@coasys/ad4m-connect 0.13.0-test-2 → 0.13.0-test-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/components/icons/CheckCircleIcon.d.ts +1 -0
  2. package/dist/components/icons/TickIcon.d.ts +1 -0
  3. package/dist/components/shared/Ad4mLogo.d.ts +1 -0
  4. package/dist/components/shared/AppLogo.d.ts +1 -0
  5. package/dist/components/shared/Header.d.ts +1 -0
  6. package/dist/components/shared/Logo.d.ts +1 -0
  7. package/dist/components/states/ErrorState.d.ts +6 -0
  8. package/dist/components/views/ConnectionOverview.d.ts +22 -0
  9. package/dist/components/views/Hosting.d.ts +22 -0
  10. package/dist/components/views/MultiUserAuth.d.ts +26 -0
  11. package/dist/components/views/RemoteConnection.d.ts +19 -0
  12. package/dist/components/views/RequestCapability.d.ts +16 -0
  13. package/dist/components/views/ScanQRCode.d.ts +14 -0
  14. package/dist/components/views/Settings.d.ts +19 -0
  15. package/dist/components/views/Start.d.ts +19 -0
  16. package/dist/components/views/old/Hosting.d.ts +22 -0
  17. package/dist/components/views/old/MultiUserAuth.d.ts +26 -0
  18. package/dist/components/views/old/RemoteConnection.d.ts +19 -0
  19. package/dist/components/views/old/RequestCapability.d.ts +16 -0
  20. package/dist/components/views/old/ScanQRCode.d.ts +14 -0
  21. package/dist/components/views/old/Settings.d.ts +19 -0
  22. package/dist/components/views/old/Start.d.ts +19 -0
  23. package/dist/core.d.ts +3 -7
  24. package/dist/core.js +132 -1703
  25. package/dist/index.js +305 -1876
  26. package/dist/old/components/InvalidToken.d.ts +0 -0
  27. package/dist/old/components/VerifyCode.d.ts +0 -0
  28. package/dist/old/core.d.ts +0 -0
  29. package/dist/old/electron.d.ts +0 -0
  30. package/dist/old/state/ConnectState.d.ts +0 -0
  31. package/dist/old/state/index.d.ts +0 -0
  32. package/dist/old/utils.d.ts +0 -0
  33. package/dist/old/views/Hosting.d.ts +0 -0
  34. package/dist/old/views/MultiUserAuth.d.ts +0 -0
  35. package/dist/old/views/RemoteConnection.d.ts +0 -0
  36. package/dist/old/views/RequestCapability.d.ts +0 -0
  37. package/dist/old/views/ScanQRCode.d.ts +0 -0
  38. package/dist/old/views/Settings.d.ts +0 -0
  39. package/dist/old/views/Start.d.ts +0 -0
  40. package/dist/old/web.d.ts +0 -0
  41. package/dist/services/hostIndex.d.ts +2 -2
  42. package/dist/state/ConnectState.d.ts +101 -0
  43. package/dist/state/index.d.ts +2 -0
  44. package/dist/utils.d.ts +4 -1
  45. package/dist/utils.js +1 -1
  46. package/dist/web.js +269 -1828
  47. package/package.json +21 -19
package/dist/index.js CHANGED
@@ -1,1787 +1,216 @@
1
- var Kp=Object.defineProperty,Yg=Object.defineProperties,Xg=Object.getOwnPropertyDescriptor,ey=Object.getOwnPropertyDescriptors;var Wp=Object.getOwnPropertySymbols,ty=Object.getPrototypeOf,ry=Object.prototype.hasOwnProperty,iy=Object.prototype.propertyIsEnumerable,ny=Reflect.get;var Gp=(r,e,t)=>e in r?Kp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Jp=(r,e)=>{for(var t in e||={})ry.call(e,t)&&Gp(r,t,e[t]);if(Wp)for(var t of Wp(e))iy.call(e,t)&&Gp(r,t,e[t]);return r},Zp=(r,e)=>Yg(r,ey(e));var F=(r,e,t,i)=>{for(var n=i>1?void 0:i?Xg(e,t):e,a=r.length-1,o;a>=0;a--)(o=r[a])&&(n=(i?o(e,t,n):o(n))||n);return i&&n&&Kp(e,t,n),n};var Yp=(r,e,t)=>ny(ty(r),t,e);var V=(r,e,t)=>new Promise((i,n)=>{var a=c=>{try{s(t.next(c))}catch(l){n(l)}},o=c=>{try{s(t.throw(c))}catch(l){n(l)}},s=c=>c.done?i(c.value):Promise.resolve(c.value).then(a,o);s((t=t.apply(r,e)).next())});var cl=function(r,e){return cl=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])},cl(r,e)};function Pe(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");cl(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var E=function(){return E=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},E.apply(this,arguments)};function cr(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(r,i[n])&&(t[i[n]]=r[i[n]]);return t}function Xt(r,e,t,i){function n(a){return a instanceof t?a:new t(function(o){o(a)})}return new(t||(t=Promise))(function(a,o){function s(u){try{l(i.next(u))}catch(d){o(d)}}function c(u){try{l(i.throw(u))}catch(d){o(d)}}function l(u){u.done?a(u.value):n(u.value).then(s,c)}l((i=i.apply(r,e||[])).next())})}function er(r,e){var t={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},i,n,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(l){return function(u){return c([l,u])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(t=0)),t;)try{if(i=1,n&&(a=l[0]&2?n.return:l[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,l[1])).done)return a;switch(n=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return t.label++,{value:l[1],done:!1};case 5:t.label++,n=l[1],l=[0];continue;case 7:l=t.ops.pop(),t.trys.pop();continue;default:if(a=t.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){t=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){t.label=l[1];break}if(l[0]===6&&t.label<a[1]){t.label=a[1],a=l;break}if(a&&t.label<a[2]){t.label=a[2],t.ops.push(l);break}a[2]&&t.ops.pop(),t.trys.pop();continue}l=e.call(r,t)}catch(u){l=[6,u],n=0}finally{i=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function Vr(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,a;i<n;i++)(a||!(i in e))&&(a||(a=Array.prototype.slice.call(e,0,i)),a[i]=e[i]);return r.concat(a||Array.prototype.slice.call(e))}var ll="Invariant Violation",Xp=Object.setPrototypeOf,ay=Xp===void 0?function(r,e){return r.__proto__=e,r}:Xp,ee=function(r){Pe(e,r);function e(t){t===void 0&&(t=ll);var i=r.call(this,typeof t=="number"?ll+": "+t+" (see https://github.com/apollographql/invariant-packages)":t)||this;return i.framesToPop=1,i.name=ll,ay(i,e.prototype),i}return e}(Error);function D(r,e){if(!r)throw new ee(e)}var is=["debug","log","warn","error","silent"],ul=is.indexOf("log");function rs(r){return function(){if(is.indexOf(r)>=ul){var e=console[r]||console.log;return e.apply(console,arguments)}}}(function(r){r.debug=rs("debug"),r.log=rs("log"),r.warn=rs("warn"),r.error=rs("error")})(D||(D={}));function ed(r){var e=is[ul];return ul=Math.max(0,is.indexOf(r)),e}function Je(r){try{return r()}catch{}}var ns=Je(function(){return globalThis})||Je(function(){return window})||Je(function(){return self})||Je(function(){return global})||Je(function(){return Je.constructor("return this")()});var td="__",rd=[td,td].join("DEV");function oy(){try{return Boolean(__DEV__)}catch{return Object.defineProperty(ns,rd,{value:Je(function(){return"production"})!=="production",enumerable:!1,configurable:!0,writable:!0}),ns[rd]}}var Ii=oy();function Qr(r){try{return r()}catch{}}var pl=Qr(function(){return globalThis})||Qr(function(){return window})||Qr(function(){return self})||Qr(function(){return global})||Qr(function(){return Qr.constructor("return this")()}),dl=!1;function sy(){pl&&!Qr(function(){return"production"})&&!Qr(function(){return process})&&(Object.defineProperty(pl,"process",{value:{env:{NODE_ENV:"production"}},configurable:!0,enumerable:!1,writable:!0}),dl=!0)}sy();function fl(){dl&&(delete pl.process,dl=!1)}var g_=typeof Symbol=="function"&&Symbol.iterator!=null?Symbol.iterator:"@@iterator",y_=typeof Symbol=="function"&&Symbol.asyncIterator!=null?Symbol.asyncIterator:"@@asyncIterator",id=typeof Symbol=="function"&&Symbol.toStringTag!=null?Symbol.toStringTag:"@@toStringTag";var je=Object.freeze({NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",VARIABLE_DEFINITION:"VariableDefinition",SELECTION_SET:"SelectionSet",FIELD:"Field",ARGUMENT:"Argument",FRAGMENT_SPREAD:"FragmentSpread",INLINE_FRAGMENT:"InlineFragment",FRAGMENT_DEFINITION:"FragmentDefinition",VARIABLE:"Variable",INT:"IntValue",FLOAT:"FloatValue",STRING:"StringValue",BOOLEAN:"BooleanValue",NULL:"NullValue",ENUM:"EnumValue",LIST:"ListValue",OBJECT:"ObjectValue",OBJECT_FIELD:"ObjectField",DIRECTIVE:"Directive",NAMED_TYPE:"NamedType",LIST_TYPE:"ListType",NON_NULL_TYPE:"NonNullType",SCHEMA_DEFINITION:"SchemaDefinition",OPERATION_TYPE_DEFINITION:"OperationTypeDefinition",SCALAR_TYPE_DEFINITION:"ScalarTypeDefinition",OBJECT_TYPE_DEFINITION:"ObjectTypeDefinition",FIELD_DEFINITION:"FieldDefinition",INPUT_VALUE_DEFINITION:"InputValueDefinition",INTERFACE_TYPE_DEFINITION:"InterfaceTypeDefinition",UNION_TYPE_DEFINITION:"UnionTypeDefinition",ENUM_TYPE_DEFINITION:"EnumTypeDefinition",ENUM_VALUE_DEFINITION:"EnumValueDefinition",INPUT_OBJECT_TYPE_DEFINITION:"InputObjectTypeDefinition",DIRECTIVE_DEFINITION:"DirectiveDefinition",SCHEMA_EXTENSION:"SchemaExtension",SCALAR_TYPE_EXTENSION:"ScalarTypeExtension",OBJECT_TYPE_EXTENSION:"ObjectTypeExtension",INTERFACE_TYPE_EXTENSION:"InterfaceTypeExtension",UNION_TYPE_EXTENSION:"UnionTypeExtension",ENUM_TYPE_EXTENSION:"EnumTypeExtension",INPUT_OBJECT_TYPE_EXTENSION:"InputObjectTypeExtension"});function hl(r,e){var t=Boolean(r);if(!t)throw new Error(e??"Unexpected invariant triggered.")}var cy=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):void 0,ka=cy;function as(r){var e=r.prototype.toJSON;typeof e=="function"||hl(0),r.prototype.inspect=e,ka&&(r.prototype[ka]=e)}var nd=function(){function r(t,i,n){this.start=t.start,this.end=i.end,this.startToken=t,this.endToken=i,this.source=n}var e=r.prototype;return e.toJSON=function(){return{start:this.start,end:this.end}},r}();as(nd);var ad=function(){function r(t,i,n,a,o,s,c){this.kind=t,this.start=i,this.end=n,this.line=a,this.column=o,this.value=c,this.prev=s,this.next=null}var e=r.prototype;return e.toJSON=function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}},r}();as(ad);function ml(r){return r!=null&&typeof r.kind=="string"}function os(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?os=function(t){return typeof t}:os=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},os(r)}var ly=10,od=2;function Aa(r){return ss(r,[])}function ss(r,e){switch(os(r)){case"string":return JSON.stringify(r);case"function":return r.name?"[function ".concat(r.name,"]"):"[function]";case"object":return r===null?"null":uy(r,e);default:return String(r)}}function uy(r,e){if(e.indexOf(r)!==-1)return"[Circular]";var t=[].concat(e,[r]),i=fy(r);if(i!==void 0){var n=i.call(r);if(n!==r)return typeof n=="string"?n:ss(n,t)}else if(Array.isArray(r))return dy(r,t);return py(r,t)}function py(r,e){var t=Object.keys(r);if(t.length===0)return"{}";if(e.length>od)return"["+hy(r)+"]";var i=t.map(function(n){var a=ss(r[n],e);return n+": "+a});return"{ "+i.join(", ")+" }"}function dy(r,e){if(r.length===0)return"[]";if(e.length>od)return"[Array]";for(var t=Math.min(ly,r.length),i=r.length-t,n=[],a=0;a<t;++a)n.push(ss(r[a],e));return i===1?n.push("... 1 more item"):i>1&&n.push("... ".concat(i," more items")),"["+n.join(", ")+"]"}function fy(r){var e=r[String(ka)];if(typeof e=="function")return e;if(typeof r.inspect=="function")return r.inspect}function hy(r){var e=Object.prototype.toString.call(r).replace(/^\[object /,"").replace(/]$/,"");if(e==="Object"&&typeof r.constructor=="function"){var t=r.constructor.name;if(typeof t=="string"&&t!=="")return t}return e}function Ia(r,e){var t=Boolean(r);if(!t)throw new Error(e)}function sd(r,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(r,i.key,i)}}function my(r,e,t){return e&&sd(r.prototype,e),t&&sd(r,t),r}var cs=function(){function r(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GraphQL request",i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{line:1,column:1};typeof e=="string"||Ia(0,"Body must be a string. Received: ".concat(Aa(e),".")),this.body=e,this.name=t,this.locationOffset=i,this.locationOffset.line>0||Ia(0,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||Ia(0,"column in locationOffset is 1-indexed and must be positive.")}return my(r,[{key:id,get:function(){return"Source"}}]),r}();function cd(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,i=r.indexOf(`
2
- `)===-1,n=r[0]===" "||r[0]===" ",a=r[r.length-1]==='"',o=r[r.length-1]==="\\",s=!i||a||o||t,c="";return s&&!(i&&n)&&(c+=`
3
- `+e),c+=e?r.replace(/\n/g,`
4
- `+e):r,s&&(c+=`
5
- `),'"""'+c.replace(/"""/g,'\\"""')+'"""'}var gy={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},Ti=Object.freeze({});function st(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:gy,i=void 0,n=Array.isArray(r),a=[r],o=-1,s=[],c=void 0,l=void 0,u=void 0,d=[],f=[],p=r;do{o++;var h=o===a.length,m=h&&s.length!==0;if(h){if(l=f.length===0?void 0:d[d.length-1],c=u,u=f.pop(),m){if(n)c=c.slice();else{for(var y={},b=0,_=Object.keys(c);b<_.length;b++){var S=_[b];y[S]=c[S]}c=y}for(var v=0,C=0;C<s.length;C++){var $=s[C][0],I=s[C][1];n&&($-=v),n&&I===null?(c.splice($,1),v++):c[$]=I}}o=i.index,a=i.keys,s=i.edits,n=i.inArray,i=i.prev}else{if(l=u?n?o:a[o]:void 0,c=u?u[l]:p,c==null)continue;u&&d.push(l)}var L=void 0;if(!Array.isArray(c)){if(!ml(c))throw new Error("Invalid AST Node: ".concat(Aa(c),"."));var M=gl(e,c.kind,h);if(M){if(L=M.call(e,c,l,u,d,f),L===Ti)break;if(L===!1){if(!h){d.pop();continue}}else if(L!==void 0&&(s.push([l,L]),!h))if(ml(L))c=L;else{d.pop();continue}}}if(L===void 0&&m&&s.push([l,c]),h)d.pop();else{var N;i={inArray:n,index:o,keys:a,edits:s,prev:i},n=Array.isArray(c),a=n?c:(N=t[c.kind])!==null&&N!==void 0?N:[],o=-1,s=[],u&&f.push(u),u=c}}while(i!==void 0);return s.length!==0&&(p=s[s.length-1][1]),p}function gl(r,e,t){var i=r[e];if(i){if(!t&&typeof i=="function")return i;var n=t?i.leave:i.enter;if(typeof n=="function")return n}else{var a=t?r.leave:r.enter;if(a){if(typeof a=="function")return a;var o=a[e];if(typeof o=="function")return o}}}function $n(r){return st(r,{leave:vy})}var yy=80,vy={Name:function(e){return e.value},Variable:function(e){return"$"+e.name},Document:function(e){return j(e.definitions,`
6
-
7
- `)+`
8
- `},OperationDefinition:function(e){var t=e.operation,i=e.name,n=$e("(",j(e.variableDefinitions,", "),")"),a=j(e.directives," "),o=e.selectionSet;return!i&&!a&&!n&&t==="query"?o:j([t,j([i,n]),a,o]," ")},VariableDefinition:function(e){var t=e.variable,i=e.type,n=e.defaultValue,a=e.directives;return t+": "+i+$e(" = ",n)+$e(" ",j(a," "))},SelectionSet:function(e){var t=e.selections;return rr(t)},Field:function(e){var t=e.alias,i=e.name,n=e.arguments,a=e.directives,o=e.selectionSet,s=$e("",t,": ")+i,c=s+$e("(",j(n,", "),")");return c.length>yy&&(c=s+$e(`(
9
- `,ls(j(n,`
10
- `)),`
11
- )`)),j([c,j(a," "),o]," ")},Argument:function(e){var t=e.name,i=e.value;return t+": "+i},FragmentSpread:function(e){var t=e.name,i=e.directives;return"..."+t+$e(" ",j(i," "))},InlineFragment:function(e){var t=e.typeCondition,i=e.directives,n=e.selectionSet;return j(["...",$e("on ",t),j(i," "),n]," ")},FragmentDefinition:function(e){var t=e.name,i=e.typeCondition,n=e.variableDefinitions,a=e.directives,o=e.selectionSet;return"fragment ".concat(t).concat($e("(",j(n,", "),")")," ")+"on ".concat(i," ").concat($e("",j(a," ")," "))+o},IntValue:function(e){var t=e.value;return t},FloatValue:function(e){var t=e.value;return t},StringValue:function(e,t){var i=e.value,n=e.block;return n?cd(i,t==="description"?"":" "):JSON.stringify(i)},BooleanValue:function(e){var t=e.value;return t?"true":"false"},NullValue:function(){return"null"},EnumValue:function(e){var t=e.value;return t},ListValue:function(e){var t=e.values;return"["+j(t,", ")+"]"},ObjectValue:function(e){var t=e.fields;return"{"+j(t,", ")+"}"},ObjectField:function(e){var t=e.name,i=e.value;return t+": "+i},Directive:function(e){var t=e.name,i=e.arguments;return"@"+t+$e("(",j(i,", "),")")},NamedType:function(e){var t=e.name;return t},ListType:function(e){var t=e.type;return"["+t+"]"},NonNullType:function(e){var t=e.type;return t+"!"},SchemaDefinition:tr(function(r){var e=r.directives,t=r.operationTypes;return j(["schema",j(e," "),rr(t)]," ")}),OperationTypeDefinition:function(e){var t=e.operation,i=e.type;return t+": "+i},ScalarTypeDefinition:tr(function(r){var e=r.name,t=r.directives;return j(["scalar",e,j(t," ")]," ")}),ObjectTypeDefinition:tr(function(r){var e=r.name,t=r.interfaces,i=r.directives,n=r.fields;return j(["type",e,$e("implements ",j(t," & ")),j(i," "),rr(n)]," ")}),FieldDefinition:tr(function(r){var e=r.name,t=r.arguments,i=r.type,n=r.directives;return e+(ld(t)?$e(`(
12
- `,ls(j(t,`
13
- `)),`
14
- )`):$e("(",j(t,", "),")"))+": "+i+$e(" ",j(n," "))}),InputValueDefinition:tr(function(r){var e=r.name,t=r.type,i=r.defaultValue,n=r.directives;return j([e+": "+t,$e("= ",i),j(n," ")]," ")}),InterfaceTypeDefinition:tr(function(r){var e=r.name,t=r.interfaces,i=r.directives,n=r.fields;return j(["interface",e,$e("implements ",j(t," & ")),j(i," "),rr(n)]," ")}),UnionTypeDefinition:tr(function(r){var e=r.name,t=r.directives,i=r.types;return j(["union",e,j(t," "),i&&i.length!==0?"= "+j(i," | "):""]," ")}),EnumTypeDefinition:tr(function(r){var e=r.name,t=r.directives,i=r.values;return j(["enum",e,j(t," "),rr(i)]," ")}),EnumValueDefinition:tr(function(r){var e=r.name,t=r.directives;return j([e,j(t," ")]," ")}),InputObjectTypeDefinition:tr(function(r){var e=r.name,t=r.directives,i=r.fields;return j(["input",e,j(t," "),rr(i)]," ")}),DirectiveDefinition:tr(function(r){var e=r.name,t=r.arguments,i=r.repeatable,n=r.locations;return"directive @"+e+(ld(t)?$e(`(
15
- `,ls(j(t,`
16
- `)),`
17
- )`):$e("(",j(t,", "),")"))+(i?" repeatable":"")+" on "+j(n," | ")}),SchemaExtension:function(e){var t=e.directives,i=e.operationTypes;return j(["extend schema",j(t," "),rr(i)]," ")},ScalarTypeExtension:function(e){var t=e.name,i=e.directives;return j(["extend scalar",t,j(i," ")]," ")},ObjectTypeExtension:function(e){var t=e.name,i=e.interfaces,n=e.directives,a=e.fields;return j(["extend type",t,$e("implements ",j(i," & ")),j(n," "),rr(a)]," ")},InterfaceTypeExtension:function(e){var t=e.name,i=e.interfaces,n=e.directives,a=e.fields;return j(["extend interface",t,$e("implements ",j(i," & ")),j(n," "),rr(a)]," ")},UnionTypeExtension:function(e){var t=e.name,i=e.directives,n=e.types;return j(["extend union",t,j(i," "),n&&n.length!==0?"= "+j(n," | "):""]," ")},EnumTypeExtension:function(e){var t=e.name,i=e.directives,n=e.values;return j(["extend enum",t,j(i," "),rr(n)]," ")},InputObjectTypeExtension:function(e){var t=e.name,i=e.directives,n=e.fields;return j(["extend input",t,j(i," "),rr(n)]," ")}};function tr(r){return function(e){return j([e.description,r(e)],`
18
- `)}}function j(r){var e,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";return(e=r?.filter(function(i){return i}).join(t))!==null&&e!==void 0?e:""}function rr(r){return $e(`{
19
- `,ls(j(r,`
20
- `)),`
21
- }`)}function $e(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"";return e!=null&&e!==""?r+e+t:""}function ls(r){return $e(" ",r.replace(/\n/g,`
22
- `))}function by(r){return r.indexOf(`
23
- `)!==-1}function ld(r){return r!=null&&r.some(by)}function Ta(r){return r.kind===je.FIELD||r.kind===je.FRAGMENT_SPREAD||r.kind===je.INLINE_FRAGMENT}function ud(){return typeof cs=="function"?fl():fl()}function Cy(){__DEV__?D(typeof Ii=="boolean",Ii):D(typeof Ii=="boolean",39)}ud();Cy();function kr(r,e){var t=r.directives;return!t||!t.length?!0:pd(t).every(function(i){var n=i.directive,a=i.ifArgument,o=!1;return a.value.kind==="Variable"?(o=e&&e[a.value.name.value],__DEV__?D(o!==void 0,"Invalid variable referenced in @".concat(n.name.value," directive.")):D(o!==void 0,40)):o=a.value.value,n.name.value==="skip"?!o:o})}function Pn(r,e,t){var i=new Set(r),n=i.size;return st(e,{Directive:function(a){if(i.delete(a.name.value)&&(!t||!i.size))return Ti}}),t?!i.size:i.size<n}function yl(r){return r&&Pn(["client","export"],r,!0)}function Oy(r){var e=r.name.value;return e==="skip"||e==="include"}function pd(r){var e=[];return r&&r.length&&r.forEach(function(t){if(!!Oy(t)){var i=t.arguments,n=t.name.value;__DEV__?D(i&&i.length===1,"Incorrect number of arguments for the @".concat(n," directive.")):D(i&&i.length===1,41);var a=i[0];__DEV__?D(a.name&&a.name.value==="if","Invalid argument for the @".concat(n," directive.")):D(a.name&&a.name.value==="if",42);var o=a.value;__DEV__?D(o&&(o.kind==="Variable"||o.kind==="BooleanValue"),"Argument for the @".concat(n," directive must be a variable or a boolean value.")):D(o&&(o.kind==="Variable"||o.kind==="BooleanValue"),43),e.push({directive:t,ifArgument:a})}}),e}function vl(r,e){var t=e,i=[];r.definitions.forEach(function(a){if(a.kind==="OperationDefinition")throw __DEV__?new ee("Found a ".concat(a.operation," operation").concat(a.name?" named '".concat(a.name.value,"'"):"",". ")+"No operations are allowed when using a fragment as a query. Only fragments are allowed."):new ee(44);a.kind==="FragmentDefinition"&&i.push(a)}),typeof t>"u"&&(__DEV__?D(i.length===1,"Found ".concat(i.length," fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")):D(i.length===1,45),t=i[0].name.value);var n=E(E({},r),{definitions:Vr([{kind:"OperationDefinition",operation:"query",selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:t}}]}}],r.definitions,!0)});return n}function Ci(r){r===void 0&&(r=[]);var e={};return r.forEach(function(t){e[t.name.value]=t}),e}function Oi(r,e){switch(r.kind){case"InlineFragment":return r;case"FragmentSpread":{var t=r.name.value;if(typeof e=="function")return e(t);var i=e&&e[t];return __DEV__?D(i,"No fragment named ".concat(t)):D(i,46),i||null}default:return null}}function he(r){return r!==null&&typeof r=="object"}function lr(r){return{__ref:String(r)}}function le(r){return Boolean(r&&typeof r=="object"&&typeof r.__ref=="string")}function bl(r){return he(r)&&r.kind==="Document"&&Array.isArray(r.definitions)}function $y(r){return r.kind==="StringValue"}function Py(r){return r.kind==="BooleanValue"}function Ry(r){return r.kind==="IntValue"}function Ly(r){return r.kind==="FloatValue"}function Ny(r){return r.kind==="Variable"}function Dy(r){return r.kind==="ObjectValue"}function Fy(r){return r.kind==="ListValue"}function My(r){return r.kind==="EnumValue"}function Uy(r){return r.kind==="NullValue"}function Hr(r,e,t,i){if(Ry(t)||Ly(t))r[e.value]=Number(t.value);else if(Py(t)||$y(t))r[e.value]=t.value;else if(Dy(t)){var n={};t.fields.map(function(o){return Hr(n,o.name,o.value,i)}),r[e.value]=n}else if(Ny(t)){var a=(i||{})[t.name.value];r[e.value]=a}else if(Fy(t))r[e.value]=t.values.map(function(o){var s={};return Hr(s,e,o,i),s[e.value]});else if(My(t))r[e.value]=t.value;else if(Uy(t))r[e.value]=null;else throw __DEV__?new ee('The inline argument "'.concat(e.value,'" of kind "').concat(t.kind,'"')+"is not supported. Use variables instead of inline arguments to overcome this limitation."):new ee(55)}function wl(r,e){var t=null;r.directives&&(t={},r.directives.forEach(function(n){t[n.name.value]={},n.arguments&&n.arguments.forEach(function(a){var o=a.name,s=a.value;return Hr(t[n.name.value],o,s,e)})}));var i=null;return r.arguments&&r.arguments.length&&(i={},r.arguments.forEach(function(n){var a=n.name,o=n.value;return Hr(i,a,o,e)})),Oa(r.name.value,i,t)}var jy=["connection","include","skip","client","rest","export"],Oa=Object.assign(function(r,e,t){if(e&&t&&t.connection&&t.connection.key)if(t.connection.filter&&t.connection.filter.length>0){var i=t.connection.filter?t.connection.filter:[];i.sort();var n={};return i.forEach(function(s){n[s]=e[s]}),"".concat(t.connection.key,"(").concat(Ca(n),")")}else return t.connection.key;var a=r;if(e){var o=Ca(e);a+="(".concat(o,")")}return t&&Object.keys(t).forEach(function(s){jy.indexOf(s)===-1&&(t[s]&&Object.keys(t[s]).length?a+="@".concat(s,"(").concat(Ca(t[s]),")"):a+="@".concat(s))}),a},{setStringify:function(r){var e=Ca;return Ca=r,e}}),Ca=function(e){return JSON.stringify(e,qy)};function qy(r,e){return he(e)&&!Array.isArray(e)&&(e=Object.keys(e).sort().reduce(function(t,i){return t[i]=e[i],t},{})),e}function Ar(r,e){if(r.arguments&&r.arguments.length){var t={};return r.arguments.forEach(function(i){var n=i.name,a=i.value;return Hr(t,n,a,e)}),t}return null}function qt(r){return r.alias?r.alias.value:r.name.value}function $a(r,e,t){if(typeof r.__typename=="string")return r.__typename;for(var i=0,n=e.selections;i<n.length;i++){var a=n[i];if(Pt(a)){if(a.name.value==="__typename")return r[qt(a)]}else{var o=$a(r,Oi(a,t).selectionSet,t);if(typeof o=="string")return o}}}function Pt(r){return r.kind==="Field"}function Sl(r){return r.kind==="InlineFragment"}function Rn(r){__DEV__?D(r&&r.kind==="Document",'Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql'):D(r&&r.kind==="Document",47);var e=r.definitions.filter(function(t){return t.kind!=="FragmentDefinition"}).map(function(t){if(t.kind!=="OperationDefinition")throw __DEV__?new ee('Schema type definitions not allowed in queries. Found: "'.concat(t.kind,'"')):new ee(48);return t});return __DEV__?D(e.length<=1,"Ambiguous GraphQL document: contains ".concat(e.length," operations")):D(e.length<=1,49),r}function ur(r){return Rn(r),r.definitions.filter(function(e){return e.kind==="OperationDefinition"})[0]}function Ln(r){return r.definitions.filter(function(e){return e.kind==="OperationDefinition"&&!!e.name}).map(function(e){return e.name.value})[0]||null}function $i(r){return r.definitions.filter(function(e){return e.kind==="FragmentDefinition"})}function Pa(r){var e=ur(r);return __DEV__?D(e&&e.operation==="query","Must contain a query definition."):D(e&&e.operation==="query",50),e}function _l(r){__DEV__?D(r.kind==="Document",'Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql'):D(r.kind==="Document",51),__DEV__?D(r.definitions.length<=1,"Fragment must have exactly one definition."):D(r.definitions.length<=1,52);var e=r.definitions[0];return __DEV__?D(e.kind==="FragmentDefinition","Must be a fragment definition."):D(e.kind==="FragmentDefinition",53),e}function Pi(r){Rn(r);for(var e,t=0,i=r.definitions;t<i.length;t++){var n=i[t];if(n.kind==="OperationDefinition"){var a=n.operation;if(a==="query"||a==="mutation"||a==="subscription")return n}n.kind==="FragmentDefinition"&&!e&&(e=n)}if(e)return e;throw __DEV__?new ee("Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment."):new ee(54)}function Ri(r){var e=Object.create(null),t=r&&r.variableDefinitions;return t&&t.length&&t.forEach(function(i){i.defaultValue&&Hr(e,i.variable.name,i.defaultValue)}),e}var be=Array.isArray;function Ve(r){return Array.isArray(r)&&r.length>0}var dd={kind:je.FIELD,name:{kind:je.NAME,value:"__typename"}};function hd(r,e){return!r||r.selectionSet.selections.every(function(t){return t.kind===je.FRAGMENT_SPREAD&&hd(e[t.name.value],e)})}function By(r){return hd(ur(r)||_l(r),Ci($i(r)))?null:r}function Vy(r){var e=new Set,t=[];return r.forEach(function(i){i.name?e.add(i.name):i.test&&t.push(i.test)}),function(i){return e.has(i.name.value)||t.some(function(n){return n(i)})}}function fd(r){var e=new Map;return function(i){i===void 0&&(i=r);var n=e.get(i);return n||e.set(i,n={variables:new Set,fragmentSpreads:new Set}),n}}function xl(r,e){for(var t=fd(""),i=fd(""),n=function(_){for(var S=0,v=void 0;S<_.length&&(v=_[S]);++S)if(!be(v)){if(v.kind===je.OPERATION_DEFINITION)return t(v.name&&v.name.value);if(v.kind===je.FRAGMENT_DEFINITION)return i(v.name.value)}return __DEV__&&D.error("Could not find operation or fragment"),null},a=0,o=e.definitions.length-1;o>=0;--o)e.definitions[o].kind===je.OPERATION_DEFINITION&&++a;var s=Vy(r),c=r.some(function(_){return _.remove}),l=function(_){return c&&_&&_.some(s)},u=new Map,d=!1,f={enter:function(_){if(l(_.directives))return d=!0,null}},p=st(e,{Field:f,InlineFragment:f,VariableDefinition:{enter:function(){return!1}},Variable:{enter:function(_,S,v,C,$){var I=n($);I&&I.variables.add(_.name.value)}},FragmentSpread:{enter:function(_,S,v,C,$){if(l(_.directives))return d=!0,null;var I=n($);I&&I.fragmentSpreads.add(_.name.value)}},FragmentDefinition:{enter:function(_,S,v,C){u.set(JSON.stringify(C),_)},leave:function(_,S,v,C){var $=u.get(JSON.stringify(C));if(_===$)return _;if(a>0&&_.selectionSet.selections.every(function(I){return I.kind===je.FIELD&&I.name.value==="__typename"}))return i(_.name.value).removed=!0,d=!0,null}},Directive:{leave:function(_){if(s(_))return d=!0,null}}});if(!d)return e;var h=function(_){return _.transitiveVars||(_.transitiveVars=new Set(_.variables),_.removed||_.fragmentSpreads.forEach(function(S){h(i(S)).transitiveVars.forEach(function(v){_.transitiveVars.add(v)})})),_},m=new Set;p.definitions.forEach(function(_){_.kind===je.OPERATION_DEFINITION?h(t(_.name&&_.name.value)).fragmentSpreads.forEach(function(S){m.add(S)}):_.kind===je.FRAGMENT_DEFINITION&&a===0&&!i(_.name.value).removed&&m.add(_.name.value)}),m.forEach(function(_){h(i(_)).fragmentSpreads.forEach(function(S){m.add(S)})});var y=function(_){return!!(!m.has(_)||i(_).removed)},b={enter:function(_){if(y(_.name.value))return null}};return By(st(p,{FragmentSpread:b,FragmentDefinition:b,OperationDefinition:{leave:function(_){if(_.variableDefinitions){var S=h(t(_.name&&_.name.value)).transitiveVars;if(S.size<_.variableDefinitions.length)return E(E({},_),{variableDefinitions:_.variableDefinitions.filter(function(v){return S.has(v.variable.name.value)})})}}}}))}var Li=Object.assign(function(r){return st(r,{SelectionSet:{enter:function(e,t,i){if(!(i&&i.kind===je.OPERATION_DEFINITION)){var n=e.selections;if(!!n){var a=n.some(function(s){return Pt(s)&&(s.name.value==="__typename"||s.name.value.lastIndexOf("__",0)===0)});if(!a){var o=i;if(!(Pt(o)&&o.directives&&o.directives.some(function(s){return s.name.value==="export"})))return E(E({},e),{selections:Vr(Vr([],n,!0),[dd],!1)})}}}}}})},{added:function(r){return r===dd}}),Qy={test:function(r){var e=r.name.value==="connection";return e&&(!r.arguments||!r.arguments.some(function(t){return t.name.value==="key"}))&&__DEV__&&D.warn("Removing an @connection directive even though it does not have a key. You may want to use the key parameter to specify a store key."),e}};function El(r){return xl([Qy],Rn(r))}function kl(r){var e=Pi(r),t=e.operation;if(t==="query")return r;var i=st(r,{OperationDefinition:{enter:function(n){return E(E({},n),{operation:"query"})}}});return i}function Al(r){Rn(r);var e=xl([{test:function(t){return t.name.value==="client"},remove:!0}],r);return e}var Hy=Object.prototype.hasOwnProperty;function Il(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return Ra(r)}function Ra(r){var e=r[0]||{},t=r.length;if(t>1)for(var i=new _t,n=1;n<t;++n)e=i.merge(e,r[n]);return e}var zy=function(r,e,t){return this.merge(r[t],e[t])},_t=function(){function r(e){e===void 0&&(e=zy),this.reconciler=e,this.isObject=he,this.pastCopies=new Set}return r.prototype.merge=function(e,t){for(var i=this,n=[],a=2;a<arguments.length;a++)n[a-2]=arguments[a];return he(t)&&he(e)?(Object.keys(t).forEach(function(o){if(Hy.call(e,o)){var s=e[o];if(t[o]!==s){var c=i.reconciler.apply(i,Vr([e,t,o],n,!1));c!==s&&(e=i.shallowCopyForMerge(e),e[o]=c)}}else e=i.shallowCopyForMerge(e),e[o]=t[o]}),e):t},r.prototype.shallowCopyForMerge=function(e){return he(e)&&(this.pastCopies.has(e)||(Array.isArray(e)?e=e.slice(0):e=E({__proto__:Object.getPrototypeOf(e)},e),this.pastCopies.add(e))),e},r}();function Wy(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t)return(t=t.call(r)).next.bind(t);if(Array.isArray(r)||(t=Gy(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var i=0;return function(){return i>=r.length?{done:!0}:{done:!1,value:r[i++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
24
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Gy(r,e){if(!!r){if(typeof r=="string")return md(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return md(r,e)}}function md(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,i=new Array(e);t<e;t++)i[t]=r[t];return i}function gd(r,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(r,i.key,i)}}function $l(r,e,t){return e&&gd(r.prototype,e),t&&gd(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}var Pl=function(){return typeof Symbol=="function"},Rl=function(r){return Pl()&&Boolean(Symbol[r])},Ll=function(r){return Rl(r)?Symbol[r]:"@@"+r};Pl()&&!Rl("observable")&&(Symbol.observable=Symbol("observable"));var Ky=Ll("iterator"),Cl=Ll("observable"),yd=Ll("species");function ps(r,e){var t=r[e];if(t!=null){if(typeof t!="function")throw new TypeError(t+" is not a function");return t}}function La(r){var e=r.constructor;return e!==void 0&&(e=e[yd],e===null&&(e=void 0)),e!==void 0?e:se}function Jy(r){return r instanceof se}function Nn(r){Nn.log?Nn.log(r):setTimeout(function(){throw r})}function us(r){Promise.resolve().then(function(){try{r()}catch(e){Nn(e)}})}function vd(r){var e=r._cleanup;if(e!==void 0&&(r._cleanup=void 0,!!e))try{if(typeof e=="function")e();else{var t=ps(e,"unsubscribe");t&&t.call(e)}}catch(i){Nn(i)}}function Ol(r){r._observer=void 0,r._queue=void 0,r._state="closed"}function Zy(r){var e=r._queue;if(!!e){r._queue=void 0,r._state="ready";for(var t=0;t<e.length&&(bd(r,e[t].type,e[t].value),r._state!=="closed");++t);}}function bd(r,e,t){r._state="running";var i=r._observer;try{var n=ps(i,e);switch(e){case"next":n&&n.call(i,t);break;case"error":if(Ol(r),n)n.call(i,t);else throw t;break;case"complete":Ol(r),n&&n.call(i);break}}catch(a){Nn(a)}r._state==="closed"?vd(r):r._state==="running"&&(r._state="ready")}function Tl(r,e,t){if(r._state!=="closed"){if(r._state==="buffering"){r._queue.push({type:e,value:t});return}if(r._state!=="ready"){r._state="buffering",r._queue=[{type:e,value:t}],us(function(){return Zy(r)});return}bd(r,e,t)}}var Yy=function(){function r(t,i){this._cleanup=void 0,this._observer=t,this._queue=void 0,this._state="initializing";var n=new Xy(this);try{this._cleanup=i.call(void 0,n)}catch(a){n.error(a)}this._state==="initializing"&&(this._state="ready")}var e=r.prototype;return e.unsubscribe=function(){this._state!=="closed"&&(Ol(this),vd(this))},$l(r,[{key:"closed",get:function(){return this._state==="closed"}}]),r}(),Xy=function(){function r(t){this._subscription=t}var e=r.prototype;return e.next=function(i){Tl(this._subscription,"next",i)},e.error=function(i){Tl(this._subscription,"error",i)},e.complete=function(){Tl(this._subscription,"complete")},$l(r,[{key:"closed",get:function(){return this._subscription._state==="closed"}}]),r}(),se=function(){function r(t){if(!(this instanceof r))throw new TypeError("Observable cannot be called as a function");if(typeof t!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=t}var e=r.prototype;return e.subscribe=function(i){return(typeof i!="object"||i===null)&&(i={next:i,error:arguments[1],complete:arguments[2]}),new Yy(i,this._subscriber)},e.forEach=function(i){var n=this;return new Promise(function(a,o){if(typeof i!="function"){o(new TypeError(i+" is not a function"));return}function s(){c.unsubscribe(),a()}var c=n.subscribe({next:function(l){try{i(l,s)}catch(u){o(u),c.unsubscribe()}},error:o,complete:a})})},e.map=function(i){var n=this;if(typeof i!="function")throw new TypeError(i+" is not a function");var a=La(this);return new a(function(o){return n.subscribe({next:function(s){try{s=i(s)}catch(c){return o.error(c)}o.next(s)},error:function(s){o.error(s)},complete:function(){o.complete()}})})},e.filter=function(i){var n=this;if(typeof i!="function")throw new TypeError(i+" is not a function");var a=La(this);return new a(function(o){return n.subscribe({next:function(s){try{if(!i(s))return}catch(c){return o.error(c)}o.next(s)},error:function(s){o.error(s)},complete:function(){o.complete()}})})},e.reduce=function(i){var n=this;if(typeof i!="function")throw new TypeError(i+" is not a function");var a=La(this),o=arguments.length>1,s=!1,c=arguments[1],l=c;return new a(function(u){return n.subscribe({next:function(d){var f=!s;if(s=!0,!f||o)try{l=i(l,d)}catch(p){return u.error(p)}else l=d},error:function(d){u.error(d)},complete:function(){if(!s&&!o)return u.error(new TypeError("Cannot reduce an empty sequence"));u.next(l),u.complete()}})})},e.concat=function(){for(var i=this,n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];var s=La(this);return new s(function(c){var l,u=0;function d(f){l=f.subscribe({next:function(p){c.next(p)},error:function(p){c.error(p)},complete:function(){u===a.length?(l=void 0,c.complete()):d(s.from(a[u++]))}})}return d(i),function(){l&&(l.unsubscribe(),l=void 0)}})},e.flatMap=function(i){var n=this;if(typeof i!="function")throw new TypeError(i+" is not a function");var a=La(this);return new a(function(o){var s=[],c=n.subscribe({next:function(u){if(i)try{u=i(u)}catch(f){return o.error(f)}var d=a.from(u).subscribe({next:function(f){o.next(f)},error:function(f){o.error(f)},complete:function(){var f=s.indexOf(d);f>=0&&s.splice(f,1),l()}});s.push(d)},error:function(u){o.error(u)},complete:function(){l()}});function l(){c.closed&&s.length===0&&o.complete()}return function(){s.forEach(function(u){return u.unsubscribe()}),c.unsubscribe()}})},e[Cl]=function(){return this},r.from=function(i){var n=typeof this=="function"?this:r;if(i==null)throw new TypeError(i+" is not an object");var a=ps(i,Cl);if(a){var o=a.call(i);if(Object(o)!==o)throw new TypeError(o+" is not an object");return Jy(o)&&o.constructor===n?o:new n(function(s){return o.subscribe(s)})}if(Rl("iterator")&&(a=ps(i,Ky),a))return new n(function(s){us(function(){if(!s.closed){for(var c=Wy(a.call(i)),l;!(l=c()).done;){var u=l.value;if(s.next(u),s.closed)return}s.complete()}})});if(Array.isArray(i))return new n(function(s){us(function(){if(!s.closed){for(var c=0;c<i.length;++c)if(s.next(i[c]),s.closed)return;s.complete()}})});throw new TypeError(i+" is not observable")},r.of=function(){for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];var o=typeof this=="function"?this:r;return new o(function(s){us(function(){if(!s.closed){for(var c=0;c<n.length;++c)if(s.next(n[c]),s.closed)return;s.complete()}})})},$l(r,null,[{key:yd,get:function(){return this}}]),r}();Pl()&&Object.defineProperty(se,Symbol("extensions"),{value:{symbol:Cl,hostReportError:Nn},configurable:!0});function Nl(r){var e,t=r.Symbol;if(typeof t=="function")if(t.observable)e=t.observable;else{typeof t.for=="function"?e=t.for("https://github.com/benlesh/symbol-observable"):e=t("https://github.com/benlesh/symbol-observable");try{t.observable=e}catch{}}else e="@@observable";return e}var Dn;typeof self<"u"?Dn=self:typeof window<"u"?Dn=window:typeof global<"u"?Dn=global:typeof module<"u"?Dn=module:Dn=Function("return this")();var Qx=Nl(Dn);var wd=se.prototype,Sd="@@observable";wd[Sd]||(wd[Sd]=function(){return this});var ev=Object.prototype.toString;function ds(r){return Dl(r)}function Dl(r,e){switch(ev.call(r)){case"[object Array]":{if(e=e||new Map,e.has(r))return e.get(r);var t=r.slice(0);return e.set(r,t),t.forEach(function(n,a){t[a]=Dl(n,e)}),t}case"[object Object]":{if(e=e||new Map,e.has(r))return e.get(r);var i=Object.create(Object.getPrototypeOf(r));return e.set(r,i),Object.keys(r).forEach(function(n){i[n]=Dl(r[n],e)}),i}default:return r}}function tv(r){var e=new Set([r]);return e.forEach(function(t){he(t)&&rv(t)===t&&Object.getOwnPropertyNames(t).forEach(function(i){he(t[i])&&e.add(t[i])})}),r}function rv(r){if(__DEV__&&!Object.isFrozen(r))try{Object.freeze(r)}catch(e){if(e instanceof TypeError)return null;throw e}return r}function Na(r){return __DEV__&&tv(r),r}function Ni(r,e,t){var i=[];r.forEach(function(n){return n[e]&&i.push(n)}),i.forEach(function(n){return n[e](t)})}function fs(r,e,t){return new se(function(i){var n=i.next,a=i.error,o=i.complete,s=0,c=!1,l={then:function(p){return new Promise(function(h){return h(p())})}};function u(p,h){return p?function(m){++s;var y=function(){return p(m)};l=l.then(y,y).then(function(b){--s,n&&n.call(i,b),c&&d.complete()},function(b){throw--s,b}).catch(function(b){a&&a.call(i,b)})}:function(m){return h&&h.call(i,m)}}var d={next:u(e,n),error:u(t,a),complete:function(){c=!0,s||o&&o.call(i)}},f=r.subscribe(d);return function(){return f.unsubscribe()}})}var Bt=typeof WeakMap=="function"&&Je(function(){return navigator.product})!=="ReactNative",_d=typeof WeakSet=="function",Fl=typeof Symbol=="function"&&typeof Symbol.for=="function",zr=Fl&&Symbol.asyncIterator,iE=typeof Je(function(){return window.document.createElement})=="function",nE=Je(function(){return navigator.userAgent.indexOf("jsdom")>=0})||!1;function hs(r){function e(t){Object.defineProperty(r,t,{value:se})}return Fl&&Symbol.species&&e(Symbol.species),e("@@species"),r}function xd(r){return r&&typeof r.then=="function"}var Fn=function(r){Pe(e,r);function e(t){var i=r.call(this,function(n){return i.addObserver(n),function(){return i.removeObserver(n)}})||this;return i.observers=new Set,i.promise=new Promise(function(n,a){i.resolve=n,i.reject=a}),i.handlers={next:function(n){i.sub!==null&&(i.latest=["next",n],i.notify("next",n),Ni(i.observers,"next",n))},error:function(n){var a=i.sub;a!==null&&(a&&setTimeout(function(){return a.unsubscribe()}),i.sub=null,i.latest=["error",n],i.reject(n),i.notify("error",n),Ni(i.observers,"error",n))},complete:function(){var n=i,a=n.sub,o=n.sources,s=o===void 0?[]:o;if(a!==null){var c=s.shift();c?xd(c)?c.then(function(l){return i.sub=l.subscribe(i.handlers)}):i.sub=c.subscribe(i.handlers):(a&&setTimeout(function(){return a.unsubscribe()}),i.sub=null,i.latest&&i.latest[0]==="next"?i.resolve(i.latest[1]):i.resolve(),i.notify("complete"),Ni(i.observers,"complete"))}}},i.nextResultListeners=new Set,i.cancel=function(n){i.reject(n),i.sources=[],i.handlers.complete()},i.promise.catch(function(n){}),typeof t=="function"&&(t=[new se(t)]),xd(t)?t.then(function(n){return i.start(n)},i.handlers.error):i.start(t),i}return e.prototype.start=function(t){this.sub===void 0&&(this.sources=Array.from(t),this.handlers.complete())},e.prototype.deliverLastMessage=function(t){if(this.latest){var i=this.latest[0],n=t[i];n&&n.call(t,this.latest[1]),this.sub===null&&i==="next"&&t.complete&&t.complete()}},e.prototype.addObserver=function(t){this.observers.has(t)||(this.deliverLastMessage(t),this.observers.add(t))},e.prototype.removeObserver=function(t){this.observers.delete(t)&&this.observers.size<1&&this.handlers.complete()},e.prototype.notify=function(t,i){var n=this.nextResultListeners;n.size&&(this.nextResultListeners=new Set,n.forEach(function(a){return a(t,i)}))},e.prototype.beforeNext=function(t){var i=!1;this.nextResultListeners.add(function(n,a){i||(i=!0,t(n,a))})},e}(se);hs(Fn);function Wr(r){return"incremental"in r}function iv(r){return"hasNext"in r&&"data"in r}function Ed(r){return Wr(r)||iv(r)}function ms(r,e){var t=r,i=new _t;return Wr(e)&&Ve(e.incremental)&&e.incremental.forEach(function(n){for(var a=n.data,o=n.path,s=o.length-1;s>=0;--s){var c=o[s],l=!isNaN(+c),u=l?[]:{};u[c]=a,a=u}t=i.merge(t,a)}),t}function Mn(r){var e=gs(r);return Ve(e)}function gs(r){var e=Ve(r.errors)?r.errors.slice(0):[];return Wr(r)&&Ve(r.incremental)&&r.incremental.forEach(function(t){t.errors&&e.push.apply(e,t.errors)}),e}function Gr(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=Object.create(null);return r.forEach(function(i){!i||Object.keys(i).forEach(function(n){var a=i[n];a!==void 0&&(t[n]=a)})}),t}var kd=new Map;function Da(r){var e=kd.get(r)||1;return kd.set(r,e+1),"".concat(r,":").concat(e,":").concat(Math.random().toString(36).slice(2))}function Ad(r){var e=Da("stringifyForDisplay");return JSON.stringify(r,function(t,i){return i===void 0?e:i}).split(JSON.stringify(e)).join("<undefined>")}function Fa(r,e){return Gr(r,e,e.variables&&{variables:E(E({},r&&r.variables),e.variables)})}function ys(r){return new se(function(e){e.error(r)})}var Ma=function(r,e,t){var i=new Error(t);throw i.name="ServerError",i.response=r,i.statusCode=r.status,i.result=e,i};function Ml(r){for(var e=["query","operationName","variables","extensions","context"],t=0,i=Object.keys(r);t<i.length;t++){var n=i[t];if(e.indexOf(n)<0)throw __DEV__?new ee("illegal argument: ".concat(n)):new ee(27)}return r}function Ul(r,e){var t=E({},r),i=function(a){typeof a=="function"?t=E(E({},t),a(t)):t=E(E({},t),a)},n=function(){return E({},t)};return Object.defineProperty(e,"setContext",{enumerable:!1,value:i}),Object.defineProperty(e,"getContext",{enumerable:!1,value:n}),e}function jl(r){var e={variables:r.variables||{},extensions:r.extensions||{},operationName:r.operationName,query:r.query};return e.operationName||(e.operationName=typeof e.query!="string"?Ln(e.query)||void 0:""),e}function Id(r,e){return e?e(r):se.of()}function Ua(r){return typeof r=="function"?new Vt(r):r}function vs(r){return r.request.length<=1}var nv=function(r){Pe(e,r);function e(t,i){var n=r.call(this,t)||this;return n.link=i,n}return e}(Error),Vt=function(){function r(e){e&&(this.request=e)}return r.empty=function(){return new r(function(){return se.of()})},r.from=function(e){return e.length===0?r.empty():e.map(Ua).reduce(function(t,i){return t.concat(i)})},r.split=function(e,t,i){var n=Ua(t),a=Ua(i||new r(Id));return vs(n)&&vs(a)?new r(function(o){return e(o)?n.request(o)||se.of():a.request(o)||se.of()}):new r(function(o,s){return e(o)?n.request(o,s)||se.of():a.request(o,s)||se.of()})},r.execute=function(e,t){return e.request(Ul(t.context,jl(Ml(t))))||se.of()},r.concat=function(e,t){var i=Ua(e);if(vs(i))return __DEV__&&D.warn(new nv("You are calling concat on a terminating link, which will have no effect",i)),i;var n=Ua(t);return vs(n)?new r(function(a){return i.request(a,function(o){return n.request(o)||se.of()})||se.of()}):new r(function(a,o){return i.request(a,function(s){return n.request(s,o)||se.of()})||se.of()})},r.prototype.split=function(e,t,i){return this.concat(r.split(e,t,i||new r(Id)))},r.prototype.concat=function(e){return r.concat(this,e)},r.prototype.request=function(e,t){throw __DEV__?new ee("request is not implemented"):new ee(22)},r.prototype.onError=function(e,t){if(t&&t.error)return t.error(e),!1;throw e},r.prototype.setOnError=function(e){return this.onError=e,this},r}();var Un=Vt.execute;var Td="3.7.10";function Cd(r){return!!r.body}function Od(r){return!!r.getReader}function $d(r){return!!(zr&&r[Symbol.asyncIterator])}function Pd(r){return!!r.stream}function Rd(r){return!!r.arrayBuffer}function Ld(r){return!!r.pipe}function ql(r){var e,t=r[Symbol.asyncIterator]();return e={next:function(){return t.next()}},e[Symbol.asyncIterator]=function(){return this},e}function Bl(r){var e=null,t=null,i=!1,n=[],a=[];function o(d){if(!t){if(a.length){var f=a.shift();if(Array.isArray(f)&&f[0])return f[0]({value:d,done:!1})}n.push(d)}}function s(d){t=d;var f=a.slice();f.forEach(function(p){p[1](d)}),!e||e()}function c(){i=!0;var d=a.slice();d.forEach(function(f){f[0]({value:void 0,done:!0})}),!e||e()}e=function(){e=null,r.removeListener("data",o),r.removeListener("error",s),r.removeListener("end",c),r.removeListener("finish",c),r.removeListener("close",c)},r.on("data",o),r.on("error",s),r.on("end",c),r.on("finish",c),r.on("close",c);function l(){return new Promise(function(d,f){if(t)return f(t);if(n.length)return d({value:n.shift(),done:!1});if(i)return d({value:void 0,done:!0});a.push([d,f])})}var u={next:function(){return l()}};return zr&&(u[Symbol.asyncIterator]=function(){return this}),u}function Vl(r){var e=!1,t={next:function(){return e?Promise.resolve({value:void 0,done:!0}):(e=!0,new Promise(function(i,n){r.then(function(a){i({value:a,done:!1})}).catch(n)}))}};return zr&&(t[Symbol.asyncIterator]=function(){return this}),t}function bs(r){var e={next:function(){return r.read()}};return zr&&(e[Symbol.asyncIterator]=function(){return this}),e}function Nd(r){var e=r;if(Cd(r)&&(e=r.body),$d(e))return ql(e);if(Od(e))return bs(e.getReader());if(Pd(e))return bs(e.stream().getReader());if(Rd(e))return Vl(e.arrayBuffer());if(Ld(e))return Bl(e);throw new Error("Unknown body type for responseIterator. Please pass a streamable response.")}var Dd=Object.prototype.hasOwnProperty;function Fd(r,e){var t,i,n;return Xt(this,void 0,void 0,function(){var a,o,s,c,l,u,d,f,p,h,m,y,b,_,S,v,C,$,I,L;return er(this,function(M){switch(M.label){case 0:if(TextDecoder===void 0)throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");a=new TextDecoder("utf-8"),o=(t=r.headers)===null||t===void 0?void 0:t.get("content-type"),s="boundary=",c=o?.includes(s)?o?.substring(o?.indexOf(s)+s.length).replace(/['"]/g,"").replace(/\;(.*)/gm,"").trim():"-",l="--".concat(c),u="",d=Nd(r),f=!0,M.label=1;case 1:return f?[4,d.next()]:[3,3];case 2:for(p=M.sent(),h=p.value,m=p.done,y=typeof h=="string"?h:a.decode(h),f=!m,u+=y,b=u.indexOf(l);b>-1;){if(_=void 0,L=[u.slice(0,b),u.slice(b+l.length)],_=L[0],u=L[1],_.trim()){if(S=_.indexOf(`\r
25
- \r
26
- `),v=av(_.slice(0,S)),C=v["content-type"],C&&C.toLowerCase().indexOf("application/json")===-1)throw new Error("Unsupported patch content type: application/json is required.");$=_.slice(S);try{I=Md(r,$.replace(`\r
27
- `,"")),(Object.keys(I).length>1||"data"in I||"incremental"in I||"errors"in I)&&((i=e.next)===null||i===void 0||i.call(e,I))}catch(N){ws(N,e)}}b=u.indexOf(l)}return[3,1];case 3:return(n=e.complete)===null||n===void 0||n.call(e),[2]}})})}function av(r){var e={};return r.split(`
28
- `).forEach(function(t){var i=t.indexOf(":");if(i>-1){var n=t.slice(0,i).trim().toLowerCase(),a=t.slice(i+1).trim();e[n]=a}}),e}function Md(r,e){if(r.status>=300){var t=function(){try{return JSON.parse(e)}catch{return e}};Ma(r,t(),"Response not successful: Received status code ".concat(r.status))}try{return JSON.parse(e)}catch(n){var i=n;throw i.name="ServerParseError",i.response=r,i.statusCode=r.status,i.bodyText=e,i}}function ws(r,e){var t,i;r.name!=="AbortError"&&(r.result&&r.result.errors&&r.result.data&&((t=e.next)===null||t===void 0||t.call(e,r.result)),(i=e.error)===null||i===void 0||i.call(e,r))}function Ud(r,e,t){ov(e)(r).then(function(i){var n,a;(n=t.next)===null||n===void 0||n.call(t,i),(a=t.complete)===null||a===void 0||a.call(t)}).catch(function(i){return ws(i,t)})}function ov(r){return function(e){return e.text().then(function(t){return Md(e,t)}).then(function(t){return e.status>=300&&Ma(e,t,"Response not successful: Received status code ".concat(e.status)),!Array.isArray(t)&&!Dd.call(t,"data")&&!Dd.call(t,"errors")&&Ma(e,t,"Server response was missing for query '".concat(Array.isArray(r)?r.map(function(i){return i.operationName}):r.operationName,"'.")),t})}}var ja=function(r,e){var t;try{t=JSON.stringify(r)}catch(n){var i=__DEV__?new ee("Network request failed. ".concat(e," is not serializable: ").concat(n.message)):new ee(24);throw i.parseError=n,i}return t};var sv={includeQuery:!0,includeExtensions:!1,preserveHeaderCase:!1},cv={accept:"*/*","content-type":"application/json"},lv={method:"POST"},jd={http:sv,headers:cv,options:lv},qd=function(r,e){return e(r)};function Bd(r,e){for(var t=[],i=2;i<arguments.length;i++)t[i-2]=arguments[i];var n={},a={};t.forEach(function(d){n=E(E(E({},n),d.options),{headers:E(E({},n.headers),d.headers)}),d.credentials&&(n.credentials=d.credentials),a=E(E({},a),d.http)}),n.headers&&(n.headers=uv(n.headers,a.preserveHeaderCase));var o=r.operationName,s=r.extensions,c=r.variables,l=r.query,u={operationName:o,variables:c};return a.includeExtensions&&(u.extensions=s),a.includeQuery&&(u.query=e(l,$n)),{options:n,body:u}}function uv(r,e){if(!e){var t=Object.create(null);return Object.keys(Object(r)).forEach(function(a){t[a.toLowerCase()]=r[a]}),t}var i=Object.create(null);Object.keys(Object(r)).forEach(function(a){i[a.toLowerCase()]={originalName:a,value:r[a]}});var n=Object.create(null);return Object.keys(i).forEach(function(a){n[i[a].originalName]=i[a].value}),n}var Vd=function(r){if(!r&&typeof fetch>"u")throw __DEV__?new ee(`
29
- "fetch" has not been found globally and no fetcher has been configured. To fix this, install a fetch package (like https://www.npmjs.com/package/cross-fetch), instantiate the fetcher, and pass it into your HttpLink constructor. For example:
30
-
31
- import fetch from 'cross-fetch';
32
- import { ApolloClient, HttpLink } from '@apollo/client';
33
- const client = new ApolloClient({
34
- link: new HttpLink({ uri: '/graphql', fetch })
35
- });
36
- `):new ee(23)};var Qd=function(){if(typeof AbortController>"u")return{controller:!1,signal:!1};var r=new AbortController,e=r.signal;return{controller:r,signal:e}};var Hd=function(r,e){var t=r.getContext(),i=t.uri;return i||(typeof e=="function"?e(r):e||"/graphql")};function zd(r,e){var t=[],i=function(d,f){t.push("".concat(d,"=").concat(encodeURIComponent(f)))};if("query"in e&&i("query",e.query),e.operationName&&i("operationName",e.operationName),e.variables){var n=void 0;try{n=ja(e.variables,"Variables map")}catch(d){return{parseError:d}}i("variables",n)}if(e.extensions){var a=void 0;try{a=ja(e.extensions,"Extensions map")}catch(d){return{parseError:d}}i("extensions",a)}var o="",s=r,c=r.indexOf("#");c!==-1&&(o=r.substr(c),s=r.substr(0,c));var l=s.indexOf("?")===-1?"?":"&",u=s+l+t.join("&")+o;return{newURI:u}}var Wd=Je(function(){return fetch}),Gd=function(r){r===void 0&&(r={});var e=r.uri,t=e===void 0?"/graphql":e,i=r.fetch,n=r.print,a=n===void 0?qd:n,o=r.includeExtensions,s=r.preserveHeaderCase,c=r.useGETForQueries,l=r.includeUnusedVariables,u=l===void 0?!1:l,d=cr(r,["uri","fetch","print","includeExtensions","preserveHeaderCase","useGETForQueries","includeUnusedVariables"]);__DEV__&&Vd(i||Wd);var f={http:{includeExtensions:o,preserveHeaderCase:s},options:d.fetchOptions,credentials:d.credentials,headers:d.headers};return new Vt(function(p){var h=Hd(p,t),m=p.getContext(),y={};if(m.clientAwareness){var b=m.clientAwareness,_=b.name,S=b.version;_&&(y["apollographql-client-name"]=_),S&&(y["apollographql-client-version"]=S)}var v=E(E({},y),m.headers),C={http:m.http,options:m.fetchOptions,credentials:m.credentials,headers:v},$=Bd(p,a,jd,f,C),I=$.options,L=$.body;if(L.variables&&!u){var M=new Set(Object.keys(L.variables));st(p.query,{Variable:function(fe,or,oe){oe&&oe.kind!=="VariableDefinition"&&M.delete(fe.name.value)}}),M.size&&(L.variables=E({},L.variables),M.forEach(function(fe){delete L.variables[fe]}))}var N;if(!I.signal){var W=Qd(),Ie=W.controller,Oe=W.signal;N=Ie,N&&(I.signal=Oe)}var T=function(fe){return fe.kind==="OperationDefinition"&&fe.operation==="mutation"};if(c&&!p.query.definitions.some(T)&&(I.method="GET"),Pn(["defer"],p.query)&&(I.headers=I.headers||{},I.headers.accept="multipart/mixed; deferSpec=20220824, application/json"),I.method==="GET"){var we=zd(h,L),Se=we.newURI,de=we.parseError;if(de)return ys(de);h=Se}else try{I.body=ja(L,"Payload")}catch(fe){return ys(fe)}return new se(function(fe){var or=i||Je(function(){return fetch})||Wd;return or(h,I).then(function(oe){var sr;p.setContext({response:oe});var Br=(sr=oe.headers)===null||sr===void 0?void 0:sr.get("content-type");return Br!==null&&/^multipart\/mixed/i.test(Br)?Fd(oe,fe):Ud(oe,p,fe)}).catch(function(oe){return ws(oe,fe)}),function(){N&&N.abort()}})})};var Ql=function(r){Pe(e,r);function e(t){t===void 0&&(t={});var i=r.call(this,Gd(t).request)||this;return i.options=t,i}return e}(Vt);var{toString:Kd,hasOwnProperty:pv}=Object.prototype,Jd=Function.prototype.toString,Hl=new Map;function Ae(r,e){try{return zl(r,e)}finally{Hl.clear()}}function zl(r,e){if(r===e)return!0;let t=Kd.call(r),i=Kd.call(e);if(t!==i)return!1;switch(t){case"[object Array]":if(r.length!==e.length)return!1;case"[object Object]":{if(Yd(r,e))return!0;let n=Zd(r),a=Zd(e),o=n.length;if(o!==a.length)return!1;for(let s=0;s<o;++s)if(!pv.call(e,n[s]))return!1;for(let s=0;s<o;++s){let c=n[s];if(!zl(r[c],e[c]))return!1}return!0}case"[object Error]":return r.name===e.name&&r.message===e.message;case"[object Number]":if(r!==r)return e!==e;case"[object Boolean]":case"[object Date]":return+r==+e;case"[object RegExp]":case"[object String]":return r==`${e}`;case"[object Map]":case"[object Set]":{if(r.size!==e.size)return!1;if(Yd(r,e))return!0;let n=r.entries(),a=t==="[object Map]";for(;;){let o=n.next();if(o.done)break;let[s,c]=o.value;if(!e.has(s)||a&&!zl(c,e.get(s)))return!1}return!0}case"[object Uint16Array]":case"[object Uint8Array]":case"[object Uint32Array]":case"[object Int32Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object ArrayBuffer]":r=new Uint8Array(r),e=new Uint8Array(e);case"[object DataView]":{let n=r.byteLength;if(n===e.byteLength)for(;n--&&r[n]===e[n];);return n===-1}case"[object AsyncFunction]":case"[object GeneratorFunction]":case"[object AsyncGeneratorFunction]":case"[object Function]":{let n=Jd.call(r);return n!==Jd.call(e)?!1:!hv(n,fv)}}return!1}function Zd(r){return Object.keys(r).filter(dv,r)}function dv(r){return this[r]!==void 0}var fv="{ [native code] }";function hv(r,e){let t=r.length-e.length;return t>=0&&r.indexOf(e,t)===t}function Yd(r,e){let t=Hl.get(r);if(t){if(t.has(e))return!0}else Hl.set(r,t=new Set);return t.add(e),!1}var mv=function(){return Object.create(null)},Xd=Array.prototype,gv=Xd.forEach,yv=Xd.slice,pr=function(){function r(e,t){e===void 0&&(e=!0),t===void 0&&(t=mv),this.weakness=e,this.makeData=t}return r.prototype.lookup=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this.lookupArray(e)},r.prototype.lookupArray=function(e){var t=this;return gv.call(e,function(i){return t=t.getChildTrie(i)}),t.data||(t.data=this.makeData(yv.call(e)))},r.prototype.getChildTrie=function(e){var t=this.weakness&&vv(e)?this.weak||(this.weak=new WeakMap):this.strong||(this.strong=new Map),i=t.get(e);return i||t.set(e,i=new r(this.weakness,this.makeData)),i},r}();function vv(r){switch(typeof r){case"object":if(r===null)break;case"function":return!0}return!1}var it=null,ef={},bv=1,wv=()=>class{constructor(){this.id=["slot",bv++,Date.now(),Math.random().toString(36).slice(2)].join(":")}hasValue(){for(let e=it;e;e=e.parent)if(this.id in e.slots){let t=e.slots[this.id];if(t===ef)break;return e!==it&&(it.slots[this.id]=t),!0}return it&&(it.slots[this.id]=ef),!1}getValue(){if(this.hasValue())return it.slots[this.id]}withValue(e,t,i,n){let a={__proto__:null,[this.id]:e},o=it;it={parent:o,slots:a};try{return t.apply(n,i)}finally{it=o}}static bind(e){let t=it;return function(){let i=it;try{return it=t,e.apply(this,arguments)}finally{it=i}}}static noContext(e,t,i){if(it){let n=it;try{return it=null,e.apply(i,t)}finally{it=n}}else return e.apply(i,t)}};function tf(r){try{return r()}catch{}}var Wl="@wry/context:Slot",Sv=tf(()=>globalThis)||tf(()=>global)||Object.create(null),rf=Sv,jn=rf[Wl]||Array[Wl]||function(r){try{Object.defineProperty(rf,Wl,{value:r,enumerable:!1,writable:!1,configurable:!0})}finally{return r}}(wv());var{bind:_v,noContext:xv}=jn;function Ev(){}var kv=function(){function r(e,t){e===void 0&&(e=1/0),t===void 0&&(t=Ev),this.max=e,this.dispose=t,this.map=new Map,this.newest=null,this.oldest=null}return r.prototype.has=function(e){return this.map.has(e)},r.prototype.get=function(e){var t=this.getNode(e);return t&&t.value},r.prototype.getNode=function(e){var t=this.map.get(e);if(t&&t!==this.newest){var i=t.older,n=t.newer;n&&(n.older=i),i&&(i.newer=n),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=n)}return t},r.prototype.set=function(e,t){var i=this.getNode(e);return i?i.value=t:(i={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=i),this.newest=i,this.oldest=this.oldest||i,this.map.set(e,i),i.value)},r.prototype.clean=function(){for(;this.oldest&&this.map.size>this.max;)this.delete(this.oldest.key)},r.prototype.delete=function(e){var t=this.map.get(e);return t?(t===this.newest&&(this.newest=t.older),t===this.oldest&&(this.oldest=t.newer),t.newer&&(t.newer.older=t.older),t.older&&(t.older.newer=t.newer),this.map.delete(e),this.dispose(t.value,e),!0):!1},r}(),_s=new jn,Gl,Av=Object.prototype.hasOwnProperty,Jl=(Gl=Array.from,Gl===void 0?function(r){var e=[];return r.forEach(function(t){return e.push(t)}),e}:Gl);function Ss(r){var e=r.unsubscribe;typeof e=="function"&&(r.unsubscribe=void 0,e())}var qa=[],Iv=100;function qn(r,e){if(!r)throw new Error(e||"assertion failure")}function Tv(r,e){var t=r.length;return t>0&&t===e.length&&r[t-1]===e[t-1]}function af(r){switch(r.length){case 0:throw new Error("unknown value");case 1:return r[0];case 2:throw r[1]}}function Cv(r){return r.slice(0)}var Ov=function(){function r(e){this.fn=e,this.parents=new Set,this.childValues=new Map,this.dirtyChildren=null,this.dirty=!0,this.recomputing=!1,this.value=[],this.deps=null,++r.count}return r.prototype.peek=function(){if(this.value.length===1&&!Kr(this))return nf(this),this.value[0]},r.prototype.recompute=function(e){return qn(!this.recomputing,"already recomputing"),nf(this),Kr(this)?$v(this,e):af(this.value)},r.prototype.setDirty=function(){this.dirty||(this.dirty=!0,this.value.length=0,of(this),Ss(this))},r.prototype.dispose=function(){var e=this;this.setDirty(),pf(this),Zl(this,function(t,i){t.setDirty(),df(t,e)})},r.prototype.forget=function(){this.dispose()},r.prototype.dependOn=function(e){e.add(this),this.deps||(this.deps=qa.pop()||new Set),this.deps.add(e)},r.prototype.forgetDeps=function(){var e=this;this.deps&&(Jl(this.deps).forEach(function(t){return t.delete(e)}),this.deps.clear(),qa.push(this.deps),this.deps=null)},r.count=0,r}();function nf(r){var e=_s.getValue();if(e)return r.parents.add(e),e.childValues.has(r)||e.childValues.set(r,[]),Kr(r)?cf(e,r):lf(e,r),e}function $v(r,e){return pf(r),_s.withValue(r,Pv,[r,e]),Lv(r,e)&&Rv(r),af(r.value)}function Pv(r,e){r.recomputing=!0,r.value.length=0;try{r.value[0]=r.fn.apply(null,e)}catch(t){r.value[1]=t}r.recomputing=!1}function Kr(r){return r.dirty||!!(r.dirtyChildren&&r.dirtyChildren.size)}function Rv(r){r.dirty=!1,!Kr(r)&&sf(r)}function of(r){Zl(r,cf)}function sf(r){Zl(r,lf)}function Zl(r,e){var t=r.parents.size;if(t)for(var i=Jl(r.parents),n=0;n<t;++n)e(i[n],r)}function cf(r,e){qn(r.childValues.has(e)),qn(Kr(e));var t=!Kr(r);if(!r.dirtyChildren)r.dirtyChildren=qa.pop()||new Set;else if(r.dirtyChildren.has(e))return;r.dirtyChildren.add(e),t&&of(r)}function lf(r,e){qn(r.childValues.has(e)),qn(!Kr(e));var t=r.childValues.get(e);t.length===0?r.childValues.set(e,Cv(e.value)):Tv(t,e.value)||r.setDirty(),uf(r,e),!Kr(r)&&sf(r)}function uf(r,e){var t=r.dirtyChildren;t&&(t.delete(e),t.size===0&&(qa.length<Iv&&qa.push(t),r.dirtyChildren=null))}function pf(r){r.childValues.size>0&&r.childValues.forEach(function(e,t){df(r,t)}),r.forgetDeps(),qn(r.dirtyChildren===null)}function df(r,e){e.parents.delete(r),r.childValues.delete(e),uf(r,e)}function Lv(r,e){if(typeof r.subscribe=="function")try{Ss(r),r.unsubscribe=r.subscribe.apply(null,e)}catch{return r.setDirty(),!1}return!0}var Nv={setDirty:!0,dispose:!0,forget:!0};function xs(r){var e=new Map,t=r&&r.subscribe;function i(n){var a=_s.getValue();if(a){var o=e.get(n);o||e.set(n,o=new Set),a.dependOn(o),typeof t=="function"&&(Ss(o),o.unsubscribe=t(n))}}return i.dirty=function(a,o){var s=e.get(a);if(s){var c=o&&Av.call(Nv,o)?o:"setDirty";Jl(s).forEach(function(l){return l[c]()}),e.delete(a),Ss(s)}},i}function ff(){var r=new pr(typeof WeakMap=="function");return function(){return r.lookupArray(arguments)}}var UA=ff(),Kl=new Set;function Di(r,e){e===void 0&&(e=Object.create(null));var t=new kv(e.max||Math.pow(2,16),function(l){return l.dispose()}),i=e.keyArgs,n=e.makeCacheKey||ff(),a=function(){var l=n.apply(null,i?i.apply(null,arguments):arguments);if(l===void 0)return r.apply(null,arguments);var u=t.get(l);u||(t.set(l,u=new Ov(r)),u.subscribe=e.subscribe,u.forget=function(){return t.delete(l)});var d=u.recompute(Array.prototype.slice.call(arguments));return t.set(l,u),Kl.add(t),_s.hasValue()||(Kl.forEach(function(f){return f.clean()}),Kl.clear()),d};Object.defineProperty(a,"size",{get:function(){return t.map.size},configurable:!1,enumerable:!1});function o(l){var u=t.get(l);u&&u.setDirty()}a.dirtyKey=o,a.dirty=function(){o(n.apply(null,arguments))};function s(l){var u=t.get(l);if(u)return u.peek()}a.peekKey=s,a.peek=function(){return s(n.apply(null,arguments))};function c(l){return t.delete(l)}return a.forgetKey=c,a.forget=function(){return c(n.apply(null,arguments))},a.makeCacheKey=n,a.getKey=i?function(){return n.apply(null,i.apply(null,arguments))}:n,Object.freeze(a)}var Yl=function(){function r(){this.getFragmentDoc=Di(vl)}return r.prototype.batch=function(e){var t=this,i=typeof e.optimistic=="string"?e.optimistic:e.optimistic===!1?null:void 0,n;return this.performTransaction(function(){return n=e.update(t)},i),n},r.prototype.recordOptimisticTransaction=function(e,t){this.performTransaction(e,t)},r.prototype.transformDocument=function(e){return e},r.prototype.transformForLink=function(e){return e},r.prototype.identify=function(e){},r.prototype.gc=function(){return[]},r.prototype.modify=function(e){return!1},r.prototype.readQuery=function(e,t){return t===void 0&&(t=!!e.optimistic),this.read(E(E({},e),{rootId:e.id||"ROOT_QUERY",optimistic:t}))},r.prototype.readFragment=function(e,t){return t===void 0&&(t=!!e.optimistic),this.read(E(E({},e),{query:this.getFragmentDoc(e.fragment,e.fragmentName),rootId:e.id,optimistic:t}))},r.prototype.writeQuery=function(e){var t=e.id,i=e.data,n=cr(e,["id","data"]);return this.write(Object.assign(n,{dataId:t||"ROOT_QUERY",result:i}))},r.prototype.writeFragment=function(e){var t=e.id,i=e.data,n=e.fragment,a=e.fragmentName,o=cr(e,["id","data","fragment","fragmentName"]);return this.write(Object.assign(o,{query:this.getFragmentDoc(n,a),dataId:t,result:i}))},r.prototype.updateQuery=function(e,t){return this.batch({update:function(i){var n=i.readQuery(e),a=t(n);return a==null?n:(i.writeQuery(E(E({},e),{data:a})),a)}})},r.prototype.updateFragment=function(e,t){return this.batch({update:function(i){var n=i.readFragment(e),a=t(n);return a==null?n:(i.writeFragment(E(E({},e),{data:a})),a)}})},r}();var Ba=function(r){Pe(e,r);function e(t,i,n,a){var o,s=r.call(this,t)||this;if(s.message=t,s.path=i,s.query=n,s.variables=a,Array.isArray(s.path)){s.missing=s.message;for(var c=s.path.length-1;c>=0;--c)s.missing=(o={},o[s.path[c]]=s.missing,o)}else s.missing=s.path;return s.__proto__=e.prototype,s}return e}(Error);var Re=Object.prototype.hasOwnProperty;function Va(r){return r==null}function ks(r,e){var t=r.__typename,i=r.id,n=r._id;if(typeof t=="string"&&(e&&(e.keyObject=Va(i)?Va(n)?void 0:{_id:n}:{id:i}),Va(i)&&!Va(n)&&(i=n),!Va(i)))return"".concat(t,":").concat(typeof i=="number"||typeof i=="string"?i:JSON.stringify(i))}var hf={dataIdFromObject:ks,addTypename:!0,resultCaching:!0,canonizeResults:!1};function mf(r){return Gr(hf,r)}function As(r){var e=r.canonizeResults;return e===void 0?hf.canonizeResults:e}function gf(r,e){return le(e)?r.get(e.__ref,"__typename"):e&&e.__typename}var Xl=/^[_a-z][_0-9a-z]*/i;function ir(r){var e=r.match(Xl);return e?e[0]:r}function Es(r,e,t){return he(e)?be(e)?e.every(function(i){return Es(r,i,t)}):r.selections.every(function(i){if(Pt(i)&&kr(i,t)){var n=qt(i);return Re.call(e,n)&&(!i.selectionSet||Es(i.selectionSet,e[n],t))}return!0}):!1}function Jr(r){return he(r)&&!le(r)&&!be(r)}function yf(){return new _t}function Is(r,e){var t=Ci($i(r));return{fragmentMap:t,lookupFragment:function(i){var n=t[i];return!n&&e&&(n=e.lookup(i)),n||null}}}var Ts=Object.create(null),eu=function(){return Ts},vf=Object.create(null),Bn=function(){function r(e,t){var i=this;this.policies=e,this.group=t,this.data=Object.create(null),this.rootIds=Object.create(null),this.refs=Object.create(null),this.getFieldValue=function(n,a){return Na(le(n)?i.get(n.__ref,a):n&&n[a])},this.canRead=function(n){return le(n)?i.has(n.__ref):typeof n=="object"},this.toReference=function(n,a){if(typeof n=="string")return lr(n);if(le(n))return n;var o=i.policies.identify(n)[0];if(o){var s=lr(o);return a&&i.merge(o,n),s}}}return r.prototype.toObject=function(){return E({},this.data)},r.prototype.has=function(e){return this.lookup(e,!0)!==void 0},r.prototype.get=function(e,t){if(this.group.depend(e,t),Re.call(this.data,e)){var i=this.data[e];if(i&&Re.call(i,t))return i[t]}if(t==="__typename"&&Re.call(this.policies.rootTypenamesById,e))return this.policies.rootTypenamesById[e];if(this instanceof Zr)return this.parent.get(e,t)},r.prototype.lookup=function(e,t){if(t&&this.group.depend(e,"__exists"),Re.call(this.data,e))return this.data[e];if(this instanceof Zr)return this.parent.lookup(e,t);if(this.policies.rootTypenamesById[e])return Object.create(null)},r.prototype.merge=function(e,t){var i=this,n;le(e)&&(e=e.__ref),le(t)&&(t=t.__ref);var a=typeof e=="string"?this.lookup(n=e):e,o=typeof t=="string"?this.lookup(n=t):t;if(!!o){__DEV__?D(typeof n=="string","store.merge expects a string ID"):D(typeof n=="string",1);var s=new _t(Fv).merge(a,o);if(this.data[n]=s,s!==a&&(delete this.refs[n],this.group.caching)){var c=Object.create(null);a||(c.__exists=1),Object.keys(o).forEach(function(l){if(!a||a[l]!==s[l]){c[l]=1;var u=ir(l);u!==l&&!i.policies.hasKeyArgs(s.__typename,u)&&(c[u]=1),s[l]===void 0&&!(i instanceof Zr)&&delete s[l]}}),c.__typename&&!(a&&a.__typename)&&this.policies.rootTypenamesById[n]===s.__typename&&delete c.__typename,Object.keys(c).forEach(function(l){return i.group.dirty(n,l)})}}},r.prototype.modify=function(e,t){var i=this,n=this.lookup(e);if(n){var a=Object.create(null),o=!1,s=!0,c={DELETE:Ts,INVALIDATE:vf,isReference:le,toReference:this.toReference,canRead:this.canRead,readField:function(l,u){return i.policies.readField(typeof l=="string"?{fieldName:l,from:u||lr(e)}:l,{store:i})}};if(Object.keys(n).forEach(function(l){var u=ir(l),d=n[l];if(d!==void 0){var f=typeof t=="function"?t:t[l]||t[u];if(f){var p=f===eu?Ts:f(Na(d),E(E({},c),{fieldName:u,storeFieldName:l,storage:i.getStorage(e,l)}));p===vf?i.group.dirty(e,l):(p===Ts&&(p=void 0),p!==d&&(a[l]=p,o=!0,d=p))}d!==void 0&&(s=!1)}}),o)return this.merge(e,a),s&&(this instanceof Zr?this.data[e]=void 0:delete this.data[e],this.group.dirty(e,"__exists")),!0}return!1},r.prototype.delete=function(e,t,i){var n,a=this.lookup(e);if(a){var o=this.getFieldValue(a,"__typename"),s=t&&i?this.policies.getStoreFieldName({typename:o,fieldName:t,args:i}):t;return this.modify(e,s?(n={},n[s]=eu,n):eu)}return!1},r.prototype.evict=function(e,t){var i=!1;return e.id&&(Re.call(this.data,e.id)&&(i=this.delete(e.id,e.fieldName,e.args)),this instanceof Zr&&this!==t&&(i=this.parent.evict(e,t)||i),(e.fieldName||i)&&this.group.dirty(e.id,e.fieldName||"__exists")),i},r.prototype.clear=function(){this.replace(null)},r.prototype.extract=function(){var e=this,t=this.toObject(),i=[];return this.getRootIdSet().forEach(function(n){Re.call(e.policies.rootTypenamesById,n)||i.push(n)}),i.length&&(t.__META={extraRootIds:i.sort()}),t},r.prototype.replace=function(e){var t=this;if(Object.keys(this.data).forEach(function(a){e&&Re.call(e,a)||t.delete(a)}),e){var i=e.__META,n=cr(e,["__META"]);Object.keys(n).forEach(function(a){t.merge(a,n[a])}),i&&i.extraRootIds.forEach(this.retain,this)}},r.prototype.retain=function(e){return this.rootIds[e]=(this.rootIds[e]||0)+1},r.prototype.release=function(e){if(this.rootIds[e]>0){var t=--this.rootIds[e];return t||delete this.rootIds[e],t}return 0},r.prototype.getRootIdSet=function(e){return e===void 0&&(e=new Set),Object.keys(this.rootIds).forEach(e.add,e),this instanceof Zr?this.parent.getRootIdSet(e):Object.keys(this.policies.rootTypenamesById).forEach(e.add,e),e},r.prototype.gc=function(){var e=this,t=this.getRootIdSet(),i=this.toObject();t.forEach(function(o){Re.call(i,o)&&(Object.keys(e.findChildRefIds(o)).forEach(t.add,t),delete i[o])});var n=Object.keys(i);if(n.length){for(var a=this;a instanceof Zr;)a=a.parent;n.forEach(function(o){return a.delete(o)})}return n},r.prototype.findChildRefIds=function(e){if(!Re.call(this.refs,e)){var t=this.refs[e]=Object.create(null),i=this.data[e];if(!i)return t;var n=new Set([i]);n.forEach(function(a){le(a)&&(t[a.__ref]=!0),he(a)&&Object.keys(a).forEach(function(o){var s=a[o];he(s)&&n.add(s)})})}return this.refs[e]},r.prototype.makeCacheKey=function(){return this.group.keyMaker.lookupArray(arguments)},r}();var bf=function(){function r(e,t){t===void 0&&(t=null),this.caching=e,this.parent=t,this.d=null,this.resetCaching()}return r.prototype.resetCaching=function(){this.d=this.caching?xs():null,this.keyMaker=new pr(Bt)},r.prototype.depend=function(e,t){if(this.d){this.d(tu(e,t));var i=ir(t);i!==t&&this.d(tu(e,i)),this.parent&&this.parent.depend(e,t)}},r.prototype.dirty=function(e,t){this.d&&this.d.dirty(tu(e,t),t==="__exists"?"forget":"setDirty")},r}();function tu(r,e){return e+"#"+r}function ru(r,e){Fi(r)&&r.group.depend(e,"__exists")}(function(r){var e=function(t){Pe(i,t);function i(n){var a=n.policies,o=n.resultCaching,s=o===void 0?!0:o,c=n.seed,l=t.call(this,a,new bf(s))||this;return l.stump=new Dv(l),l.storageTrie=new pr(Bt),c&&l.replace(c),l}return i.prototype.addLayer=function(n,a){return this.stump.addLayer(n,a)},i.prototype.removeLayer=function(){return this},i.prototype.getStorage=function(){return this.storageTrie.lookupArray(arguments)},i}(r);r.Root=e})(Bn||(Bn={}));var Zr=function(r){Pe(e,r);function e(t,i,n,a){var o=r.call(this,i.policies,a)||this;return o.id=t,o.parent=i,o.replay=n,o.group=a,n(o),o}return e.prototype.addLayer=function(t,i){return new e(t,this,i,this.group)},e.prototype.removeLayer=function(t){var i=this,n=this.parent.removeLayer(t);return t===this.id?(this.group.caching&&Object.keys(this.data).forEach(function(a){var o=i.data[a],s=n.lookup(a);s?o?o!==s&&Object.keys(o).forEach(function(c){Ae(o[c],s[c])||i.group.dirty(a,c)}):(i.group.dirty(a,"__exists"),Object.keys(s).forEach(function(c){i.group.dirty(a,c)})):i.delete(a)}),n):n===this.parent?this:n.addLayer(this.id,this.replay)},e.prototype.toObject=function(){return E(E({},this.parent.toObject()),this.data)},e.prototype.findChildRefIds=function(t){var i=this.parent.findChildRefIds(t);return Re.call(this.data,t)?E(E({},i),r.prototype.findChildRefIds.call(this,t)):i},e.prototype.getStorage=function(){for(var t=this.parent;t.parent;)t=t.parent;return t.getStorage.apply(t,arguments)},e}(Bn),Dv=function(r){Pe(e,r);function e(t){return r.call(this,"EntityStore.Stump",t,function(){},new bf(t.group.caching,t.group))||this}return e.prototype.removeLayer=function(){return this},e.prototype.merge=function(){return this.parent.merge.apply(this.parent,arguments)},e}(Zr);function Fv(r,e,t){var i=r[t],n=e[t];return Ae(i,n)?i:n}function Fi(r){return!!(r instanceof Bn&&r.group.caching)}function Mv(r){return he(r)?be(r)?r.slice(0):E({__proto__:Object.getPrototypeOf(r)},r):r}var Cs=function(){function r(){this.known=new(_d?WeakSet:Set),this.pool=new pr(Bt),this.passes=new WeakMap,this.keysByJSON=new Map,this.empty=this.admit({})}return r.prototype.isKnown=function(e){return he(e)&&this.known.has(e)},r.prototype.pass=function(e){if(he(e)){var t=Mv(e);return this.passes.set(t,e),t}return e},r.prototype.admit=function(e){var t=this;if(he(e)){var i=this.passes.get(e);if(i)return i;var n=Object.getPrototypeOf(e);switch(n){case Array.prototype:{if(this.known.has(e))return e;var a=e.map(this.admit,this),o=this.pool.lookupArray(a);return o.array||(this.known.add(o.array=a),__DEV__&&Object.freeze(a)),o.array}case null:case Object.prototype:{if(this.known.has(e))return e;var s=Object.getPrototypeOf(e),c=[s],l=this.sortedKeys(e);c.push(l.json);var u=c.length;l.sorted.forEach(function(p){c.push(t.admit(e[p]))});var o=this.pool.lookupArray(c);if(!o.object){var d=o.object=Object.create(s);this.known.add(d),l.sorted.forEach(function(p,h){d[p]=c[u+h]}),__DEV__&&Object.freeze(d)}return o.object}}}return e},r.prototype.sortedKeys=function(e){var t=Object.keys(e),i=this.pool.lookupArray(t);if(!i.keys){t.sort();var n=JSON.stringify(t);(i.keys=this.keysByJSON.get(n))||this.keysByJSON.set(n,i.keys={sorted:t,json:n})}return i.keys},r}();var Rt=Object.assign(function(r){if(he(r)){iu===void 0&&wf();var e=iu.admit(r),t=nu.get(e);return t===void 0&&nu.set(e,t=JSON.stringify(e)),t}return JSON.stringify(r)},{reset:wf}),iu,nu;function wf(){iu=new Cs,nu=new(Bt?WeakMap:Map)}function Sf(r){return[r.selectionSet,r.objectOrReference,r.context,r.context.canonizeResults]}var _f=function(){function r(e){var t=this;this.knownResults=new(Bt?WeakMap:Map),this.config=Gr(e,{addTypename:e.addTypename!==!1,canonizeResults:As(e)}),this.canon=e.canon||new Cs,this.executeSelectionSet=Di(function(i){var n,a=i.context.canonizeResults,o=Sf(i);o[3]=!a;var s=(n=t.executeSelectionSet).peek.apply(n,o);return s?a?E(E({},s),{result:t.canon.admit(s.result)}):s:(ru(i.context.store,i.enclosingRef.__ref),t.execSelectionSetImpl(i))},{max:this.config.resultCacheMaxSize,keyArgs:Sf,makeCacheKey:function(i,n,a,o){if(Fi(a.store))return a.store.makeCacheKey(i,le(n)?n.__ref:n,a.varString,o)}}),this.executeSubSelectedArray=Di(function(i){return ru(i.context.store,i.enclosingRef.__ref),t.execSubSelectedArrayImpl(i)},{max:this.config.resultCacheMaxSize,makeCacheKey:function(i){var n=i.field,a=i.array,o=i.context;if(Fi(o.store))return o.store.makeCacheKey(n,a,o.varString)}})}return r.prototype.resetCanon=function(){this.canon=new Cs},r.prototype.diffQueryAgainstStore=function(e){var t=e.store,i=e.query,n=e.rootId,a=n===void 0?"ROOT_QUERY":n,o=e.variables,s=e.returnPartialData,c=s===void 0?!0:s,l=e.canonizeResults,u=l===void 0?this.config.canonizeResults:l,d=this.config.cache.policies;o=E(E({},Ri(Pa(i))),o);var f=lr(a),p=this.executeSelectionSet({selectionSet:Pi(i).selectionSet,objectOrReference:f,enclosingRef:f,context:E({store:t,query:i,policies:d,variables:o,varString:Rt(o),canonizeResults:u},Is(i,this.config.fragments))}),h;if(p.missing&&(h=[new Ba(Uv(p.missing),p.missing,i,o)],!c))throw h[0];return{result:p.result,complete:!h,missing:h}},r.prototype.isFresh=function(e,t,i,n){if(Fi(n.store)&&this.knownResults.get(e)===i){var a=this.executeSelectionSet.peek(i,t,n,this.canon.isKnown(e));if(a&&e===a.result)return!0}return!1},r.prototype.execSelectionSetImpl=function(e){var t=this,i=e.selectionSet,n=e.objectOrReference,a=e.enclosingRef,o=e.context;if(le(n)&&!o.policies.rootTypenamesById[n.__ref]&&!o.store.has(n.__ref))return{result:this.canon.empty,missing:"Dangling reference to missing ".concat(n.__ref," object")};var s=o.variables,c=o.policies,l=o.store,u=l.getFieldValue(n,"__typename"),d=[],f,p=new _t;this.config.addTypename&&typeof u=="string"&&!c.rootIdsByTypename[u]&&d.push({__typename:u});function h(S,v){var C;return S.missing&&(f=p.merge(f,(C={},C[v]=S.missing,C))),S.result}var m=new Set(i.selections);m.forEach(function(S){var v,C;if(!!kr(S,s))if(Pt(S)){var $=c.readField({fieldName:S.name.value,field:S,variables:o.variables,from:n},o),I=qt(S);$===void 0?Li.added(S)||(f=p.merge(f,(v={},v[I]="Can't find field '".concat(S.name.value,"' on ").concat(le(n)?n.__ref+" object":"object "+JSON.stringify(n,null,2)),v))):be($)?$=h(t.executeSubSelectedArray({field:S,array:$,enclosingRef:a,context:o}),I):S.selectionSet?$!=null&&($=h(t.executeSelectionSet({selectionSet:S.selectionSet,objectOrReference:$,enclosingRef:le($)?$:a,context:o}),I)):o.canonizeResults&&($=t.canon.pass($)),$!==void 0&&d.push((C={},C[I]=$,C))}else{var L=Oi(S,o.lookupFragment);if(!L&&S.kind===je.FRAGMENT_SPREAD)throw __DEV__?new ee("No fragment named ".concat(S.name.value)):new ee(5);L&&c.fragmentMatches(L,u)&&L.selectionSet.selections.forEach(m.add,m)}});var y=Ra(d),b={result:y,missing:f},_=o.canonizeResults?this.canon.admit(b):Na(b);return _.result&&this.knownResults.set(_.result,i),_},r.prototype.execSubSelectedArrayImpl=function(e){var t=this,i=e.field,n=e.array,a=e.enclosingRef,o=e.context,s,c=new _t;function l(u,d){var f;return u.missing&&(s=c.merge(s,(f={},f[d]=u.missing,f))),u.result}return i.selectionSet&&(n=n.filter(o.store.canRead)),n=n.map(function(u,d){return u===null?null:be(u)?l(t.executeSubSelectedArray({field:i,array:u,enclosingRef:a,context:o}),d):i.selectionSet?l(t.executeSelectionSet({selectionSet:i.selectionSet,objectOrReference:u,enclosingRef:le(u)?u:a,context:o}),d):(__DEV__&&jv(o.store,i,u),u)}),{result:o.canonizeResults?this.canon.admit(n):n,missing:s}},r}();function Uv(r){try{JSON.stringify(r,function(e,t){if(typeof t=="string")throw t;return t})}catch(e){return e}}function jv(r,e,t){if(!e.selectionSet){var i=new Set([t]);i.forEach(function(n){he(n)&&(__DEV__?D(!le(n),"Missing selection set for object of type ".concat(gf(r,n)," returned for query field ").concat(e.name.value)):D(!le(n),6),Object.values(n).forEach(i.add,i))})}}var Vn=new jn,xf=new WeakMap;function Qa(r){var e=xf.get(r);return e||xf.set(r,e={vars:new Set,dep:xs()}),e}function au(r){Qa(r).vars.forEach(function(e){return e.forgetCache(r)})}function Ef(r){Qa(r).vars.forEach(function(e){return e.attachCache(r)})}function Os(r){var e=new Set,t=new Set,i=function(a){if(arguments.length>0){if(r!==a){r=a,e.forEach(function(c){Qa(c).dep.dirty(i),qv(c)});var o=Array.from(t);t.clear(),o.forEach(function(c){return c(r)})}}else{var s=Vn.getValue();s&&(n(s),Qa(s).dep(i))}return r};i.onNextChange=function(a){return t.add(a),function(){t.delete(a)}};var n=i.attachCache=function(a){return e.add(a),Qa(a).vars.add(i),i};return i.forgetCache=function(a){return e.delete(a)},i}function qv(r){r.broadcastWatches&&r.broadcastWatches()}var kf=Object.create(null);function ou(r){var e=JSON.stringify(r);return kf[e]||(kf[e]=Object.create(null))}function su(r){var e=ou(r);return e.keyFieldsFn||(e.keyFieldsFn=function(t,i){var n=function(o,s){return i.readField(s,o)},a=i.keyObject=lu(r,function(o){var s=Qn(i.storeObject,o,n);return s===void 0&&t!==i.storeObject&&Re.call(t,o[0])&&(s=Qn(t,o,If)),__DEV__?D(s!==void 0,"Missing field '".concat(o.join("."),"' while extracting keyFields from ").concat(JSON.stringify(t))):D(s!==void 0,2),s});return"".concat(i.typename,":").concat(JSON.stringify(a))})}function cu(r){var e=ou(r);return e.keyArgsFn||(e.keyArgsFn=function(t,i){var n=i.field,a=i.variables,o=i.fieldName,s=lu(r,function(l){var u=l[0],d=u.charAt(0);if(d==="@"){if(n&&Ve(n.directives)){var f=u.slice(1),p=n.directives.find(function(b){return b.name.value===f}),h=p&&Ar(p,a);return h&&Qn(h,l.slice(1))}return}if(d==="$"){var m=u.slice(1);if(a&&Re.call(a,m)){var y=l.slice(0);return y[0]=m,Qn(a,y)}return}if(t)return Qn(t,l)}),c=JSON.stringify(s);return(t||c!=="{}")&&(o+=":"+c),o})}function lu(r,e){var t=new _t;return Af(r).reduce(function(i,n){var a,o=e(n);if(o!==void 0){for(var s=n.length-1;s>=0;--s)o=(a={},a[n[s]]=o,a);i=t.merge(i,o)}return i},Object.create(null))}function Af(r){var e=ou(r);if(!e.paths){var t=e.paths=[],i=[];r.forEach(function(n,a){be(n)?(Af(n).forEach(function(o){return t.push(i.concat(o))}),i.length=0):(i.push(n),be(r[a+1])||(t.push(i.slice(0)),i.length=0))})}return e.paths}function If(r,e){return r[e]}function Qn(r,e,t){return t=t||If,Tf(e.reduce(function i(n,a){return be(n)?n.map(function(o){return i(o,a)}):n&&t(n,a)},r))}function Tf(r){return he(r)?be(r)?r.map(Tf):lu(Object.keys(r).sort(),function(e){return Qn(r,e)}):r}Oa.setStringify(Rt);function uu(r){return r.args!==void 0?r.args:r.field?Ar(r.field,r.variables):null}var Bv=function(){},Cf=function(r,e){return e.fieldName},Of=function(r,e,t){var i=t.mergeObjects;return i(r,e)},$f=function(r,e){return e},Rf=function(){function r(e){this.config=e,this.typePolicies=Object.create(null),this.toBeAdded=Object.create(null),this.supertypeMap=new Map,this.fuzzySubtypes=new Map,this.rootIdsByTypename=Object.create(null),this.rootTypenamesById=Object.create(null),this.usingPossibleTypes=!1,this.config=E({dataIdFromObject:ks},e),this.cache=this.config.cache,this.setRootTypename("Query"),this.setRootTypename("Mutation"),this.setRootTypename("Subscription"),e.possibleTypes&&this.addPossibleTypes(e.possibleTypes),e.typePolicies&&this.addTypePolicies(e.typePolicies)}return r.prototype.identify=function(e,t){var i,n=this,a=t&&(t.typename||((i=t.storeObject)===null||i===void 0?void 0:i.__typename))||e.__typename;if(a===this.rootTypenamesById.ROOT_QUERY)return["ROOT_QUERY"];for(var o=t&&t.storeObject||e,s=E(E({},t),{typename:a,storeObject:o,readField:t&&t.readField||function(){var f=$s(arguments,o);return n.readField(f,{store:n.cache.data,variables:f.variables})}}),c,l=a&&this.getTypePolicy(a),u=l&&l.keyFn||this.config.dataIdFromObject;u;){var d=u(e,s);if(be(d))u=su(d);else{c=d;break}}return c=c?String(c):void 0,s.keyObject?[c,s.keyObject]:[c]},r.prototype.addTypePolicies=function(e){var t=this;Object.keys(e).forEach(function(i){var n=e[i],a=n.queryType,o=n.mutationType,s=n.subscriptionType,c=cr(n,["queryType","mutationType","subscriptionType"]);a&&t.setRootTypename("Query",i),o&&t.setRootTypename("Mutation",i),s&&t.setRootTypename("Subscription",i),Re.call(t.toBeAdded,i)?t.toBeAdded[i].push(c):t.toBeAdded[i]=[c]})},r.prototype.updateTypePolicy=function(e,t){var i=this,n=this.getTypePolicy(e),a=t.keyFields,o=t.fields;function s(c,l){c.merge=typeof l=="function"?l:l===!0?Of:l===!1?$f:c.merge}s(n,t.merge),n.keyFn=a===!1?Bv:be(a)?su(a):typeof a=="function"?a:n.keyFn,o&&Object.keys(o).forEach(function(c){var l=i.getFieldPolicy(e,c,!0),u=o[c];if(typeof u=="function")l.read=u;else{var d=u.keyArgs,f=u.read,p=u.merge;l.keyFn=d===!1?Cf:be(d)?cu(d):typeof d=="function"?d:l.keyFn,typeof f=="function"&&(l.read=f),s(l,p)}l.read&&l.merge&&(l.keyFn=l.keyFn||Cf)})},r.prototype.setRootTypename=function(e,t){t===void 0&&(t=e);var i="ROOT_"+e.toUpperCase(),n=this.rootTypenamesById[i];t!==n&&(__DEV__?D(!n||n===e,"Cannot change root ".concat(e," __typename more than once")):D(!n||n===e,3),n&&delete this.rootIdsByTypename[n],this.rootIdsByTypename[t]=i,this.rootTypenamesById[i]=t)},r.prototype.addPossibleTypes=function(e){var t=this;this.usingPossibleTypes=!0,Object.keys(e).forEach(function(i){t.getSupertypeSet(i,!0),e[i].forEach(function(n){t.getSupertypeSet(n,!0).add(i);var a=n.match(Xl);(!a||a[0]!==n)&&t.fuzzySubtypes.set(n,new RegExp(n))})})},r.prototype.getTypePolicy=function(e){var t=this;if(!Re.call(this.typePolicies,e)){var i=this.typePolicies[e]=Object.create(null);i.fields=Object.create(null);var n=this.supertypeMap.get(e);n&&n.size&&n.forEach(function(o){var s=t.getTypePolicy(o),c=s.fields,l=cr(s,["fields"]);Object.assign(i,l),Object.assign(i.fields,c)})}var a=this.toBeAdded[e];return a&&a.length&&a.splice(0).forEach(function(o){t.updateTypePolicy(e,o)}),this.typePolicies[e]},r.prototype.getFieldPolicy=function(e,t,i){if(e){var n=this.getTypePolicy(e).fields;return n[t]||i&&(n[t]=Object.create(null))}},r.prototype.getSupertypeSet=function(e,t){var i=this.supertypeMap.get(e);return!i&&t&&this.supertypeMap.set(e,i=new Set),i},r.prototype.fragmentMatches=function(e,t,i,n){var a=this;if(!e.typeCondition)return!0;if(!t)return!1;var o=e.typeCondition.name.value;if(t===o)return!0;if(this.usingPossibleTypes&&this.supertypeMap.has(o))for(var s=this.getSupertypeSet(t,!0),c=[s],l=function(h){var m=a.getSupertypeSet(h,!1);m&&m.size&&c.indexOf(m)<0&&c.push(m)},u=!!(i&&this.fuzzySubtypes.size),d=!1,f=0;f<c.length;++f){var p=c[f];if(p.has(o))return s.has(o)||(d&&__DEV__&&D.warn("Inferring subtype ".concat(t," of supertype ").concat(o)),s.add(o)),!0;p.forEach(l),u&&f===c.length-1&&Es(e.selectionSet,i,n)&&(u=!1,d=!0,this.fuzzySubtypes.forEach(function(h,m){var y=t.match(h);y&&y[0]===t&&l(m)}))}return!1},r.prototype.hasKeyArgs=function(e,t){var i=this.getFieldPolicy(e,t,!1);return!!(i&&i.keyFn)},r.prototype.getStoreFieldName=function(e){var t=e.typename,i=e.fieldName,n=this.getFieldPolicy(t,i,!1),a,o=n&&n.keyFn;if(o&&t)for(var s={typename:t,fieldName:i,field:e.field||null,variables:e.variables},c=uu(e);o;){var l=o(c,s);if(be(l))o=cu(l);else{a=l||i;break}}return a===void 0&&(a=e.field?wl(e.field,e.variables):Oa(i,uu(e))),a===!1?i:i===ir(a)?a:i+":"+a},r.prototype.readField=function(e,t){var i=e.from;if(!!i){var n=e.field||e.fieldName;if(!!n){if(e.typename===void 0){var a=t.store.getFieldValue(i,"__typename");a&&(e.typename=a)}var o=this.getStoreFieldName(e),s=ir(o),c=t.store.getFieldValue(i,o),l=this.getFieldPolicy(e.typename,s,!1),u=l&&l.read;if(u){var d=Pf(this,i,e,t,t.store.getStorage(le(i)?i.__ref:i,o));return Vn.withValue(this.cache,u,[c,d])}return c}}},r.prototype.getReadFunction=function(e,t){var i=this.getFieldPolicy(e,t,!1);return i&&i.read},r.prototype.getMergeFunction=function(e,t,i){var n=this.getFieldPolicy(e,t,!1),a=n&&n.merge;return!a&&i&&(n=this.getTypePolicy(i),a=n&&n.merge),a},r.prototype.runMergeFunction=function(e,t,i,n,a){var o=i.field,s=i.typename,c=i.merge;return c===Of?Lf(n.store)(e,t):c===$f?t:(n.overwrite&&(e=void 0),c(e,t,Pf(this,void 0,{typename:s,fieldName:o.name.value,field:o,variables:n.variables},n,a||Object.create(null))))},r}();function Pf(r,e,t,i,n){var a=r.getStoreFieldName(t),o=ir(a),s=t.variables||i.variables,c=i.store,l=c.toReference,u=c.canRead;return{args:uu(t),field:t.field||null,fieldName:o,storeFieldName:a,variables:s,isReference:le,toReference:l,storage:n,cache:r.cache,canRead:u,readField:function(){return r.readField($s(arguments,e,s),i)},mergeObjects:Lf(i.store)}}function $s(r,e,t){var i=r[0],n=r[1],a=r.length,o;return typeof i=="string"?o={fieldName:i,from:a>1?n:e}:(o=E({},i),Re.call(o,"from")||(o.from=e)),__DEV__&&o.from===void 0&&__DEV__&&D.warn("Undefined 'from' passed to readField with arguments ".concat(Ad(Array.from(r)))),o.variables===void 0&&(o.variables=t),o}function Lf(r){return function(t,i){if(be(t)||be(i))throw __DEV__?new ee("Cannot automatically merge arrays"):new ee(4);if(he(t)&&he(i)){var n=r.getFieldValue(t,"__typename"),a=r.getFieldValue(i,"__typename"),o=n&&a&&n!==a;if(o)return i;if(le(t)&&Jr(i))return r.merge(t.__ref,i),t;if(Jr(t)&&le(i))return r.merge(t,i.__ref),i;if(Jr(t)&&Jr(i))return E(E({},t),i)}return i}}function pu(r,e,t){var i="".concat(e).concat(t),n=r.flavors.get(i);return n||r.flavors.set(i,n=r.clientOnly===e&&r.deferred===t?r:E(E({},r),{clientOnly:e,deferred:t})),n}var Mf=function(){function r(e,t,i){this.cache=e,this.reader=t,this.fragments=i}return r.prototype.writeToStore=function(e,t){var i=this,n=t.query,a=t.result,o=t.dataId,s=t.variables,c=t.overwrite,l=ur(n),u=yf();s=E(E({},Ri(l)),s);var d=E(E({store:e,written:Object.create(null),merge:function(p,h){return u.merge(p,h)},variables:s,varString:Rt(s)},Is(n,this.fragments)),{overwrite:!!c,incomingById:new Map,clientOnly:!1,deferred:!1,flavors:new Map}),f=this.processSelectionSet({result:a||Object.create(null),dataId:o,selectionSet:l.selectionSet,mergeTree:{map:new Map},context:d});if(!le(f))throw __DEV__?new ee("Could not identify object ".concat(JSON.stringify(a))):new ee(7);return d.incomingById.forEach(function(p,h){var m=p.storeObject,y=p.mergeTree,b=p.fieldNodeSet,_=lr(h);if(y&&y.map.size){var S=i.applyMerges(y,_,m,d);if(le(S))return;m=S}if(__DEV__&&!d.overwrite){var v=Object.create(null);b.forEach(function(I){I.selectionSet&&(v[I.name.value]=!0)});var C=function(I){return v[ir(I)]===!0},$=function(I){var L=y&&y.map.get(I);return Boolean(L&&L.info&&L.info.merge)};Object.keys(m).forEach(function(I){C(I)&&!$(I)&&Vv(_,m,I,d.store)})}e.merge(h,m)}),e.retain(f.__ref),f},r.prototype.processSelectionSet=function(e){var t=this,i=e.dataId,n=e.result,a=e.selectionSet,o=e.context,s=e.mergeTree,c=this.cache.policies,l=Object.create(null),u=i&&c.rootTypenamesById[i]||$a(n,a,o.fragmentMap)||i&&o.store.get(i,"__typename");typeof u=="string"&&(l.__typename=u);var d=function(){var S=$s(arguments,l,o.variables);if(le(S.from)){var v=o.incomingById.get(S.from.__ref);if(v){var C=c.readField(E(E({},S),{from:v.storeObject}),o);if(C!==void 0)return C}}return c.readField(S,o)},f=new Set;this.flattenFields(a,n,o,u).forEach(function(S,v){var C,$=qt(v),I=n[$];if(f.add(v),I!==void 0){var L=c.getStoreFieldName({typename:u,fieldName:v.name.value,field:v,variables:S.variables}),M=Nf(s,L),N=t.processFieldValue(I,v,v.selectionSet?pu(S,!1,!1):S,M),W=void 0;v.selectionSet&&(le(N)||Jr(N))&&(W=d("__typename",N));var Ie=c.getMergeFunction(u,v.name.value,W);Ie?M.info={field:v,typename:u,merge:Ie}:Df(s,L),l=S.merge(l,(C={},C[L]=N,C))}else __DEV__&&!S.clientOnly&&!S.deferred&&!Li.added(v)&&!c.getReadFunction(u,v.name.value)&&__DEV__&&D.error("Missing field '".concat(qt(v),"' while writing result ").concat(JSON.stringify(n,null,2)).substring(0,1e3))});try{var p=c.identify(n,{typename:u,selectionSet:a,fragmentMap:o.fragmentMap,storeObject:l,readField:d}),h=p[0],m=p[1];i=i||h,m&&(l=o.merge(l,m))}catch(S){if(!i)throw S}if(typeof i=="string"){var y=lr(i),b=o.written[i]||(o.written[i]=[]);if(b.indexOf(a)>=0||(b.push(a),this.reader&&this.reader.isFresh(n,y,a,o)))return y;var _=o.incomingById.get(i);return _?(_.storeObject=o.merge(_.storeObject,l),_.mergeTree=du(_.mergeTree,s),f.forEach(function(S){return _.fieldNodeSet.add(S)})):o.incomingById.set(i,{storeObject:l,mergeTree:Ps(s)?void 0:s,fieldNodeSet:f}),y}return l},r.prototype.processFieldValue=function(e,t,i,n){var a=this;return!t.selectionSet||e===null?__DEV__?ds(e):e:be(e)?e.map(function(o,s){var c=a.processFieldValue(o,t,i,Nf(n,s));return Df(n,s),c}):this.processSelectionSet({result:e,selectionSet:t.selectionSet,context:i,mergeTree:n})},r.prototype.flattenFields=function(e,t,i,n){n===void 0&&(n=$a(t,e,i.fragmentMap));var a=new Map,o=this.cache.policies,s=new pr(!1);return function c(l,u){var d=s.lookup(l,u.clientOnly,u.deferred);d.visited||(d.visited=!0,l.selections.forEach(function(f){if(!!kr(f,i.variables)){var p=u.clientOnly,h=u.deferred;if(!(p&&h)&&Ve(f.directives)&&f.directives.forEach(function(b){var _=b.name.value;if(_==="client"&&(p=!0),_==="defer"){var S=Ar(b,i.variables);(!S||S.if!==!1)&&(h=!0)}}),Pt(f)){var m=a.get(f);m&&(p=p&&m.clientOnly,h=h&&m.deferred),a.set(f,pu(i,p,h))}else{var y=Oi(f,i.lookupFragment);if(!y&&f.kind===je.FRAGMENT_SPREAD)throw __DEV__?new ee("No fragment named ".concat(f.name.value)):new ee(8);y&&o.fragmentMatches(y,n,t,i.variables)&&c(y.selectionSet,pu(i,p,h))}}}))}(e,i),a},r.prototype.applyMerges=function(e,t,i,n,a){var o,s=this;if(e.map.size&&!le(i)){var c=!be(i)&&(le(t)||Jr(t))?t:void 0,l=i;c&&!a&&(a=[le(c)?c.__ref:c]);var u,d=function(f,p){return be(f)?typeof p=="number"?f[p]:void 0:n.store.getFieldValue(f,String(p))};e.map.forEach(function(f,p){var h=d(c,p),m=d(l,p);if(m!==void 0){a&&a.push(p);var y=s.applyMerges(f,h,m,n,a);y!==m&&(u=u||new Map,u.set(p,y)),a&&D(a.pop()===p)}}),u&&(i=be(l)?l.slice(0):E({},l),u.forEach(function(f,p){i[p]=f}))}return e.info?this.cache.policies.runMergeFunction(t,i,e.info,n,a&&(o=n.store).getStorage.apply(o,a)):i},r}();var Uf=[];function Nf(r,e){var t=r.map;return t.has(e)||t.set(e,Uf.pop()||{map:new Map}),t.get(e)}function du(r,e){if(r===e||!e||Ps(e))return r;if(!r||Ps(r))return e;var t=r.info&&e.info?E(E({},r.info),e.info):r.info||e.info,i=r.map.size&&e.map.size,n=i?new Map:r.map.size?r.map:e.map,a={info:t,map:n};if(i){var o=new Set(e.map.keys());r.map.forEach(function(s,c){a.map.set(c,du(s,e.map.get(c))),o.delete(c)}),o.forEach(function(s){a.map.set(s,du(e.map.get(s),r.map.get(s)))})}return a}function Ps(r){return!r||!(r.info||r.map.size)}function Df(r,e){var t=r.map,i=t.get(e);i&&Ps(i)&&(Uf.push(i),t.delete(e))}var Ff=new Set;function Vv(r,e,t,i){var n=function(d){var f=i.getFieldValue(d,t);return typeof f=="object"&&f},a=n(r);if(!!a){var o=n(e);if(!!o&&!le(a)&&!Ae(a,o)&&!Object.keys(a).every(function(d){return i.getFieldValue(o,d)!==void 0})){var s=i.getFieldValue(r,"__typename")||i.getFieldValue(e,"__typename"),c=ir(t),l="".concat(s,".").concat(c);if(!Ff.has(l)){Ff.add(l);var u=[];!be(a)&&!be(o)&&[a,o].forEach(function(d){var f=i.getFieldValue(d,"__typename");typeof f=="string"&&!u.includes(f)&&u.push(f)}),__DEV__&&D.warn("Cache data may be lost when replacing the ".concat(c," field of a ").concat(s,` object.
37
-
38
- To address this problem (which is not a bug in Apollo Client), `).concat(u.length?"either ensure all objects of type "+u.join(" and ")+" have an ID or a custom merge function, or ":"","define a custom merge function for the ").concat(l,` field, so InMemoryCache can safely merge these objects:
39
-
40
- existing: `).concat(JSON.stringify(a).slice(0,1e3),`
41
- incoming: `).concat(JSON.stringify(o).slice(0,1e3),`
42
-
43
- For more information about these options, please refer to the documentation:
44
-
45
- * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers
46
- * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects
47
- `))}}}}var Rs=function(r){Pe(e,r);function e(t){t===void 0&&(t={});var i=r.call(this)||this;return i.watches=new Set,i.typenameDocumentCache=new Map,i.makeVar=Os,i.txCount=0,i.config=mf(t),i.addTypename=!!i.config.addTypename,i.policies=new Rf({cache:i,dataIdFromObject:i.config.dataIdFromObject,possibleTypes:i.config.possibleTypes,typePolicies:i.config.typePolicies}),i.init(),i}return e.prototype.init=function(){var t=this.data=new Bn.Root({policies:this.policies,resultCaching:this.config.resultCaching});this.optimisticData=t.stump,this.resetResultCache()},e.prototype.resetResultCache=function(t){var i=this,n=this.storeReader,a=this.config.fragments;this.storeWriter=new Mf(this,this.storeReader=new _f({cache:this,addTypename:this.addTypename,resultCacheMaxSize:this.config.resultCacheMaxSize,canonizeResults:As(this.config),canon:t?void 0:n&&n.canon,fragments:a}),a),this.maybeBroadcastWatch=Di(function(o,s){return i.broadcastWatch(o,s)},{max:this.config.resultCacheMaxSize,makeCacheKey:function(o){var s=o.optimistic?i.optimisticData:i.data;if(Fi(s)){var c=o.optimistic,l=o.id,u=o.variables;return s.makeCacheKey(o.query,o.callback,Rt({optimistic:c,id:l,variables:u}))}}}),new Set([this.data.group,this.optimisticData.group]).forEach(function(o){return o.resetCaching()})},e.prototype.restore=function(t){return this.init(),t&&this.data.replace(t),this},e.prototype.extract=function(t){return t===void 0&&(t=!1),(t?this.optimisticData:this.data).extract()},e.prototype.read=function(t){var i=t.returnPartialData,n=i===void 0?!1:i;try{return this.storeReader.diffQueryAgainstStore(E(E({},t),{store:t.optimistic?this.optimisticData:this.data,config:this.config,returnPartialData:n})).result||null}catch(a){if(a instanceof Ba)return null;throw a}},e.prototype.write=function(t){try{return++this.txCount,this.storeWriter.writeToStore(this.data,t)}finally{!--this.txCount&&t.broadcast!==!1&&this.broadcastWatches()}},e.prototype.modify=function(t){if(Re.call(t,"id")&&!t.id)return!1;var i=t.optimistic?this.optimisticData:this.data;try{return++this.txCount,i.modify(t.id||"ROOT_QUERY",t.fields)}finally{!--this.txCount&&t.broadcast!==!1&&this.broadcastWatches()}},e.prototype.diff=function(t){return this.storeReader.diffQueryAgainstStore(E(E({},t),{store:t.optimistic?this.optimisticData:this.data,rootId:t.id||"ROOT_QUERY",config:this.config}))},e.prototype.watch=function(t){var i=this;return this.watches.size||Ef(this),this.watches.add(t),t.immediate&&this.maybeBroadcastWatch(t),function(){i.watches.delete(t)&&!i.watches.size&&au(i),i.maybeBroadcastWatch.forget(t)}},e.prototype.gc=function(t){Rt.reset();var i=this.optimisticData.gc();return t&&!this.txCount&&(t.resetResultCache?this.resetResultCache(t.resetResultIdentities):t.resetResultIdentities&&this.storeReader.resetCanon()),i},e.prototype.retain=function(t,i){return(i?this.optimisticData:this.data).retain(t)},e.prototype.release=function(t,i){return(i?this.optimisticData:this.data).release(t)},e.prototype.identify=function(t){if(le(t))return t.__ref;try{return this.policies.identify(t)[0]}catch(i){__DEV__&&D.warn(i)}},e.prototype.evict=function(t){if(!t.id){if(Re.call(t,"id"))return!1;t=E(E({},t),{id:"ROOT_QUERY"})}try{return++this.txCount,this.optimisticData.evict(t,this.data)}finally{!--this.txCount&&t.broadcast!==!1&&this.broadcastWatches()}},e.prototype.reset=function(t){var i=this;return this.init(),Rt.reset(),t&&t.discardWatches?(this.watches.forEach(function(n){return i.maybeBroadcastWatch.forget(n)}),this.watches.clear(),au(this)):this.broadcastWatches(),Promise.resolve()},e.prototype.removeOptimistic=function(t){var i=this.optimisticData.removeLayer(t);i!==this.optimisticData&&(this.optimisticData=i,this.broadcastWatches())},e.prototype.batch=function(t){var i=this,n=t.update,a=t.optimistic,o=a===void 0?!0:a,s=t.removeOptimistic,c=t.onWatchUpdated,l,u=function(f){var p=i,h=p.data,m=p.optimisticData;++i.txCount,f&&(i.data=i.optimisticData=f);try{return l=n(i)}finally{--i.txCount,i.data=h,i.optimisticData=m}},d=new Set;return c&&!this.txCount&&this.broadcastWatches(E(E({},t),{onWatchUpdated:function(f){return d.add(f),!1}})),typeof o=="string"?this.optimisticData=this.optimisticData.addLayer(o,u):o===!1?u(this.data):u(),typeof s=="string"&&(this.optimisticData=this.optimisticData.removeLayer(s)),c&&d.size?(this.broadcastWatches(E(E({},t),{onWatchUpdated:function(f,p){var h=c.call(this,f,p);return h!==!1&&d.delete(f),h}})),d.size&&d.forEach(function(f){return i.maybeBroadcastWatch.dirty(f)})):this.broadcastWatches(t),l},e.prototype.performTransaction=function(t,i){return this.batch({update:t,optimistic:i||i!==null})},e.prototype.transformDocument=function(t){if(this.addTypename){var i=this.typenameDocumentCache.get(t);return i||(i=Li(t),this.typenameDocumentCache.set(t,i),this.typenameDocumentCache.set(i,i)),i}return t},e.prototype.transformForLink=function(t){var i=this.config.fragments;return i?i.transform(t):t},e.prototype.broadcastWatches=function(t){var i=this;this.txCount||this.watches.forEach(function(n){return i.maybeBroadcastWatch(n,t)})},e.prototype.broadcastWatch=function(t,i){var n=t.lastDiff,a=this.diff(t);i&&(t.optimistic&&typeof i.optimistic=="string"&&(a.fromOptimisticTransaction=!0),i.onWatchUpdated&&i.onWatchUpdated.call(this,t,a,n)===!1)||(!n||!Ae(n.result,a.result))&&t.callback(t.lastDiff=a,n)},e}(Yl);function jf(r){return r.hasOwnProperty("graphQLErrors")}var Qv=function(r){var e="";if(Ve(r.graphQLErrors)||Ve(r.clientErrors)){var t=(r.graphQLErrors||[]).concat(r.clientErrors||[]);t.forEach(function(i){var n=i?i.message:"Error message not found.";e+="".concat(n,`
48
- `)})}return r.networkError&&(e+="".concat(r.networkError.message,`
49
- `)),e=e.replace(/\n$/,""),e},Ir=function(r){Pe(e,r);function e(t){var i=t.graphQLErrors,n=t.clientErrors,a=t.networkError,o=t.errorMessage,s=t.extraInfo,c=r.call(this,o)||this;return c.name="ApolloError",c.graphQLErrors=i||[],c.clientErrors=n||[],c.networkError=a||null,c.message=o||Qv(c),c.extraInfo=s,c.__proto__=e.prototype,c}return e}(Error);var ge;(function(r){r[r.loading=1]="loading",r[r.setVariables=2]="setVariables",r[r.fetchMore=3]="fetchMore",r[r.refetch=4]="refetch",r[r.poll=6]="poll",r[r.ready=7]="ready",r[r.error=8]="error"})(ge||(ge={}));function Yr(r){return r?r<7:!1}var Hv=Object.assign,zv=Object.hasOwnProperty,Ls=function(r){Pe(e,r);function e(t){var i=t.queryManager,n=t.queryInfo,a=t.options,o=r.call(this,function(y){try{var b=y._subscription._observer;b&&!b.error&&(b.error=Wv)}catch{}var _=!o.observers.size;o.observers.add(y);var S=o.last;return S&&S.error?y.error&&y.error(S.error):S&&S.result&&y.next&&y.next(S.result),_&&o.reobserve().catch(function(){}),function(){o.observers.delete(y)&&!o.observers.size&&o.tearDownQuery()}})||this;o.observers=new Set,o.subscriptions=new Set,o.queryInfo=n,o.queryManager=i,o.isTornDown=!1;var s=i.defaultOptions.watchQuery,c=s===void 0?{}:s,l=c.fetchPolicy,u=l===void 0?"cache-first":l,d=a.fetchPolicy,f=d===void 0?u:d,p=a.initialFetchPolicy,h=p===void 0?f==="standby"?u:f:p;o.options=E(E({},a),{initialFetchPolicy:h,fetchPolicy:f}),o.queryId=n.queryId||i.generateQueryId();var m=ur(o.query);return o.queryName=m&&m.name&&m.name.value,o}return Object.defineProperty(e.prototype,"query",{get:function(){return this.queryManager.transform(this.options.query).document},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"variables",{get:function(){return this.options.variables},enumerable:!1,configurable:!0}),e.prototype.result=function(){var t=this;return new Promise(function(i,n){var a={next:function(s){i(s),t.observers.delete(a),t.observers.size||t.queryManager.removeQuery(t.queryId),setTimeout(function(){o.unsubscribe()},0)},error:n},o=t.subscribe(a)})},e.prototype.getCurrentResult=function(t){t===void 0&&(t=!0);var i=this.getLastResult(!0),n=this.queryInfo.networkStatus||i&&i.networkStatus||ge.ready,a=E(E({},i),{loading:Yr(n),networkStatus:n}),o=this.options.fetchPolicy,s=o===void 0?"cache-first":o;if(!(s==="network-only"||s==="no-cache"||s==="standby"||this.queryManager.transform(this.options.query).hasForcedResolvers)){var c=this.queryInfo.getDiff();(c.complete||this.options.returnPartialData)&&(a.data=c.result),Ae(a.data,{})&&(a.data=void 0),c.complete?(delete a.partial,c.complete&&a.networkStatus===ge.loading&&(s==="cache-first"||s==="cache-only")&&(a.networkStatus=ge.ready,a.loading=!1)):a.partial=!0,__DEV__&&!c.complete&&!this.options.partialRefetch&&!a.loading&&!a.data&&!a.error&&hu(c.missing)}return t&&this.updateLastResult(a),a},e.prototype.isDifferentFromLastResult=function(t,i){return!this.last||!Ae(this.last.result,t)||i&&!Ae(this.last.variables,i)},e.prototype.getLast=function(t,i){var n=this.last;if(n&&n[t]&&(!i||Ae(n.variables,this.variables)))return n[t]},e.prototype.getLastResult=function(t){return this.getLast("result",t)},e.prototype.getLastError=function(t){return this.getLast("error",t)},e.prototype.resetLastResults=function(){delete this.last,this.isTornDown=!1},e.prototype.resetQueryStoreErrors=function(){this.queryManager.resetErrors(this.queryId)},e.prototype.refetch=function(t){var i,n={pollInterval:0},a=this.options.fetchPolicy;if(a==="cache-and-network"?n.fetchPolicy=a:a==="no-cache"?n.fetchPolicy="no-cache":n.fetchPolicy="network-only",__DEV__&&t&&zv.call(t,"variables")){var o=Pa(this.query),s=o.variableDefinitions;(!s||!s.some(function(c){return c.variable.name.value==="variables"}))&&__DEV__&&D.warn("Called refetch(".concat(JSON.stringify(t),") for query ").concat(((i=o.name)===null||i===void 0?void 0:i.value)||JSON.stringify(o),`, which does not declare a $variables variable.
50
- Did you mean to call refetch(variables) instead of refetch({ variables })?`))}return t&&!Ae(this.options.variables,t)&&(n.variables=this.options.variables=E(E({},this.options.variables),t)),this.queryInfo.resetLastWrite(),this.reobserve(n,ge.refetch)},e.prototype.fetchMore=function(t){var i=this,n=E(E({},t.query?t:E(E(E(E({},this.options),{query:this.query}),t),{variables:E(E({},this.options.variables),t.variables)})),{fetchPolicy:"no-cache"}),a=this.queryManager.generateQueryId(),o=this.queryInfo,s=o.networkStatus;o.networkStatus=ge.fetchMore,n.notifyOnNetworkStatusChange&&this.observe();var c=new Set;return this.queryManager.fetchQuery(a,n,ge.fetchMore).then(function(l){return i.queryManager.removeQuery(a),o.networkStatus===ge.fetchMore&&(o.networkStatus=s),i.queryManager.cache.batch({update:function(u){var d=t.updateQuery;d?u.updateQuery({query:i.query,variables:i.variables,returnPartialData:!0,optimistic:!1},function(f){return d(f,{fetchMoreResult:l.data,variables:n.variables})}):u.writeQuery({query:n.query,variables:n.variables,data:l.data})},onWatchUpdated:function(u){c.add(u.query)}}),l}).finally(function(){c.has(i.query)||fu(i)})},e.prototype.subscribeToMore=function(t){var i=this,n=this.queryManager.startGraphQLSubscription({query:t.document,variables:t.variables,context:t.context}).subscribe({next:function(a){var o=t.updateQuery;o&&i.updateQuery(function(s,c){var l=c.variables;return o(s,{subscriptionData:a,variables:l})})},error:function(a){if(t.onError){t.onError(a);return}__DEV__&&D.error("Unhandled GraphQL subscription error",a)}});return this.subscriptions.add(n),function(){i.subscriptions.delete(n)&&n.unsubscribe()}},e.prototype.setOptions=function(t){return this.reobserve(t)},e.prototype.setVariables=function(t){return Ae(this.variables,t)?this.observers.size?this.result():Promise.resolve():(this.options.variables=t,this.observers.size?this.reobserve({fetchPolicy:this.options.initialFetchPolicy,variables:t},ge.setVariables):Promise.resolve())},e.prototype.updateQuery=function(t){var i=this.queryManager,n=i.cache.diff({query:this.options.query,variables:this.variables,returnPartialData:!0,optimistic:!1}).result,a=t(n,{variables:this.variables});a&&(i.cache.writeQuery({query:this.options.query,data:a,variables:this.variables}),i.broadcastQueries())},e.prototype.startPolling=function(t){this.options.pollInterval=t,this.updatePolling()},e.prototype.stopPolling=function(){this.options.pollInterval=0,this.updatePolling()},e.prototype.applyNextFetchPolicy=function(t,i){if(i.nextFetchPolicy){var n=i.fetchPolicy,a=n===void 0?"cache-first":n,o=i.initialFetchPolicy,s=o===void 0?a:o;a==="standby"||(typeof i.nextFetchPolicy=="function"?i.fetchPolicy=i.nextFetchPolicy(a,{reason:t,options:i,observable:this,initialFetchPolicy:s}):t==="variables-changed"?i.fetchPolicy=s:i.fetchPolicy=i.nextFetchPolicy)}return i.fetchPolicy},e.prototype.fetch=function(t,i){return this.queryManager.setObservableQuery(this),this.queryManager.fetchQueryObservable(this.queryId,t,i)},e.prototype.updatePolling=function(){var t=this;if(!this.queryManager.ssrMode){var i=this,n=i.pollingInfo,a=i.options.pollInterval;if(!a){n&&(clearTimeout(n.timeout),delete this.pollingInfo);return}if(!(n&&n.interval===a)){__DEV__?D(a,"Attempted to start a polling query without a polling interval."):D(a,13);var o=n||(this.pollingInfo={});o.interval=a;var s=function(){t.pollingInfo&&(Yr(t.queryInfo.networkStatus)?c():t.reobserve({fetchPolicy:t.options.initialFetchPolicy==="no-cache"?"no-cache":"network-only"},ge.poll).then(c,c))},c=function(){var l=t.pollingInfo;l&&(clearTimeout(l.timeout),l.timeout=setTimeout(s,l.interval))};c()}}},e.prototype.updateLastResult=function(t,i){return i===void 0&&(i=this.variables),this.last=E(E({},this.last),{result:this.queryManager.assumeImmutableResults?t:ds(t),variables:i}),Ve(t.errors)||delete this.last.error,this.last},e.prototype.reobserve=function(t,i){var n=this;this.isTornDown=!1;var a=i===ge.refetch||i===ge.fetchMore||i===ge.poll,o=this.options.variables,s=this.options.fetchPolicy,c=Gr(this.options,t||{}),l=a?c:Hv(this.options,c);a||(this.updatePolling(),t&&t.variables&&!Ae(t.variables,o)&&l.fetchPolicy!=="standby"&&l.fetchPolicy===s&&(this.applyNextFetchPolicy("variables-changed",l),i===void 0&&(i=ge.setVariables)));var u=l.variables&&E({},l.variables),d=this.fetch(l,i),f={next:function(p){n.reportResult(p,u)},error:function(p){n.reportError(p,u)}};return a||(this.concast&&this.observer&&this.concast.removeObserver(this.observer),this.concast=d,this.observer=f),d.addObserver(f),d.promise},e.prototype.observe=function(){this.reportResult(this.getCurrentResult(!1),this.variables)},e.prototype.reportResult=function(t,i){var n=this.getLastError();(n||this.isDifferentFromLastResult(t,i))&&((n||!t.partial||this.options.returnPartialData)&&this.updateLastResult(t,i),Ni(this.observers,"next",t))},e.prototype.reportError=function(t,i){var n=E(E({},this.getLastResult()),{error:t,errors:t.graphQLErrors,networkStatus:ge.error,loading:!1});this.updateLastResult(n,i),Ni(this.observers,"error",this.last.error=t)},e.prototype.hasObservers=function(){return this.observers.size>0},e.prototype.tearDownQuery=function(){this.isTornDown||(this.concast&&this.observer&&(this.concast.removeObserver(this.observer),delete this.concast,delete this.observer),this.stopPolling(),this.subscriptions.forEach(function(t){return t.unsubscribe()}),this.subscriptions.clear(),this.queryManager.stopQuery(this.queryId),this.observers.clear(),this.isTornDown=!0)},e}(se);hs(Ls);function fu(r){var e=r.options,t=e.fetchPolicy,i=e.nextFetchPolicy;return t==="cache-and-network"||t==="network-only"?r.reobserve({fetchPolicy:"cache-first",nextFetchPolicy:function(){return this.nextFetchPolicy=i,typeof i=="function"?i.apply(this,arguments):t}}):r.reobserve()}function Wv(r){__DEV__&&D.error("Unhandled error",r.message,r.stack)}function hu(r){__DEV__&&r&&__DEV__&&D.debug("Missing cache result fields: ".concat(JSON.stringify(r)),r)}var Ns=function(){function r(e){var t=e.cache,i=e.client,n=e.resolvers,a=e.fragmentMatcher;this.selectionsToResolveCache=new WeakMap,this.cache=t,i&&(this.client=i),n&&this.addResolvers(n),a&&this.setFragmentMatcher(a)}return r.prototype.addResolvers=function(e){var t=this;this.resolvers=this.resolvers||{},Array.isArray(e)?e.forEach(function(i){t.resolvers=Il(t.resolvers,i)}):this.resolvers=Il(this.resolvers,e)},r.prototype.setResolvers=function(e){this.resolvers={},this.addResolvers(e)},r.prototype.getResolvers=function(){return this.resolvers||{}},r.prototype.runResolvers=function(e){var t=e.document,i=e.remoteResult,n=e.context,a=e.variables,o=e.onlyRunForcedResolvers,s=o===void 0?!1:o;return Xt(this,void 0,void 0,function(){return er(this,function(c){return t?[2,this.resolveDocument(t,i.data,n,a,this.fragmentMatcher,s).then(function(l){return E(E({},i),{data:l.result})})]:[2,i]})})},r.prototype.setFragmentMatcher=function(e){this.fragmentMatcher=e},r.prototype.getFragmentMatcher=function(){return this.fragmentMatcher},r.prototype.clientQuery=function(e){return Pn(["client"],e)&&this.resolvers?e:null},r.prototype.serverQuery=function(e){return Al(e)},r.prototype.prepareContext=function(e){var t=this.cache;return E(E({},e),{cache:t,getCacheKey:function(i){return t.identify(i)}})},r.prototype.addExportedVariables=function(e,t,i){return t===void 0&&(t={}),i===void 0&&(i={}),Xt(this,void 0,void 0,function(){return er(this,function(n){return e?[2,this.resolveDocument(e,this.buildRootValueFromCache(e,t)||{},this.prepareContext(i),t).then(function(a){return E(E({},t),a.exportedVariables)})]:[2,E({},t)]})})},r.prototype.shouldForceResolvers=function(e){var t=!1;return st(e,{Directive:{enter:function(i){if(i.name.value==="client"&&i.arguments&&(t=i.arguments.some(function(n){return n.name.value==="always"&&n.value.kind==="BooleanValue"&&n.value.value===!0}),t))return Ti}}}),t},r.prototype.buildRootValueFromCache=function(e,t){return this.cache.diff({query:kl(e),variables:t,returnPartialData:!0,optimistic:!1}).result},r.prototype.resolveDocument=function(e,t,i,n,a,o){return i===void 0&&(i={}),n===void 0&&(n={}),a===void 0&&(a=function(){return!0}),o===void 0&&(o=!1),Xt(this,void 0,void 0,function(){var s,c,l,u,d,f,p,h,m,y,b;return er(this,function(_){return s=Pi(e),c=$i(e),l=Ci(c),u=this.collectSelectionsToResolve(s,l),d=s.operation,f=d?d.charAt(0).toUpperCase()+d.slice(1):"Query",p=this,h=p.cache,m=p.client,y={fragmentMap:l,context:E(E({},i),{cache:h,client:m}),variables:n,fragmentMatcher:a,defaultOperationType:f,exportedVariables:{},selectionsToResolve:u,onlyRunForcedResolvers:o},b=!1,[2,this.resolveSelectionSet(s.selectionSet,b,t,y).then(function(S){return{result:S,exportedVariables:y.exportedVariables}})]})})},r.prototype.resolveSelectionSet=function(e,t,i,n){return Xt(this,void 0,void 0,function(){var a,o,s,c,l,u=this;return er(this,function(d){return a=n.fragmentMap,o=n.context,s=n.variables,c=[i],l=function(f){return Xt(u,void 0,void 0,function(){var p,h;return er(this,function(m){return!t&&!n.selectionsToResolve.has(f)?[2]:kr(f,s)?Pt(f)?[2,this.resolveField(f,t,i,n).then(function(y){var b;typeof y<"u"&&c.push((b={},b[qt(f)]=y,b))})]:(Sl(f)?p=f:(p=a[f.name.value],__DEV__?D(p,"No fragment named ".concat(f.name.value)):D(p,11)),p&&p.typeCondition&&(h=p.typeCondition.name.value,n.fragmentMatcher(i,h,o))?[2,this.resolveSelectionSet(p.selectionSet,t,i,n).then(function(y){c.push(y)})]:[2]):[2]})})},[2,Promise.all(e.selections.map(l)).then(function(){return Ra(c)})]})})},r.prototype.resolveField=function(e,t,i,n){return Xt(this,void 0,void 0,function(){var a,o,s,c,l,u,d,f,p,h=this;return er(this,function(m){return i?(a=n.variables,o=e.name.value,s=qt(e),c=o!==s,l=i[s]||i[o],u=Promise.resolve(l),(!n.onlyRunForcedResolvers||this.shouldForceResolvers(e))&&(d=i.__typename||n.defaultOperationType,f=this.resolvers&&this.resolvers[d],f&&(p=f[c?o:s],p&&(u=Promise.resolve(Vn.withValue(this.cache,p,[i,Ar(e,a),n.context,{field:e,fragmentMap:n.fragmentMap}]))))),[2,u.then(function(y){var b,_;if(y===void 0&&(y=l),e.directives&&e.directives.forEach(function(v){v.name.value==="export"&&v.arguments&&v.arguments.forEach(function(C){C.name.value==="as"&&C.value.kind==="StringValue"&&(n.exportedVariables[C.value.value]=y)})}),!e.selectionSet||y==null)return y;var S=(_=(b=e.directives)===null||b===void 0?void 0:b.some(function(v){return v.name.value==="client"}))!==null&&_!==void 0?_:!1;if(Array.isArray(y))return h.resolveSubSelectedArray(e,t||S,y,n);if(e.selectionSet)return h.resolveSelectionSet(e.selectionSet,t||S,y,n)})]):[2,null]})})},r.prototype.resolveSubSelectedArray=function(e,t,i,n){var a=this;return Promise.all(i.map(function(o){if(o===null)return null;if(Array.isArray(o))return a.resolveSubSelectedArray(e,t,o,n);if(e.selectionSet)return a.resolveSelectionSet(e.selectionSet,t,o,n)}))},r.prototype.collectSelectionsToResolve=function(e,t){var i=function(o){return!Array.isArray(o)},n=this.selectionsToResolveCache;function a(o){if(!n.has(o)){var s=new Set;n.set(o,s),st(o,{Directive:function(c,l,u,d,f){c.name.value==="client"&&f.forEach(function(p){i(p)&&Ta(p)&&s.add(p)})},FragmentSpread:function(c,l,u,d,f){var p=t[c.name.value];__DEV__?D(p,"No fragment named ".concat(c.name.value)):D(p,12);var h=a(p);h.size>0&&(f.forEach(function(m){i(m)&&Ta(m)&&s.add(m)}),s.add(c),h.forEach(function(m){s.add(m)}))}})}return n.get(o)}return a(e)},r}();var Hn=new(Bt?WeakMap:Map);function mu(r,e){var t=r[e];typeof t=="function"&&(r[e]=function(){return Hn.set(r,(Hn.get(r)+1)%1e15),t.apply(this,arguments)})}function qf(r){r.notifyTimeout&&(clearTimeout(r.notifyTimeout),r.notifyTimeout=void 0)}var Ds=function(){function r(e,t){t===void 0&&(t=e.generateQueryId()),this.queryId=t,this.listeners=new Set,this.document=null,this.lastRequestId=1,this.subscriptions=new Set,this.stopped=!1,this.dirty=!1,this.observableQuery=null;var i=this.cache=e.cache;Hn.has(i)||(Hn.set(i,0),mu(i,"evict"),mu(i,"modify"),mu(i,"reset"))}return r.prototype.init=function(e){var t=e.networkStatus||ge.loading;return this.variables&&this.networkStatus!==ge.loading&&!Ae(this.variables,e.variables)&&(t=ge.setVariables),Ae(e.variables,this.variables)||(this.lastDiff=void 0),Object.assign(this,{document:e.document,variables:e.variables,networkError:null,graphQLErrors:this.graphQLErrors||[],networkStatus:t}),e.observableQuery&&this.setObservableQuery(e.observableQuery),e.lastRequestId&&(this.lastRequestId=e.lastRequestId),this},r.prototype.reset=function(){qf(this),this.dirty=!1},r.prototype.getDiff=function(e){e===void 0&&(e=this.variables);var t=this.getDiffOptions(e);if(this.lastDiff&&Ae(t,this.lastDiff.options))return this.lastDiff.diff;this.updateWatch(this.variables=e);var i=this.observableQuery;if(i&&i.options.fetchPolicy==="no-cache")return{complete:!1};var n=this.cache.diff(t);return this.updateLastDiff(n,t),n},r.prototype.updateLastDiff=function(e,t){this.lastDiff=e?{diff:e,options:t||this.getDiffOptions()}:void 0},r.prototype.getDiffOptions=function(e){var t;return e===void 0&&(e=this.variables),{query:this.document,variables:e,returnPartialData:!0,optimistic:!0,canonizeResults:(t=this.observableQuery)===null||t===void 0?void 0:t.options.canonizeResults}},r.prototype.setDiff=function(e){var t=this,i=this.lastDiff&&this.lastDiff.diff;this.updateLastDiff(e),!this.dirty&&!Ae(i&&i.result,e&&e.result)&&(this.dirty=!0,this.notifyTimeout||(this.notifyTimeout=setTimeout(function(){return t.notify()},0)))},r.prototype.setObservableQuery=function(e){var t=this;e!==this.observableQuery&&(this.oqListener&&this.listeners.delete(this.oqListener),this.observableQuery=e,e?(e.queryInfo=this,this.listeners.add(this.oqListener=function(){var i=t.getDiff();i.fromOptimisticTransaction?e.observe():fu(e)})):delete this.oqListener)},r.prototype.notify=function(){var e=this;qf(this),this.shouldNotify()&&this.listeners.forEach(function(t){return t(e)}),this.dirty=!1},r.prototype.shouldNotify=function(){if(!this.dirty||!this.listeners.size)return!1;if(Yr(this.networkStatus)&&this.observableQuery){var e=this.observableQuery.options.fetchPolicy;if(e!=="cache-only"&&e!=="cache-and-network")return!1}return!0},r.prototype.stop=function(){if(!this.stopped){this.stopped=!0,this.reset(),this.cancel(),this.cancel=r.prototype.cancel,this.subscriptions.forEach(function(t){return t.unsubscribe()});var e=this.observableQuery;e&&e.stopPolling()}},r.prototype.cancel=function(){},r.prototype.updateWatch=function(e){var t=this;e===void 0&&(e=this.variables);var i=this.observableQuery;if(!(i&&i.options.fetchPolicy==="no-cache")){var n=E(E({},this.getDiffOptions(e)),{watcher:this,callback:function(a){return t.setDiff(a)}});(!this.lastWatch||!Ae(n,this.lastWatch))&&(this.cancel(),this.cancel=this.cache.watch(this.lastWatch=n))}},r.prototype.resetLastWrite=function(){this.lastWrite=void 0},r.prototype.shouldWrite=function(e,t){var i=this.lastWrite;return!(i&&i.dmCount===Hn.get(this.cache)&&Ae(t,i.variables)&&Ae(e.data,i.result.data))},r.prototype.markResult=function(e,t,i,n){var a=this,o=new _t,s=Ve(e.errors)?e.errors.slice(0):[];if(this.reset(),"incremental"in e&&Ve(e.incremental)){var c=ms(this.getDiff().result,e);e.data=c}else if("hasNext"in e&&e.hasNext){var l=this.getDiff();e.data=o.merge(l.result,e.data)}this.graphQLErrors=s,i.fetchPolicy==="no-cache"?this.updateLastDiff({result:e.data,complete:!0},this.getDiffOptions(i.variables)):n!==0&&(Fs(e,i.errorPolicy)?this.cache.performTransaction(function(u){if(a.shouldWrite(e,i.variables))u.writeQuery({query:t,data:e.data,variables:i.variables,overwrite:n===1}),a.lastWrite={result:e,variables:i.variables,dmCount:Hn.get(a.cache)};else if(a.lastDiff&&a.lastDiff.diff.complete){e.data=a.lastDiff.diff.result;return}var d=a.getDiffOptions(i.variables),f=u.diff(d);a.stopped||a.updateWatch(i.variables),a.updateLastDiff(f,d),f.complete&&(e.data=f.result)}):this.lastWrite=void 0)},r.prototype.markReady=function(){return this.networkError=null,this.networkStatus=ge.ready},r.prototype.markError=function(e){return this.networkStatus=ge.error,this.lastWrite=void 0,this.reset(),e.graphQLErrors&&(this.graphQLErrors=e.graphQLErrors),e.networkError&&(this.networkError=e.networkError),e},r}();function Fs(r,e){e===void 0&&(e="none");var t=e==="ignore"||e==="all",i=!Mn(r);return!i&&t&&r.data&&(i=!0),i}var Gv=Object.prototype.hasOwnProperty,Bf=function(){function r(e){var t=e.cache,i=e.link,n=e.defaultOptions,a=e.queryDeduplication,o=a===void 0?!1:a,s=e.onBroadcast,c=e.ssrMode,l=c===void 0?!1:c,u=e.clientAwareness,d=u===void 0?{}:u,f=e.localState,p=e.assumeImmutableResults;this.clientAwareness={},this.queries=new Map,this.fetchCancelFns=new Map,this.transformCache=new(Bt?WeakMap:Map),this.queryIdCounter=1,this.requestIdCounter=1,this.mutationIdCounter=1,this.inFlightLinkObservables=new Map,this.cache=t,this.link=i,this.defaultOptions=n||Object.create(null),this.queryDeduplication=o,this.clientAwareness=d,this.localState=f||new Ns({cache:t}),this.ssrMode=l,this.assumeImmutableResults=!!p,(this.onBroadcast=s)&&(this.mutationStore=Object.create(null))}return r.prototype.stop=function(){var e=this;this.queries.forEach(function(t,i){e.stopQueryNoBroadcast(i)}),this.cancelPendingFetches(__DEV__?new ee("QueryManager stopped while query was in flight"):new ee(14))},r.prototype.cancelPendingFetches=function(e){this.fetchCancelFns.forEach(function(t){return t(e)}),this.fetchCancelFns.clear()},r.prototype.mutate=function(e){var t,i,n=e.mutation,a=e.variables,o=e.optimisticResponse,s=e.updateQueries,c=e.refetchQueries,l=c===void 0?[]:c,u=e.awaitRefetchQueries,d=u===void 0?!1:u,f=e.update,p=e.onQueryUpdated,h=e.fetchPolicy,m=h===void 0?((t=this.defaultOptions.mutate)===null||t===void 0?void 0:t.fetchPolicy)||"network-only":h,y=e.errorPolicy,b=y===void 0?((i=this.defaultOptions.mutate)===null||i===void 0?void 0:i.errorPolicy)||"none":y,_=e.keepRootFields,S=e.context;return Xt(this,void 0,void 0,function(){var v,C,$,I,L,M;return er(this,function(N){switch(N.label){case 0:return __DEV__?D(n,"mutation option is required. You must specify your GraphQL document in the mutation option."):D(n,15),__DEV__?D(m==="network-only"||m==="no-cache","Mutations support only 'network-only' or 'no-cache' fetchPolicy strings. The default `network-only` behavior automatically writes mutation results to the cache. Passing `no-cache` skips the cache write."):D(m==="network-only"||m==="no-cache",16),v=this.generateMutationId(),C=this.transform(n),$=C.document,I=C.hasClientExports,n=this.cache.transformForLink($),a=this.getVariables(n,a),I?[4,this.localState.addExportedVariables(n,a,S)]:[3,2];case 1:a=N.sent(),N.label=2;case 2:return L=this.mutationStore&&(this.mutationStore[v]={mutation:n,variables:a,loading:!0,error:null}),o&&this.markMutationOptimistic(o,{mutationId:v,document:n,variables:a,fetchPolicy:m,errorPolicy:b,context:S,updateQueries:s,update:f,keepRootFields:_}),this.broadcastQueries(),M=this,[2,new Promise(function(W,Ie){return fs(M.getObservableFromLink(n,E(E({},S),{optimisticResponse:o}),a,!1),function(Oe){if(Mn(Oe)&&b==="none")throw new Ir({graphQLErrors:gs(Oe)});L&&(L.loading=!1,L.error=null);var T=E({},Oe);return typeof l=="function"&&(l=l(T)),b==="ignore"&&Mn(T)&&delete T.errors,M.markMutationResult({mutationId:v,result:T,document:n,variables:a,fetchPolicy:m,errorPolicy:b,context:S,update:f,updateQueries:s,awaitRefetchQueries:d,refetchQueries:l,removeOptimistic:o?v:void 0,onQueryUpdated:p,keepRootFields:_})}).subscribe({next:function(Oe){M.broadcastQueries(),(!("hasNext"in Oe)||Oe.hasNext===!1)&&W(Oe)},error:function(Oe){L&&(L.loading=!1,L.error=Oe),o&&M.cache.removeOptimistic(v),M.broadcastQueries(),Ie(Oe instanceof Ir?Oe:new Ir({networkError:Oe}))}})})]}})})},r.prototype.markMutationResult=function(e,t){var i=this;t===void 0&&(t=this.cache);var n=e.result,a=[],o=e.fetchPolicy==="no-cache";if(!o&&Fs(n,e.errorPolicy)){if(Wr(n)||a.push({result:n.data,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}),Wr(n)&&Ve(n.incremental)){var s=t.diff({id:"ROOT_MUTATION",query:this.transform(e.document).asQuery,variables:e.variables,optimistic:!1,returnPartialData:!0}),c=void 0;s.result&&(c=ms(s.result,n)),typeof c<"u"&&(n.data=c,a.push({result:c,dataId:"ROOT_MUTATION",query:e.document,variables:e.variables}))}var l=e.updateQueries;l&&this.queries.forEach(function(d,f){var p=d.observableQuery,h=p&&p.queryName;if(!(!h||!Gv.call(l,h))){var m=l[h],y=i.queries.get(f),b=y.document,_=y.variables,S=t.diff({query:b,variables:_,returnPartialData:!0,optimistic:!1}),v=S.result,C=S.complete;if(C&&v){var $=m(v,{mutationResult:n,queryName:b&&Ln(b)||void 0,queryVariables:_});$&&a.push({result:$,dataId:"ROOT_QUERY",query:b,variables:_})}}})}if(a.length>0||e.refetchQueries||e.update||e.onQueryUpdated||e.removeOptimistic){var u=[];if(this.refetchQueries({updateCache:function(d){o||a.forEach(function(m){return d.write(m)});var f=e.update,p=!Ed(n)||Wr(n)&&!n.hasNext;if(f){if(!o){var h=d.diff({id:"ROOT_MUTATION",query:i.transform(e.document).asQuery,variables:e.variables,optimistic:!1,returnPartialData:!0});h.complete&&(n=E(E({},n),{data:h.result}),"incremental"in n&&delete n.incremental,"hasNext"in n&&delete n.hasNext)}p&&f(d,n,{context:e.context,variables:e.variables})}!o&&!e.keepRootFields&&p&&d.modify({id:"ROOT_MUTATION",fields:function(m,y){var b=y.fieldName,_=y.DELETE;return b==="__typename"?m:_}})},include:e.refetchQueries,optimistic:!1,removeOptimistic:e.removeOptimistic,onQueryUpdated:e.onQueryUpdated||null}).forEach(function(d){return u.push(d)}),e.awaitRefetchQueries||e.onQueryUpdated)return Promise.all(u).then(function(){return n})}return Promise.resolve(n)},r.prototype.markMutationOptimistic=function(e,t){var i=this,n=typeof e=="function"?e(t.variables):e;return this.cache.recordOptimisticTransaction(function(a){try{i.markMutationResult(E(E({},t),{result:{data:n}}),a)}catch(o){__DEV__&&D.error(o)}},t.mutationId)},r.prototype.fetchQuery=function(e,t,i){return this.fetchQueryObservable(e,t,i).promise},r.prototype.getQueryStore=function(){var e=Object.create(null);return this.queries.forEach(function(t,i){e[i]={variables:t.variables,networkStatus:t.networkStatus,networkError:t.networkError,graphQLErrors:t.graphQLErrors}}),e},r.prototype.resetErrors=function(e){var t=this.queries.get(e);t&&(t.networkError=void 0,t.graphQLErrors=[])},r.prototype.transform=function(e){var t=this.transformCache;if(!t.has(e)){var i=this.cache.transformDocument(e),n=El(i),a=this.localState.clientQuery(i),o=n&&this.localState.serverQuery(n),s={document:i,hasClientExports:yl(i),hasForcedResolvers:this.localState.shouldForceResolvers(i),clientQuery:a,serverQuery:o,defaultVars:Ri(ur(i)),asQuery:E(E({},i),{definitions:i.definitions.map(function(l){return l.kind==="OperationDefinition"&&l.operation!=="query"?E(E({},l),{operation:"query"}):l})})},c=function(l){l&&!t.has(l)&&t.set(l,s)};c(e),c(i),c(a),c(o)}return t.get(e)},r.prototype.getVariables=function(e,t){return E(E({},this.transform(e).defaultVars),t)},r.prototype.watchQuery=function(e){e=E(E({},e),{variables:this.getVariables(e.query,e.variables)}),typeof e.notifyOnNetworkStatusChange>"u"&&(e.notifyOnNetworkStatusChange=!1);var t=new Ds(this),i=new Ls({queryManager:this,queryInfo:t,options:e});return this.queries.set(i.queryId,t),t.init({document:i.query,observableQuery:i,variables:i.variables}),i},r.prototype.query=function(e,t){var i=this;return t===void 0&&(t=this.generateQueryId()),__DEV__?D(e.query,"query option is required. You must specify your GraphQL document in the query option."):D(e.query,17),__DEV__?D(e.query.kind==="Document",'You must wrap the query string in a "gql" tag.'):D(e.query.kind==="Document",18),__DEV__?D(!e.returnPartialData,"returnPartialData option only supported on watchQuery."):D(!e.returnPartialData,19),__DEV__?D(!e.pollInterval,"pollInterval option only supported on watchQuery."):D(!e.pollInterval,20),this.fetchQuery(t,e).finally(function(){return i.stopQuery(t)})},r.prototype.generateQueryId=function(){return String(this.queryIdCounter++)},r.prototype.generateRequestId=function(){return this.requestIdCounter++},r.prototype.generateMutationId=function(){return String(this.mutationIdCounter++)},r.prototype.stopQueryInStore=function(e){this.stopQueryInStoreNoBroadcast(e),this.broadcastQueries()},r.prototype.stopQueryInStoreNoBroadcast=function(e){var t=this.queries.get(e);t&&t.stop()},r.prototype.clearStore=function(e){return e===void 0&&(e={discardWatches:!0}),this.cancelPendingFetches(__DEV__?new ee("Store reset while query was in flight (not completed in link chain)"):new ee(21)),this.queries.forEach(function(t){t.observableQuery?t.networkStatus=ge.loading:t.stop()}),this.mutationStore&&(this.mutationStore=Object.create(null)),this.cache.reset(e)},r.prototype.getObservableQueries=function(e){var t=this;e===void 0&&(e="active");var i=new Map,n=new Map,a=new Set;return Array.isArray(e)&&e.forEach(function(o){typeof o=="string"?n.set(o,!1):bl(o)?n.set(t.transform(o).document,!1):he(o)&&o.query&&a.add(o)}),this.queries.forEach(function(o,s){var c=o.observableQuery,l=o.document;if(c){if(e==="all"){i.set(s,c);return}var u=c.queryName,d=c.options.fetchPolicy;if(d==="standby"||e==="active"&&!c.hasObservers())return;(e==="active"||u&&n.has(u)||l&&n.has(l))&&(i.set(s,c),u&&n.set(u,!0),l&&n.set(l,!0))}}),a.size&&a.forEach(function(o){var s=Da("legacyOneTimeQuery"),c=t.getQuery(s).init({document:o.query,variables:o.variables}),l=new Ls({queryManager:t,queryInfo:c,options:E(E({},o),{fetchPolicy:"network-only"})});D(l.queryId===s),c.setObservableQuery(l),i.set(s,l)}),__DEV__&&n.size&&n.forEach(function(o,s){o||__DEV__&&D.warn("Unknown query ".concat(typeof s=="string"?"named ":"").concat(JSON.stringify(s,null,2)," requested in refetchQueries options.include array"))}),i},r.prototype.reFetchObservableQueries=function(e){var t=this;e===void 0&&(e=!1);var i=[];return this.getObservableQueries(e?"all":"active").forEach(function(n,a){var o=n.options.fetchPolicy;n.resetLastResults(),(e||o!=="standby"&&o!=="cache-only")&&i.push(n.refetch()),t.getQuery(a).setDiff(null)}),this.broadcastQueries(),Promise.all(i)},r.prototype.setObservableQuery=function(e){this.getQuery(e.queryId).setObservableQuery(e)},r.prototype.startGraphQLSubscription=function(e){var t=this,i=e.query,n=e.fetchPolicy,a=e.errorPolicy,o=e.variables,s=e.context,c=s===void 0?{}:s;i=this.transform(i).document,o=this.getVariables(i,o);var l=function(d){return t.getObservableFromLink(i,c,d).map(function(f){if(n!=="no-cache"&&(Fs(f,a)&&t.cache.write({query:i,result:f.data,dataId:"ROOT_SUBSCRIPTION",variables:d}),t.broadcastQueries()),Mn(f))throw new Ir({graphQLErrors:f.errors});return f})};if(this.transform(i).hasClientExports){var u=this.localState.addExportedVariables(i,o,c).then(l);return new se(function(d){var f=null;return u.then(function(p){return f=p.subscribe(d)},d.error),function(){return f&&f.unsubscribe()}})}return l(o)},r.prototype.stopQuery=function(e){this.stopQueryNoBroadcast(e),this.broadcastQueries()},r.prototype.stopQueryNoBroadcast=function(e){this.stopQueryInStoreNoBroadcast(e),this.removeQuery(e)},r.prototype.removeQuery=function(e){this.fetchCancelFns.delete(e),this.queries.has(e)&&(this.getQuery(e).stop(),this.queries.delete(e))},r.prototype.broadcastQueries=function(){this.onBroadcast&&this.onBroadcast(),this.queries.forEach(function(e){return e.notify()})},r.prototype.getLocalState=function(){return this.localState},r.prototype.getObservableFromLink=function(e,t,i,n){var a=this,o;n===void 0&&(n=(o=t?.queryDeduplication)!==null&&o!==void 0?o:this.queryDeduplication);var s,c=this.transform(e).serverQuery;if(c){var l=this,u=l.inFlightLinkObservables,d=l.link,f={query:c,variables:i,operationName:Ln(c)||void 0,context:this.prepareContext(E(E({},t),{forceFetch:!n}))};if(t=f.context,n){var p=u.get(c)||new Map;u.set(c,p);var h=Rt(i);if(s=p.get(h),!s){var m=new Fn([Un(d,f)]);p.set(h,s=m),m.beforeNext(function(){p.delete(h)&&p.size<1&&u.delete(c)})}}else s=new Fn([Un(d,f)])}else s=new Fn([se.of({data:{}})]),t=this.prepareContext(t);var y=this.transform(e).clientQuery;return y&&(s=fs(s,function(b){return a.localState.runResolvers({document:y,remoteResult:b,context:t,variables:i})})),s},r.prototype.getResultsFromLink=function(e,t,i){var n=e.lastRequestId=this.generateRequestId(),a=this.cache.transformForLink(this.transform(e.document).document);return fs(this.getObservableFromLink(a,i.context,i.variables),function(o){var s=gs(o),c=s.length>0;if(n>=e.lastRequestId){if(c&&i.errorPolicy==="none")throw e.markError(new Ir({graphQLErrors:s}));e.markResult(o,a,i,t),e.markReady()}var l={data:o.data,loading:!1,networkStatus:ge.ready};return c&&i.errorPolicy!=="ignore"&&(l.errors=s,l.networkStatus=ge.error),l},function(o){var s=jf(o)?o:new Ir({networkError:o});throw n>=e.lastRequestId&&e.markError(s),s})},r.prototype.fetchQueryObservable=function(e,t,i){var n=this;i===void 0&&(i=ge.loading);var a=this.transform(t.query).document,o=this.getVariables(a,t.variables),s=this.getQuery(e),c=this.defaultOptions.watchQuery,l=t.fetchPolicy,u=l===void 0?c&&c.fetchPolicy||"cache-first":l,d=t.errorPolicy,f=d===void 0?c&&c.errorPolicy||"none":d,p=t.returnPartialData,h=p===void 0?!1:p,m=t.notifyOnNetworkStatusChange,y=m===void 0?!1:m,b=t.context,_=b===void 0?{}:b,S=Object.assign({},t,{query:a,variables:o,fetchPolicy:u,errorPolicy:f,returnPartialData:h,notifyOnNetworkStatusChange:y,context:_}),v=function(I){S.variables=I;var L=n.fetchQueryByPolicy(s,S,i);return S.fetchPolicy!=="standby"&&L.length>0&&s.observableQuery&&s.observableQuery.applyNextFetchPolicy("after-fetch",t),L},C=function(){return n.fetchCancelFns.delete(e)};this.fetchCancelFns.set(e,function(I){C(),setTimeout(function(){return $.cancel(I)})});var $=new Fn(this.transform(S.query).hasClientExports?this.localState.addExportedVariables(S.query,S.variables,S.context).then(v):v(S.variables));return $.promise.then(C,C),$},r.prototype.refetchQueries=function(e){var t=this,i=e.updateCache,n=e.include,a=e.optimistic,o=a===void 0?!1:a,s=e.removeOptimistic,c=s===void 0?o?Da("refetchQueries"):void 0:s,l=e.onQueryUpdated,u=new Map;n&&this.getObservableQueries(n).forEach(function(f,p){u.set(p,{oq:f,lastDiff:t.getQuery(p).getDiff()})});var d=new Map;return i&&this.cache.batch({update:i,optimistic:o&&c||!1,removeOptimistic:c,onWatchUpdated:function(f,p,h){var m=f.watcher instanceof Ds&&f.watcher.observableQuery;if(m){if(l){u.delete(m.queryId);var y=l(m,p,h);return y===!0&&(y=m.refetch()),y!==!1&&d.set(m,y),y}l!==null&&u.set(m.queryId,{oq:m,lastDiff:h,diff:p})}}}),u.size&&u.forEach(function(f,p){var h=f.oq,m=f.lastDiff,y=f.diff,b;if(l){if(!y){var _=h.queryInfo;_.reset(),y=_.getDiff()}b=l(h,y,m)}(!l||b===!0)&&(b=h.refetch()),b!==!1&&d.set(h,b),p.indexOf("legacyOneTimeQuery")>=0&&t.stopQueryNoBroadcast(p)}),c&&this.cache.removeOptimistic(c),d},r.prototype.fetchQueryByPolicy=function(e,t,i){var n=this,a=t.query,o=t.variables,s=t.fetchPolicy,c=t.refetchWritePolicy,l=t.errorPolicy,u=t.returnPartialData,d=t.context,f=t.notifyOnNetworkStatusChange,p=e.networkStatus;e.init({document:this.transform(a).document,variables:o,networkStatus:i});var h=function(){return e.getDiff(o)},m=function(v,C){C===void 0&&(C=e.networkStatus||ge.loading);var $=v.result;__DEV__&&!u&&!Ae($,{})&&hu(v.missing);var I=function(L){return se.of(E({data:L,loading:Yr(C),networkStatus:C},v.complete?null:{partial:!0}))};return $&&n.transform(a).hasForcedResolvers?n.localState.runResolvers({document:a,remoteResult:{data:$},context:d,variables:o,onlyRunForcedResolvers:!0}).then(function(L){return I(L.data||void 0)}):l==="none"&&C===ge.refetch&&Array.isArray(v.missing)?I(void 0):I($)},y=s==="no-cache"?0:i===ge.refetch&&c!=="merge"?1:2,b=function(){return n.getResultsFromLink(e,y,{variables:o,context:d,fetchPolicy:s,errorPolicy:l})},_=f&&typeof p=="number"&&p!==i&&Yr(i);switch(s){default:case"cache-first":{var S=h();return S.complete?[m(S,e.markReady())]:u||_?[m(S),b()]:[b()]}case"cache-and-network":{var S=h();return S.complete||u||_?[m(S),b()]:[b()]}case"cache-only":return[m(h(),e.markReady())];case"network-only":return _?[m(h()),b()]:[b()];case"no-cache":return _?[m(e.getDiff()),b()]:[b()];case"standby":return[]}},r.prototype.getQuery=function(e){return e&&!this.queries.has(e)&&this.queries.set(e,new Ds(this,e)),this.queries.get(e)},r.prototype.prepareContext=function(e){e===void 0&&(e={});var t=this.localState.prepareContext(e);return E(E({},t),{clientAwareness:this.clientAwareness})},r}();var Vf=!1;var gu=function(){function r(e){var t=this;this.resetStoreCallbacks=[],this.clearStoreCallbacks=[];var i=e.uri,n=e.credentials,a=e.headers,o=e.cache,s=e.ssrMode,c=s===void 0?!1:s,l=e.ssrForceFetchDelay,u=l===void 0?0:l,d=e.connectToDevTools,f=d===void 0?typeof window=="object"&&!window.__APOLLO_CLIENT__&&__DEV__:d,p=e.queryDeduplication,h=p===void 0?!0:p,m=e.defaultOptions,y=e.assumeImmutableResults,b=y===void 0?!1:y,_=e.resolvers,S=e.typeDefs,v=e.fragmentMatcher,C=e.name,$=e.version,I=e.link;if(I||(I=i?new Ql({uri:i,credentials:n,headers:a}):Vt.empty()),!o)throw __DEV__?new ee(`To initialize Apollo Client, you must specify a 'cache' property in the options object.
51
- For more information, please visit: https://go.apollo.dev/c/docs`):new ee(9);if(this.link=I,this.cache=o,this.disableNetworkFetches=c||u>0,this.queryDeduplication=h,this.defaultOptions=m||Object.create(null),this.typeDefs=S,u&&setTimeout(function(){return t.disableNetworkFetches=!1},u),this.watchQuery=this.watchQuery.bind(this),this.query=this.query.bind(this),this.mutate=this.mutate.bind(this),this.resetStore=this.resetStore.bind(this),this.reFetchObservableQueries=this.reFetchObservableQueries.bind(this),f&&typeof window=="object"&&(window.__APOLLO_CLIENT__=this),!Vf&&f&&__DEV__&&(Vf=!0,typeof window<"u"&&window.document&&window.top===window.self&&!window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__)){var L=window.navigator,M=L&&L.userAgent,N=void 0;typeof M=="string"&&(M.indexOf("Chrome/")>-1?N="https://chrome.google.com/webstore/detail/apollo-client-developer-t/jdkknkkbebbapilgoeccciglkfbmbnfm":M.indexOf("Firefox/")>-1&&(N="https://addons.mozilla.org/en-US/firefox/addon/apollo-developer-tools/")),N&&__DEV__&&D.log("Download the Apollo DevTools for a better development experience: "+N)}this.version=Td,this.localState=new Ns({cache:o,client:this,resolvers:_,fragmentMatcher:v}),this.queryManager=new Bf({cache:this.cache,link:this.link,defaultOptions:this.defaultOptions,queryDeduplication:h,ssrMode:c,clientAwareness:{name:C,version:$},localState:this.localState,assumeImmutableResults:b,onBroadcast:f?function(){t.devToolsHookCb&&t.devToolsHookCb({action:{},state:{queries:t.queryManager.getQueryStore(),mutations:t.queryManager.mutationStore||{}},dataWithOptimisticResults:t.cache.extract(!0)})}:void 0})}return r.prototype.stop=function(){this.queryManager.stop()},r.prototype.watchQuery=function(e){return this.defaultOptions.watchQuery&&(e=Fa(this.defaultOptions.watchQuery,e)),this.disableNetworkFetches&&(e.fetchPolicy==="network-only"||e.fetchPolicy==="cache-and-network")&&(e=E(E({},e),{fetchPolicy:"cache-first"})),this.queryManager.watchQuery(e)},r.prototype.query=function(e){return this.defaultOptions.query&&(e=Fa(this.defaultOptions.query,e)),__DEV__?D(e.fetchPolicy!=="cache-and-network","The cache-and-network fetchPolicy does not work with client.query, because client.query can only return a single result. Please use client.watchQuery to receive multiple results from the cache and the network, or consider using a different fetchPolicy, such as cache-first or network-only."):D(e.fetchPolicy!=="cache-and-network",10),this.disableNetworkFetches&&e.fetchPolicy==="network-only"&&(e=E(E({},e),{fetchPolicy:"cache-first"})),this.queryManager.query(e)},r.prototype.mutate=function(e){return this.defaultOptions.mutate&&(e=Fa(this.defaultOptions.mutate,e)),this.queryManager.mutate(e)},r.prototype.subscribe=function(e){return this.queryManager.startGraphQLSubscription(e)},r.prototype.readQuery=function(e,t){return t===void 0&&(t=!1),this.cache.readQuery(e,t)},r.prototype.readFragment=function(e,t){return t===void 0&&(t=!1),this.cache.readFragment(e,t)},r.prototype.writeQuery=function(e){var t=this.cache.writeQuery(e);return e.broadcast!==!1&&this.queryManager.broadcastQueries(),t},r.prototype.writeFragment=function(e){var t=this.cache.writeFragment(e);return e.broadcast!==!1&&this.queryManager.broadcastQueries(),t},r.prototype.__actionHookForDevTools=function(e){this.devToolsHookCb=e},r.prototype.__requestRaw=function(e){return Un(this.link,e)},r.prototype.resetStore=function(){var e=this;return Promise.resolve().then(function(){return e.queryManager.clearStore({discardWatches:!1})}).then(function(){return Promise.all(e.resetStoreCallbacks.map(function(t){return t()}))}).then(function(){return e.reFetchObservableQueries()})},r.prototype.clearStore=function(){var e=this;return Promise.resolve().then(function(){return e.queryManager.clearStore({discardWatches:!0})}).then(function(){return Promise.all(e.clearStoreCallbacks.map(function(t){return t()}))})},r.prototype.onResetStore=function(e){var t=this;return this.resetStoreCallbacks.push(e),function(){t.resetStoreCallbacks=t.resetStoreCallbacks.filter(function(i){return i!==e})}},r.prototype.onClearStore=function(e){var t=this;return this.clearStoreCallbacks.push(e),function(){t.clearStoreCallbacks=t.clearStoreCallbacks.filter(function(i){return i!==e})}},r.prototype.reFetchObservableQueries=function(e){return this.queryManager.reFetchObservableQueries(e)},r.prototype.refetchQueries=function(e){var t=this.queryManager.refetchQueries(e),i=[],n=[];t.forEach(function(o,s){i.push(s),n.push(o)});var a=Promise.all(n);return a.queries=i,a.results=n,a.catch(function(o){__DEV__&&D.debug("In client.refetchQueries, Promise.all promise rejected with error ".concat(o))}),a},r.prototype.getObservableQueries=function(e){return e===void 0&&(e="active"),this.queryManager.getObservableQueries(e)},r.prototype.extract=function(e){return this.cache.extract(e)},r.prototype.restore=function(e){return this.cache.restore(e)},r.prototype.addResolvers=function(e){this.localState.addResolvers(e)},r.prototype.setResolvers=function(e){this.localState.setResolvers(e)},r.prototype.getResolvers=function(){return this.localState.getResolvers()},r.prototype.setLocalStateFragmentMatcher=function(e){this.localState.setFragmentMatcher(e)},r.prototype.setLink=function(e){this.link=this.queryManager.link=e},r}();ed(Ii?"log":"silent");function pt(r){return r===null?"null":Array.isArray(r)?"array":typeof r}function Tr(r){return pt(r)==="object"}function Qf(r){return Array.isArray(r)&&r.length>0&&r.every(e=>"message"in e)}function yu(r,e){return r.length<124?r:e}var Hf="graphql-transport-ws";var xt;(function(r){r[r.InternalServerError=4500]="InternalServerError",r[r.InternalClientError=4005]="InternalClientError",r[r.BadRequest=4400]="BadRequest",r[r.BadResponse=4004]="BadResponse",r[r.Unauthorized=4401]="Unauthorized",r[r.Forbidden=4403]="Forbidden",r[r.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",r[r.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",r[r.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",r[r.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",r[r.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests"})(xt||(xt={}));var Le;(function(r){r.ConnectionInit="connection_init",r.ConnectionAck="connection_ack",r.Ping="ping",r.Pong="pong",r.Subscribe="subscribe",r.Next="next",r.Error="error",r.Complete="complete"})(Le||(Le={}));function zf(r){if(!Tr(r))throw new Error(`Message is expected to be an object, but got ${pt(r)}`);if(!r.type)throw new Error("Message is missing the 'type' property");if(typeof r.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${pt(r.type)}`);switch(r.type){case Le.ConnectionInit:case Le.ConnectionAck:case Le.Ping:case Le.Pong:{if(r.payload!=null&&!Tr(r.payload))throw new Error(`"${r.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${r.payload}"`);break}case Le.Subscribe:{if(typeof r.id!="string")throw new Error(`"${r.type}" message expects the 'id' property to be a string, but got ${pt(r.id)}`);if(!r.id)throw new Error(`"${r.type}" message requires a non-empty 'id' property`);if(!Tr(r.payload))throw new Error(`"${r.type}" message expects the 'payload' property to be an object, but got ${pt(r.payload)}`);if(typeof r.payload.query!="string")throw new Error(`"${r.type}" message payload expects the 'query' property to be a string, but got ${pt(r.payload.query)}`);if(r.payload.variables!=null&&!Tr(r.payload.variables))throw new Error(`"${r.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${pt(r.payload.variables)}`);if(r.payload.operationName!=null&&pt(r.payload.operationName)!=="string")throw new Error(`"${r.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${pt(r.payload.operationName)}`);if(r.payload.extensions!=null&&!Tr(r.payload.extensions))throw new Error(`"${r.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${pt(r.payload.extensions)}`);break}case Le.Next:{if(typeof r.id!="string")throw new Error(`"${r.type}" message expects the 'id' property to be a string, but got ${pt(r.id)}`);if(!r.id)throw new Error(`"${r.type}" message requires a non-empty 'id' property`);if(!Tr(r.payload))throw new Error(`"${r.type}" message expects the 'payload' property to be an object, but got ${pt(r.payload)}`);break}case Le.Error:{if(typeof r.id!="string")throw new Error(`"${r.type}" message expects the 'id' property to be a string, but got ${pt(r.id)}`);if(!r.id)throw new Error(`"${r.type}" message requires a non-empty 'id' property`);if(!Qf(r.payload))throw new Error(`"${r.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(r.payload)}`);break}case Le.Complete:{if(typeof r.id!="string")throw new Error(`"${r.type}" message expects the 'id' property to be a string, but got ${pt(r.id)}`);if(!r.id)throw new Error(`"${r.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${r.type}"`)}return r}function Wf(r,e){return zf(typeof r=="string"?JSON.parse(r,e):r)}function zn(r,e){return zf(r),JSON.stringify(r,e)}function vu(r){let{url:e,connectionParams:t,lazy:i=!0,onNonLazyError:n=console.error,lazyCloseTimeout:a=0,keepAlive:o=0,disablePong:s,connectionAckWaitTimeout:c=0,retryAttempts:l=5,retryWait:u=async function(we){let Se=1e3;for(let de=0;de<we;de++)Se*=2;await new Promise(de=>setTimeout(de,Se+Math.floor(Math.random()*(3e3-300)+300)))},shouldRetry:d=Ms,isFatalConnectionProblem:f,on:p,webSocketImpl:h,generateID:m=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,we=>{let Se=Math.random()*16|0;return(we=="x"?Se:Se&3|8).toString(16)})},jsonMessageReplacer:y,jsonMessageReviver:b}=r,_;if(h){if(!Jv(h))throw new Error("Invalid WebSocket implementation provided");_=h}else typeof WebSocket<"u"?_=WebSocket:typeof global<"u"?_=global.WebSocket||global.MozWebSocket:typeof window<"u"&&(_=window.WebSocket||window.MozWebSocket);if(!_)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let S=_,v=(()=>{let T=(()=>{let Se={};return{on(de,fe){return Se[de]=fe,()=>{delete Se[de]}},emit(de){var fe;"id"in de&&((fe=Se[de.id])===null||fe===void 0||fe.call(Se,de))}}})(),we={connecting:p?.connecting?[p.connecting]:[],opened:p?.opened?[p.opened]:[],connected:p?.connected?[p.connected]:[],ping:p?.ping?[p.ping]:[],pong:p?.pong?[p.pong]:[],message:p?.message?[T.emit,p.message]:[T.emit],closed:p?.closed?[p.closed]:[],error:p?.error?[p.error]:[]};return{onMessage:T.on,on(Se,de){let fe=we[Se];return fe.push(de),()=>{fe.splice(fe.indexOf(de),1)}},emit(Se,...de){for(let fe of[...we[Se]])fe(...de)}}})();function C(T){let we=[v.on("error",Se=>{we.forEach(de=>de()),T(Se)}),v.on("closed",Se=>{we.forEach(de=>de()),T(Se)})]}let $,I=0,L,M=!1,N=0,W=!1;async function Ie(){clearTimeout(L);let[T,we]=await($??($=new Promise((fe,or)=>(async()=>{if(M){if(await u(N),!I)return $=void 0,or({code:1e3,reason:"All Subscriptions Gone"});N++}v.emit("connecting");let oe=new S(typeof e=="function"?await e():e,Hf),sr,Br;function ts(){isFinite(o)&&o>0&&(clearTimeout(Br),Br=setTimeout(()=>{oe.readyState===S.OPEN&&(oe.send(zn({type:Le.Ping})),v.emit("ping",!1,void 0))},o))}C(tt=>{$=void 0,clearTimeout(sr),clearTimeout(Br),or(tt),Ms(tt)&&tt.code===4499&&(oe.close(4499,"Terminated"),oe.onerror=null,oe.onclose=null)}),oe.onerror=tt=>v.emit("error",tt),oe.onclose=tt=>v.emit("closed",tt),oe.onopen=async()=>{try{v.emit("opened",oe);let tt=typeof t=="function"?await t():t;if(oe.readyState!==S.OPEN)return;oe.send(zn(tt?{type:Le.ConnectionInit,payload:tt}:{type:Le.ConnectionInit},y)),isFinite(c)&&c>0&&(sr=setTimeout(()=>{oe.close(xt.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},c)),ts()}catch(tt){v.emit("error",tt),oe.close(xt.InternalClientError,yu(tt instanceof Error?tt.message:new Error(tt).message,"Internal client error"))}};let On=!1;oe.onmessage=({data:tt})=>{try{let rt=Wf(tt,b);if(v.emit("message",rt),rt.type==="ping"||rt.type==="pong"){v.emit(rt.type,!0,rt.payload),rt.type==="pong"?ts():s||(oe.send(zn(rt.payload?{type:Le.Pong,payload:rt.payload}:{type:Le.Pong})),v.emit("pong",!1,rt.payload));return}if(On)return;if(rt.type!==Le.ConnectionAck)throw new Error(`First message cannot be of type ${rt.type}`);clearTimeout(sr),On=!0,v.emit("connected",oe,rt.payload),M=!1,N=0,fe([oe,new Promise((n_,Zg)=>C(Zg))])}catch(rt){oe.onmessage=null,v.emit("error",rt),oe.close(xt.BadResponse,yu(rt instanceof Error?rt.message:new Error(rt).message,"Bad response"))}}})())));T.readyState===S.CLOSING&&await we;let Se=()=>{},de=new Promise(fe=>Se=fe);return[T,Se,Promise.race([de.then(()=>{if(!I){let fe=()=>T.close(1e3,"Normal Closure");isFinite(a)&&a>0?L=setTimeout(()=>{T.readyState===S.OPEN&&fe()},a):fe()}}),we])]}function Oe(T){if(Ms(T)&&(Kv(T.code)||[xt.InternalServerError,xt.InternalClientError,xt.BadRequest,xt.BadResponse,xt.Unauthorized,xt.SubprotocolNotAcceptable,xt.SubscriberAlreadyExists,xt.TooManyInitialisationRequests].includes(T.code)))throw T;if(W)return!1;if(Ms(T)&&T.code===1e3)return I>0;if(!l||N>=l||!d(T)||f?.(T))throw T;return M=!0}return i||(async()=>{for(I++;;)try{let[,,T]=await Ie();await T}catch(T){try{if(!Oe(T))return}catch(we){return n?.(we)}}})(),{on:v.on,subscribe(T,we){let Se=m(T),de=!1,fe=!1,or=()=>{I--,de=!0};return(async()=>{for(I++;;)try{let[oe,sr,Br]=await Ie();if(de)return sr();let ts=v.onMessage(Se,On=>{switch(On.type){case Le.Next:{we.next(On.payload);return}case Le.Error:{fe=!0,de=!0,we.error(On.payload),or();return}case Le.Complete:{de=!0,or();return}}});oe.send(zn({id:Se,type:Le.Subscribe,payload:T},y)),or=()=>{!de&&oe.readyState===S.OPEN&&oe.send(zn({id:Se,type:Le.Complete},y)),I--,de=!0,sr()},await Br.finally(ts);return}catch(oe){if(!Oe(oe))return}})().then(()=>{fe||we.complete()}).catch(oe=>{we.error(oe)}),()=>{de||or()}},async dispose(){if(W=!0,$){let[T]=await $;T.close(1e3,"Normal Closure")}},terminate(){$&&v.emit("closed",{code:4499,reason:"Terminated",wasClean:!1})}}}function Ms(r){return Tr(r)&&"code"in r&&"reason"in r}function Kv(r){return[1e3,1001,1006,1005,1012,1013,1013].includes(r)?!1:r>=1e3&&r<=1999}function Jv(r){return typeof r=="function"&&"constructor"in r&&"CLOSED"in r&&"CLOSING"in r&&"CONNECTING"in r&&"OPEN"in r}function Zv(r){return he(r)&&"code"in r&&"reason"in r}var Gf=function(r){Pe(e,r);function e(t){var i=r.call(this)||this;return i.client=t,i}return e.prototype.request=function(t){var i=this;return new se(function(n){return i.client.subscribe(E(E({},t),{query:$n(t.query)}),{next:n.next.bind(n),complete:n.complete.bind(n),error:function(a){return a instanceof Error?n.error(a):Zv(a)?n.error(new Error("Socket closed with event ".concat(a.code," ").concat(a.reason||""))):n.error(new Ir({graphQLErrors:Array.isArray(a)?a:[a]}))}})})},e}(Vt);var Us="0.13.0-test-2";function js(){return typeof window!="undefined"&&window.self!==window.top}function bu(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(r){return!1}return!0}function dt(r,e){bu()&&localStorage.setItem(`${Us}/${r}`,e)}function Ha(r){return bu()?localStorage.getItem(`${Us}/${r}`):null}function Wn(r){bu()&&localStorage.removeItem(`${Us}/${r}`)}function Mi(r,e=1e4){return V(this,null,function*(){return Promise.race([new Promise((t,i)=>{let n;try{n=new WebSocket(r,"graphql-transport-ws"),n.onopen=()=>{n.close(),t(n)},n.onerror=a=>{i(a)},n.onclose=a=>{a.code!==1e3&&i(new Error(`WebSocket closed with code ${a.code}: ${a.reason}`))}}catch(a){n&&n.close(),i(a)}}),new Promise((t,i)=>{setTimeout(()=>{i(new Error("WebSocket connection timed out"))},e)})])})}function Kf(r){let e=r.trim();if(!e)return"";let t=e.split(/\s+/);return t.length>=2?(t[0][0]+t[1][0]).toUpperCase():e.slice(0,2).toUpperCase()}function Jf(r){let e=0;for(let t=0;t<r.length;t++)e=r.charCodeAt(t)+((e<<5)-e);return(e%360+360)%360}var gc=function(){return gc=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},gc.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;function ec(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ec=function(t){return typeof t}:ec=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ec(r)}function Xv(r){return ec(r)=="object"&&r!==null}var _m=typeof Symbol=="function"&&Symbol.toStringTag!=null?Symbol.toStringTag:"@@toStringTag";function ju(r,e){for(var t=/\r\n|[\n\r]/g,i=1,n=e+1,a;(a=t.exec(r.body))&&a.index<e;)i+=1,n=e+1-(a.index+a[0].length);return{line:i,column:n}}function eb(r){return xm(r.source,ju(r.source,r.start))}function xm(r,e){var t=r.locationOffset.column-1,i=tc(t)+r.body,n=e.line-1,a=r.locationOffset.line-1,o=e.line+a,s=e.line===1?t:0,c=e.column+s,l="".concat(r.name,":").concat(o,":").concat(c,`
52
- `),u=i.split(/\r\n|[\n\r]/g),d=u[n];if(d.length>120){for(var f=Math.floor(c/80),p=c%80,h=[],m=0;m<d.length;m+=80)h.push(d.slice(m,m+80));return l+Zf([["".concat(o),h[0]]].concat(h.slice(1,f+1).map(function(y){return["",y]}),[[" ",tc(p-1)+"^"],["",h[f+1]]]))}return l+Zf([["".concat(o-1),u[n-1]],["".concat(o),d],["",tc(c-1)+"^"],["".concat(o+1),u[n+1]]])}function Zf(r){var e=r.filter(function(i){i[0];var n=i[1];return n!==void 0}),t=Math.max.apply(Math,e.map(function(i){var n=i[0];return n.length}));return e.map(function(i){var n=i[0],a=i[1];return tb(t,n)+(a?" | "+a:" |")}).join(`
53
- `)}function tc(r){return Array(r+1).join(" ")}function tb(r,e){return tc(r-e.length)+e}function rc(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?rc=function(t){return typeof t}:rc=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rc(r)}function Yf(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,i)}return t}function rb(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Yf(Object(t),!0).forEach(function(i){ib(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Yf(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}function ib(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function nb(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Xf(r,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(r,i.key,i)}}function ab(r,e,t){return e&&Xf(r.prototype,e),t&&Xf(r,t),r}function ob(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&Io(r,e)}function sb(r){var e=km();return function(){var i=To(r),n;if(e){var a=To(this).constructor;n=Reflect.construct(i,arguments,a)}else n=i.apply(this,arguments);return Em(this,n)}}function Em(r,e){return e&&(rc(e)==="object"||typeof e=="function")?e:Ja(r)}function Ja(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function qu(r){var e=typeof Map=="function"?new Map:void 0;return qu=function(i){if(i===null||!cb(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(i))return e.get(i);e.set(i,n)}function n(){return ic(i,arguments,To(this).constructor)}return n.prototype=Object.create(i.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Io(n,i)},qu(r)}function ic(r,e,t){return km()?ic=Reflect.construct:ic=function(n,a,o){var s=[null];s.push.apply(s,a);var c=Function.bind.apply(n,s),l=new c;return o&&Io(l,o.prototype),l},ic.apply(null,arguments)}function km(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function cb(r){return Function.toString.call(r).indexOf("[native code]")!==-1}function Io(r,e){return Io=Object.setPrototypeOf||function(i,n){return i.__proto__=n,i},Io(r,e)}function To(r){return To=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},To(r)}var lb=function(r){ob(t,r);var e=sb(t);function t(i,n,a,o,s,c,l){var u,d,f,p;nb(this,t),p=e.call(this,i),p.name="GraphQLError",p.originalError=c??void 0,p.nodes=eh(Array.isArray(n)?n:n?[n]:void 0);for(var h=[],m=0,y=(b=p.nodes)!==null&&b!==void 0?b:[];m<y.length;m++){var b,_=y[m],S=_.loc;S!=null&&h.push(S)}h=eh(h),p.source=a??((u=h)===null||u===void 0?void 0:u[0].source),p.positions=o??((d=h)===null||d===void 0?void 0:d.map(function(C){return C.start})),p.locations=o&&a?o.map(function(C){return ju(a,C)}):(f=h)===null||f===void 0?void 0:f.map(function(C){return ju(C.source,C.start)}),p.path=s??void 0;var v=c?.extensions;return l==null&&Xv(v)?p.extensions=rb({},v):p.extensions=l??{},Object.defineProperties(Ja(p),{message:{enumerable:!0},locations:{enumerable:p.locations!=null},path:{enumerable:p.path!=null},extensions:{enumerable:p.extensions!=null&&Object.keys(p.extensions).length>0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),c!=null&&c.stack?(Object.defineProperty(Ja(p),"stack",{value:c.stack,writable:!0,configurable:!0}),Em(p)):(Error.captureStackTrace?Error.captureStackTrace(Ja(p),t):Object.defineProperty(Ja(p),"stack",{value:Error().stack,writable:!0,configurable:!0}),p)}return ab(t,[{key:"toString",value:function(){return ub(this)}},{key:_m,get:function(){return"Object"}}]),t}(qu(Error));function eh(r){return r===void 0||r.length===0?void 0:r}function ub(r){var e=r.message;if(r.nodes)for(var t=0,i=r.nodes;t<i.length;t++){var n=i[t];n.loc&&(e+=`
54
-
55
- `+eb(n.loc))}else if(r.source&&r.locations)for(var a=0,o=r.locations;a<o.length;a++){var s=o[a];e+=`
56
-
57
- `+xm(r.source,s)}return e}function Nt(r,e,t){return new lb("Syntax Error: ".concat(t),void 0,r,[e])}var Z=Object.freeze({NAME:"Name",DOCUMENT:"Document",OPERATION_DEFINITION:"OperationDefinition",VARIABLE_DEFINITION:"VariableDefinition",SELECTION_SET:"SelectionSet",FIELD:"Field",ARGUMENT:"Argument",FRAGMENT_SPREAD:"FragmentSpread",INLINE_FRAGMENT:"InlineFragment",FRAGMENT_DEFINITION:"FragmentDefinition",VARIABLE:"Variable",INT:"IntValue",FLOAT:"FloatValue",STRING:"StringValue",BOOLEAN:"BooleanValue",NULL:"NullValue",ENUM:"EnumValue",LIST:"ListValue",OBJECT:"ObjectValue",OBJECT_FIELD:"ObjectField",DIRECTIVE:"Directive",NAMED_TYPE:"NamedType",LIST_TYPE:"ListType",NON_NULL_TYPE:"NonNullType",SCHEMA_DEFINITION:"SchemaDefinition",OPERATION_TYPE_DEFINITION:"OperationTypeDefinition",SCALAR_TYPE_DEFINITION:"ScalarTypeDefinition",OBJECT_TYPE_DEFINITION:"ObjectTypeDefinition",FIELD_DEFINITION:"FieldDefinition",INPUT_VALUE_DEFINITION:"InputValueDefinition",INTERFACE_TYPE_DEFINITION:"InterfaceTypeDefinition",UNION_TYPE_DEFINITION:"UnionTypeDefinition",ENUM_TYPE_DEFINITION:"EnumTypeDefinition",ENUM_VALUE_DEFINITION:"EnumValueDefinition",INPUT_OBJECT_TYPE_DEFINITION:"InputObjectTypeDefinition",DIRECTIVE_DEFINITION:"DirectiveDefinition",SCHEMA_EXTENSION:"SchemaExtension",SCALAR_TYPE_EXTENSION:"ScalarTypeExtension",OBJECT_TYPE_EXTENSION:"ObjectTypeExtension",INTERFACE_TYPE_EXTENSION:"InterfaceTypeExtension",UNION_TYPE_EXTENSION:"UnionTypeExtension",ENUM_TYPE_EXTENSION:"EnumTypeExtension",INPUT_OBJECT_TYPE_EXTENSION:"InputObjectTypeExtension"});function pb(r,e){var t=Boolean(r);if(!t)throw new Error(e??"Unexpected invariant triggered.")}var db=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):void 0,Bu=db;function Am(r){var e=r.prototype.toJSON;typeof e=="function"||pb(0),r.prototype.inspect=e,Bu&&(r.prototype[Bu]=e)}var Im=function(){function r(t,i,n){this.start=t.start,this.end=i.end,this.startToken=t,this.endToken=i,this.source=n}var e=r.prototype;return e.toJSON=function(){return{start:this.start,end:this.end}},r}();Am(Im);var Fe=function(){function r(t,i,n,a,o,s,c){this.kind=t,this.start=i,this.end=n,this.line=a,this.column=o,this.value=c,this.prev=s,this.next=null}var e=r.prototype;return e.toJSON=function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}},r}();Am(Fe);var R=Object.freeze({SOF:"<SOF>",EOF:"<EOF>",BANG:"!",DOLLAR:"$",AMP:"&",PAREN_L:"(",PAREN_R:")",SPREAD:"...",COLON:":",EQUALS:"=",AT:"@",BRACKET_L:"[",BRACKET_R:"]",BRACE_L:"{",PIPE:"|",BRACE_R:"}",NAME:"Name",INT:"Int",FLOAT:"Float",STRING:"String",BLOCK_STRING:"BlockString",COMMENT:"Comment"});function nc(r){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?nc=function(t){return typeof t}:nc=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nc(r)}var fb=10,Tm=2;function hb(r){return Uc(r,[])}function Uc(r,e){switch(nc(r)){case"string":return JSON.stringify(r);case"function":return r.name?"[function ".concat(r.name,"]"):"[function]";case"object":return r===null?"null":mb(r,e);default:return String(r)}}function mb(r,e){if(e.indexOf(r)!==-1)return"[Circular]";var t=[].concat(e,[r]),i=vb(r);if(i!==void 0){var n=i.call(r);if(n!==r)return typeof n=="string"?n:Uc(n,t)}else if(Array.isArray(r))return yb(r,t);return gb(r,t)}function gb(r,e){var t=Object.keys(r);if(t.length===0)return"{}";if(e.length>Tm)return"["+bb(r)+"]";var i=t.map(function(n){var a=Uc(r[n],e);return n+": "+a});return"{ "+i.join(", ")+" }"}function yb(r,e){if(r.length===0)return"[]";if(e.length>Tm)return"[Array]";for(var t=Math.min(fb,r.length),i=r.length-t,n=[],a=0;a<t;++a)n.push(Uc(r[a],e));return i===1?n.push("... 1 more item"):i>1&&n.push("... ".concat(i," more items")),"["+n.join(", ")+"]"}function vb(r){var e=r[String(Bu)];if(typeof e=="function")return e;if(typeof r.inspect=="function")return r.inspect}function bb(r){var e=Object.prototype.toString.call(r).replace(/^\[object /,"").replace(/]$/,"");if(e==="Object"&&typeof r.constructor=="function"){var t=r.constructor.name;if(typeof t=="string"&&t!=="")return t}return e}function wu(r,e){var t=Boolean(r);if(!t)throw new Error(e)}var wb=function(e,t){return e instanceof t};function th(r,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(r,i.key,i)}}function Sb(r,e,t){return e&&th(r.prototype,e),t&&th(r,t),r}var Cm=function(){function r(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GraphQL request",i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{line:1,column:1};typeof e=="string"||wu(0,"Body must be a string. Received: ".concat(hb(e),".")),this.body=e,this.name=t,this.locationOffset=i,this.locationOffset.line>0||wu(0,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||wu(0,"column in locationOffset is 1-indexed and must be positive.")}return Sb(r,[{key:_m,get:function(){return"Source"}}]),r}();function _b(r){return wb(r,Cm)}var xb=Object.freeze({QUERY:"QUERY",MUTATION:"MUTATION",SUBSCRIPTION:"SUBSCRIPTION",FIELD:"FIELD",FRAGMENT_DEFINITION:"FRAGMENT_DEFINITION",FRAGMENT_SPREAD:"FRAGMENT_SPREAD",INLINE_FRAGMENT:"INLINE_FRAGMENT",VARIABLE_DEFINITION:"VARIABLE_DEFINITION",SCHEMA:"SCHEMA",SCALAR:"SCALAR",OBJECT:"OBJECT",FIELD_DEFINITION:"FIELD_DEFINITION",ARGUMENT_DEFINITION:"ARGUMENT_DEFINITION",INTERFACE:"INTERFACE",UNION:"UNION",ENUM:"ENUM",ENUM_VALUE:"ENUM_VALUE",INPUT_OBJECT:"INPUT_OBJECT",INPUT_FIELD_DEFINITION:"INPUT_FIELD_DEFINITION"});function Eb(r){var e=r.split(/\r\n|[\n\r]/g),t=kb(r);if(t!==0)for(var i=1;i<e.length;i++)e[i]=e[i].slice(t);for(var n=0;n<e.length&&rh(e[n]);)++n;for(var a=e.length;a>n&&rh(e[a-1]);)--a;return e.slice(n,a).join(`
58
- `)}function rh(r){for(var e=0;e<r.length;++e)if(r[e]!==" "&&r[e]!==" ")return!1;return!0}function kb(r){for(var e,t=!0,i=!0,n=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,i=!0,n=0;break;case 9:case 32:++n;break;default:i&&!t&&(a===null||n<a)&&(a=n),i=!1}return(e=a)!==null&&e!==void 0?e:0}var Ab=function(){function r(t){var i=new Fe(R.SOF,0,0,0,0,null);this.source=t,this.lastToken=i,this.token=i,this.line=1,this.lineStart=0}var e=r.prototype;return e.advance=function(){this.lastToken=this.token;var i=this.token=this.lookahead();return i},e.lookahead=function(){var i=this.token;if(i.kind!==R.EOF)do{var n;i=(n=i.next)!==null&&n!==void 0?n:i.next=Tb(this,i)}while(i.kind===R.COMMENT);return i},r}();function Ib(r){return r===R.BANG||r===R.DOLLAR||r===R.AMP||r===R.PAREN_L||r===R.PAREN_R||r===R.SPREAD||r===R.COLON||r===R.EQUALS||r===R.AT||r===R.BRACKET_L||r===R.BRACKET_R||r===R.BRACE_L||r===R.PIPE||r===R.BRACE_R}function tn(r){return isNaN(r)?R.EOF:r<127?JSON.stringify(String.fromCharCode(r)):'"\\u'.concat(("00"+r.toString(16).toUpperCase()).slice(-4),'"')}function Tb(r,e){for(var t=r.source,i=t.body,n=i.length,a=e.end;a<n;){var o=i.charCodeAt(a),s=r.line,c=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:i.charCodeAt(a+1)===10?a+=2:++a,++r.line,r.lineStart=a;continue;case 33:return new Fe(R.BANG,a,a+1,s,c,e);case 35:return Ob(t,a,s,c,e);case 36:return new Fe(R.DOLLAR,a,a+1,s,c,e);case 38:return new Fe(R.AMP,a,a+1,s,c,e);case 40:return new Fe(R.PAREN_L,a,a+1,s,c,e);case 41:return new Fe(R.PAREN_R,a,a+1,s,c,e);case 46:if(i.charCodeAt(a+1)===46&&i.charCodeAt(a+2)===46)return new Fe(R.SPREAD,a,a+3,s,c,e);break;case 58:return new Fe(R.COLON,a,a+1,s,c,e);case 61:return new Fe(R.EQUALS,a,a+1,s,c,e);case 64:return new Fe(R.AT,a,a+1,s,c,e);case 91:return new Fe(R.BRACKET_L,a,a+1,s,c,e);case 93:return new Fe(R.BRACKET_R,a,a+1,s,c,e);case 123:return new Fe(R.BRACE_L,a,a+1,s,c,e);case 124:return new Fe(R.PIPE,a,a+1,s,c,e);case 125:return new Fe(R.BRACE_R,a,a+1,s,c,e);case 34:return i.charCodeAt(a+1)===34&&i.charCodeAt(a+2)===34?Rb(t,a,s,c,e,r):Pb(t,a,s,c,e);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return $b(t,a,o,s,c,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 Nb(t,a,s,c,e)}throw Nt(t,a,Cb(o))}var l=r.line,u=1+a-r.lineStart;return new Fe(R.EOF,n,n,l,u,e)}function Cb(r){return r<32&&r!==9&&r!==10&&r!==13?"Cannot contain the invalid character ".concat(tn(r),"."):r===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:"Cannot parse the unexpected character ".concat(tn(r),".")}function Ob(r,e,t,i,n){var a=r.body,o,s=e;do o=a.charCodeAt(++s);while(!isNaN(o)&&(o>31||o===9));return new Fe(R.COMMENT,e,s,t,i,n,a.slice(e+1,s))}function $b(r,e,t,i,n,a){var o=r.body,s=t,c=e,l=!1;if(s===45&&(s=o.charCodeAt(++c)),s===48){if(s=o.charCodeAt(++c),s>=48&&s<=57)throw Nt(r,c,"Invalid number, unexpected digit after 0: ".concat(tn(s),"."))}else c=Su(r,c,s),s=o.charCodeAt(c);if(s===46&&(l=!0,s=o.charCodeAt(++c),c=Su(r,c,s),s=o.charCodeAt(c)),(s===69||s===101)&&(l=!0,s=o.charCodeAt(++c),(s===43||s===45)&&(s=o.charCodeAt(++c)),c=Su(r,c,s),s=o.charCodeAt(c)),s===46||Db(s))throw Nt(r,c,"Invalid number, expected digit but got: ".concat(tn(s),"."));return new Fe(l?R.FLOAT:R.INT,e,c,i,n,a,o.slice(e,c))}function Su(r,e,t){var i=r.body,n=e,a=t;if(a>=48&&a<=57){do a=i.charCodeAt(++n);while(a>=48&&a<=57);return n}throw Nt(r,n,"Invalid number, expected digit but got: ".concat(tn(a),"."))}function Pb(r,e,t,i,n){for(var a=r.body,o=e+1,s=o,c=0,l="";o<a.length&&!isNaN(c=a.charCodeAt(o))&&c!==10&&c!==13;){if(c===34)return l+=a.slice(s,o),new Fe(R.STRING,e,o+1,t,i,n,l);if(c<32&&c!==9)throw Nt(r,o,"Invalid character within String: ".concat(tn(c),"."));if(++o,c===92){switch(l+=a.slice(s,o-1),c=a.charCodeAt(o),c){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
- `;break;case 114:l+="\r";break;case 116:l+=" ";break;case 117:{var u=Lb(a.charCodeAt(o+1),a.charCodeAt(o+2),a.charCodeAt(o+3),a.charCodeAt(o+4));if(u<0){var d=a.slice(o+1,o+5);throw Nt(r,o,"Invalid character escape sequence: \\u".concat(d,"."))}l+=String.fromCharCode(u),o+=4;break}default:throw Nt(r,o,"Invalid character escape sequence: \\".concat(String.fromCharCode(c),"."))}++o,s=o}}throw Nt(r,o,"Unterminated string.")}function Rb(r,e,t,i,n,a){for(var o=r.body,s=e+3,c=s,l=0,u="";s<o.length&&!isNaN(l=o.charCodeAt(s));){if(l===34&&o.charCodeAt(s+1)===34&&o.charCodeAt(s+2)===34)return u+=o.slice(c,s),new Fe(R.BLOCK_STRING,e,s+3,t,i,n,Eb(u));if(l<32&&l!==9&&l!==10&&l!==13)throw Nt(r,s,"Invalid character within String: ".concat(tn(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?(u+=o.slice(c,s)+'"""',s+=4,c=s):++s}throw Nt(r,s,"Unterminated string.")}function Lb(r,e,t,i){return qs(r)<<12|qs(e)<<8|qs(t)<<4|qs(i)}function qs(r){return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:-1}function Nb(r,e,t,i,n){for(var a=r.body,o=a.length,s=e+1,c=0;s!==o&&!isNaN(c=a.charCodeAt(s))&&(c===95||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122);)++s;return new Fe(R.NAME,e,s,t,i,n,a.slice(e,s))}function Db(r){return r===95||r>=65&&r<=90||r>=97&&r<=122}function Fb(r,e){var t=new Mb(r,e);return t.parseDocument()}var Mb=function(){function r(t,i){var n=_b(t)?t:new Cm(t);this._lexer=new Ab(n),this._options=i}var e=r.prototype;return e.parseName=function(){var i=this.expectToken(R.NAME);return{kind:Z.NAME,value:i.value,loc:this.loc(i)}},e.parseDocument=function(){var i=this._lexer.token;return{kind:Z.DOCUMENT,definitions:this.many(R.SOF,this.parseDefinition,R.EOF),loc:this.loc(i)}},e.parseDefinition=function(){if(this.peek(R.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(R.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},e.parseOperationDefinition=function(){var i=this._lexer.token;if(this.peek(R.BRACE_L))return{kind:Z.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(i)};var n=this.parseOperationType(),a;return this.peek(R.NAME)&&(a=this.parseName()),{kind:Z.OPERATION_DEFINITION,operation:n,name:a,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(i)}},e.parseOperationType=function(){var i=this.expectToken(R.NAME);switch(i.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(i)},e.parseVariableDefinitions=function(){return this.optionalMany(R.PAREN_L,this.parseVariableDefinition,R.PAREN_R)},e.parseVariableDefinition=function(){var i=this._lexer.token;return{kind:Z.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(R.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(R.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(i)}},e.parseVariable=function(){var i=this._lexer.token;return this.expectToken(R.DOLLAR),{kind:Z.VARIABLE,name:this.parseName(),loc:this.loc(i)}},e.parseSelectionSet=function(){var i=this._lexer.token;return{kind:Z.SELECTION_SET,selections:this.many(R.BRACE_L,this.parseSelection,R.BRACE_R),loc:this.loc(i)}},e.parseSelection=function(){return this.peek(R.SPREAD)?this.parseFragment():this.parseField()},e.parseField=function(){var i=this._lexer.token,n=this.parseName(),a,o;return this.expectOptionalToken(R.COLON)?(a=n,o=this.parseName()):o=n,{kind:Z.FIELD,alias:a,name:o,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(R.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(i)}},e.parseArguments=function(i){var n=i?this.parseConstArgument:this.parseArgument;return this.optionalMany(R.PAREN_L,n,R.PAREN_R)},e.parseArgument=function(){var i=this._lexer.token,n=this.parseName();return this.expectToken(R.COLON),{kind:Z.ARGUMENT,name:n,value:this.parseValueLiteral(!1),loc:this.loc(i)}},e.parseConstArgument=function(){var i=this._lexer.token;return{kind:Z.ARGUMENT,name:this.parseName(),value:(this.expectToken(R.COLON),this.parseValueLiteral(!0)),loc:this.loc(i)}},e.parseFragment=function(){var i=this._lexer.token;this.expectToken(R.SPREAD);var n=this.expectOptionalKeyword("on");return!n&&this.peek(R.NAME)?{kind:Z.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(i)}:{kind:Z.INLINE_FRAGMENT,typeCondition:n?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(i)}},e.parseFragmentDefinition=function(){var i,n=this._lexer.token;return this.expectKeyword("fragment"),((i=this._options)===null||i===void 0?void 0:i.experimentalFragmentVariables)===!0?{kind:Z.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(n)}:{kind:Z.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(n)}},e.parseFragmentName=function(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()},e.parseValueLiteral=function(i){var n=this._lexer.token;switch(n.kind){case R.BRACKET_L:return this.parseList(i);case R.BRACE_L:return this.parseObject(i);case R.INT:return this._lexer.advance(),{kind:Z.INT,value:n.value,loc:this.loc(n)};case R.FLOAT:return this._lexer.advance(),{kind:Z.FLOAT,value:n.value,loc:this.loc(n)};case R.STRING:case R.BLOCK_STRING:return this.parseStringLiteral();case R.NAME:switch(this._lexer.advance(),n.value){case"true":return{kind:Z.BOOLEAN,value:!0,loc:this.loc(n)};case"false":return{kind:Z.BOOLEAN,value:!1,loc:this.loc(n)};case"null":return{kind:Z.NULL,loc:this.loc(n)};default:return{kind:Z.ENUM,value:n.value,loc:this.loc(n)}}case R.DOLLAR:if(!i)return this.parseVariable();break}throw this.unexpected()},e.parseStringLiteral=function(){var i=this._lexer.token;return this._lexer.advance(),{kind:Z.STRING,value:i.value,block:i.kind===R.BLOCK_STRING,loc:this.loc(i)}},e.parseList=function(i){var n=this,a=this._lexer.token,o=function(){return n.parseValueLiteral(i)};return{kind:Z.LIST,values:this.any(R.BRACKET_L,o,R.BRACKET_R),loc:this.loc(a)}},e.parseObject=function(i){var n=this,a=this._lexer.token,o=function(){return n.parseObjectField(i)};return{kind:Z.OBJECT,fields:this.any(R.BRACE_L,o,R.BRACE_R),loc:this.loc(a)}},e.parseObjectField=function(i){var n=this._lexer.token,a=this.parseName();return this.expectToken(R.COLON),{kind:Z.OBJECT_FIELD,name:a,value:this.parseValueLiteral(i),loc:this.loc(n)}},e.parseDirectives=function(i){for(var n=[];this.peek(R.AT);)n.push(this.parseDirective(i));return n},e.parseDirective=function(i){var n=this._lexer.token;return this.expectToken(R.AT),{kind:Z.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(i),loc:this.loc(n)}},e.parseTypeReference=function(){var i=this._lexer.token,n;return this.expectOptionalToken(R.BRACKET_L)?(n=this.parseTypeReference(),this.expectToken(R.BRACKET_R),n={kind:Z.LIST_TYPE,type:n,loc:this.loc(i)}):n=this.parseNamedType(),this.expectOptionalToken(R.BANG)?{kind:Z.NON_NULL_TYPE,type:n,loc:this.loc(i)}:n},e.parseNamedType=function(){var i=this._lexer.token;return{kind:Z.NAMED_TYPE,name:this.parseName(),loc:this.loc(i)}},e.parseTypeSystemDefinition=function(){var i=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(i.kind===R.NAME)switch(i.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(i)},e.peekDescription=function(){return this.peek(R.STRING)||this.peek(R.BLOCK_STRING)},e.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},e.parseSchemaDefinition=function(){var i=this._lexer.token,n=this.parseDescription();this.expectKeyword("schema");var a=this.parseDirectives(!0),o=this.many(R.BRACE_L,this.parseOperationTypeDefinition,R.BRACE_R);return{kind:Z.SCHEMA_DEFINITION,description:n,directives:a,operationTypes:o,loc:this.loc(i)}},e.parseOperationTypeDefinition=function(){var i=this._lexer.token,n=this.parseOperationType();this.expectToken(R.COLON);var a=this.parseNamedType();return{kind:Z.OPERATION_TYPE_DEFINITION,operation:n,type:a,loc:this.loc(i)}},e.parseScalarTypeDefinition=function(){var i=this._lexer.token,n=this.parseDescription();this.expectKeyword("scalar");var a=this.parseName(),o=this.parseDirectives(!0);return{kind:Z.SCALAR_TYPE_DEFINITION,description:n,name:a,directives:o,loc:this.loc(i)}},e.parseObjectTypeDefinition=function(){var i=this._lexer.token,n=this.parseDescription();this.expectKeyword("type");var a=this.parseName(),o=this.parseImplementsInterfaces(),s=this.parseDirectives(!0),c=this.parseFieldsDefinition();return{kind:Z.OBJECT_TYPE_DEFINITION,description:n,name:a,interfaces:o,directives:s,fields:c,loc:this.loc(i)}},e.parseImplementsInterfaces=function(){var i;if(!this.expectOptionalKeyword("implements"))return[];if(((i=this._options)===null||i===void 0?void 0:i.allowLegacySDLImplementsInterfaces)===!0){var n=[];this.expectOptionalToken(R.AMP);do n.push(this.parseNamedType());while(this.expectOptionalToken(R.AMP)||this.peek(R.NAME));return n}return this.delimitedMany(R.AMP,this.parseNamedType)},e.parseFieldsDefinition=function(){var i;return((i=this._options)===null||i===void 0?void 0:i.allowLegacySDLEmptyFields)===!0&&this.peek(R.BRACE_L)&&this._lexer.lookahead().kind===R.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(R.BRACE_L,this.parseFieldDefinition,R.BRACE_R)},e.parseFieldDefinition=function(){var i=this._lexer.token,n=this.parseDescription(),a=this.parseName(),o=this.parseArgumentDefs();this.expectToken(R.COLON);var s=this.parseTypeReference(),c=this.parseDirectives(!0);return{kind:Z.FIELD_DEFINITION,description:n,name:a,arguments:o,type:s,directives:c,loc:this.loc(i)}},e.parseArgumentDefs=function(){return this.optionalMany(R.PAREN_L,this.parseInputValueDef,R.PAREN_R)},e.parseInputValueDef=function(){var i=this._lexer.token,n=this.parseDescription(),a=this.parseName();this.expectToken(R.COLON);var o=this.parseTypeReference(),s;this.expectOptionalToken(R.EQUALS)&&(s=this.parseValueLiteral(!0));var c=this.parseDirectives(!0);return{kind:Z.INPUT_VALUE_DEFINITION,description:n,name:a,type:o,defaultValue:s,directives:c,loc:this.loc(i)}},e.parseInterfaceTypeDefinition=function(){var i=this._lexer.token,n=this.parseDescription();this.expectKeyword("interface");var a=this.parseName(),o=this.parseImplementsInterfaces(),s=this.parseDirectives(!0),c=this.parseFieldsDefinition();return{kind:Z.INTERFACE_TYPE_DEFINITION,description:n,name:a,interfaces:o,directives:s,fields:c,loc:this.loc(i)}},e.parseUnionTypeDefinition=function(){var i=this._lexer.token,n=this.parseDescription();this.expectKeyword("union");var a=this.parseName(),o=this.parseDirectives(!0),s=this.parseUnionMemberTypes();return{kind:Z.UNION_TYPE_DEFINITION,description:n,name:a,directives:o,types:s,loc:this.loc(i)}},e.parseUnionMemberTypes=function(){return this.expectOptionalToken(R.EQUALS)?this.delimitedMany(R.PIPE,this.parseNamedType):[]},e.parseEnumTypeDefinition=function(){var i=this._lexer.token,n=this.parseDescription();this.expectKeyword("enum");var a=this.parseName(),o=this.parseDirectives(!0),s=this.parseEnumValuesDefinition();return{kind:Z.ENUM_TYPE_DEFINITION,description:n,name:a,directives:o,values:s,loc:this.loc(i)}},e.parseEnumValuesDefinition=function(){return this.optionalMany(R.BRACE_L,this.parseEnumValueDefinition,R.BRACE_R)},e.parseEnumValueDefinition=function(){var i=this._lexer.token,n=this.parseDescription(),a=this.parseName(),o=this.parseDirectives(!0);return{kind:Z.ENUM_VALUE_DEFINITION,description:n,name:a,directives:o,loc:this.loc(i)}},e.parseInputObjectTypeDefinition=function(){var i=this._lexer.token,n=this.parseDescription();this.expectKeyword("input");var a=this.parseName(),o=this.parseDirectives(!0),s=this.parseInputFieldsDefinition();return{kind:Z.INPUT_OBJECT_TYPE_DEFINITION,description:n,name:a,directives:o,fields:s,loc:this.loc(i)}},e.parseInputFieldsDefinition=function(){return this.optionalMany(R.BRACE_L,this.parseInputValueDef,R.BRACE_R)},e.parseTypeSystemExtension=function(){var i=this._lexer.lookahead();if(i.kind===R.NAME)switch(i.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(i)},e.parseSchemaExtension=function(){var i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var n=this.parseDirectives(!0),a=this.optionalMany(R.BRACE_L,this.parseOperationTypeDefinition,R.BRACE_R);if(n.length===0&&a.length===0)throw this.unexpected();return{kind:Z.SCHEMA_EXTENSION,directives:n,operationTypes:a,loc:this.loc(i)}},e.parseScalarTypeExtension=function(){var i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");var n=this.parseName(),a=this.parseDirectives(!0);if(a.length===0)throw this.unexpected();return{kind:Z.SCALAR_TYPE_EXTENSION,name:n,directives:a,loc:this.loc(i)}},e.parseObjectTypeExtension=function(){var i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var n=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:Z.OBJECT_TYPE_EXTENSION,name:n,interfaces:a,directives:o,fields:s,loc:this.loc(i)}},e.parseInterfaceTypeExtension=function(){var i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var n=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:Z.INTERFACE_TYPE_EXTENSION,name:n,interfaces:a,directives:o,fields:s,loc:this.loc(i)}},e.parseUnionTypeExtension=function(){var i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var n=this.parseName(),a=this.parseDirectives(!0),o=this.parseUnionMemberTypes();if(a.length===0&&o.length===0)throw this.unexpected();return{kind:Z.UNION_TYPE_EXTENSION,name:n,directives:a,types:o,loc:this.loc(i)}},e.parseEnumTypeExtension=function(){var i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var n=this.parseName(),a=this.parseDirectives(!0),o=this.parseEnumValuesDefinition();if(a.length===0&&o.length===0)throw this.unexpected();return{kind:Z.ENUM_TYPE_EXTENSION,name:n,directives:a,values:o,loc:this.loc(i)}},e.parseInputObjectTypeExtension=function(){var i=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var n=this.parseName(),a=this.parseDirectives(!0),o=this.parseInputFieldsDefinition();if(a.length===0&&o.length===0)throw this.unexpected();return{kind:Z.INPUT_OBJECT_TYPE_EXTENSION,name:n,directives:a,fields:o,loc:this.loc(i)}},e.parseDirectiveDefinition=function(){var i=this._lexer.token,n=this.parseDescription();this.expectKeyword("directive"),this.expectToken(R.AT);var a=this.parseName(),o=this.parseArgumentDefs(),s=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var c=this.parseDirectiveLocations();return{kind:Z.DIRECTIVE_DEFINITION,description:n,name:a,arguments:o,repeatable:s,locations:c,loc:this.loc(i)}},e.parseDirectiveLocations=function(){return this.delimitedMany(R.PIPE,this.parseDirectiveLocation)},e.parseDirectiveLocation=function(){var i=this._lexer.token,n=this.parseName();if(xb[n.value]!==void 0)return n;throw this.unexpected(i)},e.loc=function(i){var n;if(((n=this._options)===null||n===void 0?void 0:n.noLocation)!==!0)return new Im(i,this._lexer.lastToken,this._lexer.source)},e.peek=function(i){return this._lexer.token.kind===i},e.expectToken=function(i){var n=this._lexer.token;if(n.kind===i)return this._lexer.advance(),n;throw Nt(this._lexer.source,n.start,"Expected ".concat(Om(i),", found ").concat(_u(n),"."))},e.expectOptionalToken=function(i){var n=this._lexer.token;if(n.kind===i)return this._lexer.advance(),n},e.expectKeyword=function(i){var n=this._lexer.token;if(n.kind===R.NAME&&n.value===i)this._lexer.advance();else throw Nt(this._lexer.source,n.start,'Expected "'.concat(i,'", found ').concat(_u(n),"."))},e.expectOptionalKeyword=function(i){var n=this._lexer.token;return n.kind===R.NAME&&n.value===i?(this._lexer.advance(),!0):!1},e.unexpected=function(i){var n=i??this._lexer.token;return Nt(this._lexer.source,n.start,"Unexpected ".concat(_u(n),"."))},e.any=function(i,n,a){this.expectToken(i);for(var o=[];!this.expectOptionalToken(a);)o.push(n.call(this));return o},e.optionalMany=function(i,n,a){if(this.expectOptionalToken(i)){var o=[];do o.push(n.call(this));while(!this.expectOptionalToken(a));return o}return[]},e.many=function(i,n,a){this.expectToken(i);var o=[];do o.push(n.call(this));while(!this.expectOptionalToken(a));return o},e.delimitedMany=function(i,n){this.expectOptionalToken(i);var a=[];do a.push(n.call(this));while(this.expectOptionalToken(i));return a},r}();function _u(r){var e=r.value;return Om(r.kind)+(e!=null?' "'.concat(e,'"'):"")}function Om(r){return Ib(r)?'"'.concat(r,'"'):r}var ac=new Map,Vu=new Map,$m=!0,yc=!1;function Pm(r){return r.replace(/[\s,]+/g," ").trim()}function Ub(r){return Pm(r.source.body.substring(r.start,r.end))}function jb(r){var e=new Set,t=[];return r.definitions.forEach(function(i){if(i.kind==="FragmentDefinition"){var n=i.name.value,a=Ub(i.loc),o=Vu.get(n);o&&!o.has(a)?$m&&console.warn("Warning: fragment with name "+n+` already exists.
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||Vu.set(n,o=new Set),o.add(a),e.has(a)||(e.add(a),t.push(i))}else t.push(i)}),gc(gc({},r),{definitions:t})}function qb(r){var e=new Set(r.definitions);e.forEach(function(i){i.loc&&delete i.loc,Object.keys(i).forEach(function(n){var a=i[n];a&&typeof a=="object"&&e.add(a)})});var t=r.loc;return t&&(delete t.startToken,delete t.endToken),r}function Bb(r){var e=Pm(r);if(!ac.has(e)){var t=Fb(r,{experimentalFragmentVariables:yc,allowLegacyFragmentVariables:yc});if(!t||t.kind!=="Document")throw new Error("Not a valid GraphQL document.");ac.set(e,qb(jb(t)))}return ac.get(e)}function x(r){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];typeof r=="string"&&(r=[r]);var i=r[0];return e.forEach(function(n,a){n&&n.kind==="Document"?i+=n.loc.source.body:i+=n,i+=r[a+1]}),Bb(i)}function Vb(){ac.clear(),Vu.clear()}function Qb(){$m=!1}function Hb(){yc=!0}function zb(){yc=!1}var za={gql:x,resetCaches:Vb,disableFragmentWarnings:Qb,enableExperimentalFragmentVariables:Hb,disableExperimentalFragmentVariables:zb};(function(r){r.gql=za.gql,r.resetCaches=za.resetCaches,r.disableFragmentWarnings=za.disableFragmentWarnings,r.enableExperimentalFragmentVariables=za.enableExperimentalFragmentVariables,r.disableExperimentalFragmentVariables=za.disableExperimentalFragmentVariables})(x||(x={}));x.default=x;function k(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 Wb(){}function Si(){return Wb}var Q=Si,w=Si,Xe=Si,ae=Si,J=Si,qe=Si,Gb=Si,fp=Si,Rm=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Lm=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},rn=class{constructor(e){this.code=e}};Rm([w(),Lm("design:type",String)],rn.prototype,"code",void 0);rn=Rm([J(),Lm("design:paramtypes",[String])],rn);var hp=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},mp=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},yr=class{constructor(e,t){this.address=e,this.name=t}};hp([w(),mp("design:type",String)],yr.prototype,"address",void 0);hp([w(),mp("design:type",String)],yr.prototype,"name",void 0);yr=hp([J(),mp("design:paramtypes",[String,String])],yr);var Ce=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},ze=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Dr=class{constructor(e,t){this.key=t,this.signature=e}};Ce([w(),ze("design:type",String)],Dr.prototype,"signature",void 0);Ce([w(),ze("design:type",String)],Dr.prototype,"key",void 0);Ce([w(),ze("design:type",Boolean)],Dr.prototype,"valid",void 0);Ce([w(),ze("design:type",Boolean)],Dr.prototype,"invalid",void 0);Dr=Ce([J(),Xe(),ze("design:paramtypes",[String,String])],Dr);var nn=class{};Ce([w(),ze("design:type",String)],nn.prototype,"signature",void 0);Ce([w(),ze("design:type",String)],nn.prototype,"key",void 0);Ce([w(),ze("design:type",Boolean)],nn.prototype,"valid",void 0);Ce([w(),ze("design:type",Boolean)],nn.prototype,"invalid",void 0);nn=Ce([Xe()],nn);function _i(r){let e=class{constructor(i,n,a,o){this.author=i,this.timestamp=n,this.data=a,this.proof=o}};return Ce([w(),ze("design:type",String)],e.prototype,"author",void 0),Ce([w(),ze("design:type",String)],e.prototype,"timestamp",void 0),Ce([w(),ze("design:type",Object)],e.prototype,"data",void 0),Ce([w(),ze("design:type",Dr)],e.prototype,"proof",void 0),e=Ce([J(),ze("design:paramtypes",[String,String,Object,Dr])],e),e}function Kb(r){let e=class{};return Ce([w(),ze("design:type",String)],e.prototype,"author",void 0),Ce([w(),ze("design:type",String)],e.prototype,"timestamp",void 0),Ce([w(),ze("design:type",Object)],e.prototype,"data",void 0),Ce([w(),ze("design:type",nn)],e.prototype,"proof",void 0),e=Ce([Xe()],e),e}var ih=class extends _i(){};ih=Ce([J()],ih);var vc=class extends _i(){};Ce([w(),ze("design:type",yr)],vc.prototype,"language",void 0);Ce([w(),ze("design:type",rn)],vc.prototype,"icon",void 0);vc=Ce([J()],vc);function BC(r){return r&&r.author&&r.timestamp&&r.data}var Be=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},ot=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},It=class{constructor(e){this.source=e.source?e.source:"",this.target=e.target?e.target:"",this.predicate=e.predicate?e.predicate:""}};Be([w(),ot("design:type",String)],It.prototype,"source",void 0);Be([w(),ot("design:type",String)],It.prototype,"target",void 0);Be([w(),ot("design:type",String)],It.prototype,"predicate",void 0);It=Be([J(),ot("design:paramtypes",[Object])],It);var bc=class{};Be([w(),ot("design:type",Array)],bc.prototype,"additions",void 0);Be([w(),ot("design:type",Array)],bc.prototype,"removals",void 0);bc=Be([Xe()],bc);var wc=class{constructor(e,t){this.additions=e,this.removals=t}};Be([w(),ot("design:type",Array)],wc.prototype,"additions",void 0);Be([w(),ot("design:type",Array)],wc.prototype,"removals",void 0);wc=Be([J(),ot("design:paramtypes",[Array,Array])],wc);var Co=class{};Be([w(),ot("design:type",String)],Co.prototype,"source",void 0);Be([w(),ot("design:type",String)],Co.prototype,"target",void 0);Be([w(),ot("design:type",String)],Co.prototype,"predicate",void 0);Co=Be([Xe()],Co);var hi=class extends _i(){hash(){let e=JSON.stringify(this.data,Object.keys(this.data).sort())+JSON.stringify(this.author)+this.timestamp,t=0,i,n;for(i=0;i<e.length;i++)n=e.charCodeAt(i),t=(t<<5)-t+n,t|=0;return t}};Be([w(),ot("design:type",String)],hi.prototype,"status",void 0);hi=Be([J()],hi);var Qu=class extends Kb(){};Be([w(),ot("design:type",String)],Qu.prototype,"status",void 0);Qu=Be([Xe()],Qu);function KC(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 JC(r){return r&&r.source&&r.target}var Sc=class{constructor(e,t){this.oldLink=e,this.newLink=t}};Be([w(),ot("design:type",hi)],Sc.prototype,"oldLink",void 0);Be([w(),ot("design:type",hi)],Sc.prototype,"newLink",void 0);Sc=Be([J(),ot("design:paramtypes",[hi,hi])],Sc);var mn=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Bo=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Hu,Sr=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 i=JSON.parse(JSON.stringify(this.links));return e.target&&(i=i.filter(n=>n.data.target===e.target)),e.predicate&&(i=i.filter(n=>n.data.predicate===e.predicate)),e.fromDate&&(i=i.filter(n=>new Date(n.timestamp)>=e.fromDate)),e.untilDate&&(i=i.filter(n=>new Date(n.timestamp)<=e.untilDate)),e.limit&&(i=i.slice(0,e.limit)),i}if(e.target){let i=JSON.parse(JSON.stringify(this.links));return e.predicate&&(i=i.filter(n=>n.data.predicate===e.predicate)),e.fromDate&&(i=i.filter(n=>new Date(n.timestamp)>=e.fromDate)),e.untilDate&&(i=i.filter(n=>new Date(n.timestamp)<=e.untilDate)),e.limit&&(i=i.slice(0,e.limit)),i}let t=JSON.parse(JSON.stringify(this.links));return t=t.filter(i=>i.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}};mn([w(),Bo("design:type",Array)],Sr.prototype,"links",void 0);Sr=mn([J(),Bo("design:paramtypes",[Array])],Sr);var _c=class{};mn([w(),Bo("design:type",Array)],_c.prototype,"links",void 0);_c=mn([Xe()],_c);var zu=Hu=class{constructor(e){e?this.links=e:this.links=[]}static fromLink(e){let t=new Hu;return t.links.push(e),t}};mn([w(),Bo("design:type",Array)],zu.prototype,"links",void 0);zu=Hu=mn([Xe(),Bo("design:paramtypes",[Array])],zu);var an=class extends _i(){};an=mn([J()],an);var z=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},G=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},li=class{constructor(e,t){this.did=e,t?this.perspective=t:this.perspective=new Sr}};z([w(),G("design:type",String)],li.prototype,"did",void 0);z([w(),G("design:type",Sr)],li.prototype,"perspective",void 0);z([w(),G("design:type",String)],li.prototype,"directMessageLanguage",void 0);li=z([J(),G("design:paramtypes",[String,Sr])],li);var nh=class extends _i(){};nh=z([J()],nh);var mi=class{constructor(e,t,i,n,a,o){this.did=e,this.didSigningKeyId=t,this.deviceKeyType=i,this.deviceKey=n,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=o}};z([w(),G("design:type",String)],mi.prototype,"did",void 0);z([w(),G("design:type",String)],mi.prototype,"didSigningKeyId",void 0);z([w(),G("design:type",String)],mi.prototype,"deviceKeyType",void 0);z([w(),G("design:type",String)],mi.prototype,"deviceKey",void 0);z([w(),G("design:type",String)],mi.prototype,"deviceKeySignedByDid",void 0);z([w(),G("design:type",String)],mi.prototype,"didSignedByDeviceKey",void 0);mi=z([J(),G("design:paramtypes",[String,String,String,String,String,String])],mi);var gi=class{constructor(e,t,i,n,a,o){this.did=e,this.didSigningKeyId=t,this.deviceKeyType=i,this.deviceKey=n,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=o}};z([w(),G("design:type",String)],gi.prototype,"did",void 0);z([w(),G("design:type",String)],gi.prototype,"didSigningKeyId",void 0);z([w(),G("design:type",String)],gi.prototype,"deviceKeyType",void 0);z([w(),G("design:type",String)],gi.prototype,"deviceKey",void 0);z([w(),G("design:type",String)],gi.prototype,"deviceKeySignedByDid",void 0);z([w(),G("design:type",String)],gi.prototype,"didSignedByDeviceKey",void 0);gi=z([Xe(),G("design:paramtypes",[String,String,String,String,String,String])],gi);var xc=class{constructor(e,t){this.signature=e,this.publicKey=t}};z([w(),G("design:type",String)],xc.prototype,"signature",void 0);z([w(),G("design:type",String)],xc.prototype,"publicKey",void 0);xc=z([J(),G("design:paramtypes",[String,String])],xc);var aa=class{constructor(e,t){this.domain=e,this.pointers=t}};z([w(),G("design:type",String)],aa.prototype,"domain",void 0);z([w(),G("design:type",Array)],aa.prototype,"pointers",void 0);aa=z([J(),G("design:paramtypes",[String,Array])],aa);var Ec=class{constructor(e,t){this.with=e,this.can=t}};z([w(),G("design:type",aa)],Ec.prototype,"with",void 0);z([w(),G("design:type",Array)],Ec.prototype,"can",void 0);Ec=z([J(),G("design:paramtypes",[aa,Array])],Ec);var Fr=class{constructor(e,t,i,n,a){this.appName=e,this.appDesc=t,this.appIconPath=a,this.appUrl=i,this.capabilities=n}};z([w(),G("design:type",String)],Fr.prototype,"appName",void 0);z([w(),G("design:type",String)],Fr.prototype,"appDesc",void 0);z([w(),G("design:type",String)],Fr.prototype,"appUrl",void 0);z([w(),G("design:type",String)],Fr.prototype,"appIconPath",void 0);z([w(),G("design:type",Array)],Fr.prototype,"capabilities",void 0);Fr=z([J(),G("design:paramtypes",[String,String,String,Array,String])],Fr);var oa=class{constructor(e,t,i,n){this.requestId=e,this.auth=t,this.token=i,this.revoked=n}};z([w(),G("design:type",String)],oa.prototype,"requestId",void 0);z([w(),G("design:type",String)],oa.prototype,"token",void 0);z([w(),G("design:type",Boolean)],oa.prototype,"revoked",void 0);z([w(),G("design:type",Fr)],oa.prototype,"auth",void 0);oa=z([J(),G("design:paramtypes",[String,Fr,String,Boolean])],oa);var sa=class{constructor(e,t){this.domain=e,this.pointers=t}};z([w(),G("design:type",String)],sa.prototype,"domain",void 0);z([w(),G("design:type",Array)],sa.prototype,"pointers",void 0);sa=z([Xe(),G("design:paramtypes",[String,Array])],sa);var kc=class{constructor(e,t){this.with=e,this.can=t}};z([w(),G("design:type",sa)],kc.prototype,"with",void 0);z([w(),G("design:type",Array)],kc.prototype,"can",void 0);kc=z([Xe(),G("design:paramtypes",[sa,Array])],kc);var _r=class{constructor(e,t,i,n,a,o){this.appName=e,this.appDesc=t,this.appUrl=n,this.appDomain=i,this.capabilities=o,this.appIconPath=a}};z([w(),G("design:type",String)],_r.prototype,"appName",void 0);z([w(),G("design:type",String)],_r.prototype,"appDesc",void 0);z([w(),G("design:type",String)],_r.prototype,"appDomain",void 0);z([w(),G("design:type",String)],_r.prototype,"appUrl",void 0);z([w(),G("design:type",String)],_r.prototype,"appIconPath",void 0);z([w(),G("design:type",Array)],_r.prototype,"capabilities",void 0);_r=z([Xe(),G("design:paramtypes",[String,String,String,String,String,Array])],_r);var on=class{constructor(e,t,i){this.did=e,this.success=t,this.error=i}};z([w(),G("design:type",String)],on.prototype,"did",void 0);z([w(),G("design:type",Boolean)],on.prototype,"success",void 0);z([w(),G("design:type",String)],on.prototype,"error",void 0);on=z([J(),G("design:paramtypes",[String,Boolean,String])],on);var ma=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},ga=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},zt=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)}};ma([w(),ga("design:type",Boolean)],zt.prototype,"isInitialized",void 0);ma([w(),ga("design:type",Boolean)],zt.prototype,"isUnlocked",void 0);ma([w(),ga("design:type",String)],zt.prototype,"did",void 0);ma([w(),ga("design:type",String)],zt.prototype,"didDocument",void 0);ma([w(),ga("design:type",String)],zt.prototype,"error",void 0);zt=ma([J(),ga("design:paramtypes",[Object])],zt);var ah=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},Ne=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},Et,kt,Wu=class{constructor(e,t){Et.set(this,void 0),kt.set(this,void 0),ah(this,Et,e,"f"),ah(this,kt,t,"f")}async otherAgents(){return await Ne(this,Et,"f").otherAgents(Ne(this,kt,"f"))}async hasTelepresenceAdapter(){return await Ne(this,Et,"f").hasTelepresenceAdapter(Ne(this,kt,"f"))}async onlineAgents(){return await Ne(this,Et,"f").onlineAgents(Ne(this,kt,"f"))}async setOnlineStatus(e){return await Ne(this,Et,"f").setOnlineStatus(Ne(this,kt,"f"),e)}async setOnlineStatusU(e){return await Ne(this,Et,"f").setOnlineStatusU(Ne(this,kt,"f"),e)}async sendSignal(e,t){return await Ne(this,Et,"f").sendSignal(Ne(this,kt,"f"),e,t)}async sendSignalU(e,t){return await Ne(this,Et,"f").sendSignalU(Ne(this,kt,"f"),e,t)}async sendBroadcast(e,t=!1){return await Ne(this,Et,"f").sendBroadcast(Ne(this,kt,"f"),e,t)}async sendBroadcastU(e,t=!1){return await Ne(this,Et,"f").sendBroadcastU(Ne(this,kt,"f"),e,t)}async addSignalHandler(e){await Ne(this,Et,"f").addSignalHandler(Ne(this,kt,"f"),e)}removeSignalHandler(e){Ne(this,Et,"f").removeSignalHandler(Ne(this,kt,"f"),e)}};Et=new WeakMap,kt=new WeakMap;var gn=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},yn=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},K=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)}};gn([w(),yn("design:type",String)],K.prototype,"source",void 0);gn([w(),yn("design:type",String)],K.prototype,"target",void 0);gn([w(),yn("design:type",String)],K.prototype,"predicate",void 0);gn([w(),yn("design:type",Date)],K.prototype,"fromDate",void 0);gn([w(),yn("design:type",Date)],K.prototype,"untilDate",void 0);gn([w(),yn("design:type",Number)],K.prototype,"limit",void 0);K=gn([J(),Xe(),yn("design:paramtypes",[Object])],K);var oh=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},nt=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},At,Or;function Bs(r){return encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}var xe=class{constructor(){At.set(this,void 0),Or.set(this,void 0)}static fromUrl(e){if(!e||!e.startsWith("literal:"))throw new Error("Can't create Literal from non-literal URL");if(e.startsWith("literal://"))throw new Error("literal:// format is no longer supported. Use literal: instead.");let t=new xe;return oh(t,Or,e,"f"),t}static from(e){let t=new xe;return oh(t,At,e,"f"),t}toUrl(){if(nt(this,Or,"f")&&!nt(this,At,"f"))return nt(this,Or,"f");if(!nt(this,Or,"f")&&(nt(this,At,"f")===void 0||nt(this,At,"f")===""||nt(this,At,"f")===null))throw new Error("Can't turn empty Literal into URL");let e;switch(typeof nt(this,At,"f")){case"string":e=`string:${Bs(nt(this,At,"f"))}`;break;case"number":e=`number:${Bs(nt(this,At,"f"))}`;break;case"boolean":e=`boolean:${Bs(nt(this,At,"f"))}`;break;case"object":e=`json:${Bs(JSON.stringify(nt(this,At,"f")))}`;break}return`literal:${e}`}get(){if(nt(this,At,"f"))return nt(this,At,"f");if(!nt(this,Or,"f"))throw new Error("Can't render empty Literal");if(!nt(this,Or,"f").startsWith("literal:"))throw new Error("Can't render Literal from non-literal URL");let e=nt(this,Or,"f").substring(8);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}`)}};At=new WeakMap,Or=new WeakMap;function vt(r){return r.charAt(0).toUpperCase()+r.slice(1)}function jc(r){return`set${vt(r)}`}function Nm(r){return r.endsWith("ies")?r.slice(0,-3)+"y":r.endsWith("s")?r.slice(0,-1):r}function Jb(r){return`add${vt(Nm(r))}`}function Zb(r){return`remove${vt(Nm(r))}`}function Yb(r){return`set${vt(r)}`}function Dm(r){let e="",t="abcdefghijklmnopqrstuvwxyz",i=t.length;for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*i));return e}function ji(r){if(Array.isArray(r))return`[${r.map(ji).join(", ")}]`;let e=Object.keys(r),t=[];for(let i of e){let n=JSON.stringify(r[i]),a=`${i}: ${n}`;t.push(a)}return`{${t.join(", ")}}`}var xu=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},re=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},ht,mt,De,_o=class{constructor(r,e,t){ht.set(this,void 0),mt.set(this,void 0),De.set(this,void 0),xu(this,ht,e,"f"),xu(this,mt,t,"f"),xu(this,De,r,"f")}get baseExpression(){return re(this,ht,"f")}async init(){let isInstance=await re(this,De,"f").isSubjectInstance(re(this,ht,"f"),re(this,mt,"f"));if(!isInstance)throw`Not a valid subject instance of ${re(this,mt,"f")} for ${re(this,ht,"f")}`;let results=await re(this,De,"f").infer(`subject_class("${re(this,mt,"f")}", C), property(C, Property)`),properties=results.map(r=>r.Property);for(let r of properties)await re(this,De,"f").infer(`subject_class("${re(this,mt,"f")}", C), property_resolve(C, "${r}")`),Object.defineProperty(this,r,{configurable:!0,get:async()=>{try{return await re(this,De,"f").getPropertyValueViaSparql(re(this,ht,"f"),re(this,mt,"f"),r)}catch(e){console.warn(`Failed to get property ${r} via SPARQL:`,e);return}}});let setters=await re(this,De,"f").infer(`subject_class("${re(this,mt,"f")}", C), property_setter(C, Property, Setter)`);for(let setter of setters||[])if(setter){let property=setter.Property,actions=eval(setter.Setter),resolveLanguageResults=await re(this,De,"f").infer(`subject_class("${re(this,mt,"f")}", C), property_resolve_language(C, "${property}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),this[jc(property)]=async r=>{resolveLanguage&&(r=await re(this,De,"f").createExpression(r,resolveLanguage)),await re(this,De,"f").executeAction(actions,re(this,ht,"f"),[{name:"value",value:r}])}}let results2=await re(this,De,"f").infer(`subject_class("${re(this,mt,"f")}", C), collection(C, Collection)`);results2||(results2=[]);let relations=results2.map(r=>r.Collection);for(let r of relations)Object.defineProperty(this,r,{configurable:!0,get:async()=>{try{return await re(this,De,"f").getRelationValuesViaSparql(re(this,ht,"f"),re(this,mt,"f"),r)}catch(e){return console.warn(`Failed to get relation ${r} via SPARQL:`,e),[]}}});let adders=await re(this,De,"f").infer(`subject_class("${re(this,mt,"f")}", C), collection_adder(C, Collection, Adder)`);adders||(adders=[]);for(let adder of adders)if(adder){let relation=adder.Collection,actions=eval(adder.Adder);this[Jb(relation)]=async r=>{Array.isArray(r)?await Promise.all(r.map(e=>re(this,De,"f").executeAction(actions,re(this,ht,"f"),[{name:"value",value:e}]))):await re(this,De,"f").executeAction(actions,re(this,ht,"f"),[{name:"value",value:r}])}}let removers=await re(this,De,"f").infer(`subject_class("${re(this,mt,"f")}", C), collection_remover(C, Collection, Remover)`);removers||(removers=[]);for(let remover of removers)if(remover){let relation=remover.Collection,actions=eval(remover.Remover);this[Zb(relation)]=async r=>{Array.isArray(r)?await Promise.all(r.map(e=>re(this,De,"f").executeAction(actions,re(this,ht,"f"),[{name:"value",value:e}]))):await re(this,De,"f").executeAction(actions,re(this,ht,"f"),[{name:"value",value:r}])}}let relationSetters=await re(this,De,"f").infer(`subject_class("${re(this,mt,"f")}", C), collection_setter(C, Collection, Setter)`);relationSetters||(relationSetters=[]);for(let relationSetter of relationSetters)if(relationSetter){let relation=relationSetter.Collection,actions=eval(relationSetter.Setter);this[Yb(relation)]=async r=>{Array.isArray(r)?await re(this,De,"f").executeAction(actions,re(this,ht,"f"),r.map(e=>({name:"value",value:e}))):await re(this,De,"f").executeAction(actions,re(this,ht,"f"),[{name:"value",value:r}])}}}};ht=new WeakMap,mt=new WeakMap,De=new WeakMap;function Xb(r,e,t,i){let n="",a=Dm(8);n+=`subject_class("${r}", ${a}).
62
- `;let o=[],s=[];e.subjectConstructor&&e.subjectConstructor.length&&(s=s.concat(e.subjectConstructor));let c=[];e.isSubjectInstance&&e.isSubjectInstance.length&&(c=c.concat(e.isSubjectInstance));let l=[];for(let p in t){let h=`property(${a}, "${p}").
63
- `,{through:m,initial:y,required:b,resolveLanguage:_,writable:S,flag:v,prologGetter:C,prologSetter:$,local:I}=t[p];if(_&&(h+=`property_resolve(${a}, "${p}").
64
- `,h+=`property_resolve_language(${a}, "${p}", "${_}").
65
- `),C?h+=`property_getter(${a}, Base, "${p}", Value) :- ${C}.
66
- `:m&&(h+=`property_getter(${a}, Base, "${p}", Value) :- triple(Base, "${m}", Value).
67
- `,b&&(v?c.push(`triple(Base, "${m}", "${y}")`):c.push(`triple(Base, "${m}", _)`))),$)h+=`property_setter(${a}, "${p}", Actions) :- ${$}.
68
- `;else if(S&&m&&typeof e[jc(p)]=="function"){let N=[{action:"setSingleTarget",source:"this",predicate:m,target:"value",...I&&{local:!0}}];h+=`property_setter(${a}, "${p}", '${ji(N)}').
69
- `}l.push(h);let L=y??(b&&S&&!v&&m?"literal:string:":void 0);L&&(s.push({action:"addLink",source:"this",predicate:m,target:L}),o.push({action:"removeLink",source:"this",predicate:m,target:"*"}))}let u=[],d=Object.fromEntries(Object.entries(i).filter(([,p])=>p.kind==="hasMany"||p.kind==="belongsToMany"));for(let p in d){let h=`collection(${a}, "${p}").
70
- `,{predicate:m,local:y}=d[p];if(m){h+=`collection_getter(${a}, Base, "${p}", List) :- findall(C, triple(Base, "${m}", C), List).
71
- `;let b=[{action:"addLink",source:"this",predicate:m,target:"value",...y&&{local:!0}}],_=[{action:"removeLink",source:"this",predicate:m,target:"value"}],S=[{action:"collectionSetter",source:"this",predicate:m,target:"value",...y&&{local:!0}}];h+=`collection_adder(${a}, "${p}", '${ji(b)}').
72
- `,h+=`collection_remover(${a}, "${p}", '${ji(_)}').
73
- `,h+=`collection_setter(${a}, "${p}", '${ji(S)}').
74
- `}u.push(h)}let f=ji(s);if(n+=`constructor(${a}, '${f}').
75
- `,c.length>0){let p=c.join(", ");n+=`instance(${a}, Base) :- ${p}.
76
- `,n+=`
77
- `}return n+=`destructor(${a}, '${ji(o)}').
78
- `,n+=`
79
- `,n+=l.join(`
80
- `),n+=`
81
- `,n+=u.join(`
82
- `),{sdna:n,name:r}}function sh(r){let e=r.lastIndexOf("#");if(e!==-1)return r.substring(0,e+1);let t=r.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)(.*)$/);if(t){let n=t[2],a=n.lastIndexOf("/");return a!==-1?t[1]+n.substring(0,a+1):t[1]}let i=r.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:)/);return i?i[1]:""}function ch(r){return r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\b/g,"\\b").replace(/\f/g,"\\f")}function lh(r){let e=r.lastIndexOf("#");if(e!==-1)return r.substring(e+1);let t=r.lastIndexOf("/");if(t!==-1&&t<r.length-1)return r.substring(t+1);let i=r.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:(.+)$/);return i?i[1]:r}var ui=class{constructor(e,t){if(t!==void 0)this.nodeShapeUri=e,this.targetClass=t;else{this.targetClass=e;let i=sh(e),n=lh(e);this.nodeShapeUri=`${i}${n}Shape`}this.properties=[],this.parentShapes=[]}addParentShape(e){this.parentShapes.includes(e)||this.parentShapes.push(e)}addProperty(e){this.properties.push(e)}setConstructorActions(e){this.constructor_actions=e}setDestructorActions(e){this.destructor_actions=e}toTurtle(){let e=`@prefix sh: <http://www.w3.org/ns/shacl#> .
83
- `;e+=`@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
84
- `,e+=`@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
85
- `,e+=`@prefix ad4m: <ad4m://> .
86
-
87
- `,e+=`<${this.nodeShapeUri}>
88
- `,e+=` a sh:NodeShape ;
89
- `,this.targetClass&&(e+=` sh:targetClass <${this.targetClass}> ;
90
- `);for(let t of this.parentShapes)e+=` sh:node <${t}> ;
91
- `;for(let t=0;t<this.properties.length;t++){let i=this.properties[t],n=t===this.properties.length-1;e+=` sh:property [
92
- `,e+=` sh:path <${i.path}> ;
93
- `,i.datatype&&(e+=` sh:datatype <${i.datatype}> ;
94
- `),i.nodeKind&&(e+=` sh:nodeKind sh:${i.nodeKind} ;
95
- `),i.minCount!==void 0&&(e+=` sh:minCount ${i.minCount} ;
96
- `),i.maxCount!==void 0&&(e+=` sh:maxCount ${i.maxCount} ;
97
- `),i.pattern&&(e+=` sh:pattern "${ch(i.pattern)}" ;
98
- `),i.minInclusive!==void 0&&(e+=` sh:minInclusive ${i.minInclusive} ;
99
- `),i.maxInclusive!==void 0&&(e+=` sh:maxInclusive ${i.maxInclusive} ;
100
- `),i.hasValue&&(e+=` sh:hasValue "${ch(i.hasValue)}" ;
101
- `),i.local!==void 0&&(e+=` ad4m:local ${i.local} ;
102
- `),i.writable!==void 0&&(e+=` ad4m:writable ${i.writable} ;
103
- `),e=e.slice(0,-2)+`
104
- `,e+=n?` ] .
1
+ var Pn=Object.defineProperty,dl=Object.defineProperties,hl=Object.getOwnPropertyDescriptor,ul=Object.getOwnPropertyDescriptors;var Tn=Object.getOwnPropertySymbols,pl=Object.getPrototypeOf,fl=Object.prototype.hasOwnProperty,gl=Object.prototype.propertyIsEnumerable,ml=Reflect.get;var Ln=(i,t,e)=>t in i?Pn(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,In=(i,t)=>{for(var e in t||={})fl.call(t,e)&&Ln(i,e,t[e]);if(Tn)for(var e of Tn(t))gl.call(t,e)&&Ln(i,e,t[e]);return i},On=(i,t)=>dl(i,ul(t));var C=(i,t,e,r)=>{for(var s=r>1?void 0:r?hl(t,e):t,n=i.length-1,a;n>=0;n--)(a=i[n])&&(s=(r?a(t,e,s):a(s))||s);return r&&s&&Pn(t,e,s),s};var Rn=(i,t,e)=>ml(pl(i),e,t);var L=(i,t,e)=>new Promise((r,s)=>{var n=c=>{try{o(e.next(c))}catch(l){s(l)}},a=c=>{try{o(e.throw(c))}catch(l){s(l)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(n,a);o((e=e.apply(i,t)).next())});var yr="0.13.0-test-4";function br(){return typeof window!="undefined"&&window.self!==window.top}function hs(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(i){return!1}return!0}function ce(i,t){hs()&&localStorage.setItem(`${yr}/${i}`,t)}function bi(i){return hs()?localStorage.getItem(`${yr}/${i}`):null}function Xt(i){hs()&&localStorage.removeItem(`${yr}/${i}`)}function tt(i){return i.replace(/^ws(s?):\/\//,(t,e)=>`http${e}://`)}function it(i,t=1e4){return L(this,null,function*(){let e=new AbortController,r=setTimeout(()=>e.abort(),t);try{let s=yield fetch(`${i}/health`,{signal:e.signal});if(!s.ok)throw new Error(`Health check returned ${s.status}`);let n=yield s.json();if((n==null?void 0:n.status)!=="ok")throw new Error("Not an AD4M executor")}catch(s){throw s.name==="AbortError"?new Error("Connection timed out"):s}finally{clearTimeout(r)}})}function Mn(i){let t=i.trim();if(!t)return"";let e=t.split(/\s+/);return e.length>=2?(e[0][0]+e[1][0]).toUpperCase():t.slice(0,2).toUpperCase()}function Nn(i){let t=0;for(let e=0;e<i.length;e++)t=i.charCodeAt(e)+((t<<5)-t);return(t%360+360)%360}var ct=class extends Error{constructor(t,e){super(`RPC error ${t}: ${e}`),this.name="RpcError",this.status=t,this.body=e}},Un=3e4,yl=3e4,jn=500,bl=0;function vl(){return String(++bl)}var We=class{constructor(t,e){this._ws=null,this._wsCallbacks=new Set,this._pendingCalls=new Map,this._wsReady=null,this._wsReadyResolve=null,this._wsReconnectTimer=null,this._wsReconnectDelay=jn,this._wsClosed=!1,this._wsPingTimer=null,this.baseUrl=t,this.token=e}getBaseUrl(){return this.baseUrl}getToken(){return this.token}setToken(t){this.token=t}_getWsUrl(){let t=this.baseUrl.replace(/^http:\/\//,"ws://").replace(/^https:\/\//,"wss://"),e=this.token?`token=${encodeURIComponent(this.token)}`:"",r="/api/v1/ws";return e?`${t}${r}?${e}`:`${t}${r}`}_ensureWs(){if(this._ws&&(this._ws.readyState===WebSocket.OPEN||this._ws.readyState===WebSocket.CONNECTING)||this._wsReady)return;this._wsClosed=!1,this._wsReady=new Promise(r=>{this._wsReadyResolve=r});let t=this._getWsUrl(),e=new WebSocket(t);this._ws=e,e.onopen=()=>{this._wsReconnectDelay=jn,this._wsReadyResolve&&(this._wsReadyResolve(),this._wsReadyResolve=null),this._startPing()},e.onmessage=r=>{let s;try{s=JSON.parse(r.data)}catch(a){console.error("Error parsing WebSocket data:",a);return}if(s.type==="pong")return;let n=s.id;if(n&&this._pendingCalls.has(n)){let a=this._pendingCalls.get(n);if(this._pendingCalls.delete(n),clearTimeout(a.timer),s.error){let o=s.error;a.reject(new ct(o.code??500,o.message??"Unknown error"))}else a.resolve(s.result);return}for(let a of this._wsCallbacks)a(s)},e.onerror=r=>{console.error("WebSocket error:",r)},e.onclose=()=>{this._stopPing(),this._ws=null,this._wsReady=null;for(let[r,s]of this._pendingCalls)clearTimeout(s.timer),s.reject(new ct(503,"WebSocket connection closed"));this._pendingCalls.clear(),!this._wsClosed&&(this._wsCallbacks.size>0||this._pendingCalls.size>0)&&this._scheduleReconnect()}}_startPing(){this._stopPing(),this._wsPingTimer=setInterval(()=>{this._ws&&this._ws.readyState===WebSocket.OPEN&&this._ws.send(JSON.stringify({type:"ping"}))},3e4)}_stopPing(){this._wsPingTimer&&(clearInterval(this._wsPingTimer),this._wsPingTimer=null)}_scheduleReconnect(){if(this._wsReconnectTimer)return;let t=this._wsReconnectDelay;this._wsReconnectDelay=Math.min(this._wsReconnectDelay*2,yl),this._wsReconnectTimer=setTimeout(()=>{this._wsReconnectTimer=null,this._wsClosed||this._ensureWs()},t)}async _ready(){this._ensureWs(),this._wsReady&&await this._wsReady}async call(t,e){await this._ready();let r=vl(),s={id:r,type:t,params:e||{}};return new Promise((n,a)=>{let o=setTimeout(()=>{this._pendingCalls.delete(r),a(new ct(408,`RPC call '${t}' timed out after ${Un}ms`))},Un);this._pendingCalls.set(r,{resolve:n,reject:a,timer:o}),this._ws&&this._ws.readyState===WebSocket.OPEN?this._ws.send(JSON.stringify(s)):(this._pendingCalls.delete(r),clearTimeout(o),a(new ct(503,"WebSocket not connected")))})}subscribe(t){return this._wsCallbacks.add(t),this._ensureWs(),()=>{this._wsCallbacks.delete(t),this._wsCallbacks.size===0&&this._pendingCalls.size===0&&this._closeWs()}}async waitForSubscription(){await this._ready()}connect(){this._ensureWs()}_closeWs(){this._stopPing(),this._wsReconnectTimer&&(clearTimeout(this._wsReconnectTimer),this._wsReconnectTimer=null),this._ws&&(this._wsClosed=!0,this._ws.close(),this._ws=null,this._wsReady=null)}closeAll(){for(let[t,e]of this._pendingCalls)clearTimeout(e.timer),e.reject(new ct(503,"Client closed"));this._pendingCalls.clear(),this._closeWs(),this._wsCallbacks.clear()}};function wt(i){class t{constructor(r,s,n,a){this.author=r,this.timestamp=s,this.data=n,this.proof=a}}return t}function _l(i){class t{}return t}var Dn=class extends wt(){},zn=class extends wt(){};var As=class{constructor(t){t?this.links=t:this.links=[]}get(t){if(!t||!t.source&&!t.predicate&&!t.target)return this.links;if(t.source){let r=JSON.parse(JSON.stringify(this.links));return t.target&&(r=r.filter(s=>s.data.target===t.target)),t.predicate&&(r=r.filter(s=>s.data.predicate===t.predicate)),t.fromDate&&(r=r.filter(s=>new Date(s.timestamp)>=t.fromDate)),t.untilDate&&(r=r.filter(s=>new Date(s.timestamp)<=t.untilDate)),t.limit&&(r=r.slice(0,t.limit)),r}if(t.target){let r=JSON.parse(JSON.stringify(this.links));return t.predicate&&(r=r.filter(s=>s.data.predicate===t.predicate)),t.fromDate&&(r=r.filter(s=>new Date(s.timestamp)>=t.fromDate)),t.untilDate&&(r=r.filter(s=>new Date(s.timestamp)<=t.untilDate)),t.limit&&(r=r.slice(0,t.limit)),r}let e=JSON.parse(JSON.stringify(this.links));return e=e.filter(r=>r.data.predicate===t.predicate),t.limit&&(e=e.slice(0,t.limit)),e}getSingleTarget(t){delete t.target;let e=this.get(t);return e.length?e[0].data.target:null}};var Hn=class extends wt(){},Vi=class{constructor(t,e){this.did=t,e?this.perspective=e:this.perspective=new As}},Fn=class extends wt(){};var Es=class{constructor(t,e,r,s=!1){this.email=t,this.remainingCredits=e,this.hotWalletAddress=r,this.freeAccess=s}};var Rt=class{constructor(t){t?(this.isInitialized=t.isInitialized,this.isInitialized||(this.isInitialized=!1),this.isUnlocked=t.isUnlocked,this.isUnlocked||(this.isUnlocked=!1),this.did=t.did,this.didDocument=t.didDocument,this.error=t.error):(this.isInitialized=!1,this.isUnlocked=!1)}},Wn=function(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e},G=function(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)},me,we,Ts=class{constructor(t,e){me.set(this,void 0),we.set(this,void 0),Wn(this,me,t,"f"),Wn(this,we,e,"f")}async otherAgents(){return await G(this,me,"f").otherAgents(G(this,we,"f"))}async hasTelepresenceAdapter(){return await G(this,me,"f").hasTelepresenceAdapter(G(this,we,"f"))}async onlineAgents(){return await G(this,me,"f").onlineAgents(G(this,we,"f"))}async setOnlineStatus(t){return await G(this,me,"f").setOnlineStatus(G(this,we,"f"),t)}async setOnlineStatusU(t){return await G(this,me,"f").setOnlineStatusU(G(this,we,"f"),t)}async sendSignal(t,e){return await G(this,me,"f").sendSignal(G(this,we,"f"),t,e)}async sendSignalU(t,e){return await G(this,me,"f").sendSignalU(G(this,we,"f"),t,e)}async sendBroadcast(t,e=!1){return await G(this,me,"f").sendBroadcast(G(this,we,"f"),t,e)}async sendBroadcastU(t,e=!1){return await G(this,me,"f").sendBroadcastU(G(this,we,"f"),t,e)}async addSignalHandler(t){await G(this,me,"f").addSignalHandler(G(this,we,"f"),t)}removeSignalHandler(t){G(this,me,"f").removeSignalHandler(G(this,we,"f"),t)}};me=new WeakMap,we=new WeakMap;var Re=class{constructor(t){this.source=t.source?t.source:"",this.target=t.target?t.target:"",this.predicate=t.predicate?t.predicate:""}};var Bn=class extends wt(){hash(){let t=JSON.stringify(this.data,Object.keys(this.data).sort())+JSON.stringify(this.author)+this.timestamp,e=0,r,s;for(r=0;r<t.length;r++)s=t.charCodeAt(r),e=(e<<5)-e+s,e|=0;return e}},qn=class extends _l(){};var Q=class{constructor(t){t&&(this.source=t.source,this.predicate=t.predicate,this.target=t.target,t.fromDate&&(this.fromDate=t.fromDate),t.untilDate&&(this.untilDate=t.untilDate),t.limit&&(this.limit=t.limit))}isMatch(t){return!(this.source&&this.source!==t.source||this.predicate&&this.predicate!==t.predicate||this.target&&this.target!==t.target)}},Zn=function(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e},oe=function(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)},ye,Ve;function vr(i){return encodeURIComponent(i).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`)}var K=class{constructor(){ye.set(this,void 0),Ve.set(this,void 0)}static fromUrl(t){if(!t||!t.startsWith("literal:"))throw new Error("Can't create Literal from non-literal URL");if(t.startsWith("literal://"))throw new Error("literal:// format is no longer supported. Use literal: instead.");let e=new K;return Zn(e,Ve,t,"f"),e}static from(t){let e=new K;return Zn(e,ye,t,"f"),e}toUrl(){if(oe(this,Ve,"f")&&!oe(this,ye,"f"))return oe(this,Ve,"f");if(!oe(this,Ve,"f")&&(oe(this,ye,"f")===void 0||oe(this,ye,"f")===""||oe(this,ye,"f")===null))throw new Error("Can't turn empty Literal into URL");let t;switch(typeof oe(this,ye,"f")){case"string":t=`string:${vr(oe(this,ye,"f"))}`;break;case"number":t=`number:${vr(oe(this,ye,"f"))}`;break;case"boolean":t=`boolean:${vr(oe(this,ye,"f"))}`;break;case"object":t=`json:${vr(JSON.stringify(oe(this,ye,"f")))}`;break}return`literal:${t}`}get(){if(oe(this,ye,"f"))return oe(this,ye,"f");if(!oe(this,Ve,"f"))throw new Error("Can't render empty Literal");if(!oe(this,Ve,"f").startsWith("literal:"))throw new Error("Can't render Literal from non-literal URL");let t=oe(this,Ve,"f").substring(8);if(t.startsWith("string:"))return decodeURIComponent(t.substring(7));if(t.startsWith("number:")){let e=t.substring(7);return parseFloat(e)}if(t.startsWith("json:")){let e=t.substring(5);return JSON.parse(decodeURIComponent(e))}throw new Error(`Can't parse unknown literal: ${t}`)}};ye=new WeakMap,Ve=new WeakMap;function Ar(i){return i.charAt(0).toUpperCase()+i.slice(1)}function en(i){return`set${Ar(i)}`}function Ka(i){let t="",e="abcdefghijklmnopqrstuvwxyz",r=e.length;for(let s=0;s<i;s++)t+=e.charAt(Math.floor(Math.random()*r));return t}function St(i){if(Array.isArray(i))return`[${i.map(St).join(", ")}]`;let t=Object.keys(i),e=[];for(let r of t){let s=JSON.stringify(i[r]),n=`${r}: ${s}`;e.push(n)}return`{${e.join(", ")}}`}function xl(i,t,e,r){let s="",n=Ka(8);s+=`subject_class("${i}", ${n}).
2
+ `;let a=[],o=[];t.subjectConstructor&&t.subjectConstructor.length&&(o=o.concat(t.subjectConstructor));let c=[];t.isSubjectInstance&&t.isSubjectInstance.length&&(c=c.concat(t.isSubjectInstance));let l=[];for(let h in e){let u=`property(${n}, "${h}").
3
+ `,{through:f,initial:w,required:v,resolveLanguage:x,writable:S,flag:_,prologGetter:P,prologSetter:R,local:k}=e[h];if(x&&(u+=`property_resolve(${n}, "${h}").
4
+ `,u+=`property_resolve_language(${n}, "${h}", "${x}").
5
+ `),P?u+=`property_getter(${n}, Base, "${h}", Value) :- ${P}.
6
+ `:f&&(u+=`property_getter(${n}, Base, "${h}", Value) :- triple(Base, "${f}", Value).
7
+ `,v&&(_?c.push(`triple(Base, "${f}", "${w}")`):c.push(`triple(Base, "${f}", _)`))),R)u+=`property_setter(${n}, "${h}", Actions) :- ${R}.
8
+ `;else if(S&&f&&typeof t[en(h)]=="function"){let A=[{action:"setSingleTarget",source:"this",predicate:f,target:"value",...k&&{local:!0}}];u+=`property_setter(${n}, "${h}", '${St(A)}').
9
+ `}l.push(u);let M=w??(v&&S&&!_&&f?"literal:string:":void 0);M&&(o.push({action:"addLink",source:"this",predicate:f,target:M}),a.push({action:"removeLink",source:"this",predicate:f,target:"*"}))}let d=[],g=Object.fromEntries(Object.entries(r).filter(([,h])=>h.kind==="hasMany"||h.kind==="belongsToMany"));for(let h in g){let u=`collection(${n}, "${h}").
10
+ `,{predicate:f,local:w}=g[h];if(f){u+=`collection_getter(${n}, Base, "${h}", List) :- findall(C, triple(Base, "${f}", C), List).
11
+ `;let v=[{action:"addLink",source:"this",predicate:f,target:"value",...w&&{local:!0}}],x=[{action:"removeLink",source:"this",predicate:f,target:"value"}],S=[{action:"collectionSetter",source:"this",predicate:f,target:"value",...w&&{local:!0}}];u+=`collection_adder(${n}, "${h}", '${St(v)}').
12
+ `,u+=`collection_remover(${n}, "${h}", '${St(x)}').
13
+ `,u+=`collection_setter(${n}, "${h}", '${St(S)}').
14
+ `}d.push(u)}let p=St(o);if(s+=`constructor(${n}, '${p}').
15
+ `,c.length>0){let h=c.join(", ");s+=`instance(${n}, Base) :- ${h}.
16
+ `,s+=`
17
+ `}return s+=`destructor(${n}, '${St(a)}').
18
+ `,s+=`
19
+ `,s+=l.join(`
20
+ `),s+=`
21
+ `,s+=d.join(`
22
+ `),{sdna:s,name:i}}function Vn(i){let t=i.lastIndexOf("#");if(t!==-1)return i.substring(0,t+1);let e=i.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)(.*)$/);if(e){let s=e[2],n=s.lastIndexOf("/");return n!==-1?e[1]+s.substring(0,n+1):e[1]}let r=i.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:)/);return r?r[1]:""}function Jn(i){return i.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\b/g,"\\b").replace(/\f/g,"\\f")}function Qn(i){let t=i.lastIndexOf("#");if(t!==-1)return i.substring(t+1);let e=i.lastIndexOf("/");if(e!==-1&&e<i.length-1)return i.substring(e+1);let r=i.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:(.+)$/);return r?r[1]:i}var ut=class{constructor(t,e){if(e!==void 0)this.nodeShapeUri=t,this.targetClass=e;else{this.targetClass=t;let r=Vn(t),s=Qn(t);this.nodeShapeUri=`${r}${s}Shape`}this.properties=[],this.parentShapes=[]}addParentShape(t){this.parentShapes.includes(t)||this.parentShapes.push(t)}addProperty(t){this.properties.push(t)}setConstructorActions(t){this.constructor_actions=t}setDestructorActions(t){this.destructor_actions=t}toTurtle(){let t=`@prefix sh: <http://www.w3.org/ns/shacl#> .
23
+ `;t+=`@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
24
+ `,t+=`@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
25
+ `,t+=`@prefix ad4m: <ad4m://> .
26
+
27
+ `,t+=`<${this.nodeShapeUri}>
28
+ `,t+=` a sh:NodeShape ;
29
+ `,this.targetClass&&(t+=` sh:targetClass <${this.targetClass}> ;
30
+ `);for(let e of this.parentShapes)t+=` sh:node <${e}> ;
31
+ `;for(let e=0;e<this.properties.length;e++){let r=this.properties[e],s=e===this.properties.length-1;t+=` sh:property [
32
+ `,t+=` sh:path <${r.path}> ;
33
+ `,r.datatype&&(t+=` sh:datatype <${r.datatype}> ;
34
+ `),r.nodeKind&&(t+=` sh:nodeKind sh:${r.nodeKind} ;
35
+ `),r.minCount!==void 0&&(t+=` sh:minCount ${r.minCount} ;
36
+ `),r.maxCount!==void 0&&(t+=` sh:maxCount ${r.maxCount} ;
37
+ `),r.pattern&&(t+=` sh:pattern "${Jn(r.pattern)}" ;
38
+ `),r.minInclusive!==void 0&&(t+=` sh:minInclusive ${r.minInclusive} ;
39
+ `),r.maxInclusive!==void 0&&(t+=` sh:maxInclusive ${r.maxInclusive} ;
40
+ `),r.hasValue&&(t+=` sh:hasValue "${Jn(r.hasValue)}" ;
41
+ `),r.local!==void 0&&(t+=` ad4m:local ${r.local} ;
42
+ `),r.writable!==void 0&&(t+=` ad4m:writable ${r.writable} ;
43
+ `),t=t.slice(0,-2)+`
44
+ `,t+=s?` ] .
105
45
  `:` ] ;
106
- `}return e}toLinks(){let e=[];e.push({source:this.nodeShapeUri,predicate:"rdf://type",target:"sh://NodeShape"}),this.targetClass&&e.push({source:this.nodeShapeUri,predicate:"sh://targetClass",target:this.targetClass}),this.constructor_actions&&e.push({source:this.nodeShapeUri,predicate:"ad4m://constructor",target:`literal:string:${JSON.stringify(this.constructor_actions)}`}),this.destructor_actions&&e.push({source:this.nodeShapeUri,predicate:"ad4m://destructor",target:`literal:string:${JSON.stringify(this.destructor_actions)}`});for(let t=0;t<this.properties.length;t++){let i=this.properties[t],n;if(i.name&&this.targetClass){let a=sh(this.targetClass),o=lh(this.targetClass);n=`${a}${o}.${i.name}`}else n=`_:propShape${t}`;e.push({source:this.nodeShapeUri,predicate:"sh://property",target:n}),e.push({source:n,predicate:"sh://path",target:i.path}),i.datatype&&e.push({source:n,predicate:"sh://datatype",target:i.datatype}),i.nodeKind&&e.push({source:n,predicate:"sh://nodeKind",target:`sh://${i.nodeKind}`}),i.minCount!==void 0&&e.push({source:n,predicate:"sh://minCount",target:`literal:${i.minCount}^^xsd:integer`}),i.maxCount!==void 0&&e.push({source:n,predicate:"sh://maxCount",target:`literal:${i.maxCount}^^xsd:integer`}),i.pattern&&e.push({source:n,predicate:"sh://pattern",target:`literal:${i.pattern}`}),i.minInclusive!==void 0&&e.push({source:n,predicate:"sh://minInclusive",target:`literal:${i.minInclusive}`}),i.maxInclusive!==void 0&&e.push({source:n,predicate:"sh://maxInclusive",target:`literal:${i.maxInclusive}`}),i.hasValue&&e.push({source:n,predicate:"sh://hasValue",target:`literal:${i.hasValue}`}),i.local!==void 0&&e.push({source:n,predicate:"ad4m://local",target:`literal:${i.local}`}),i.writable!==void 0&&e.push({source:n,predicate:"ad4m://writable",target:`literal:${i.writable}`}),i.resolveLanguage&&e.push({source:n,predicate:"ad4m://resolveLanguage",target:`literal:string:${i.resolveLanguage}`}),i.setter&&i.setter.length>0&&e.push({source:n,predicate:"ad4m://setter",target:`literal:string:${JSON.stringify(i.setter)}`}),i.adder&&i.adder.length>0&&e.push({source:n,predicate:"ad4m://adder",target:`literal:string:${JSON.stringify(i.adder)}`}),i.remover&&i.remover.length>0&&e.push({source:n,predicate:"ad4m://remover",target:`literal:string:${JSON.stringify(i.remover)}`}),i.getter&&e.push({source:n,predicate:"ad4m://getter",target:`literal:string:${i.getter}`}),i.conformanceConditions&&i.conformanceConditions.length>0&&e.push({source:n,predicate:"ad4m://conformanceConditions",target:`literal:string:${JSON.stringify(i.conformanceConditions)}`}),i.class&&e.push({source:n,predicate:"sh://class",target:i.class})}return e}static fromLinks(e,t){let i=e.find(c=>c.source===t&&c.predicate==="sh://targetClass"),n=new ui(t,i?.target),a=e.find(c=>c.source===t&&c.predicate==="ad4m://constructor");if(a)try{let c=a.target.replace(/^literal:\/\/string:|^literal:string:/,"");n.constructor_actions=JSON.parse(c)}catch{}let o=e.find(c=>c.source===t&&c.predicate==="ad4m://destructor");if(o)try{let c=o.target.replace(/^literal:\/\/string:|^literal:string:/,"");n.destructor_actions=JSON.parse(c)}catch{}let s=e.filter(c=>c.source===t&&c.predicate==="sh://property");for(let c of s){let l=c.target,u=e.find(T=>T.source===l&&T.predicate==="sh://path");if(!u)continue;let d;if(!l.startsWith("_:")){let T=l.lastIndexOf(".");T!==-1&&(d=l.substring(T+1))}let f={name:d,path:u.target},p=e.find(T=>T.source===l&&T.predicate==="sh://datatype");p&&(f.datatype=p.target);let h=e.find(T=>T.source===l&&T.predicate==="sh://nodeKind");h&&(f.nodeKind=h.target.replace("sh://",""));let m=e.find(T=>T.source===l&&T.predicate==="sh://minCount");if(m){let T=m.target.replace(/^literal:\/\/|^literal:/,"").replace(/\^\^.*$/,"");T.startsWith("number:")&&(T=T.substring(7)),f.minCount=parseInt(T)}let y=e.find(T=>T.source===l&&T.predicate==="sh://maxCount");if(y){let T=y.target.replace(/^literal:\/\/|^literal:/,"").replace(/\^\^.*$/,"");T.startsWith("number:")&&(T=T.substring(7)),f.maxCount=parseInt(T)}let b=e.find(T=>T.source===l&&T.predicate==="sh://pattern");b&&(f.pattern=b.target.replace(/^literal:\/\/|^literal:/,""));let _=e.find(T=>T.source===l&&T.predicate==="sh://minInclusive");if(_){let T=_.target.replace(/^literal:\/\/|^literal:/,"");T.startsWith("number:")&&(T=T.substring(7)),f.minInclusive=parseFloat(T)}let S=e.find(T=>T.source===l&&T.predicate==="sh://maxInclusive");if(S){let T=S.target.replace(/^literal:\/\/|^literal:/,"");T.startsWith("number:")&&(T=T.substring(7)),f.maxInclusive=parseFloat(T)}let v=e.find(T=>T.source===l&&T.predicate==="sh://hasValue");v&&(f.hasValue=v.target.replace(/^literal:\/\/|^literal:/,""));let C=e.find(T=>T.source===l&&T.predicate==="ad4m://local");if(C){let T=C.target.replace(/^literal:\/\/|^literal:/,"");T.startsWith("boolean:")&&(T=T.substring(8)),f.local=T==="true"}let $=e.find(T=>T.source===l&&T.predicate==="ad4m://writable");if($){let T=$.target.replace(/^literal:\/\/|^literal:/,"");T.startsWith("boolean:")&&(T=T.substring(8)),f.writable=T==="true"}let I=e.find(T=>T.source===l&&T.predicate==="ad4m://resolveLanguage");I&&(f.resolveLanguage=I.target.replace(/^literal:\/\/string:|^literal:string:/,""));let L=e.find(T=>T.source===l&&T.predicate==="ad4m://setter");if(L)try{let T=L.target.replace(/^literal:\/\/string:|^literal:string:/,"");f.setter=JSON.parse(T)}catch{}let M=e.find(T=>T.source===l&&T.predicate==="ad4m://adder");if(M)try{let T=M.target.replace(/^literal:\/\/string:|^literal:string:/,"");f.adder=JSON.parse(T)}catch{}let N=e.find(T=>T.source===l&&T.predicate==="ad4m://remover");if(N)try{let T=N.target.replace(/^literal:\/\/string:|^literal:string:/,"");f.remover=JSON.parse(T)}catch{}let W=e.find(T=>T.source===l&&T.predicate==="ad4m://getter");W&&(f.getter=W.target.replace(/^literal:\/\/string:|^literal:string:/,""));let Ie=e.find(T=>T.source===l&&T.predicate==="ad4m://conformanceConditions");if(Ie)try{let T=Ie.target.replace(/^literal:\/\/string:|^literal:string:/,"");f.conformanceConditions=JSON.parse(T)}catch{}let Oe=e.find(T=>T.source===l&&T.predicate==="sh://class");Oe&&(f.class=Oe.target),n.addProperty(f)}return n}toJSON(){return{node_shape_uri:this.nodeShapeUri,target_class:this.targetClass,parent_shapes:this.parentShapes.length>0?this.parentShapes:void 0,properties:this.properties.map(e=>({path:e.path,name:e.name,datatype:e.datatype,node_kind:e.nodeKind,min_count:e.minCount,max_count:e.maxCount,min_inclusive:e.minInclusive,max_inclusive:e.maxInclusive,pattern:e.pattern,has_value:e.hasValue,local:e.local,writable:e.writable,resolve_language:e.resolveLanguage,setter:e.setter,adder:e.adder,remover:e.remover,getter:e.getter,conformance_conditions:e.conformanceConditions,class:e.class})),constructor_actions:this.constructor_actions,destructor_actions:this.destructor_actions}}static fromJSON(e){let t=e.node_shape_uri?new ui(e.node_shape_uri,e.target_class):new ui(e.target_class);for(let i of e.properties||[])t.addProperty({path:i.path,name:i.name,datatype:i.datatype,nodeKind:i.node_kind,minCount:i.min_count,maxCount:i.max_count,minInclusive:i.min_inclusive,maxInclusive:i.max_inclusive,pattern:i.pattern,hasValue:i.has_value,local:i.local,writable:i.writable,resolveLanguage:i.resolve_language,setter:i.setter,adder:i.adder,remover:i.remover,getter:i.getter,conformanceConditions:i.conformance_conditions,class:i.class});if(e.constructor_actions&&(t.constructor_actions=e.constructor_actions),e.destructor_actions&&(t.destructor_actions=e.destructor_actions),e.parent_shapes)for(let i of e.parent_shapes)t.addParentShape(i);return t}};function uh(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 Fm(r){let e=r.can.includes("*")?["READ","WRITE","UPDATE"]:r.can,t=r.with.domain==="*"?"":r.with.domain,i=r.with.pointers.includes("*")?["all AD4M data"]:r.with.pointers;return`${uh(e)} your ${t} actions, with access to ${uh(i)}`}function Lr(r){return r.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function e0(r){return typeof r=="string"?`'${r.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`:typeof r=="number"||typeof r=="boolean"?String(r):Array.isArray(r)?`[${r.map(e=>e0(e)).join(", ")}]`:String(r)}function t0(r,e,t){let i=Lr(r),n=!t?.resolveLanguage||t.resolveLanguage==="literal";function a(o){return typeof o=="string"?n?`<literal:string:${Lr(o)}>`:`<${Lr(o)}>`:`<literal:string:${o}>`}if(Array.isArray(e)){let o=e.map(a).join(", ");return`FILTER EXISTS { ?target <${i}> ?_val . FILTER(?_val IN (${o})) }`}else if(typeof e=="object"&&e!==null){let o=e,s=[];if(o.not!==void 0)if(Array.isArray(o.not)){let l=o.not.map(u=>a(u)).join(", ");s.push(`FILTER NOT EXISTS { ?target <${i}> ?_nval . FILTER(?_nval IN (${l})) }`)}else s.push(`FILTER NOT EXISTS { ?target <${i}> ${a(o.not)} }`);return(o.gt!==void 0||o.gte!==void 0||o.lt!==void 0||o.lte!==void 0||o.between!==void 0||o.contains!==void 0)&&s.push(`FILTER EXISTS { ?target <${i}> ?_cmp }`),s.join(" ")}else return`?target <${i}> ${a(e)} .`}function Mm(r,e){let t=[];for(let[i,n]of Object.entries(r)){if(["id","author","timestamp"].includes(i))continue;let a,o;if(e){let c=e.properties[i];c?(a=c.predicate,o=c.resolveLanguage):a=i}else a=i;let s=t0(a,n,{resolveLanguage:o});s&&t.push(s)}return t}function r0(r,e,t,i,n){let a=e.prototype,o="ad4m://",s=Object.fromEntries(Object.entries(i).filter(([,h])=>h.kind==="hasMany"||h.kind==="belongsToMany"));if(Object.keys(t).length>0){let h=t[Object.keys(t)[0]];if(h.through){let m=h.through.match(/^([^:]+:\/\/)/);m&&(o=m[1])}}else if(Object.keys(s).length>0){let h=s[Object.keys(s)[0]];if(h.predicate){let m=h.predicate.match(/^([^:]+:\/\/)/);m&&(o=m[1])}}let c=`${o}${r}Shape`,l=`${o}${r}`,u=new ui(c,l),d=Object.getPrototypeOf(e);if(d&&typeof d.generateSHACL=="function"){let h=d.generateSHACL();h?.shape?.nodeShapeUri&&u.addParentShape(h.shape.nodeShapeUri)}let f=[];a.subjectConstructor&&a.subjectConstructor.length&&(f=f.concat(a.subjectConstructor));let p=[];for(let h in t){let m=t[h];if(!m.through)continue;let y={name:h,path:m.through};if(m.resolveLanguage==="literal")y.datatype="xsd://string";else if(m.initial){let _=typeof a[h];_==="number"?y.datatype="xsd://integer":_==="boolean"?y.datatype="xsd://boolean":_==="string"&&(y.datatype="xsd://string")}m.required&&(y.minCount=1),y.maxCount=1,m.flag&&m.initial&&(y.hasValue=m.initial),m.local!==void 0&&(y.local=m.local),m.writable!==void 0&&(y.writable=m.writable),m.resolveLanguage&&(y.resolveLanguage=m.resolveLanguage),m.prologSetter?console.warn(`[SHACL Generation] Custom Prolog setter for property '${h}' in class '${r}' is not yet supported. The property will be created without setter actions. Consider using standard writable properties or provide explicit SHACL JSON.`):m.writable&&m.through&&typeof a[jc(h)]=="function"&&(y.setter=[{action:"setSingleTarget",source:"this",predicate:m.through,target:"value",...m.local&&{local:!0}}]);let b=m.initial??(m.required&&m.writable&&!m.flag&&m.through?"literal:string:":void 0);b&&(f.push({action:"addLink",source:"this",predicate:m.through,target:b}),p.push({action:"removeLink",source:"this",predicate:m.through,target:"*"})),u.addProperty(y)}for(let h in s){let m=s[h];if(!m.predicate)continue;let y={name:h,path:m.predicate};if(y.nodeKind="IRI",m.local!==void 0&&(y.local=m.local),y.adder=[{action:"addLink",source:"this",predicate:m.predicate,target:"value",...m.local&&{local:!0}}],y.remover=[{action:"removeLink",source:"this",predicate:m.predicate,target:"value",...m.local&&{local:!0}}],m.getter)y.getter=m.getter;else if(m.where)try{let b=m.target?.(),_=b?b.getModelMetadata?.()??null:null,S=Mm(m.where,_);if(S.length>0){let v=Lr(m.predicate);y.getter=`SELECT ?target WHERE { <Base> <${v}> ?target . ${S.join(" ")} }`}}catch{}else if(m.target&&m.filter!==!1){let b=m.target,_=m.predicate,S=!1,v,C,$=()=>{if(!S){S=!0;try{let I=b(),L=n(_,I);L&&(v=L.getter,C=L.conformanceConditions)}catch{}}};Object.defineProperty(y,"getter",{get(){return $(),v},set(I){S=!0,v=I},enumerable:!0,configurable:!0}),Object.defineProperty(y,"conformanceConditions",{get(){return $(),C},set(I){S=!0,C=I},enumerable:!0,configurable:!0})}if(m.target)try{let _=m.target().generateSHACL?.();_?.shape?.nodeShapeUri&&(y.class=_.shape.nodeShapeUri)}catch{}u.addProperty(y)}return u.setConstructorActions(f),u.setDestructorActions(p),{shape:u,name:r}}var vr=new WeakMap,lt=new WeakMap,ph=new WeakMap,dh=new WeakMap,fh=new WeakMap;function sn(r){let e=ph.get(r);if(e)return e;let t={},i=[],n=r;for(;n&&n!==Object;)i.unshift(n),n=Object.getPrototypeOf(n);for(let a of i){let o=vr.get(a);o&&Object.assign(t,o)}return ph.set(r,t),t}function hr(r){let e=dh.get(r);if(e)return e;let t={},i=[],n=r;for(;n&&n!==Object;)i.unshift(n),n=Object.getPrototypeOf(n);for(let a of i){let o=lt.get(a);o&&Object.assign(t,o)}return dh.set(r,t),t}function i0(r,e){let t=fh.get(r);if(t)return t;let i=e();return fh.set(r,i),i}function n0(r,e,t){vr.has(r)||vr.set(r,{}),vr.get(r)[e]=t}function a0(r,e,t){lt.has(r)||lt.set(r,{}),lt.get(r)[e]=t}function Um(r,e){try{let t=sn(e),i=[],n=[],a=0;for(let[s,c]of Object.entries(t))c.flag&&c.initial&&c.through&&(i.push({type:"flag",predicate:c.through,value:c.initial}),n.push(`?target <${Lr(c.through)}> <${Lr(c.initial)}> .`));for(let[s,c]of Object.entries(t))c.required&&!c.flag&&!c.getter&&c.through&&(i.push({type:"required",predicate:c.through}),n.push(`?target <${Lr(c.through)}> ?_v${a++} .`));return i.length===0?void 0:{getter:`SELECT ?target WHERE { <Base> <${Lr(r)}> ?target . ${n.join(" ")} }`,conformanceConditions:i}}catch{return}}function qc(r){return function(e,t){let i=r.readOnly?!1:!!r.through;if(r.required&&!r.initial)throw new Error("SubjectProperty requires an 'initial' option if 'required' is true");if(!r.through&&!r.prologGetter&&!r.getter)throw new Error("SubjectProperty requires either 'through' or 'prologGetter' or 'getter' option");let n=e.constructor;if(vr.has(n)||vr.set(n,{}),vr.get(n)[t]={...r,writable:i},i){let a=t;e[`set${vt(a)}`]=()=>{}}Object.defineProperty(e,t,{configurable:!0,writable:!0})}}function yO(r){return qc({...r,required:r.required??!1,readOnly:r.readOnly??!1})}function vO(r){return function(e,t){if(!r.through&&!r.value)throw new Error("SubjectFlag requires a 'through' and 'value' option");if(!r.through)throw new Error("SubjectFlag requires a 'through' option");if(!r.value)throw new Error("SubjectFlag requires a 'value' option");let i={through:r.through,required:!0,initial:r.value,flag:!0,readOnly:!0,writable:!1},n=e.constructor;vr.has(n)||vr.set(n,{}),vr.get(n)[t]=i,e[t]=r.value,Object.defineProperty(e,t,{configurable:!0,writable:!0})}}function o0(r){return function(e){e.prototype.className=r.name,e.className=r.name,e.generateSDNA=function(){return Xb(r.name,e.prototype,sn(e),hr(e))},e.generateSHACL=function(){return i0(e,()=>r0(r.name,e,sn(e),hr(e),Um))},Object.defineProperty(e,"type",{configurable:!0})}}function s0(r){let e=r.required??!1;return qc({...r,required:e,readOnly:r.readOnly??!1,resolveLanguage:r.resolveLanguage??"literal",initial:r.initial??(e?"literal:string:uninitialized":void 0)})}function bO(r){return s0({...r,readOnly:!0})}function Bc(r,e){let t=typeof r=="function"?{...e||{},target:r}:r;if(t.getter){if(t.through)throw new Error("Relation decorator: `getter` and `through` are mutually exclusive. Use `getter` alone for custom read-only relations, or `through` (with optional `target`) for standard link-based relations.");if(t.target)throw new Error("Relation decorator: `getter` and `target` are mutually exclusive. `target` auto-generates a conformance getter from the model shape; providing both is contradictory.");if(t.where)throw new Error("Relation decorator: `where` and `getter` are mutually exclusive. Use `where` for DSL-based filtering, or `getter` for raw getter expression.");return t}if(t.through||(t.through="ad4m://has_child"),t.where&&t.filter===!1)throw new Error("Relation decorator: `where` and `filter: false` are contradictory. `where` adds filtering constraints; `filter: false` disables filtering.");return t}function wO(r,e){let t=Bc(r,e);return function(i,n){let a=i.constructor;lt.has(a)||lt.set(a,{});let o=lt.get(a);o[n]={predicate:t.through,target:t.target,kind:"hasMany",local:t.local,...t.getter&&{getter:t.getter},...t.filter!==void 0&&{filter:t.filter},...t.where&&{where:t.where}};let s=n;t.through&&(i[`add${vt(s)}`]=async function(c,l){return this.addRelationValue(s,c,l)},i[`remove${vt(s)}`]=async function(c,l){return this.removeRelationValue(s,c,l)},i[`set${vt(s)}`]=async function(c,l){return this.setRelationValues(s,c,l)}),Object.defineProperty(i,s,{configurable:!0,writable:!0})}}function SO(r,e){let t=Bc(r,e);return function(i,n){let a=i.constructor;lt.has(a)||lt.set(a,{});let o=lt.get(a);o[n]={predicate:t.through,target:t.target,kind:"hasOne",maxCount:1,local:t.local,...t.filter!==void 0&&{filter:t.filter},...t.where&&{where:t.where}};let s=n;t.through?(qc({through:t.through,readOnly:!1,local:t.local})(i,n),i[`add${vt(s)}`]=async function(c){return this.addRelationValue(s,c)},i[`remove${vt(s)}`]=async function(c){return this.removeRelationValue(s,c)},i[`set${vt(s)}`]=async function(c){return this.setRelationValues(s,c)}):Object.defineProperty(i,s,{configurable:!0,writable:!0})}}function _O(r,e){let t=Bc(r,e);return function(i,n){let a=i.constructor;lt.has(a)||lt.set(a,{});let o=lt.get(a);o[n]={predicate:t.through,target:t.target,kind:"belongsToOne",maxCount:1,local:t.local,...t.filter!==void 0&&{filter:t.filter},...t.where&&{where:t.where}},t.through?qc({through:t.through,readOnly:!0,local:t.local})(i,n):Object.defineProperty(i,n,{configurable:!0,writable:!0})}}function xO(r,e){let t=Bc(r,e);return function(i,n){let a=i.constructor;lt.has(a)||lt.set(a,{});let o=lt.get(a);o[n]={predicate:t.through,target:t.target,kind:"belongsToMany",local:t.local,...t.getter&&{getter:t.getter},...t.filter!==void 0&&{filter:t.filter},...t.where&&{where:t.where}},Object.defineProperty(i,n,{configurable:!0,writable:!0})}}var Nr=new Map,c0=200;function jm(r,e){return`${r}:${e}`}function l0(r,e){let t=jm(r,e),i=Nr.get(t);if(!!i){if(Date.now()>i.expiry){Nr.delete(t);return}return i.result}}function u0(r,e,t,i=c0){let n=Date.now();for(let[o,s]of Nr)n>s.expiry&&Nr.delete(o);let a=jm(r,e);Nr.set(a,{result:t,expiry:n+i})}function Xr(r){let e=r+":";for(let[t]of Nr)t.startsWith(e)&&Nr.delete(t)}function EO(){Nr.clear()}function kO(){return Nr.size}var ca=class{constructor(e,t){this.flowable="any",this.startAction=[],this._states=[],this._transitions=[],this.name=e,this.namespace=t}get states(){return[...this._states]}get transitions(){return[...this._transitions]}addState(e){this._states.push(e)}addTransition(e){this._transitions.push(e)}get flowUri(){return`${this.namespace}${this.name}Flow`}stateUri(e){return`${this.namespace}${this.name}.${e}`}transitionUri(e,t){return`${this.namespace}${this.name}.${e}To${t}`}toLinks(){let e=[],t=this.flowUri;e.push({source:t,predicate:"rdf://type",target:"ad4m://Flow"}),e.push({source:t,predicate:"ad4m://flowName",target:xe.from(this.name).toUrl()}),this.flowable==="any"?e.push({source:t,predicate:"ad4m://flowable",target:"ad4m://any"}):e.push({source:t,predicate:"ad4m://flowable",target:`literal:string:${encodeURIComponent(JSON.stringify(this.flowable))}`}),this.startAction.length>0&&e.push({source:t,predicate:"ad4m://startAction",target:`literal:string:${encodeURIComponent(JSON.stringify(this.startAction))}`});for(let i of this._states){let n=this.stateUri(i.name);e.push({source:t,predicate:"ad4m://hasState",target:n}),e.push({source:n,predicate:"rdf://type",target:"ad4m://FlowState"}),e.push({source:n,predicate:"ad4m://stateName",target:xe.from(i.name).toUrl()}),e.push({source:n,predicate:"ad4m://stateValue",target:xe.from(i.value).toUrl()}),e.push({source:n,predicate:"ad4m://stateCheck",target:`literal:string:${encodeURIComponent(JSON.stringify(i.stateCheck))}`})}for(let i of this._transitions){let n=this.transitionUri(i.fromState,i.toState),a=this.stateUri(i.fromState),o=this.stateUri(i.toState);e.push({source:t,predicate:"ad4m://hasTransition",target:n}),e.push({source:n,predicate:"rdf://type",target:"ad4m://FlowTransition"}),e.push({source:n,predicate:"ad4m://actionName",target:xe.from(i.actionName).toUrl()}),e.push({source:n,predicate:"ad4m://fromState",target:a}),e.push({source:n,predicate:"ad4m://toState",target:o}),e.push({source:n,predicate:"ad4m://transitionActions",target:`literal:string:${encodeURIComponent(JSON.stringify(i.actions))}`})}return e}static fromLinks(e,t){let i="Flow";if(!t.endsWith(i))throw new Error(`Invalid flow URI: ${t} (must end with 'Flow')`);let n=t.slice(0,-i.length),a=Math.max(n.lastIndexOf("/"),n.lastIndexOf(":")),o=n.slice(0,a+1),s=n.slice(a+1),c=new ca(s,o),l=e.find(h=>h.source===t&&h.predicate==="ad4m://flowable");if(l)if(l.target==="ad4m://any")c.flowable="any";else try{let h=l.target.replace(/^literal:\/\/string:|^literal:string:/,"");c.flowable=JSON.parse(decodeURIComponent(h))}catch{c.flowable="any"}let u=e.find(h=>h.source===t&&h.predicate==="ad4m://startAction");if(u)try{let h=u.target.replace(/^literal:\/\/string:|^literal:string:/,"");c.startAction=JSON.parse(decodeURIComponent(h))}catch{}let d=e.filter(h=>h.source===t&&h.predicate==="ad4m://hasState"),f=new Map;for(let h of d){let m=h.target,y=e.find($=>$.source===m&&$.predicate==="ad4m://stateName"),b=y?xe.fromUrl(y.target).get():"";f.set(m,b);let _=e.find($=>$.source===m&&$.predicate==="ad4m://stateValue"),S=_?xe.fromUrl(_.target).get():0,v=e.find($=>$.source===m&&$.predicate==="ad4m://stateCheck"),C={predicate:"",target:""};if(v)try{let $=v.target.replace(/^literal:\/\/string:|^literal:string:/,"");C=JSON.parse(decodeURIComponent($))}catch{}c.addState({name:b,value:S,stateCheck:C})}let p=e.filter(h=>h.source===t&&h.predicate==="ad4m://hasTransition");for(let h of p){let m=h.target,y=e.find(N=>N.source===m&&N.predicate==="ad4m://actionName"),b=y?xe.fromUrl(y.target).get():"",S=e.find(N=>N.source===m&&N.predicate==="ad4m://fromState")?.target||"",v=f.get(S)||"",$=e.find(N=>N.source===m&&N.predicate==="ad4m://toState")?.target||"",I=f.get($)||"",L=e.find(N=>N.source===m&&N.predicate==="ad4m://transitionActions"),M=[];if(L)try{let N=L.target.replace(/^literal:\/\/string:|^literal:string:/,"");M=JSON.parse(decodeURIComponent(N))}catch{}c.addTransition({actionName:b,fromState:v,toState:I,actions:M})}return c}toJSON(){return{name:this.name,namespace:this.namespace,flowable:this.flowable,startAction:this.startAction,states:this._states,transitions:this._transitions}}static fromJSON(e){let t=new ca(e.name,e.namespace);t.flowable=e.flowable||"any",t.startAction=e.startAction||[];for(let i of e.states||[])t.addState(i);for(let i of e.transitions||[])t.addTransition(i);return t}},ve=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},O=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},oc,ta,ii,qi,Ji,ni,ai,Bi,Za,sc,Vi,Qi,Qt,Ya,Gu,ie,me,Hi,zi,Wi,Xa,eo,Ac=class{constructor(e,t,i){oc.add(this),ta.set(this,void 0),ii.set(this,void 0),qi.set(this,void 0),Ji.set(this,void 0),ni.set(this,void 0),ai.set(this,void 0),Bi.set(this,void 0),Za.set(this,!1),sc.set(this,void 0),Vi.set(this,void 0),Qi.set(this,void 0),Qt.set(this,void 0),Ya.set(this,void 0),ve(this,ta,e,"f"),ve(this,Ya,t,"f"),ve(this,qi,i,"f"),ve(this,Ji,new Set,"f"),ve(this,Bi,null,"f"),ve(this,sc,new Promise((n,a)=>{ve(this,Vi,n,"f"),ve(this,Qi,a,"f")}),"f")}async subscribe(){O(this,ai,"f")&&(O(this,ai,"f").call(this),ve(this,ai,void 0,"f")),O(this,Qt,"f")&&(clearTimeout(O(this,Qt,"f")),ve(this,Qt,void 0,"f")),O(this,ni,"f")&&(clearTimeout(O(this,ni,"f")),ve(this,ni,void 0,"f"));try{let t;t=await O(this,qi,"f").subscribeQuery(O(this,ta,"f"),O(this,Ya,"f")),ve(this,ii,t.subscriptionId,"f"),t.result?(ve(this,Bi,t.result,"f"),O(this,oc,"m",Gu).call(this,t.result)):console.warn("\u26A0\uFE0F No initial result returned from subscribeQuery!"),ve(this,Qt,setTimeout(()=>{console.error("Subscription initialization timed out after 30 seconds. Resubscribing..."),this.subscribe().catch(i=>{console.error("Error during subscription retry after timeout:",i)})},3e4),"f"),ve(this,ai,O(this,qi,"f").subscribeToQueryUpdates(O(this,ii,"f"),i=>{O(this,Qt,"f")&&(clearTimeout(O(this,Qt,"f")),ve(this,Qt,void 0,"f")),O(this,Vi,"f")&&(O(this,Vi,"f").call(this,!0),ve(this,Vi,void 0,"f"),ve(this,Qi,void 0,"f")),!(i.isInit&&O(this,Bi,"f"))&&(ve(this,Bi,i,"f"),O(this,oc,"m",Gu).call(this,i))}),"f")}catch(t){throw console.error("Error setting up subscription:",t),O(this,Qi,"f")&&(O(this,Qi,"f").call(this,t),ve(this,Vi,void 0,"f"),ve(this,Qi,void 0,"f")),t}let e=async()=>{if(!O(this,Za,"f")){try{await O(this,qi,"f").keepAliveQuery(O(this,ta,"f"),O(this,ii,"f"))}catch(t){console.error("Error in keepalive:",t),console.log("Reinitializing subscription for query:",O(this,Ya,"f"));try{await this.subscribe(),console.log("Subscription reinitialized")}catch(i){console.error("Error during resubscription from keepalive:",i);return}}O(this,Za,"f")||ve(this,ni,setTimeout(e,3e4),"f")}};ve(this,ni,setTimeout(e,3e4),"f")}get id(){return O(this,ii,"f")}get initialized(){return O(this,sc,"f")}get result(){return O(this,Bi,"f")}onResult(e){return O(this,Ji,"f").add(e),()=>O(this,Ji,"f").delete(e)}dispose(){ve(this,Za,!0,"f"),clearTimeout(O(this,ni,"f")),O(this,ai,"f")&&O(this,ai,"f").call(this),O(this,Ji,"f").clear(),O(this,Qt,"f")&&(clearTimeout(O(this,Qt,"f")),ve(this,Qt,void 0,"f")),O(this,ii,"f")&&O(this,qi,"f").disposeQuerySubscription(O(this,ta,"f"),O(this,ii,"f")).catch(e=>console.error("Error disposing query subscription:",e))}};ta=new WeakMap,ii=new WeakMap,qi=new WeakMap,Ji=new WeakMap,ni=new WeakMap,ai=new WeakMap,Bi=new WeakMap,Za=new WeakMap,sc=new WeakMap,Vi=new WeakMap,Qi=new WeakMap,Qt=new WeakMap,Ya=new WeakMap,oc=new WeakSet,Gu=function r(e){for(let t of O(this,Ji,"f"))try{t(e)}catch(i){console.error("Error in query subscription callback:",i)}};var ia=class{constructor(e,t){ie.set(this,void 0),me.set(this,void 0),Hi.set(this,void 0),zi.set(this,void 0),Wi.set(this,void 0),Xa.set(this,void 0),eo.set(this,new Set),ve(this,Hi,[],"f"),ve(this,zi,[],"f"),ve(this,Wi,[],"f"),ve(this,Xa,[],"f"),ve(this,ie,e,"f"),ve(this,me,t,"f"),this.uuid=O(this,ie,"f").uuid,this.name=O(this,ie,"f").name,this.owners=O(this,ie,"f").owners,this.sharedUrl=O(this,ie,"f").sharedUrl,this.neighbourhood=O(this,ie,"f").neighbourhood,this.state=O(this,ie,"f").state,O(this,me,"f").addPerspectiveLinkAddedListener(O(this,ie,"f").uuid,O(this,Hi,"f")),O(this,me,"f").addPerspectiveLinkRemovedListener(O(this,ie,"f").uuid,O(this,zi,"f")),O(this,me,"f").addPerspectiveLinkUpdatedListener(O(this,ie,"f").uuid,O(this,Wi,"f")),O(this,me,"f").addPerspectiveSyncStateChangeListener(O(this,ie,"f").uuid,O(this,Xa,"f"))}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async executeAction(e,t,i,n){let a=await O(this,me,"f").executeCommands(O(this,ie,"f").uuid,JSON.stringify(e),t,JSON.stringify(i),n);return Xr(O(this,ie,"f").uuid),a}async get(e){return await O(this,me,"f").queryLinks(O(this,ie,"f").uuid,e)}async infer(e){return await O(this,me,"f").queryProlog(O(this,ie,"f").uuid,e)}async querySparql(e){let t=l0(O(this,ie,"f").uuid,e);if(t!==void 0)return t;let i=await O(this,me,"f").querySparql(O(this,ie,"f").uuid,e);return u0(O(this,ie,"f").uuid,e,i),i}async add(e,t="shared",i){let n=await O(this,me,"f").addLink(O(this,ie,"f").uuid,e,t,i);return Xr(O(this,ie,"f").uuid),n}async addLinks(e,t="shared",i){let n=await O(this,me,"f").addLinks(O(this,ie,"f").uuid,e,t,i);return Xr(O(this,ie,"f").uuid),n}async removeLinks(e,t){let i=await O(this,me,"f").removeLinks(O(this,ie,"f").uuid,e,t);return Xr(O(this,ie,"f").uuid),i}async linkMutations(e,t="shared"){let i=await O(this,me,"f").linkMutations(O(this,ie,"f").uuid,e,t);return Xr(O(this,ie,"f").uuid),i}async addLinkExpression(e,t="shared",i){return await O(this,me,"f").addLinkExpression(O(this,ie,"f").uuid,e,t,i)}async update(e,t,i){let n=await O(this,me,"f").updateLink(O(this,ie,"f").uuid,e,t,i);return Xr(O(this,ie,"f").uuid),n}async remove(e,t){let i=await O(this,me,"f").removeLink(O(this,ie,"f").uuid,e,t);return Xr(O(this,ie,"f").uuid),i}async createBatch(){return await O(this,me,"f").createBatch(O(this,ie,"f").uuid)}async commitBatch(e){let t=await O(this,me,"f").commitBatch(O(this,ie,"f").uuid,e);return Xr(O(this,ie,"f").uuid),t}async getExpression(e){return await O(this,me,"f").getExpression(e)}async createExpression(e,t){return await O(this,me,"f").createExpression(e,t)}async addListener(e,t){e==="link-added"?O(this,Hi,"f").push(t):e==="link-removed"?O(this,zi,"f").push(t):e==="link-updated"&&O(this,Wi,"f").push(t)}async addSyncStateChangeListener(e){O(this,Xa,"f").push(e)}async removeListener(e,t){if(e==="link-added"){let i=O(this,Hi,"f").indexOf(t);O(this,Hi,"f").splice(i,1)}else if(e==="link-removed"){let i=O(this,zi,"f").indexOf(t);O(this,zi,"f").splice(i,1)}else if(e==="link-updated"){let i=O(this,Wi,"f").indexOf(t);O(this,Wi,"f").splice(i,1)}}async snapshot(){return O(this,me,"f").snapshotByUUID(O(this,ie,"f").uuid)}async loadSnapshot(e){let t=JSON.parse(JSON.stringify(e));delete t.__typename,t.links.forEach(i=>{delete i.data.__typename});for(let i of t.links)await this.addLinkExpression(i)}async getSingleTarget(e){delete e.target;let t=await this.get(e);return t.length?t[0].data.target:null}async setSingleTarget(e,t="shared"){let i=new K({source:e.source,predicate:e.predicate}),n=await this.get(i),a=[];for(let s of n)delete s.__typename,delete s.data.__typename,delete s.proof.__typename,a.push(s);let o=[e];await this.linkMutations({additions:o,removals:a},t)}async sdnaFlows(){return(await this.get(new K({source:"ad4m://self",predicate:"ad4m://has_flow"}))).map(t=>{try{return xe.fromUrl(t.data.target).get()}catch{return t.data.target}})}async availableFlows(e){let t=await this.sdnaFlows(),i=[];for(let n of t){let a=await this.getFlow(n);if(!!a)if(a.flowable==="any")i.push(n);else{let o=a.flowable,s=o.source||e;(await this.get(new K({source:s,predicate:o.predicate,target:o.target}))).length>0&&i.push(n)}}return i}async startFlow(e,t){let i=await this.getFlow(e);if(!i)throw`Flow "${e}" not found`;if(i.startAction.length===0)throw`Flow "${e}" has no start action`;await this.executeAction(i.startAction,t,void 0)}async expressionsInFlowState(e,t){let i=await this.getFlow(e);if(!i)return[];let n=i.states.find(s=>s.value===t);if(!n)return[];let a=n.stateCheck;return(await this.get(new K({predicate:a.predicate,target:a.target}))).map(s=>a.source?s.data.target:s.data.source)}async flowState(e,t){let i=await this.getFlow(e);if(!i)throw`Flow "${e}" not found`;for(let n of i.states){let a=n.stateCheck,o=a.source||t;if((await this.get(new K({source:o,predicate:a.predicate,target:a.target}))).length>0)return n.value}throw`Expression "${t}" is not in any state of flow "${e}"`}async flowActions(e,t){let i=await this.getFlow(e);if(!i)return[];let n=null;for(let a of i.states){let o=a.stateCheck,s=o.source||t;if((await this.get(new K({source:s,predicate:o.predicate,target:o.target}))).length>0){n=a.name;break}}return n?i.transitions.filter(a=>a.fromState===n).map(a=>a.actionName):[]}async runFlowAction(e,t,i){let n=await this.getFlow(e);if(!n)throw`Flow "${e}" not found`;let a=n.transitions.find(o=>o.actionName===i);if(!a)throw`Action "${i}" not found in flow "${e}"`;await this.executeAction(a.actions,t,void 0)}async getSdna(){let e=["ad4m://has_subject_class","ad4m://has_flow","ad4m://has_custom_sdna"],t=[];for(let i of e){let n=await this.get(new K({source:"ad4m://self",predicate:i}));for(let a of n){let o=a.data.target,s=await this.get(new K({source:o,predicate:"ad4m://sdna"}));for(let c of s){let l=xe.fromUrl(c.data.target).get();typeof l=="string"&&t.push(l)}}}return t}async getSdnaForClass(e){let t=xe.from(e);if((await this.get(new K({source:"ad4m://self",target:t.toUrl(),predicate:"ad4m://has_subject_class"}))).length===0)return null;let n=await this.get(new K({source:t.toUrl(),predicate:"ad4m://sdna"}));if(n.length===0)return null;let a=xe.fromUrl(n[0].data.target).get();return typeof a=="string"?a:null}async addSdna(e,t,i,n){return O(this,me,"f").addSdna(O(this,ie,"f").uuid,e,t,i,n)}async addSubjectClass(e,t){return this.addSdna(e,"","subject_class",t)}async addShacl(e,t){let i=t.toLinks(),n=xe.fromUrl(`literal:string:shacl://${e}`),a=[...i.map(o=>new It({source:o.source,predicate:o.predicate,target:o.target})),new It({source:"ad4m://self",predicate:"ad4m://has_shacl",target:n.toUrl()}),new It({source:n.toUrl(),predicate:"ad4m://shacl_shape_uri",target:t.nodeShapeUri})];await this.addLinks(a)}async getShacl(e){let t=xe.fromUrl(`literal:string:shacl://${e}`),i=await this.get(new K({source:t.toUrl(),predicate:"ad4m://shacl_shape_uri"}));if(i.length===0)return null;let n=i[0].data.target,a=await this.get(new K({source:n,predicate:"sh://property"})),o=[n,...a.map(l=>l.data.target)],s=[];for(let l of o){let u=await this.get(new K({source:l}));for(let d of u)s.push({source:d.data.source,predicate:d.data.predicate,target:d.data.target})}let c=s;return ui.fromLinks(c,n)}async getAllShacl(){let e=await this.get(new K({source:"ad4m://self",predicate:"ad4m://has_shacl"})),t=[];for(let i of e){let n=i.data.target,o=xe.fromUrl(n).get().replace("shacl://",""),s=await this.getShacl(o);s&&t.push({name:o,shape:s})}return t}async addFlow(e,t){let i=t.toLinks(),n=xe.from(e).toUrl(),a=[...i.map(o=>new It({source:o.source,predicate:o.predicate,target:o.target})),new It({source:"ad4m://self",predicate:"ad4m://has_flow",target:n}),new It({source:n,predicate:"ad4m://flow_uri",target:t.flowUri})];await this.addLinks(a)}async getFlow(e){let t=xe.from(e).toUrl(),i=await this.get(new K({source:t,predicate:"ad4m://flow_uri"}));if(i.length===0)return null;let n=i[0].data.target,a=n.endsWith("Flow")?n.slice(0,-4)+".":n+".",o=`SELECT ?s ?p ?o WHERE {
46
+ `}return t}toLinks(){let t=[];t.push({source:this.nodeShapeUri,predicate:"rdf://type",target:"sh://NodeShape"}),this.targetClass&&t.push({source:this.nodeShapeUri,predicate:"sh://targetClass",target:this.targetClass}),this.constructor_actions&&t.push({source:this.nodeShapeUri,predicate:"ad4m://constructor",target:`literal:string:${JSON.stringify(this.constructor_actions)}`}),this.destructor_actions&&t.push({source:this.nodeShapeUri,predicate:"ad4m://destructor",target:`literal:string:${JSON.stringify(this.destructor_actions)}`});for(let e=0;e<this.properties.length;e++){let r=this.properties[e],s;if(r.name&&this.targetClass){let n=Vn(this.targetClass),a=Qn(this.targetClass);s=`${n}${a}.${r.name}`}else s=`_:propShape${e}`;t.push({source:this.nodeShapeUri,predicate:"sh://property",target:s}),t.push({source:s,predicate:"sh://path",target:r.path}),r.datatype&&t.push({source:s,predicate:"sh://datatype",target:r.datatype}),r.nodeKind&&t.push({source:s,predicate:"sh://nodeKind",target:`sh://${r.nodeKind}`}),r.minCount!==void 0&&t.push({source:s,predicate:"sh://minCount",target:`literal:${r.minCount}^^xsd:integer`}),r.maxCount!==void 0&&t.push({source:s,predicate:"sh://maxCount",target:`literal:${r.maxCount}^^xsd:integer`}),r.pattern&&t.push({source:s,predicate:"sh://pattern",target:`literal:${r.pattern}`}),r.minInclusive!==void 0&&t.push({source:s,predicate:"sh://minInclusive",target:`literal:${r.minInclusive}`}),r.maxInclusive!==void 0&&t.push({source:s,predicate:"sh://maxInclusive",target:`literal:${r.maxInclusive}`}),r.hasValue&&t.push({source:s,predicate:"sh://hasValue",target:`literal:${r.hasValue}`}),r.local!==void 0&&t.push({source:s,predicate:"ad4m://local",target:`literal:${r.local}`}),r.writable!==void 0&&t.push({source:s,predicate:"ad4m://writable",target:`literal:${r.writable}`}),r.resolveLanguage&&t.push({source:s,predicate:"ad4m://resolveLanguage",target:`literal:string:${r.resolveLanguage}`}),r.setter&&r.setter.length>0&&t.push({source:s,predicate:"ad4m://setter",target:`literal:string:${JSON.stringify(r.setter)}`}),r.adder&&r.adder.length>0&&t.push({source:s,predicate:"ad4m://adder",target:`literal:string:${JSON.stringify(r.adder)}`}),r.remover&&r.remover.length>0&&t.push({source:s,predicate:"ad4m://remover",target:`literal:string:${JSON.stringify(r.remover)}`}),r.getter&&t.push({source:s,predicate:"ad4m://getter",target:`literal:string:${r.getter}`}),r.conformanceConditions&&r.conformanceConditions.length>0&&t.push({source:s,predicate:"ad4m://conformanceConditions",target:`literal:string:${JSON.stringify(r.conformanceConditions)}`}),r.class&&t.push({source:s,predicate:"sh://class",target:r.class}),r.in&&r.in.length>0&&t.push({source:s,predicate:"sh://in",target:`literal:string:${JSON.stringify(r.in)}`})}return t}static fromLinks(t,e){let r=t.find(c=>c.source===e&&c.predicate==="sh://targetClass"),s=new ut(e,r?.target),n=t.find(c=>c.source===e&&c.predicate==="ad4m://constructor");if(n)try{let c=n.target.replace(/^literal:\/\/string:|^literal:string:/,"");s.constructor_actions=JSON.parse(c)}catch{}let a=t.find(c=>c.source===e&&c.predicate==="ad4m://destructor");if(a)try{let c=a.target.replace(/^literal:\/\/string:|^literal:string:/,"");s.destructor_actions=JSON.parse(c)}catch{}let o=t.filter(c=>c.source===e&&c.predicate==="sh://property");for(let c of o){let l=c.target,d=t.find(b=>b.source===l&&b.predicate==="sh://path");if(!d)continue;let g;if(!l.startsWith("_:")){let b=l.lastIndexOf(".");b!==-1&&(g=l.substring(b+1))}let p={name:g,path:d.target},h=t.find(b=>b.source===l&&b.predicate==="sh://datatype");h&&(p.datatype=h.target);let u=t.find(b=>b.source===l&&b.predicate==="sh://nodeKind");u&&(p.nodeKind=u.target.replace("sh://",""));let f=t.find(b=>b.source===l&&b.predicate==="sh://minCount");if(f){let b=f.target.replace(/^literal:\/\/|^literal:/,"").replace(/\^\^.*$/,"");b.startsWith("number:")&&(b=b.substring(7)),p.minCount=parseInt(b)}let w=t.find(b=>b.source===l&&b.predicate==="sh://maxCount");if(w){let b=w.target.replace(/^literal:\/\/|^literal:/,"").replace(/\^\^.*$/,"");b.startsWith("number:")&&(b=b.substring(7)),p.maxCount=parseInt(b)}let v=t.find(b=>b.source===l&&b.predicate==="sh://pattern");v&&(p.pattern=v.target.replace(/^literal:\/\/|^literal:/,""));let x=t.find(b=>b.source===l&&b.predicate==="sh://minInclusive");if(x){let b=x.target.replace(/^literal:\/\/|^literal:/,"");b.startsWith("number:")&&(b=b.substring(7)),p.minInclusive=parseFloat(b)}let S=t.find(b=>b.source===l&&b.predicate==="sh://maxInclusive");if(S){let b=S.target.replace(/^literal:\/\/|^literal:/,"");b.startsWith("number:")&&(b=b.substring(7)),p.maxInclusive=parseFloat(b)}let _=t.find(b=>b.source===l&&b.predicate==="sh://hasValue");_&&(p.hasValue=_.target.replace(/^literal:\/\/|^literal:/,""));let P=t.find(b=>b.source===l&&b.predicate==="ad4m://local");if(P){let b=P.target.replace(/^literal:\/\/|^literal:/,"");b.startsWith("boolean:")&&(b=b.substring(8)),p.local=b==="true"}let R=t.find(b=>b.source===l&&b.predicate==="ad4m://writable");if(R){let b=R.target.replace(/^literal:\/\/|^literal:/,"");b.startsWith("boolean:")&&(b=b.substring(8)),p.writable=b==="true"}let k=t.find(b=>b.source===l&&b.predicate==="ad4m://resolveLanguage");k&&(p.resolveLanguage=k.target.replace(/^literal:\/\/string:|^literal:string:/,""));let M=t.find(b=>b.source===l&&b.predicate==="ad4m://setter");if(M)try{let b=M.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.setter=JSON.parse(b)}catch{}let N=t.find(b=>b.source===l&&b.predicate==="ad4m://adder");if(N)try{let b=N.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.adder=JSON.parse(b)}catch{}let A=t.find(b=>b.source===l&&b.predicate==="ad4m://remover");if(A)try{let b=A.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.remover=JSON.parse(b)}catch{}let D=t.find(b=>b.source===l&&b.predicate==="ad4m://getter");D&&(p.getter=D.target.replace(/^literal:\/\/string:|^literal:string:/,""));let Me=t.find(b=>b.source===l&&b.predicate==="ad4m://conformanceConditions");if(Me)try{let b=Me.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.conformanceConditions=JSON.parse(b)}catch{}let yi=t.find(b=>b.source===l&&b.predicate==="sh://class");yi&&(p.class=yi.target);let xt=t.find(b=>b.source===l&&b.predicate==="sh://in");if(xt)try{let b=xt.target.replace(/^literal:\/\/string:|^literal:string:/,"");p.in=JSON.parse(b)}catch{}s.addProperty(p)}return s}toJSON(){return{node_shape_uri:this.nodeShapeUri,target_class:this.targetClass,parent_shapes:this.parentShapes.length>0?this.parentShapes:void 0,properties:this.properties.map(t=>({path:t.path,name:t.name,datatype:t.datatype,node_kind:t.nodeKind,min_count:t.minCount,max_count:t.maxCount,min_inclusive:t.minInclusive,max_inclusive:t.maxInclusive,pattern:t.pattern,has_value:t.hasValue,local:t.local,writable:t.writable,resolve_language:t.resolveLanguage,setter:t.setter,adder:t.adder,remover:t.remover,getter:t.getter,conformance_conditions:t.conformanceConditions,class:t.class,in:t.in})),constructor_actions:this.constructor_actions,destructor_actions:this.destructor_actions}}static fromJSON(t){let e=t.node_shape_uri?new ut(t.node_shape_uri,t.target_class):new ut(t.target_class);for(let r of t.properties||[])e.addProperty({path:r.path,name:r.name,datatype:r.datatype,nodeKind:r.node_kind,minCount:r.min_count,maxCount:r.max_count,minInclusive:r.min_inclusive,maxInclusive:r.max_inclusive,pattern:r.pattern,hasValue:r.has_value,local:r.local,writable:r.writable,resolveLanguage:r.resolve_language,setter:r.setter,adder:r.adder,remover:r.remover,getter:r.getter,conformanceConditions:r.conformance_conditions,class:r.class,in:r.in});if(t.constructor_actions&&(e.constructor_actions=t.constructor_actions),t.destructor_actions&&(e.destructor_actions=t.destructor_actions),t.parent_shapes)for(let r of t.parent_shapes)e.addParentShape(r);return e}};function Kn(i){return i?.length?i.length===1?i.toString():i.length===2?i.join(" and "):i.slice(0,-1).join(", ")+", and "+i.slice(-1):""}function Ga(i){let t=i.can.includes("*")?["READ","WRITE","UPDATE"]:i.can,e=i.with.domain==="*"?"":i.with.domain,r=i.with.pointers.includes("*")?["all AD4M data"]:i.with.pointers;return`${Kn(t)} your ${e} actions, with access to ${Kn(r)}`}function Xe(i){return i.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function Cl(i,t,e){let r=Xe(i),s=!e?.resolveLanguage||e.resolveLanguage==="literal";function n(a){return typeof a=="string"?s?`<literal:string:${Xe(a)}>`:`<${Xe(a)}>`:`<literal:string:${a}>`}if(Array.isArray(t)){let a=t.map(n).join(", ");return`FILTER EXISTS { ?target <${r}> ?_val . FILTER(?_val IN (${a})) }`}else if(typeof t=="object"&&t!==null){let a=t,o=[];if(a.not!==void 0)if(Array.isArray(a.not)){let l=a.not.map(d=>n(d)).join(", ");o.push(`FILTER NOT EXISTS { ?target <${r}> ?_nval . FILTER(?_nval IN (${l})) }`)}else o.push(`FILTER NOT EXISTS { ?target <${r}> ${n(a.not)} }`);return(a.gt!==void 0||a.gte!==void 0||a.lt!==void 0||a.lte!==void 0||a.between!==void 0||a.contains!==void 0)&&o.push(`FILTER EXISTS { ?target <${r}> ?_cmp }`),o.join(" ")}else return`?target <${r}> ${n(t)} .`}function zr(i,t){let e=[];for(let[r,s]of Object.entries(i)){if(["id","author","timestamp"].includes(r))continue;let n,a;if(t){let c=t.properties[r];c?(n=c.predicate,a=c.resolveLanguage):n=r}else n=r;let o=Cl(n,s,{resolveLanguage:a});o&&e.push(o)}return e}function Sl(i,t,e,r,s){let n=t.prototype,a="ad4m://",o=Object.fromEntries(Object.entries(r).filter(([,u])=>u.kind==="hasMany"||u.kind==="belongsToMany"));if(Object.keys(e).length>0){let u=e[Object.keys(e)[0]];if(u.through){let f=u.through.match(/^([^:]+:\/\/)/);f&&(a=f[1])}}else if(Object.keys(o).length>0){let u=o[Object.keys(o)[0]];if(u.predicate){let f=u.predicate.match(/^([^:]+:\/\/)/);f&&(a=f[1])}}let c=`${a}${i}Shape`,l=`${a}${i}`,d=new ut(c,l),g=Object.getPrototypeOf(t);if(g&&typeof g.generateSHACL=="function"){let u=g.generateSHACL();u?.shape?.nodeShapeUri&&d.addParentShape(u.shape.nodeShapeUri)}let p=[];n.subjectConstructor&&n.subjectConstructor.length&&(p=p.concat(n.subjectConstructor));let h=[];for(let u in e){let f=e[u];if(!f.through)continue;let w={name:u,path:f.through};if(f.resolveLanguage==="literal")w.datatype="xsd://string";else if(f.initial){let x=typeof n[u];x==="number"?w.datatype="xsd://integer":x==="boolean"?w.datatype="xsd://boolean":x==="string"&&(w.datatype="xsd://string")}f.required&&(w.minCount=1),w.maxCount=1,f.flag&&f.initial&&(w.hasValue=f.initial),f.options&&f.options.length>0&&(w.in=f.options),f.local!==void 0&&(w.local=f.local),f.writable!==void 0&&(w.writable=f.writable),f.resolveLanguage&&(w.resolveLanguage=f.resolveLanguage),f.prologSetter?console.warn(`[SHACL Generation] Custom Prolog setter for property '${u}' in class '${i}' is not yet supported. The property will be created without setter actions. Consider using standard writable properties or provide explicit SHACL JSON.`):f.writable&&f.through&&typeof n[en(u)]=="function"&&(w.setter=[{action:"setSingleTarget",source:"this",predicate:f.through,target:"value",...f.local&&{local:!0}}]);let v=f.initial??(f.required&&f.writable&&!f.flag&&f.through?"literal:string:":void 0);v&&(p.push({action:"addLink",source:"this",predicate:f.through,target:v}),h.push({action:"removeLink",source:"this",predicate:f.through,target:"*"})),d.addProperty(w)}for(let u in o){let f=o[u];if(!f.predicate)continue;let w={name:u,path:f.predicate};if(w.nodeKind="IRI",f.local!==void 0&&(w.local=f.local),w.adder=[{action:"addLink",source:"this",predicate:f.predicate,target:"value",...f.local&&{local:!0}}],w.remover=[{action:"removeLink",source:"this",predicate:f.predicate,target:"value",...f.local&&{local:!0}}],f.getter)w.getter=f.getter;else if(f.where)try{let v=f.target?.(),x=v?v.getModelMetadata?.()??null:null,S=zr(f.where,x);if(S.length>0){let _=Xe(f.predicate);w.getter=`SELECT ?target WHERE { <Base> <${_}> ?target . ${S.join(" ")} }`}}catch{}else if(f.target&&f.filter!==!1){let v=f.target,x=f.predicate,S=!1,_,P,R=()=>{if(!S){S=!0;try{let k=v(),M=s(x,k);M&&(_=M.getter,P=M.conformanceConditions)}catch{}}};Object.defineProperty(w,"getter",{get(){return R(),_},set(k){S=!0,_=k},enumerable:!0,configurable:!0}),Object.defineProperty(w,"conformanceConditions",{get(){return R(),P},set(k){S=!0,P=k},enumerable:!0,configurable:!0})}if(f.target)try{let x=f.target().generateSHACL?.();x?.shape?.nodeShapeUri&&(w.class=x.shape.nodeShapeUri)}catch{}d.addProperty(w)}return d.setConstructorActions(p),d.setDestructorActions(h),{shape:d,name:i}}var Er=new WeakMap,Tr=new WeakMap,Gn=new WeakMap,Xn=new WeakMap,Yn=new WeakMap;function pt(i){let t=Gn.get(i);if(t)return t;let e={},r=[],s=i;for(;s&&s!==Object;)r.unshift(s),s=Object.getPrototypeOf(s);for(let n of r){let a=Er.get(n);a&&Object.assign(e,a)}return Gn.set(i,e),e}function ue(i){let t=Xn.get(i);if(t)return t;let e={},r=[],s=i;for(;s&&s!==Object;)r.unshift(s),s=Object.getPrototypeOf(s);for(let n of r){let a=Tr.get(n);a&&Object.assign(e,a)}return Xn.set(i,e),e}function kl(i,t){let e=Yn.get(i);if(e)return e;let r=t();return Yn.set(i,r),r}function Ls(i,t,e){Er.has(i)||Er.set(i,{}),Er.get(i)[t]=e}function Xa(i,t,e){Tr.has(i)||Tr.set(i,{}),Tr.get(i)[t]=e}function Hr(i,t){try{let e=pt(t),r=[],s=[],n=0;for(let[o,c]of Object.entries(e))c.flag&&c.initial&&c.through&&(r.push({type:"flag",predicate:c.through,value:c.initial}),s.push(`?target <${Xe(c.through)}> <${Xe(c.initial)}> .`));for(let[o,c]of Object.entries(e))c.required&&!c.flag&&!c.getter&&c.through&&(r.push({type:"required",predicate:c.through}),s.push(`?target <${Xe(c.through)}> ?_v${n++} .`));return r.length===0?void 0:{getter:`SELECT ?target WHERE { <Base> <${Xe(i)}> ?target . ${s.join(" ")} }`,conformanceConditions:r}}catch{return}}function Ya(i){return function(t){t.prototype.className=i.name,t.className=i.name,t.generateSDNA=function(){return xl(i.name,t.prototype,pt(t),ue(t))},t.generateSHACL=function(){return kl(t,()=>Sl(i.name,t,pt(t),ue(t),Hr))},Object.defineProperty(t,"type",{configurable:!0})}}var Dt=new Map,$l=200;function eo(i,t){return`${i}:${t}`}function Al(i,t){let e=eo(i,t),r=Dt.get(e);if(!!r){if(Date.now()>r.expiry){Dt.delete(e);return}return r.result}}function El(i,t,e,r=$l){let s=Date.now();for(let[a,o]of Dt)s>o.expiry&&Dt.delete(a);let n=eo(i,t);Dt.set(n,{result:e,expiry:s+r})}function rt(i){let t=i+":";for(let[e]of Dt)e.startsWith(t)&&Dt.delete(e)}var li=class{constructor(t,e){this.flowable="any",this.startAction=[],this._states=[],this._transitions=[],this.name=t,this.namespace=e}get states(){return[...this._states]}get transitions(){return[...this._transitions]}addState(t){this._states.push(t)}addTransition(t){this._transitions.push(t)}get flowUri(){return`${this.namespace}${this.name}Flow`}stateUri(t){return`${this.namespace}${this.name}.${t}`}transitionUri(t,e){return`${this.namespace}${this.name}.${t}To${e}`}toLinks(){let t=[],e=this.flowUri;t.push({source:e,predicate:"rdf://type",target:"ad4m://Flow"}),t.push({source:e,predicate:"ad4m://flowName",target:K.from(this.name).toUrl()}),this.flowable==="any"?t.push({source:e,predicate:"ad4m://flowable",target:"ad4m://any"}):t.push({source:e,predicate:"ad4m://flowable",target:`literal:string:${encodeURIComponent(JSON.stringify(this.flowable))}`}),this.startAction.length>0&&t.push({source:e,predicate:"ad4m://startAction",target:`literal:string:${encodeURIComponent(JSON.stringify(this.startAction))}`});for(let r of this._states){let s=this.stateUri(r.name);t.push({source:e,predicate:"ad4m://hasState",target:s}),t.push({source:s,predicate:"rdf://type",target:"ad4m://FlowState"}),t.push({source:s,predicate:"ad4m://stateName",target:K.from(r.name).toUrl()}),t.push({source:s,predicate:"ad4m://stateValue",target:K.from(r.value).toUrl()}),t.push({source:s,predicate:"ad4m://stateCheck",target:`literal:string:${encodeURIComponent(JSON.stringify(r.stateCheck))}`})}for(let r of this._transitions){let s=this.transitionUri(r.fromState,r.toState),n=this.stateUri(r.fromState),a=this.stateUri(r.toState);t.push({source:e,predicate:"ad4m://hasTransition",target:s}),t.push({source:s,predicate:"rdf://type",target:"ad4m://FlowTransition"}),t.push({source:s,predicate:"ad4m://actionName",target:K.from(r.actionName).toUrl()}),t.push({source:s,predicate:"ad4m://fromState",target:n}),t.push({source:s,predicate:"ad4m://toState",target:a}),t.push({source:s,predicate:"ad4m://transitionActions",target:`literal:string:${encodeURIComponent(JSON.stringify(r.actions))}`})}return t}static fromLinks(t,e){let r="Flow";if(!e.endsWith(r))throw new Error(`Invalid flow URI: ${e} (must end with 'Flow')`);let s=e.slice(0,-r.length),n=Math.max(s.lastIndexOf("/"),s.lastIndexOf(":")),a=s.slice(0,n+1),o=s.slice(n+1),c=new li(o,a),l=t.find(u=>u.source===e&&u.predicate==="ad4m://flowable");if(l)if(l.target==="ad4m://any")c.flowable="any";else try{let u=l.target.replace(/^literal:\/\/string:|^literal:string:/,"");c.flowable=JSON.parse(decodeURIComponent(u))}catch{c.flowable="any"}let d=t.find(u=>u.source===e&&u.predicate==="ad4m://startAction");if(d)try{let u=d.target.replace(/^literal:\/\/string:|^literal:string:/,"");c.startAction=JSON.parse(decodeURIComponent(u))}catch{}let g=t.filter(u=>u.source===e&&u.predicate==="ad4m://hasState"),p=new Map;for(let u of g){let f=u.target,w=t.find(R=>R.source===f&&R.predicate==="ad4m://stateName"),v=w?K.fromUrl(w.target).get():"";p.set(f,v);let x=t.find(R=>R.source===f&&R.predicate==="ad4m://stateValue"),S=x?K.fromUrl(x.target).get():0,_=t.find(R=>R.source===f&&R.predicate==="ad4m://stateCheck"),P={predicate:"",target:""};if(_)try{let R=_.target.replace(/^literal:\/\/string:|^literal:string:/,"");P=JSON.parse(decodeURIComponent(R))}catch{}c.addState({name:v,value:S,stateCheck:P})}let h=t.filter(u=>u.source===e&&u.predicate==="ad4m://hasTransition");for(let u of h){let f=u.target,w=t.find(A=>A.source===f&&A.predicate==="ad4m://actionName"),v=w?K.fromUrl(w.target).get():"",S=t.find(A=>A.source===f&&A.predicate==="ad4m://fromState")?.target||"",_=p.get(S)||"",R=t.find(A=>A.source===f&&A.predicate==="ad4m://toState")?.target||"",k=p.get(R)||"",M=t.find(A=>A.source===f&&A.predicate==="ad4m://transitionActions"),N=[];if(M)try{let A=M.target.replace(/^literal:\/\/string:|^literal:string:/,"");N=JSON.parse(decodeURIComponent(A))}catch{}c.addTransition({actionName:v,fromState:_,toState:k,actions:N})}return c}toJSON(){return{name:this.name,namespace:this.namespace,flowable:this.flowable,startAction:this.startAction,states:this._states,transitions:this._transitions}}static fromJSON(t){let e=new li(t.name,t.namespace);e.flowable=t.flowable||"any",e.startAction=t.startAction||[];for(let r of t.states||[])e.addState(r);for(let r of t.transitions||[])e.addTransition(r);return e}},B=function(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e},m=function(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)},Lr,ri,st,kt,Mt,nt,at,$t,Ci,Pr,je,ot,ke,Si,Ps,O,H,At,Et,Tt,ki,$i;function Tl(i){let t=i.lastIndexOf("#");if(t>=0)return i.substring(0,t+1);let e=i.lastIndexOf("/");if(e>=0)return i.substring(0,e+1);let r=i.lastIndexOf(":");return r>=0?i.substring(0,r+1):i}var Fr=class{constructor(t,e,r){Lr.add(this),ri.set(this,void 0),st.set(this,void 0),kt.set(this,void 0),Mt.set(this,void 0),nt.set(this,void 0),at.set(this,void 0),$t.set(this,void 0),Ci.set(this,!1),Pr.set(this,void 0),je.set(this,void 0),ot.set(this,void 0),ke.set(this,void 0),Si.set(this,void 0),B(this,ri,t,"f"),B(this,Si,e,"f"),B(this,kt,r,"f"),B(this,Mt,new Set,"f"),B(this,$t,null,"f"),B(this,Pr,new Promise((s,n)=>{B(this,je,s,"f"),B(this,ot,n,"f")}),"f")}async subscribe(){m(this,at,"f")&&(m(this,at,"f").call(this),B(this,at,void 0,"f")),m(this,ke,"f")&&(clearTimeout(m(this,ke,"f")),B(this,ke,void 0,"f")),m(this,nt,"f")&&(clearTimeout(m(this,nt,"f")),B(this,nt,void 0,"f"));try{let e;e=await m(this,kt,"f").subscribeQuery(m(this,ri,"f"),m(this,Si,"f")),B(this,st,e.subscriptionId,"f"),e.result!==void 0?(B(this,$t,e.result,"f"),m(this,Lr,"m",Ps).call(this,e.result),m(this,je,"f")&&(m(this,je,"f").call(this,!0),B(this,je,void 0,"f"),B(this,ot,void 0,"f"))):(console.warn("\u26A0\uFE0F No initial result returned from subscribeQuery!"),B(this,ke,setTimeout(()=>{console.error("Subscription initialization timed out after 30 seconds. Resubscribing..."),this.subscribe().catch(r=>{console.error("Error during subscription retry after timeout:",r)})},3e4),"f")),B(this,at,m(this,kt,"f").subscribeToQueryUpdates(m(this,st,"f"),r=>{m(this,ke,"f")&&(clearTimeout(m(this,ke,"f")),B(this,ke,void 0,"f")),m(this,je,"f")&&(m(this,je,"f").call(this,!0),B(this,je,void 0,"f"),B(this,ot,void 0,"f")),!(r.isInit&&m(this,$t,"f"))&&(B(this,$t,r,"f"),m(this,Lr,"m",Ps).call(this,r))}),"f")}catch(e){throw console.error("Error setting up subscription:",e),m(this,ot,"f")&&(m(this,ot,"f").call(this,e),B(this,je,void 0,"f"),B(this,ot,void 0,"f")),e}let t=async()=>{if(!m(this,Ci,"f")){try{await m(this,kt,"f").keepAliveQuery(m(this,ri,"f"),m(this,st,"f"))}catch(e){console.error("Error in keepalive:",e),console.log("Reinitializing subscription for query:",m(this,Si,"f"));try{await this.subscribe(),console.log("Subscription reinitialized")}catch(r){console.error("Error during resubscription from keepalive:",r);return}}m(this,Ci,"f")||B(this,nt,setTimeout(t,3e4),"f")}};B(this,nt,setTimeout(t,3e4),"f")}get id(){return m(this,st,"f")}get initialized(){return m(this,Pr,"f")}get result(){return m(this,$t,"f")}onResult(t){return m(this,Mt,"f").add(t),()=>m(this,Mt,"f").delete(t)}dispose(){B(this,Ci,!0,"f"),clearTimeout(m(this,nt,"f")),m(this,at,"f")&&m(this,at,"f").call(this),m(this,Mt,"f").clear(),m(this,ke,"f")&&(clearTimeout(m(this,ke,"f")),B(this,ke,void 0,"f")),m(this,st,"f")&&m(this,kt,"f").disposeQuerySubscription(m(this,ri,"f"),m(this,st,"f")).catch(t=>console.error("Error disposing query subscription:",t))}};ri=new WeakMap,st=new WeakMap,kt=new WeakMap,Mt=new WeakMap,nt=new WeakMap,at=new WeakMap,$t=new WeakMap,Ci=new WeakMap,Pr=new WeakMap,je=new WeakMap,ot=new WeakMap,ke=new WeakMap,Si=new WeakMap,Lr=new WeakSet,Ps=function(t){for(let e of m(this,Mt,"f"))try{e(t)}catch(r){console.error("Error in query subscription callback:",r)}};var ai=class{get client(){return m(this,H,"f")}constructor(t,e){O.set(this,void 0),H.set(this,void 0),At.set(this,void 0),Et.set(this,void 0),Tt.set(this,void 0),ki.set(this,void 0),$i.set(this,new Set),B(this,At,[],"f"),B(this,Et,[],"f"),B(this,Tt,[],"f"),B(this,ki,[],"f"),B(this,O,t,"f"),B(this,H,e,"f"),this.uuid=m(this,O,"f").uuid,this.name=m(this,O,"f").name,this.owners=m(this,O,"f").owners,this.sharedUrl=m(this,O,"f").sharedUrl,this.neighbourhood=m(this,O,"f").neighbourhood,this.state=m(this,O,"f").state,m(this,H,"f").addPerspectiveLinkAddedListener(m(this,O,"f").uuid,m(this,At,"f")),m(this,H,"f").addPerspectiveLinkRemovedListener(m(this,O,"f").uuid,m(this,Et,"f")),m(this,H,"f").addPerspectiveLinkUpdatedListener(m(this,O,"f").uuid,m(this,Tt,"f")),m(this,H,"f").addPerspectiveSyncStateChangeListener(m(this,O,"f").uuid,m(this,ki,"f"))}updateHandle(t){if(t.uuid!==m(this,O,"f").uuid)throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch \u2014 proxy is bound to "${m(this,O,"f").uuid}" but received handle with UUID "${t.uuid}". This would silently diverge from listeners registered under the original UUID.`);B(this,O,t,"f"),this.uuid=t.uuid,this.name=t.name,this.owners=t.owners,this.sharedUrl=t.sharedUrl,this.neighbourhood=t.neighbourhood,this.state=t.state}escapeRegExp(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async executeAction(t,e,r,s){let n=await m(this,H,"f").executeCommands(m(this,O,"f").uuid,JSON.stringify(t),e,JSON.stringify(r),s);return rt(m(this,O,"f").uuid),n}async get(t){return await m(this,H,"f").queryLinks(m(this,O,"f").uuid,t)}async infer(t){return await m(this,H,"f").queryProlog(m(this,O,"f").uuid,t)}async querySparql(t){let e=Al(m(this,O,"f").uuid,t);if(e!==void 0)return e;let r=await m(this,H,"f").querySparql(m(this,O,"f").uuid,t);return El(m(this,O,"f").uuid,t,r),r}async modelQuery(t,e,r){return await m(this,H,"f").modelQuery(m(this,O,"f").uuid,t,e,r)}async modelSubscribe(t,e,r){return await m(this,H,"f").modelSubscribe(m(this,O,"f").uuid,t,e,r)}async add(t,e="shared",r){let s=await m(this,H,"f").addLink(m(this,O,"f").uuid,t,e,r);return rt(m(this,O,"f").uuid),s}async addLinks(t,e="shared",r){let s=await m(this,H,"f").addLinks(m(this,O,"f").uuid,t,e,r);return rt(m(this,O,"f").uuid),s}async removeLinks(t,e){let r=await m(this,H,"f").removeLinks(m(this,O,"f").uuid,t,e);return rt(m(this,O,"f").uuid),r}async linkMutations(t,e="shared"){let r=await m(this,H,"f").linkMutations(m(this,O,"f").uuid,t,e);return rt(m(this,O,"f").uuid),r}async addLinkExpression(t,e="shared",r){return await m(this,H,"f").addLinkExpression(m(this,O,"f").uuid,t,e,r)}async update(t,e,r){let s=await m(this,H,"f").updateLink(m(this,O,"f").uuid,t,e,r);return rt(m(this,O,"f").uuid),s}async remove(t,e){let r=await m(this,H,"f").removeLink(m(this,O,"f").uuid,t,e);return rt(m(this,O,"f").uuid),r}async createBatch(){return await m(this,H,"f").createBatch(m(this,O,"f").uuid)}async commitBatch(t){let e=await m(this,H,"f").commitBatch(m(this,O,"f").uuid,t);return rt(m(this,O,"f").uuid),e}async getExpression(t){return await m(this,H,"f").getExpression(t)}async createExpression(t,e){return await m(this,H,"f").createExpression(t,e)}async addListener(t,e){t==="link-added"?m(this,At,"f").push(e):t==="link-removed"?m(this,Et,"f").push(e):t==="link-updated"&&m(this,Tt,"f").push(e)}async addSyncStateChangeListener(t){m(this,ki,"f").push(t)}async removeListener(t,e){if(t==="link-added"){let r=m(this,At,"f").indexOf(e);m(this,At,"f").splice(r,1)}else if(t==="link-removed"){let r=m(this,Et,"f").indexOf(e);m(this,Et,"f").splice(r,1)}else if(t==="link-updated"){let r=m(this,Tt,"f").indexOf(e);m(this,Tt,"f").splice(r,1)}}async snapshot(){return m(this,H,"f").snapshotByUUID(m(this,O,"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 Q({source:t.source,predicate:t.predicate}),s=await this.get(r),n=[];for(let o of s)delete o.__typename,delete o.data.__typename,delete o.proof.__typename,n.push(o);let a=[t];await this.linkMutations({additions:a,removals:n},e)}async sdnaFlows(){return(await this.get(new Q({source:"ad4m://self",predicate:"ad4m://has_flow"}))).map(e=>{try{return K.fromUrl(e.data.target).get()}catch{return e.data.target}})}async availableFlows(t){let e=await this.sdnaFlows(),r=[];for(let s of e){let n=await this.getFlow(s);if(!!n)if(n.flowable==="any")r.push(s);else{let a=n.flowable,o=a.source||t;(await this.get(new Q({source:o,predicate:a.predicate,target:a.target}))).length>0&&r.push(s)}}return r}async startFlow(t,e){let r=await this.getFlow(t);if(!r)throw`Flow "${t}" not found`;if(r.startAction.length===0)throw`Flow "${t}" has no start action`;await this.executeAction(r.startAction,e,void 0)}async expressionsInFlowState(t,e){let r=await this.getFlow(t);if(!r)return[];let s=r.states.find(o=>o.value===e);if(!s)return[];let n=s.stateCheck;return(await this.get(new Q({predicate:n.predicate,target:n.target}))).map(o=>n.source?o.data.target:o.data.source)}async flowState(t,e){let r=await this.getFlow(t);if(!r)throw`Flow "${t}" not found`;for(let s of r.states){let n=s.stateCheck,a=n.source||e;if((await this.get(new Q({source:a,predicate:n.predicate,target:n.target}))).length>0)return s.value}throw`Expression "${e}" is not in any state of flow "${t}"`}async flowActions(t,e){let r=await this.getFlow(t);if(!r)return[];let s=null;for(let n of r.states){let a=n.stateCheck,o=a.source||e;if((await this.get(new Q({source:o,predicate:a.predicate,target:a.target}))).length>0){s=n.name;break}}return s?r.transitions.filter(n=>n.fromState===s).map(n=>n.actionName):[]}async runFlowAction(t,e,r){let s=await this.getFlow(t);if(!s)throw`Flow "${t}" not found`;let n=s.transitions.find(a=>a.actionName===r);if(!n)throw`Action "${r}" not found in flow "${t}"`;await this.executeAction(n.actions,e,void 0)}async getSdna(){let t=["ad4m://has_subject_class","ad4m://has_flow","ad4m://has_custom_sdna"],e=[];for(let r of t){let s=await this.get(new Q({source:"ad4m://self",predicate:r}));for(let n of s){let a=n.data.target,o=await this.get(new Q({source:a,predicate:"ad4m://sdna"}));for(let c of o){let l=K.fromUrl(c.data.target).get();typeof l=="string"&&e.push(l)}}}return e}async getSdnaForClass(t){let e=K.from(t);if((await this.get(new Q({source:"ad4m://self",target:e.toUrl(),predicate:"ad4m://has_subject_class"}))).length===0)return null;let s=await this.get(new Q({source:e.toUrl(),predicate:"ad4m://sdna"}));if(s.length===0)return null;let n=K.fromUrl(s[0].data.target).get();return typeof n=="string"?n:null}async addSdna(t,e,r,s){return m(this,H,"f").addSdna(m(this,O,"f").uuid,t,e,r,s)}async addSubjectClass(t,e){return this.addSdna(t,"","subject_class",e)}async addShacl(t,e){let r=e.toLinks(),s=K.fromUrl(`literal:string:shacl://${t}`),n=[...r.map(a=>new Re({source:a.source,predicate:a.predicate,target:a.target})),new Re({source:"ad4m://self",predicate:"ad4m://has_shacl",target:s.toUrl()}),new Re({source:s.toUrl(),predicate:"ad4m://shacl_shape_uri",target:e.nodeShapeUri})];await this.addLinks(n)}async getShacl(t){let e=K.fromUrl(`literal:string:shacl://${t}`),r=await this.get(new Q({source:e.toUrl(),predicate:"ad4m://shacl_shape_uri"}));if(r.length===0)return null;let s=r[0].data.target,n=await this.get(new Q({source:s,predicate:"sh://property"})),a=[s,...n.map(l=>l.data.target)],o=[];for(let l of a){let d=await this.get(new Q({source:l}));for(let g of d)o.push({source:g.data.source,predicate:g.data.predicate,target:g.data.target})}let c=o;return ut.fromLinks(c,s)}async getAllShacl(){let t=await this.get(new Q({source:"ad4m://self",predicate:"ad4m://has_shacl"})),e=[];for(let r of t){let s=r.data.target,a=K.fromUrl(s).get().replace("shacl://",""),o=await this.getShacl(a);o&&e.push({name:a,shape:o})}return e}async addFlow(t,e){let r=e.toLinks(),s=K.from(t).toUrl(),n=[...r.map(a=>new Re({source:a.source,predicate:a.predicate,target:a.target})),new Re({source:"ad4m://self",predicate:"ad4m://has_flow",target:s}),new Re({source:s,predicate:"ad4m://flow_uri",target:e.flowUri})];await this.addLinks(n)}async getFlow(t){let e=K.from(t).toUrl(),r=await this.get(new Q({source:e,predicate:"ad4m://flow_uri"}));if(r.length===0)return null;let s=r[0].data.target,n=s.endsWith("Flow")?s.slice(0,-4)+".":s+".",a=`SELECT ?s ?p ?o WHERE {
107
47
  ?s ?p ?o .
108
- FILTER(?s = <${n}> || STRSTARTS(STR(?s), "${a}"))
109
- }`,c=(await this.querySparql(o)||[]).map(l=>({source:l.s,predicate:l.p,target:l.o}));return ca.fromLinks(c,n)}async subjectClasses(){try{let t=(await this.get(new K({predicate:"rdf://type",target:"ad4m://SubjectClass"}))).map(i=>{let a=i.data.source.split("://");return a[a.length-1].split("/").pop()||""}).filter(i=>i.length>0);return[...new Set(t)]}catch(e){return console.warn("subjectClasses: SHACL lookup failed:",e),[]}}async stringOrTemplateObjectToSubjectClassName(e){if(typeof e=="string")return e;{let t=await this.subjectClassesByTemplate(e);return t[0]?t[0]:e.className}}async createSubject(e,t,i,n){let a;if(typeof e=="string")a=e,await O(this,me,"f").createSubject(O(this,ie,"f").uuid,JSON.stringify({className:a,initialValues:i}),t,i?JSON.stringify(i):void 0,n);else{let o=e,s=o.className||o.constructor?.className||o.constructor?.prototype?.className||await this.findClassByProperties(o);if(!s)throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");await O(this,me,"f").createSubject(O(this,ie,"f").uuid,JSON.stringify({className:s,initialValues:i}),t,i?JSON.stringify(i):void 0,n)}return n?t:this.getSubjectProxy(t,e)}async getSubjectData(e,t){if(typeof e=="string")return JSON.parse(await O(this,me,"f").getSubjectData(O(this,ie,"f").uuid,JSON.stringify({className:e}),t));let i=e,n=i.className||i.constructor?.className||i.constructor?.prototype?.className||await this.findClassByProperties(i);if(!n)throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");return JSON.parse(await O(this,me,"f").getSubjectData(O(this,ie,"f").uuid,JSON.stringify({className:n}),t))}async getActionsFromSHACL(e,t){let i=this.escapeRegExp(e),n=new RegExp(`[/:#]${i}Shape$`),a=await this.get(new K({predicate:t}));for(let o of a)if(n.test(o.data.source)){let s="literal:string:";if(o.data.target.startsWith(s)){let c=o.data.target.slice(s.length),l=c;try{l=decodeURIComponent(c)}catch{}try{return JSON.parse(l)}catch(u){return console.warn(`Failed to parse SHACL actions JSON for ${e}:`,u),null}}}return null}async removeSubject(e,t,i){let n=await this.stringOrTemplateObjectToSubjectClassName(e),a=await this.getActionsFromSHACL(n,"ad4m://destructor");if(!a)throw`No destructor found for subject class: ${n}. Make sure the class was registered with SHACL.`;await this.executeAction(a,t,void 0,i)}async isSubjectInstance(e,t){let i=await this.stringOrTemplateObjectToSubjectClassName(t),n=await this.getSubjectClassMetadataFromSDNA(i);if(!n)return console.warn(`isSubjectInstance: No SHACL metadata found for class ${i}`),!1;if(n.requiredTriples.length===0)return(await this.get(new K({source:e}))).length>0;for(let a of n.requiredTriples){let o;a.target?o=new K({source:e,predicate:a.predicate,target:a.target}):o=new K({source:e,predicate:a.predicate});let s=await this.get(o);if(!s||s.length===0)return!1}return!0}async getSubjectProxy(e,t){if(!await this.isSubjectInstance(e,t))throw`Expression ${e} is not a subject instance of given class: ${JSON.stringify(t)}`;let i=await this.stringOrTemplateObjectToSubjectClassName(t),n=new _o(this,e,i);return await n.init(),n}async getSubjectClassMetadata(e){return this.getSubjectClassMetadataFromSDNA(e)}async getSubjectClassMetadataFromSDNA(e){try{let t=await this.getShacl(e);if(!t)return console.warn(`No SHACL metadata found for ${e}`),null;let i=[],n=[],a=new Map,o=new Map,s=new Set;for(let c of t.properties){if(!c.path||!c.name)continue;c.writable&&s.add(c.path),c.adder&&c.adder.length>0?o.set(c.name,{predicate:c.path}):a.set(c.name,{predicate:c.path,resolveLanguage:c.resolveLanguage})}if(t.constructor_actions){for(let c of t.constructor_actions)if(c.predicate){i.push(c.predicate);let l=s.has(c.predicate);c.target&&c.target!=="value"&&!l?n.push({predicate:c.predicate,target:c.target}):n.push({predicate:c.predicate})}}return{requiredPredicates:i,requiredTriples:n,properties:a,relations:o}}catch(t){return console.error(`Error getting SHACL metadata for ${e}:`,t),null}}async findInstancesByMetadata(e){if(e.requiredTriples.length===0){let o=await this.get(new K({})),s=new Set(o.map(c=>c.data.source));return Array.from(s).map(c=>({base:c}))}let t=e.requiredTriples[0],i;t.target?i=new K({predicate:t.predicate,target:t.target}):i=new K({predicate:t.predicate});let n=await this.get(i),a=[...new Set(n.map(o=>o.data.source))];for(let o=1;o<e.requiredTriples.length;o++){let s=e.requiredTriples[o],c=[];for(let l of a){let u;s.target?u=new K({source:l,predicate:s.predicate,target:s.target}):u=new K({source:l,predicate:s.predicate}),(await this.get(u)).length>0&&c.push(l)}a=c}return a.map(o=>({base:o}))}async getPropertyValueViaSparql(e,t,i){let n=await this.getSubjectClassMetadataFromSDNA(t);if(!n)return;let a=n.properties.get(i);if(!a)return;let o=await this.get(new K({source:e,predicate:a.predicate}));if(!o||o.length===0)return;let s=o[0].data.target;if(a.resolveLanguage&&s)try{let c=await this.getExpression(s);try{return JSON.parse(c.data)}catch{return c.data}}catch{return s}return s}async getRelationValuesViaSparql(e,t,i){let n=await this.getSubjectClassMetadataFromSDNA(t);if(!n)return[];let a=n.relations.get(i);if(!a)return[];let o=await this.get(new K({source:e,predicate:a.predicate}));if(!o||o.length===0)return[];o.sort((c,l)=>new Date(c.timestamp).getTime()-new Date(l.timestamp).getTime());let s=o.map(c=>c.data.target).filter(c=>c!==""&&c!=="");if(a.condition&&s.length>0)try{let c=[];for(let l of s){let u=a.condition.replace(/\$perspective/g,`'${this.uuid}'`).replace(/\$base/g,`'${e}'`).replace(/Target/g,`'${l.replace(/'/g,"\\'")}'`),d=u.match(/in\.uri\s*=\s*'([^']+)'/),f=u.match(/predicate\s*=\s*'([^']+)'/),p=u.match(/out\.uri\s*=\s*'([^']+)'/);if(d||f||p){let h={};d&&(h.source=d[1]),f&&(h.predicate=f[1]),p&&(h.target=p[1]),(await this.get(new K(h))).length>0&&c.push(l)}else c.push(l)}s=c}catch(c){console.warn(`Failed to apply condition filter for ${i}:`,c)}if(a.instanceFilter)try{let c=await this.getSubjectClassMetadataFromSDNA(a.instanceFilter);return c?await this.batchCheckSubjectInstances(s,c):this.filterInstancesSequential(s,a.instanceFilter)}catch{return this.filterInstancesSequential(s,a.instanceFilter)}return s}async batchCheckSubjectInstances(e,t){if(e.length===0)return[];if(t.requiredTriples.length===0){let a=[];for(let o of e)(await this.get(new K({source:o}))).length>0&&a.push(o);return a}let i=[];for(let a of t.requiredTriples){let o=new Set;for(let s of e){let c;a.target?c=new K({source:s,predicate:a.predicate,target:a.target}):c=new K({source:s,predicate:a.predicate}),(await this.get(c)).length>0&&o.add(s)}i.push(o)}return i.length===0?e:e.filter(a=>i.every(o=>o.has(a)))}async filterInstancesSequential(e,t){let i=[];for(let n of e)try{await this.isSubjectInstance(n,t)&&i.push(n)}catch{continue}return i}async getAllSubjectInstances(e){let t=[],i=typeof e=="function";typeof e=="string"?t=[e]:i?t=[e.name]:t=await this.subjectClassesByTemplate(e);let n=[];for(let a of t){let o=await this.getSubjectClassMetadataFromSDNA(a);if(o){let s=await this.findInstancesByMetadata(o);for(let c of s||[])try{let l;i?(l=new e(this,c.base),await l.get()):(l=new _o(this,c.base,a),await l.init()),n.push(l)}catch{}}}return n}async getAllSubjectProxies(e){let t=[];typeof e=="string"?t=[e]:t=await this.subjectClassesByTemplate(e);let i=[];for(let n of t){let a=await this.getSubjectClassMetadataFromSDNA(n);if(a){let o=await this.findInstancesByMetadata(a);for(let s of o||[])try{let c=new _o(this,s.base,n);await c.init(),i.push(c)}catch{}}}return i}async findClassByProperties(e){let t=[],i=[],a=Object.getPrototypeOf(e)?.constructor,o=a?sn(a):{};Object.keys(o).length>0?t=Object.keys(o):t=Object.keys(e).filter(p=>!Array.isArray(e[p]));let s=a?Object.fromEntries(Object.entries(hr(a)).filter(([,p])=>p.kind==="hasMany"||p.kind==="belongsToMany")):{};if(Object.keys(s).length>0?i=Object.keys(s).filter(p=>p!=="isSubjectInstance"):i=Object.keys(e).filter(p=>Array.isArray(e[p])&&p!=="isSubjectInstance"),t.length===0&&i.length===0)return null;let c=await this.get(new K({predicate:"rdf://type",target:"ad4m://SubjectClass"})),l=await this.get(new K({predicate:"sh://property"})),u=await this.get(new K({predicate:"sh://collection"})),d=[...c.map(p=>({shape_source:p.data.source,predicate:p.data.predicate,target:p.data.target})),...l.map(p=>({shape_source:p.data.source,predicate:p.data.predicate,target:p.data.target})),...u.map(p=>({shape_source:p.data.source,predicate:p.data.predicate,target:p.data.target}))];if(d.length===0)return null;let f=new Map;for(let p of d)if(p.predicate==="rdf://type"&&p.target==="ad4m://SubjectClass"){let h=p.shape_source,m=h.indexOf("://");if(m<0)continue;let y=h.substring(m+3).split("/").pop();if(!y)continue;f.set(y,{shapeUri:h,properties:[],relations:[]})}for(let p of d)if(p.predicate==="sh://property"||p.predicate==="sh://collection"){for(let[h,m]of f)if(p.shape_source.endsWith(`${h}Shape`)){let y=p.target.lastIndexOf(".");if(y<0)continue;let b=p.target.substring(y+1);p.predicate==="sh://property"?m.properties.push(b):m.relations.push(b)}}for(let[p,h]of f){let m=t.every(b=>h.properties.includes(b)),y=i.every(b=>h.relations.includes(b));if(m&&y)return p}return null}async subjectClassesByTemplate(e){try{let t=e.className||e.constructor?.className||e.constructor?.prototype?.className;if(t&&(await this.subjectClasses()).includes(t))return[t]}catch(t){console.warn("subjectClassesByTemplate: className lookup failed:",t)}try{let t=await this.findClassByProperties(e);if(t)return[t]}catch(t){console.warn("subjectClassesByTemplate: property matching failed:",t)}return[]}async ensureSDNASubjectClass(e){return this.ensureSubjectClass(e)}async ensureSubjectClass(e){let t=e.className||e.prototype?.className||e.name;if(O(this,eo,"f").has(t))return;if(!e.generateSHACL)throw new Error(`Class ${e.name} must have generateSHACL(). Use @Model decorator.`);let{shape:i}=e.generateSHACL(),n=JSON.stringify(i.toJSON());await this.addSdna(t,"","subject_class",n),O(this,eo,"f").add(t)}clearEnsuredSubjectClasses(){O(this,eo,"f").clear()}getNeighbourhoodProxy(){return O(this,me,"f").getNeighbourhoodProxy(O(this,ie,"f").uuid)}get ai(){return O(this,me,"f").aiClient}async subscribeInfer(e){let t=new Ac(this.uuid,e,O(this,me,"f"));return await t.subscribe(),await t.initialized,t}async subscribeQuery(e){let t=new Ac(this.uuid,e,O(this,me,"f"));return await t.subscribe(),await t.initialized,t}};ie=new WeakMap,me=new WeakMap,Hi=new WeakMap,zi=new WeakMap,Wi=new WeakMap,Xa=new WeakMap,eo=new WeakMap;var ei=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},X=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},ce,to,ro,io,cc,no,lc,uc,ft=`
110
- author
111
- timestamp
112
- status
113
- data { source, predicate, target }
114
- proof { valid, invalid, signature, key }
115
- `,Gn=`
116
- uuid
117
- name
118
- sharedUrl
119
- state
120
- owners
121
- neighbourhood {
122
- data {
123
- linkLanguage
124
- meta {
125
- links
126
- {
127
- author
128
- timestamp
129
- data { source, predicate, target }
130
- proof { valid, invalid, signature, key }
131
- }
132
- }
133
- }
134
- author
135
- }
136
- `,Ic=class{constructor(e,t=!0){ce.set(this,void 0),to.set(this,void 0),ro.set(this,void 0),io.set(this,void 0),cc.set(this,void 0),no.set(this,void 0),lc.set(this,void 0),uc.set(this,void 0),ei(this,ce,e,"f"),ei(this,to,[],"f"),ei(this,ro,[],"f"),ei(this,io,[],"f"),ei(this,cc,[],"f"),t&&(this.subscribePerspectiveAdded(),this.subscribePerspectiveUpdated(),this.subscribePerspectiveRemoved())}setExpressionClient(e){ei(this,no,e,"f")}setNeighbourhoodClient(e){ei(this,lc,e,"f")}setAIClient(e){ei(this,uc,e,"f")}get aiClient(){return X(this,uc,"f")}async all(){let{perspectives:e}=k(await X(this,ce,"f").query({query:x`query perspectives {
137
- perspectives {
138
- ${Gn}
139
- }
140
- }`}));return e.map(t=>new ia(t,this))}async byUUID(e){let{perspective:t}=k(await X(this,ce,"f").query({query:x`query perspective($uuid: String!) {
141
- perspective(uuid: $uuid) {
142
- ${Gn}
143
- }
144
- }`,variables:{uuid:e}}));return t?new ia(t,this):null}async snapshotByUUID(e){let{perspectiveSnapshot:t}=k(await X(this,ce,"f").query({query:x`query perspectiveSnapshot($uuid: String!) {
145
- perspectiveSnapshot(uuid: $uuid) {
146
- links { ${ft} }
147
- }
148
- }`,variables:{uuid:e}}));return t}async publishSnapshotByUUID(e){let{perspectivePublishSnapshot:t}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectivePublishSnapshot($uuid: String!) {
149
- perspectivePublishSnapshot(uuid: $uuid)
150
- }`,variables:{uuid:e}}));return t}async queryLinks(e,t){let{perspectiveQueryLinks:i}=k(await X(this,ce,"f").query({query:x`query perspectiveQueryLinks($uuid: String!, $query: LinkQuery!) {
151
- perspectiveQueryLinks(query: $query, uuid: $uuid) {
152
- ${ft}
153
- }
154
- }`,variables:{uuid:e,query:t}}));return i}async queryProlog(e,t){let{perspectiveQueryProlog:i}=k(await X(this,ce,"f").query({query:x`query perspectiveQueryProlog($uuid: String!, $query: String!) {
155
- perspectiveQueryProlog(uuid: $uuid, query: $query)
156
- }`,variables:{uuid:e,query:t}}));return JSON.parse(i)}async querySparql(e,t){let{perspectiveQuerySparql:i}=k(await X(this,ce,"f").query({query:x`query perspectiveQuerySparql($uuid: String!, $query: String!) {
157
- perspectiveQuerySparql(uuid: $uuid, query: $query)
158
- }`,variables:{uuid:e,query:t}}));return JSON.parse(i)}async subscribeQuery(e,t){let{perspectiveSubscribeQuery:i}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveSubscribeQuery($uuid: String!, $query: String!) {
159
- perspectiveSubscribeQuery(uuid: $uuid, query: $query) {
160
- subscriptionId
161
- result
162
- }
163
- }`,variables:{uuid:e,query:t}})),{subscriptionId:n,result:a}=i,o=a,s=!1;o.startsWith("#init#")&&(o=o.substring(6),s=!0);try{o=JSON.parse(o)}catch(c){console.error("Error parsing perspectiveSubscribeQuery result:",c)}return{subscriptionId:n,result:o,isInit:s}}subscribeToQueryUpdates(e,t){let i=X(this,ce,"f").subscribe({query:x`
164
- subscription perspectiveQuerySubscription($subscriptionId: String!) {
165
- perspectiveQuerySubscription(subscriptionId: $subscriptionId)
166
- }
167
- `,variables:{subscriptionId:e}}).subscribe({next:n=>{if(n.data&&n.data.perspectiveQuerySubscription){let a=n.data.perspectiveQuerySubscription,o=!1;a.startsWith("#init#")&&(a=a.substring(6),o=!0);try{a=JSON.parse(a),o&&typeof a=="object"&&(a.isInit=!0)}catch(s){console.error("Error parsing perspectiveQuerySubscription:",s)}t(a)}},error:n=>console.error("Error in query subscription:",n)});return()=>i.unsubscribe()}async keepAliveQuery(e,t){let{perspectiveKeepAliveQuery:i}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveKeepAliveQuery($uuid: String!, $subscriptionId: String!) {
168
- perspectiveKeepAliveQuery(uuid: $uuid, subscriptionId: $subscriptionId)
169
- }`,variables:{uuid:e,subscriptionId:t}}));return i}async disposeQuerySubscription(e,t){let{perspectiveDisposeQuerySubscription:i}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveDisposeQuerySubscription($uuid: String!, $subscriptionId: String!) {
170
- perspectiveDisposeQuerySubscription(uuid: $uuid, subscriptionId: $subscriptionId)
171
- }`,variables:{uuid:e,subscriptionId:t}}));return i}async add(e){let{perspectiveAdd:t}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveAdd($name: String!) {
172
- perspectiveAdd(name: $name) {
173
- ${Gn}
174
- }
175
- }`,variables:{name:e}}));return new ia(t,this)}async update(e,t){let{perspectiveUpdate:i}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveUpdate($uuid: String!, $name: String!) {
176
- perspectiveUpdate(uuid: $uuid, name: $name) {
177
- ${Gn}
178
- }
179
- }`,variables:{uuid:e,name:t}}));return new ia(i,this)}async remove(e){return k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveRemove($uuid: String!) {
180
- perspectiveRemove(uuid: $uuid)
181
- }`,variables:{uuid:e}}))}async addLink(e,t,i="shared",n){let{perspectiveAddLink:a}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String!, $batchId: String) {
182
- perspectiveAddLink(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
183
- ${ft}
184
- }
185
- }`,variables:{uuid:e,link:t,status:i,batchId:n}}));return a}async addLinks(e,t,i="shared",n){let{perspectiveAddLinks:a}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String!, $batchId: String) {
186
- perspectiveAddLinks(uuid: $uuid, links: $links, status: $status, batchId: $batchId) {
187
- ${ft}
188
- }
189
- }`,variables:{uuid:e,links:t,status:i,batchId:n}}));return a}async removeLinks(e,t,i){let{perspectiveRemoveLinks:n}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]!, $batchId: String) {
190
- perspectiveRemoveLinks(uuid: $uuid, links: $links, batchId: $batchId) {
191
- ${ft}
192
- }
193
- }`,variables:{uuid:e,links:t,batchId:i}}));return n}async linkMutations(e,t,i){let{perspectiveLinkMutations:n}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveLinkMutations($uuid: String!, $mutations: LinkMutations!, $status: String){
194
- perspectiveLinkMutations(mutations: $mutations, uuid: $uuid, status: $status) {
195
- additions {
196
- ${ft}
197
- }
198
- removals {
199
- ${ft}
200
- }
201
- }
202
- }`,variables:{uuid:e,mutations:t,status:i}}));return n}async addLinkExpression(e,t,i="shared",n){let{perspectiveAddLinkExpression:a}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String!, $batchId: String) {
203
- perspectiveAddLinkExpression(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
204
- ${ft}
205
- }
206
- }`,variables:{uuid:e,link:t,status:i,batchId:n}}));return a}async updateLink(e,t,i,n){let{perspectiveUpdateLink:a}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveUpdateLink($uuid: String!, $oldLink: LinkExpressionInput!, $newLink: LinkInput!, $batchId: String) {
207
- perspectiveUpdateLink(uuid: $uuid, oldLink: $oldLink, newLink: $newLink, batchId: $batchId) {
208
- ${ft}
209
- }
210
- }`,variables:{uuid:e,oldLink:t,newLink:i,batchId:n}}));return a}async removeLink(e,t,i){delete t.__typename,delete t.data.__typename,delete t.proof.__typename,delete t.status;let{perspectiveRemoveLink:n}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveRemoveLink($link: LinkExpressionInput!, $uuid: String!, $batchId: String) {
211
- perspectiveRemoveLink(link: $link, uuid: $uuid, batchId: $batchId)
212
- }`,variables:{uuid:e,link:t,batchId:i}}));return n}async addSdna(e,t,i,n,a){return k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveAddSdna($uuid: String!, $name: String!, $sdnaCode: String, $sdnaType: String!, $shaclJson: String) {
213
- perspectiveAddSdna(uuid: $uuid, name: $name, sdnaCode: $sdnaCode, sdnaType: $sdnaType, shaclJson: $shaclJson)
214
- }`,variables:{uuid:e,name:t,sdnaCode:i||"",sdnaType:n,shaclJson:a}})).perspectiveAddSdna}async executeCommands(e,t,i,n,a){return k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveExecuteCommands($uuid: String!, $commands: String!, $expression: String!, $parameters: String, $batchId: String) {
215
- perspectiveExecuteCommands(uuid: $uuid, commands: $commands, expression: $expression, parameters: $parameters, batchId: $batchId)
216
- }`,variables:{uuid:e,commands:t,expression:i,parameters:n,batchId:a}})).perspectiveExecuteCommands}async createSubject(e,t,i,n,a){return k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveCreateSubject($uuid: String!, $subjectClass: String!, $expressionAddress: String!, $initialValues: String, $batchId: String) {
217
- perspectiveCreateSubject(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress, initialValues: $initialValues, batchId: $batchId)
218
- }`,variables:{uuid:e,subjectClass:t,expressionAddress:i,initialValues:n,batchId:a}})).perspectiveCreateSubject}async getSubjectData(e,t,i){return k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveGetSubjectData($uuid: String!, $subjectClass: String!, $expressionAddress: String!) {
219
- perspectiveGetSubjectData(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress)
220
- }`,variables:{uuid:e,subjectClass:t,expressionAddress:i}})).perspectiveGetSubjectData}async getExpression(e){return await X(this,no,"f").get(e)}async createExpression(e,t){return await X(this,no,"f").create(e,t)}addPerspectiveAddedListener(e){X(this,to,"f").push(e)}subscribePerspectiveAdded(){X(this,ce,"f").subscribe({query:x` subscription {
221
- perspectiveAdded { ${Gn} }
222
- }
223
- `}).subscribe({next:e=>{X(this,to,"f").forEach(t=>{t(e.data.perspectiveAdded)})},error:e=>console.error(e)})}addPerspectiveUpdatedListener(e){X(this,ro,"f").push(e)}subscribePerspectiveUpdated(){X(this,ce,"f").subscribe({query:x` subscription {
224
- perspectiveUpdated { ${Gn} }
225
- }
226
- `}).subscribe({next:e=>{X(this,ro,"f").forEach(t=>{t(e.data.perspectiveUpdated)})},error:e=>console.error(e)})}addPerspectiveSyncedListener(e){X(this,cc,"f").push(e)}async addPerspectiveSyncStateChangeListener(e,t){X(this,ce,"f").subscribe({query:x` subscription {
227
- perspectiveSyncStateChange(uuid: "${e}")
228
- }
229
- `}).subscribe({next:i=>{t.forEach(n=>{n(i.data.perspectiveSyncStateChange)})},error:i=>console.error(i)}),await new Promise(i=>setTimeout(i,500))}addPerspectiveRemovedListener(e){X(this,io,"f").push(e)}subscribePerspectiveRemoved(){X(this,ce,"f").subscribe({query:x` subscription {
230
- perspectiveRemoved
231
- }
232
- `}).subscribe({next:e=>{X(this,io,"f").forEach(t=>{t(e.data.perspectiveRemoved)})},error:e=>console.error(e)})}async addPerspectiveLinkAddedListener(e,t){X(this,ce,"f").subscribe({query:x` subscription {
233
- perspectiveLinkAdded(uuid: "${e}") { ${ft} }
234
- }
235
- `}).subscribe({next:i=>{t.forEach(n=>{n(i.data.perspectiveLinkAdded)})},error:i=>console.error(i)}),await new Promise(i=>setTimeout(i,500))}async addPerspectiveLinkRemovedListener(e,t){X(this,ce,"f").subscribe({query:x` subscription {
236
- perspectiveLinkRemoved(uuid: "${e}") { ${ft} }
237
- }
238
- `}).subscribe({next:i=>{t.forEach(n=>{i.data.perspectiveLinkRemoved.status||delete i.data.perspectiveLinkRemoved.status,n(i.data.perspectiveLinkRemoved)})},error:i=>console.error(i)}),await new Promise(i=>setTimeout(i,500))}async addPerspectiveLinkUpdatedListener(e,t){X(this,ce,"f").subscribe({query:x` subscription {
239
- perspectiveLinkUpdated(uuid: "${e}") {
240
- oldLink {
241
- ${ft}
242
- }
243
- newLink {
244
- ${ft}
245
- }
246
- }
247
- }
248
- `}).subscribe({next:i=>{t.forEach(n=>{i.data.perspectiveLinkUpdated.newLink.status||delete i.data.perspectiveLinkUpdated.newLink.status,i.data.perspectiveLinkUpdated.oldLink.status||delete i.data.perspectiveLinkUpdated.oldLink.status,n(i.data.perspectiveLinkUpdated)})},error:i=>console.error(i)}),await new Promise(i=>setTimeout(i,500))}getNeighbourhoodProxy(e){return new Wu(X(this,lc,"f"),e)}async createBatch(e){let{perspectiveCreateBatch:t}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveCreateBatch($uuid: String!) {
249
- perspectiveCreateBatch(uuid: $uuid)
250
- }`,variables:{uuid:e}}));return t}async commitBatch(e,t){let{perspectiveCommitBatch:i}=k(await X(this,ce,"f").mutate({mutation:x`mutation perspectiveCommitBatch($uuid: String!, $batchId: String!) {
251
- perspectiveCommitBatch(uuid: $uuid, batchId: $batchId) {
252
- additions {
253
- ${ft}
254
- }
255
- removals {
256
- ${ft}
257
- }
258
- }
259
- }`,variables:{uuid:e,batchId:t}}));return i}};ce=new WeakMap,to=new WeakMap,ro=new WeakMap,io=new WeakMap,cc=new WeakMap,no=new WeakMap,lc=new WeakMap,uc=new WeakMap;var Kn=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},Y=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},ne,ao,oo,so,co,lo,Wa=`
260
- did
261
- directMessageLanguage
262
- perspective {
263
- links {
264
- author, timestamp,
265
- proof {
266
- signature, key, valid, invalid
48
+ FILTER(?s = <${s}> || STRSTARTS(STR(?s), "${n}"))
49
+ }`,c=(await this.querySparql(a)||[]).map(l=>({source:l.s,predicate:l.p,target:l.o}));return li.fromLinks(c,s)}async subjectClasses(){try{let e=(await this.get(new Q({predicate:"rdf://type",target:"ad4m://SubjectClass"}))).map(r=>{let n=r.data.source.split("://");return n[n.length-1].split("/").pop()||""}).filter(r=>r.length>0);return[...new Set(e)]}catch(t){return console.warn("subjectClasses: SHACL lookup failed:",t),[]}}async stringOrTemplateObjectToSubjectClassName(t){if(typeof t=="string")return t;{let e=await this.subjectClassesByTemplate(t);return e[0]?e[0]:t.className}}async createSubject(t,e,r,s){let n;if(typeof t=="string")n=t,await m(this,H,"f").createSubject(m(this,O,"f").uuid,JSON.stringify({className:n,initialValues:r}),e,r?JSON.stringify(r):void 0,s);else{let a=t,o=a.className||a.constructor?.className||a.constructor?.prototype?.className||await this.findClassByProperties(a);if(!o)throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");await m(this,H,"f").createSubject(m(this,O,"f").uuid,JSON.stringify({className:o,initialValues:r}),e,r?JSON.stringify(r):void 0,s)}return e}async getSubjectData(t,e){if(typeof t=="string")return JSON.parse(await m(this,H,"f").getSubjectData(m(this,O,"f").uuid,JSON.stringify({className:t}),e));let r=t,s=r.className||r.constructor?.className||r.constructor?.prototype?.className||await this.findClassByProperties(r);if(!s)throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");return JSON.parse(await m(this,H,"f").getSubjectData(m(this,O,"f").uuid,JSON.stringify({className:s}),e))}async getActionsFromSHACL(t,e){let r=this.escapeRegExp(t),s=new RegExp(`[/:#]${r}Shape$`),n=await this.get(new Q({predicate:e}));for(let a of n)if(s.test(a.data.source)){let o="literal:string:";if(a.data.target.startsWith(o)){let c=a.data.target.slice(o.length),l=c;try{l=decodeURIComponent(c)}catch{}try{return JSON.parse(l)}catch(d){return console.warn(`Failed to parse SHACL actions JSON for ${t}:`,d),null}}}return null}async removeSubject(t,e,r){let s=await this.stringOrTemplateObjectToSubjectClassName(t),n=await this.getActionsFromSHACL(s,"ad4m://destructor");if(!n)throw`No destructor found for subject class: ${s}. Make sure the class was registered with SHACL.`;await this.executeAction(n,e,void 0,r)}async isSubjectInstance(t,e){let r=await this.stringOrTemplateObjectToSubjectClassName(e),s=await this.getSubjectClassMetadata(r);if(!s)return console.warn(`isSubjectInstance: No SHACL metadata found for class ${r}`),!1;if(s.requiredTriples.length===0)return(await this.get(new Q({source:t}))).length>0;let n=s.requiredTriples.map((o,c)=>{let l=o.target?`<${o.target}>`:`?t${c}`;return`<${t}> <${o.predicate}> ${l} .`}).join(`
50
+ `);return await this.querySparql(`ASK WHERE {
51
+ ${n}
52
+ }`)===!0}async getSubjectClassMetadata(t){try{let e=await this.getShacl(t);if(!e)return console.warn(`No SHACL metadata found for ${t}`),null;let r=[],s=[],n=new Map,a=new Map,o=new Set;for(let c of e.properties){if(!c.path||!c.name)continue;c.writable&&o.add(c.path),c.adder&&c.adder.length>0?a.set(c.name,{predicate:c.path}):n.set(c.name,{predicate:c.path,resolveLanguage:c.resolveLanguage})}if(e.constructor_actions){for(let c of e.constructor_actions)if(c.predicate){r.push(c.predicate);let l=o.has(c.predicate);c.target&&c.target!=="value"&&!l?s.push({predicate:c.predicate,target:c.target}):s.push({predicate:c.predicate})}}return{requiredPredicates:r,requiredTriples:s,properties:n,relations:a}}catch(e){return console.error(`Error getting SHACL metadata for ${t}:`,e),null}}async findInstancesByMetadata(t){if(t.requiredTriples.length===0){let s=await this.get(new Q({})),n=new Set(s.map(a=>a.data.source));return Array.from(n).map(a=>({base:a}))}let e=t.requiredTriples.map((s,n)=>{let a=s.target?`<${s.target}>`:`?t${n}`;return`?base <${s.predicate}> ${a} .`}).join(`
53
+ `),r=await this.querySparql(`SELECT DISTINCT ?base WHERE {
54
+ ${e}
55
+ }`);return Array.isArray(r)?r.map(s=>({base:s.base})):[]}async getAllSubjectInstances(t){let e=[],r=typeof t=="function";typeof t=="string"?e=[t]:r?e=[t.name]:e=await this.subjectClassesByTemplate(t);let s=[];for(let n of e){let a=await this.getSubjectClassMetadata(n);if(a){let o=await this.findInstancesByMetadata(a);for(let c of o||[])try{let l;if(r)l=new t(this,c.base),await l.get();else{let d=await this.getSubjectData(n,c.base);l={id:c.base,...d}}s.push(l)}catch{}}}return s}async findClassByProperties(t){let e=[],r=[],n=Object.getPrototypeOf(t)?.constructor,a=n?pt(n):{};Object.keys(a).length>0?e=Object.keys(a):e=Object.keys(t).filter(d=>!Array.isArray(t[d]));let o=n?Object.fromEntries(Object.entries(ue(n)).filter(([,d])=>d.kind==="hasMany"||d.kind==="belongsToMany")):{};if(Object.keys(o).length>0?r=Object.keys(o).filter(d=>d!=="isSubjectInstance"):r=Object.keys(t).filter(d=>Array.isArray(t[d])&&d!=="isSubjectInstance"),e.length===0&&r.length===0)return null;let c=await this.querySparql(`
56
+ SELECT ?shape ?predicate ?target WHERE {
57
+ { ?shape <rdf://type> <ad4m://SubjectClass> . BIND(<rdf://type> AS ?predicate) BIND(<ad4m://SubjectClass> AS ?target) }
58
+ UNION
59
+ { ?shape <sh://property> ?target . BIND(<sh://property> AS ?predicate) }
60
+ UNION
61
+ { ?shape <sh://collection> ?target . BIND(<sh://collection> AS ?predicate) }
267
62
  }
268
- data {
269
- source, predicate, target
270
- }
271
- }
272
- }
273
- `,Vs=`
274
- requestId
275
- revoked
276
- auth {
277
- appName
278
- appDesc
279
- appUrl
280
- appIconPath
281
- capabilities {
282
- with {
283
- domain
284
- pointers
285
- }
286
- can
287
- }
288
- }
289
- `,Jn=`
290
- isInitialized
291
- isUnlocked
292
- did
293
- didDocument
294
- error
295
- `,Qs=`
296
- did
297
- didSigningKeyId
298
- deviceKeyType
299
- deviceKey
300
- deviceKeySignedByDid
301
- didSignedByDeviceKey
302
- `,p0=`
303
- signature
304
- publicKey
305
- `,Oo=class{constructor(e,t=!0){ne.set(this,void 0),ao.set(this,void 0),oo.set(this,void 0),so.set(this,void 0),co.set(this,void 0),lo.set(this,void 0),Kn(this,ne,e,"f"),Kn(this,oo,[],"f"),Kn(this,so,[],"f"),Kn(this,ao,[],"f"),Kn(this,co,[],"f"),Kn(this,lo,[],"f"),t&&(this.subscribeAgentUpdated(),this.subscribeAgentStatusChanged(),this.subscribeAppsChanged())}async me(){let{agent:e}=k(await Y(this,ne,"f").query({query:x`query agent { agent { ${Wa} } }`})),t=new li(e.did,e.perspective);return t.directMessageLanguage=e.directMessageLanguage,t}async status(){let{agentStatus:e}=k(await Y(this,ne,"f").query({query:x`query agentStatus {
306
- agentStatus {
307
- ${Jn}
308
- }
309
- }`}));return new zt(e)}async generate(e){let{agentGenerate:t}=k(await Y(this,ne,"f").mutate({mutation:x`mutation agentGenerate(
310
- $passphrase: String!
311
- ) {
312
- agentGenerate(passphrase: $passphrase) {
313
- ${Jn}
314
- }
315
- }`,variables:{passphrase:e}}));return new zt(t)}async import(e){let{did:t,didDocument:i,keystore:n,passphrase:a}=e,{agentImport:o}=k(await Y(this,ne,"f").mutate({mutation:x`mutation agentImport(
316
- $did: String!,
317
- $didDocument: String!,
318
- $keystore: String!,
319
- $passphrase: String!
320
- ) {
321
- agentImport(did: $did, didDocument: $didDocument, keystore: $keystore, passphrase: $passphrase) {
322
- ${Jn}
323
- }
324
- }`,variables:{did:t,didDocument:i,keystore:n,passphrase:a}}));return new zt(o)}async lock(e){let{agentLock:t}=k(await Y(this,ne,"f").mutate({mutation:x`mutation agentLock($passphrase: String!) {
325
- agentLock(passphrase: $passphrase) {
326
- ${Jn}
327
- }
328
- }`,variables:{passphrase:e}}));return new zt(t)}async unlock(e,t=!0){let{agentUnlock:i}=k(await Y(this,ne,"f").mutate({mutation:x`mutation agentUnlock($passphrase: String!, $holochain: Boolean!) {
329
- agentUnlock(passphrase: $passphrase, holochain: $holochain) {
330
- ${Jn}
331
- }
332
- }`,variables:{passphrase:e,holochain:t}}));return new zt(i)}async byDID(e){let{agentByDID:t}=k(await Y(this,ne,"f").query({query:x`query agentByDID($did: String!) {
333
- agentByDID(did: $did) {
334
- ${Wa}
335
- }
336
- }`,variables:{did:e}}));return t}async updatePublicPerspective(e){let t=JSON.parse(JSON.stringify(e));delete t.__typename,t.links.forEach(o=>{delete o.__typename,delete o.data.__typename,delete o.proof.__typename,delete o.status});let{agentUpdatePublicPerspective:i}=k(await Y(this,ne,"f").mutate({mutation:x`mutation agentUpdatePublicPerspective($perspective: PerspectiveInput!) {
337
- agentUpdatePublicPerspective(perspective: $perspective) {
338
- ${Wa}
339
- }
340
- }`,variables:{perspective:t}})),n=i,a=new li(n.did,n.perspective);return a.directMessageLanguage=n.directMessageLanguage,a}async mutatePublicPerspective(e){let t=new Ic(Y(this,ne,"f")),i=new Oo(Y(this,ne,"f")),n=await t.add("Agent Perspective Proxy"),a=await i.me();a.perspective&&await n.loadSnapshot(a.perspective);for(let c of e.additions)await n.add(c);for(let c of e.removals)await n.remove(c);let o=await n.snapshot(),s=await this.updatePublicPerspective(o);return await t.remove(n.uuid),s}async updateDirectMessageLanguage(e){let{agentUpdateDirectMessageLanguage:t}=k(await Y(this,ne,"f").mutate({mutation:x`mutation agentUpdateDirectMessageLanguage($directMessageLanguage: String!) {
341
- agentUpdateDirectMessageLanguage(directMessageLanguage: $directMessageLanguage) {
342
- ${Wa}
343
- }
344
- }`,variables:{directMessageLanguage:e}})),i=t,n=new li(i.did,i.perspective);return n.directMessageLanguage=i.directMessageLanguage,n}async addEntanglementProofs(e){let{agentAddEntanglementProofs:t}=k(await Y(this,ne,"f").mutate({mutation:x`mutation agentAddEntanglementProofs($proofs: [EntanglementProofInput!]!) {
345
- agentAddEntanglementProofs(proofs: $proofs) {
346
- ${Qs}
347
- }
348
- }`,variables:{proofs:e}}));return t}async deleteEntanglementProofs(e){let{agentDeleteEntanglementProofs:t}=k(await Y(this,ne,"f").mutate({mutation:x`mutation agentDeleteEntanglementProofs($proofs: [EntanglementProofInput!]!) {
349
- agentDeleteEntanglementProofs(proofs: $proofs) {
350
- ${Qs}
351
- }
352
- }`,variables:{proofs:e}}));return t}async getEntanglementProofs(){let{agentGetEntanglementProofs:e}=k(await Y(this,ne,"f").query({query:x`query agentGetEntanglementProofs {
353
- agentGetEntanglementProofs {
354
- ${Qs}
355
- }
356
- }`}));return e}async entanglementProofPreFlight(e,t){let{agentEntanglementProofPreFlight:i}=k(await Y(this,ne,"f").mutate({mutation:x`mutation agentEntanglementProofPreFlight($deviceKey: String!, $deviceKeyType: String!) {
357
- agentEntanglementProofPreFlight(deviceKey: $deviceKey, deviceKeyType: $deviceKeyType) {
358
- ${Qs}
359
- }
360
- }`,variables:{deviceKey:e,deviceKeyType:t}}));return i}addUpdatedListener(e){Y(this,oo,"f").push(e)}addAppChangedListener(e){Y(this,ao,"f").push(e)}subscribeAgentUpdated(){Y(this,ne,"f").subscribe({query:x` subscription {
361
- agentUpdated { ${Wa} }
362
- }
363
- `}).subscribe({next:e=>{let t=e.data.agentUpdated;Y(this,oo,"f").forEach(i=>{i(t)})},error:e=>console.error(e)})}subscribeAppsChanged(){Y(this,ne,"f").subscribe({query:x` subscription {
364
- agentAppsChanged {
365
- ${Vs}
366
- }
367
- }
368
- `}).subscribe({next:e=>{Y(this,ao,"f").forEach(t=>{t()})},error:e=>console.error(e)})}addAgentStatusChangedListener(e){Y(this,so,"f").push(e)}subscribeAgentStatusChanged(){Y(this,ne,"f").subscribe({query:x` subscription {
369
- agentStatusChanged { ${Jn} }
370
- }
371
- `}).subscribe({next:e=>{let t=e.data.agentStatusChanged;Y(this,so,"f").forEach(i=>{i(t)})},error:e=>console.error(e)})}addHostingUserInfoChangedListener(e){Y(this,co,"f").push(e)}subscribeHostingUserInfoChanged(){Y(this,ne,"f").subscribe({query:x`subscription {
372
- runtimeHostingUserInfoChanged {
373
- email
374
- remainingCredits
375
- hotWalletAddress
376
- freeAccess
377
- }
378
- }`}).subscribe({next:e=>{let t=e.data.runtimeHostingUserInfoChanged;Y(this,co,"f").forEach(i=>i(t))},error:e=>console.error(e)})}addComputeLogUpdatedListener(e){Y(this,lo,"f").push(e)}subscribeComputeLogUpdated(){Y(this,ne,"f").subscribe({query:x`subscription {
379
- runtimeComputeLogUpdated {
380
- id
381
- userEmail
382
- timestamp
383
- operation
384
- summary
385
- cost
386
- creditsAfter
387
- }
388
- }`}).subscribe({next:e=>{let t=e.data.runtimeComputeLogUpdated;Y(this,lo,"f").forEach(i=>i(t))},error:e=>console.error(e)})}async requestCapability(e){let{agentRequestCapability:t}=k(await Y(this,ne,"f").mutate({mutation:x`
389
- mutation agentRequestCapability($authInfo: AuthInfoInput!) {
390
- agentRequestCapability(authInfo: $authInfo)
391
- }
392
- `,variables:{authInfo:e}}));return t}async permitCapability(e){let{agentPermitCapability:t}=k(await Y(this,ne,"f").mutate({mutation:x`
393
- mutation agentPermitCapability($auth: String!) {
394
- agentPermitCapability(auth: $auth)
395
- }
396
- `,variables:{auth:e}}));return t}async generateJwt(e,t){let{agentGenerateJwt:i}=k(await Y(this,ne,"f").mutate({mutation:x`
397
- mutation agentGenerateJwt($requestId: String!, $rand: String!) {
398
- agentGenerateJwt(requestId: $requestId, rand: $rand)
399
- }
400
- `,variables:{requestId:e,rand:t}}));return i}async getApps(){let{agentGetApps:e}=k(await Y(this,ne,"f").mutate({mutation:x`query agentGetApps {
401
- agentGetApps {
402
- ${Vs}
403
- }
404
- }`}));return e}async removeApp(e){let{agentRemoveApp:t}=k(await Y(this,ne,"f").mutate({mutation:x`mutation agentRemoveApp($requestId: String!) {
405
- agentRemoveApp(requestId: $requestId) {
406
- ${Vs}
407
- }
408
- }`,variables:{requestId:e}}));return t}async revokeToken(e){let{agentRevokeToken:t}=k(await Y(this,ne,"f").mutate({mutation:x`mutation agentRevokeToken($requestId: String!) {
409
- agentRevokeToken(requestId: $requestId) {
410
- ${Vs}
411
- }
412
- }`,variables:{requestId:e}}));return t}async isLocked(){let{agentIsLocked:e}=k(await Y(this,ne,"f").mutate({mutation:x`
413
- query agentIsLocked {
414
- agentIsLocked
415
- }
416
- `}));return e}async signMessage(e){let{agentSignMessage:t}=k(await Y(this,ne,"f").mutate({mutation:x`mutation agentSignMessage($message: String!) {
417
- agentSignMessage(message: $message) {
418
- ${p0}
419
- }
420
- }`,variables:{message:e}}));return t}async createUser(e,t,i){let{runtimeCreateUser:n}=k(await Y(this,ne,"f").mutate({mutation:x`mutation runtimeCreateUser($email: String!, $password: String!, $appInfo: AuthInfoInput) {
421
- runtimeCreateUser(email: $email, password: $password, appInfo: $appInfo) {
422
- did
423
- success
424
- error
425
- }
426
- }`,variables:{email:e,password:t,appInfo:i}}));return n}async loginUser(e,t){let{runtimeLoginUser:i}=k(await Y(this,ne,"f").mutate({mutation:x`mutation runtimeLoginUser($email: String!, $password: String!) {
427
- runtimeLoginUser(email: $email, password: $password)
428
- }`,variables:{email:e,password:t}}));return i}async requestLoginVerification(e,t){let{runtimeRequestLoginVerification:i}=k(await Y(this,ne,"f").mutate({mutation:x`mutation runtimeRequestLoginVerification($email: String!, $appInfo: AuthInfoInput) {
429
- runtimeRequestLoginVerification(email: $email, appInfo: $appInfo) {
430
- success
431
- message
432
- requiresPassword
433
- isExistingUser
434
- }
435
- }`,variables:{email:e,appInfo:t}}));return i}async verifyEmailCode(e,t,i){let{runtimeVerifyEmailCode:n}=k(await Y(this,ne,"f").mutate({mutation:x`mutation runtimeVerifyEmailCode($email: String!, $code: String!, $verificationType: String!) {
436
- runtimeVerifyEmailCode(email: $email, code: $code, verificationType: $verificationType)
437
- }`,variables:{email:e,code:t,verificationType:i}}));return n}async hostingUserInfo(){let{runtimeHostingUserInfo:e}=k(await Y(this,ne,"f").query({query:x`query runtimeHostingUserInfo {
438
- runtimeHostingUserInfo {
439
- email
440
- remainingCredits
441
- hotWalletAddress
442
- freeAccess
443
- }
444
- }`}));return e}async computeLog(e,t,i){let{runtimeComputeLog:n}=k(await Y(this,ne,"f").query({query:x`query runtimeComputeLog($since: String, $limit: Int, $userEmail: String) {
445
- runtimeComputeLog(since: $since, limit: $limit, userEmail: $userEmail) {
446
- id
447
- userEmail
448
- timestamp
449
- operation
450
- summary
451
- cost
452
- creditsAfter
453
- }
454
- }`,variables:{since:e,limit:t,userEmail:i},fetchPolicy:"network-only"}));return n}async setHotWalletAddress(e){let{runtimeSetHotWalletAddress:t}=k(await Y(this,ne,"f").mutate({mutation:x`mutation runtimeSetHotWalletAddress($address: String!) {
455
- runtimeSetHotWalletAddress(address: $address)
456
- }`,variables:{address:e}}));return t}async requestPayment(e){let{runtimeRequestPayment:t}=k(await Y(this,ne,"f").mutate({mutation:x`mutation runtimeRequestPayment($amountHOT: String!) {
457
- runtimeRequestPayment(amountHOT: $amountHOT) {
458
- success
459
- message
460
- }
461
- }`,variables:{amountHOT:e}}));return t}};ne=new WeakMap,ao=new WeakMap,oo=new WeakMap,so=new WeakMap,co=new WeakMap,lo=new WeakMap;var d0=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},ti=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},nr,hh=`
462
- name
463
- address
464
- settings
465
- icon { code }
466
- constructorIcon { code }
467
- settingsIcon { code }
468
- `,mh=`
469
- name
470
- address
471
- description
472
- author
473
- templated
474
- templateSourceLanguageAddress
475
- templateAppliedParams
476
- possibleTemplateParams
477
- sourceCodeLink
478
- `,Ku=class{constructor(e){nr.set(this,void 0),d0(this,nr,e,"f")}async byAddress(e){let{language:t}=k(await ti(this,nr,"f").query({query:x`query byAddress($address: String!) {
479
- language(address: $address) {
480
- ${hh}
481
- }
482
- }`,variables:{address:e}}));return t}async byFilter(e){let{languages:t}=k(await ti(this,nr,"f").query({query:x`query byFilter($filter: String!) {
483
- languages(filter: $filter) {
484
- ${hh}
485
- }
486
- }`,variables:{filter:e}}));return t}async all(){return this.byFilter("")}async writeSettings(e,t){let{languageWriteSettings:i}=k(await ti(this,nr,"f").mutate({mutation:x`mutation writeSettings($languageAddress: String!, $settings: String!) {
487
- languageWriteSettings(languageAddress: $languageAddress, settings: $settings)
488
- }`,variables:{languageAddress:e,settings:t}}));return i}async applyTemplateAndPublish(e,t){let{languageApplyTemplateAndPublish:i}=k(await ti(this,nr,"f").mutate({mutation:x`mutation languageApplyTemplateAndPublish(
489
- $sourceLanguageHash: String!,
490
- $templateData: String!,
491
- ) {
492
- languageApplyTemplateAndPublish(sourceLanguageHash: $sourceLanguageHash, templateData: $templateData) {
493
- name, address
494
- }
495
- }`,variables:{sourceLanguageHash:e,templateData:t}}));return i}async publish(e,t){let{languagePublish:i}=k(await ti(this,nr,"f").mutate({mutation:x`mutation languagePublish(
496
- $languagePath: String!,
497
- $languageMeta: LanguageMetaInput!,
498
- ) {
499
- languagePublish(languagePath: $languagePath, languageMeta: $languageMeta) {
500
- ${mh}
501
- }
502
- }`,variables:{languagePath:e,languageMeta:t}}));return i}async meta(e){let{languageMeta:t}=k(await ti(this,nr,"f").query({query:x`query languageMeta(
503
- $address: String!,
504
- ) {
505
- languageMeta(address: $address) {
506
- ${mh}
507
- }
508
- }`,variables:{address:e}}));return t}async source(e){let{languageSource:t}=k(await ti(this,nr,"f").query({query:x`query languageSource(
509
- $address: String!,
510
- ) {
511
- languageSource(address: $address)
512
- }`,variables:{address:e}}));return t}async remove(e){let{languageRemove:t}=k(await ti(this,nr,"f").mutate({mutation:x`mutation languageRemove(
513
- $address: String!,
514
- ) {
515
- languageRemove(address: $address)
516
- }`,variables:{address:e}}));return t}};nr=new WeakMap;var f0=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},ct=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},gt,ra,Ju=class{constructor(e){gt.set(this,void 0),ra.set(this,new Map),f0(this,gt,e,"f")}async publishFromPerspective(e,t,i){let{neighbourhoodPublishFromPerspective:n}=k(await ct(this,gt,"f").mutate({mutation:x`mutation neighbourhoodPublishFromPerspective(
517
- $linkLanguage: String!,
518
- $meta: PerspectiveInput!,
519
- $perspectiveUUID: String!
520
- ) {
521
- neighbourhoodPublishFromPerspective(
522
- linkLanguage: $linkLanguage,
523
- meta: $meta,
524
- perspectiveUUID: $perspectiveUUID
525
- )
526
- }`,variables:{perspectiveUUID:e,linkLanguage:t,meta:i}}));return n}async joinFromUrl(e){let{neighbourhoodJoinFromUrl:t}=k(await ct(this,gt,"f").mutate({mutation:x`mutation neighbourhoodJoinFromUrl($url: String!) {
527
- neighbourhoodJoinFromUrl(url: $url) {
528
- uuid
529
- name
530
- sharedUrl
531
- state
532
- neighbourhood {
533
- data {
534
- linkLanguage
535
- meta {
536
- links
537
- {
538
- author
539
- timestamp
540
- data { source, predicate, target }
541
- proof { valid, invalid, signature, key }
542
- }
543
- }
544
- }
545
- author
546
- }
547
- }
548
- }`,variables:{url:e}}));return t}async otherAgents(e){let{neighbourhoodOtherAgents:t}=k(await ct(this,gt,"f").query({query:x`query neighbourhoodOtherAgents($perspectiveUUID: String!) {
549
- neighbourhoodOtherAgents(perspectiveUUID: $perspectiveUUID)
550
- }`,variables:{perspectiveUUID:e}}));return t}async hasTelepresenceAdapter(e){let{neighbourhoodHasTelepresenceAdapter:t}=k(await ct(this,gt,"f").query({query:x`query neighbourhoodHasTelepresenceAdapter($perspectiveUUID: String!) {
551
- neighbourhoodHasTelepresenceAdapter(perspectiveUUID: $perspectiveUUID)
552
- }`,variables:{perspectiveUUID:e}}));return t}async onlineAgents(e){let{neighbourhoodOnlineAgents:t}=k(await ct(this,gt,"f").query({query:x`query neighbourhoodOnlineAgents($perspectiveUUID: String!) {
553
- neighbourhoodOnlineAgents(perspectiveUUID: $perspectiveUUID) {
554
- did
555
- status {
556
- author
557
- timestamp
558
- data {
559
- links {
560
- author
561
- timestamp
562
- data { source, predicate, target }
563
- proof { valid, invalid, signature, key }
564
- }
565
- }
566
- proof { valid, invalid, signature, key }
567
- }
568
- }
569
- }`,variables:{perspectiveUUID:e}}));return t}async setOnlineStatus(e,t){let{neighbourhoodSetOnlineStatus:i}=k(await ct(this,gt,"f").mutate({mutation:x`mutation neighbourhoodSetOnlineStatus(
570
- $perspectiveUUID: String!,
571
- $status: PerspectiveInput!
572
- ) {
573
- neighbourhoodSetOnlineStatus(
574
- perspectiveUUID: $perspectiveUUID,
575
- status: $status
576
- )
577
- }`,variables:{perspectiveUUID:e,status:t}}));return i}async setOnlineStatusU(e,t){let{neighbourhoodSetOnlineStatusU:i}=k(await ct(this,gt,"f").mutate({mutation:x`mutation neighbourhoodSetOnlineStatusU(
578
- $perspectiveUUID: String!,
579
- $status: PerspectiveUnsignedInput!
580
- ) {
581
- neighbourhoodSetOnlineStatusU(
582
- perspectiveUUID: $perspectiveUUID,
583
- status: $status
584
- )
585
- }`,variables:{perspectiveUUID:e,status:t}}));return i}async sendSignal(e,t,i){let{neighbourhoodSendSignal:n}=k(await ct(this,gt,"f").mutate({mutation:x`mutation neighbourhoodSendSignal(
586
- $perspectiveUUID: String!,
587
- $remoteAgentDid: String!,
588
- $payload: PerspectiveInput!
589
- ) {
590
- neighbourhoodSendSignal(
591
- perspectiveUUID: $perspectiveUUID,
592
- remoteAgentDid: $remoteAgentDid,
593
- payload: $payload
594
- )
595
- }`,variables:{perspectiveUUID:e,remoteAgentDid:t,payload:i}}));return n}async sendSignalU(e,t,i){let{neighbourhoodSendSignalU:n}=k(await ct(this,gt,"f").mutate({mutation:x`mutation neighbourhoodSendSignalU(
596
- $perspectiveUUID: String!,
597
- $remoteAgentDid: String!,
598
- $payload: PerspectiveUnsignedInput!
599
- ) {
600
- neighbourhoodSendSignalU(
601
- perspectiveUUID: $perspectiveUUID,
602
- remoteAgentDid: $remoteAgentDid,
603
- payload: $payload
604
- )
605
- }`,variables:{perspectiveUUID:e,remoteAgentDid:t,payload:i}}));return n}async sendBroadcast(e,t,i=!1){let{neighbourhoodSendBroadcast:n}=k(await ct(this,gt,"f").mutate({mutation:x`mutation neighbourhoodSendBroadcast(
606
- $perspectiveUUID: String!,
607
- $payload: PerspectiveInput!,
608
- $loopback: Boolean
609
- ) {
610
- neighbourhoodSendBroadcast(
611
- perspectiveUUID: $perspectiveUUID,
612
- payload: $payload,
613
- loopback: $loopback
614
- )
615
- }`,variables:{perspectiveUUID:e,payload:t,loopback:i}}));return n}async sendBroadcastU(e,t,i=!1){let{neighbourhoodSendBroadcastU:n}=k(await ct(this,gt,"f").mutate({mutation:x`mutation neighbourhoodSendBroadcastU(
616
- $perspectiveUUID: String!,
617
- $payload: PerspectiveUnsignedInput!,
618
- $loopback: Boolean
619
- ) {
620
- neighbourhoodSendBroadcastU(
621
- perspectiveUUID: $perspectiveUUID,
622
- payload: $payload,
623
- loopback: $loopback
624
- )
625
- }`,variables:{perspectiveUUID:e,payload:t,loopback:i}}));return n}dispatchSignal(e,t){let i=ct(this,ra,"f").get(e);if(i)for(let n of i)try{n(t)}catch(a){console.error("Error in signal handler:",a)}}async subscribeToSignals(e){let t=this;ct(this,gt,"f").subscribe({query:x`subscription neighbourhoodSignal($perspectiveUUID: String!) {
626
- neighbourhoodSignal(perspectiveUUID: $perspectiveUUID) {
627
- author
628
- timestamp
629
- data {
630
- links
631
- {
632
- author
633
- timestamp
634
- data { source, predicate, target }
635
- proof { valid, invalid, signature, key }
636
- }
637
- }
638
- proof { valid, invalid, signature, key }
639
- }
640
- }`,variables:{perspectiveUUID:e}}).subscribe({next:i=>{try{let{neighbourhoodSignal:n}=k(i);t.dispatchSignal(e,n)}catch(n){console.error("Error in signal subscription:",n)}},error:i=>{console.error("Signal subscription error for perspective",e,i)}})}async addSignalHandler(e,t){let i=ct(this,ra,"f").get(e);i?i.push(t):(i=[],ct(this,ra,"f").set(e,i),i.push(t),await this.subscribeToSignals(e))}removeSignalHandler(e,t){let i=ct(this,ra,"f").get(e);if(i){let n=i.indexOf(t);n>-1&&i.splice(n,1)}}};gt=new WeakMap,ra=new WeakMap;var Hs=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},q=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},B,uo,po,fo,qm,zs=`
641
- author
642
- timestamp
643
- data {
644
- links {
645
- author
646
- timestamp
647
- data { source, predicate, target }
648
- proof { valid, invalid, signature, key }
649
- }
650
- }
651
- proof { valid, invalid, signature, key }
652
- `,h0=`
653
- description
654
- appName
655
- appUrl
656
- appIconPath
657
- trigger
658
- perspectiveIds
659
- webhookUrl
660
- webhookAuth
661
- `,Bm=`
662
- id
663
- granted
664
- ${h0}
665
- `,m0=`
666
- notification { ${Bm} }
667
- perspectiveId
668
- triggerMatch
669
- `,Zu=class{constructor(e,t=!0){B.set(this,void 0),uo.set(this,void 0),po.set(this,void 0),fo.set(this,void 0),qm.set(this,void 0),Hs(this,B,e,"f"),Hs(this,uo,[],"f"),Hs(this,po,[],"f"),Hs(this,fo,[],"f"),t&&(this.subscribeMessageReceived(),this.subscribeExceptionOccurred(),this.subscribeNotificationTriggered())}async info(){let{runtimeInfo:e}=k(await q(this,B,"f").query({query:x`query runtimeInfo {
670
- runtimeInfo {
671
- ad4mExecutorVersion,
672
- isInitialized,
673
- isUnlocked
674
- }
675
- }`}));return e}async tlsDomain(){let{runtimeTlsDomain:e}=k(await q(this,B,"f").query({query:x`query runtimeTlsDomain {
676
- runtimeTlsDomain
677
- }`}));return e}async quit(){return k(await q(this,B,"f").mutate({mutation:x`mutation runtimeQuit { runtimeQuit }`})).runtimeQuit}async openLink(e){let{runtimeOpenLink:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeOpenLink($url: String!) {
678
- runtimeOpenLink(url: $url)
679
- }`,variables:{url:e}}));return t}async addTrustedAgents(e){let{addTrustedAgents:t}=k(await q(this,B,"f").mutate({mutation:x`mutation addTrustedAgents($agents: [String!]!) {
680
- addTrustedAgents(agents: $agents)
681
- }`,variables:{agents:e}}));return t}async deleteTrustedAgents(e){let{deleteTrustedAgents:t}=k(await q(this,B,"f").mutate({mutation:x`mutation deleteTrustedAgents($agents: [String!]!) {
682
- deleteTrustedAgents(agents: $agents)
683
- }`,variables:{agents:e}}));return t}async getTrustedAgents(){let{getTrustedAgents:e}=k(await q(this,B,"f").query({query:x`query getTrustedAgents {
684
- getTrustedAgents
685
- }`}));return e}async addKnownLinkLanguageTemplates(e){let{runtimeAddKnownLinkLanguageTemplates:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeAddKnownLinkLanguageTemplates($addresses: [String!]!) {
686
- runtimeAddKnownLinkLanguageTemplates(addresses: $addresses)
687
- }`,variables:{addresses:e}}));return t}async removeKnownLinkLanguageTemplates(e){let{runtimeRemoveKnownLinkLanguageTemplates:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeRemoveKnownLinkLanguageTemplates($addresses: [String!]!) {
688
- runtimeRemoveKnownLinkLanguageTemplates(addresses: $addresses)
689
- }`,variables:{addresses:e}}));return t}async knownLinkLanguageTemplates(){let{runtimeKnownLinkLanguageTemplates:e}=k(await q(this,B,"f").query({query:x`query runtimeKnownLinkLanguageTemplates {
690
- runtimeKnownLinkLanguageTemplates
691
- }`}));return e}async addFriends(e){let{runtimeAddFriends:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeAddFriends($dids: [String!]!) {
692
- runtimeAddFriends(dids: $dids)
693
- }`,variables:{dids:e}}));return t}async removeFriends(e){let{runtimeRemoveFriends:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeRemoveFriends($dids: [String!]!) {
694
- runtimeRemoveFriends(dids: $dids)
695
- }`,variables:{dids:e}}));return t}async friends(){let{runtimeFriends:e}=k(await q(this,B,"f").query({query:x`query runtimeFriends {
696
- runtimeFriends
697
- }`}));return e}async hcAgentInfos(){let{runtimeHcAgentInfos:e}=k(await q(this,B,"f").query({query:x`query runtimeHcAgentInfos {
698
- runtimeHcAgentInfos
699
- }`}));return e}async getNetworkMetrics(){let{runtimeGetNetworkMetrics:e}=k(await q(this,B,"f").query({query:x`query runtimeGetNetworkMetrics {
700
- runtimeGetNetworkMetrics
701
- }`}));return e}async restartHolochain(){let{runtimeRestartHolochain:e}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeRestartHolochain {
702
- runtimeRestartHolochain
703
- }`}));return e}async hcAddAgentInfos(e){let{runtimeHcAddAgentInfos:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeHcAddAgentInfos($agentInfos: String!) {
704
- runtimeHcAddAgentInfos(agentInfos: $agentInfos)
705
- }`,variables:{agentInfos:e}}));return t}async verifyStringSignedByDid(e,t,i,n){let{runtimeVerifyStringSignedByDid:a}=k(await q(this,B,"f").mutate({mutation:x`query runtimeVerifyStringSignedByDid($did: String!, $didSigningKeyId: String!, $data: String!, $signedData: String!) {
706
- runtimeVerifyStringSignedByDid(did: $did, didSigningKeyId: $didSigningKeyId, data: $data, signedData: $signedData)
707
- }`,variables:{did:e,didSigningKeyId:t,data:i,signedData:n}}));return a}async setStatus(e){let{runtimeSetStatus:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeSetStatus($status: PerspectiveInput!) {
708
- runtimeSetStatus(status: $status)
709
- }`,variables:{status:e}}));return t}async friendStatus(e){let{runtimeFriendStatus:t}=k(await q(this,B,"f").query({query:x`query runtimeFriendStatus($did: String!) {
710
- runtimeFriendStatus(did: $did) { ${zs} }
711
- }`,variables:{did:e}}));return t}async friendSendMessage(e,t){let{runtimeFriendSendMessage:i}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeFriendSendMessage($did: String!, $message: PerspectiveInput!) {
712
- runtimeFriendSendMessage(did: $did, message: $message)
713
- }`,variables:{did:e,message:t}}));return i}async messageInbox(e){let{runtimeMessageInbox:t}=k(await q(this,B,"f").query({query:x`query runtimeMessageInbox($filter: String) {
714
- runtimeMessageInbox(filter: $filter) { ${zs} }
715
- }`,variables:{filter:e}}));return t}async messageOutbox(e){let{runtimeMessageOutbox:t}=k(await q(this,B,"f").query({query:x`query runtimeMessageOutbox($filter: String) {
716
- runtimeMessageOutbox(filter: $filter) {
717
- recipient,
718
- message {
719
- ${zs}
720
- }
721
- }
722
- }`,variables:{filter:e}}));return t}async requestInstallNotification(e){let{runtimeRequestInstallNotification:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeRequestInstallNotification($notification: NotificationInput!) {
723
- runtimeRequestInstallNotification(notification: $notification)
724
- }`,variables:{notification:e}}));return t}async grantNotification(e){let{runtimeGrantNotification:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeGrantNotification($id: String!) {
725
- runtimeGrantNotification(id: $id)
726
- }`,variables:{id:e}}));return t}async exportDb(e){let{runtimeExportDb:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeExportDb($filePath: String!) {
727
- runtimeExportDb(filePath: $filePath)
728
- }`,variables:{filePath:e}}));return t}async importDb(e){let{runtimeImportDb:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeImportDb($filePath: String!) {
729
- runtimeImportDb(filePath: $filePath) {
730
- perspectives { total imported failed omitted errors }
731
- links { total imported failed omitted errors }
732
- expressions { total imported failed omitted errors }
733
- perspectiveDiffs { total imported failed omitted errors }
734
- notifications { total imported failed omitted errors }
735
- models { total imported failed omitted errors }
736
- defaultModels { total imported failed omitted errors }
737
- tasks { total imported failed omitted errors }
738
- friends { total imported failed omitted errors }
739
- trustedAgents { total imported failed omitted errors }
740
- knownLinkLanguages { total imported failed omitted errors }
741
- }
742
- }`,variables:{filePath:e}}));return t}async notifications(){let{runtimeNotifications:e}=k(await q(this,B,"f").query({query:x`query runtimeNotifications {
743
- runtimeNotifications { ${Bm} }
744
- }`}));return e}async updateNotification(e,t){let{runtimeUpdateNotification:i}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeUpdateNotification($id: String!, $notification: NotificationInput!) {
745
- runtimeUpdateNotification(id: $id, notification: $notification)
746
- }`,variables:{id:e,notification:t}}));return i}async removeNotification(e){let{runtimeRemoveNotification:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeRemoveNotification($id: String!) {
747
- runtimeRemoveNotification(id: $id)
748
- }`,variables:{id:e}}));return t}async exportPerspective(e,t){let{runtimeExportPerspective:i}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeExportPerspective($perspectiveUuid: String!, $filePath: String!) {
749
- runtimeExportPerspective(perspectiveUuid: $perspectiveUuid, filePath: $filePath)
750
- }`,variables:{perspectiveUuid:e,filePath:t}}));return i}async importPerspective(e){let{runtimeImportPerspective:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeImportPerspective($filePath: String!) {
751
- runtimeImportPerspective(filePath: $filePath)
752
- }`,variables:{filePath:e}}));return t}async multiUserEnabled(){let{runtimeMultiUserEnabled:e}=k(await q(this,B,"f").query({query:x`query runtimeMultiUserEnabled {
753
- runtimeMultiUserEnabled
754
- }`}));return e}async setMultiUserEnabled(e){let{runtimeSetMultiUserEnabled:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeSetMultiUserEnabled($enabled: Boolean!) {
755
- runtimeSetMultiUserEnabled(enabled: $enabled)
756
- }`,variables:{enabled:e}}));return t}async freeHostingEnabled(){let{runtimeFreeHostingEnabled:e}=k(await q(this,B,"f").query({query:x`query runtimeFreeHostingEnabled {
757
- runtimeFreeHostingEnabled
758
- }`}));return e}async setFreeHostingEnabled(e){let{runtimeSetFreeHostingEnabled:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeSetFreeHostingEnabled($enabled: Boolean!) {
759
- runtimeSetFreeHostingEnabled(enabled: $enabled)
760
- }`,variables:{enabled:e}}));return t}async listUsers(){let{runtimeListUsers:e}=k(await q(this,B,"f").query({query:x`query runtimeListUsers {
761
- runtimeListUsers {
762
- email
763
- did
764
- lastSeen
765
- perspectiveCount
766
- remainingCredits
767
- freeAccess
768
- hotWalletAddress
769
- }
770
- }`}));return e}async userWalletAddress(e){let{runtimeUserWalletAddress:t}=k(await q(this,B,"f").query({query:x`query runtimeUserWalletAddress($email: String!) {
771
- runtimeUserWalletAddress(email: $email)
772
- }`,variables:{email:e}}));return t}async emailTestModeEnable(){let{runtimeEmailTestModeEnable:e}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeEmailTestModeEnable {
773
- runtimeEmailTestModeEnable
774
- }`}));return e}async emailTestModeDisable(){let{runtimeEmailTestModeDisable:e}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeEmailTestModeDisable {
775
- runtimeEmailTestModeDisable
776
- }`}));return e}async emailTestGetCode(e){let{runtimeEmailTestGetCode:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeEmailTestGetCode($email: String!) {
777
- runtimeEmailTestGetCode(email: $email)
778
- }`,variables:{email:e}}));return t}async emailTestClearCodes(){let{runtimeEmailTestClearCodes:e}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeEmailTestClearCodes {
779
- runtimeEmailTestClearCodes
780
- }`}));return e}async emailTestSetExpiry(e,t,i){let{runtimeEmailTestSetExpiry:n}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeEmailTestSetExpiry($email: String!, $verificationType: String!, $expiresAt: Int!) {
781
- runtimeEmailTestSetExpiry(email: $email, verificationType: $verificationType, expiresAt: $expiresAt)
782
- }`,variables:{email:e,verificationType:t,expiresAt:i}}));return n}async unytAgentKey(){let{runtimeUnytAgentKey:e}=k(await q(this,B,"f").query({query:x`query runtimeUnytAgentKey { runtimeUnytAgentKey }`,fetchPolicy:"network-only"}));return e}async unytHotAgentPubkey(){let{runtimeHotAgentPubkey:e}=k(await q(this,B,"f").query({query:x`query runtimeHotAgentPubkey { runtimeHotAgentPubkey }`,fetchPolicy:"network-only"}));return e}async unytWalletBalance(){let{runtimeHotWalletBalance:e}=k(await q(this,B,"f").query({query:x`query runtimeHotWalletBalance { runtimeHotWalletBalance }`,fetchPolicy:"network-only"}));return e}async unytWalletHistory(e,t){let{runtimeHotWalletHistory:i}=k(await q(this,B,"f").query({query:x`query runtimeHotWalletHistory($page: Int, $perPage: Int) {
783
- runtimeHotWalletHistory(page: $page, perPage: $perPage)
784
- }`,variables:{page:e,perPage:t},fetchPolicy:"network-only"}));return i}async unytVersionInfo(){let{runtimeUnytVersionInfo:e}=k(await q(this,B,"f").query({query:x`query runtimeUnytVersionInfo { runtimeUnytVersionInfo }`,fetchPolicy:"network-only"}));return e}async unytSetMembraneProof(e){let{runtimeSetUnytMembraneProof:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeSetUnytMembraneProof($proof: String!) {
785
- runtimeSetUnytMembraneProof(proof: $proof) { success message }
786
- }`,variables:{proof:e}}));return t}async unytReinstallDna(){let{runtimeReinstallUnytDna:e}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeReinstallUnytDna {
787
- runtimeReinstallUnytDna { success message }
788
- }`}));return e}async unytSendHot(e,t){let{runtimeSendHot:i}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeSendHot($recipient: String!, $amount: String!) {
789
- runtimeSendHot(recipient: $recipient, amount: $amount) { success message }
790
- }`,variables:{recipient:e,amount:t}}));return i}async setUserCredits(e,t){let{runtimeSetUserCredits:i}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeSetUserCredits($email: String!, $amount: Float!) {
791
- runtimeSetUserCredits(email: $email, amount: $amount)
792
- }`,variables:{email:e,amount:t}}));return i}async setUserFreeAccess(e,t){let{runtimeSetUserFreeAccess:i}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeSetUserFreeAccess($email: String!, $enabled: Boolean!) {
793
- runtimeSetUserFreeAccess(email: $email, enabled: $enabled)
794
- }`,variables:{email:e,enabled:t}}));return i}async setHostRates(e){let{runtimeSetHostRates:t}=k(await q(this,B,"f").mutate({mutation:x`mutation runtimeSetHostRates($ratesJson: String!) {
795
- runtimeSetHostRates(ratesJson: $ratesJson)
796
- }`,variables:{ratesJson:e}}));return t}async getHostRates(){let{runtimeHostRates:e}=k(await q(this,B,"f").query({query:x`query runtimeHostRates {
797
- runtimeHostRates
798
- }`,fetchPolicy:"network-only"}));try{return JSON.parse(e)}catch{return[]}}addNotificationTriggeredCallback(e){q(this,fo,"f").push(e)}subscribeNotificationTriggered(){q(this,B,"f").subscribe({query:x` subscription {
799
- runtimeNotificationTriggered { ${m0} }
800
- }
801
- `}).subscribe({next:e=>{q(this,fo,"f").forEach(t=>{t(e.data.runtimeNotificationTriggered)})},error:e=>console.error(e)})}addMessageCallback(e){q(this,uo,"f").push(e)}subscribeMessageReceived(){q(this,B,"f").subscribe({query:x` subscription {
802
- runtimeMessageReceived { ${zs} }
803
- }
804
- `}).subscribe({next:e=>{q(this,uo,"f").forEach(t=>{t(e.data.runtimeMessageReceived)})},error:e=>console.error(e)})}addExceptionCallback(e){q(this,po,"f").push(e)}subscribeExceptionOccurred(){q(this,B,"f").subscribe({query:x` subscription {
805
- exceptionOccurred {
806
- title
807
- message
808
- type
809
- addon
810
- }
811
- }`}).subscribe({next:e=>{q(this,po,"f").forEach(t=>{t(e.data.exceptionOccurred)})},error:e=>console.error(e)})}};B=new WeakMap,uo=new WeakMap,po=new WeakMap,fo=new WeakMap,qm=new WeakMap;var g0=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},Zn=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},$r,Yu=class{constructor(e){$r.set(this,void 0),g0(this,$r,e,"f")}async get(e,t=!1){if(!t)try{let n=xe.fromUrl(e).get();if(typeof n=="object"&&n!==null&&"author"in n&&"timestamp"in n&&"data"in n&&"proof"in n)return n}catch{}let{expression:i}=k(await Zn(this,$r,"f").query({query:x`query expression($url: String!) {
812
- expression(url: $url) {
813
- author
814
- timestamp
815
- data
816
- language {
817
- address
818
- }
819
- proof {
820
- valid
821
- invalid
822
- }
823
- }
824
- }`,variables:{url:e}}));return i}async getMany(e){let{expressionMany:t}=k(await Zn(this,$r,"f").query({query:x`query expressionMany($urls: [String!]!) {
825
- expressionMany(urls: $urls) {
826
- author
827
- timestamp
828
- data
829
- language {
830
- address
831
- }
832
- proof {
833
- valid
834
- invalid
835
- }
836
- }
837
- }`,variables:{urls:e}}));return t}async getRaw(e){let{expressionRaw:t}=k(await Zn(this,$r,"f").query({query:x`query expressionRaw($url: String!) {
838
- expressionRaw(url: $url)
839
- }`,variables:{url:e}}));return t}async create(e,t){e=JSON.stringify(e);let{expressionCreate:i}=k(await Zn(this,$r,"f").mutate({mutation:x`mutation expressionCreate($content: String!, $languageAddress: String!){
840
- expressionCreate(content: $content, languageAddress: $languageAddress)
841
- }`,variables:{content:e,languageAddress:t}}));return i}async interactions(e){let{expressionInteractions:t}=k(await Zn(this,$r,"f").query({query:x`query expressionInteractions($url: String!) {
842
- expressionInteractions(url: $url) {
843
- label
844
- name
845
- parameters { name, type }
846
- }
847
- }`,variables:{url:e}}));return t}async interact(e,t){let{expressionInteract:i}=k(await Zn(this,$r,"f").mutate({mutation:x`mutation expressionInteract($url: String!, $interactionCall: InteractionCall!){
848
- expressionInteract(url: $url, interactionCall: $interactionCall)
849
- }`,variables:{url:e,interactionCall:t}}));return i}};$r=new WeakMap;var Vc={};Vc.byteLength=v0;Vc.toByteArray=w0;Vc.fromByteArray=x0;var mr=[],Ht=[],y0=typeof Uint8Array<"u"?Uint8Array:Array,Eu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ui=0,gh=Eu.length;Ui<gh;++Ui)mr[Ui]=Eu[Ui],Ht[Eu.charCodeAt(Ui)]=Ui;var Ui,gh;Ht["-".charCodeAt(0)]=62;Ht["_".charCodeAt(0)]=63;function Vm(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var i=t===e?0:4-t%4;return[t,i]}function v0(r){var e=Vm(r),t=e[0],i=e[1];return(t+i)*3/4-i}function b0(r,e,t){return(e+t)*3/4-t}function w0(r){var e,t=Vm(r),i=t[0],n=t[1],a=new y0(b0(r,i,n)),o=0,s=n>0?i-4:i,c;for(c=0;c<s;c+=4)e=Ht[r.charCodeAt(c)]<<18|Ht[r.charCodeAt(c+1)]<<12|Ht[r.charCodeAt(c+2)]<<6|Ht[r.charCodeAt(c+3)],a[o++]=e>>16&255,a[o++]=e>>8&255,a[o++]=e&255;return n===2&&(e=Ht[r.charCodeAt(c)]<<2|Ht[r.charCodeAt(c+1)]>>4,a[o++]=e&255),n===1&&(e=Ht[r.charCodeAt(c)]<<10|Ht[r.charCodeAt(c+1)]<<4|Ht[r.charCodeAt(c+2)]>>2,a[o++]=e>>8&255,a[o++]=e&255),a}function S0(r){return mr[r>>18&63]+mr[r>>12&63]+mr[r>>6&63]+mr[r&63]}function _0(r,e,t){for(var i,n=[],a=e;a<t;a+=3)i=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(r[a+2]&255),n.push(S0(i));return n.join("")}function x0(r){for(var e,t=r.length,i=t%3,n=[],a=16383,o=0,s=t-i;o<s;o+=a)n.push(_0(r,o,o+a>s?s:o+a));return i===1?(e=r[t-1],n.push(mr[e>>2]+mr[e<<4&63]+"==")):i===2&&(e=(r[t-2]<<8)+r[t-1],n.push(mr[e>>10]+mr[e>>4&63]+mr[e<<2&63]+"=")),n.join("")}var E0=4,yh=0,vh=1,k0=2;function ya(r){let e=r.length;for(;--e>=0;)r[e]=0}var A0=0,Qm=1,I0=2,T0=3,C0=258,gp=29,Vo=256,$o=Vo+1+gp,na=30,yp=19,Hm=2*$o+1,Zi=15,ku=16,O0=7,vp=256,zm=16,Wm=17,Gm=18,Xu=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),pc=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),$0=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Km=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),P0=512,Pr=new Array(($o+2)*2);ya(Pr);var xo=new Array(na*2);ya(xo);var Po=new Array(P0);ya(Po);var Ro=new Array(C0-T0+1);ya(Ro);var bp=new Array(gp);ya(bp);var Tc=new Array(na);ya(Tc);function Au(r,e,t,i,n){this.static_tree=r,this.extra_bits=e,this.extra_base=t,this.elems=i,this.max_length=n,this.has_stree=r&&r.length}var Jm,Zm,Ym;function Iu(r,e){this.dyn_tree=r,this.max_code=0,this.stat_desc=e}var Xm=r=>r<256?Po[r]:Po[256+(r>>>7)],Lo=(r,e)=>{r.pending_buf[r.pending++]=e&255,r.pending_buf[r.pending++]=e>>>8&255},Tt=(r,e,t)=>{r.bi_valid>ku-t?(r.bi_buf|=e<<r.bi_valid&65535,Lo(r,r.bi_buf),r.bi_buf=e>>ku-r.bi_valid,r.bi_valid+=t-ku):(r.bi_buf|=e<<r.bi_valid&65535,r.bi_valid+=t)},gr=(r,e,t)=>{Tt(r,t[e*2],t[e*2+1])},eg=(r,e)=>{let t=0;do t|=r&1,r>>>=1,t<<=1;while(--e>0);return t>>>1},R0=r=>{r.bi_valid===16?(Lo(r,r.bi_buf),r.bi_buf=0,r.bi_valid=0):r.bi_valid>=8&&(r.pending_buf[r.pending++]=r.bi_buf&255,r.bi_buf>>=8,r.bi_valid-=8)},L0=(r,e)=>{let t=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,a=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,c=e.stat_desc.max_length,l,u,d,f,p,h,m=0;for(f=0;f<=Zi;f++)r.bl_count[f]=0;for(t[r.heap[r.heap_max]*2+1]=0,l=r.heap_max+1;l<Hm;l++)u=r.heap[l],f=t[t[u*2+1]*2+1]+1,f>c&&(f=c,m++),t[u*2+1]=f,!(u>i)&&(r.bl_count[f]++,p=0,u>=s&&(p=o[u-s]),h=t[u*2],r.opt_len+=h*(f+p),a&&(r.static_len+=h*(n[u*2+1]+p)));if(m!==0){do{for(f=c-1;r.bl_count[f]===0;)f--;r.bl_count[f]--,r.bl_count[f+1]+=2,r.bl_count[c]--,m-=2}while(m>0);for(f=c;f!==0;f--)for(u=r.bl_count[f];u!==0;)d=r.heap[--l],!(d>i)&&(t[d*2+1]!==f&&(r.opt_len+=(f-t[d*2+1])*t[d*2],t[d*2+1]=f),u--)}},tg=(r,e,t)=>{let i=new Array(Zi+1),n=0,a,o;for(a=1;a<=Zi;a++)n=n+t[a-1]<<1,i[a]=n;for(o=0;o<=e;o++){let s=r[o*2+1];s!==0&&(r[o*2]=eg(i[s]++,s))}},N0=()=>{let r,e,t,i,n,a=new Array(Zi+1);for(t=0,i=0;i<gp-1;i++)for(bp[i]=t,r=0;r<1<<Xu[i];r++)Ro[t++]=i;for(Ro[t-1]=i,n=0,i=0;i<16;i++)for(Tc[i]=n,r=0;r<1<<pc[i];r++)Po[n++]=i;for(n>>=7;i<na;i++)for(Tc[i]=n<<7,r=0;r<1<<pc[i]-7;r++)Po[256+n++]=i;for(e=0;e<=Zi;e++)a[e]=0;for(r=0;r<=143;)Pr[r*2+1]=8,r++,a[8]++;for(;r<=255;)Pr[r*2+1]=9,r++,a[9]++;for(;r<=279;)Pr[r*2+1]=7,r++,a[7]++;for(;r<=287;)Pr[r*2+1]=8,r++,a[8]++;for(tg(Pr,$o+1,a),r=0;r<na;r++)xo[r*2+1]=5,xo[r*2]=eg(r,5);Jm=new Au(Pr,Xu,Vo+1,$o,Zi),Zm=new Au(xo,pc,0,na,Zi),Ym=new Au(new Array(0),$0,0,yp,O0)},rg=r=>{let e;for(e=0;e<$o;e++)r.dyn_ltree[e*2]=0;for(e=0;e<na;e++)r.dyn_dtree[e*2]=0;for(e=0;e<yp;e++)r.bl_tree[e*2]=0;r.dyn_ltree[vp*2]=1,r.opt_len=r.static_len=0,r.sym_next=r.matches=0},ig=r=>{r.bi_valid>8?Lo(r,r.bi_buf):r.bi_valid>0&&(r.pending_buf[r.pending++]=r.bi_buf),r.bi_buf=0,r.bi_valid=0},bh=(r,e,t,i)=>{let n=e*2,a=t*2;return r[n]<r[a]||r[n]===r[a]&&i[e]<=i[t]},Tu=(r,e,t)=>{let i=r.heap[t],n=t<<1;for(;n<=r.heap_len&&(n<r.heap_len&&bh(e,r.heap[n+1],r.heap[n],r.depth)&&n++,!bh(e,i,r.heap[n],r.depth));)r.heap[t]=r.heap[n],t=n,n<<=1;r.heap[t]=i},wh=(r,e,t)=>{let i,n,a=0,o,s;if(r.sym_next!==0)do i=r.pending_buf[r.sym_buf+a++]&255,i+=(r.pending_buf[r.sym_buf+a++]&255)<<8,n=r.pending_buf[r.sym_buf+a++],i===0?gr(r,n,e):(o=Ro[n],gr(r,o+Vo+1,e),s=Xu[o],s!==0&&(n-=bp[o],Tt(r,n,s)),i--,o=Xm(i),gr(r,o,t),s=pc[o],s!==0&&(i-=Tc[o],Tt(r,i,s)));while(a<r.sym_next);gr(r,vp,e)},ep=(r,e)=>{let t=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,a=e.stat_desc.elems,o,s,c=-1,l;for(r.heap_len=0,r.heap_max=Hm,o=0;o<a;o++)t[o*2]!==0?(r.heap[++r.heap_len]=c=o,r.depth[o]=0):t[o*2+1]=0;for(;r.heap_len<2;)l=r.heap[++r.heap_len]=c<2?++c:0,t[l*2]=1,r.depth[l]=0,r.opt_len--,n&&(r.static_len-=i[l*2+1]);for(e.max_code=c,o=r.heap_len>>1;o>=1;o--)Tu(r,t,o);l=a;do o=r.heap[1],r.heap[1]=r.heap[r.heap_len--],Tu(r,t,1),s=r.heap[1],r.heap[--r.heap_max]=o,r.heap[--r.heap_max]=s,t[l*2]=t[o*2]+t[s*2],r.depth[l]=(r.depth[o]>=r.depth[s]?r.depth[o]:r.depth[s])+1,t[o*2+1]=t[s*2+1]=l,r.heap[1]=l++,Tu(r,t,1);while(r.heap_len>=2);r.heap[--r.heap_max]=r.heap[1],L0(r,e),tg(t,c,r.bl_count)},Sh=(r,e,t)=>{let i,n=-1,a,o=e[0*2+1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),e[(t+1)*2+1]=65535,i=0;i<=t;i++)a=o,o=e[(i+1)*2+1],!(++s<c&&a===o)&&(s<l?r.bl_tree[a*2]+=s:a!==0?(a!==n&&r.bl_tree[a*2]++,r.bl_tree[zm*2]++):s<=10?r.bl_tree[Wm*2]++:r.bl_tree[Gm*2]++,s=0,n=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4))},_h=(r,e,t)=>{let i,n=-1,a,o=e[0*2+1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),i=0;i<=t;i++)if(a=o,o=e[(i+1)*2+1],!(++s<c&&a===o)){if(s<l)do gr(r,a,r.bl_tree);while(--s!==0);else a!==0?(a!==n&&(gr(r,a,r.bl_tree),s--),gr(r,zm,r.bl_tree),Tt(r,s-3,2)):s<=10?(gr(r,Wm,r.bl_tree),Tt(r,s-3,3)):(gr(r,Gm,r.bl_tree),Tt(r,s-11,7));s=0,n=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4)}},D0=r=>{let e;for(Sh(r,r.dyn_ltree,r.l_desc.max_code),Sh(r,r.dyn_dtree,r.d_desc.max_code),ep(r,r.bl_desc),e=yp-1;e>=3&&r.bl_tree[Km[e]*2+1]===0;e--);return r.opt_len+=3*(e+1)+5+5+4,e},F0=(r,e,t,i)=>{let n;for(Tt(r,e-257,5),Tt(r,t-1,5),Tt(r,i-4,4),n=0;n<i;n++)Tt(r,r.bl_tree[Km[n]*2+1],3);_h(r,r.dyn_ltree,e-1),_h(r,r.dyn_dtree,t-1)},M0=r=>{let e=4093624447,t;for(t=0;t<=31;t++,e>>>=1)if(e&1&&r.dyn_ltree[t*2]!==0)return yh;if(r.dyn_ltree[9*2]!==0||r.dyn_ltree[10*2]!==0||r.dyn_ltree[13*2]!==0)return vh;for(t=32;t<Vo;t++)if(r.dyn_ltree[t*2]!==0)return vh;return yh},xh=!1,U0=r=>{xh||(N0(),xh=!0),r.l_desc=new Iu(r.dyn_ltree,Jm),r.d_desc=new Iu(r.dyn_dtree,Zm),r.bl_desc=new Iu(r.bl_tree,Ym),r.bi_buf=0,r.bi_valid=0,rg(r)},ng=(r,e,t,i)=>{Tt(r,(A0<<1)+(i?1:0),3),ig(r),Lo(r,t),Lo(r,~t),t&&r.pending_buf.set(r.window.subarray(e,e+t),r.pending),r.pending+=t},j0=r=>{Tt(r,Qm<<1,3),gr(r,vp,Pr),R0(r)},q0=(r,e,t,i)=>{let n,a,o=0;r.level>0?(r.strm.data_type===k0&&(r.strm.data_type=M0(r)),ep(r,r.l_desc),ep(r,r.d_desc),o=D0(r),n=r.opt_len+3+7>>>3,a=r.static_len+3+7>>>3,a<=n&&(n=a)):n=a=t+5,t+4<=n&&e!==-1?ng(r,e,t,i):r.strategy===E0||a===n?(Tt(r,(Qm<<1)+(i?1:0),3),wh(r,Pr,xo)):(Tt(r,(I0<<1)+(i?1:0),3),F0(r,r.l_desc.max_code+1,r.d_desc.max_code+1,o+1),wh(r,r.dyn_ltree,r.dyn_dtree)),rg(r),i&&ig(r)},B0=(r,e,t)=>(r.pending_buf[r.sym_buf+r.sym_next++]=e,r.pending_buf[r.sym_buf+r.sym_next++]=e>>8,r.pending_buf[r.sym_buf+r.sym_next++]=t,e===0?r.dyn_ltree[t*2]++:(r.matches++,e--,r.dyn_ltree[(Ro[t]+Vo+1)*2]++,r.dyn_dtree[Xm(e)*2]++),r.sym_next===r.sym_end),V0=U0,Q0=ng,H0=q0,z0=B0,W0=j0,G0={_tr_init:V0,_tr_stored_block:Q0,_tr_flush_block:H0,_tr_tally:z0,_tr_align:W0},K0=(r,e,t,i)=>{let n=r&65535|0,a=r>>>16&65535|0,o=0;for(;t!==0;){o=t>2e3?2e3:t,t-=o;do n=n+e[i++]|0,a=a+n|0;while(--o);n%=65521,a%=65521}return n|a<<16|0},No=K0,J0=()=>{let r,e=[];for(var t=0;t<256;t++){r=t;for(var i=0;i<8;i++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r}return e},Z0=new Uint32Array(J0()),Y0=(r,e,t,i)=>{let n=Z0,a=i+t;r^=-1;for(let o=i;o<a;o++)r=r>>>8^n[(r^e[o])&255];return r^-1},Ze=Y0,cn={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},vn={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:X0,_tr_stored_block:tp,_tr_flush_block:ew,_tr_tally:pi,_tr_align:tw}=G0,{Z_NO_FLUSH:di,Z_PARTIAL_FLUSH:rw,Z_FULL_FLUSH:iw,Z_FINISH:Wt,Z_BLOCK:Eh,Z_OK:at,Z_STREAM_END:kh,Z_STREAM_ERROR:br,Z_DATA_ERROR:nw,Z_BUF_ERROR:Cu,Z_DEFAULT_COMPRESSION:aw,Z_FILTERED:ow,Z_HUFFMAN_ONLY:Ws,Z_RLE:sw,Z_FIXED:cw,Z_DEFAULT_STRATEGY:lw,Z_UNKNOWN:uw,Z_DEFLATED:Qc}=vn,pw=9,dw=15,fw=8,hw=29,mw=256,rp=mw+1+hw,gw=30,yw=19,vw=2*rp+1,bw=15,ue=3,si=258,wr=si+ue+1,ww=32,la=42,wp=57,ip=69,np=73,ap=91,op=103,Yi=113,ho=666,yt=1,va=2,ln=3,ba=4,Sw=3,Xi=(r,e)=>(r.msg=cn[e],e),Ah=r=>r*2-(r>4?9:0),oi=r=>{let e=r.length;for(;--e>=0;)r[e]=0},_w=r=>{let e,t,i,n=r.w_size;e=r.hash_size,i=e;do t=r.head[--i],r.head[i]=t>=n?t-n:0;while(--e);e=n,i=e;do t=r.prev[--i],r.prev[i]=t>=n?t-n:0;while(--e)},xw=(r,e,t)=>(e<<r.hash_shift^t)&r.hash_mask,fi=xw,Lt=r=>{let e=r.state,t=e.pending;t>r.avail_out&&(t=r.avail_out),t!==0&&(r.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+t),r.next_out),r.next_out+=t,e.pending_out+=t,r.total_out+=t,r.avail_out-=t,e.pending-=t,e.pending===0&&(e.pending_out=0))},Dt=(r,e)=>{ew(r,r.block_start>=0?r.block_start:-1,r.strstart-r.block_start,e),r.block_start=r.strstart,Lt(r.strm)},ye=(r,e)=>{r.pending_buf[r.pending++]=e},Ga=(r,e)=>{r.pending_buf[r.pending++]=e>>>8&255,r.pending_buf[r.pending++]=e&255},sp=(r,e,t,i)=>{let n=r.avail_in;return n>i&&(n=i),n===0?0:(r.avail_in-=n,e.set(r.input.subarray(r.next_in,r.next_in+n),t),r.state.wrap===1?r.adler=No(r.adler,e,n,t):r.state.wrap===2&&(r.adler=Ze(r.adler,e,n,t)),r.next_in+=n,r.total_in+=n,n)},ag=(r,e)=>{let t=r.max_chain_length,i=r.strstart,n,a,o=r.prev_length,s=r.nice_match,c=r.strstart>r.w_size-wr?r.strstart-(r.w_size-wr):0,l=r.window,u=r.w_mask,d=r.prev,f=r.strstart+si,p=l[i+o-1],h=l[i+o];r.prev_length>=r.good_match&&(t>>=2),s>r.lookahead&&(s=r.lookahead);do if(n=e,!(l[n+o]!==h||l[n+o-1]!==p||l[n]!==l[i]||l[++n]!==l[i+1])){i+=2,n++;do;while(l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&i<f);if(a=si-(f-i),i=f-si,a>o){if(r.match_start=e,o=a,a>=s)break;p=l[i+o-1],h=l[i+o]}}while((e=d[e&u])>c&&--t!==0);return o<=r.lookahead?o:r.lookahead},ua=r=>{let e=r.w_size,t,i,n;do{if(i=r.window_size-r.lookahead-r.strstart,r.strstart>=e+(e-wr)&&(r.window.set(r.window.subarray(e,e+e-i),0),r.match_start-=e,r.strstart-=e,r.block_start-=e,r.insert>r.strstart&&(r.insert=r.strstart),_w(r),i+=e),r.strm.avail_in===0)break;if(t=sp(r.strm,r.window,r.strstart+r.lookahead,i),r.lookahead+=t,r.lookahead+r.insert>=ue)for(n=r.strstart-r.insert,r.ins_h=r.window[n],r.ins_h=fi(r,r.ins_h,r.window[n+1]);r.insert&&(r.ins_h=fi(r,r.ins_h,r.window[n+ue-1]),r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++,r.insert--,!(r.lookahead+r.insert<ue)););}while(r.lookahead<wr&&r.strm.avail_in!==0)},og=(r,e)=>{let t=r.pending_buf_size-5>r.w_size?r.w_size:r.pending_buf_size-5,i,n,a,o=0,s=r.strm.avail_in;do{if(i=65535,a=r.bi_valid+42>>3,r.strm.avail_out<a||(a=r.strm.avail_out-a,n=r.strstart-r.block_start,i>n+r.strm.avail_in&&(i=n+r.strm.avail_in),i>a&&(i=a),i<t&&(i===0&&e!==Wt||e===di||i!==n+r.strm.avail_in)))break;o=e===Wt&&i===n+r.strm.avail_in?1:0,tp(r,0,0,o),r.pending_buf[r.pending-4]=i,r.pending_buf[r.pending-3]=i>>8,r.pending_buf[r.pending-2]=~i,r.pending_buf[r.pending-1]=~i>>8,Lt(r.strm),n&&(n>i&&(n=i),r.strm.output.set(r.window.subarray(r.block_start,r.block_start+n),r.strm.next_out),r.strm.next_out+=n,r.strm.avail_out-=n,r.strm.total_out+=n,r.block_start+=n,i-=n),i&&(sp(r.strm,r.strm.output,r.strm.next_out,i),r.strm.next_out+=i,r.strm.avail_out-=i,r.strm.total_out+=i)}while(o===0);return s-=r.strm.avail_in,s&&(s>=r.w_size?(r.matches=2,r.window.set(r.strm.input.subarray(r.strm.next_in-r.w_size,r.strm.next_in),0),r.strstart=r.w_size,r.insert=r.strstart):(r.window_size-r.strstart<=s&&(r.strstart-=r.w_size,r.window.set(r.window.subarray(r.w_size,r.w_size+r.strstart),0),r.matches<2&&r.matches++,r.insert>r.strstart&&(r.insert=r.strstart)),r.window.set(r.strm.input.subarray(r.strm.next_in-s,r.strm.next_in),r.strstart),r.strstart+=s,r.insert+=s>r.w_size-r.insert?r.w_size-r.insert:s),r.block_start=r.strstart),r.high_water<r.strstart&&(r.high_water=r.strstart),o?ba:e!==di&&e!==Wt&&r.strm.avail_in===0&&r.strstart===r.block_start?va:(a=r.window_size-r.strstart,r.strm.avail_in>a&&r.block_start>=r.w_size&&(r.block_start-=r.w_size,r.strstart-=r.w_size,r.window.set(r.window.subarray(r.w_size,r.w_size+r.strstart),0),r.matches<2&&r.matches++,a+=r.w_size,r.insert>r.strstart&&(r.insert=r.strstart)),a>r.strm.avail_in&&(a=r.strm.avail_in),a&&(sp(r.strm,r.window,r.strstart,a),r.strstart+=a,r.insert+=a>r.w_size-r.insert?r.w_size-r.insert:a),r.high_water<r.strstart&&(r.high_water=r.strstart),a=r.bi_valid+42>>3,a=r.pending_buf_size-a>65535?65535:r.pending_buf_size-a,t=a>r.w_size?r.w_size:a,n=r.strstart-r.block_start,(n>=t||(n||e===Wt)&&e!==di&&r.strm.avail_in===0&&n<=a)&&(i=n>a?a:n,o=e===Wt&&r.strm.avail_in===0&&i===n?1:0,tp(r,r.block_start,i,o),r.block_start+=i,Lt(r.strm)),o?ln:yt)},Ou=(r,e)=>{let t,i;for(;;){if(r.lookahead<wr){if(ua(r),r.lookahead<wr&&e===di)return yt;if(r.lookahead===0)break}if(t=0,r.lookahead>=ue&&(r.ins_h=fi(r,r.ins_h,r.window[r.strstart+ue-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),t!==0&&r.strstart-t<=r.w_size-wr&&(r.match_length=ag(r,t)),r.match_length>=ue)if(i=pi(r,r.strstart-r.match_start,r.match_length-ue),r.lookahead-=r.match_length,r.match_length<=r.max_lazy_match&&r.lookahead>=ue){r.match_length--;do r.strstart++,r.ins_h=fi(r,r.ins_h,r.window[r.strstart+ue-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart;while(--r.match_length!==0);r.strstart++}else r.strstart+=r.match_length,r.match_length=0,r.ins_h=r.window[r.strstart],r.ins_h=fi(r,r.ins_h,r.window[r.strstart+1]);else i=pi(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++;if(i&&(Dt(r,!1),r.strm.avail_out===0))return yt}return r.insert=r.strstart<ue-1?r.strstart:ue-1,e===Wt?(Dt(r,!0),r.strm.avail_out===0?ln:ba):r.sym_next&&(Dt(r,!1),r.strm.avail_out===0)?yt:va},Yn=(r,e)=>{let t,i,n;for(;;){if(r.lookahead<wr){if(ua(r),r.lookahead<wr&&e===di)return yt;if(r.lookahead===0)break}if(t=0,r.lookahead>=ue&&(r.ins_h=fi(r,r.ins_h,r.window[r.strstart+ue-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),r.prev_length=r.match_length,r.prev_match=r.match_start,r.match_length=ue-1,t!==0&&r.prev_length<r.max_lazy_match&&r.strstart-t<=r.w_size-wr&&(r.match_length=ag(r,t),r.match_length<=5&&(r.strategy===ow||r.match_length===ue&&r.strstart-r.match_start>4096)&&(r.match_length=ue-1)),r.prev_length>=ue&&r.match_length<=r.prev_length){n=r.strstart+r.lookahead-ue,i=pi(r,r.strstart-1-r.prev_match,r.prev_length-ue),r.lookahead-=r.prev_length-1,r.prev_length-=2;do++r.strstart<=n&&(r.ins_h=fi(r,r.ins_h,r.window[r.strstart+ue-1]),t=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart);while(--r.prev_length!==0);if(r.match_available=0,r.match_length=ue-1,r.strstart++,i&&(Dt(r,!1),r.strm.avail_out===0))return yt}else if(r.match_available){if(i=pi(r,0,r.window[r.strstart-1]),i&&Dt(r,!1),r.strstart++,r.lookahead--,r.strm.avail_out===0)return yt}else r.match_available=1,r.strstart++,r.lookahead--}return r.match_available&&(i=pi(r,0,r.window[r.strstart-1]),r.match_available=0),r.insert=r.strstart<ue-1?r.strstart:ue-1,e===Wt?(Dt(r,!0),r.strm.avail_out===0?ln:ba):r.sym_next&&(Dt(r,!1),r.strm.avail_out===0)?yt:va},Ew=(r,e)=>{let t,i,n,a,o=r.window;for(;;){if(r.lookahead<=si){if(ua(r),r.lookahead<=si&&e===di)return yt;if(r.lookahead===0)break}if(r.match_length=0,r.lookahead>=ue&&r.strstart>0&&(n=r.strstart-1,i=o[n],i===o[++n]&&i===o[++n]&&i===o[++n])){a=r.strstart+si;do;while(i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&i===o[++n]&&n<a);r.match_length=si-(a-n),r.match_length>r.lookahead&&(r.match_length=r.lookahead)}if(r.match_length>=ue?(t=pi(r,1,r.match_length-ue),r.lookahead-=r.match_length,r.strstart+=r.match_length,r.match_length=0):(t=pi(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++),t&&(Dt(r,!1),r.strm.avail_out===0))return yt}return r.insert=0,e===Wt?(Dt(r,!0),r.strm.avail_out===0?ln:ba):r.sym_next&&(Dt(r,!1),r.strm.avail_out===0)?yt:va},kw=(r,e)=>{let t;for(;;){if(r.lookahead===0&&(ua(r),r.lookahead===0)){if(e===di)return yt;break}if(r.match_length=0,t=pi(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++,t&&(Dt(r,!1),r.strm.avail_out===0))return yt}return r.insert=0,e===Wt?(Dt(r,!0),r.strm.avail_out===0?ln:ba):r.sym_next&&(Dt(r,!1),r.strm.avail_out===0)?yt:va};function dr(r,e,t,i,n){this.good_length=r,this.max_lazy=e,this.nice_length=t,this.max_chain=i,this.func=n}var mo=[new dr(0,0,0,0,og),new dr(4,4,8,4,Ou),new dr(4,5,16,8,Ou),new dr(4,6,32,32,Ou),new dr(4,4,16,16,Yn),new dr(8,16,32,32,Yn),new dr(8,16,128,128,Yn),new dr(8,32,128,256,Yn),new dr(32,128,258,1024,Yn),new dr(32,258,258,4096,Yn)],Aw=r=>{r.window_size=2*r.w_size,oi(r.head),r.max_lazy_match=mo[r.level].max_lazy,r.good_match=mo[r.level].good_length,r.nice_match=mo[r.level].nice_length,r.max_chain_length=mo[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=ue-1,r.match_available=0,r.ins_h=0};function Iw(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Qc,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(vw*2),this.dyn_dtree=new Uint16Array((2*gw+1)*2),this.bl_tree=new Uint16Array((2*yw+1)*2),oi(this.dyn_ltree),oi(this.dyn_dtree),oi(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(bw+1),this.heap=new Uint16Array(2*rp+1),oi(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*rp+1),oi(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var Qo=r=>{if(!r)return 1;let e=r.state;return!e||e.strm!==r||e.status!==la&&e.status!==wp&&e.status!==ip&&e.status!==np&&e.status!==ap&&e.status!==op&&e.status!==Yi&&e.status!==ho?1:0},sg=r=>{if(Qo(r))return Xi(r,br);r.total_in=r.total_out=0,r.data_type=uw;let e=r.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?wp:e.wrap?la:Yi,r.adler=e.wrap===2?0:1,e.last_flush=-2,X0(e),at},cg=r=>{let e=sg(r);return e===at&&Aw(r.state),e},Tw=(r,e)=>Qo(r)||r.state.wrap!==2?br:(r.state.gzhead=e,at),lg=(r,e,t,i,n,a)=>{if(!r)return br;let o=1;if(e===aw&&(e=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),n<1||n>pw||t!==Qc||i<8||i>15||e<0||e>9||a<0||a>cw||i===8&&o!==1)return Xi(r,br);i===8&&(i=9);let s=new Iw;return r.state=s,s.strm=r,s.status=la,s.wrap=o,s.gzhead=null,s.w_bits=i,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=n+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+ue-1)/ue),s.window=new Uint8Array(s.w_size*2),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<n+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Uint8Array(s.pending_buf_size),s.sym_buf=s.lit_bufsize,s.sym_end=(s.lit_bufsize-1)*3,s.level=e,s.strategy=a,s.method=t,cg(r)},Cw=(r,e)=>lg(r,e,Qc,dw,fw,lw),Ow=(r,e)=>{if(Qo(r)||e>Eh||e<0)return r?Xi(r,br):br;let t=r.state;if(!r.output||r.avail_in!==0&&!r.input||t.status===ho&&e!==Wt)return Xi(r,r.avail_out===0?Cu:br);let i=t.last_flush;if(t.last_flush=e,t.pending!==0){if(Lt(r),r.avail_out===0)return t.last_flush=-1,at}else if(r.avail_in===0&&Ah(e)<=Ah(i)&&e!==Wt)return Xi(r,Cu);if(t.status===ho&&r.avail_in!==0)return Xi(r,Cu);if(t.status===la&&t.wrap===0&&(t.status=Yi),t.status===la){let n=Qc+(t.w_bits-8<<4)<<8,a=-1;if(t.strategy>=Ws||t.level<2?a=0:t.level<6?a=1:t.level===6?a=2:a=3,n|=a<<6,t.strstart!==0&&(n|=ww),n+=31-n%31,Ga(t,n),t.strstart!==0&&(Ga(t,r.adler>>>16),Ga(t,r.adler&65535)),r.adler=1,t.status=Yi,Lt(r),t.pending!==0)return t.last_flush=-1,at}if(t.status===wp){if(r.adler=0,ye(t,31),ye(t,139),ye(t,8),t.gzhead)ye(t,(t.gzhead.text?1:0)+(t.gzhead.hcrc?2:0)+(t.gzhead.extra?4:0)+(t.gzhead.name?8:0)+(t.gzhead.comment?16:0)),ye(t,t.gzhead.time&255),ye(t,t.gzhead.time>>8&255),ye(t,t.gzhead.time>>16&255),ye(t,t.gzhead.time>>24&255),ye(t,t.level===9?2:t.strategy>=Ws||t.level<2?4:0),ye(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(ye(t,t.gzhead.extra.length&255),ye(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(r.adler=Ze(r.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=ip;else if(ye(t,0),ye(t,0),ye(t,0),ye(t,0),ye(t,0),ye(t,t.level===9?2:t.strategy>=Ws||t.level<2?4:0),ye(t,Sw),t.status=Yi,Lt(r),t.pending!==0)return t.last_flush=-1,at}if(t.status===ip){if(t.gzhead.extra){let n=t.pending,a=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+a>t.pending_buf_size;){let s=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+s),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>n&&(r.adler=Ze(r.adler,t.pending_buf,t.pending-n,n)),t.gzindex+=s,Lt(r),t.pending!==0)return t.last_flush=-1,at;n=0,a-=s}let o=new Uint8Array(t.gzhead.extra);t.pending_buf.set(o.subarray(t.gzindex,t.gzindex+a),t.pending),t.pending+=a,t.gzhead.hcrc&&t.pending>n&&(r.adler=Ze(r.adler,t.pending_buf,t.pending-n,n)),t.gzindex=0}t.status=np}if(t.status===np){if(t.gzhead.name){let n=t.pending,a;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>n&&(r.adler=Ze(r.adler,t.pending_buf,t.pending-n,n)),Lt(r),t.pending!==0)return t.last_flush=-1,at;n=0}t.gzindex<t.gzhead.name.length?a=t.gzhead.name.charCodeAt(t.gzindex++)&255:a=0,ye(t,a)}while(a!==0);t.gzhead.hcrc&&t.pending>n&&(r.adler=Ze(r.adler,t.pending_buf,t.pending-n,n)),t.gzindex=0}t.status=ap}if(t.status===ap){if(t.gzhead.comment){let n=t.pending,a;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>n&&(r.adler=Ze(r.adler,t.pending_buf,t.pending-n,n)),Lt(r),t.pending!==0)return t.last_flush=-1,at;n=0}t.gzindex<t.gzhead.comment.length?a=t.gzhead.comment.charCodeAt(t.gzindex++)&255:a=0,ye(t,a)}while(a!==0);t.gzhead.hcrc&&t.pending>n&&(r.adler=Ze(r.adler,t.pending_buf,t.pending-n,n))}t.status=op}if(t.status===op){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(Lt(r),t.pending!==0))return t.last_flush=-1,at;ye(t,r.adler&255),ye(t,r.adler>>8&255),r.adler=0}if(t.status=Yi,Lt(r),t.pending!==0)return t.last_flush=-1,at}if(r.avail_in!==0||t.lookahead!==0||e!==di&&t.status!==ho){let n=t.level===0?og(t,e):t.strategy===Ws?kw(t,e):t.strategy===sw?Ew(t,e):mo[t.level].func(t,e);if((n===ln||n===ba)&&(t.status=ho),n===yt||n===ln)return r.avail_out===0&&(t.last_flush=-1),at;if(n===va&&(e===rw?tw(t):e!==Eh&&(tp(t,0,0,!1),e===iw&&(oi(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),Lt(r),r.avail_out===0))return t.last_flush=-1,at}return e!==Wt?at:t.wrap<=0?kh:(t.wrap===2?(ye(t,r.adler&255),ye(t,r.adler>>8&255),ye(t,r.adler>>16&255),ye(t,r.adler>>24&255),ye(t,r.total_in&255),ye(t,r.total_in>>8&255),ye(t,r.total_in>>16&255),ye(t,r.total_in>>24&255)):(Ga(t,r.adler>>>16),Ga(t,r.adler&65535)),Lt(r),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?at:kh)},$w=r=>{if(Qo(r))return br;let e=r.state.status;return r.state=null,e===Yi?Xi(r,nw):at},Pw=(r,e)=>{let t=e.length;if(Qo(r))return br;let i=r.state,n=i.wrap;if(n===2||n===1&&i.status!==la||i.lookahead)return br;if(n===1&&(r.adler=No(r.adler,e,t,0)),i.wrap=0,t>=i.w_size){n===0&&(oi(i.head),i.strstart=0,i.block_start=0,i.insert=0);let c=new Uint8Array(i.w_size);c.set(e.subarray(t-i.w_size,t),0),e=c,t=i.w_size}let a=r.avail_in,o=r.next_in,s=r.input;for(r.avail_in=t,r.next_in=0,r.input=e,ua(i);i.lookahead>=ue;){let c=i.strstart,l=i.lookahead-(ue-1);do i.ins_h=fi(i,i.ins_h,i.window[c+ue-1]),i.prev[c&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=c,c++;while(--l);i.strstart=c,i.lookahead=ue-1,ua(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=ue-1,i.match_available=0,r.next_in=o,r.input=s,r.avail_in=a,i.wrap=n,at},Rw=Cw,Lw=lg,Nw=cg,Dw=sg,Fw=Tw,Mw=Ow,Uw=$w,jw=Pw,qw="pako deflate (from Nodeca project)",Eo={deflateInit:Rw,deflateInit2:Lw,deflateReset:Nw,deflateResetKeep:Dw,deflateSetHeader:Fw,deflate:Mw,deflateEnd:Uw,deflateSetDictionary:jw,deflateInfo:qw},Bw=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),Vw=function(r){let e=Array.prototype.slice.call(arguments,1);for(;e.length;){let t=e.shift();if(!!t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(let i in t)Bw(t,i)&&(r[i]=t[i])}}return r},Qw=r=>{let e=0;for(let i=0,n=r.length;i<n;i++)e+=r[i].length;let t=new Uint8Array(e);for(let i=0,n=0,a=r.length;i<a;i++){let o=r[i];t.set(o,n),n+=o.length}return t},Hc={assign:Vw,flattenChunks:Qw},ug=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(r){ug=!1}var Do=new Uint8Array(256);for(let r=0;r<256;r++)Do[r]=r>=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;Do[254]=Do[254]=1;var Hw=r=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(r);let e,t,i,n,a,o=r.length,s=0;for(n=0;n<o;n++)t=r.charCodeAt(n),(t&64512)===55296&&n+1<o&&(i=r.charCodeAt(n+1),(i&64512)===56320&&(t=65536+(t-55296<<10)+(i-56320),n++)),s+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(s),a=0,n=0;a<s;n++)t=r.charCodeAt(n),(t&64512)===55296&&n+1<o&&(i=r.charCodeAt(n+1),(i&64512)===56320&&(t=65536+(t-55296<<10)+(i-56320),n++)),t<128?e[a++]=t:t<2048?(e[a++]=192|t>>>6,e[a++]=128|t&63):t<65536?(e[a++]=224|t>>>12,e[a++]=128|t>>>6&63,e[a++]=128|t&63):(e[a++]=240|t>>>18,e[a++]=128|t>>>12&63,e[a++]=128|t>>>6&63,e[a++]=128|t&63);return e},zw=(r,e)=>{if(e<65534&&r.subarray&&ug)return String.fromCharCode.apply(null,r.length===e?r:r.subarray(0,e));let t="";for(let i=0;i<e;i++)t+=String.fromCharCode(r[i]);return t},Ww=(r,e)=>{let t=e||r.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(r.subarray(0,e));let i,n,a=new Array(t*2);for(n=0,i=0;i<t;){let o=r[i++];if(o<128){a[n++]=o;continue}let s=Do[o];if(s>4){a[n++]=65533,i+=s-1;continue}for(o&=s===2?31:s===3?15:7;s>1&&i<t;)o=o<<6|r[i++]&63,s--;if(s>1){a[n++]=65533;continue}o<65536?a[n++]=o:(o-=65536,a[n++]=55296|o>>10&1023,a[n++]=56320|o&1023)}return zw(a,n)},Gw=(r,e)=>{e=e||r.length,e>r.length&&(e=r.length);let t=e-1;for(;t>=0&&(r[t]&192)===128;)t--;return t<0||t===0?e:t+Do[r[t]]>e?t:e},Fo={string2buf:Hw,buf2string:Ww,utf8border:Gw};function Kw(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var pg=Kw,dg=Object.prototype.toString,{Z_NO_FLUSH:Jw,Z_SYNC_FLUSH:Zw,Z_FULL_FLUSH:Yw,Z_FINISH:Xw,Z_OK:Cc,Z_STREAM_END:eS,Z_DEFAULT_COMPRESSION:tS,Z_DEFAULT_STRATEGY:rS,Z_DEFLATED:iS}=vn;function Ho(r){this.options=Hc.assign({level:tS,method:iS,chunkSize:16384,windowBits:15,memLevel:8,strategy:rS},r||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new pg,this.strm.avail_out=0;let t=Eo.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(t!==Cc)throw new Error(cn[t]);if(e.header&&Eo.deflateSetHeader(this.strm,e.header),e.dictionary){let i;if(typeof e.dictionary=="string"?i=Fo.string2buf(e.dictionary):dg.call(e.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(e.dictionary):i=e.dictionary,t=Eo.deflateSetDictionary(this.strm,i),t!==Cc)throw new Error(cn[t]);this._dict_set=!0}}Ho.prototype.push=function(r,e){let t=this.strm,i=this.options.chunkSize,n,a;if(this.ended)return!1;for(e===~~e?a=e:a=e===!0?Xw:Jw,typeof r=="string"?t.input=Fo.string2buf(r):dg.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),(a===Zw||a===Yw)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(n=Eo.deflate(t,a),n===eS)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),n=Eo.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Cc;if(t.avail_out===0){this.onData(t.output);continue}if(a>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0};Ho.prototype.onData=function(r){this.chunks.push(r)};Ho.prototype.onEnd=function(r){r===Cc&&(this.result=Hc.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function Sp(r,e){let t=new Ho(e);if(t.push(r,!0),t.err)throw t.msg||cn[t.err];return t.result}function nS(r,e){return e=e||{},e.raw=!0,Sp(r,e)}function aS(r,e){return e=e||{},e.gzip=!0,Sp(r,e)}var oS=Ho,sS=Sp,cS=nS,lS=aS,uS=vn,pS={Deflate:oS,deflate:sS,deflateRaw:cS,gzip:lS,constants:uS},Gs=16209,dS=16191,fS=function r(e,t){let i,n,a,o,s,c,l,u,d,f,p,h,m,y,b,_,S,v,C,$,I,L,M,N,W=e.state;i=e.next_in,M=e.input,n=i+(e.avail_in-5),a=e.next_out,N=e.output,o=a-(t-e.avail_out),s=a+(e.avail_out-257),c=W.dmax,l=W.wsize,u=W.whave,d=W.wnext,f=W.window,p=W.hold,h=W.bits,m=W.lencode,y=W.distcode,b=(1<<W.lenbits)-1,_=(1<<W.distbits)-1;e:do{h<15&&(p+=M[i++]<<h,h+=8,p+=M[i++]<<h,h+=8),S=m[p&b];t:for(;;){if(v=S>>>24,p>>>=v,h-=v,v=S>>>16&255,v===0)N[a++]=S&65535;else if(v&16){C=S&65535,v&=15,v&&(h<v&&(p+=M[i++]<<h,h+=8),C+=p&(1<<v)-1,p>>>=v,h-=v),h<15&&(p+=M[i++]<<h,h+=8,p+=M[i++]<<h,h+=8),S=y[p&_];r:for(;;){if(v=S>>>24,p>>>=v,h-=v,v=S>>>16&255,v&16){if($=S&65535,v&=15,h<v&&(p+=M[i++]<<h,h+=8,h<v&&(p+=M[i++]<<h,h+=8)),$+=p&(1<<v)-1,$>c){e.msg="invalid distance too far back",W.mode=Gs;break e}if(p>>>=v,h-=v,v=a-o,$>v){if(v=$-v,v>u&&W.sane){e.msg="invalid distance too far back",W.mode=Gs;break e}if(I=0,L=f,d===0){if(I+=l-v,v<C){C-=v;do N[a++]=f[I++];while(--v);I=a-$,L=N}}else if(d<v){if(I+=l+d-v,v-=d,v<C){C-=v;do N[a++]=f[I++];while(--v);if(I=0,d<C){v=d,C-=v;do N[a++]=f[I++];while(--v);I=a-$,L=N}}}else if(I+=d-v,v<C){C-=v;do N[a++]=f[I++];while(--v);I=a-$,L=N}for(;C>2;)N[a++]=L[I++],N[a++]=L[I++],N[a++]=L[I++],C-=3;C&&(N[a++]=L[I++],C>1&&(N[a++]=L[I++]))}else{I=a-$;do N[a++]=N[I++],N[a++]=N[I++],N[a++]=N[I++],C-=3;while(C>2);C&&(N[a++]=N[I++],C>1&&(N[a++]=N[I++]))}}else if((v&64)===0){S=y[(S&65535)+(p&(1<<v)-1)];continue r}else{e.msg="invalid distance code",W.mode=Gs;break e}break}}else if((v&64)===0){S=m[(S&65535)+(p&(1<<v)-1)];continue t}else if(v&32){W.mode=dS;break e}else{e.msg="invalid literal/length code",W.mode=Gs;break e}break}}while(i<n&&a<s);C=h>>3,i-=C,h-=C<<3,p&=(1<<h)-1,e.next_in=i,e.next_out=a,e.avail_in=i<n?5+(n-i):5-(i-n),e.avail_out=a<s?257+(s-a):257-(a-s),W.hold=p,W.bits=h},Xn=15,Ih=852,Th=592,Ch=0,$u=1,Oh=2,hS=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),mS=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),gS=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),yS=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),vS=(r,e,t,i,n,a,o,s)=>{let c=s.bits,l=0,u=0,d=0,f=0,p=0,h=0,m=0,y=0,b=0,_=0,S,v,C,$,I,L=null,M,N=new Uint16Array(Xn+1),W=new Uint16Array(Xn+1),Ie=null,Oe,T,we;for(l=0;l<=Xn;l++)N[l]=0;for(u=0;u<i;u++)N[e[t+u]]++;for(p=c,f=Xn;f>=1&&N[f]===0;f--);if(p>f&&(p=f),f===0)return n[a++]=1<<24|64<<16|0,n[a++]=1<<24|64<<16|0,s.bits=1,0;for(d=1;d<f&&N[d]===0;d++);for(p<d&&(p=d),y=1,l=1;l<=Xn;l++)if(y<<=1,y-=N[l],y<0)return-1;if(y>0&&(r===Ch||f!==1))return-1;for(W[1]=0,l=1;l<Xn;l++)W[l+1]=W[l]+N[l];for(u=0;u<i;u++)e[t+u]!==0&&(o[W[e[t+u]]++]=u);if(r===Ch?(L=Ie=o,M=20):r===$u?(L=hS,Ie=mS,M=257):(L=gS,Ie=yS,M=0),_=0,u=0,l=d,I=a,h=p,m=0,C=-1,b=1<<p,$=b-1,r===$u&&b>Ih||r===Oh&&b>Th)return 1;for(;;){Oe=l-m,o[u]+1<M?(T=0,we=o[u]):o[u]>=M?(T=Ie[o[u]-M],we=L[o[u]-M]):(T=32+64,we=0),S=1<<l-m,v=1<<h,d=v;do v-=S,n[I+(_>>m)+v]=Oe<<24|T<<16|we|0;while(v!==0);for(S=1<<l-1;_&S;)S>>=1;if(S!==0?(_&=S-1,_+=S):_=0,u++,--N[l]===0){if(l===f)break;l=e[t+o[u]]}if(l>p&&(_&$)!==C){for(m===0&&(m=p),I+=d,h=l-m,y=1<<h;h+m<f&&(y-=N[h+m],!(y<=0));)h++,y<<=1;if(b+=1<<h,r===$u&&b>Ih||r===Oh&&b>Th)return 1;C=_&$,n[C]=p<<24|h<<16|I-a|0}}return _!==0&&(n[I+_]=l-m<<24|64<<16|0),s.bits=p,0},ko=vS,bS=0,fg=1,hg=2,{Z_FINISH:$h,Z_BLOCK:wS,Z_TREES:Ks,Z_OK:un,Z_STREAM_END:SS,Z_NEED_DICT:_S,Z_STREAM_ERROR:Kt,Z_DATA_ERROR:mg,Z_MEM_ERROR:gg,Z_BUF_ERROR:xS,Z_DEFLATED:Ph}=vn,zc=16180,Rh=16181,Lh=16182,Nh=16183,Dh=16184,Fh=16185,Mh=16186,Uh=16187,jh=16188,qh=16189,Oc=16190,Cr=16191,Pu=16192,Bh=16193,Ru=16194,Vh=16195,Qh=16196,Hh=16197,zh=16198,Js=16199,Zs=16200,Wh=16201,Gh=16202,Kh=16203,Jh=16204,Zh=16205,Lu=16206,Yh=16207,Xh=16208,Te=16209,yg=16210,vg=16211,ES=852,kS=592,AS=15,IS=AS,em=r=>(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24);function TS(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var bn=r=>{if(!r)return 1;let e=r.state;return!e||e.strm!==r||e.mode<zc||e.mode>vg?1:0},bg=r=>{if(bn(r))return Kt;let e=r.state;return r.total_in=r.total_out=e.total=0,r.msg="",e.wrap&&(r.adler=e.wrap&1),e.mode=zc,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(ES),e.distcode=e.distdyn=new Int32Array(kS),e.sane=1,e.back=-1,un},wg=r=>{if(bn(r))return Kt;let e=r.state;return e.wsize=0,e.whave=0,e.wnext=0,bg(r)},Sg=(r,e)=>{let t;if(bn(r))return Kt;let i=r.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?Kt:(i.window!==null&&i.wbits!==e&&(i.window=null),i.wrap=t,i.wbits=e,wg(r))},_g=(r,e)=>{if(!r)return Kt;let t=new TS;r.state=t,t.strm=r,t.window=null,t.mode=zc;let i=Sg(r,e);return i!==un&&(r.state=null),i},CS=r=>_g(r,IS),tm=!0,Nu,Du,OS=r=>{if(tm){Nu=new Int32Array(512),Du=new Int32Array(32);let e=0;for(;e<144;)r.lens[e++]=8;for(;e<256;)r.lens[e++]=9;for(;e<280;)r.lens[e++]=7;for(;e<288;)r.lens[e++]=8;for(ko(fg,r.lens,0,288,Nu,0,r.work,{bits:9}),e=0;e<32;)r.lens[e++]=5;ko(hg,r.lens,0,32,Du,0,r.work,{bits:5}),tm=!1}r.lencode=Nu,r.lenbits=9,r.distcode=Du,r.distbits=5},xg=(r,e,t,i)=>{let n,a=r.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),i>=a.wsize?(a.window.set(e.subarray(t-a.wsize,t),0),a.wnext=0,a.whave=a.wsize):(n=a.wsize-a.wnext,n>i&&(n=i),a.window.set(e.subarray(t-i,t-i+n),a.wnext),i-=n,i?(a.window.set(e.subarray(t-i,t),0),a.wnext=i,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=n))),0},$S=(r,e)=>{let t,i,n,a,o,s,c,l,u,d,f,p,h,m,y=0,b,_,S,v,C,$,I,L,M=new Uint8Array(4),N,W,Ie=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(bn(r)||!r.output||!r.input&&r.avail_in!==0)return Kt;t=r.state,t.mode===Cr&&(t.mode=Pu),o=r.next_out,n=r.output,c=r.avail_out,a=r.next_in,i=r.input,s=r.avail_in,l=t.hold,u=t.bits,d=s,f=c,L=un;e:for(;;)switch(t.mode){case zc:if(t.wrap===0){t.mode=Pu;break}for(;u<16;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}if(t.wrap&2&&l===35615){t.wbits===0&&(t.wbits=15),t.check=0,M[0]=l&255,M[1]=l>>>8&255,t.check=Ze(t.check,M,2,0),l=0,u=0,t.mode=Rh;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((l&255)<<8)+(l>>8))%31){r.msg="incorrect header check",t.mode=Te;break}if((l&15)!==Ph){r.msg="unknown compression method",t.mode=Te;break}if(l>>>=4,u-=4,I=(l&15)+8,t.wbits===0&&(t.wbits=I),I>15||I>t.wbits){r.msg="invalid window size",t.mode=Te;break}t.dmax=1<<t.wbits,t.flags=0,r.adler=t.check=1,t.mode=l&512?qh:Cr,l=0,u=0;break;case Rh:for(;u<16;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}if(t.flags=l,(t.flags&255)!==Ph){r.msg="unknown compression method",t.mode=Te;break}if(t.flags&57344){r.msg="unknown header flags set",t.mode=Te;break}t.head&&(t.head.text=l>>8&1),t.flags&512&&t.wrap&4&&(M[0]=l&255,M[1]=l>>>8&255,t.check=Ze(t.check,M,2,0)),l=0,u=0,t.mode=Lh;case Lh:for(;u<32;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}t.head&&(t.head.time=l),t.flags&512&&t.wrap&4&&(M[0]=l&255,M[1]=l>>>8&255,M[2]=l>>>16&255,M[3]=l>>>24&255,t.check=Ze(t.check,M,4,0)),l=0,u=0,t.mode=Nh;case Nh:for(;u<16;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}t.head&&(t.head.xflags=l&255,t.head.os=l>>8),t.flags&512&&t.wrap&4&&(M[0]=l&255,M[1]=l>>>8&255,t.check=Ze(t.check,M,2,0)),l=0,u=0,t.mode=Dh;case Dh:if(t.flags&1024){for(;u<16;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}t.length=l,t.head&&(t.head.extra_len=l),t.flags&512&&t.wrap&4&&(M[0]=l&255,M[1]=l>>>8&255,t.check=Ze(t.check,M,2,0)),l=0,u=0}else t.head&&(t.head.extra=null);t.mode=Fh;case Fh:if(t.flags&1024&&(p=t.length,p>s&&(p=s),p&&(t.head&&(I=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(i.subarray(a,a+p),I)),t.flags&512&&t.wrap&4&&(t.check=Ze(t.check,i,p,a)),s-=p,a+=p,t.length-=p),t.length))break e;t.length=0,t.mode=Mh;case Mh:if(t.flags&2048){if(s===0)break e;p=0;do I=i[a+p++],t.head&&I&&t.length<65536&&(t.head.name+=String.fromCharCode(I));while(I&&p<s);if(t.flags&512&&t.wrap&4&&(t.check=Ze(t.check,i,p,a)),s-=p,a+=p,I)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=Uh;case Uh:if(t.flags&4096){if(s===0)break e;p=0;do I=i[a+p++],t.head&&I&&t.length<65536&&(t.head.comment+=String.fromCharCode(I));while(I&&p<s);if(t.flags&512&&t.wrap&4&&(t.check=Ze(t.check,i,p,a)),s-=p,a+=p,I)break e}else t.head&&(t.head.comment=null);t.mode=jh;case jh:if(t.flags&512){for(;u<16;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}if(t.wrap&4&&l!==(t.check&65535)){r.msg="header crc mismatch",t.mode=Te;break}l=0,u=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),r.adler=t.check=0,t.mode=Cr;break;case qh:for(;u<32;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}r.adler=t.check=em(l),l=0,u=0,t.mode=Oc;case Oc:if(t.havedict===0)return r.next_out=o,r.avail_out=c,r.next_in=a,r.avail_in=s,t.hold=l,t.bits=u,_S;r.adler=t.check=1,t.mode=Cr;case Cr:if(e===wS||e===Ks)break e;case Pu:if(t.last){l>>>=u&7,u-=u&7,t.mode=Lu;break}for(;u<3;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}switch(t.last=l&1,l>>>=1,u-=1,l&3){case 0:t.mode=Bh;break;case 1:if(OS(t),t.mode=Js,e===Ks){l>>>=2,u-=2;break e}break;case 2:t.mode=Qh;break;case 3:r.msg="invalid block type",t.mode=Te}l>>>=2,u-=2;break;case Bh:for(l>>>=u&7,u-=u&7;u<32;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}if((l&65535)!==(l>>>16^65535)){r.msg="invalid stored block lengths",t.mode=Te;break}if(t.length=l&65535,l=0,u=0,t.mode=Ru,e===Ks)break e;case Ru:t.mode=Vh;case Vh:if(p=t.length,p){if(p>s&&(p=s),p>c&&(p=c),p===0)break e;n.set(i.subarray(a,a+p),o),s-=p,a+=p,c-=p,o+=p,t.length-=p;break}t.mode=Cr;break;case Qh:for(;u<14;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}if(t.nlen=(l&31)+257,l>>>=5,u-=5,t.ndist=(l&31)+1,l>>>=5,u-=5,t.ncode=(l&15)+4,l>>>=4,u-=4,t.nlen>286||t.ndist>30){r.msg="too many length or distance symbols",t.mode=Te;break}t.have=0,t.mode=Hh;case Hh:for(;t.have<t.ncode;){for(;u<3;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}t.lens[Ie[t.have++]]=l&7,l>>>=3,u-=3}for(;t.have<19;)t.lens[Ie[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,N={bits:t.lenbits},L=ko(bS,t.lens,0,19,t.lencode,0,t.work,N),t.lenbits=N.bits,L){r.msg="invalid code lengths set",t.mode=Te;break}t.have=0,t.mode=zh;case zh:for(;t.have<t.nlen+t.ndist;){for(;y=t.lencode[l&(1<<t.lenbits)-1],b=y>>>24,_=y>>>16&255,S=y&65535,!(b<=u);){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}if(S<16)l>>>=b,u-=b,t.lens[t.have++]=S;else{if(S===16){for(W=b+2;u<W;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}if(l>>>=b,u-=b,t.have===0){r.msg="invalid bit length repeat",t.mode=Te;break}I=t.lens[t.have-1],p=3+(l&3),l>>>=2,u-=2}else if(S===17){for(W=b+3;u<W;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}l>>>=b,u-=b,I=0,p=3+(l&7),l>>>=3,u-=3}else{for(W=b+7;u<W;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}l>>>=b,u-=b,I=0,p=11+(l&127),l>>>=7,u-=7}if(t.have+p>t.nlen+t.ndist){r.msg="invalid bit length repeat",t.mode=Te;break}for(;p--;)t.lens[t.have++]=I}}if(t.mode===Te)break;if(t.lens[256]===0){r.msg="invalid code -- missing end-of-block",t.mode=Te;break}if(t.lenbits=9,N={bits:t.lenbits},L=ko(fg,t.lens,0,t.nlen,t.lencode,0,t.work,N),t.lenbits=N.bits,L){r.msg="invalid literal/lengths set",t.mode=Te;break}if(t.distbits=6,t.distcode=t.distdyn,N={bits:t.distbits},L=ko(hg,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,N),t.distbits=N.bits,L){r.msg="invalid distances set",t.mode=Te;break}if(t.mode=Js,e===Ks)break e;case Js:t.mode=Zs;case Zs:if(s>=6&&c>=258){r.next_out=o,r.avail_out=c,r.next_in=a,r.avail_in=s,t.hold=l,t.bits=u,fS(r,f),o=r.next_out,n=r.output,c=r.avail_out,a=r.next_in,i=r.input,s=r.avail_in,l=t.hold,u=t.bits,t.mode===Cr&&(t.back=-1);break}for(t.back=0;y=t.lencode[l&(1<<t.lenbits)-1],b=y>>>24,_=y>>>16&255,S=y&65535,!(b<=u);){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}if(_&&(_&240)===0){for(v=b,C=_,$=S;y=t.lencode[$+((l&(1<<v+C)-1)>>v)],b=y>>>24,_=y>>>16&255,S=y&65535,!(v+b<=u);){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}l>>>=v,u-=v,t.back+=v}if(l>>>=b,u-=b,t.back+=b,t.length=S,_===0){t.mode=Zh;break}if(_&32){t.back=-1,t.mode=Cr;break}if(_&64){r.msg="invalid literal/length code",t.mode=Te;break}t.extra=_&15,t.mode=Wh;case Wh:if(t.extra){for(W=t.extra;u<W;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}t.length+=l&(1<<t.extra)-1,l>>>=t.extra,u-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=Gh;case Gh:for(;y=t.distcode[l&(1<<t.distbits)-1],b=y>>>24,_=y>>>16&255,S=y&65535,!(b<=u);){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}if((_&240)===0){for(v=b,C=_,$=S;y=t.distcode[$+((l&(1<<v+C)-1)>>v)],b=y>>>24,_=y>>>16&255,S=y&65535,!(v+b<=u);){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}l>>>=v,u-=v,t.back+=v}if(l>>>=b,u-=b,t.back+=b,_&64){r.msg="invalid distance code",t.mode=Te;break}t.offset=S,t.extra=_&15,t.mode=Kh;case Kh:if(t.extra){for(W=t.extra;u<W;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}t.offset+=l&(1<<t.extra)-1,l>>>=t.extra,u-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){r.msg="invalid distance too far back",t.mode=Te;break}t.mode=Jh;case Jh:if(c===0)break e;if(p=f-c,t.offset>p){if(p=t.offset-p,p>t.whave&&t.sane){r.msg="invalid distance too far back",t.mode=Te;break}p>t.wnext?(p-=t.wnext,h=t.wsize-p):h=t.wnext-p,p>t.length&&(p=t.length),m=t.window}else m=n,h=o-t.offset,p=t.length;p>c&&(p=c),c-=p,t.length-=p;do n[o++]=m[h++];while(--p);t.length===0&&(t.mode=Zs);break;case Zh:if(c===0)break e;n[o++]=t.length,c--,t.mode=Zs;break;case Lu:if(t.wrap){for(;u<32;){if(s===0)break e;s--,l|=i[a++]<<u,u+=8}if(f-=c,r.total_out+=f,t.total+=f,t.wrap&4&&f&&(r.adler=t.check=t.flags?Ze(t.check,n,f,o-f):No(t.check,n,f,o-f)),f=c,t.wrap&4&&(t.flags?l:em(l))!==t.check){r.msg="incorrect data check",t.mode=Te;break}l=0,u=0}t.mode=Yh;case Yh:if(t.wrap&&t.flags){for(;u<32;){if(s===0)break e;s--,l+=i[a++]<<u,u+=8}if(t.wrap&4&&l!==(t.total&4294967295)){r.msg="incorrect length check",t.mode=Te;break}l=0,u=0}t.mode=Xh;case Xh:L=SS;break e;case Te:L=mg;break e;case yg:return gg;case vg:default:return Kt}return r.next_out=o,r.avail_out=c,r.next_in=a,r.avail_in=s,t.hold=l,t.bits=u,(t.wsize||f!==r.avail_out&&t.mode<Te&&(t.mode<Lu||e!==$h))&&xg(r,r.output,r.next_out,f-r.avail_out),d-=r.avail_in,f-=r.avail_out,r.total_in+=d,r.total_out+=f,t.total+=f,t.wrap&4&&f&&(r.adler=t.check=t.flags?Ze(t.check,n,f,r.next_out-f):No(t.check,n,f,r.next_out-f)),r.data_type=t.bits+(t.last?64:0)+(t.mode===Cr?128:0)+(t.mode===Js||t.mode===Ru?256:0),(d===0&&f===0||e===$h)&&L===un&&(L=xS),L},PS=r=>{if(bn(r))return Kt;let e=r.state;return e.window&&(e.window=null),r.state=null,un},RS=(r,e)=>{if(bn(r))return Kt;let t=r.state;return(t.wrap&2)===0?Kt:(t.head=e,e.done=!1,un)},LS=(r,e)=>{let t=e.length,i,n,a;return bn(r)||(i=r.state,i.wrap!==0&&i.mode!==Oc)?Kt:i.mode===Oc&&(n=1,n=No(n,e,t,0),n!==i.check)?mg:(a=xg(r,e,t,t),a?(i.mode=yg,gg):(i.havedict=1,un))},NS=wg,DS=Sg,FS=bg,MS=CS,US=_g,jS=$S,qS=PS,BS=RS,VS=LS,QS="pako inflate (from Nodeca project)",Rr={inflateReset:NS,inflateReset2:DS,inflateResetKeep:FS,inflateInit:MS,inflateInit2:US,inflate:jS,inflateEnd:qS,inflateGetHeader:BS,inflateSetDictionary:VS,inflateInfo:QS};function HS(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var zS=HS,Eg=Object.prototype.toString,{Z_NO_FLUSH:WS,Z_FINISH:GS,Z_OK:Mo,Z_STREAM_END:Fu,Z_NEED_DICT:Mu,Z_STREAM_ERROR:KS,Z_DATA_ERROR:rm,Z_MEM_ERROR:JS}=vn;function zo(r){this.options=Hc.assign({chunkSize:1024*64,windowBits:15,to:""},r||{});let e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(r&&r.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15)===0&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new pg,this.strm.avail_out=0;let t=Rr.inflateInit2(this.strm,e.windowBits);if(t!==Mo)throw new Error(cn[t]);if(this.header=new zS,Rr.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Fo.string2buf(e.dictionary):Eg.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=Rr.inflateSetDictionary(this.strm,e.dictionary),t!==Mo)))throw new Error(cn[t])}zo.prototype.push=function(r,e){let t=this.strm,i=this.options.chunkSize,n=this.options.dictionary,a,o,s;if(this.ended)return!1;for(e===~~e?o=e:o=e===!0?GS:WS,Eg.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),a=Rr.inflate(t,o),a===Mu&&n&&(a=Rr.inflateSetDictionary(t,n),a===Mo?a=Rr.inflate(t,o):a===rm&&(a=Mu));t.avail_in>0&&a===Fu&&t.state.wrap>0&&r[t.next_in]!==0;)Rr.inflateReset(t),a=Rr.inflate(t,o);switch(a){case KS:case rm:case Mu:case JS:return this.onEnd(a),this.ended=!0,!1}if(s=t.avail_out,t.next_out&&(t.avail_out===0||a===Fu))if(this.options.to==="string"){let c=Fo.utf8border(t.output,t.next_out),l=t.next_out-c,u=Fo.buf2string(t.output,c);t.next_out=l,t.avail_out=i-l,l&&t.output.set(t.output.subarray(c,c+l),0),this.onData(u)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(a===Mo&&s===0)){if(a===Fu)return a=Rr.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};zo.prototype.onData=function(r){this.chunks.push(r)};zo.prototype.onEnd=function(r){r===Mo&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Hc.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function _p(r,e){let t=new zo(e);if(t.push(r),t.err)throw t.msg||cn[t.err];return t.result}function ZS(r,e){return e=e||{},e.raw=!0,_p(r,e)}var YS=zo,XS=_p,e1=ZS,t1=_p,r1=vn,i1={Inflate:YS,inflate:XS,inflateRaw:e1,ungzip:t1,constants:r1},{Deflate:n1,deflate:a1,deflateRaw:o1,gzip:s1}=pS,{Inflate:c1,inflate:l1,inflateRaw:u1,ungzip:p1}=i1,d1=n1,f1=a1,h1=o1,m1=s1,g1=c1,y1=l1,v1=u1,b1=p1,w1=vn,S1={Deflate:d1,deflate:f1,deflateRaw:h1,gzip:m1,Inflate:g1,inflate:y1,inflateRaw:v1,ungzip:b1,constants:w1},Ee=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},ke=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},$c=class{constructor(e,t){this.input=e,this.output=t}};Ee([w(),ke("design:type",String)],$c.prototype,"input",void 0);Ee([w(),ke("design:type",String)],$c.prototype,"output",void 0);$c=Ee([Xe(),ke("design:paramtypes",[String,String])],$c);var Pc=class{constructor(e,t){this.input=e,this.output=t}};Ee([w(),ke("design:type",String)],Pc.prototype,"input",void 0);Ee([w(),ke("design:type",String)],Pc.prototype,"output",void 0);Pc=Ee([J(),ke("design:paramtypes",[String,String])],Pc);var yi=class{constructor(e,t,i,n,a){this.name=e,this.modelId=t,this.systemPrompt=i,this.promptExamples=n,this.metaData=a}};Ee([w(),ke("design:type",String)],yi.prototype,"name",void 0);Ee([w(),ke("design:type",String)],yi.prototype,"modelId",void 0);Ee([w(),ke("design:type",String)],yi.prototype,"systemPrompt",void 0);Ee([w(),ke("design:type",Array)],yi.prototype,"promptExamples",void 0);Ee([w(),ke("design:type",String)],yi.prototype,"metaData",void 0);yi=Ee([Xe(),ke("design:paramtypes",[String,String,String,Array,String])],yi);var xr=class{constructor(e,t,i,n,a,o,s,c){this.name=e,this.modelId=t,this.taskId=i,this.systemPrompt=n,this.promptExamples=a,this.metaData=o,this.createdAt=s,this.updatedAt=c}};Ee([w(),ke("design:type",String)],xr.prototype,"name",void 0);Ee([w(),ke("design:type",String)],xr.prototype,"modelId",void 0);Ee([w(),ke("design:type",String)],xr.prototype,"taskId",void 0);Ee([w(),ke("design:type",String)],xr.prototype,"systemPrompt",void 0);Ee([w(),ke("design:type",Array)],xr.prototype,"promptExamples",void 0);Ee([w(),ke("design:type",String)],xr.prototype,"metaData",void 0);Ee([w(),ke("design:type",String)],xr.prototype,"createdAt",void 0);Ee([w(),ke("design:type",String)],xr.prototype,"updatedAt",void 0);xr=Ee([J(),ke("design:paramtypes",[String,String,String,String,Array,String,String,String])],xr);var pn=class{constructor(e,t,i,n,a){this.model=e,this.status=t,this.progress=i,this.downloaded=n,this.loaded=a}};Ee([w(),ke("design:type",String)],pn.prototype,"model",void 0);Ee([w(),ke("design:type",String)],pn.prototype,"status",void 0);Ee([w(),ke("design:type",Number)],pn.prototype,"progress",void 0);Ee([w(),ke("design:type",Boolean)],pn.prototype,"downloaded",void 0);Ee([w(),ke("design:type",Boolean)],pn.prototype,"loaded",void 0);pn=Ee([J(),ke("design:paramtypes",[String,String,Number,Boolean,Boolean])],pn);var _1=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},We=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},He,dc,cp=class{constructor(e,t=!0){He.set(this,void 0),dc.set(this,new Map),_1(this,He,e,"f")}async getModels(){let e=await We(this,He,"f").query({query:x`
850
- query {
851
- aiGetModels {
852
- id
853
- name
854
- api {
855
- baseUrl
856
- apiKey
857
- model
858
- apiType
859
- }
860
- local {
861
- fileName
862
- tokenizerSource {
863
- repo
864
- revision
865
- fileName
866
- }
867
- huggingfaceRepo
868
- revision
869
- }
870
- modelType
871
- }
872
- }
873
- `});return k(e).aiGetModels}async addModel(e){let t=await We(this,He,"f").mutate({mutation:x`
874
- mutation($model: ModelInput!) {
875
- aiAddModel(model: $model)
876
- }
877
- `,variables:{model:e}});return k(t).aiAddModel}async updateModel(e,t){let i=await We(this,He,"f").mutate({mutation:x`
878
- mutation($modelId: String!, $model: ModelInput!) {
879
- aiUpdateModel(modelId: $modelId, model: $model)
880
- }
881
- `,variables:{modelId:e,model:t}});return k(i).aiUpdateModel}async removeModel(e){let t=await We(this,He,"f").mutate({mutation:x`
882
- mutation($modelId: String!) {
883
- aiRemoveModel(modelId: $modelId)
884
- }
885
- `,variables:{modelId:e}});return k(t).aiRemoveModel}async setDefaultModel(e,t){let i=await We(this,He,"f").mutate({mutation:x`
886
- mutation($modelType: ModelType!, $modelId: String!) {
887
- aiSetDefaultModel(modelType: $modelType modelId: $modelId)
888
- }
889
- `,variables:{modelId:t,modelType:e}});return k(i).aiSetDefaultModel}async getDefaultModel(e){let t=await We(this,He,"f").query({query:x`
890
- query($modelType: ModelType!) {
891
- aiGetDefaultModel(modelType: $modelType) {
892
- id
893
- name
894
- api {
895
- baseUrl
896
- apiKey
897
- model
898
- apiType
899
- }
900
- local {
901
- fileName
902
- tokenizerSource {
903
- repo
904
- revision
905
- fileName
906
- }
907
- huggingfaceRepo
908
- revision
909
- }
910
- modelType
911
- }
912
- }
913
- `,variables:{modelType:e}});return k(t).aiGetDefaultModel}async tasks(){let{aiTasks:e}=k(await We(this,He,"f").query({query:x`
914
- query {
915
- aiTasks {
916
- name
917
- modelId
918
- taskId
919
- systemPrompt
920
- promptExamples {
921
- input
922
- output
923
- }
924
- metaData
925
- createdAt
926
- updatedAt
927
- }
928
- }
929
- `}));return e}async addTask(e,t,i,n,a){let o=new yi(e,t,i,n,a),{aiAddTask:s}=k(await We(this,He,"f").mutate({mutation:x`
930
- mutation AiAddTask($task: AITaskInput!) {
931
- aiAddTask(task: $task) {
932
- name
933
- modelId
934
- taskId
935
- systemPrompt
936
- promptExamples {
937
- input
938
- output
939
- }
940
- metaData
941
- createdAt
942
- updatedAt
943
- }
944
- }
945
- `,variables:{task:o}}));return s}async removeTask(e){let{aiRemoveTask:t}=k(await We(this,He,"f").mutate({mutation:x`
946
- mutation AiRemoveTask($taskId: String!) {
947
- aiRemoveTask(taskId: $taskId) {
948
- name
949
- modelId
950
- taskId
951
- systemPrompt
952
- promptExamples {
953
- input
954
- output
955
- }
956
- metaData
957
- createdAt
958
- updatedAt
959
- }
960
- }
961
- `,variables:{taskId:e}}));return t}async updateTask(e,t){let{aiUpdateTask:i}=k(await We(this,He,"f").mutate({mutation:x`
962
- mutation AiUpdateTask($taskId: String!, $task: AITaskInput!) {
963
- aiUpdateTask(taskId: $taskId, task: $task) {
964
- name
965
- modelId
966
- taskId
967
- systemPrompt
968
- promptExamples {
969
- input
970
- output
971
- }
972
- metaData
973
- createdAt
974
- updatedAt
975
- }
976
- }
977
- `,variables:{taskId:e,task:{name:t.name,modelId:t.modelId,systemPrompt:t.systemPrompt,promptExamples:t.promptExamples}}}));return i}async modelLoadingStatus(e){let{aiModelLoadingStatus:t}=k(await We(this,He,"f").query({query:x`
978
- query AiModelLoadingStatus($model: String!) {
979
- aiModelLoadingStatus(model: $model) {
980
- model
981
- status
982
- progress
983
- loaded
984
- downloaded
985
- }
986
- }
987
- `,variables:{model:e}}));return t}async prompt(e,t){let{aiPrompt:i}=k(await We(this,He,"f").mutate({mutation:x`
988
- mutation AiPrompt($taskId: String!, $prompt: String!) {
989
- aiPrompt(taskId: $taskId, prompt: $prompt)
990
- }
991
- `,variables:{taskId:e,prompt:t}}));return i}async embed(e,t){let{aiEmbed:i}=k(await We(this,He,"f").mutate({mutation:x`
992
- mutation aiEmbed($modelId: String!, $text: String!) {
993
- aiEmbed(modelId: $modelId, text: $text)
994
- }
995
- `,variables:{modelId:e,text:t}})),n=Vc.toByteArray(i);return JSON.parse(S1.inflate(n,{to:"string"}))}async openTranscriptionStream(e,t,i){let{aiOpenTranscriptionStream:n}=k(await We(this,He,"f").mutate({mutation:x`
996
- mutation AiOpenTranscriptionStream($modelId: String!, $params: VoiceActivityParamsInput) {
997
- aiOpenTranscriptionStream(modelId: $modelId, params: $params)
998
- }
999
- `,variables:{modelId:e,params:i}})),a=We(this,He,"f").subscribe({query:x` subscription {
1000
- aiTranscriptionText(streamId: "${n}")
1001
- }`}).subscribe({next(o){return t(o.data.aiTranscriptionText),o.data.aiTranscriptionText},error(o){console.error(o)}});return We(this,dc,"f").set(n,a),n}async closeTranscriptionStream(e){let{aiCloseTranscriptionStream:t}=k(await We(this,He,"f").mutate({mutation:x`
1002
- mutation aiCloseTranscriptionStream($streamId: String!) {
1003
- aiCloseTranscriptionStream(streamId: $streamId)
1004
- }
1005
- `,variables:{streamId:e}})),i=We(this,dc,"f").get(e);return i.closed||i.unsubscribe(),t}async feedTranscriptionStream(e,t){let{aiFeedTranscriptionStream:i}=k(await We(this,He,"f").mutate({mutation:x`
1006
- mutation AiFeedTranscriptionStream($streamIds: [String!]!, $audio: [Float!]!) {
1007
- aiFeedTranscriptionStream(streamIds: $streamIds, audio: $audio)
1008
- }
1009
- `,variables:{streamIds:Array.isArray(e)?e:[e],audio:t}}));return i}};He=new WeakMap,dc=new WeakMap;var ri=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},Qe=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},fr,fc,go,hc,yo,Gi,mc,vo,Uo=class{constructor(e,t=!0){fr.set(this,void 0),fc.set(this,void 0),go.set(this,void 0),hc.set(this,void 0),yo.set(this,void 0),Gi.set(this,void 0),mc.set(this,void 0),vo.set(this,void 0),ri(this,fr,e,"f"),ri(this,fc,new Oo(Qe(this,fr,"f"),t),"f"),ri(this,go,new Yu(Qe(this,fr,"f")),"f"),ri(this,hc,new Ku(Qe(this,fr,"f")),"f"),ri(this,yo,new Ju(Qe(this,fr,"f")),"f"),ri(this,vo,new cp(Qe(this,fr,"f"),t),"f"),ri(this,Gi,new Ic(Qe(this,fr,"f"),t),"f"),Qe(this,Gi,"f").setExpressionClient(Qe(this,go,"f")),Qe(this,Gi,"f").setNeighbourhoodClient(Qe(this,yo,"f")),Qe(this,Gi,"f").setAIClient(Qe(this,vo,"f")),ri(this,mc,new Zu(Qe(this,fr,"f"),t),"f")}get agent(){return Qe(this,fc,"f")}get expression(){return Qe(this,go,"f")}get languages(){return Qe(this,hc,"f")}get neighbourhood(){return Qe(this,yo,"f")}get perspective(){return Qe(this,Gi,"f")}get runtime(){return Qe(this,mc,"f")}get ai(){return Qe(this,vo,"f")}};fr=new WeakMap,fc=new WeakMap,go=new WeakMap,hc=new WeakMap,yo=new WeakMap,Gi=new WeakMap,mc=new WeakMap,vo=new WeakMap;var lp;(function(r){r.LanguageIsNotLoaded="LANGUAGE_IS_NOT_LOADED",r.ExpressionIsNotVerified="EXPRESSION_IS_NOT_VERIFIED",r.AgentIsUntrusted="AGENT_IS_UNTRUSTED",r.CapabilityRequested="CAPABILITY_REQUESTED",r.InstallNotificationRequest="INSTALL_NOTIFICATION_REQUEST"})(lp||(lp={}));var xp=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Ep=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},en=class{constructor(e,t){this.language=e,this.expression=t}};xp([w(),Ep("design:type",yr)],en.prototype,"language",void 0);xp([w(),Ep("design:type",String)],en.prototype,"expression",void 0);en=xp([J(),Ep("design:paramtypes",[yr,String])],en);function PO(r){return r.language.address==="did"?r.expression.toString():`${r.language.address}://${r.expression}`}function RO(r){if(r.startsWith("literal:")){let a=new yr;a.address="literal",a.name="literal";let o=r.substring(8);return new en(a,o)}let t=/^([^:^\s]+):\/\/([\s\S]+)$/.exec(r);if(t&&t.length==3){let a=t[1],o=t[2],s=new yr;return s.address=a,new en(s,o)}let n=/^did:([^\s]+)$/.exec(r);if(n&&n.length==2){let a=new yr;return a.address="did",new en(a,r)}throw new Error("Couldn't parse string as expression URL or DID: "+r)}var Ut=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Er=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Rc=class{};Ut([w(),Er("design:type",String)],Rc.prototype,"name",void 0);Ut([w(),Er("design:type",String)],Rc.prototype,"type",void 0);Rc=Ut([J()],Rc);var jo=class{};Ut([w(),Er("design:type",String)],jo.prototype,"label",void 0);Ut([w(),Er("design:type",String)],jo.prototype,"name",void 0);Ut([w(),Er("design:type",Array)],jo.prototype,"parameters",void 0);jo=Ut([J()],jo);var Lc=class{get parameters(){return JSON.parse(this.parametersStringified)}constructor(e,t){this.name=e,this.parametersStringified=JSON.stringify(t)}};Ut([w(),Er("design:type",String)],Lc.prototype,"name",void 0);Ut([w(),Er("design:type",String)],Lc.prototype,"parametersStringified",void 0);Lc=Ut([Xe(),Er("design:paramtypes",[String,Object])],Lc);var Nc=class{};Ut([w(),Er("design:type",String)],Nc.prototype,"did",void 0);Ut([w(),Er("design:type",an)],Nc.prototype,"status",void 0);Nc=Ut([J()],Nc);var im=class{},wn=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},wa=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},vi=class{};wn([w(),wa("design:type",String)],vi.prototype,"name",void 0);wn([w(),wa("design:type",String)],vi.prototype,"address",void 0);wn([w(),wa("design:type",String)],vi.prototype,"settings",void 0);wn([w(),wa("design:type",rn)],vi.prototype,"icon",void 0);wn([w(),wa("design:type",rn)],vi.prototype,"constructorIcon",void 0);wn([w(),wa("design:type",rn)],vi.prototype,"settingsIcon",void 0);vi=wn([J()],vi);var bt=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Ct=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},ar=class{};bt([w(),Ct("design:type",String)],ar.prototype,"name",void 0);bt([w(),Ct("design:type",String)],ar.prototype,"address",void 0);bt([w(),Ct("design:type",String)],ar.prototype,"description",void 0);bt([w(),Ct("design:type",String)],ar.prototype,"author",void 0);bt([w(),Ct("design:type",Boolean)],ar.prototype,"templated",void 0);bt([w(),Ct("design:type",String)],ar.prototype,"templateSourceLanguageAddress",void 0);bt([w(),Ct("design:type",String)],ar.prototype,"templateAppliedParams",void 0);bt([w(),Ct("design:type",Array)],ar.prototype,"possibleTemplateParams",void 0);bt([w(),Ct("design:type",String)],ar.prototype,"sourceCodeLink",void 0);ar=bt([J()],ar);var pa=class{constructor(e,t){this.name=e,this.description=t,this.description||(this.description="")}};bt([w(),Ct("design:type",String)],pa.prototype,"name",void 0);bt([w(),Ct("design:type",String)],pa.prototype,"description",void 0);bt([w(),Ct("design:type",Array)],pa.prototype,"possibleTemplateParams",void 0);bt([w(),Ct("design:type",String)],pa.prototype,"sourceCodeLink",void 0);pa=bt([Xe(),Ct("design:paramtypes",[String,String])],pa);var nm=class{},am=class extends _i(){},om=class{},Wc=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},kp=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Dc=class{constructor(e,t){this.linkLanguage=e,this.meta=t}};Wc([w(),kp("design:type",String)],Dc.prototype,"linkLanguage",void 0);Wc([w(),kp("design:type",Sr)],Dc.prototype,"meta",void 0);Dc=Wc([J(),kp("design:paramtypes",[String,Sr])],Dc);var up=class extends _i(){};up=Wc([J()],up);var Sn=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},_n=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},pp;(function(r){r.Private="PRIVATE",r.NeighboudhoodCreationInitiated="NEIGHBOURHOOD_CREATION_INITIATED",r.NeighbourhoodJoinInitiated="NEIGHBOURHOOD_JOIN_INITIATED",r.LinkLanguageFailedToInstall="LINK_LANGUAGE_FAILED_TO_INSTALL",r.LinkLanguageInstalledButNotSynced="LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED",r.Synced="SYNCED"})(pp||(pp={}));var bi=class{constructor(e,t,i){this.uuid=e,this.name=t,i?this.state=i:this.state=pp.Private}};Sn([w(),_n("design:type",String)],bi.prototype,"uuid",void 0);Sn([w(),_n("design:type",String)],bi.prototype,"name",void 0);Sn([w(),_n("design:type",String)],bi.prototype,"state",void 0);Sn([w(),_n("design:type",String)],bi.prototype,"sharedUrl",void 0);Sn([w(),_n("design:type",up)],bi.prototype,"neighbourhood",void 0);Sn([w(),_n("design:type",Array)],bi.prototype,"owners",void 0);bi=Sn([J(),_n("design:paramtypes",[String,String,String])],bi);var sm=class{constructor(e){this.proxies=new Map,this.activeSubscriptions=new Map,this.debounceTimers=new Map,this.seenMessages=new Map,this.perspectiveClient=e.perspectiveClient,this.logger=e.logger,this.debounceMs=e.debounceMs??2e3,this.onWake=e.onWake,this.onPersist=e.onPersist,this.QuerySubscriptionProxyCtor=e.QuerySubscriptionProxy??null,this.previousSeenMessages=e.previousSeenMessages??{}}async subscribe(e){if(this.dispose(e.id,!1),!this.QuerySubscriptionProxyCtor)throw new Error("WakerSubscriptionManager: QuerySubscriptionProxy must be provided via constructor options");let t=this.QuerySubscriptionProxyCtor;this.logger.info(`[waker] ${e.id}: creating subscription (perspective=${e.perspective}, type=${e.type})`),this.logger.info(`[waker] ${e.id}: SPARQL query:
1010
- ${e.query}`);let i=new t(e.perspective,e.query,this.perspectiveClient);i.isSPARQL=!0,i.initialized&&typeof i.initialized.catch=="function"&&i.initialized.catch(()=>{});try{await i.subscribe(),await i.initialized}catch(a){let o=a?.message??String(a);this.logger.warn(`[waker] ${e.id}: subscription failed \u2014 ${o}`);try{i.dispose()}catch{}this.activeSubscriptions.delete(e.id),this.seenMessages.delete(e.id),this.persist();return}this.logger.info(`[waker] ${e.id}: subscription initialized successfully`);let n=new Set(this.previousSeenMessages[e.id]??[]);this.seenMessages.set(e.id,n),n.size>0&&this.logger.info(`[waker] ${e.id}: seeded ${n.size} seen message(s) from persisted state`),i.onResult(async a=>{if(this.logger.info(`[waker] ${e.id}: onResult fired \u2014 type=${typeof a}, isArray=${Array.isArray(a)}, value=${String(JSON.stringify(a)).substring(0,500)}`),!Array.isArray(a)){this.logger.warn(`[waker] ${e.id}: ignoring non-array result: ${JSON.stringify(a)}`);return}if(e.type==="mention"){let o=this.seenMessages.get(e.id)??new Set,s=[];for(let u of a)u&&u.source&&!o.has(u.source)&&s.push(u.source);if(s.length===0){this.logger.info(`[waker] ${e.id}: all ${a.length} items already seen, skipping`);return}this.logger.info(`[waker] ${e.id}: ${s.length} new message(s) out of ${a.length} total`);let c=[];for(let u of s){let d=[];try{let f=`SELECT ?source WHERE { ?source <ad4m://has_child> <${u}> . }`;this.logger.info(`[waker] ${e.id}: resolving parents for ${u}`);let p=await this.perspectiveClient.querySparql(e.perspective,f);if(Array.isArray(p))for(let h of p)h&&h.source&&d.push(h.source)}catch(f){this.logger.warn(`[waker] ${e.id}: parent resolution failed for ${u} \u2014 ${f?.message??f}`)}this.logger.info(`[waker] ${e.id}: message ${u} has ${d.length} parent(s): ${d.join(", ")}`),c.push({address:u,parents:d})}for(let u of s)o.add(u);this.seenMessages.set(e.id,o);let l=this.debounceTimers.get(e.id);l&&clearTimeout(l),this.debounceTimers.set(e.id,setTimeout(()=>{this.onWake(e,a,c),this.debounceTimers.delete(e.id),this.persist()},this.debounceMs))}else{this.logger.info(`[waker] ${e.id}: channel update (${a.length} items)`);let o=this.debounceTimers.get(e.id);o&&clearTimeout(o),this.debounceTimers.set(e.id,setTimeout(()=>{this.onWake(e,a),this.debounceTimers.delete(e.id)},this.debounceMs))}}),this.proxies.set(e.id,i),this.activeSubscriptions.set(e.id,e),this.persist(),this.logger.info(`[waker] Subscription ${e.id} active (type=${e.type}, perspective=${e.perspective})`)}dispose(e,t=!0){let i=this.proxies.get(e);if(i){try{i.dispose()}catch{}this.proxies.delete(e)}let n=this.debounceTimers.get(e);n&&(clearTimeout(n),this.debounceTimers.delete(e)),this.activeSubscriptions.delete(e),this.seenMessages.delete(e),t&&this.persist()}disposeAll(){for(let[e]of this.proxies)this.dispose(e,!1)}getActive(){return Array.from(this.activeSubscriptions.values())}has(e){return this.activeSubscriptions.has(e)}persist(){if(this.onPersist){let e={};for(let[t,i]of this.seenMessages)e[t]=Array.from(i);this.onPersist(this.getActive(),e)}}},Gc=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},kg=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Fc=class{};Gc([w(),kg("design:type",Array)],Fc.prototype,"additions",void 0);Gc([w(),kg("design:type",Array)],Fc.prototype,"removals",void 0);Fc=Gc([J()],Fc);var cm=class extends _i(){};cm=Gc([J()],cm);var lm=function(r,e,t,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},ea=function(r,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!i:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(r):i?i.value:e.get(r)},bo,Ki,Ys="smart_literal://content";function x1(r){let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=t.length;for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*i));return e}var qo=class{constructor(e,t){bo.set(this,void 0),Ki.set(this,void 0),lm(this,bo,e,"f"),lm(this,Ki,t,"f")}get base(){return ea(this,Ki,"f")}static async create(e,t){let i=xe.from(x1(10)).toUrl(),n=new qo(e,i);return await n.set(t),n}static async isSmartLiteralBase(e,t){return(await e.get(new K({source:t,predicate:Ys}))).length>0}static async getAllSmartLiterals(e){return(await e.get(new K({predicate:Ys}))).map(i=>new qo(e,i.data.source))}async get(){let e=await ea(this,bo,"f").getSingleTarget(new K({source:ea(this,Ki,"f"),predicate:Ys}));if(!e)throw`No content for smart literal ${ea(this,Ki,"f")}`;return xe.fromUrl(e).get()}async set(e){let t=xe.from(e);await ea(this,bo,"f").setSingleTarget(new It({source:ea(this,Ki,"f"),predicate:Ys,target:t.toUrl()}))}};bo=new WeakMap,Ki=new WeakMap;function wo(r,e){if("predicate"in r)return r.predicate;let{model:t}=r,i=hr(t);if(r.field){let n=i[r.field];if(!n)throw new Error(`parent(): field "${r.field}" is not a registered relation on ${t.name}`);return n.predicate}for(let[,n]of Object.entries(i))if(n.target&&n.target()===e)return n.predicate;throw new Error(`parent(): could not resolve predicate \u2014 no relation on ${t.name} targets ${e.name||"the queried class"}`)}function um(r,e){return!r||!e?"":`triple("${r.id}", "${e}", Base)`}function pm(){return`
1011
- findall(
1012
- [T, A],
1013
- link(Base, _, _, T, A),
1014
- AllLinks
1015
- ),
1016
- sort(AllLinks, SortedLinks),
1017
- SortedLinks = [[Timestamp, Author]|_]
1018
- `}function E1(r){return`
1019
- findall([PropertyName, PropertyValue, Resolve], (
1020
- % Constrain to specified properties if provided
1021
- ${r?`member(PropertyName, [${r.map(e=>`"${e}"`).join(", ")}]),`:""}
1022
- resolve_property(SubjectClass, Base, PropertyName, PropertyValue, Resolve)
1023
- ), Properties)
1024
- `}function dm(r={}){function e(t){return typeof t=="string"?`"${t}"`:t}return Object.entries(r).map(([t,i])=>{let n=["id","author","timestamp"].includes(t),a=`resolve_property(SubjectClass, Base, "${t}", Value${t}, _)`,o=t==="id"?"Base":vt(t);if(Array.isArray(i)){let s=i.map(c=>e(c)).join(", ");return n?`member(${o}, [${s}])`:`${a}, member(Value${t}, [${s}])`}if(typeof i=="object"&&i!==null){let{not:s,between:c,lt:l,lte:u,gt:d,gte:f}=i;if(s!==void 0)if(Array.isArray(s)){let h=s.map(m=>e(m)).join(", ");return n?`\\+ member(${o}, [${h}])`:`${a}, \\+ member(Value${t}, [${h}])`}else return n?`${o} \\= ${e(s)}`:`${a}, Value${t} \\= ${e(s)}`;if(c!==void 0&&Array.isArray(c)&&c.length===2)return n?`${o} >= ${c[0]}, ${o} =< ${c[1]}`:`${a}, Value${t} >= ${c[0]}, Value${t} =< ${c[1]}`;let p=[{value:l,symbol:"<"},{value:u,symbol:"=<"},{value:d,symbol:">"},{value:f,symbol:">="}];for(let{value:h,symbol:m}of p)if(h!==void 0)return n?`${o} ${m} ${h}`:`${a}, Value${t} ${m} ${h}`}return n?`${o} = ${e(i)}`:`${a}, Value${t} = ${e(i)}`}).join(", ")}function fm(r){return r?"length(UnsortedInstances, TotalCount)":""}function hm(r){if(!r)return"SortedInstances = UnsortedInstances";let e=Object.entries(r);if(e.length===1){let[i,n]=e[0];return`sort_instances(UnsortedInstances, "${i}", "${n}", SortedInstances)`}let t=[];for(let i=e.length-1;i>=0;i--){let[n,a]=e[i],o=i===e.length-1?"UnsortedInstances":`MultiSortIntermediate${i+1}`,s=i===0?"SortedInstances":`MultiSortIntermediate${i}`;t.push(`sort_instances(${o}, "${n}", "${a}", ${s})`)}return t.join(`,
1025
- `)}function mm(r){return!r||r<0?"InstancesWithOffset = SortedInstances":`skipN(SortedInstances, ${r}, InstancesWithOffset)`}function gm(r){return!r||r<0?"AllInstances = InstancesWithOffset":`takeN(InstancesWithOffset, ${r}, AllInstances)`}function ym(r){if(!r)return"";if(r.includes("://")){let[e,t]=r.split("://"),i=(t||"").replace(/\/+$/,"");return`${e}://${i}`}else return r.replace(/\/+$/,"")}function Ap(r){if(!!r){if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r.find(t=>t!=="null")||r[0]}}function Ag(r,e){return Ap(r.type)===e}function Ig(r){return Ag(r,"array")}function vm(r){return Ag(r,"object")}function k1(r){let e=Ap(r.type);return e==="number"||e==="integer"}function Tg(r,e){if(e.namespace)return e.namespace;if(r["x-ad4m"]?.namespace)return r["x-ad4m"].namespace;if(r.title)return`${r.title.toLowerCase()}://`;if(r.$id)try{let i=new URL(r.$id).pathname.split("/").filter(n=>n);if(i.length>0)return`${i[i.length-1].replace(/\.schema\.json$/,"").replace(/\.json$/,"").toLowerCase()}://`}catch{}throw new Error(`Cannot infer namespace for JSON Schema. Please provide one of:
63
+ `);if(!Array.isArray(c)||c.length===0)return null;let l=new Map;for(let d of c)if(d.predicate==="rdf://type"&&d.target==="ad4m://SubjectClass"){let g=d.shape,p=g.indexOf("://");if(p<0)continue;let h=g.substring(p+3).split("/").pop();if(!h)continue;l.set(h,{shapeUri:g,properties:[],relations:[]})}for(let d of c)if(d.predicate==="sh://property"||d.predicate==="sh://collection"){for(let[g,p]of l)if(d.shape.endsWith(`${g}Shape`)){let h=d.target.lastIndexOf(".");if(h<0)continue;let u=d.target.substring(h+1);d.predicate==="sh://property"?p.properties.push(u):p.relations.push(u)}}for(let[d,g]of l){let p=e.every(u=>g.properties.includes(u)),h=r.every(u=>g.relations.includes(u));if(p&&h)return d}return null}async subjectClassesByTemplate(t){try{let e=t.className||t.constructor?.className||t.constructor?.prototype?.className;if(e&&(await this.subjectClasses()).includes(e))return[e]}catch(e){console.warn("subjectClassesByTemplate: className lookup failed:",e)}try{let e=await this.findClassByProperties(t);if(e)return[e]}catch(e){console.warn("subjectClassesByTemplate: property matching failed:",e)}return[]}async ensureSDNASubjectClass(t){return this.ensureSubjectClass(t)}async ensureSubjectClass(t){let e=t.className||t.prototype?.className||t.name;if(m(this,$i,"f").has(e))return;if(!t.generateSHACL)throw new Error(`Class ${t.name} must have generateSHACL(). Use @Model decorator.`);let{shape:r}=t.generateSHACL(),s=JSON.stringify(r.toJSON());await this.addSdna(e,"","subject_class",s),m(this,$i,"f").add(e)}clearEnsuredSubjectClasses(){m(this,$i,"f").clear()}async listRegisteredClasses(){let t=await this.querySparql("SELECT DISTINCT ?class WHERE { ?class <rdf://type> <ad4m://SubjectClass> . }");return Array.isArray(t)?t.map(e=>{let r=e.class||"",s=r.lastIndexOf("#");if(s>=0)return r.substring(s+1);let n=r.lastIndexOf("/");return n>=0?r.substring(n+1):r}).filter(Boolean):[]}async getClassShape(t){let e=t.replace(/['"\\]/g,""),r=await this.querySparql(`SELECT ?shapeUri ?targetClass WHERE {
64
+ ?targetClass <rdf://type> <ad4m://SubjectClass> .
65
+ ?targetClass <ad4m://shape> ?shapeUri .
66
+ FILTER(STRENDS(STR(?targetClass), "/${e}") || STRENDS(STR(?targetClass), "#${e}"))
67
+ } LIMIT 1`);if(!Array.isArray(r)||r.length===0)return null;let s=r[0].shapeUri;r[0].targetClass;let n=await this.querySparql(`SELECT ?propShape ?path ?datatype ?minCount ?maxCount ?writable ?propType ?shIn WHERE {
68
+ <${s}> <sh://property> ?propShape .
69
+ ?propShape <sh://path> ?path .
70
+ ?propShape <rdf://type> ?propType .
71
+ OPTIONAL { ?propShape <sh://datatype> ?datatype }
72
+ OPTIONAL { ?propShape <sh://minCount> ?minCount }
73
+ OPTIONAL { ?propShape <sh://maxCount> ?maxCount }
74
+ OPTIONAL { ?propShape <ad4m://writable> ?writable }
75
+ OPTIONAL { ?propShape <sh://in> ?shIn }
76
+ }`),a=(Array.isArray(n)?n:[]).map(o=>{let c=o.propShape||"",l=c.lastIndexOf("."),d=l>=0?c.substring(l+1):c,g=parseInt(o.minCount||"0",10),p=o.propType==="ad4m://CollectionShape",h=o.writable==="true"||o.writable==="literal:true",u;if(o.shIn)try{let f=o.shIn;f.startsWith("literal:string:")&&(f=decodeURIComponent(f.substring(15))),u=JSON.parse(f)}catch{}return{name:d,predicate:o.path||"",datatype:o.datatype||void 0,required:g>0,collection:p,writable:h,...u&&u.length>0?{options:u}:{}}});return{className:e,shapeUri:s,properties:a}}async getInstanceClasses(t){let e=t.replace(/['"\\]/g,""),r=await this.querySparql(`SELECT DISTINCT ?class WHERE {
77
+ ?class <rdf://type> <ad4m://SubjectClass> .
78
+ ?class <ad4m://shape> ?shape .
79
+ ?shape <sh://property> ?propShape .
80
+ ?propShape <sh://minCount> ?mc .
81
+ FILTER(?mc >= 1)
82
+ ?propShape <sh://path> ?path .
83
+ <${e}> ?path ?_val .
84
+ }`);return Array.isArray(r)?r.map(s=>{let n=s.class||"",a=n.lastIndexOf("#");if(a>=0)return n.substring(a+1);let o=n.lastIndexOf("/");return o>=0?n.substring(o+1):n}).filter(Boolean):[]}async getNamedOptions(t){let e=await this.getClassShape(t);if(!e)return{};let r={};for(let s of e.properties)s.options&&s.options.length>0&&(r[s.name]=s.options);return r}async addNamedOption(t,e,r,s){let n=await this.getClassShape(t);if(!n)throw new Error(`Class "${t}" not found`);let a=n.properties.find(p=>p.name===e);if(!a)throw new Error(`Property "${e}" not found on class "${t}"`);let c=`${Tl(n.shapeUri)}${t}.${e}`,l=a.options||[];if(l.some(p=>p.value===r))return;let d=[...l,{value:r,...s?{label:s}:{}}],g=await this.get(new Q({source:c,predicate:"sh://in"}));for(let p of g)await this.remove(p);await this.add(new Re({source:c,predicate:"sh://in",target:`literal:string:${JSON.stringify(d)}`}))}getNeighbourhoodProxy(){return m(this,H,"f").getNeighbourhoodProxy(m(this,O,"f").uuid)}get ai(){return m(this,H,"f").aiClient}async subscribeInfer(t){let e=new Fr(this.uuid,t,m(this,H,"f"));return await e.subscribe(),await e.initialized,e}async subscribeQuery(t){let e=new Fr(this.uuid,t,m(this,H,"f"));return await e.subscribe(),await e.initialized,e}};O=new WeakMap,H=new WeakMap,At=new WeakMap,Et=new WeakMap,Tt=new WeakMap,ki=new WeakMap,$i=new WeakMap;var Ie=function(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e},E=function(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)},U,Ai,Ei,Ti,Ir,Li,Or,Rr,Lt,Je,si;function ea(i,t){let e=i,r=!1;if(typeof e=="string"&&e.startsWith("#init#")&&(e=e.substring(6),r=!0),typeof e=="string")try{e=JSON.parse(e)}catch(s){console.error(t,s)}return r&&typeof e=="object"&&e!==null&&(e.isInit=!0),{result:e,isInit:r}}var Wr=class{constructor(t,e,r=!0,s){U.set(this,void 0),Ai.set(this,void 0),Ei.set(this,void 0),Ti.set(this,void 0),Ir.set(this,void 0),Li.set(this,void 0),Or.set(this,void 0),Rr.set(this,void 0),Lt.set(this,void 0),Je.set(this,void 0),si.set(this,void 0),Ie(this,U,s||new We(t,e),"f"),Ie(this,Ai,[],"f"),Ie(this,Ei,[],"f"),Ie(this,Ti,[],"f"),Ie(this,Ir,[],"f"),Ie(this,Lt,[],"f"),Ie(this,Je,new Map,"f"),Ie(this,si,new Map,"f"),r&&(this.subscribePerspectiveAdded(),this.subscribePerspectiveUpdated(),this.subscribePerspectiveRemoved())}setExpressionClient(t){Ie(this,Li,t,"f")}setNeighbourhoodClient(t){Ie(this,Or,t,"f")}setAIClient(t){Ie(this,Rr,t,"f")}get aiClient(){return E(this,Rr,"f")}async all(){return(await E(this,U,"f").call("perspective.all")).map(e=>new ai(e,this))}async byUUID(t){try{let e=await E(this,U,"f").call("perspective.get",{uuid:t});return e?new ai(e,this):null}catch(e){if(e instanceof ct&&e.status===404)return null;throw e}}async snapshotByUUID(t){return E(this,U,"f").call("perspective.snapshot",{uuid:t})}async publishSnapshotByUUID(t){return E(this,U,"f").call("perspective.publishSnapshot",{uuid:t})}async queryLinks(t,e){let r={uuid:t};return e.source&&(r.source=e.source),e.predicate&&(r.predicate=e.predicate),e.target&&(r.target=e.target),e.fromDate&&(r.fromDate=e.fromDate instanceof Date?e.fromDate.toISOString():String(e.fromDate)),e.untilDate&&(r.untilDate=e.untilDate instanceof Date?e.untilDate.toISOString():String(e.untilDate)),e.limit!==void 0&&(r.limit=e.limit),E(this,U,"f").call("perspective.queryLinks",r)}async queryProlog(t,e){let r=await E(this,U,"f").call("perspective.queryProlog",{uuid:t,query:e});return JSON.parse(r)}async querySparql(t,e){let r=await E(this,U,"f").call("perspective.querySparql",{uuid:t,engine:"sparql",query:e});return JSON.parse(r)}async subscribeQuery(t,e){let r=await E(this,U,"f").call("perspective.subscribeQuery",{uuid:t,query:e}),{subscriptionId:s,result:n}=r,a=ea(n,"Error parsing subscribeQuery result:");return{subscriptionId:s,result:a.result,isInit:a.isInit}}async perspectiveKeepAliveQuery(t,e){return E(this,U,"f").call("perspective.keepAliveQuery",{uuid:t,subscriptionId:e})}async perspectiveDisposeQuerySubscription(t,e){return E(this,U,"f").call("perspective.disposeQuery",{uuid:t,subscriptionId:e})}subscribeToQueryUpdates(t,e){let r=E(this,U,"f").subscribe(s=>{let n=s;if(n.type!=="query-subscription-update"||(n.subscriptionId||n.subscription_id)!==t)return;let o=ea(n.result,"Error parsing query subscription:");e(o.result)});return E(this,si,"f").set(t,r),r}async keepAliveQuery(t,e){return E(this,U,"f").call("perspective.keepAliveQuery",{uuid:t,subscriptionId:e})}async disposeQuerySubscription(t,e){let r=E(this,si,"f").get(e);return r&&(r(),E(this,si,"f").delete(e)),E(this,U,"f").call("perspective.disposeQuery",{uuid:t,subscriptionId:e})}async modelQuery(t,e,r,s){let n=await E(this,U,"f").call("perspective.modelQuery",{uuid:t,class_name:e,query_json:r,shape_json:s});return JSON.parse(n)}async modelSubscribe(t,e,r,s){let n=await E(this,U,"f").call("perspective.modelSubscribe",{uuid:t,class_name:e,query_json:r,shape_json:s});return{subscriptionId:n.subscription_id,result:JSON.parse(n.result)}}async add(t){let e=await E(this,U,"f").call("perspective.create",{name:t});return new ai(e,this)}async update(t,e){let r=await E(this,U,"f").call("perspective.update",{uuid:t,name:e});return new ai(r,this)}async remove(t){return{perspectiveRemove:await E(this,U,"f").call("perspective.remove",{uuid:t})}}async addLink(t,e,r="shared",s){return E(this,U,"f").call("perspective.addLink",{uuid:t,link:e,status:r,batchId:s})}async addLinks(t,e,r="shared",s){return E(this,U,"f").call("perspective.addLinks",{uuid:t,links:e,status:r,batchId:s})}async removeLinks(t,e,r){return E(this,U,"f").call("perspective.removeLinks",{uuid:t,links:e,batchId:r})}async linkMutations(t,e,r){return E(this,U,"f").call("perspective.linkMutations",{uuid:t,mutations:e,status:r})}async addLinkExpression(t,e,r="shared",s){return E(this,U,"f").call("perspective.addLinkExpression",{uuid:t,link:e,status:r,batchId:s})}async updateLink(t,e,r,s){return E(this,U,"f").call("perspective.updateLink",{uuid:t,oldLink:e,newLink:r,batchId:s})}async removeLink(t,e,r){return delete e.__typename,delete e.data.__typename,delete e.proof.__typename,delete e.status,E(this,U,"f").call("perspective.removeLink",{uuid:t,link:e,batchId:r})}async addSdna(t,e,r,s,n){return E(this,U,"f").call("perspective.addSdna",{uuid:t,name:e,sdnaCode:r||"",sdnaType:s,shaclJson:n})}async executeCommands(t,e,r,s,n){return E(this,U,"f").call("perspective.executeCommands",{uuid:t,commands:e,expression:r,parameters:s,batchId:n})}async createSubject(t,e,r,s,n){return E(this,U,"f").call("perspective.createSubject",{uuid:t,subjectClass:e,expressionAddress:r,initialValues:s,batchId:n})}async getSubjectData(t,e,r){return E(this,U,"f").call("perspective.getSubjectData",{uuid:t,subjectClass:e,expressionAddress:r})}async getExpression(t){return await E(this,Li,"f").get(t)}async createExpression(t,e){return await E(this,Li,"f").create(t,e)}addPerspectiveAddedListener(t){E(this,Ai,"f").push(t)}subscribePerspectiveAdded(){let t=E(this,U,"f").subscribe(e=>{e.type==="perspective-added"&&E(this,Ai,"f").forEach(r=>r(e.perspective))});E(this,Lt,"f").push(t)}addPerspectiveUpdatedListener(t){E(this,Ei,"f").push(t)}subscribePerspectiveUpdated(){let t=E(this,U,"f").subscribe(e=>{e.type==="perspective-updated"&&E(this,Ei,"f").forEach(r=>r(e.perspective))});E(this,Lt,"f").push(t)}addPerspectiveSyncedListener(t){E(this,Ir,"f").push(t)}async addPerspectiveSyncStateChangeListener(t,e){let r=E(this,U,"f").subscribe(s=>{s.type==="sync-state-change"&&s.uuid===t&&e.forEach(n=>n(s.state))});E(this,Lt,"f").push(r),await new Promise(s=>setTimeout(s,500))}addPerspectiveRemovedListener(t){E(this,Ti,"f").push(t)}subscribePerspectiveRemoved(){let t=E(this,U,"f").subscribe(e=>{e.type==="perspective-removed"&&E(this,Ti,"f").forEach(r=>r(e.uuid))});E(this,Lt,"f").push(t)}async addPerspectiveLinkAddedListener(t,e){let r=E(this,U,"f").subscribe(n=>{n.type==="link-added"&&n.perspectiveUuid===t&&e.forEach(a=>a(n.link))}),s=E(this,Je,"f").get(t)||[];s.push(r),E(this,Je,"f").set(t,s),await E(this,U,"f").waitForSubscription()}async addPerspectiveLinkRemovedListener(t,e){let r=E(this,U,"f").subscribe(n=>{if(n.type==="link-removed"&&n.perspectiveUuid===t){let a=n.link;a.status||delete a.status,e.forEach(o=>o(a))}}),s=E(this,Je,"f").get(t)||[];s.push(r),E(this,Je,"f").set(t,s),await E(this,U,"f").waitForSubscription()}async addPerspectiveLinkUpdatedListener(t,e){let r=E(this,U,"f").subscribe(n=>{if(n.type==="link-updated"&&n.perspectiveUuid===t){let a=n.newLink,o=n.oldLink;a.status||delete a.status,o.status||delete o.status,e.forEach(c=>c(n))}}),s=E(this,Je,"f").get(t)||[];s.push(r),E(this,Je,"f").set(t,s),await E(this,U,"f").waitForSubscription()}getNeighbourhoodProxy(t){return new Ts(E(this,Or,"f"),t)}async createBatch(t){return E(this,U,"f").call("perspective.createBatch",{uuid:t})}async commitBatch(t,e){return E(this,U,"f").call("perspective.commitBatch",{uuid:t,batchId:e})}};U=new WeakMap,Ai=new WeakMap,Ei=new WeakMap,Ti=new WeakMap,Ir=new WeakMap,Li=new WeakMap,Or=new WeakMap,Rr=new WeakMap,Lt=new WeakMap,Je=new WeakMap,si=new WeakMap;var Be=function(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e},I=function(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)},z,Mr,Nr,Pi,Ii,Oi,Ri,Mi,lt,Is=class{constructor(t,e,r=!0,s){z.set(this,void 0),Mr.set(this,void 0),Nr.set(this,void 0),Pi.set(this,void 0),Ii.set(this,void 0),Oi.set(this,void 0),Ri.set(this,void 0),Mi.set(this,void 0),lt.set(this,void 0),Be(this,Mr,t,"f"),Be(this,Nr,e,"f"),Be(this,z,s||new We(t,e),"f"),Be(this,Ii,[],"f"),Be(this,Oi,[],"f"),Be(this,Pi,[],"f"),Be(this,Ri,[],"f"),Be(this,Mi,[],"f"),Be(this,lt,[],"f"),r&&(this.subscribeAgentUpdated(),this.subscribeAgentStatusChanged(),this.subscribeAppsChanged())}async me(){let t=await I(this,z,"f").call("agent.get"),e=new Vi(t.did,t.perspective);return e.directMessageLanguage=t.directMessageLanguage,e}async status(){let t=await I(this,z,"f").call("agent.status");return new Rt(t)}async generate(t){let e=await I(this,z,"f").call("agent.generate",{passphrase:t});return new Rt(e)}async import(t){let e=await I(this,z,"f").call("agent.import",{...t});return new Rt(e)}async lock(t){let e=await I(this,z,"f").call("agent.lock",{passphrase:t});return new Rt(e)}async unlock(t,e=!0){let r=await I(this,z,"f").call("agent.unlock",{passphrase:t,holochain:e});return new Rt(r)}async byDID(t){return I(this,z,"f").call("agent.byDid",{did:t})}async updatePublicPerspective(t){let e=JSON.parse(JSON.stringify(t));delete e.__typename,e.links.forEach(n=>{delete n.__typename,delete n.data.__typename,delete n.proof.__typename,delete n.status});let r=await I(this,z,"f").call("agent.updateProfile",{publicPerspective:e}),s=new Vi(r.did,r.perspective);return s.directMessageLanguage=r.directMessageLanguage,s}async mutatePublicPerspective(t){let e=new Wr(I(this,Mr,"f"),I(this,Nr,"f")),r=await e.add("Agent Perspective Proxy"),s=await this.me();s.perspective&&await r.loadSnapshot(s.perspective);for(let o of t.additions)await r.add(o);for(let o of t.removals)await r.remove(o);let n=await r.snapshot(),a=await this.updatePublicPerspective(n);return await e.remove(r.uuid),a}async updateDirectMessageLanguage(t){let e=await I(this,z,"f").call("agent.updateProfile",{dmLanguage:t}),r=new Vi(e.did,e.perspective);return r.directMessageLanguage=e.directMessageLanguage,r}async addEntanglementProofs(t){return I(this,z,"f").call("agent.addEntanglementProofs",{proofs:t})}async deleteEntanglementProofs(t){return I(this,z,"f").call("agent.deleteEntanglementProofs",{proofs:t})}async getEntanglementProofs(){return I(this,z,"f").call("agent.getEntanglementProofs")}async entanglementProofPreFlight(t,e){return I(this,z,"f").call("agent.entanglementProofPreflight",{deviceKey:t,deviceKeyType:e})}addUpdatedListener(t){I(this,Ii,"f").push(t)}addAppChangedListener(t){I(this,Pi,"f").push(t)}subscribeAgentUpdated(){let t=I(this,z,"f").subscribe(e=>{e.type==="agent-updated"&&I(this,Ii,"f").forEach(r=>r(e.agent||e))});I(this,lt,"f").push(t)}subscribeAppsChanged(){let t=I(this,z,"f").subscribe(e=>{e.type==="apps-changed"&&I(this,Pi,"f").forEach(r=>r())});I(this,lt,"f").push(t)}addAgentStatusChangedListener(t){I(this,Oi,"f").push(t)}subscribeAgentStatusChanged(){let t=I(this,z,"f").subscribe(e=>{e.type==="agent-status-changed"&&I(this,Oi,"f").forEach(r=>r(e.agent||e))});I(this,lt,"f").push(t)}addHostingUserInfoChangedListener(t){I(this,Ri,"f").push(t)}subscribeHostingUserInfoChanged(){let t=I(this,z,"f").subscribe(e=>{e.type==="hosting-user-info-changed"&&I(this,Ri,"f").forEach(r=>r(e.info||e))});I(this,lt,"f").push(t)}addComputeLogUpdatedListener(t){I(this,Mi,"f").push(t)}subscribeComputeLogUpdated(){let t=I(this,z,"f").subscribe(e=>{e.type==="compute-log-updated"&&I(this,Mi,"f").forEach(r=>r(e.entry||e))});I(this,lt,"f").push(t)}async requestCapability(t){return I(this,z,"f").call("agent.requestCapability",{authInfo:t})}async permitCapability(t){return I(this,z,"f").call("agent.permitCapability",{auth:t})}async generateJwt(t,e){return I(this,z,"f").call("agent.generateJwt",{requestId:t,rand:e})}async getApps(){return I(this,z,"f").call("agent.getApps")}async removeApp(t){return I(this,z,"f").call("agent.removeApp",{id:t})}async revokeToken(t){return I(this,z,"f").call("agent.revokeToken",{token:t})}async isLocked(){return I(this,z,"f").call("agent.isLocked")}async signMessage(t){return I(this,z,"f").call("agent.sign",{message:t})}async createUser(t,e,r){return I(this,z,"f").call("user.create",{email:t,password:e,appInfo:r})}async loginUser(t,e){return I(this,z,"f").call("user.login",{email:t,password:e})}async requestLoginVerification(t,e){return I(this,z,"f").call("user.requestVerification",{email:t,appInfo:e})}async verifyEmailCode(t,e,r){return I(this,z,"f").call("user.verifyEmail",{email:t,code:e,verificationType:r})}async hostingUserInfo(){let t=await I(this,z,"f").call("hosting.info"),e=t?.userInfo||t;return new Es(e.email||"",e.freeAccess?"unlimited":String(e.credits??e.remainingCredits??"0"),e.hotWalletAddress||void 0,!!e.freeAccess)}async computeLog(t,e,r){return I(this,z,"f").call("runtime.computeLog",{since:t,limit:e,userEmail:r})}async setHotWalletAddress(t){return I(this,z,"f").call("hosting.setHotWallet",{address:t})}async requestPayment(t){return I(this,z,"f").call("hosting.requestPayment",{amountHOT:t})}};z=new WeakMap,Mr=new WeakMap,Nr=new WeakMap,Pi=new WeakMap,Ii=new WeakMap,Oi=new WeakMap,Ri=new WeakMap,Mi=new WeakMap,lt=new WeakMap;var Ll=function(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e},qe=function(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)},$e,Os=class{constructor(t,e,r){$e.set(this,void 0),Ll(this,$e,r||new We(t,e),"f")}async byAddress(t){return qe(this,$e,"f").call("language.get",{address:t})}async byFilter(t){return qe(this,$e,"f").call("language.all",{filter:t})}async all(){return qe(this,$e,"f").call("language.all")}async writeSettings(t,e){return qe(this,$e,"f").call("language.writeSettings",{address:t,settings:e})}async applyTemplateAndPublish(t,e){return qe(this,$e,"f").call("language.applyTemplate",{sourceLanguageHash:t,templateData:e})}async publish(t,e){return qe(this,$e,"f").call("language.publish",{languagePath:t,languageMeta:e})}async meta(t){return qe(this,$e,"f").call("language.meta",{address:t})}async source(t){return qe(this,$e,"f").call("language.source",{address:t})}async remove(t){return qe(this,$e,"f").call("language.remove",{address:t})}};$e=new WeakMap;var Pl=function(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e},ie=function(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)},he,Pt,Ni,Rs=class{constructor(t,e,r){he.set(this,void 0),Pt.set(this,new Map),Ni.set(this,new Map),Pl(this,he,r||new We(t,e),"f")}async publishFromPerspective(t,e,r){return ie(this,he,"f").call("neighbourhood.publish",{perspectiveUUID:t,linkLanguage:e,meta:r})}async joinFromUrl(t){return ie(this,he,"f").call("neighbourhood.join",{url:t})}async otherAgents(t){return ie(this,he,"f").call("neighbourhood.otherAgents",{uuid:t})}async hasTelepresenceAdapter(t){return ie(this,he,"f").call("neighbourhood.hasTelepresence",{uuid:t})}async onlineAgents(t){return ie(this,he,"f").call("neighbourhood.onlineAgents",{uuid:t})}async setOnlineStatus(t,e){return ie(this,he,"f").call("neighbourhood.setOnlineStatus",{uuid:t,status:e})}async setOnlineStatusU(t,e){return ie(this,he,"f").call("neighbourhood.setOnlineStatus",{uuid:t,status:e,signed:!1})}async sendSignal(t,e,r){return ie(this,he,"f").call("neighbourhood.sendSignal",{uuid:t,remoteAgentDid:e,payload:r})}async sendSignalU(t,e,r){return ie(this,he,"f").call("neighbourhood.sendSignal",{uuid:t,remoteAgentDid:e,payload:r,signed:!1})}async sendBroadcast(t,e,r=!1){return ie(this,he,"f").call("neighbourhood.sendBroadcast",{uuid:t,payload:e,loopback:r})}async sendBroadcastU(t,e,r=!1){return ie(this,he,"f").call("neighbourhood.sendBroadcast",{uuid:t,payload:e,loopback:r,signed:!1})}dispatchSignal(t,e){let r=ie(this,Pt,"f").get(t);if(r)for(let s of r)try{s(e)}catch(n){console.error("Error in signal handler:",n)}}async subscribeToSignals(t){let e=ie(this,he,"f").subscribe(r=>{r.type==="signal"&&this.dispatchSignal(t,r.signal)});ie(this,Ni,"f").set(t,e)}async addSignalHandler(t,e){let r=ie(this,Pt,"f").get(t);r?r.push(e):(r=[],ie(this,Pt,"f").set(t,r),r.push(e),await this.subscribeToSignals(t))}removeSignalHandler(t,e){let r=ie(this,Pt,"f").get(t);if(r){let s=r.indexOf(e);if(s>-1&&r.splice(s,1),r.length===0){ie(this,Pt,"f").delete(t);let n=ie(this,Ni,"f").get(t);n&&(n(),ie(this,Ni,"f").delete(t))}}}};he=new WeakMap,Pt=new WeakMap,Ni=new WeakMap;var Yt=function(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e},$=function(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)},T,Ui,ji,Di,Ms,ni;function Il(i){return typeof i!="string"||i===i.toUpperCase()?i:i.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z])([A-Z][a-z])/g,"$1_$2").toUpperCase()}var Ns=class{constructor(t,e,r=!0,s){T.set(this,void 0),Ui.set(this,void 0),ji.set(this,void 0),Di.set(this,void 0),Ms.set(this,void 0),ni.set(this,void 0),Yt(this,T,s||new We(t,e),"f"),Yt(this,Ui,[],"f"),Yt(this,ji,[],"f"),Yt(this,Di,[],"f"),Yt(this,Ms,[],"f"),Yt(this,ni,[],"f"),r&&(this.subscribeMessageReceived(),this.subscribeExceptionOccurred(),this.subscribeNotificationTriggered())}async info(){return $(this,T,"f").call("runtime.info")}async tlsDomain(){return $(this,T,"f").call("runtime.tlsDomain")}async quit(){return $(this,T,"f").call("runtime.quit")}async openLink(t){return $(this,T,"f").call("runtime.openLink",{url:t})}async addTrustedAgents(t){return $(this,T,"f").call("agent.addTrustedAgents",{agents:t})}async deleteTrustedAgents(t){return $(this,T,"f").call("agent.deleteTrustedAgents",{agents:t})}async getTrustedAgents(){return $(this,T,"f").call("agent.getTrustedAgents")}async addKnownLinkLanguageTemplates(t){return $(this,T,"f").call("runtime.addLinkLanguageTemplates",{addresses:t})}async removeKnownLinkLanguageTemplates(t){return $(this,T,"f").call("runtime.removeLinkLanguageTemplates",{addresses:t})}async knownLinkLanguageTemplates(){return $(this,T,"f").call("runtime.linkLanguageTemplates")}async addFriends(t){return $(this,T,"f").call("runtime.addFriends",{dids:t})}async removeFriends(t){return $(this,T,"f").call("runtime.removeFriends",{dids:t})}async friends(){return $(this,T,"f").call("runtime.friends")}async hcAgentInfos(){return $(this,T,"f").call("runtime.hcAgentInfos")}async getNetworkMetrics(){return $(this,T,"f").call("runtime.networkMetrics")}async restartHolochain(){return $(this,T,"f").call("runtime.restartHolochain")}async hcAddAgentInfos(t){return $(this,T,"f").call("runtime.addHcAgentInfos",{agentInfos:t})}async verifyStringSignedByDid(t,e,r,s){return $(this,T,"f").call("runtime.verifySignature",{did:t,didSigningKeyId:e,data:r,signedData:s})}async setStatus(t){return $(this,T,"f").call("runtime.setStatus",{status:t})}async friendStatus(t){return $(this,T,"f").call("runtime.friendStatus",{did:t})}async friendSendMessage(t,e){return $(this,T,"f").call("runtime.sendFriendMessage",{did:t,message:e})}async messageInbox(t){return $(this,T,"f").call("runtime.inbox",{filter:t})}async messageOutbox(t){return $(this,T,"f").call("runtime.outbox",{filter:t})}async requestInstallNotification(t){return $(this,T,"f").call("runtime.createNotification",{...t})}async grantNotification(t){return $(this,T,"f").call("runtime.grantNotification",{id:t,granted:!0})}async exportDb(t){return $(this,T,"f").call("runtime.exportData",{type:"db",filePath:t})}async importDb(t){return $(this,T,"f").call("runtime.importData",{type:"db",filePath:t})}async notifications(){return $(this,T,"f").call("runtime.notifications")}async updateNotification(t,e){return $(this,T,"f").call("runtime.updateNotification",{...e,id:t})}async removeNotification(t){return $(this,T,"f").call("runtime.deleteNotification",{id:t})}async exportPerspective(t,e){return $(this,T,"f").call("runtime.exportData",{type:"perspective",perspectiveUuid:t,filePath:e})}async importPerspective(t){return $(this,T,"f").call("runtime.importData",{type:"perspective",filePath:t})}async multiUserEnabled(){return $(this,T,"f").call("user.multiUserEnabled")}async setMultiUserEnabled(t){return $(this,T,"f").call("user.setMultiUserEnabled",{enabled:t})}async freeHostingEnabled(){return $(this,T,"f").call("runtime.freeHostingEnabled")}async setFreeHostingEnabled(t){return $(this,T,"f").call("runtime.setFreeHostingEnabled",{enabled:t})}async listUsers(){return $(this,T,"f").call("user.list")}async userWalletAddress(t){return $(this,T,"f").call("user.wallet",{email:t})}async emailTestModeEnable(){return $(this,T,"f").call("user.emailTest",{action:"enable"})}async emailTestModeDisable(){return $(this,T,"f").call("user.emailTest",{action:"disable"})}async emailTestGetCode(t){return $(this,T,"f").call("user.emailTest",{action:"get-code",email:t})}async emailTestClearCodes(){return $(this,T,"f").call("user.emailTest",{action:"clear-codes"})}async emailTestSetExpiry(t,e,r){return $(this,T,"f").call("user.emailTest",{action:"set-expiry",email:t,verificationType:e,expiresAt:r})}async unytAgentKey(){return $(this,T,"f").call("runtime.unytAgentKey")}async unytHotAgentPubkey(){return $(this,T,"f").call("runtime.unytHotAgentPubkey")}async unytWalletBalance(){return $(this,T,"f").call("runtime.unytWalletBalance")}async unytWalletHistory(t,e){return $(this,T,"f").call("runtime.unytWalletHistory",{page:t,perPage:e})}async unytVersionInfo(){return $(this,T,"f").call("runtime.unytVersionInfo")}async unytSetMembraneProof(t){return $(this,T,"f").call("runtime.unytSetMembraneProof",{proof:t})}async unytReinstallDna(){return $(this,T,"f").call("runtime.unytReinstallDna")}async unytSendHot(t,e){return $(this,T,"f").call("runtime.unytSendHot",{recipient:t,amount:e})}async setUserCredits(t,e){return $(this,T,"f").call("user.credits",{email:t,amount:e})}async setUserFreeAccess(t,e){return $(this,T,"f").call("user.freeAccess",{email:t,enabled:e})}async setHostRates(t){return $(this,T,"f").call("runtime.setHostRates",{ratesJson:t})}async getHostRates(){let t=await $(this,T,"f").call("runtime.getHostRates");try{return JSON.parse(t)}catch{return[]}}addNotificationTriggeredCallback(t){$(this,Di,"f").push(t)}subscribeNotificationTriggered(){let t=$(this,T,"f").subscribe(e=>{e.type==="notification-triggered"&&$(this,Di,"f").forEach(r=>r(e.notification))});$(this,ni,"f").push(t)}addMessageCallback(t){$(this,Ui,"f").push(t)}subscribeMessageReceived(){let t=$(this,T,"f").subscribe(e=>{e.type==="message-received"&&$(this,Ui,"f").forEach(r=>r(e.message))});$(this,ni,"f").push(t)}addExceptionCallback(t){$(this,ji,"f").push(t)}subscribeExceptionOccurred(){let t=$(this,T,"f").subscribe(e=>{if(e.type==="exception-occurred"&&e.exception){let r=e.exception,s={...r,type:Il(r.type)};$(this,ji,"f").forEach(n=>n(s))}});$(this,ni,"f").push(t)}};T=new WeakMap,Ui=new WeakMap,ji=new WeakMap,Di=new WeakMap,Ms=new WeakMap,ni=new WeakMap;var Ol=function(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e},ei=function(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)},Qe,Us=class{constructor(t,e,r){Qe.set(this,void 0),Ol(this,Qe,r||new We(t,e),"f")}async get(t,e=!1){if(!e)try{let r=K.fromUrl(t).get();if(typeof r=="object"&&r!==null&&"author"in r&&"timestamp"in r&&"data"in r&&"proof"in r)return r}catch{}return ei(this,Qe,"f").call("expression.get",{url:t})}async getMany(t){return ei(this,Qe,"f").call("expression.getMany",{urls:t})}async getRaw(t){return ei(this,Qe,"f").call("expression.get",{url:t,raw:!0})}async create(t,e){let r=JSON.stringify(t);return ei(this,Qe,"f").call("expression.create",{content:r,languageAddress:e})}async interactions(t){return ei(this,Qe,"f").call("expression.interactions",{url:t})}async interact(t,e){return ei(this,Qe,"f").call("expression.interact",{url:t,interactionCall:e})}};Qe=new WeakMap;var Jr={};Jr.byteLength=Ml;Jr.toByteArray=Ul;Jr.fromByteArray=zl;var De=[],Ae=[],Rl=typeof Uint8Array<"u"?Uint8Array:Array,us="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ct=0,ta=us.length;Ct<ta;++Ct)De[Ct]=us[Ct],Ae[us.charCodeAt(Ct)]=Ct;var Ct,ta;Ae["-".charCodeAt(0)]=62;Ae["_".charCodeAt(0)]=63;function to(i){var t=i.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=i.indexOf("=");e===-1&&(e=t);var r=e===t?0:4-e%4;return[e,r]}function Ml(i){var t=to(i),e=t[0],r=t[1];return(e+r)*3/4-r}function Nl(i,t,e){return(t+e)*3/4-e}function Ul(i){var t,e=to(i),r=e[0],s=e[1],n=new Rl(Nl(i,r,s)),a=0,o=s>0?r-4:r,c;for(c=0;c<o;c+=4)t=Ae[i.charCodeAt(c)]<<18|Ae[i.charCodeAt(c+1)]<<12|Ae[i.charCodeAt(c+2)]<<6|Ae[i.charCodeAt(c+3)],n[a++]=t>>16&255,n[a++]=t>>8&255,n[a++]=t&255;return s===2&&(t=Ae[i.charCodeAt(c)]<<2|Ae[i.charCodeAt(c+1)]>>4,n[a++]=t&255),s===1&&(t=Ae[i.charCodeAt(c)]<<10|Ae[i.charCodeAt(c+1)]<<4|Ae[i.charCodeAt(c+2)]>>2,n[a++]=t>>8&255,n[a++]=t&255),n}function jl(i){return De[i>>18&63]+De[i>>12&63]+De[i>>6&63]+De[i&63]}function Dl(i,t,e){for(var r,s=[],n=t;n<e;n+=3)r=(i[n]<<16&16711680)+(i[n+1]<<8&65280)+(i[n+2]&255),s.push(jl(r));return s.join("")}function zl(i){for(var t,e=i.length,r=e%3,s=[],n=16383,a=0,o=e-r;a<o;a+=n)s.push(Dl(i,a,a+n>o?o:a+n));return r===1?(t=i[e-1],s.push(De[t>>2]+De[t<<4&63]+"==")):r===2&&(t=(i[e-2]<<8)+i[e-1],s.push(De[t>>10]+De[t>>4&63]+De[t<<2&63]+"=")),s.join("")}var Hl=4,ia=0,ra=1,Fl=2;function hi(i){let t=i.length;for(;--t>=0;)i[t]=0}var Wl=0,io=1,Bl=2,ql=3,Zl=258,tn=29,or=256,Gi=or+1+tn,oi=30,rn=19,ro=2*Gi+1,Nt=15,ps=16,Vl=7,sn=256,so=16,no=17,ao=18,js=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Ur=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Jl=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),oo=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ql=512,Ke=new Array((Gi+2)*2);hi(Ke);var Ji=new Array(oi*2);hi(Ji);var Xi=new Array(Ql);hi(Xi);var Yi=new Array(Zl-ql+1);hi(Yi);var nn=new Array(tn);hi(nn);var Br=new Array(oi);hi(Br);function fs(i,t,e,r,s){this.static_tree=i,this.extra_bits=t,this.extra_base=e,this.elems=r,this.max_length=s,this.has_stree=i&&i.length}var lo,co,ho;function gs(i,t){this.dyn_tree=i,this.max_code=0,this.stat_desc=t}var uo=i=>i<256?Xi[i]:Xi[256+(i>>>7)],er=(i,t)=>{i.pending_buf[i.pending++]=t&255,i.pending_buf[i.pending++]=t>>>8&255},be=(i,t,e)=>{i.bi_valid>ps-e?(i.bi_buf|=t<<i.bi_valid&65535,er(i,i.bi_buf),i.bi_buf=t>>ps-i.bi_valid,i.bi_valid+=e-ps):(i.bi_buf|=t<<i.bi_valid&65535,i.bi_valid+=e)},ze=(i,t,e)=>{be(i,e[t*2],e[t*2+1])},po=(i,t)=>{let e=0;do e|=i&1,i>>>=1,e<<=1;while(--t>0);return e>>>1},Kl=i=>{i.bi_valid===16?(er(i,i.bi_buf),i.bi_buf=0,i.bi_valid=0):i.bi_valid>=8&&(i.pending_buf[i.pending++]=i.bi_buf&255,i.bi_buf>>=8,i.bi_valid-=8)},Gl=(i,t)=>{let e=t.dyn_tree,r=t.max_code,s=t.stat_desc.static_tree,n=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,d,g,p,h,u,f=0;for(p=0;p<=Nt;p++)i.bl_count[p]=0;for(e[i.heap[i.heap_max]*2+1]=0,l=i.heap_max+1;l<ro;l++)d=i.heap[l],p=e[e[d*2+1]*2+1]+1,p>c&&(p=c,f++),e[d*2+1]=p,!(d>r)&&(i.bl_count[p]++,h=0,d>=o&&(h=a[d-o]),u=e[d*2],i.opt_len+=u*(p+h),n&&(i.static_len+=u*(s[d*2+1]+h)));if(f!==0){do{for(p=c-1;i.bl_count[p]===0;)p--;i.bl_count[p]--,i.bl_count[p+1]+=2,i.bl_count[c]--,f-=2}while(f>0);for(p=c;p!==0;p--)for(d=i.bl_count[p];d!==0;)g=i.heap[--l],!(g>r)&&(e[g*2+1]!==p&&(i.opt_len+=(p-e[g*2+1])*e[g*2],e[g*2+1]=p),d--)}},fo=(i,t,e)=>{let r=new Array(Nt+1),s=0,n,a;for(n=1;n<=Nt;n++)s=s+e[n-1]<<1,r[n]=s;for(a=0;a<=t;a++){let o=i[a*2+1];o!==0&&(i[a*2]=po(r[o]++,o))}},Xl=()=>{let i,t,e,r,s,n=new Array(Nt+1);for(e=0,r=0;r<tn-1;r++)for(nn[r]=e,i=0;i<1<<js[r];i++)Yi[e++]=r;for(Yi[e-1]=r,s=0,r=0;r<16;r++)for(Br[r]=s,i=0;i<1<<Ur[r];i++)Xi[s++]=r;for(s>>=7;r<oi;r++)for(Br[r]=s<<7,i=0;i<1<<Ur[r]-7;i++)Xi[256+s++]=r;for(t=0;t<=Nt;t++)n[t]=0;for(i=0;i<=143;)Ke[i*2+1]=8,i++,n[8]++;for(;i<=255;)Ke[i*2+1]=9,i++,n[9]++;for(;i<=279;)Ke[i*2+1]=7,i++,n[7]++;for(;i<=287;)Ke[i*2+1]=8,i++,n[8]++;for(fo(Ke,Gi+1,n),i=0;i<oi;i++)Ji[i*2+1]=5,Ji[i*2]=po(i,5);lo=new fs(Ke,js,or+1,Gi,Nt),co=new fs(Ji,Ur,0,oi,Nt),ho=new fs(new Array(0),Jl,0,rn,Vl)},go=i=>{let t;for(t=0;t<Gi;t++)i.dyn_ltree[t*2]=0;for(t=0;t<oi;t++)i.dyn_dtree[t*2]=0;for(t=0;t<rn;t++)i.bl_tree[t*2]=0;i.dyn_ltree[sn*2]=1,i.opt_len=i.static_len=0,i.sym_next=i.matches=0},mo=i=>{i.bi_valid>8?er(i,i.bi_buf):i.bi_valid>0&&(i.pending_buf[i.pending++]=i.bi_buf),i.bi_buf=0,i.bi_valid=0},sa=(i,t,e,r)=>{let s=t*2,n=e*2;return i[s]<i[n]||i[s]===i[n]&&r[t]<=r[e]},ms=(i,t,e)=>{let r=i.heap[e],s=e<<1;for(;s<=i.heap_len&&(s<i.heap_len&&sa(t,i.heap[s+1],i.heap[s],i.depth)&&s++,!sa(t,r,i.heap[s],i.depth));)i.heap[e]=i.heap[s],e=s,s<<=1;i.heap[e]=r},na=(i,t,e)=>{let r,s,n=0,a,o;if(i.sym_next!==0)do r=i.pending_buf[i.sym_buf+n++]&255,r+=(i.pending_buf[i.sym_buf+n++]&255)<<8,s=i.pending_buf[i.sym_buf+n++],r===0?ze(i,s,t):(a=Yi[s],ze(i,a+or+1,t),o=js[a],o!==0&&(s-=nn[a],be(i,s,o)),r--,a=uo(r),ze(i,a,e),o=Ur[a],o!==0&&(r-=Br[a],be(i,r,o)));while(n<i.sym_next);ze(i,sn,t)},Ds=(i,t)=>{let e=t.dyn_tree,r=t.stat_desc.static_tree,s=t.stat_desc.has_stree,n=t.stat_desc.elems,a,o,c=-1,l;for(i.heap_len=0,i.heap_max=ro,a=0;a<n;a++)e[a*2]!==0?(i.heap[++i.heap_len]=c=a,i.depth[a]=0):e[a*2+1]=0;for(;i.heap_len<2;)l=i.heap[++i.heap_len]=c<2?++c:0,e[l*2]=1,i.depth[l]=0,i.opt_len--,s&&(i.static_len-=r[l*2+1]);for(t.max_code=c,a=i.heap_len>>1;a>=1;a--)ms(i,e,a);l=n;do a=i.heap[1],i.heap[1]=i.heap[i.heap_len--],ms(i,e,1),o=i.heap[1],i.heap[--i.heap_max]=a,i.heap[--i.heap_max]=o,e[l*2]=e[a*2]+e[o*2],i.depth[l]=(i.depth[a]>=i.depth[o]?i.depth[a]:i.depth[o])+1,e[a*2+1]=e[o*2+1]=l,i.heap[1]=l++,ms(i,e,1);while(i.heap_len>=2);i.heap[--i.heap_max]=i.heap[1],Gl(i,t),fo(e,c,i.bl_count)},aa=(i,t,e)=>{let r,s=-1,n,a=t[0*2+1],o=0,c=7,l=4;for(a===0&&(c=138,l=3),t[(e+1)*2+1]=65535,r=0;r<=e;r++)n=a,a=t[(r+1)*2+1],!(++o<c&&n===a)&&(o<l?i.bl_tree[n*2]+=o:n!==0?(n!==s&&i.bl_tree[n*2]++,i.bl_tree[so*2]++):o<=10?i.bl_tree[no*2]++:i.bl_tree[ao*2]++,o=0,s=n,a===0?(c=138,l=3):n===a?(c=6,l=3):(c=7,l=4))},oa=(i,t,e)=>{let r,s=-1,n,a=t[0*2+1],o=0,c=7,l=4;for(a===0&&(c=138,l=3),r=0;r<=e;r++)if(n=a,a=t[(r+1)*2+1],!(++o<c&&n===a)){if(o<l)do ze(i,n,i.bl_tree);while(--o!==0);else n!==0?(n!==s&&(ze(i,n,i.bl_tree),o--),ze(i,so,i.bl_tree),be(i,o-3,2)):o<=10?(ze(i,no,i.bl_tree),be(i,o-3,3)):(ze(i,ao,i.bl_tree),be(i,o-11,7));o=0,s=n,a===0?(c=138,l=3):n===a?(c=6,l=3):(c=7,l=4)}},Yl=i=>{let t;for(aa(i,i.dyn_ltree,i.l_desc.max_code),aa(i,i.dyn_dtree,i.d_desc.max_code),Ds(i,i.bl_desc),t=rn-1;t>=3&&i.bl_tree[oo[t]*2+1]===0;t--);return i.opt_len+=3*(t+1)+5+5+4,t},ec=(i,t,e,r)=>{let s;for(be(i,t-257,5),be(i,e-1,5),be(i,r-4,4),s=0;s<r;s++)be(i,i.bl_tree[oo[s]*2+1],3);oa(i,i.dyn_ltree,t-1),oa(i,i.dyn_dtree,e-1)},tc=i=>{let t=4093624447,e;for(e=0;e<=31;e++,t>>>=1)if(t&1&&i.dyn_ltree[e*2]!==0)return ia;if(i.dyn_ltree[9*2]!==0||i.dyn_ltree[10*2]!==0||i.dyn_ltree[13*2]!==0)return ra;for(e=32;e<or;e++)if(i.dyn_ltree[e*2]!==0)return ra;return ia},la=!1,ic=i=>{la||(Xl(),la=!0),i.l_desc=new gs(i.dyn_ltree,lo),i.d_desc=new gs(i.dyn_dtree,co),i.bl_desc=new gs(i.bl_tree,ho),i.bi_buf=0,i.bi_valid=0,go(i)},wo=(i,t,e,r)=>{be(i,(Wl<<1)+(r?1:0),3),mo(i),er(i,e),er(i,~e),e&&i.pending_buf.set(i.window.subarray(t,t+e),i.pending),i.pending+=e},rc=i=>{be(i,io<<1,3),ze(i,sn,Ke),Kl(i)},sc=(i,t,e,r)=>{let s,n,a=0;i.level>0?(i.strm.data_type===Fl&&(i.strm.data_type=tc(i)),Ds(i,i.l_desc),Ds(i,i.d_desc),a=Yl(i),s=i.opt_len+3+7>>>3,n=i.static_len+3+7>>>3,n<=s&&(s=n)):s=n=e+5,e+4<=s&&t!==-1?wo(i,t,e,r):i.strategy===Hl||n===s?(be(i,(io<<1)+(r?1:0),3),na(i,Ke,Ji)):(be(i,(Bl<<1)+(r?1:0),3),ec(i,i.l_desc.max_code+1,i.d_desc.max_code+1,a+1),na(i,i.dyn_ltree,i.dyn_dtree)),go(i),r&&mo(i)},nc=(i,t,e)=>(i.pending_buf[i.sym_buf+i.sym_next++]=t,i.pending_buf[i.sym_buf+i.sym_next++]=t>>8,i.pending_buf[i.sym_buf+i.sym_next++]=e,t===0?i.dyn_ltree[e*2]++:(i.matches++,t--,i.dyn_ltree[(Yi[e]+or+1)*2]++,i.dyn_dtree[uo(t)*2]++),i.sym_next===i.sym_end),ac=ic,oc=wo,lc=sc,cc=nc,dc=rc,hc={_tr_init:ac,_tr_stored_block:oc,_tr_flush_block:lc,_tr_tally:cc,_tr_align:dc},uc=(i,t,e,r)=>{let s=i&65535|0,n=i>>>16&65535|0,a=0;for(;e!==0;){a=e>2e3?2e3:e,e-=a;do s=s+t[r++]|0,n=n+s|0;while(--a);s%=65521,n%=65521}return s|n<<16|0},tr=uc,pc=()=>{let i,t=[];for(var e=0;e<256;e++){i=e;for(var r=0;r<8;r++)i=i&1?3988292384^i>>>1:i>>>1;t[e]=i}return t},fc=new Uint32Array(pc()),gc=(i,t,e,r)=>{let s=fc,n=r+e;i^=-1;for(let a=r;a<n;a++)i=i>>>8^s[(i^t[a])&255];return i^-1},ne=gc,zt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Wt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:mc,_tr_stored_block:zs,_tr_flush_block:wc,_tr_tally:ft,_tr_align:yc}=hc,{Z_NO_FLUSH:gt,Z_PARTIAL_FLUSH:bc,Z_FULL_FLUSH:vc,Z_FINISH:Ee,Z_BLOCK:ca,Z_OK:le,Z_STREAM_END:da,Z_STREAM_ERROR:He,Z_DATA_ERROR:_c,Z_BUF_ERROR:ws,Z_DEFAULT_COMPRESSION:xc,Z_FILTERED:Cc,Z_HUFFMAN_ONLY:_r,Z_RLE:Sc,Z_FIXED:kc,Z_DEFAULT_STRATEGY:$c,Z_UNKNOWN:Ac,Z_DEFLATED:Qr}=Wt,Ec=9,Tc=15,Lc=8,Pc=29,Ic=256,Hs=Ic+1+Pc,Oc=30,Rc=19,Mc=2*Hs+1,Nc=15,F=3,ht=258,Fe=ht+F+1,Uc=32,ci=42,an=57,Fs=69,Ws=73,Bs=91,qs=103,Ut=113,zi=666,pe=1,ui=2,Ht=3,pi=4,jc=3,jt=(i,t)=>(i.msg=zt[t],t),ha=i=>i*2-(i>4?9:0),dt=i=>{let t=i.length;for(;--t>=0;)i[t]=0},Dc=i=>{let t,e,r,s=i.w_size;t=i.hash_size,r=t;do e=i.head[--r],i.head[r]=e>=s?e-s:0;while(--t);t=s,r=t;do e=i.prev[--r],i.prev[r]=e>=s?e-s:0;while(--t)},zc=(i,t,e)=>(t<<i.hash_shift^e)&i.hash_mask,mt=zc,xe=i=>{let t=i.state,e=t.pending;e>i.avail_out&&(e=i.avail_out),e!==0&&(i.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+e),i.next_out),i.next_out+=e,t.pending_out+=e,i.total_out+=e,i.avail_out-=e,t.pending-=e,t.pending===0&&(t.pending_out=0))},Ce=(i,t)=>{wc(i,i.block_start>=0?i.block_start:-1,i.strstart-i.block_start,t),i.block_start=i.strstart,xe(i.strm)},q=(i,t)=>{i.pending_buf[i.pending++]=t},vi=(i,t)=>{i.pending_buf[i.pending++]=t>>>8&255,i.pending_buf[i.pending++]=t&255},Zs=(i,t,e,r)=>{let s=i.avail_in;return s>r&&(s=r),s===0?0:(i.avail_in-=s,t.set(i.input.subarray(i.next_in,i.next_in+s),e),i.state.wrap===1?i.adler=tr(i.adler,t,s,e):i.state.wrap===2&&(i.adler=ne(i.adler,t,s,e)),i.next_in+=s,i.total_in+=s,s)},yo=(i,t)=>{let e=i.max_chain_length,r=i.strstart,s,n,a=i.prev_length,o=i.nice_match,c=i.strstart>i.w_size-Fe?i.strstart-(i.w_size-Fe):0,l=i.window,d=i.w_mask,g=i.prev,p=i.strstart+ht,h=l[r+a-1],u=l[r+a];i.prev_length>=i.good_match&&(e>>=2),o>i.lookahead&&(o=i.lookahead);do if(s=t,!(l[s+a]!==u||l[s+a-1]!==h||l[s]!==l[r]||l[++s]!==l[r+1])){r+=2,s++;do;while(l[++r]===l[++s]&&l[++r]===l[++s]&&l[++r]===l[++s]&&l[++r]===l[++s]&&l[++r]===l[++s]&&l[++r]===l[++s]&&l[++r]===l[++s]&&l[++r]===l[++s]&&r<p);if(n=ht-(p-r),r=p-ht,n>a){if(i.match_start=t,a=n,n>=o)break;h=l[r+a-1],u=l[r+a]}}while((t=g[t&d])>c&&--e!==0);return a<=i.lookahead?a:i.lookahead},di=i=>{let t=i.w_size,e,r,s;do{if(r=i.window_size-i.lookahead-i.strstart,i.strstart>=t+(t-Fe)&&(i.window.set(i.window.subarray(t,t+t-r),0),i.match_start-=t,i.strstart-=t,i.block_start-=t,i.insert>i.strstart&&(i.insert=i.strstart),Dc(i),r+=t),i.strm.avail_in===0)break;if(e=Zs(i.strm,i.window,i.strstart+i.lookahead,r),i.lookahead+=e,i.lookahead+i.insert>=F)for(s=i.strstart-i.insert,i.ins_h=i.window[s],i.ins_h=mt(i,i.ins_h,i.window[s+1]);i.insert&&(i.ins_h=mt(i,i.ins_h,i.window[s+F-1]),i.prev[s&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=s,s++,i.insert--,!(i.lookahead+i.insert<F)););}while(i.lookahead<Fe&&i.strm.avail_in!==0)},bo=(i,t)=>{let e=i.pending_buf_size-5>i.w_size?i.w_size:i.pending_buf_size-5,r,s,n,a=0,o=i.strm.avail_in;do{if(r=65535,n=i.bi_valid+42>>3,i.strm.avail_out<n||(n=i.strm.avail_out-n,s=i.strstart-i.block_start,r>s+i.strm.avail_in&&(r=s+i.strm.avail_in),r>n&&(r=n),r<e&&(r===0&&t!==Ee||t===gt||r!==s+i.strm.avail_in)))break;a=t===Ee&&r===s+i.strm.avail_in?1:0,zs(i,0,0,a),i.pending_buf[i.pending-4]=r,i.pending_buf[i.pending-3]=r>>8,i.pending_buf[i.pending-2]=~r,i.pending_buf[i.pending-1]=~r>>8,xe(i.strm),s&&(s>r&&(s=r),i.strm.output.set(i.window.subarray(i.block_start,i.block_start+s),i.strm.next_out),i.strm.next_out+=s,i.strm.avail_out-=s,i.strm.total_out+=s,i.block_start+=s,r-=s),r&&(Zs(i.strm,i.strm.output,i.strm.next_out,r),i.strm.next_out+=r,i.strm.avail_out-=r,i.strm.total_out+=r)}while(a===0);return o-=i.strm.avail_in,o&&(o>=i.w_size?(i.matches=2,i.window.set(i.strm.input.subarray(i.strm.next_in-i.w_size,i.strm.next_in),0),i.strstart=i.w_size,i.insert=i.strstart):(i.window_size-i.strstart<=o&&(i.strstart-=i.w_size,i.window.set(i.window.subarray(i.w_size,i.w_size+i.strstart),0),i.matches<2&&i.matches++,i.insert>i.strstart&&(i.insert=i.strstart)),i.window.set(i.strm.input.subarray(i.strm.next_in-o,i.strm.next_in),i.strstart),i.strstart+=o,i.insert+=o>i.w_size-i.insert?i.w_size-i.insert:o),i.block_start=i.strstart),i.high_water<i.strstart&&(i.high_water=i.strstart),a?pi:t!==gt&&t!==Ee&&i.strm.avail_in===0&&i.strstart===i.block_start?ui:(n=i.window_size-i.strstart,i.strm.avail_in>n&&i.block_start>=i.w_size&&(i.block_start-=i.w_size,i.strstart-=i.w_size,i.window.set(i.window.subarray(i.w_size,i.w_size+i.strstart),0),i.matches<2&&i.matches++,n+=i.w_size,i.insert>i.strstart&&(i.insert=i.strstart)),n>i.strm.avail_in&&(n=i.strm.avail_in),n&&(Zs(i.strm,i.window,i.strstart,n),i.strstart+=n,i.insert+=n>i.w_size-i.insert?i.w_size-i.insert:n),i.high_water<i.strstart&&(i.high_water=i.strstart),n=i.bi_valid+42>>3,n=i.pending_buf_size-n>65535?65535:i.pending_buf_size-n,e=n>i.w_size?i.w_size:n,s=i.strstart-i.block_start,(s>=e||(s||t===Ee)&&t!==gt&&i.strm.avail_in===0&&s<=n)&&(r=s>n?n:s,a=t===Ee&&i.strm.avail_in===0&&r===s?1:0,zs(i,i.block_start,r,a),i.block_start+=r,xe(i.strm)),a?Ht:pe)},ys=(i,t)=>{let e,r;for(;;){if(i.lookahead<Fe){if(di(i),i.lookahead<Fe&&t===gt)return pe;if(i.lookahead===0)break}if(e=0,i.lookahead>=F&&(i.ins_h=mt(i,i.ins_h,i.window[i.strstart+F-1]),e=i.prev[i.strstart&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=i.strstart),e!==0&&i.strstart-e<=i.w_size-Fe&&(i.match_length=yo(i,e)),i.match_length>=F)if(r=ft(i,i.strstart-i.match_start,i.match_length-F),i.lookahead-=i.match_length,i.match_length<=i.max_lazy_match&&i.lookahead>=F){i.match_length--;do i.strstart++,i.ins_h=mt(i,i.ins_h,i.window[i.strstart+F-1]),e=i.prev[i.strstart&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=i.strstart;while(--i.match_length!==0);i.strstart++}else i.strstart+=i.match_length,i.match_length=0,i.ins_h=i.window[i.strstart],i.ins_h=mt(i,i.ins_h,i.window[i.strstart+1]);else r=ft(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++;if(r&&(Ce(i,!1),i.strm.avail_out===0))return pe}return i.insert=i.strstart<F-1?i.strstart:F-1,t===Ee?(Ce(i,!0),i.strm.avail_out===0?Ht:pi):i.sym_next&&(Ce(i,!1),i.strm.avail_out===0)?pe:ui},ti=(i,t)=>{let e,r,s;for(;;){if(i.lookahead<Fe){if(di(i),i.lookahead<Fe&&t===gt)return pe;if(i.lookahead===0)break}if(e=0,i.lookahead>=F&&(i.ins_h=mt(i,i.ins_h,i.window[i.strstart+F-1]),e=i.prev[i.strstart&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=i.strstart),i.prev_length=i.match_length,i.prev_match=i.match_start,i.match_length=F-1,e!==0&&i.prev_length<i.max_lazy_match&&i.strstart-e<=i.w_size-Fe&&(i.match_length=yo(i,e),i.match_length<=5&&(i.strategy===Cc||i.match_length===F&&i.strstart-i.match_start>4096)&&(i.match_length=F-1)),i.prev_length>=F&&i.match_length<=i.prev_length){s=i.strstart+i.lookahead-F,r=ft(i,i.strstart-1-i.prev_match,i.prev_length-F),i.lookahead-=i.prev_length-1,i.prev_length-=2;do++i.strstart<=s&&(i.ins_h=mt(i,i.ins_h,i.window[i.strstart+F-1]),e=i.prev[i.strstart&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=i.strstart);while(--i.prev_length!==0);if(i.match_available=0,i.match_length=F-1,i.strstart++,r&&(Ce(i,!1),i.strm.avail_out===0))return pe}else if(i.match_available){if(r=ft(i,0,i.window[i.strstart-1]),r&&Ce(i,!1),i.strstart++,i.lookahead--,i.strm.avail_out===0)return pe}else i.match_available=1,i.strstart++,i.lookahead--}return i.match_available&&(r=ft(i,0,i.window[i.strstart-1]),i.match_available=0),i.insert=i.strstart<F-1?i.strstart:F-1,t===Ee?(Ce(i,!0),i.strm.avail_out===0?Ht:pi):i.sym_next&&(Ce(i,!1),i.strm.avail_out===0)?pe:ui},Hc=(i,t)=>{let e,r,s,n,a=i.window;for(;;){if(i.lookahead<=ht){if(di(i),i.lookahead<=ht&&t===gt)return pe;if(i.lookahead===0)break}if(i.match_length=0,i.lookahead>=F&&i.strstart>0&&(s=i.strstart-1,r=a[s],r===a[++s]&&r===a[++s]&&r===a[++s])){n=i.strstart+ht;do;while(r===a[++s]&&r===a[++s]&&r===a[++s]&&r===a[++s]&&r===a[++s]&&r===a[++s]&&r===a[++s]&&r===a[++s]&&s<n);i.match_length=ht-(n-s),i.match_length>i.lookahead&&(i.match_length=i.lookahead)}if(i.match_length>=F?(e=ft(i,1,i.match_length-F),i.lookahead-=i.match_length,i.strstart+=i.match_length,i.match_length=0):(e=ft(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++),e&&(Ce(i,!1),i.strm.avail_out===0))return pe}return i.insert=0,t===Ee?(Ce(i,!0),i.strm.avail_out===0?Ht:pi):i.sym_next&&(Ce(i,!1),i.strm.avail_out===0)?pe:ui},Fc=(i,t)=>{let e;for(;;){if(i.lookahead===0&&(di(i),i.lookahead===0)){if(t===gt)return pe;break}if(i.match_length=0,e=ft(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++,e&&(Ce(i,!1),i.strm.avail_out===0))return pe}return i.insert=0,t===Ee?(Ce(i,!0),i.strm.avail_out===0?Ht:pi):i.sym_next&&(Ce(i,!1),i.strm.avail_out===0)?pe:ui};function Ne(i,t,e,r,s){this.good_length=i,this.max_lazy=t,this.nice_length=e,this.max_chain=r,this.func=s}var Hi=[new Ne(0,0,0,0,bo),new Ne(4,4,8,4,ys),new Ne(4,5,16,8,ys),new Ne(4,6,32,32,ys),new Ne(4,4,16,16,ti),new Ne(8,16,32,32,ti),new Ne(8,16,128,128,ti),new Ne(8,32,128,256,ti),new Ne(32,128,258,1024,ti),new Ne(32,258,258,4096,ti)],Wc=i=>{i.window_size=2*i.w_size,dt(i.head),i.max_lazy_match=Hi[i.level].max_lazy,i.good_match=Hi[i.level].good_length,i.nice_match=Hi[i.level].nice_length,i.max_chain_length=Hi[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=F-1,i.match_available=0,i.ins_h=0};function Bc(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Qr,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(Mc*2),this.dyn_dtree=new Uint16Array((2*Oc+1)*2),this.bl_tree=new Uint16Array((2*Rc+1)*2),dt(this.dyn_ltree),dt(this.dyn_dtree),dt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Nc+1),this.heap=new Uint16Array(2*Hs+1),dt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Hs+1),dt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var lr=i=>{if(!i)return 1;let t=i.state;return!t||t.strm!==i||t.status!==ci&&t.status!==an&&t.status!==Fs&&t.status!==Ws&&t.status!==Bs&&t.status!==qs&&t.status!==Ut&&t.status!==zi?1:0},vo=i=>{if(lr(i))return jt(i,He);i.total_in=i.total_out=0,i.data_type=Ac;let t=i.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?an:t.wrap?ci:Ut,i.adler=t.wrap===2?0:1,t.last_flush=-2,mc(t),le},_o=i=>{let t=vo(i);return t===le&&Wc(i.state),t},qc=(i,t)=>lr(i)||i.state.wrap!==2?He:(i.state.gzhead=t,le),xo=(i,t,e,r,s,n)=>{if(!i)return He;let a=1;if(t===xc&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),s<1||s>Ec||e!==Qr||r<8||r>15||t<0||t>9||n<0||n>kc||r===8&&a!==1)return jt(i,He);r===8&&(r=9);let o=new Bc;return i.state=o,o.strm=i,o.status=ci,o.wrap=a,o.gzhead=null,o.w_bits=r,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=s+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+F-1)/F),o.window=new Uint8Array(o.w_size*2),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<s+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=(o.lit_bufsize-1)*3,o.level=t,o.strategy=n,o.method=e,_o(i)},Zc=(i,t)=>xo(i,t,Qr,Tc,Lc,$c),Vc=(i,t)=>{if(lr(i)||t>ca||t<0)return i?jt(i,He):He;let e=i.state;if(!i.output||i.avail_in!==0&&!i.input||e.status===zi&&t!==Ee)return jt(i,i.avail_out===0?ws:He);let r=e.last_flush;if(e.last_flush=t,e.pending!==0){if(xe(i),i.avail_out===0)return e.last_flush=-1,le}else if(i.avail_in===0&&ha(t)<=ha(r)&&t!==Ee)return jt(i,ws);if(e.status===zi&&i.avail_in!==0)return jt(i,ws);if(e.status===ci&&e.wrap===0&&(e.status=Ut),e.status===ci){let s=Qr+(e.w_bits-8<<4)<<8,n=-1;if(e.strategy>=_r||e.level<2?n=0:e.level<6?n=1:e.level===6?n=2:n=3,s|=n<<6,e.strstart!==0&&(s|=Uc),s+=31-s%31,vi(e,s),e.strstart!==0&&(vi(e,i.adler>>>16),vi(e,i.adler&65535)),i.adler=1,e.status=Ut,xe(i),e.pending!==0)return e.last_flush=-1,le}if(e.status===an){if(i.adler=0,q(e,31),q(e,139),q(e,8),e.gzhead)q(e,(e.gzhead.text?1:0)+(e.gzhead.hcrc?2:0)+(e.gzhead.extra?4:0)+(e.gzhead.name?8:0)+(e.gzhead.comment?16:0)),q(e,e.gzhead.time&255),q(e,e.gzhead.time>>8&255),q(e,e.gzhead.time>>16&255),q(e,e.gzhead.time>>24&255),q(e,e.level===9?2:e.strategy>=_r||e.level<2?4:0),q(e,e.gzhead.os&255),e.gzhead.extra&&e.gzhead.extra.length&&(q(e,e.gzhead.extra.length&255),q(e,e.gzhead.extra.length>>8&255)),e.gzhead.hcrc&&(i.adler=ne(i.adler,e.pending_buf,e.pending,0)),e.gzindex=0,e.status=Fs;else if(q(e,0),q(e,0),q(e,0),q(e,0),q(e,0),q(e,e.level===9?2:e.strategy>=_r||e.level<2?4:0),q(e,jc),e.status=Ut,xe(i),e.pending!==0)return e.last_flush=-1,le}if(e.status===Fs){if(e.gzhead.extra){let s=e.pending,n=(e.gzhead.extra.length&65535)-e.gzindex;for(;e.pending+n>e.pending_buf_size;){let o=e.pending_buf_size-e.pending;if(e.pending_buf.set(e.gzhead.extra.subarray(e.gzindex,e.gzindex+o),e.pending),e.pending=e.pending_buf_size,e.gzhead.hcrc&&e.pending>s&&(i.adler=ne(i.adler,e.pending_buf,e.pending-s,s)),e.gzindex+=o,xe(i),e.pending!==0)return e.last_flush=-1,le;s=0,n-=o}let a=new Uint8Array(e.gzhead.extra);e.pending_buf.set(a.subarray(e.gzindex,e.gzindex+n),e.pending),e.pending+=n,e.gzhead.hcrc&&e.pending>s&&(i.adler=ne(i.adler,e.pending_buf,e.pending-s,s)),e.gzindex=0}e.status=Ws}if(e.status===Ws){if(e.gzhead.name){let s=e.pending,n;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>s&&(i.adler=ne(i.adler,e.pending_buf,e.pending-s,s)),xe(i),e.pending!==0)return e.last_flush=-1,le;s=0}e.gzindex<e.gzhead.name.length?n=e.gzhead.name.charCodeAt(e.gzindex++)&255:n=0,q(e,n)}while(n!==0);e.gzhead.hcrc&&e.pending>s&&(i.adler=ne(i.adler,e.pending_buf,e.pending-s,s)),e.gzindex=0}e.status=Bs}if(e.status===Bs){if(e.gzhead.comment){let s=e.pending,n;do{if(e.pending===e.pending_buf_size){if(e.gzhead.hcrc&&e.pending>s&&(i.adler=ne(i.adler,e.pending_buf,e.pending-s,s)),xe(i),e.pending!==0)return e.last_flush=-1,le;s=0}e.gzindex<e.gzhead.comment.length?n=e.gzhead.comment.charCodeAt(e.gzindex++)&255:n=0,q(e,n)}while(n!==0);e.gzhead.hcrc&&e.pending>s&&(i.adler=ne(i.adler,e.pending_buf,e.pending-s,s))}e.status=qs}if(e.status===qs){if(e.gzhead.hcrc){if(e.pending+2>e.pending_buf_size&&(xe(i),e.pending!==0))return e.last_flush=-1,le;q(e,i.adler&255),q(e,i.adler>>8&255),i.adler=0}if(e.status=Ut,xe(i),e.pending!==0)return e.last_flush=-1,le}if(i.avail_in!==0||e.lookahead!==0||t!==gt&&e.status!==zi){let s=e.level===0?bo(e,t):e.strategy===_r?Fc(e,t):e.strategy===Sc?Hc(e,t):Hi[e.level].func(e,t);if((s===Ht||s===pi)&&(e.status=zi),s===pe||s===Ht)return i.avail_out===0&&(e.last_flush=-1),le;if(s===ui&&(t===bc?yc(e):t!==ca&&(zs(e,0,0,!1),t===vc&&(dt(e.head),e.lookahead===0&&(e.strstart=0,e.block_start=0,e.insert=0))),xe(i),i.avail_out===0))return e.last_flush=-1,le}return t!==Ee?le:e.wrap<=0?da:(e.wrap===2?(q(e,i.adler&255),q(e,i.adler>>8&255),q(e,i.adler>>16&255),q(e,i.adler>>24&255),q(e,i.total_in&255),q(e,i.total_in>>8&255),q(e,i.total_in>>16&255),q(e,i.total_in>>24&255)):(vi(e,i.adler>>>16),vi(e,i.adler&65535)),xe(i),e.wrap>0&&(e.wrap=-e.wrap),e.pending!==0?le:da)},Jc=i=>{if(lr(i))return He;let t=i.state.status;return i.state=null,t===Ut?jt(i,_c):le},Qc=(i,t)=>{let e=t.length;if(lr(i))return He;let r=i.state,s=r.wrap;if(s===2||s===1&&r.status!==ci||r.lookahead)return He;if(s===1&&(i.adler=tr(i.adler,t,e,0)),r.wrap=0,e>=r.w_size){s===0&&(dt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let c=new Uint8Array(r.w_size);c.set(t.subarray(e-r.w_size,e),0),t=c,e=r.w_size}let n=i.avail_in,a=i.next_in,o=i.input;for(i.avail_in=e,i.next_in=0,i.input=t,di(r);r.lookahead>=F;){let c=r.strstart,l=r.lookahead-(F-1);do r.ins_h=mt(r,r.ins_h,r.window[c+F-1]),r.prev[c&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=c,c++;while(--l);r.strstart=c,r.lookahead=F-1,di(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=F-1,r.match_available=0,i.next_in=a,i.input=o,i.avail_in=n,r.wrap=s,le},Kc=Zc,Gc=xo,Xc=_o,Yc=vo,ed=qc,td=Vc,id=Jc,rd=Qc,sd="pako deflate (from Nodeca project)",Qi={deflateInit:Kc,deflateInit2:Gc,deflateReset:Xc,deflateResetKeep:Yc,deflateSetHeader:ed,deflate:td,deflateEnd:id,deflateSetDictionary:rd,deflateInfo:sd},nd=(i,t)=>Object.prototype.hasOwnProperty.call(i,t),ad=function(i){let t=Array.prototype.slice.call(arguments,1);for(;t.length;){let e=t.shift();if(!!e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(let r in e)nd(e,r)&&(i[r]=e[r])}}return i},od=i=>{let t=0;for(let r=0,s=i.length;r<s;r++)t+=i[r].length;let e=new Uint8Array(t);for(let r=0,s=0,n=i.length;r<n;r++){let a=i[r];e.set(a,s),s+=a.length}return e},Kr={assign:ad,flattenChunks:od},Co=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{Co=!1}var ir=new Uint8Array(256);for(let i=0;i<256;i++)ir[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;ir[254]=ir[254]=1;var ld=i=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(i);let t,e,r,s,n,a=i.length,o=0;for(s=0;s<a;s++)e=i.charCodeAt(s),(e&64512)===55296&&s+1<a&&(r=i.charCodeAt(s+1),(r&64512)===56320&&(e=65536+(e-55296<<10)+(r-56320),s++)),o+=e<128?1:e<2048?2:e<65536?3:4;for(t=new Uint8Array(o),n=0,s=0;n<o;s++)e=i.charCodeAt(s),(e&64512)===55296&&s+1<a&&(r=i.charCodeAt(s+1),(r&64512)===56320&&(e=65536+(e-55296<<10)+(r-56320),s++)),e<128?t[n++]=e:e<2048?(t[n++]=192|e>>>6,t[n++]=128|e&63):e<65536?(t[n++]=224|e>>>12,t[n++]=128|e>>>6&63,t[n++]=128|e&63):(t[n++]=240|e>>>18,t[n++]=128|e>>>12&63,t[n++]=128|e>>>6&63,t[n++]=128|e&63);return t},cd=(i,t)=>{if(t<65534&&i.subarray&&Co)return String.fromCharCode.apply(null,i.length===t?i:i.subarray(0,t));let e="";for(let r=0;r<t;r++)e+=String.fromCharCode(i[r]);return e},dd=(i,t)=>{let e=t||i.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(i.subarray(0,t));let r,s,n=new Array(e*2);for(s=0,r=0;r<e;){let a=i[r++];if(a<128){n[s++]=a;continue}let o=ir[a];if(o>4){n[s++]=65533,r+=o-1;continue}for(a&=o===2?31:o===3?15:7;o>1&&r<e;)a=a<<6|i[r++]&63,o--;if(o>1){n[s++]=65533;continue}a<65536?n[s++]=a:(a-=65536,n[s++]=55296|a>>10&1023,n[s++]=56320|a&1023)}return cd(n,s)},hd=(i,t)=>{t=t||i.length,t>i.length&&(t=i.length);let e=t-1;for(;e>=0&&(i[e]&192)===128;)e--;return e<0||e===0?t:e+ir[i[e]]>t?e:t},rr={string2buf:ld,buf2string:dd,utf8border:hd};function ud(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var So=ud,ko=Object.prototype.toString,{Z_NO_FLUSH:pd,Z_SYNC_FLUSH:fd,Z_FULL_FLUSH:gd,Z_FINISH:md,Z_OK:qr,Z_STREAM_END:wd,Z_DEFAULT_COMPRESSION:yd,Z_DEFAULT_STRATEGY:bd,Z_DEFLATED:vd}=Wt;function cr(i){this.options=Kr.assign({level:yd,method:vd,chunkSize:16384,windowBits:15,memLevel:8,strategy:bd},i||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new So,this.strm.avail_out=0;let e=Qi.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==qr)throw new Error(zt[e]);if(t.header&&Qi.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=rr.string2buf(t.dictionary):ko.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,e=Qi.deflateSetDictionary(this.strm,r),e!==qr)throw new Error(zt[e]);this._dict_set=!0}}cr.prototype.push=function(i,t){let e=this.strm,r=this.options.chunkSize,s,n;if(this.ended)return!1;for(t===~~t?n=t:n=t===!0?md:pd,typeof i=="string"?e.input=rr.string2buf(i):ko.call(i)==="[object ArrayBuffer]"?e.input=new Uint8Array(i):e.input=i,e.next_in=0,e.avail_in=e.input.length;;){if(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),(n===fd||n===gd)&&e.avail_out<=6){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(s=Qi.deflate(e,n),s===wd)return e.next_out>0&&this.onData(e.output.subarray(0,e.next_out)),s=Qi.deflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===qr;if(e.avail_out===0){this.onData(e.output);continue}if(n>0&&e.next_out>0){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(e.avail_in===0)break}return!0};cr.prototype.onData=function(i){this.chunks.push(i)};cr.prototype.onEnd=function(i){i===qr&&(this.result=Kr.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function on(i,t){let e=new cr(t);if(e.push(i,!0),e.err)throw e.msg||zt[e.err];return e.result}function _d(i,t){return t=t||{},t.raw=!0,on(i,t)}function xd(i,t){return t=t||{},t.gzip=!0,on(i,t)}var Cd=cr,Sd=on,kd=_d,$d=xd,Ad=Wt,Ed={Deflate:Cd,deflate:Sd,deflateRaw:kd,gzip:$d,constants:Ad},xr=16209,Td=16191,Ld=function(t,e){let r,s,n,a,o,c,l,d,g,p,h,u,f,w,v,x,S,_,P,R,k,M,N,A,D=t.state;r=t.next_in,N=t.input,s=r+(t.avail_in-5),n=t.next_out,A=t.output,a=n-(e-t.avail_out),o=n+(t.avail_out-257),c=D.dmax,l=D.wsize,d=D.whave,g=D.wnext,p=D.window,h=D.hold,u=D.bits,f=D.lencode,w=D.distcode,v=(1<<D.lenbits)-1,x=(1<<D.distbits)-1;e:do{u<15&&(h+=N[r++]<<u,u+=8,h+=N[r++]<<u,u+=8),S=f[h&v];t:for(;;){if(_=S>>>24,h>>>=_,u-=_,_=S>>>16&255,_===0)A[n++]=S&65535;else if(_&16){P=S&65535,_&=15,_&&(u<_&&(h+=N[r++]<<u,u+=8),P+=h&(1<<_)-1,h>>>=_,u-=_),u<15&&(h+=N[r++]<<u,u+=8,h+=N[r++]<<u,u+=8),S=w[h&x];i:for(;;){if(_=S>>>24,h>>>=_,u-=_,_=S>>>16&255,_&16){if(R=S&65535,_&=15,u<_&&(h+=N[r++]<<u,u+=8,u<_&&(h+=N[r++]<<u,u+=8)),R+=h&(1<<_)-1,R>c){t.msg="invalid distance too far back",D.mode=xr;break e}if(h>>>=_,u-=_,_=n-a,R>_){if(_=R-_,_>d&&D.sane){t.msg="invalid distance too far back",D.mode=xr;break e}if(k=0,M=p,g===0){if(k+=l-_,_<P){P-=_;do A[n++]=p[k++];while(--_);k=n-R,M=A}}else if(g<_){if(k+=l+g-_,_-=g,_<P){P-=_;do A[n++]=p[k++];while(--_);if(k=0,g<P){_=g,P-=_;do A[n++]=p[k++];while(--_);k=n-R,M=A}}}else if(k+=g-_,_<P){P-=_;do A[n++]=p[k++];while(--_);k=n-R,M=A}for(;P>2;)A[n++]=M[k++],A[n++]=M[k++],A[n++]=M[k++],P-=3;P&&(A[n++]=M[k++],P>1&&(A[n++]=M[k++]))}else{k=n-R;do A[n++]=A[k++],A[n++]=A[k++],A[n++]=A[k++],P-=3;while(P>2);P&&(A[n++]=A[k++],P>1&&(A[n++]=A[k++]))}}else if((_&64)===0){S=w[(S&65535)+(h&(1<<_)-1)];continue i}else{t.msg="invalid distance code",D.mode=xr;break e}break}}else if((_&64)===0){S=f[(S&65535)+(h&(1<<_)-1)];continue t}else if(_&32){D.mode=Td;break e}else{t.msg="invalid literal/length code",D.mode=xr;break e}break}}while(r<s&&n<o);P=u>>3,r-=P,u-=P<<3,h&=(1<<u)-1,t.next_in=r,t.next_out=n,t.avail_in=r<s?5+(s-r):5-(r-s),t.avail_out=n<o?257+(o-n):257-(n-o),D.hold=h,D.bits=u},ii=15,ua=852,pa=592,fa=0,bs=1,ga=2,Pd=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Id=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Od=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),Rd=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),Md=(i,t,e,r,s,n,a,o)=>{let c=o.bits,l=0,d=0,g=0,p=0,h=0,u=0,f=0,w=0,v=0,x=0,S,_,P,R,k,M=null,N,A=new Uint16Array(ii+1),D=new Uint16Array(ii+1),Me=null,yi,xt,b;for(l=0;l<=ii;l++)A[l]=0;for(d=0;d<r;d++)A[t[e+d]]++;for(h=c,p=ii;p>=1&&A[p]===0;p--);if(h>p&&(h=p),p===0)return s[n++]=1<<24|64<<16|0,s[n++]=1<<24|64<<16|0,o.bits=1,0;for(g=1;g<p&&A[g]===0;g++);for(h<g&&(h=g),w=1,l=1;l<=ii;l++)if(w<<=1,w-=A[l],w<0)return-1;if(w>0&&(i===fa||p!==1))return-1;for(D[1]=0,l=1;l<ii;l++)D[l+1]=D[l]+A[l];for(d=0;d<r;d++)t[e+d]!==0&&(a[D[t[e+d]]++]=d);if(i===fa?(M=Me=a,N=20):i===bs?(M=Pd,Me=Id,N=257):(M=Od,Me=Rd,N=0),x=0,d=0,l=g,k=n,u=h,f=0,P=-1,v=1<<h,R=v-1,i===bs&&v>ua||i===ga&&v>pa)return 1;for(;;){yi=l-f,a[d]+1<N?(xt=0,b=a[d]):a[d]>=N?(xt=Me[a[d]-N],b=M[a[d]-N]):(xt=32+64,b=0),S=1<<l-f,_=1<<u,g=_;do _-=S,s[k+(x>>f)+_]=yi<<24|xt<<16|b|0;while(_!==0);for(S=1<<l-1;x&S;)S>>=1;if(S!==0?(x&=S-1,x+=S):x=0,d++,--A[l]===0){if(l===p)break;l=t[e+a[d]]}if(l>h&&(x&R)!==P){for(f===0&&(f=h),k+=g,u=l-f,w=1<<u;u+f<p&&(w-=A[u+f],!(w<=0));)u++,w<<=1;if(v+=1<<u,i===bs&&v>ua||i===ga&&v>pa)return 1;P=x&R,s[P]=h<<24|u<<16|k-n|0}}return x!==0&&(s[k+x]=l-f<<24|64<<16|0),o.bits=h,0},Ki=Md,Nd=0,$o=1,Ao=2,{Z_FINISH:ma,Z_BLOCK:Ud,Z_TREES:Cr,Z_OK:Ft,Z_STREAM_END:jd,Z_NEED_DICT:Dd,Z_STREAM_ERROR:Te,Z_DATA_ERROR:Eo,Z_MEM_ERROR:To,Z_BUF_ERROR:zd,Z_DEFLATED:wa}=Wt,Gr=16180,ya=16181,ba=16182,va=16183,_a=16184,xa=16185,Ca=16186,Sa=16187,ka=16188,$a=16189,Zr=16190,Ze=16191,vs=16192,Aa=16193,_s=16194,Ea=16195,Ta=16196,La=16197,Pa=16198,Sr=16199,kr=16200,Ia=16201,Oa=16202,Ra=16203,Ma=16204,Na=16205,xs=16206,Ua=16207,ja=16208,V=16209,Lo=16210,Po=16211,Hd=852,Fd=592,Wd=15,Bd=Wd,Da=i=>(i>>>24&255)+(i>>>8&65280)+((i&65280)<<8)+((i&255)<<24);function qd(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var Bt=i=>{if(!i)return 1;let t=i.state;return!t||t.strm!==i||t.mode<Gr||t.mode>Po?1:0},Io=i=>{if(Bt(i))return Te;let t=i.state;return i.total_in=i.total_out=t.total=0,i.msg="",t.wrap&&(i.adler=t.wrap&1),t.mode=Gr,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Hd),t.distcode=t.distdyn=new Int32Array(Fd),t.sane=1,t.back=-1,Ft},Oo=i=>{if(Bt(i))return Te;let t=i.state;return t.wsize=0,t.whave=0,t.wnext=0,Io(i)},Ro=(i,t)=>{let e;if(Bt(i))return Te;let r=i.state;return t<0?(e=0,t=-t):(e=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?Te:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=e,r.wbits=t,Oo(i))},Mo=(i,t)=>{if(!i)return Te;let e=new qd;i.state=e,e.strm=i,e.window=null,e.mode=Gr;let r=Ro(i,t);return r!==Ft&&(i.state=null),r},Zd=i=>Mo(i,Bd),za=!0,Cs,Ss,Vd=i=>{if(za){Cs=new Int32Array(512),Ss=new Int32Array(32);let t=0;for(;t<144;)i.lens[t++]=8;for(;t<256;)i.lens[t++]=9;for(;t<280;)i.lens[t++]=7;for(;t<288;)i.lens[t++]=8;for(Ki($o,i.lens,0,288,Cs,0,i.work,{bits:9}),t=0;t<32;)i.lens[t++]=5;Ki(Ao,i.lens,0,32,Ss,0,i.work,{bits:5}),za=!1}i.lencode=Cs,i.lenbits=9,i.distcode=Ss,i.distbits=5},No=(i,t,e,r)=>{let s,n=i.state;return n.window===null&&(n.wsize=1<<n.wbits,n.wnext=0,n.whave=0,n.window=new Uint8Array(n.wsize)),r>=n.wsize?(n.window.set(t.subarray(e-n.wsize,e),0),n.wnext=0,n.whave=n.wsize):(s=n.wsize-n.wnext,s>r&&(s=r),n.window.set(t.subarray(e-r,e-r+s),n.wnext),r-=s,r?(n.window.set(t.subarray(e-r,e),0),n.wnext=r,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whave<n.wsize&&(n.whave+=s))),0},Jd=(i,t)=>{let e,r,s,n,a,o,c,l,d,g,p,h,u,f,w=0,v,x,S,_,P,R,k,M,N=new Uint8Array(4),A,D,Me=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Bt(i)||!i.output||!i.input&&i.avail_in!==0)return Te;e=i.state,e.mode===Ze&&(e.mode=vs),a=i.next_out,s=i.output,c=i.avail_out,n=i.next_in,r=i.input,o=i.avail_in,l=e.hold,d=e.bits,g=o,p=c,M=Ft;e:for(;;)switch(e.mode){case Gr:if(e.wrap===0){e.mode=vs;break}for(;d<16;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}if(e.wrap&2&&l===35615){e.wbits===0&&(e.wbits=15),e.check=0,N[0]=l&255,N[1]=l>>>8&255,e.check=ne(e.check,N,2,0),l=0,d=0,e.mode=ya;break}if(e.head&&(e.head.done=!1),!(e.wrap&1)||(((l&255)<<8)+(l>>8))%31){i.msg="incorrect header check",e.mode=V;break}if((l&15)!==wa){i.msg="unknown compression method",e.mode=V;break}if(l>>>=4,d-=4,k=(l&15)+8,e.wbits===0&&(e.wbits=k),k>15||k>e.wbits){i.msg="invalid window size",e.mode=V;break}e.dmax=1<<e.wbits,e.flags=0,i.adler=e.check=1,e.mode=l&512?$a:Ze,l=0,d=0;break;case ya:for(;d<16;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}if(e.flags=l,(e.flags&255)!==wa){i.msg="unknown compression method",e.mode=V;break}if(e.flags&57344){i.msg="unknown header flags set",e.mode=V;break}e.head&&(e.head.text=l>>8&1),e.flags&512&&e.wrap&4&&(N[0]=l&255,N[1]=l>>>8&255,e.check=ne(e.check,N,2,0)),l=0,d=0,e.mode=ba;case ba:for(;d<32;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}e.head&&(e.head.time=l),e.flags&512&&e.wrap&4&&(N[0]=l&255,N[1]=l>>>8&255,N[2]=l>>>16&255,N[3]=l>>>24&255,e.check=ne(e.check,N,4,0)),l=0,d=0,e.mode=va;case va:for(;d<16;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}e.head&&(e.head.xflags=l&255,e.head.os=l>>8),e.flags&512&&e.wrap&4&&(N[0]=l&255,N[1]=l>>>8&255,e.check=ne(e.check,N,2,0)),l=0,d=0,e.mode=_a;case _a:if(e.flags&1024){for(;d<16;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}e.length=l,e.head&&(e.head.extra_len=l),e.flags&512&&e.wrap&4&&(N[0]=l&255,N[1]=l>>>8&255,e.check=ne(e.check,N,2,0)),l=0,d=0}else e.head&&(e.head.extra=null);e.mode=xa;case xa:if(e.flags&1024&&(h=e.length,h>o&&(h=o),h&&(e.head&&(k=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(r.subarray(n,n+h),k)),e.flags&512&&e.wrap&4&&(e.check=ne(e.check,r,h,n)),o-=h,n+=h,e.length-=h),e.length))break e;e.length=0,e.mode=Ca;case Ca:if(e.flags&2048){if(o===0)break e;h=0;do k=r[n+h++],e.head&&k&&e.length<65536&&(e.head.name+=String.fromCharCode(k));while(k&&h<o);if(e.flags&512&&e.wrap&4&&(e.check=ne(e.check,r,h,n)),o-=h,n+=h,k)break e}else e.head&&(e.head.name=null);e.length=0,e.mode=Sa;case Sa:if(e.flags&4096){if(o===0)break e;h=0;do k=r[n+h++],e.head&&k&&e.length<65536&&(e.head.comment+=String.fromCharCode(k));while(k&&h<o);if(e.flags&512&&e.wrap&4&&(e.check=ne(e.check,r,h,n)),o-=h,n+=h,k)break e}else e.head&&(e.head.comment=null);e.mode=ka;case ka:if(e.flags&512){for(;d<16;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}if(e.wrap&4&&l!==(e.check&65535)){i.msg="header crc mismatch",e.mode=V;break}l=0,d=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),i.adler=e.check=0,e.mode=Ze;break;case $a:for(;d<32;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}i.adler=e.check=Da(l),l=0,d=0,e.mode=Zr;case Zr:if(e.havedict===0)return i.next_out=a,i.avail_out=c,i.next_in=n,i.avail_in=o,e.hold=l,e.bits=d,Dd;i.adler=e.check=1,e.mode=Ze;case Ze:if(t===Ud||t===Cr)break e;case vs:if(e.last){l>>>=d&7,d-=d&7,e.mode=xs;break}for(;d<3;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}switch(e.last=l&1,l>>>=1,d-=1,l&3){case 0:e.mode=Aa;break;case 1:if(Vd(e),e.mode=Sr,t===Cr){l>>>=2,d-=2;break e}break;case 2:e.mode=Ta;break;case 3:i.msg="invalid block type",e.mode=V}l>>>=2,d-=2;break;case Aa:for(l>>>=d&7,d-=d&7;d<32;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}if((l&65535)!==(l>>>16^65535)){i.msg="invalid stored block lengths",e.mode=V;break}if(e.length=l&65535,l=0,d=0,e.mode=_s,t===Cr)break e;case _s:e.mode=Ea;case Ea:if(h=e.length,h){if(h>o&&(h=o),h>c&&(h=c),h===0)break e;s.set(r.subarray(n,n+h),a),o-=h,n+=h,c-=h,a+=h,e.length-=h;break}e.mode=Ze;break;case Ta:for(;d<14;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}if(e.nlen=(l&31)+257,l>>>=5,d-=5,e.ndist=(l&31)+1,l>>>=5,d-=5,e.ncode=(l&15)+4,l>>>=4,d-=4,e.nlen>286||e.ndist>30){i.msg="too many length or distance symbols",e.mode=V;break}e.have=0,e.mode=La;case La:for(;e.have<e.ncode;){for(;d<3;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}e.lens[Me[e.have++]]=l&7,l>>>=3,d-=3}for(;e.have<19;)e.lens[Me[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,A={bits:e.lenbits},M=Ki(Nd,e.lens,0,19,e.lencode,0,e.work,A),e.lenbits=A.bits,M){i.msg="invalid code lengths set",e.mode=V;break}e.have=0,e.mode=Pa;case Pa:for(;e.have<e.nlen+e.ndist;){for(;w=e.lencode[l&(1<<e.lenbits)-1],v=w>>>24,x=w>>>16&255,S=w&65535,!(v<=d);){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}if(S<16)l>>>=v,d-=v,e.lens[e.have++]=S;else{if(S===16){for(D=v+2;d<D;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}if(l>>>=v,d-=v,e.have===0){i.msg="invalid bit length repeat",e.mode=V;break}k=e.lens[e.have-1],h=3+(l&3),l>>>=2,d-=2}else if(S===17){for(D=v+3;d<D;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}l>>>=v,d-=v,k=0,h=3+(l&7),l>>>=3,d-=3}else{for(D=v+7;d<D;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}l>>>=v,d-=v,k=0,h=11+(l&127),l>>>=7,d-=7}if(e.have+h>e.nlen+e.ndist){i.msg="invalid bit length repeat",e.mode=V;break}for(;h--;)e.lens[e.have++]=k}}if(e.mode===V)break;if(e.lens[256]===0){i.msg="invalid code -- missing end-of-block",e.mode=V;break}if(e.lenbits=9,A={bits:e.lenbits},M=Ki($o,e.lens,0,e.nlen,e.lencode,0,e.work,A),e.lenbits=A.bits,M){i.msg="invalid literal/lengths set",e.mode=V;break}if(e.distbits=6,e.distcode=e.distdyn,A={bits:e.distbits},M=Ki(Ao,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,A),e.distbits=A.bits,M){i.msg="invalid distances set",e.mode=V;break}if(e.mode=Sr,t===Cr)break e;case Sr:e.mode=kr;case kr:if(o>=6&&c>=258){i.next_out=a,i.avail_out=c,i.next_in=n,i.avail_in=o,e.hold=l,e.bits=d,Ld(i,p),a=i.next_out,s=i.output,c=i.avail_out,n=i.next_in,r=i.input,o=i.avail_in,l=e.hold,d=e.bits,e.mode===Ze&&(e.back=-1);break}for(e.back=0;w=e.lencode[l&(1<<e.lenbits)-1],v=w>>>24,x=w>>>16&255,S=w&65535,!(v<=d);){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}if(x&&(x&240)===0){for(_=v,P=x,R=S;w=e.lencode[R+((l&(1<<_+P)-1)>>_)],v=w>>>24,x=w>>>16&255,S=w&65535,!(_+v<=d);){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}l>>>=_,d-=_,e.back+=_}if(l>>>=v,d-=v,e.back+=v,e.length=S,x===0){e.mode=Na;break}if(x&32){e.back=-1,e.mode=Ze;break}if(x&64){i.msg="invalid literal/length code",e.mode=V;break}e.extra=x&15,e.mode=Ia;case Ia:if(e.extra){for(D=e.extra;d<D;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}e.length+=l&(1<<e.extra)-1,l>>>=e.extra,d-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=Oa;case Oa:for(;w=e.distcode[l&(1<<e.distbits)-1],v=w>>>24,x=w>>>16&255,S=w&65535,!(v<=d);){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}if((x&240)===0){for(_=v,P=x,R=S;w=e.distcode[R+((l&(1<<_+P)-1)>>_)],v=w>>>24,x=w>>>16&255,S=w&65535,!(_+v<=d);){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}l>>>=_,d-=_,e.back+=_}if(l>>>=v,d-=v,e.back+=v,x&64){i.msg="invalid distance code",e.mode=V;break}e.offset=S,e.extra=x&15,e.mode=Ra;case Ra:if(e.extra){for(D=e.extra;d<D;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}e.offset+=l&(1<<e.extra)-1,l>>>=e.extra,d-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){i.msg="invalid distance too far back",e.mode=V;break}e.mode=Ma;case Ma:if(c===0)break e;if(h=p-c,e.offset>h){if(h=e.offset-h,h>e.whave&&e.sane){i.msg="invalid distance too far back",e.mode=V;break}h>e.wnext?(h-=e.wnext,u=e.wsize-h):u=e.wnext-h,h>e.length&&(h=e.length),f=e.window}else f=s,u=a-e.offset,h=e.length;h>c&&(h=c),c-=h,e.length-=h;do s[a++]=f[u++];while(--h);e.length===0&&(e.mode=kr);break;case Na:if(c===0)break e;s[a++]=e.length,c--,e.mode=kr;break;case xs:if(e.wrap){for(;d<32;){if(o===0)break e;o--,l|=r[n++]<<d,d+=8}if(p-=c,i.total_out+=p,e.total+=p,e.wrap&4&&p&&(i.adler=e.check=e.flags?ne(e.check,s,p,a-p):tr(e.check,s,p,a-p)),p=c,e.wrap&4&&(e.flags?l:Da(l))!==e.check){i.msg="incorrect data check",e.mode=V;break}l=0,d=0}e.mode=Ua;case Ua:if(e.wrap&&e.flags){for(;d<32;){if(o===0)break e;o--,l+=r[n++]<<d,d+=8}if(e.wrap&4&&l!==(e.total&4294967295)){i.msg="incorrect length check",e.mode=V;break}l=0,d=0}e.mode=ja;case ja:M=jd;break e;case V:M=Eo;break e;case Lo:return To;case Po:default:return Te}return i.next_out=a,i.avail_out=c,i.next_in=n,i.avail_in=o,e.hold=l,e.bits=d,(e.wsize||p!==i.avail_out&&e.mode<V&&(e.mode<xs||t!==ma))&&No(i,i.output,i.next_out,p-i.avail_out),g-=i.avail_in,p-=i.avail_out,i.total_in+=g,i.total_out+=p,e.total+=p,e.wrap&4&&p&&(i.adler=e.check=e.flags?ne(e.check,s,p,i.next_out-p):tr(e.check,s,p,i.next_out-p)),i.data_type=e.bits+(e.last?64:0)+(e.mode===Ze?128:0)+(e.mode===Sr||e.mode===_s?256:0),(g===0&&p===0||t===ma)&&M===Ft&&(M=zd),M},Qd=i=>{if(Bt(i))return Te;let t=i.state;return t.window&&(t.window=null),i.state=null,Ft},Kd=(i,t)=>{if(Bt(i))return Te;let e=i.state;return(e.wrap&2)===0?Te:(e.head=t,t.done=!1,Ft)},Gd=(i,t)=>{let e=t.length,r,s,n;return Bt(i)||(r=i.state,r.wrap!==0&&r.mode!==Zr)?Te:r.mode===Zr&&(s=1,s=tr(s,t,e,0),s!==r.check)?Eo:(n=No(i,t,e,e),n?(r.mode=Lo,To):(r.havedict=1,Ft))},Xd=Oo,Yd=Ro,eh=Io,th=Zd,ih=Mo,rh=Jd,sh=Qd,nh=Kd,ah=Gd,oh="pako inflate (from Nodeca project)",Ge={inflateReset:Xd,inflateReset2:Yd,inflateResetKeep:eh,inflateInit:th,inflateInit2:ih,inflate:rh,inflateEnd:sh,inflateGetHeader:nh,inflateSetDictionary:ah,inflateInfo:oh};function lh(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var ch=lh,Uo=Object.prototype.toString,{Z_NO_FLUSH:dh,Z_FINISH:hh,Z_OK:sr,Z_STREAM_END:ks,Z_NEED_DICT:$s,Z_STREAM_ERROR:uh,Z_DATA_ERROR:Ha,Z_MEM_ERROR:ph}=Wt;function dr(i){this.options=Kr.assign({chunkSize:1024*64,windowBits:15,to:""},i||{});let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(i&&i.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new So,this.strm.avail_out=0;let e=Ge.inflateInit2(this.strm,t.windowBits);if(e!==sr)throw new Error(zt[e]);if(this.header=new ch,Ge.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=rr.string2buf(t.dictionary):Uo.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=Ge.inflateSetDictionary(this.strm,t.dictionary),e!==sr)))throw new Error(zt[e])}dr.prototype.push=function(i,t){let e=this.strm,r=this.options.chunkSize,s=this.options.dictionary,n,a,o;if(this.ended)return!1;for(t===~~t?a=t:a=t===!0?hh:dh,Uo.call(i)==="[object ArrayBuffer]"?e.input=new Uint8Array(i):e.input=i,e.next_in=0,e.avail_in=e.input.length;;){for(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),n=Ge.inflate(e,a),n===$s&&s&&(n=Ge.inflateSetDictionary(e,s),n===sr?n=Ge.inflate(e,a):n===Ha&&(n=$s));e.avail_in>0&&n===ks&&e.state.wrap>0&&i[e.next_in]!==0;)Ge.inflateReset(e),n=Ge.inflate(e,a);switch(n){case uh:case Ha:case $s:case ph:return this.onEnd(n),this.ended=!0,!1}if(o=e.avail_out,e.next_out&&(e.avail_out===0||n===ks))if(this.options.to==="string"){let c=rr.utf8border(e.output,e.next_out),l=e.next_out-c,d=rr.buf2string(e.output,c);e.next_out=l,e.avail_out=r-l,l&&e.output.set(e.output.subarray(c,c+l),0),this.onData(d)}else this.onData(e.output.length===e.next_out?e.output:e.output.subarray(0,e.next_out));if(!(n===sr&&o===0)){if(n===ks)return n=Ge.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,!0;if(e.avail_in===0)break}}return!0};dr.prototype.onData=function(i){this.chunks.push(i)};dr.prototype.onEnd=function(i){i===sr&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Kr.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function ln(i,t){let e=new dr(t);if(e.push(i),e.err)throw e.msg||zt[e.err];return e.result}function fh(i,t){return t=t||{},t.raw=!0,ln(i,t)}var gh=dr,mh=ln,wh=fh,yh=ln,bh=Wt,vh={Inflate:gh,inflate:mh,inflateRaw:wh,ungzip:yh,constants:bh},{Deflate:_h,deflate:xh,deflateRaw:Ch,gzip:Sh}=Ed,{Inflate:kh,inflate:$h,inflateRaw:Ah,ungzip:Eh}=vh,Th=_h,Lh=xh,Ph=Ch,Ih=Sh,Oh=kh,Rh=$h,Mh=Ah,Nh=Eh,Uh=Wt,jh={Deflate:Th,deflate:Lh,deflateRaw:Ph,gzip:Ih,Inflate:Oh,inflate:Rh,inflateRaw:Mh,ungzip:Nh,constants:Uh};var Vs=class{constructor(t,e,r,s,n){this.name=t,this.modelId=e,this.systemPrompt=r,this.promptExamples=s,this.metaData=n}};var Dh=function(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e},X=function(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)},te,Fi,Js,Qs=class{constructor(t,e,r=!0,s){te.set(this,void 0),Fi.set(this,new Map),Js.set(this,new Set),Dh(this,te,s||new We(t,e),"f")}serializeModelInput(t){let e={...t};return"modelType"in e&&(e.type=e.modelType,delete e.modelType),e}async getModels(){return X(this,te,"f").call("ai.models")}async addModel(t){return X(this,te,"f").call("ai.addModel",{model:this.serializeModelInput(t)})}async updateModel(t,e){return X(this,te,"f").call("ai.updateModel",{id:t,model:this.serializeModelInput(e)})}async removeModel(t){return X(this,te,"f").call("ai.removeModel",{id:t})}async setDefaultModel(t,e){return X(this,te,"f").call("ai.setDefaultModel",{id:e,modelType:t})}async getDefaultModel(t){return X(this,te,"f").call("ai.getDefaultModel",{modelType:t})}async tasks(){return X(this,te,"f").call("ai.tasks")}async addTask(t,e,r,s,n){let a=new Vs(t,e,r,s,n);return X(this,te,"f").call("ai.addTask",{task:a})}async removeTask(t){return X(this,te,"f").call("ai.removeTask",{id:t})}async updateTask(t,e){return X(this,te,"f").call("ai.updateTask",{id:t,task:{name:e.name,modelId:e.modelId,systemPrompt:e.systemPrompt,promptExamples:e.promptExamples}})}async modelLoadingStatus(t){return X(this,te,"f").call("ai.modelLoadingStatus",{model:t})}async prompt(t,e){return X(this,te,"f").call("ai.prompt",{taskId:t,prompt:e})}async embed(t,e){let r=await X(this,te,"f").call("ai.embed",{modelId:t,text:e}),s=Jr.toByteArray(r);return JSON.parse(jh.inflate(s,{to:"string"}))}async openTranscriptionStream(t,e,r){let s=await X(this,te,"f").call("ai.transcriptionOpen",{modelId:t,params:r}),n=X(this,te,"f").subscribe(a=>{a.type==="transcription-text"&&a.streamId===s&&a.text&&e(a.text)});return X(this,Fi,"f").set(s,n),s}async closeTranscriptionStream(t){X(this,Js,"f").delete(t),await X(this,te,"f").call("ai.transcriptionClose",{streamId:t});let e=X(this,Fi,"f").get(t);e&&(e(),X(this,Fi,"f").delete(t))}async feedTranscriptionStream(t,e){let r=Array.isArray(t)?t:[t],s=e instanceof Float32Array?e:new Float32Array(e);if(r.length===0||s.length===0)return;let n=X(this,te,"f").getBaseUrl(),a=X(this,te,"f").getToken(),o=s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),c=await fetch(`${n}/api/v1/ai/transcription/feed`,{method:"POST",headers:{"Content-Type":"application/octet-stream","X-Stream-Ids":r.join(","),...a?{Authorization:`Bearer ${a}`}:{}},body:o});if(!c.ok){let l=await c.text().catch(()=>"");throw new Error(`[AIClient] feed failed: ${c.status} ${c.statusText} ${l}`)}}};te=new WeakMap,Fi=new WeakMap,Js=new WeakMap;var Ue=function(i,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?i!==t||!s:!t.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(i,e):s?s.value=e:t.set(i,e),e},J=function(i,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?i!==t||!r:!t.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(i):r?r.value:t.get(i)},Ks,Gs,Oe,It,Wi,jr,Bi,Ot,Dr,qi,nr=class{constructor(t,e,r=!0){Ks.set(this,void 0),Gs.set(this,void 0),Oe.set(this,void 0),It.set(this,void 0),Wi.set(this,void 0),jr.set(this,void 0),Bi.set(this,void 0),Ot.set(this,void 0),Dr.set(this,void 0),qi.set(this,void 0),Ue(this,Ks,t,"f"),Ue(this,Gs,e,"f"),Ue(this,Oe,new We(t,e),"f"),Ue(this,It,new Is(t,e,r,J(this,Oe,"f")),"f"),Ue(this,Wi,new Us(t,e,J(this,Oe,"f")),"f"),Ue(this,jr,new Os(t,e,J(this,Oe,"f")),"f"),Ue(this,Bi,new Rs(t,e,J(this,Oe,"f")),"f"),Ue(this,qi,new Qs(t,e,r,J(this,Oe,"f")),"f"),Ue(this,Ot,new Wr(t,e,r,J(this,Oe,"f")),"f"),J(this,Ot,"f").setExpressionClient(J(this,Wi,"f")),J(this,Ot,"f").setNeighbourhoodClient(J(this,Bi,"f")),J(this,Ot,"f").setAIClient(J(this,qi,"f")),Ue(this,Dr,new Ns(t,e,r,J(this,Oe,"f")),"f")}get agent(){return J(this,It,"f")}get expression(){return J(this,Wi,"f")}get languages(){return J(this,jr,"f")}get neighbourhood(){return J(this,Bi,"f")}get perspective(){return J(this,Ot,"f")}get runtime(){return J(this,Dr,"f")}get ai(){return J(this,qi,"f")}startSubscriptions(){J(this,It,"f").subscribeAgentUpdated(),J(this,It,"f").subscribeAgentStatusChanged(),J(this,It,"f").subscribeAppsChanged()}close(){J(this,Oe,"f").closeAll()}};Ks=new WeakMap,Gs=new WeakMap,Oe=new WeakMap,It=new WeakMap,Wi=new WeakMap,jr=new WeakMap,Bi=new WeakMap,Ot=new WeakMap,Dr=new WeakMap,qi=new WeakMap;var Fa;(function(i){i.LanguageIsNotLoaded="LANGUAGE_IS_NOT_LOADED",i.ExpressionIsNotVerified="EXPRESSION_IS_NOT_VERIFIED",i.AgentIsUntrusted="AGENT_IS_UNTRUSTED",i.CapabilityRequested="CAPABILITY_REQUESTED",i.InstallNotificationRequest="INSTALL_NOTIFICATION_REQUEST"})(Fa||(Fa={}));var Wa=class extends wt(){};var Ba;(function(i){i.Private="PRIVATE",i.NeighboudhoodCreationInitiated="NEIGHBOURHOOD_CREATION_INITIATED",i.NeighbourhoodJoinInitiated="NEIGHBOURHOOD_JOIN_INITIATED",i.LinkLanguageFailedToInstall="LINK_LANGUAGE_FAILED_TO_INSTALL",i.LinkLanguageInstalledButNotSynced="LINK_LANGUAGE_INSTALLED_BUT_NOT_SYNCED",i.Synced="SYNCED"})(Ba||(Ba={}));var qa=class extends wt(){};var zh,Hh;zh=new WeakMap,Hh=new WeakMap;function Zi(i,t){if("predicate"in i)return i.predicate;let{model:e}=i,r=ue(e);if(i.field){let s=r[i.field];if(!s)throw new Error(`parent(): field "${i.field}" is not a registered relation on ${e.name}`);return s.predicate}for(let[,s]of Object.entries(r))if(s.target&&s.target()===t)return s.predicate;throw new Error(`parent(): could not resolve predicate \u2014 no relation on ${e.name} targets ${t.name||"the queried class"}`)}function Za(i){if(!i)return"";if(i.includes("://")){let[t,e]=i.split("://"),r=(e||"").replace(/\/+$/,"");return`${t}://${r}`}else return i.replace(/\/+$/,"")}function cn(i){if(!!i){if(typeof i=="string")return i;if(Array.isArray(i)&&i.length>0)return i.find(e=>e!=="null")||i[0]}}function jo(i,t){return cn(i.type)===t}function Do(i){return jo(i,"array")}function Va(i){return jo(i,"object")}function Fh(i){let t=cn(i.type);return t==="number"||t==="integer"}function zo(i,t){if(t.namespace)return t.namespace;if(i["x-ad4m"]?.namespace)return i["x-ad4m"].namespace;if(i.title)return`${i.title.toLowerCase()}://`;if(i.$id)try{let r=new URL(i.$id).pathname.split("/").filter(s=>s);if(r.length>0)return`${r[r.length-1].replace(/\.schema\.json$/,"").replace(/\.json$/,"").toLowerCase()}://`}catch{}throw new Error(`Cannot infer namespace for JSON Schema. Please provide one of:
1026
85
  - options.namespace
1027
86
  - schema["x-ad4m"].namespace
1028
87
  - schema.title
1029
- - valid schema.$id`)}function Cg(r,e,t,i,n){if(n.propertyMapping?.[e])return n.propertyMapping[e];if(t["x-ad4m"]?.through)return t["x-ad4m"].through;if(n.predicateTemplate){let o=ym(i),[s,c]=o.includes("://")?o.split("://"):["",o],l=c||"";return n.predicateTemplate.replace("${namespace}",l).replace("${scheme}",s).replace("${ns}",l).replace("${title}",r.title||"").replace("${property}",e)}if(n.predicateGenerator)return n.predicateGenerator(r.title||"",e);let a=ym(i);return a.includes("://")?`${a}${e}`:`${a}://${e}`}function Ka(r,e,t,i,n){return t.propertyOptions?.[r]?.[i]!==void 0?t.propertyOptions[r][i]:e["x-ad4m"]?.[i]!==void 0?e["x-ad4m"][i]:t[i]!==void 0?t[i]:n}function A1(r){switch(r){case"string":return"";case"number":return 0;case"integer":return 0;case"boolean":return!1;case"array":return[];case"object":return{};default:return""}}function I1(r,e,t){if(e?.properties&&Object.prototype.hasOwnProperty.call(e.properties,"author"))throw new Error('JSON Schema must not define a top-level "author" property because Ad4mModel already exposes it. Please rename the property (e.g., "writer").');let i=Tg(e,t),n=class extends r{};if(!t.name||t.name.trim()==="")throw new Error("options.name is required and cannot be empty");n.className=t.name,n.prototype.className=t.name;let a={},o={};if(e.properties)for(let[c,l]of Object.entries(e.properties)){let u=Cg(e,c,l,i,t),d=e.required?.includes(c)||!1,f=Ap(l.type);if(Ig(l)){o[c]={through:u,local:Ka(c,l,t,"local")},Object.defineProperty(n.prototype,c,{configurable:!0,writable:!0,value:[]});let h=`add${vt(c)}`,m=`remove${vt(c)}`,y=`set${vt(c)}`;n.prototype[h]=function(){},n.prototype[m]=function(){},n.prototype[y]=function(){}}else{let h=Ka(c,l,t,"resolveLanguage");!h&&t.resolveLanguage&&(h=t.resolveLanguage);let m=Ka(c,l,t,"local"),y=Ka(c,l,t,"readOnly");if(y===void 0){let S=l["x-ad4m"]?.writable;y=S!==void 0?!S:!1}let b=!y,_=Ka(c,l,t,"initial");if(vm(l)&&!h&&(h="literal",console.warn(`Property "${c}" is an object type. It will be stored as JSON. Consider flattening complex objects for better semantic querying.`)),h==null&&k1(l)&&(h="literal"),h==null&&(h="literal"),d&&!_&&(vm(l)?_="literal:json:{}":_="ad4m://undefined"),a[c]={through:u,required:d,writable:b,...h&&{resolveLanguage:h},...m!==void 0&&{local:m},..._&&{initial:_}},Object.defineProperty(n.prototype,c,{configurable:!0,writable:!0,value:A1(f)}),b){let S=jc(c);n.prototype[S]=function(){}}}}for(let[c,l]of Object.entries(a))n0(n,c,l);for(let[c,l]of Object.entries(o))a0(n,c,{predicate:l.through||"",kind:"hasMany",...l.getter!==void 0&&{getter:l.getter},...l.local!==void 0&&{local:l.local}});return n.prototype.__jsonSchema=e,n.prototype.__jsonSchemaOptions=t,o0({name:t.name})(n),n}function T1(r){return!(r.flag||r.resolveLanguage&&r.resolveLanguage!=="literal")}function C1(r){return r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function zO(r){return typeof r=="string"?`"${C1(r)}"`:`"${String(r)}"`}function _e(r){return`<${r}>`}function O1(r,e,t,i){let n=[],a=[];if(t.parent){let d=wo(t.parent,i);n.push(`
1030
- ${_e(t.parent.id)} ${_e(d)} ?source .`)}let o=!1;for(let[,d]of Object.entries(r.properties))if(d.required){if(d.getter)continue;o=!0,d.flag&&d.initial?n.push(`
1031
- ?source ${_e(d.predicate)} ${_e(d.initial)} .`):n.push(`
1032
- ?source ${_e(d.predicate)} ?cfTarget_${d.name} .`)}if(!o){for(let[,d]of Object.entries(r.properties))if(d.initial){o=!0,d.flag?n.push(`
1033
- ?source ${_e(d.predicate)} ${_e(d.initial)} .`):n.push(`
1034
- ?source ${_e(d.predicate)} ?cfInitTarget_${d.name} .`);break}}if(!o&&n.length===0){let d=[];for(let[,f]of Object.entries(r.properties))f.predicate&&d.push(_e(f.predicate));if(r.relations)for(let[,f]of Object.entries(r.relations))f.predicate&&d.push(_e(f.predicate));d.length>0&&n.push(`
1035
- { SELECT DISTINCT ?source WHERE { ?source ?cf_structPred ?cf_structTarget . FILTER(?cf_structPred IN (${d.join(", ")})) } }`)}let{joins:s,filters:c}=R1(r,e,t.where);n.push(...s),a.push(...c);let l=n.join(`
1036
- `),u=a.length>0?`FILTER(
1037
- ${a.join(` &&
88
+ - valid schema.$id`)}function Ho(i,t,e,r,s){if(s.propertyMapping?.[t])return s.propertyMapping[t];if(e["x-ad4m"]?.through)return e["x-ad4m"].through;if(s.predicateTemplate){let a=Za(r),[o,c]=a.includes("://")?a.split("://"):["",a],l=c||"";return s.predicateTemplate.replace("${namespace}",l).replace("${scheme}",o).replace("${ns}",l).replace("${title}",i.title||"").replace("${property}",t)}if(s.predicateGenerator)return s.predicateGenerator(i.title||"",t);let n=Za(r);return n.includes("://")?`${n}${t}`:`${n}://${t}`}function _i(i,t,e,r,s){return e.propertyOptions?.[i]?.[r]!==void 0?e.propertyOptions[i][r]:t["x-ad4m"]?.[r]!==void 0?t["x-ad4m"][r]:e[r]!==void 0?e[r]:s}function Wh(i){switch(i){case"string":return"";case"number":return 0;case"integer":return 0;case"boolean":return!1;case"array":return[];case"object":return{};default:return""}}function Bh(i,t,e){if(t?.properties&&Object.prototype.hasOwnProperty.call(t.properties,"author"))throw new Error('JSON Schema must not define a top-level "author" property because Ad4mModel already exposes it. Please rename the property (e.g., "writer").');let r=zo(t,e),s=class extends i{};if(!e.name||e.name.trim()==="")throw new Error("options.name is required and cannot be empty");s.className=e.name,s.prototype.className=e.name;let n={},a={};if(t.properties)for(let[c,l]of Object.entries(t.properties)){let d=Ho(t,c,l,r,e),g=t.required?.includes(c)||!1,p=cn(l.type);if(Do(l)){a[c]={through:d,local:_i(c,l,e,"local")},Object.defineProperty(s.prototype,c,{configurable:!0,writable:!0,value:[]});let u=`add${Ar(c)}`,f=`remove${Ar(c)}`,w=`set${Ar(c)}`;s.prototype[u]=function(){},s.prototype[f]=function(){},s.prototype[w]=function(){}}else{let u=_i(c,l,e,"resolveLanguage");!u&&e.resolveLanguage&&(u=e.resolveLanguage);let f=_i(c,l,e,"local"),w=_i(c,l,e,"readOnly");if(w===void 0){let S=l["x-ad4m"]?.writable;w=S!==void 0?!S:!1}let v=!w,x=_i(c,l,e,"initial");if(Va(l)&&!u&&(u="literal",console.warn(`Property "${c}" is an object type. It will be stored as JSON. Consider flattening complex objects for better semantic querying.`)),u==null&&Fh(l)&&(u="literal"),u==null&&(u="literal"),g&&!x&&(Va(l)?x="literal:json:{}":x="ad4m://undefined"),n[c]={through:d,required:g,writable:v,...u&&{resolveLanguage:u},...f!==void 0&&{local:f},...x&&{initial:x}},Object.defineProperty(s.prototype,c,{configurable:!0,writable:!0,value:Wh(p)}),v){let S=en(c);s.prototype[S]=function(){}}}}for(let[c,l]of Object.entries(n))Ls(s,c,l);for(let[c,l]of Object.entries(a))Xa(s,c,{predicate:l.through||"",kind:"hasMany",...l.getter!==void 0&&{getter:l.getter},...l.local!==void 0&&{local:l.local}});return s.prototype.__jsonSchema=t,s.prototype.__jsonSchemaOptions=e,Ya({name:e.name})(s),s}function qh(i,t,e){if(!e)return!1;for(let[r,s]of Object.entries(e)){if(r==="base"||r==="id")continue;if(r==="author"||r==="timestamp")return!0;let n=i.properties[r];if(!n)continue;let a=t[r];if(a&&(a.kind==="belongsToOne"||a.kind==="belongsToMany"))return!0;if(Fo(n)&&typeof s=="object"&&s!==null&&!Array.isArray(s)){let o=s;if(o.gt!==void 0||o.gte!==void 0||o.lt!==void 0||o.lte!==void 0||o.between!==void 0||o.contains!==void 0)return!0}}return!1}function Fo(i){return!(i.flag||i.resolveLanguage&&i.resolveLanguage!=="literal")}function Zh(i){return i.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function $r(i){return typeof i=="string"?`"${Zh(i)}"`:`"${String(i)}"`}function Z(i){return`<${i}>`}function Vh(i,t){let e=t.properties[i];if(e){if(e.required&&!e.getter&&!(e.flag&&e.initial))return`?cfTarget_${i}`;if(e.initial&&!e.flag)return`?cfInitTarget_${i}`}return`?wTarget_${i}`}function Jh(i,t,e,r){let s=[],n=[];if(e.parent){let h=Zi(e.parent,r);s.push(`
89
+ ${Z(e.parent.id)} ${Z(h)} ?source .`)}let a=!1;for(let[,h]of Object.entries(i.properties))if(h.required){if(h.getter)continue;a=!0,h.flag&&h.initial?s.push(`
90
+ ?source ${Z(h.predicate)} ${Z(h.initial)} .`):s.push(`
91
+ ?source ${Z(h.predicate)} ?cfTarget_${h.name} .`)}if(!a){for(let[,h]of Object.entries(i.properties))if(h.initial){a=!0,h.flag?s.push(`
92
+ ?source ${Z(h.predicate)} ${Z(h.initial)} .`):s.push(`
93
+ ?source ${Z(h.predicate)} ?cfInitTarget_${h.name} .`);break}}if(!a&&s.length===0){let h=[];for(let[,u]of Object.entries(i.properties))u.predicate&&h.push(Z(u.predicate));if(i.relations)for(let[,u]of Object.entries(i.relations))u.predicate&&h.push(Z(u.predicate));h.length>0&&s.push(`
94
+ { SELECT DISTINCT ?source WHERE { ?source ?cf_structPred ?cf_structTarget . FILTER(?cf_structPred IN (${h.join(", ")})) } }`)}let{joins:o,filters:c}=Gh(i,t,e.where);s.push(...o),n.push(...c);let l=s.join(`
95
+ `),d=n.length>0?`FILTER(
96
+ ${n.join(` &&
1038
97
  `)}
1039
- )`:"";return`
1040
- SELECT ?source ?predicate ?target ?author ?timestamp WHERE {${l}
1041
- GRAPH ?linkGraph { ?source ?predicate ?target . }
98
+ )`:"",p=!qh(i,t,e.where)&&(e.limit!==void 0||e.offset!==void 0)?Kh(s,n,i,e):"";return p?`
99
+
100
+ SELECT ?source ?predicate ?target ?author ?timestamp WHERE {
101
+ ${p}${l}
102
+ ?source ?predicate ?target .
103
+ ?_reifier <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<( ?source ?predicate ?target )>> .
1042
104
  FILTER(isIRI(?source) && isIRI(?predicate))
1043
- ?linkGraph <ad4m://ontology/author> ?author .
1044
- ?linkGraph <ad4m://ontology/timestamp> ?timestamp .
1045
- ${u}
105
+ ?_reifier <ad4m://ontology/author> ?author .
106
+ ?_reifier <ad4m://ontology/timestamp> ?timestamp .
107
+ ${d}
1046
108
  }
1047
- ${$1()}
1048
- `.trim()}function $1(r,e){return""}function P1(r){return`
1049
- SELECT ?source ?predicate ?target ?author ?timestamp WHERE {
1050
- GRAPH ?linkGraph { ${_e(r)} ?predicate ?target . }
1051
- FILTER(isIRI(?predicate))
1052
- BIND(${_e(r)} AS ?source)
1053
- ?linkGraph <ad4m://ontology/author> ?author .
1054
- ?linkGraph <ad4m://ontology/timestamp> ?timestamp .
109
+ `.trim():`
110
+
111
+ SELECT ?source ?predicate ?target ?author ?timestamp WHERE {${l}
112
+ ?source ?predicate ?target .
113
+ ?_reifier <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<( ?source ?predicate ?target )>> .
114
+ FILTER(isIRI(?source) && isIRI(?predicate))
115
+ ?_reifier <ad4m://ontology/author> ?author .
116
+ ?_reifier <ad4m://ontology/timestamp> ?timestamp .
117
+ ${d}
1055
118
  }
1056
- `.trim()}function So(r){let e=new Map;for(let t of r){let i=t.source;e.has(i)||e.set(i,[]),e.get(i).push({predicate:t.predicate,target:t.target,author:t.author,timestamp:t.timestamp})}return Array.from(e.entries()).map(([t,i])=>({source_uri:t,links:i}))}function R1(r,e,t){if(!t)return{joins:[],filters:[]};let i=[],n=[];for(let[a,o]of Object.entries(t)){if(a==="base"||a==="id"){if(Array.isArray(o)){let u=o.map(d=>_e(d)).join(", ");n.push(`?source IN (${u})`)}else if(typeof o=="object"&&o!==null){let u=o;if(u.not!==void 0)if(Array.isArray(u.not)){let d=u.not.map(f=>_e(f)).join(", ");n.push(`!(?source IN (${d}))`)}else n.push(`?source != ${_e(u.not)}`)}else n.push(`?source = ${_e(String(o))}`);continue}if(a==="author"||a==="timestamp")continue;let s=r.properties[a];if(!s)continue;let c=e[a];if(c&&(c.kind==="belongsToOne"||c.kind==="belongsToMany"))continue;if(T1(s))if(typeof o=="object"&&o!==null&&!Array.isArray(o)){let u=o;(u.gt!==void 0||u.gte!==void 0||u.lt!==void 0||u.lte!==void 0||u.between!==void 0||u.contains!==void 0||u.not!==void 0)&&i.push(`
1057
- ?source ${_e(s.predicate)} ?wTarget_cmp_${a} .`)}else i.push(`
1058
- ?source ${_e(s.predicate)} ?wTarget_${a} .`);else if(Array.isArray(o)){let u=o.map(d=>_e(d)).join(", ");i.push(`
1059
- ?source ${_e(s.predicate)} ?wTarget_${a} .`),n.push(`?wTarget_${a} IN (${u})`)}else if(typeof o=="object"&&o!==null){let u=o;if(u.not!==void 0)if(Array.isArray(u.not)){let f=u.not.map(p=>_e(p)).join(", ");n.push(`
119
+ ${Qh()}
120
+ `.trim()}function Qh(i,t){return""}function Kh(i,t,e,r){let s=i.join(`
121
+ `),n=t.length>0?`FILTER(
122
+ ${t.join(` &&
123
+ `)}
124
+ )`:"",a="",o=[];if(r.order){let p=Object.entries(r.order).map(([h,u])=>{let f=Vh(h,e);if(!s.includes(f)){let v=e.properties[h];v&&v.predicate&&!v.getter&&o.push(`
125
+ OPTIONAL { ?source <${v.predicate}> ${f} . }`)}return u==="DESC"?`DESC(${f})`:`ASC(${f})`});p.length>0&&(a=`ORDER BY ${p.join(" ")}`)}let c="",l="",d=r.limit!==void 0?`LIMIT ${r.limit}`:"",g=r.offset!==void 0&&r.offset>0?`OFFSET ${r.offset}`:"";return`
126
+ { SELECT DISTINCT ?source${c} WHERE {${s}${o.join("")}${l}
127
+ FILTER(isIRI(?source))
128
+ ${n}
129
+ } GROUP BY ?source ${a} ${d} ${g} }
130
+ `}function Gh(i,t,e){if(!e)return{joins:[],filters:[]};let r=[],s=[];for(let[n,a]of Object.entries(e)){if(n==="base"||n==="id"){if(Array.isArray(a)){let d=a.map(g=>Z(g)).join(", ");s.push(`?source IN (${d})`)}else if(typeof a=="object"&&a!==null){let d=a;if(d.not!==void 0)if(Array.isArray(d.not)){let g=d.not.map(p=>Z(p)).join(", ");s.push(`!(?source IN (${g}))`)}else s.push(`?source != ${Z(d.not)}`)}else s.push(`?source = ${Z(String(a))}`);continue}if(n==="author"||n==="timestamp")continue;let o=i.properties[n];if(!o)continue;let c=t[n];if(c&&(c.kind==="belongsToOne"||c.kind==="belongsToMany"))continue;if(Fo(o))if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let d=a;if((d.gt!==void 0||d.gte!==void 0||d.lt!==void 0||d.lte!==void 0||d.between!==void 0||d.contains!==void 0)&&r.push(`
131
+ ?source ${Z(o.predicate)} ?wTarget_cmp_${n} .`),d.not!==void 0)if(r.push(`
132
+ ?source ${Z(o.predicate)} ?wTarget_${n} .`),Array.isArray(d.not)){let p=d.not.map(h=>$r(h)).join(", ");s.push(`STR(<ad4m://fn/parse_literal>(?wTarget_${n})) NOT IN (${p})`)}else s.push(`STR(<ad4m://fn/parse_literal>(?wTarget_${n})) != ${$r(d.not)}`)}else if(Array.isArray(a)){r.push(`
133
+ ?source ${Z(o.predicate)} ?wTarget_${n} .`);let d=a.map(g=>$r(g)).join(", ");s.push(`STR(<ad4m://fn/parse_literal>(?wTarget_${n})) IN (${d})`)}else r.push(`
134
+ ?source ${Z(o.predicate)} ?wTarget_${n} .`),s.push(`STR(<ad4m://fn/parse_literal>(?wTarget_${n})) = ${$r(a)}`);else if(Array.isArray(a)){let d=a.map(g=>Z(g)).join(", ");r.push(`
135
+ ?source ${Z(o.predicate)} ?wTarget_${n} .`),s.push(`?wTarget_${n} IN (${d})`)}else if(typeof a=="object"&&a!==null){let d=a;if(d.not!==void 0)if(Array.isArray(d.not)){let p=d.not.map(h=>Z(h)).join(", ");s.push(`
1060
136
  NOT EXISTS {
1061
- ?source ${_e(s.predicate)} ?wTarget_not_${a} .
1062
- FILTER(?wTarget_not_${a} IN (${f}))
137
+ ?source ${Z(o.predicate)} ?wTarget_not_${n} .
138
+ FILTER(?wTarget_not_${n} IN (${p}))
1063
139
  }
1064
- `)}else n.push(`
140
+ `)}else s.push(`
1065
141
  NOT EXISTS {
1066
- ?source ${_e(s.predicate)} ${_e(u.not)} .
142
+ ?source ${Z(o.predicate)} ${Z(d.not)} .
1067
143
  }
1068
- `);(u.gt!==void 0||u.gte!==void 0||u.lt!==void 0||u.lte!==void 0||u.between!==void 0||u.contains!==void 0)&&i.push(`
1069
- ?source ${_e(s.predicate)} ?wTarget_cmp_${a} .`)}else i.push(`
1070
- ?source ${_e(s.predicate)} ${_e(String(o))} .`)}return{joins:i,filters:n}}var dn=new Map;function L1(r,e){return`${r}::${e}`}async function N1(r,e,t,i){let n=r.uuid||r.handle?.uuid||"",a=L1(n,e),o=dn.get(a),s={onResult:i,hydrate:t};if(o){o.callbacks.add(s),o.refCount++;let d;return o.latestHydrated!==void 0?d=o.latestHydrated:o.latestRaw!==void 0&&(d=await t(o.latestRaw)),{initialResult:d,dispose:()=>bm(a,s)}}let c=await r.subscribeQuery(e),l={subscription:c,callbacks:new Set([s]),latestRaw:c.result,latestHydrated:void 0,hydrating:!1,refCount:1};dn.set(a,l),c.onResult(async d=>{l.latestRaw=d,l.hydrating=!0;try{let f=l.callbacks.values().next().value;if(f){let p=await f.hydrate(d);l.latestHydrated=p;for(let h of l.callbacks)try{h.onResult(p)}catch{}}}finally{l.hydrating=!1}});let u=await t(c.result);return l.latestHydrated=u,{initialResult:u,dispose:()=>bm(a,s)}}function bm(r,e){let t=dn.get(r);!t||(t.callbacks.delete(e),t.refCount--,t.refCount<=0&&(t.subscription?.dispose&&t.subscription.dispose(),dn.delete(r)))}function WO(){for(let r of dn.values())r.subscription?.dispose&&r.subscription.dispose();dn.clear()}function GO(){return dn.size}var dp=class{constructor(e,t,i){this.queryParams={},this.modelClassName=null,this.engineFlag="sparql",this.perspective=e,this.ctor=t,i&&(this.queryParams=i)}dispose(){this.currentSubscription&&(this.currentSubscription.dispose(),this.currentSubscription=void 0)}where(e){return this.queryParams.where=e,this}order(e){return this.queryParams.order=e,this}limit(e){return this.queryParams.limit=e,this}offset(e){return this.queryParams.offset=e,this}parent(e,t,i){let n=typeof e=="string"?e:e.id;if(typeof t=="object"&&t!==null&&!("prototype"in t)){if(typeof e=="string")throw new Error("parent() called with a string id and options object requires a model class as second argument");let o=e.constructor;return this.queryParams.parent={id:n,model:o,field:t.field},this}let a=i?.field;if(typeof t=="string")this.queryParams.parent={id:n,predicate:t};else if(typeof t=="function")this.queryParams.parent={id:n,model:t,...a&&{field:a}};else if(typeof e!="string")this.queryParams.parent={id:n,model:e.constructor,...a&&{field:a}};else throw new Error("parent() called with a string id requires a second argument: either a model class or a predicate string");return this}properties(e){return this.queryParams.properties=e,this}include(e){return this.queryParams.include=e,this}overrideModelClassName(e){return this.modelClassName=e,this}engine(e){return this.engineFlag=e,this}async get(){let e;if(this.engineFlag==="sparql")e=await this.executeSparqlQuery();else{let t=await this.ctor.queryToProlog(this.perspective,this.queryParams,this.modelClassName),i=await this.perspective.infer(t);({results:e}=await this.ctor.instancesFromPrologResult(this.perspective,this.queryParams,i))}return e}async getSparql(){return this.executeSparqlQuery()}async executeSparqlQuery(){let e=await this.ctor.queryToSPARQL(this.perspective,this.queryParams),t=await this.perspective.querySparql(e),{results:i}=await this.processSparqlResult(t);return i}async processSparqlResult(e,t){let i=So(Array.isArray(e)?e:[]);return await this.ctor.instancesFromQueryResult(this.perspective,t||this.queryParams,i)}async first(){return this.queryParams.limit=1,(await this.get())[0]??null}async subscribe(e){this.dispose();let t=this.ctor;if(this.engineFlag==="sparql"){let i=await t.queryToSPARQL(this.perspective,this.queryParams),n=null,a=l=>{if(l.length===0)return"0:";let u=l.map(f=>f.id||"").sort().join(","),d=l.map(f=>f.updatedAt||f.timestamp||"").join(",");return`${l.length}:${u}:${d}`},o=async l=>{let{results:u}=await this.processSparqlResult(l);return u},s=await N1(this.perspective,i,o,l=>{let u=a(l);u!==n&&(n=u,e(l))});this.currentSubscription={dispose:s.dispose};let c=s.initialResult;return n=a(c),c}else{let i=await t.queryToProlog(this.perspective,this.queryParams,this.modelClassName);this.currentSubscription=await this.perspective.subscribeInfer(i);let n=async o=>{let{results:s}=await t.instancesFromPrologResult(this.perspective,this.queryParams,o);e(s)};this.currentSubscription.onResult(n);let{results:a}=await t.instancesFromPrologResult(this.perspective,this.queryParams,this.currentSubscription.result);return a}}async subscribeSparql(e){this.dispose();let t=await this.ctor.queryToSPARQL(this.perspective,this.queryParams);this.currentSubscription=await this.perspective.subscribeQuery(t);let i=async a=>{let{results:o}=await this.processSparqlResult(a);e(o)};this.currentSubscription.onResult(i);let{results:n}=await this.processSparqlResult(this.currentSubscription.result);return n}async count(){if(this.engineFlag==="sparql"){let e=await this.ctor.queryToSPARQL(this.perspective,this.queryParams),t=await this.perspective.querySparql(e),{totalCount:i}=await this.processSparqlResult(t);return i}else{let e=await this.ctor.countQueryToProlog(this.perspective,this.queryParams,this.modelClassName);return(await this.perspective.infer(e))?.[0]?.TotalCount||0}}async countSparql(){let e=this.engineFlag;this.engineFlag="sparql";try{return await this.count()}finally{this.engineFlag=e}}async countSubscribe(e){if(this.dispose(),this.engineFlag==="sparql"){let t=await this.ctor.queryToSPARQL(this.perspective,this.queryParams);this.currentSubscription=await this.perspective.subscribeQuery(t);let i=async a=>{let{totalCount:o}=await this.processSparqlResult(a);e(o)};this.currentSubscription.onResult(i);let{totalCount:n}=await this.processSparqlResult(this.currentSubscription.result);return n}else{let t=await this.ctor.countQueryToProlog(this.perspective,this.queryParams,this.modelClassName);this.currentSubscription=await this.perspective.subscribeInfer(t);let i=async a=>{let o=a?.[0]?.TotalCount||0;e(o)};return this.currentSubscription.onResult(i),this.currentSubscription.result?.[0]?.TotalCount||0}}async countSubscribeSparql(e){this.dispose();let t=await this.ctor.queryToSPARQL(this.perspective,this.queryParams);this.currentSubscription=await this.perspective.subscribeQuery(t);let i=async a=>{let{totalCount:o}=await this.processSparqlResult(a);e(o)};this.currentSubscription.onResult(i);let{totalCount:n}=await this.processSparqlResult(this.currentSubscription.result);return n}async paginate(e,t){let i={...this.queryParams||{},limit:e,offset:e*(t-1),count:!0};if(this.engineFlag==="sparql"){let n=await this.ctor.queryToSPARQL(this.perspective,i),a=await this.perspective.querySparql(n),{results:o,totalCount:s}=await this.processSparqlResult(a,i);return{results:o,totalCount:s,pageSize:e,pageNumber:t}}else{let n=await this.ctor.queryToProlog(this.perspective,i,this.modelClassName),a=await this.perspective.infer(n),{results:o,totalCount:s}=await this.ctor.instancesFromPrologResult(this.perspective,i,a);return{results:o,totalCount:s,pageSize:e,pageNumber:t}}}async paginateSparql(e,t){let i=this.engineFlag;this.engineFlag="sparql";try{return await this.paginate(e,t)}finally{this.engineFlag=i}}async paginateSubscribe(e,t,i){this.dispose();let n={...this.queryParams||{},limit:e,offset:e*(t-1),count:!0};if(this.engineFlag==="sparql"){let a=await this.ctor.queryToSPARQL(this.perspective,n);this.currentSubscription=await this.perspective.subscribeQuery(a);let o=async u=>{let{results:d,totalCount:f}=await this.processSparqlResult(u,n);i({results:d,totalCount:f,pageSize:e,pageNumber:t})};this.currentSubscription.onResult(o);let{results:s,totalCount:c}=await this.processSparqlResult(this.currentSubscription.result,n);return{results:s,totalCount:c,pageSize:e,pageNumber:t}}else{let a=await this.ctor.queryToProlog(this.perspective,n,this.modelClassName);this.currentSubscription=await this.perspective.subscribeInfer(a);let o=async u=>{let{results:d,totalCount:f}=await this.ctor.instancesFromPrologResult(this.perspective,this.queryParams,u);i({results:d,totalCount:f,pageSize:e,pageNumber:t})};this.currentSubscription.onResult(o);let{results:s,totalCount:c}=await this.ctor.instancesFromPrologResult(this.perspective,n,this.currentSubscription.result);return{results:s,totalCount:c,pageSize:e,pageNumber:t}}}async paginateSubscribeSparql(e,t,i){let n=this.engineFlag;this.engineFlag="sparql";try{return await this.paginateSubscribe(e,t,i)}finally{this.engineFlag=n}}};function Xs(r){return Array.isArray(r)?r.map(e=>e&&typeof e=="object"&&typeof e.id=="string"?e.id:e):r}function Uu(r,e){if(Array.isArray(e))return e.includes(r);if(typeof e=="object"&&e!==null){let t=e;if(t.not!==void 0)return Array.isArray(t.not)?!t.not.includes(r):r!==t.not;if(t.between!==void 0&&Array.isArray(t.between)&&t.between.length===2)return r>=t.between[0]&&r<=t.between[1];let i=!0;return t.gt!==void 0&&(i=i&&r>t.gt),t.gte!==void 0&&(i=i&&r>=t.gte),t.lt!==void 0&&(i=i&&r<t.lt),t.lte!==void 0&&(i=i&&r<=t.lte),t.contains!==void 0&&(typeof r=="string"?i=i&&r.includes(String(t.contains)):Array.isArray(r)?i=i&&r.includes(t.contains):i=!1),i}return r===e}async function D1(r,e,t,i){let n=r;if(r!=null&&r!=="")if(e.resolveLanguage!=null&&e.resolveLanguage!=="literal"&&typeof r=="string"&&!r.startsWith("literal:"))try{let a=await t.getExpression(r);if(a)try{n=JSON.parse(a.data)}catch{n=a.data}}catch(a){console.warn(`hydratePropertyValue: failed to resolve expression for "${e.name}":`,a)}else if(e.resolveLanguage==="literal"&&typeof r=="string"&&r.startsWith("literal:"))try{let a=xe.fromUrl(r).get();n=a.data!==void 0?a.data:a}catch{}else typeof r=="string"&&i&&(i==="number"?n=Number(r):i==="boolean"&&(n=r==="true"||r==="1"));return e.transform&&typeof e.transform=="function"&&(n=e.transform(n)),n}async function wm(r,e,t,i,n){if(!e||e.length===0)return;let a=null,o=null,s=null,c=n&&n.length>0?new Set(n):null,l=new Map;for(let[h,m]of Object.entries(t.properties))m.getter||c&&!c.has(h)||l.set(m.predicate,[h,m]);let u=new Map,d=[];for(let[h,m]of Object.entries(t.relations))if(!m.getter){if(m.target&&m.filter!==!1){d.push([h,m]);continue}u.set(m.predicate,[h,m])}for(let[h,m]of d)u.has(m.predicate)||u.set(m.predicate,[h,m]);let f=new Map,p=new Map;for(let h=0;h<e.length;h++){let m=e[h],{predicate:y,target:b,author:_,timestamp:S}=m;if(b==="None"||b===void 0||b===null)continue;S!=null&&((a==null||S<a)&&(a=S,s=_??null),(o==null||S>o)&&(o=S));let v=l.get(y);if(v){f.get(v[0]),f.set(v[0],{target:b,timestamp:S});continue}let C=u.get(y);if(C){let[$]=C,I=p.get($);I||(I=[],p.set($,I)),I.push({target:b,timestamp:S??"",index:h})}}for(let[h,{target:m}]of f){let[,y]=l.get(t.properties[h].predicate),b=typeof r[h];r[h]=await D1(m,y,i,b!=="undefined"?b:void 0)}for(let[h,m]of p)m.sort((y,b)=>{let _=String(y.timestamp).localeCompare(String(b.timestamp));return _!==0?_:y.index-b.index}),r[h]=m.map(y=>y.target).filter(y=>y!=null&&y!==""&&y!=="None");s&&(r.author=s),a!=null&&(r.createdAt=typeof a=="string"&&a.includes("T")?new Date(a).getTime():typeof a=="string"?isNaN(parseInt(a,10))?a:parseInt(a,10):a),o!=null&&(r.updatedAt=typeof o=="string"&&o.includes("T")?new Date(o).getTime():typeof o=="string"?isNaN(parseInt(o,10))?o:parseInt(o,10):o)}async function F1(r,e,t){let i=Object.fromEntries(await Promise.all(t.map(async([a,o,s])=>{let c=o;if(!s&&typeof o=="string"){let d=Array.from(o,h=>h.codePointAt(0)),f=d.every(h=>h<=255),p=d.some(h=>h>=128);if(f&&p)try{let h=Uint8Array.from(d),m=new TextDecoder("utf-8",{fatal:!0}).decode(h);m!==o&&(c=m)}catch(h){console.warn(`UTF-8 byte reconstruction failed for property "${a}"`,{value:o,error:h})}}if(s){let d=await r.getExpression(o);if(d)try{c=JSON.parse(d.data)}catch{c=d.data}}let u=sn(e.constructor)[a]?.transform;return u&&typeof u=="function"&&(c=u(c)),[a,c]}))),n=Object.fromEntries(Object.entries(i).filter(([a])=>{let o=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),a);return o?o.get!==void 0||o.set!==void 0?o.set!==void 0:o.writable!==!1:!0}));Object.assign(e,n)}function M1(r,e){let t=Um(r,e);if(!t){let i=e?.prototype?.className||e?.name||"unknown";console.warn(`[Ad4mModel] buildConformanceGetter: no conditions found for target "${i}".`);return}return t.getter}async function Sm(r,e,t,i){`${r.id}`;let a=i?.requestedProperties&&i.requestedProperties.length>0?new Set(i.requestedProperties):null;for(let[o,s]of Object.entries(t.properties))if(!(a&&!a.has(o))&&s.getter)try{let c=s.getter,l=c.replace(/\?source\b/g,`<${r.id}>`).replace(/<Base>/g,`<${r.id}>`).replace(/Base/g,`<${r.id}>`),u=l.trim().toUpperCase();if(u.startsWith("SELECT")||u.startsWith("ASK")||u.startsWith("CONSTRUCT")){let d=await e.querySparql(l);if(u.startsWith("ASK"))r[o]=d===!0||d==="true";else if(d&&d.length>0){let f=d[0],p=Object.keys(f)[0],h=f[p]?.value??f[p];h!=null&&h!=="None"&&h!==""&&(r[o]=h)}}else console.warn(`Unsupported legacy getter syntax for property ${o} \u2014 use native SPARQL (SELECT/ASK): ${c.slice(0,100)}`)}catch(c){console.warn(`Failed to evaluate getter for ${o}:`,c)}for(let[o,s]of Object.entries(t.relations)){if(a&&!a.has(o)&&!(i?.include&&o in i.include))continue;let c=s,l=c.getter;if(!l&&c.where&&c.direction!=="reverse")try{let d=c.target?.(),f=d?d.getModelMetadata?.()??null:null,p=!0;if(f)for(let h of Object.keys(c.where)){if(["id","author","timestamp"].includes(h))continue;let m=f.properties[h];if(m&&(!m.resolveLanguage||m.resolveLanguage==="literal")){p=!1;break}}else p=!1;if(p){let h=Mm(c.where,f);h.length>0&&(l=`SELECT ?target WHERE { <Base> <${Lr(c.predicate)}> ?target . ${h.join(" ")} }`)}}catch(d){console.warn(`[Ad4mModel] where-clause compilation failed for relation "${o}":`,d)}if(!l&&c.target&&c.filter!==!1&&c.direction!=="reverse")try{let d=c.target();l=M1(c.predicate,d),l||console.warn(`[Ad4mModel] buildConformanceGetter returned undefined for relation "${o}" (predicate: "${c.predicate}")`)}catch(d){console.warn(`[Ad4mModel] auto-generation failed for relation "${o}":`,d)}if(l)try{let d=l.replace(/\?source\b/g,`<${r.id}>`).replace(/<Base>/g,`<${r.id}>`).replace(/\bBase\b/g,`<${r.id}>`),f=d.trim().toUpperCase();if(f.startsWith("SELECT")||f.startsWith("ASK")||f.startsWith("CONSTRUCT")){let p=await e.querySparql(d);if(p&&p.length>0){let h=p.map(m=>{let y=Object.keys(m)[0];return m[y]?.value??m[y]}).filter(m=>m!=null&&m!==""&&m!=="None");r[o]=h}}else console.warn(`Unsupported legacy getter syntax for relation ${o} \u2014 use native SPARQL (SELECT/ASK): ${l.slice(0,100)}`)}catch(d){console.warn(`Failed to evaluate getter for ${o}:`,d)}let u=r[o];if(c.where&&Array.isArray(u)&&u.length>0){let d=c.target?.();if(d){let f=[];for(let p of u)try{let h=new d(e,p);await h.get();let m=!0;for(let[y,b]of Object.entries(c.where))if(h[y]!==b){m=!1;break}m&&f.push(p)}catch{f.push(p)}r[o]=f}}}}async function Ao(r,e,t,i){if(!i||Object.keys(i).length===0)return;let n=hr(r);for(let[a,o]of Object.entries(i)){let s=n[a];if(!s){console.warn(`include: relation "${a}" not found in metadata, skipping`);continue}let c=s.target(),l=typeof o=="object"&&o!==null?o:void 0,u=l?.include;if(s.kind==="belongsToOne"||s.kind==="belongsToMany"){for(let b of e){let S=(await t.get(new K({predicate:s.predicate,target:b.id}))).filter(v=>v.data.target===b.id).map(v=>v.data.source);if(s.kind==="belongsToOne"){if(S.length===0){b[a]=null;continue}let v=S[S.length-1];try{let C=new c(t,v);await C.get(),b[a]=C}catch{b[a]=null}}else{let v=[];if(l&&(l.where||l.order||l.properties)){let C={id:S,...l.where??{}};v=await c.findAll(t,{where:C,...l.order&&{order:l.order},...l.properties&&{properties:l.properties}})}else await Promise.all(S.map(async C=>{try{let $=new c(t,C);await $.get(l?.properties?{properties:l.properties}:void 0),v.push($)}catch{}}));if(l?.order&&!(l.where||l.properties)){let C=Object.entries(l.order);v=v.sort(($,I)=>{for(let[L,M]of C){let N=String($[L]??""),W=String(I[L]??""),Ie=N.localeCompare(W);if(Ie!==0)return M==="DESC"?-Ie:Ie}return 0})}if(l?.offset!=null||l?.limit!=null){let C=l.offset??0,$=l.limit!=null?C+l.limit:void 0;v=v.slice(C,$)}b[a]=v,u&&v.length>0&&await Ao(c,v,t,u)}}continue}let d=new Set,f=new Map;for(let b of e){let _=b[a];if(f.set(b,Array.isArray(_)?[..._]:_),_!=null)if(Array.isArray(_))for(let S of _)typeof S=="string"?d.add(S):S&&typeof S=="object"&&typeof S.id=="string"&&d.add(S.id);else typeof _=="string"?d.add(_):_&&typeof _=="object"&&typeof _.id=="string"&&d.add(_.id)}if(d.size===0)continue;let p=new Map,m={where:{id:Array.from(d),...l?.where??{}},...l?.order&&{order:l.order},...l?.properties&&{properties:l.properties}},y=await c.findAll(t,m);for(let b of y)p.set(b.id,b);for(let b of e){let _=f.get(b);if(_!=null)if(Array.isArray(_)){let S=_.map(v=>typeof v=="string"?p.has(v)?p.get(v):null:v&&typeof v=="object"&&typeof v.id=="string"?p.has(v.id)?p.get(v.id):v:null).filter(v=>v!==null);if(l?.order){let v=Object.entries(l.order);S=S.sort((C,$)=>{for(let[I,L]of v){let M=String(C[I]??""),N=String($[I]??""),W=M.localeCompare(N);if(W!==0)return L==="DESC"?-W:W}return 0})}if(l?.offset!=null||l?.limit!=null){let v=l.offset??0,C=l.limit!=null?v+l.limit:void 0;S=S.slice(v,C)}s.maxCount===1?(S.length>1&&console.warn(`include: relation "${a}" has maxCount 1 but ${S.length} values found; keeping the last`),b[a]=S.length>0?S[S.length-1]:null):b[a]=S}else typeof _=="string"&&p.has(_)?b[a]=p.get(_):_&&typeof _=="object"&&typeof _.id=="string"&&(b[a]=p.has(_.id)?p.get(_.id):_)}if(u){let b=Array.from(p.values());await Ao(c,b,t,u)}}}var da=class{static generateSDNA(){return{sdna:"",name:""}}static generateSHACL(){return{shape:null,name:""}}static async getClassName(e){if(this===da)return await e.stringOrTemplateObjectToSubjectClassName(this);let i=this.classNamesByClass.get(this);i||(i={},this.classNamesByClass.set(this,i));let n=e.uuid;return i[n]||(i[n]=await e.stringOrTemplateObjectToSubjectClassName(this)),i[n]}get timestamp(){return this.createdAt}static getModelMetadata(){let e=this.prototype;if(!e.className||e.className==="Ad4mModel")throw new Error("Model class must be decorated with @Model");let t=e.className,i={},n=sn(this);for(let[d,f]of Object.entries(n)){let p=f;i[d]={name:d,predicate:p.through||"",required:p.required||!1,readOnly:!(p.writable??!1),...p.initial!==void 0&&{initial:p.initial},...p.resolveLanguage!==void 0&&{resolveLanguage:p.resolveLanguage},...p.prologGetter!==void 0&&{prologGetter:p.prologGetter},...p.getter!==void 0&&{getter:p.getter},...p.prologSetter!==void 0&&{prologSetter:p.prologSetter},...p.local!==void 0&&{local:p.local},...p.transform!==void 0&&{transform:p.transform},...p.flag!==void 0&&{flag:p.flag}}}let a={},o=hr(this),s=Object.fromEntries(Object.entries(o).filter(([,d])=>d.kind==="hasMany"||d.kind==="belongsToMany"));for(let[d,f]of Object.entries(s)){let p=f;a[d]={name:d,predicate:p.predicate||"",...p.local!==void 0&&{local:p.local},...p.getter!==void 0&&{getter:p.getter},direction:p.kind==="belongsToMany"||p.kind==="belongsToOne"?"reverse":"forward",...p.target!==void 0&&{target:p.target},...p.filter!==void 0&&{filter:p.filter},...p.where!==void 0&&{where:p.where}}}let c=Object.keys(i).length>0,l=Object.keys(a).length>0;if(!(c||l)&&e.__jsonSchema){let d=e.__jsonSchema,f=e.__jsonSchemaOptions||{};if(d.properties)for(let[p,h]of Object.entries(d.properties)){let m=Ig(h),y=Cg(d,p,h,Tg(d,f),f);if(m)a[p]={name:p,predicate:y,...h["x-ad4m"]?.local!==void 0&&{local:h["x-ad4m"].local}};else{let b=d.required?.includes(p)||!1;i[p]={name:p,predicate:y,required:b,readOnly:h["x-ad4m"]?.writable===!1,...h["x-ad4m"]?.resolveLanguage&&{resolveLanguage:h["x-ad4m"].resolveLanguage},...h["x-ad4m"]?.initial&&{initial:h["x-ad4m"].initial},...h["x-ad4m"]?.local!==void 0&&{local:h["x-ad4m"].local}}}}}return{className:t,properties:i,relations:a}}constructor(e,t){this._snapshot=null,this._baseExpression=t||xe.from(Dm(24)).toUrl(),this._perspective=e}get id(){return this._baseExpression}get baseExpression(){return this._baseExpression}get perspective(){return this._perspective}getPropertyMetadata(e){let t=this.constructor;return sn(t)[e]}getRelationOptions(e){let t=this.constructor;return hr(t)[e]}generatePropertySetterAction(e,t){if(t.flag)throw new Error(`Property "${e}" is a @Flag and cannot be written. Flags are immutable type markers set at creation time.`);if(t.readOnly)throw new Error(`Property "${e}" is read-only and cannot be written`);if(t.prologSetter)throw new Error(`Custom Prolog setter for property "${e}" not yet supported without Prolog. Use standard @Property decorator or enable Prolog for custom setters.`);if(!t.through)throw new Error(`Property "${e}" has no 'through' predicate defined`);return[{action:"setSingleTarget",source:"this",predicate:t.through,target:"value",...t.local&&{local:!0}}]}generateRelationAction(e,t){let i=this.getRelationOptions(e);if(!i)throw new Error(`Relation "${e}" has no metadata defined`);if(!i.predicate)throw new Error(`Relation "${e}" has no predicate defined`);return[{action:{adder:"addLink",remover:"removeLink",setter:"collectionSetter"}[t],source:"this",predicate:i.predicate,target:"value",...i.local&&{local:!0}}]}static async assignValuesToInstance(e,t,i){return F1(e,t,i)}takeSnapshot(e){let i=this.constructor.getModelMetadata(),n={};for(let a of Object.keys(i.properties)){let o=this[a];n[a]=Xs(Array.isArray(o)?[...o]:o)}if(e===void 0)for(let a of Object.keys(i.relations)){let o=this[a];n[a]=Xs(Array.isArray(o)?[...o]:o)}else if(e&&Object.keys(e).length>0){for(let a of Object.keys(e))if(a in i.relations){let o=this[a];n[a]=Xs(Array.isArray(o)?[...o]:o)}}this._snapshot=n}isDirty(){return this._snapshot?this.changedFields().length>0:!0}changedFields(){let t=this.constructor.getModelMetadata();if(!this._snapshot)return[...Object.keys(t.properties),...Object.keys(t.relations)];let i=[],n=[...Object.keys(t.properties),...Object.keys(t.relations)];for(let a of n){if(!(a in this._snapshot))continue;let o=Xs(this[a]),s=this._snapshot[a];if(Array.isArray(o)||Array.isArray(s)){let c=Array.isArray(o)?[...o].sort():[],l=Array.isArray(s)?[...s].sort():[];(c.length!==l.length||c.some((u,d)=>u!==l[d]))&&i.push(a)}else o!==s&&i.push(a)}return i}async getData(e){try{let t=this.constructor,i=t.getModelMetadata(),n=P1(this._baseExpression),a=await this._perspective.querySparql(n);if(a&&a.length>0){let l=e?.properties&&e.properties.length>0?e.properties:void 0;await wm(this,a,i,this._perspective,l)}let o=hr(t),s=e?.properties&&e.properties.length>0?new Set(e.properties):null;for(let[l,u]of Object.entries(o)){if(u.kind!=="belongsToOne"&&u.kind!=="belongsToMany"||s&&!s.has(l))continue;let f=(await this._perspective.get(new K({predicate:u.predicate,target:this._baseExpression}))).filter(p=>p.data.target===this._baseExpression).map(p=>p.data.source);u.kind==="belongsToOne"?this[l]=f.length>0?f[f.length-1]:null:this[l]=f}let c=e?.properties||e?.include?{requestedProperties:e?.properties,include:e?.include}:void 0;await Sm(this,this._perspective,i,c),e?.include&&await Ao(t,[this],this._perspective,e.include)}catch(t){console.error(`SPARQL getData also failed for ${this._baseExpression}:`,t)}return this.takeSnapshot(),this}static async queryToProlog(e,t,i){let{properties:n,where:a,order:o,offset:s,limit:c,count:l}=t,u=i||await this.getClassName(e),d=t.parent?wo(t.parent,this):void 0,f=[pm(),um(t.parent,d),E1(n),dm(a)],p=[fm(l),hm(o),mm(s),gm(c)];return`
1071
- findall([Base, Properties, Collections, Timestamp, Author], (
1072
- subject_class("${u}", SubjectClass),
1073
- instance(SubjectClass, Base),
1074
- ${f.filter(m=>m).join(", ")}
1075
- ), UnsortedInstances),
1076
- ${p.filter(m=>m).join(", ")}
1077
- `}static async queryToSPARQL(e,t){let i=this.getModelMetadata(),n=hr(this);return O1(i,n,t,this)}static async instancesFromPrologResult(e,t,i){if(!i?.[0]?.AllInstances)return{results:[],totalCount:0};let n=t?.properties||[],o=(await Promise.all(i[0].AllInstances.map(async([c,l,u,d,f])=>{try{let p=new this(e,c);n.length&&Object.keys(p).forEach(m=>{!n.includes(m)&&m!=="createdAt"&&m!=="updatedAt"&&m!=="author"&&m!=="id"&&m!=="baseExpression"&&delete p[m]});let h=[...l,...u,["createdAt",d],["author",f]];return await da.assignValuesToInstance(e,p,h),p}catch(p){return console.error(`Failed to process instance ${c}:`,p),null}}))).filter(c=>c!==null);t.include&&o.length>0&&await Ao(this,o,e,t.include);let s=t.include;for(let c of o)c.takeSnapshot(s);return{results:o,totalCount:i[0].TotalCount}}static async instancesFromQueryResult(e,t,i){if(!i||i.length===0)return{results:[],totalCount:0};let n=this.getModelMetadata(),a=t?.properties||[],o=[];for(let m of i){let y;try{if(y=m.source_uri,!y)continue;let b=m.links||[],_=new this(e,y),S=a.length>0?[...a]:void 0;if(S&&t.where)for(let v of Object.keys(t.where))S.includes(v)||S.push(v);await wm(_,b,n,e,S),o.push(_)}catch(b){console.error(`Failed to process SPARQL instance ${y}:`,b)}}let s=hr(this),c=Object.entries(s).filter(([m,y])=>(y.kind==="belongsToOne"||y.kind==="belongsToMany")&&(a.length===0||a.includes(m)));c.length>0&&o.length>0&&await Promise.all(o.map(async m=>{for(let[y,b]of c){let S=(await e.get(new K({predicate:b.predicate,target:m.id}))).filter(v=>v.data.target===m.id).map(v=>v.data.source);b.kind==="belongsToOne"?m[y]=S.length>0?S[S.length-1]:null:m[y]=S}}));let l=a.length>0||t.include?{requestedProperties:a,include:t.include}:void 0;for(let m of o)await Sm(m,e,n,l);let u=o;t.where&&(u=o.filter(m=>{for(let[y,b]of Object.entries(t.where)){if(y==="base"||y==="id")continue;if(y==="author"||y==="timestamp"){if(!Uu(m[y],b))return!1;continue}if(!(y in n.properties)){if(!Uu(m[y],b))return!1;continue}if(!Uu(m[y],b))return!1}return!0}));let d=t.order||(t.limit!==void 0||t.offset!==void 0?{timestamp:"ASC"}:null);if(d){let m=Object.entries(d);u.sort((y,b)=>{for(let[_,S]of m){let v=y[_],C=b[_];if(v===void 0&&C===void 0)continue;if(v===void 0)return S==="ASC"?1:-1;if(C===void 0)return S==="ASC"?-1:1;let $=0;if(typeof v=="number"&&typeof C=="number"?$=v-C:typeof v=="string"&&typeof C=="string"?$=v.localeCompare(C):$=String(v).localeCompare(String(C)),$!==0)return S==="DESC"?-$:$}return 0})}let f=u.length,p=u;if(t.offset!==void 0||t.limit!==void 0){let m=t.offset||0,y=t.limit?m+t.limit:void 0;p=u.slice(m,y)}if(a.length>0){let m=new Set(a);for(let y of p){for(let b of Object.keys(n.properties))m.has(b)||delete y[b];for(let b of Object.keys(n.relations))!m.has(b)&&!(t.include&&b in t.include)&&delete y[b];for(let b of["author","createdAt","updatedAt"])m.has(b)||delete y[b]}}t.include&&p.length>0&&await Ao(this,p,e,t.include);let h=t.include;for(let m of p)m.takeSnapshot(h);return{results:p,totalCount:f}}static async findAll(e,t={},i="sparql"){if(t.properties&&t.properties.length===0)throw new Error("properties[] must not be empty \u2014 omit the field to return all properties, or specify at least one field name");if((typeof i=="boolean"?i?"sparql":"prolog":i)==="sparql"){let a=await this.queryToSPARQL(e,t),o=await e.querySparql(a),s=So(o),{results:c}=await this.instancesFromQueryResult(e,t,s);return c}else{let a=await this.queryToProlog(e,t),o=await e.infer(a),{results:s}=await this.instancesFromPrologResult(e,t,o);return s}}static async findOne(e,t={},i="sparql"){let n={...t,limit:1};return(await this.findAll(e,n,i))[0]??null}static async findAllAndCount(e,t={},i="sparql"){if((typeof i=="boolean"?i?"sparql":"prolog":i)==="sparql"){let a=await this.queryToSPARQL(e,t),o=await e.querySparql(a),s=So(o);return await this.instancesFromQueryResult(e,t,s)}else{let a=await this.queryToProlog(e,t),o=await e.infer(a);return await this.instancesFromPrologResult(e,t,o)}}static async paginate(e,t,i,n,a="sparql"){let o={...n||{},limit:t,offset:t*(i-1),count:!0};if((typeof a=="boolean"?a?"sparql":"prolog":a)==="sparql"){let c=await this.queryToSPARQL(e,o),l=await e.querySparql(c),u=So(l),{results:d,totalCount:f}=await this.instancesFromQueryResult(e,o,u);return{results:d,totalCount:f,pageSize:t,pageNumber:i}}else{let c=await this.queryToProlog(e,o),l=await e.infer(c),{results:u,totalCount:d}=await this.instancesFromPrologResult(e,o,l);return{results:u,totalCount:d,pageSize:t,pageNumber:i}}}static async countQueryToProlog(e,t={},i){let{where:n}=t,a=i||await this.getClassName(e),o=t.parent?wo(t.parent,this):void 0,s=[pm(),um(t.parent,o),dm(n)],c=[fm(!0),hm(),mm(),gm()];return`
1078
- findall([Base, Properties, Collections, Timestamp, Author], (
1079
- subject_class("${a}", SubjectClass),
1080
- instance(SubjectClass, Base),
1081
- ${s.filter(u=>u).join(", ")}
1082
- ), UnsortedInstances),
1083
- ${c.filter(u=>u).join(", ")}
1084
- `}static async countQueryToSPARQL(e,t){let i={...t};return delete i.limit,delete i.offset,await this.queryToSPARQL(e,i)}static async count(e,t={},i="sparql"){if((typeof i=="boolean"?i?"sparql":"prolog":i)==="sparql"){let a=await this.queryToSPARQL(e,t),o=await e.querySparql(a),s=So(o),{totalCount:c}=await this.instancesFromQueryResult(e,t,s);return c}else return(await e.infer(await this.countQueryToProlog(e,t)))?.[0]?.TotalCount||0}async setProperty(e,t,i){let n=this.getPropertyMetadata(e);if(!n){console.warn(`Property "${e}" has no metadata, skipping`);return}let a=this.generatePropertySetterAction(e,n),o=n.resolveLanguage;t==null||t===""||(o&&(t=await this._perspective.createExpression(t,o)),await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:t}],i))}resolveRelationId(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.id=="string"?e.id:String(e)}async setRelationValues(e,t,i){if(!this.getRelationOptions(e)){console.warn(`Relation "${e}" has no metadata, skipping`);return}let a=this.generateRelationAction(e,"setter");t!=null&&(Array.isArray(t)?await this._perspective.executeAction(a,this._baseExpression,t.map(o=>({name:"value",value:this.resolveRelationId(o)})),i):await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(t)}],i))}async addRelationValue(e,t,i){if(!this.getRelationOptions(e)){console.warn(`Relation "${e}" has no metadata, skipping`);return}let a=this.generateRelationAction(e,"adder");t!=null&&(Array.isArray(t)?await Promise.all(t.map(o=>this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(o)}],i))):await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(t)}],i))}async removeRelationValue(e,t,i){if(!this.getRelationOptions(e)){console.warn(`Relation "${e}" has no metadata, skipping`);return}let a=this.generateRelationAction(e,"remover");t!=null&&(Array.isArray(t)?await Promise.all(t.map(o=>this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(o)}],i))):await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(t)}],i))}async save(e){if(this._snapshot){await this.innerUpdate(!0,e),e?this.takeSnapshot():await this.getData();return}let t=!1;e||(e=await this.perspective.createBatch(),t=!0);let i=this.constructor.getModelMetadata(),n=Object.values(i.properties).some(o=>o.required||o.flag||o.initial!==void 0),a=[];if(n){let o={};for(let[c,l]of Object.entries(this))if(l!=null&&!(Array.isArray(l)&&l.length>0)&&!l?.action){let u=i.properties[c];if(u?.resolveLanguage&&u.resolveLanguage!=="literal"&&typeof l=="object"){a.push(c);continue}o[c]=l}let s=await this.perspective.stringOrTemplateObjectToSubjectClassName(this);await this.perspective.createSubject(s,this._baseExpression,o,e)}await this.innerUpdate(!n,e);for(let o of a){let s=this[o];s!=null&&await this.setProperty(o,s,e)}t?(await this.perspective.commitBatch(e),await this.getData()):this.takeSnapshot()}cleanCopy(){let t=this.constructor.getModelMetadata(),i={},n=new Set([...Object.keys(t.properties),...Object.keys(t.relations)]);for(let a of n){let o=this[a];o!=null&&a!=="author"&&a!=="timestamp"&&(i[a]=o)}return i}async innerUpdate(e=!0,t){let i=this.constructor,n=this._snapshot?new Set(this.changedFields()):null,a=i.getModelMetadata(),o=new Set([...Object.keys(a.properties),...Object.keys(a.relations)]),s=Object.entries(this);for(let[c,l]of s){if(!o.has(c)||n&&!n.has(c))continue;let u=a.relations[c];if(!(u&&(u.getter||u.target&&u.filter!==!1&&Object.entries(a.relations).some(([f,p])=>f!==c&&p.predicate===u.predicate)))&&l!=null){if(l?.action)switch(l.action){case"setter":await this.setRelationValues(c,l.value,t);break;case"adder":await this.addRelationValue(c,l.value,t);break;case"remover":await this.removeRelationValue(c,l.value,t);break;default:await this.setRelationValues(c,l.value,t);break}else if(Array.isArray(l))await this.setRelationValues(c,l,t);else if(l!=null&&l!==""&&e){if(this.getRelationOptions(c)||this.getPropertyMetadata(c)?.flag)continue;await this.setProperty(c,l,t)}}}}async get(e){let t;return e?"include"in e||"properties"in e?t=e:t={include:e}:t=void 0,await this.getData(t)}async delete(e){let t=this.constructor.getModelMetadata();if(Object.values(t.properties).some(n=>n.required||n.flag||n.initial!==void 0))await this._perspective.removeSubject(this,this._baseExpression,e);else try{let n=new Set;for(let s of Object.values(t.properties))s.predicate&&n.add(s.predicate);for(let s of Object.values(t.relations))s.predicate&&n.add(s.predicate);let o=(await this._perspective.get(new K({source:this._baseExpression}))).filter(s=>s.data.predicate&&n.has(s.data.predicate));o.length>0&&await this._perspective.removeLinks(o,e)}catch(n){console.warn(`delete(): failed to remove outgoing links for ${this._baseExpression}:`,n)}try{let n=await this._perspective.get(new K({target:this._baseExpression}));n.length>0&&await this._perspective.removeLinks(n,e)}catch(n){console.warn(`delete(): failed to clean up incoming links for ${this._baseExpression}:`,n)}}static async create(e,t={},i){let n=new this(e);if(Object.assign(n,t),i?.parent&&!i?.batchId){let a=await e.createBatch();await n.save(a);let o=wo(i.parent,this),s=new It({source:i.parent.id,predicate:o,target:n.id});return await e.add(s,"shared",a),await e.commitBatch(a),await n.get(),n}if(await n.save(i?.batchId),i?.parent){let a=wo(i.parent,this),o=new It({source:i.parent.id,predicate:a,target:n.id});await e.add(o,"shared",i?.batchId)}return n}static async update(e,t,i){let n=new this(e,t);return await n.get(),Object.assign(n,i),await n.save(),n}static async remove(e,t){return this.delete(e,t)}static async delete(e,t){await new this(e,t).delete()}static async register(e){await e.ensureSDNASubjectClass(this)}static async transaction(e,t){let i=await e.createBatch(),n=await t({batchId:i});return await e.commitBatch(i),n}static query(e,t){return new dp(e,this,t)}static fromJSONSchema(e,t){return I1(this,e,t)}};da.classNamesByClass=new WeakMap;function Ip(r){return r.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"")}function U1(r,e){let t=e.properties,i=Object.values(t).filter(o=>o.flag&&o.predicate&&o.initial);if(i.length>0){let o=i.map(s=>`triple(X, '${s.predicate}', '${s.initial}')`).join(`,
1085
- `);return`${r}(X) :-
1086
- ${o}.`}let n=Object.values(t).filter(o=>o.required&&o.predicate&&!o.flag);if(n.length>0){let o=n.map(s=>`triple(X, '${s.predicate}', _)`).join(`,
1087
- `);return`${r}(X) :-
1088
- ${o}.`}let a=Object.values(t).filter(o=>o.predicate).map(o=>o.predicate);if(e.relations)for(let o of Object.values(e.relations))o.predicate&&a.push(o.predicate);if(a.length>0){let o=a.map(s=>`triple(X, '${s}', _)`).join(` ;
1089
- `);return`${r}(X) :-
1090
- (${o}).`}return null}function j1(r,e){return e.flag||!e.predicate?null:`${`${r}_${Ip(e.name)}`}(X, Value) :- triple(X, '${e.predicate}', Value).`}function q1(r,e){if(!e.predicate)return null;let t=`${r}_${Ip(e.name)}`;return e.direction==="reverse"?`${t}(X, Values) :- findall(V, triple(V, '${e.predicate}', X), Values).`:`${t}(X, Values) :- findall(V, triple(X, '${e.predicate}', V), Values).`}function KO(r){let e=r.getModelMetadata(),t=Ip(e.className),i=[];i.push(`% ${e.className} \u2014 generated Prolog facts`);let n=U1(t,e);n&&(i.push(""),i.push("% Instance recognizer"),i.push(n));let a=Object.values(e.properties).map(s=>j1(t,s)).filter(s=>s!==null);a.length>0&&(i.push(""),i.push("% Field getters"),i.push(...a));let o=Object.values(e.relations).map(s=>q1(t,s)).filter(s=>s!==null);return o.length>0&&(i.push(""),i.push("% Relation getters"),i.push(...o)),i.join(`
1091
- `)}var JO=`
1092
- type AIModelLoadingStatus {
1093
- downloaded: Boolean!
1094
- loaded: Boolean!
1095
- model: String!
1096
- progress: Float!
1097
- status: String!
1098
- }
1099
-
1100
- type AIPromptExamples {
1101
- input: String!
1102
- output: String!
1103
- }
1104
-
1105
- input AIPromptExamplesInput {
1106
- input: String!
1107
- output: String!
1108
- }
1109
-
1110
- type AITask {
1111
- createdAt: String!
1112
- metaData: String
1113
- modelId: String!
1114
- name: String!
1115
- promptExamples: [AIPromptExamples!]!
1116
- systemPrompt: String!
1117
- taskId: String!
1118
- updatedAt: String!
1119
- }
1120
-
1121
- input AITaskInput {
1122
- metaData: String
1123
- modelId: String!
1124
- name: String!
1125
- promptExamples: [AIPromptExamplesInput!]!
1126
- systemPrompt: String!
1127
- }
1128
-
1129
- type Agent {
1130
- did: String!
1131
- directMessageLanguage: String
1132
- perspective: Perspective
1133
- }
1134
-
1135
- type AgentSignature {
1136
- publicKey: String!
1137
- signature: String!
1138
- }
1139
-
1140
- type AgentStatus {
1141
- did: String
1142
- didDocument: String
1143
- error: String
1144
- isInitialized: Boolean!
1145
- isUnlocked: Boolean!
1146
- }
1147
-
1148
- type Apps {
1149
- auth: AuthInfo!
1150
- requestId: String!
1151
- revoked: Boolean
1152
- token: String!
1153
- }
1154
-
1155
- type AuthInfo {
1156
- appDesc: String!
1157
- appIconPath: String
1158
- appName: String!
1159
- appUrl: String!
1160
- capabilities: [Capability!]!
1161
- }
1162
-
1163
- input AuthInfoInput {
1164
- appDesc: String!
1165
- appDomain: String!
1166
- appIconPath: String
1167
- appName: String!
1168
- appUrl: String
1169
- capabilities: [CapabilityInput!]
1170
- }
1171
-
1172
- type Capability {
1173
- can: [String!]!
1174
- with: Resource!
1175
- }
1176
-
1177
- input CapabilityInput {
1178
- can: [String!]!
1179
- with: ResourceInput!
1180
- }
1181
-
1182
- type ComputeLogEntry {
1183
- cost: Float!
1184
- creditsAfter: Float!
1185
- id: Float!
1186
- operation: String!
1187
- summary: String
1188
- timestamp: String!
1189
- userEmail: String!
1190
- }
1191
-
1192
- scalar DateTime
1193
-
1194
- type EntanglementProof {
1195
- deviceKey: String!
1196
- deviceKeySignedByDid: String!
1197
- deviceKeyType: String!
1198
- did: String!
1199
- didSignedByDeviceKey: String
1200
- didSigningKeyId: String!
1201
- }
1202
-
1203
- input EntanglementProofInput {
1204
- deviceKey: String!
1205
- deviceKeySignedByDid: String!
1206
- deviceKeyType: String!
1207
- did: String!
1208
- didSignedByDeviceKey: String!
1209
- didSigningKeyId: String!
1210
- }
1211
-
1212
- type ExceptionInfo {
1213
- addon: String
1214
- message: String!
1215
- title: String!
1216
- type: Int!
1217
- }
1218
-
1219
- type ExpressionProof {
1220
- invalid: Boolean
1221
- key: String
1222
- signature: String
1223
- valid: Boolean
1224
- }
1225
-
1226
- input ExpressionProofInput {
1227
- invalid: Boolean
1228
- key: String
1229
- signature: String
1230
- valid: Boolean
1231
- }
1232
-
1233
- type ExpressionRendered {
1234
- author: String!
1235
- data: String!
1236
- icon: Icon!
1237
- language: LanguageRef!
1238
- proof: ExpressionProof!
1239
- timestamp: String!
1240
- }
1241
-
1242
- type HostingUserInfo {
1243
- email: String!
1244
- freeAccess: Boolean!
1245
- hotWalletAddress: String
1246
- remainingCredits: String!
1247
- }
1248
-
1249
- type Icon {
1250
- code: String!
1251
- }
1252
-
1253
- input InteractionCall {
1254
- name: String!
1255
- parametersStringified: String!
1256
- }
1257
-
1258
- type InteractionMeta {
1259
- label: String!
1260
- name: String!
1261
- parameters: [InteractionParameter!]!
1262
- }
1263
-
1264
- type InteractionParameter {
1265
- name: String!
1266
- type: String!
1267
- }
1268
-
1269
- type LanguageHandle {
1270
- address: String!
1271
- constructorIcon: Icon
1272
- icon: Icon
1273
- name: String!
1274
- settings: String
1275
- settingsIcon: Icon
1276
- }
1277
-
1278
- type LanguageMeta {
1279
- address: String!
1280
- author: String!
1281
- description: String
1282
- name: String!
1283
- possibleTemplateParams: [String!]
1284
- sourceCodeLink: String
1285
- templateAppliedParams: String
1286
- templateSourceLanguageAddress: String
1287
- templated: Boolean
1288
- }
1289
-
1290
- input LanguageMetaInput {
1291
- description: String = ""
1292
- name: String!
1293
- possibleTemplateParams: [String!]
1294
- sourceCodeLink: String
1295
- }
1296
-
1297
- type LanguageRef {
1298
- address: String!
1299
- name: String!
1300
- }
1301
-
1302
- type Link {
1303
- predicate: String
1304
- source: String!
1305
- target: String!
1306
- }
1307
-
1308
- type LinkExpression {
1309
- author: String!
1310
- data: Link!
1311
- proof: ExpressionProof!
1312
- status: String
1313
- timestamp: String!
1314
- }
1315
-
1316
- input LinkExpressionInput {
1317
- author: String!
1318
- data: LinkInput!
1319
- proof: ExpressionProofInput!
1320
- status: String = "shared"
1321
- timestamp: String!
1322
- }
1323
-
1324
- type LinkExpressionMutations {
1325
- additions: [LinkExpression!]!
1326
- removals: [LinkExpression!]!
1327
- }
1328
-
1329
- type LinkExpressionUpdated {
1330
- newLink: LinkExpression!
1331
- oldLink: LinkExpression!
1332
- }
1333
-
1334
- input LinkInput {
1335
- predicate: String
1336
- source: String!
1337
- target: String!
1338
- }
1339
-
1340
- input LinkMutations {
1341
- additions: [LinkInput!]!
1342
- removals: [LinkExpressionInput!]!
1343
- }
1344
-
1345
- input LinkQuery {
1346
- fromDate: DateTime
1347
- limit: Float
1348
- predicate: String
1349
- source: String
1350
- target: String
1351
- untilDate: DateTime
1352
- }
1353
-
1354
- type LocalModel {
1355
- fileName: String!
1356
- huggingfaceRepo: String
1357
- revision: String
1358
- tokenizerSource: TokenizerSource
1359
- }
1360
-
1361
- input LocalModelInput {
1362
- fileName: String!
1363
- huggingfaceRepo: String
1364
- revision: String
1365
- tokenizerSource: TokenizerSourceInput
1366
- }
1367
-
1368
- type Model {
1369
- api: ModelApi
1370
- id: String!
1371
- local: LocalModel
1372
- modelType: String!
1373
- name: String!
1374
- }
1375
-
1376
- type ModelApi {
1377
- apiKey: String!
1378
- apiType: String!
1379
- baseUrl: String!
1380
- model: String!
1381
- }
1382
-
1383
- input ModelApiInput {
1384
- apiKey: String!
1385
- apiType: String!
1386
- baseUrl: String!
1387
- model: String!
1388
- }
1389
-
1390
- input ModelInput {
1391
- api: ModelApiInput
1392
- local: LocalModelInput
1393
- modelType: String!
1394
- name: String!
1395
- }
1396
-
1397
- type Mutation {
1398
- addTrustedAgents(agents: [String!]!): [String!]!
1399
- agentAddEntanglementProofs(proofs: [EntanglementProofInput!]!): [EntanglementProof!]!
1400
- agentDeleteEntanglementProofs(proofs: [EntanglementProofInput!]!): [EntanglementProof!]!
1401
- agentEntanglementProofPreFlight(deviceKey: String!, deviceKeyType: String!): EntanglementProof!
1402
- agentGenerate(passphrase: String!): AgentStatus!
1403
- agentGenerateJwt(rand: String!, requestId: String!): String!
1404
- agentImport(did: String!, didDocument: String!, keystore: String!, passphrase: String!): AgentStatus!
1405
- agentLock(passphrase: String!): AgentStatus!
1406
- agentPermitCapability(auth: String!): String!
1407
- agentRemoveApp(requestId: String!): [Apps!]!
1408
- agentRequestCapability(authInfo: AuthInfoInput!): String!
1409
- agentRevokeToken(requestId: String!): [Apps!]!
1410
- agentSignMessage(message: String!): AgentSignature!
1411
- agentUnlock(holochain: Boolean!, passphrase: String!): AgentStatus!
1412
- agentUpdateDirectMessageLanguage(directMessageLanguage: String!): Agent!
1413
- agentUpdatePublicPerspective(perspective: PerspectiveInput!): Agent!
1414
- aiAddModel(model: ModelInput!): String!
1415
- aiAddTask(task: AITaskInput!): AITask!
1416
- aiCloseTranscriptionStream(streamId: String!): String!
1417
- aiEmbed(modelId: String!, text: String!): String!
1418
- aiFeedTranscriptionStream(audio: [Float!]!, streamIds: [String!]!): String!
1419
- aiOpenTranscriptionStream(modelId: String!, params: VoiceActivityParamsInput): String!
1420
- aiPrompt(prompt: String!, taskId: String!): String!
1421
- aiRemoveModel(modelId: String!): Boolean!
1422
- aiRemoveTask(taskId: String!): AITask!
1423
- aiSetDefaultModel(modelId: String!, modelType: String!): Boolean!
1424
- aiUpdateModel(model: ModelInput!, modelId: String!): Boolean!
1425
- aiUpdateTask(task: AITaskInput!, taskId: String!): AITask!
1426
- deleteTrustedAgents(agents: [String!]!): [String!]!
1427
- expressionCreate(content: String!, languageAddress: String!): String!
1428
- expressionInteract(interactionCall: InteractionCall!, url: String!): String
1429
- languageApplyTemplateAndPublish(sourceLanguageHash: String!, templateData: String!): LanguageRef!
1430
- languagePublish(languageMeta: LanguageMetaInput!, languagePath: String!): LanguageMeta!
1431
- languageRemove(address: String!): Boolean!
1432
- languageWriteSettings(languageAddress: String!, settings: String!): Boolean!
1433
- neighbourhoodJoinFromUrl(url: String!): PerspectiveHandle!
1434
- neighbourhoodPublishFromPerspective(linkLanguage: String!, meta: PerspectiveInput!, perspectiveUUID: String!): String!
1435
- neighbourhoodSendBroadcast(loopback: Boolean, payload: PerspectiveInput!, perspectiveUUID: String!): Boolean!
1436
- neighbourhoodSendBroadcastU(loopback: Boolean, payload: PerspectiveUnsignedInput!, perspectiveUUID: String!): Boolean!
1437
- neighbourhoodSendSignal(payload: PerspectiveInput!, perspectiveUUID: String!, remoteAgentDid: String!): Boolean!
1438
- neighbourhoodSendSignalU(payload: PerspectiveUnsignedInput!, perspectiveUUID: String!, remoteAgentDid: String!): Boolean!
1439
- neighbourhoodSetOnlineStatus(perspectiveUUID: String!, status: PerspectiveInput!): Boolean!
1440
- neighbourhoodSetOnlineStatusU(perspectiveUUID: String!, status: PerspectiveUnsignedInput!): Boolean!
1441
- perspectiveAdd(name: String!): PerspectiveHandle!
1442
- perspectiveAddLink(batchId: String, link: LinkInput!, status: String = "shared", uuid: String!): LinkExpression!
1443
- perspectiveAddLinkExpression(batchId: String, link: LinkExpressionInput!, status: String = "shared", uuid: String!): LinkExpression!
1444
- perspectiveAddLinks(batchId: String, links: [LinkInput!]!, status: String = "shared", uuid: String!): [LinkExpression!]!
1445
- perspectiveAddSdna(name: String!, sdnaCode: String, sdnaType: String!, shaclJson: String, uuid: String!): Boolean!
1446
- perspectiveCommitBatch(batchId: String!, uuid: String!): LinkExpressionMutations!
1447
- perspectiveCreateBatch(uuid: String!): String!
1448
- perspectiveCreateSubject(batchId: String, expressionAddress: String!, initialValues: String, subjectClass: String!, uuid: String!): Boolean!
1449
- perspectiveDisposeQuerySubscription(subscriptionId: String!, uuid: String!): Boolean!
1450
- perspectiveExecuteCommands(batchId: String, commands: String!, expression: String!, parameters: String, uuid: String!): Boolean!
1451
- perspectiveGetSubjectData(expressionAddress: String!, subjectClass: String!, uuid: String!): String!
1452
- perspectiveKeepAliveQuery(subscriptionId: String!, uuid: String!): Boolean!
1453
- perspectiveLinkMutations(mutations: LinkMutations!, status: String, uuid: String!): LinkExpressionMutations!
1454
- perspectivePublishSnapshot(uuid: String!): String
1455
- perspectiveRemove(uuid: String!): Boolean!
1456
- perspectiveRemoveLink(batchId: String, link: LinkExpressionInput!, uuid: String!): Boolean!
1457
- perspectiveRemoveLinks(batchId: String, links: [LinkExpressionInput!]!, uuid: String!): [LinkExpression!]!
1458
- perspectiveSubscribeQuery(query: String!, uuid: String!): QuerySubscription!
1459
- perspectiveUpdate(name: String!, uuid: String!): PerspectiveHandle
1460
- perspectiveUpdateLink(batchId: String, newLink: LinkInput!, oldLink: LinkExpressionInput!, uuid: String!): LinkExpression!
1461
- runtimeAddFriends(dids: [String!]!): [String!]!
1462
- runtimeAddKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
1463
- runtimeCreateUser(appInfo: AuthInfoInput, email: String!, password: String!): UserCreationResult!
1464
- runtimeEmailTestClearCodes: Boolean!
1465
- runtimeEmailTestGetCode(email: String!): String
1466
- runtimeEmailTestModeDisable: Boolean!
1467
- runtimeEmailTestModeEnable: Boolean!
1468
- runtimeEmailTestSetExpiry(email: String!, expiresAt: Float!, verificationType: String!): Boolean!
1469
- runtimeExportDb(filePath: String!): Boolean!
1470
- runtimeExportPerspective(filePath: String!, perspectiveUuid: String!): Boolean!
1471
- runtimeFriendSendMessage(did: String!, message: PerspectiveInput!): Boolean!
1472
- runtimeGrantNotification(id: String!): Boolean!
1473
- runtimeHcAddAgentInfos(agentInfos: String!): Boolean!
1474
- runtimeImportDb(filePath: String!): Boolean!
1475
- runtimeImportPerspective(filePath: String!): Boolean!
1476
- runtimeLoginUser(email: String!, password: String!): String!
1477
- runtimeOpenLink(url: String!): Boolean!
1478
- runtimeQuit: Boolean!
1479
- runtimeReinstallUnytDna: PaymentRequestResult!
1480
- runtimeRemoveFriends(dids: [String!]!): [String!]!
1481
- runtimeRemoveKnownLinkLanguageTemplates(addresses: [String!]!): [String!]!
1482
- runtimeRemoveNotification(id: String!): Boolean!
1483
- runtimeRequestInstallNotification(notification: NotificationInput!): String!
1484
- runtimeRequestLoginVerification(appInfo: AuthInfoInput, email: String!): VerificationRequestResult!
1485
- runtimeRequestPayment(amountHOT: String!): PaymentRequestResult!
1486
- runtimeRestartHolochain: Boolean!
1487
- runtimeSendHot(amount: String!, recipient: String!): PaymentRequestResult!
1488
- runtimeSetFreeHostingEnabled(enabled: Boolean!): Boolean!
1489
- runtimeSetHotWalletAddress(address: String!): Boolean!
1490
- runtimeSetMultiUserEnabled(enabled: Boolean!): Boolean!
1491
- runtimeSetStatus(status: PerspectiveInput!): Boolean!
1492
- runtimeSetUnytMembraneProof(proof: String!): PaymentRequestResult!
1493
- runtimeSetUserCredits(amount: Float!, email: String!): Boolean!
1494
- runtimeSetUserFreeAccess(email: String!, enabled: Boolean!): Boolean!
1495
- runtimeTestEmail(to: String!): Boolean!
1496
- runtimeUpdateNotification(id: String!, notification: NotificationInput!): Boolean!
1497
- runtimeVerifyEmailCode(code: String!, email: String!, verificationType: String!): String!
1498
- }
1499
-
1500
- type Neighbourhood {
1501
- linkLanguage: String!
1502
- meta: Perspective!
1503
- }
1504
-
1505
- type NeighbourhoodExpression {
1506
- author: String!
1507
- data: Neighbourhood!
1508
- proof: ExpressionProof!
1509
- timestamp: String!
1510
- }
1511
-
1512
- type Notification {
1513
- appIconPath: String!
1514
- appName: String!
1515
- appUrl: String!
1516
- description: String!
1517
- granted: Boolean!
1518
- id: String!
1519
- perspectiveIds: [String!]!
1520
- trigger: String!
1521
- webhookAuth: String!
1522
- webhookUrl: String!
1523
- }
1524
-
1525
- input NotificationInput {
1526
- appIconPath: String!
1527
- appName: String!
1528
- appUrl: String!
1529
- description: String!
1530
- perspectiveIds: [String!]!
1531
- trigger: String!
1532
- webhookAuth: String!
1533
- webhookUrl: String!
1534
- }
1535
-
1536
- type OnlineAgent {
1537
- did: String!
1538
- status: PerspectiveExpression!
1539
- }
1540
-
1541
- type PaymentRequestResult {
1542
- message: String!
1543
- success: Boolean!
1544
- }
1545
-
1546
- type Perspective {
1547
- links: [LinkExpression!]!
1548
- }
1549
-
1550
- type PerspectiveExpression {
1551
- author: String!
1552
- data: Perspective!
1553
- proof: ExpressionProof!
1554
- timestamp: String!
1555
- }
1556
-
1557
- type PerspectiveHandle {
1558
- name: String!
1559
- neighbourhood: NeighbourhoodExpression
1560
- owners: [String!]
1561
- sharedUrl: String
1562
- state: String!
1563
- uuid: String!
1564
- }
1565
-
1566
- input PerspectiveInput {
1567
- links: [LinkExpressionInput!]!
1568
- }
1569
-
1570
- input PerspectiveUnsignedInput {
1571
- links: [LinkInput!] = []
1572
- }
1573
-
1574
- type Query {
1575
- agent: Agent!
1576
- agentByDID(did: String!): Agent
1577
- agentGetApps: [Apps!]!
1578
- agentGetEntanglementProofs: [EntanglementProof!]!
1579
- agentIsLocked: Boolean!
1580
- agentStatus: AgentStatus!
1581
- aiGetDefaultModel(modelType: String!): Model!
1582
- aiGetModels: [Model!]!
1583
- aiModelLoadingStatus(model: String!): AIModelLoadingStatus!
1584
- aiTasks: [AITask!]!
1585
- expression(url: String!): ExpressionRendered
1586
- expressionInteractions(url: String!): [InteractionMeta!]!
1587
- expressionMany(urls: [String!]!): [ExpressionRendered]!
1588
- expressionRaw(url: String!): String
1589
- getTrustedAgents: [String!]!
1590
- language(address: String!): LanguageHandle
1591
- languageMeta(address: String!): LanguageMeta!
1592
- languageSource(address: String!): String!
1593
- languages(filter: String): [LanguageHandle!]!
1594
- neighbourhoodHasTelepresenceAdapter(perspectiveUUID: String!): Boolean!
1595
- neighbourhoodOnlineAgents(perspectiveUUID: String!): [OnlineAgent!]!
1596
- neighbourhoodOtherAgents(perspectiveUUID: String!): [String!]!
1597
- perspective(uuid: String!): PerspectiveHandle
1598
- perspectiveQueryLinks(query: LinkQuery!, uuid: String!): [LinkExpression!]
1599
- perspectiveQueryProlog(query: String!, uuid: String!): String!
1600
- perspectiveSnapshot(uuid: String!): Perspective
1601
- perspectives: [PerspectiveHandle!]!
1602
- runtimeComputeLog(limit: Float, since: String, userEmail: String): [ComputeLogEntry!]!
1603
- runtimeFreeHostingEnabled: Boolean!
1604
- runtimeFriendStatus(did: String!): PerspectiveExpression
1605
- runtimeFriends: [String!]!
1606
- runtimeGetNetworkMetrics: String!
1607
- runtimeHcAgentInfos: String!
1608
- runtimeHostingUserInfo: HostingUserInfo!
1609
- runtimeHotAgentPubkey: String!
1610
- runtimeHotWalletBalance: String!
1611
- runtimeHotWalletHistory(page: Float, perPage: Float): String!
1612
- runtimeInfo: RuntimeInfo!
1613
- runtimeKnownLinkLanguageTemplates: [String!]!
1614
- runtimeListUsers: [UserStatistics!]!
1615
- runtimeMessageInbox(filter: String): [PerspectiveExpression!]!
1616
- runtimeMessageOutbox(filter: String): [SentMessage!]!
1617
- runtimeMultiUserEnabled: Boolean!
1618
- runtimeNotifications: [Notification!]!
1619
- runtimeUnytAgentKey: String!
1620
- runtimeUnytVersionInfo: String!
1621
- runtimeVerifyStringSignedByDid(data: String!, did: String!, didSigningKeyId: String!, signedData: String!): Boolean!
1622
- }
1623
-
1624
- type QuerySubscription {
1625
- result: String!
1626
- subscriptionId: String!
1627
- }
1628
-
1629
- type Resource {
1630
- domain: String!
1631
- pointers: [String!]!
1632
- }
1633
-
1634
- input ResourceInput {
1635
- domain: String!
1636
- pointers: [String!]!
1637
- }
1638
-
1639
- type RuntimeInfo {
1640
- ad4mExecutorVersion: String!
1641
- isInitialized: Boolean!
1642
- isUnlocked: Boolean!
1643
- }
1644
-
1645
- type SentMessage {
1646
- message: PerspectiveExpression!
1647
- recipient: String!
1648
- }
1649
-
1650
- type Subscription {
1651
- agentAppsChanged: [Apps!]
1652
- agentStatusChanged: AgentStatus
1653
- agentUpdated: Agent
1654
- aiTranscriptionText(streamId: String!): String!
1655
- exceptionOccurred: ExceptionInfo
1656
- neighbourhoodSignal(perspectiveUUID: String!): PerspectiveExpression
1657
- perspectiveAdded: PerspectiveHandle
1658
- perspectiveLinkAdded(uuid: String!): LinkExpression
1659
- perspectiveLinkRemoved(uuid: String!): LinkExpression
1660
- perspectiveLinkUpdated(uuid: String!): LinkExpressionUpdated
1661
- perspectiveQuerySubscription(subscriptionId: String!): String!
1662
- perspectiveRemoved: String
1663
- perspectiveSyncStateChange(uuid: String!): String!
1664
- perspectiveUpdated: PerspectiveHandle
1665
- runtimeMessageReceived: PerspectiveExpression
1666
- runtimeNotificationTriggered: TriggeredNotification
1667
- }
1668
-
1669
- type TokenizerSource {
1670
- fileName: String!
1671
- repo: String!
1672
- revision: String!
1673
- }
1674
-
1675
- input TokenizerSourceInput {
1676
- fileName: String!
1677
- repo: String!
1678
- revision: String!
1679
- }
1680
-
1681
- type TriggeredNotification {
1682
- notification: Notification!
1683
- perspectiveId: String!
1684
- triggerMatch: String!
1685
- }
1686
-
1687
- type UserCreationResult {
1688
- did: String!
1689
- error: String
1690
- success: Boolean!
1691
- }
1692
-
1693
- type UserStatistics {
1694
- did: String!
1695
- email: String!
1696
- freeAccess: Boolean!
1697
- hotWalletAddress: String
1698
- lastSeen: String
1699
- perspectiveCount: Int!
1700
- remainingCredits: String!
1701
- }
1702
-
1703
- type VerificationRequestResult {
1704
- isExistingUser: Boolean!
1705
- message: String!
1706
- requiresPassword: Boolean!
1707
- success: Boolean!
1708
- }
1709
-
1710
- input VoiceActivityParamsInput {
1711
- endThreshold: Float
1712
- endWindow: Float
1713
- startThreshold: Float
1714
- startWindow: Float
1715
- timeBeforeSpeech: Float
1716
- }
1717
- `,A=function(r,e,t,i){var n=arguments.length,a=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,i);else for(var s=r.length-1;s>=0;s--)(o=r[s])&&(a=(n<3?o(a):n>3?o(e,t,a):o(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},g=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},H=function(r,e){return function(t,i){e(t,i,r)}},Wo=new hi;Wo.author="did:ad4m:test";Wo.timestamp=Date.now();Wo.data={source:"root",target:"neighbourhood://Qm12345"};Wo.proof={signature:"",key:"",valid:!0};var ci=new an;ci.author="did:ad4m:test";ci.timestamp=Date.now().toString();ci.proof=new Dr("","");ci.data=new Sr([Wo]);var Mc=class{};A([w(),g("design:type",String)],Mc.prototype,"recipient",void 0);A([w(),g("design:type",an)],Mc.prototype,"message",void 0);Mc=A([J()],Mc);var fa=class{};A([w(),g("design:type",String)],fa.prototype,"ad4mExecutorVersion",void 0);A([w(),g("design:type",Boolean)],fa.prototype,"isInitialized",void 0);A([w(),g("design:type",Boolean)],fa.prototype,"isUnlocked",void 0);fa=A([J()],fa);var fn=class{};A([w(),g("design:type",String)],fn.prototype,"title",void 0);A([w(),g("design:type",String)],fn.prototype,"message",void 0);A([w(),g("design:type",String)],fn.prototype,"type",void 0);A([w(),g("design:type",String)],fn.prototype,"addon",void 0);fn=A([J()],fn);var Jt=class{};A([w(),g("design:type",String)],Jt.prototype,"description",void 0);A([w(),g("design:type",String)],Jt.prototype,"appName",void 0);A([w(),g("design:type",String)],Jt.prototype,"appUrl",void 0);A([w(),g("design:type",String)],Jt.prototype,"appIconPath",void 0);A([w(),g("design:type",String)],Jt.prototype,"trigger",void 0);A([w(),g("design:type",Array)],Jt.prototype,"perspectiveIds",void 0);A([w(),g("design:type",String)],Jt.prototype,"webhookUrl",void 0);A([w(),g("design:type",String)],Jt.prototype,"webhookAuth",void 0);Jt=A([Xe()],Jt);var Ft=class{};A([w(),g("design:type",String)],Ft.prototype,"id",void 0);A([w(),g("design:type",Boolean)],Ft.prototype,"granted",void 0);A([w(),g("design:type",String)],Ft.prototype,"description",void 0);A([w(),g("design:type",String)],Ft.prototype,"appName",void 0);A([w(),g("design:type",String)],Ft.prototype,"appUrl",void 0);A([w(),g("design:type",String)],Ft.prototype,"appIconPath",void 0);A([w(),g("design:type",String)],Ft.prototype,"trigger",void 0);A([w(),g("design:type",Array)],Ft.prototype,"perspectiveIds",void 0);A([w(),g("design:type",String)],Ft.prototype,"webhookUrl",void 0);A([w(),g("design:type",String)],Ft.prototype,"webhookAuth",void 0);Ft=A([J()],Ft);var ha=class{};A([w(),g("design:type",Ft)],ha.prototype,"notification",void 0);A([w(),g("design:type",String)],ha.prototype,"perspectiveId",void 0);A([w(),g("design:type",String)],ha.prototype,"triggerMatch",void 0);ha=A([J()],ha);var Ye=class{};A([w(),g("design:type",Number)],Ye.prototype,"total",void 0);A([w(),g("design:type",Number)],Ye.prototype,"imported",void 0);A([w(),g("design:type",Number)],Ye.prototype,"failed",void 0);A([w(),g("design:type",Number)],Ye.prototype,"omitted",void 0);A([w(),g("design:type",Array)],Ye.prototype,"errors",void 0);Ye=A([J()],Ye);var Mt=class{};A([w(),g("design:type",Ye)],Mt.prototype,"perspectives",void 0);A([w(),g("design:type",Ye)],Mt.prototype,"links",void 0);A([w(),g("design:type",Ye)],Mt.prototype,"expressions",void 0);A([w(),g("design:type",Ye)],Mt.prototype,"perspectiveDiffs",void 0);A([w(),g("design:type",Ye)],Mt.prototype,"notifications",void 0);A([w(),g("design:type",Ye)],Mt.prototype,"models",void 0);A([w(),g("design:type",Ye)],Mt.prototype,"defaultModels",void 0);A([w(),g("design:type",Ye)],Mt.prototype,"tasks",void 0);A([w(),g("design:type",Ye)],Mt.prototype,"friends",void 0);A([w(),g("design:type",Ye)],Mt.prototype,"trustedAgents",void 0);A([w(),g("design:type",Ye)],Mt.prototype,"knownLinkLanguages",void 0);Mt=A([J()],Mt);var Mr=class{};A([w(),g("design:type",String)],Mr.prototype,"email",void 0);A([w(),g("design:type",String)],Mr.prototype,"did",void 0);A([w(),g("design:type",String)],Mr.prototype,"lastSeen",void 0);A([w(),g("design:type",Number)],Mr.prototype,"perspectiveCount",void 0);A([w(),g("design:type",String)],Mr.prototype,"remainingCredits",void 0);A([w(),g("design:type",Boolean)],Mr.prototype,"freeAccess",void 0);A([w(),g("design:type",String)],Mr.prototype,"hotWalletAddress",void 0);Mr=A([J()],Mr);var hn=class{};A([w(),g("design:type",Boolean)],hn.prototype,"success",void 0);A([w(),g("design:type",String)],hn.prototype,"message",void 0);A([w(),g("design:type",Boolean)],hn.prototype,"requiresPassword",void 0);A([w(),g("design:type",Boolean)],hn.prototype,"isExistingUser",void 0);hn=A([J()],hn);var wi=class{constructor(e,t,i,n=!1){this.email=e,this.remainingCredits=t,this.hotWalletAddress=i,this.freeAccess=n}};A([w(),g("design:type",String)],wi.prototype,"email",void 0);A([w(),g("design:type",String)],wi.prototype,"remainingCredits",void 0);A([w(),g("design:type",String)],wi.prototype,"hotWalletAddress",void 0);A([w(),g("design:type",Boolean)],wi.prototype,"freeAccess",void 0);wi=A([J(),g("design:paramtypes",[String,String,String,Boolean])],wi);var Gt=class{constructor(e,t){this.success=e,this.message=t}};A([w(),g("design:type",Boolean)],Gt.prototype,"success",void 0);A([w(),g("design:type",String)],Gt.prototype,"message",void 0);Gt=A([J(),g("design:paramtypes",[Boolean,String])],Gt);var Ur=class{constructor(e,t,i,n,a,o,s){this.id=e,this.userEmail=t,this.timestamp=i,this.operation=n,this.cost=a,this.creditsAfter=o,this.summary=s}};A([w(),g("design:type",Number)],Ur.prototype,"id",void 0);A([w(),g("design:type",String)],Ur.prototype,"userEmail",void 0);A([w(),g("design:type",String)],Ur.prototype,"timestamp",void 0);A([w(),g("design:type",String)],Ur.prototype,"operation",void 0);A([w(),g("design:type",String)],Ur.prototype,"summary",void 0);A([w(),g("design:type",Number)],Ur.prototype,"cost",void 0);A([w(),g("design:type",Number)],Ur.prototype,"creditsAfter",void 0);Ur=A([J(),g("design:paramtypes",[Number,String,String,String,Number,Number,String])],Ur);var U=class{runtimeQuit(){return!0}runtimeOpenLink(e){return!0}runtimeInfo(){return{ad4mExecutorVersion:"x.x.x",isInitialized:!0,isUnlocked:!0}}addTrustedAgents(e){return e}deleteTrustedAgents(e){return[]}getTrustedAgents(){return["agentPubKey"]}runtimeKnownLinkLanguageTemplates(){return["Qm12345abcdef"]}runtimeAddKnownLinkLanguageTemplates(e){return e}runtimeRemoveKnownLinkLanguageTemplates(e){return[]}runtimeFriends(){return["did:test:friend"]}runtimeAddFriends(e){return e}runtimeRemoveFriends(e){return[]}runtimeHcAgentInfos(){return JSON.stringify([{agent:{type:"Buffer",data:[9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186]},signature:{type:"Buffer",data:[195,143,170,36,234,123,255,85,188,138,124,2,91,18,53,231,44,41,240,8,80,131,100,150,165,125,146,90,17,200,190,129,114,211,11,146,150,128,198,199,79,118,157,101,194,68,58,245,98,182,79,139,140,41,143,129,8,136,87,77,180,231,218,11]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,9,191,231,58,255,107,202,55,206,57,9,103,17,34,206,195,207,114,5,73,77,198,56,136,17,227,242,231,194,135,128,48,170,189,119,186,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,101,83,52,86,112,54,109,118,80,48,122,116,85,101,104,114,117,113,89,52,102,66,53,101,69,98,121,48,69,66,100,89,84,50,95,67,48,69,112,77,111,76,111,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,104,189,50,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38]},signature:{type:"Buffer",data:[233,192,38,3,59,248,124,231,57,255,40,154,50,60,119,252,68,198,154,109,175,155,106,217,211,155,109,223,249,91,221,210,17,132,72,230,11,230,247,119,72,244,145,91,75,7,67,5,130,151,44,231,52,220,28,154,212,82,58,90,203,211,236,4]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,98,187,145,48,115,209,94,143,31,153,102,69,138,29,133,213,34,52,39,164,157,139,178,111,23,33,118,250,28,155,78,246,128,49,179,38,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,55,101,77,106,48,73,83,72,56,56,81,56,45,89,51,74,89,70,53,76,72,57,83,54,68,119,71,73,49,88,45,115,87,53,68,104,66,87,121,71,119,78,115,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,103,45,197,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109]},signature:{type:"Buffer",data:[88,189,229,122,44,171,194,156,90,79,148,49,207,224,34,199,219,88,24,243,103,127,123,41,87,171,127,92,6,216,198,171,26,226,237,217,122,78,98,146,55,255,68,240,202,83,58,140,147,185,3,66,15,216,210,22,99,197,73,234,120,17,74,1]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,181,101,115,45,214,127,198,153,159,184,30,87,67,224,208,184,203,176,130,158,236,127,153,125,243,183,188,167,154,25,118,254,101,145,210,109,164,117,114,108,115,145,217,99,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,114,70,71,83,100,113,104,101,68,107,70,70,56,69,102,109,45,69,116,55,119,81,101,120,83,88,55,65,112,69,51,89,86,99,45,120,102,52,104,106,77,115,77,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,57,50,46,49,54,56,46,49,55,56,46,54,48,47,112,47,55,55,52,52,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,23,220,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}},{agent:{type:"Buffer",data:[3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56]},signature:{type:"Buffer",data:[129,12,55,104,239,121,138,2,86,106,136,51,219,79,170,8,195,69,81,188,225,192,247,196,54,39,164,110,75,39,240,56,245,189,154,77,72,11,97,250,202,149,242,97,128,28,47,164,236,104,136,82,212,246,44,143,132,119,255,135,112,11,20,13]},agent_info:{type:"Buffer",data:[134,165,115,112,97,99,101,196,36,203,165,212,173,24,215,165,196,25,145,248,113,246,139,205,182,241,138,57,0,26,8,217,179,23,126,59,136,128,213,110,225,173,72,197,95,165,97,103,101,110,116,196,36,3,171,237,107,186,245,165,47,237,235,211,49,245,62,113,53,255,252,223,226,75,118,148,187,23,53,70,174,160,184,64,63,94,210,227,56,164,117,114,108,115,145,217,97,107,105,116,115,117,110,101,45,112,114,111,120,121,58,47,47,104,121,112,115,86,121,103,117,80,84,115,53,118,73,80,65,102,97,112,90,88,113,117,84,115,79,80,100,67,81,79,79,117,103,57,51,82,103,106,95,114,85,73,47,107,105,116,115,117,110,101,45,113,117,105,99,47,104,47,49,54,53,46,50,50,46,51,50,46,49,49,47,112,47,53,55,55,57,47,45,45,172,115,105,103,110,101,100,95,97,116,95,109,115,207,0,0,1,123,233,113,188,123,176,101,120,112,105,114,101,115,95,97,102,116,101,114,95,109,115,206,0,18,79,128,169,109,101,116,97,95,105,110,102,111,196,34,129,187,100,104,116,95,115,116,111,114,97,103,101,95,97,114,99,95,104,97,108,102,95,108,101,110,103,116,104,206,128,0,0,1]}}])}runtimeGetNetworkMetrics(){return JSON.stringify({metrics:{},stats:{}})}runtimeRestartHolochain(){return!0}runtimeHcAddAgentInfos(e){return!0}runtimeVerifyStringSignedByDid(e,t,i,n){return!0}runtimeSetStatus(e){return!0}runtimeFriendStatus(e){return ci}runtimeFriendSendMessage(e,t){return!0}runtimeMessageInbox(e){return[ci]}runtimeMessageOutbox(e){return[{recipient:"did:test:recipient",message:ci}]}runtimeMessageReceived(){return ci}exceptionOccurred(){return{title:"Test title",message:"Test message",type:lp.LanguageIsNotLoaded}}runtimeRequestInstallNotification(e){return"new-notification-id"}runtimeNotifications(){return[{id:"test-id",granted:!1,description:"Test description",appName:"Test app name",appUrl:"https://example.com",appIconPath:"https://fluxsocial.io/favicon",trigger:"triple(X, ad4m://has_type, flux://message)",perspectiveIds:["u983ud-jdhh38d"],webhookUrl:"https://example.com/webhook",webhookAuth:"test-auth"}]}runtimeUpdateNotification(e,t){return!0}runtimeRemoveNotification(e){return!0}runtimeGrantNotification(e){return!0}runtimeNotificationTriggered(){return{perspectiveId:"test-perspective-id",triggerMatch:"test-trigger-match",notification:{id:"test-id",granted:!1,description:"Test description",appName:"Test app name",appUrl:"https://example.com",appIconPath:"https://fluxsocial.io/favicon",trigger:"triple(X, ad4m://has_type, flux://message)",perspectiveIds:["u983ud-jdhh38d"],webhookUrl:"https://example.com/webhook",webhookAuth:"test-auth"}}}runtimeExportDb(e){return!0}runtimeImportDb(e){return!0}runtimeExportPerspective(e,t){return!0}runtimeImportPerspective(e){return!0}runtimeMultiUserEnabled(){return!1}runtimeSetMultiUserEnabled(e){return e}runtimeFreeHostingEnabled(){return!0}runtimeSetFreeHostingEnabled(e){return e}runtimeListUsers(){return[{email:"test@example.com",did:"did:key:test123",lastSeen:new Date().toISOString(),perspectiveCount:5,remainingCredits:"0",freeAccess:!1}]}runtimeRequestLoginVerification(e,t){return{success:!0,message:"Verification email sent",requiresPassword:!1,isExistingUser:!0}}runtimeVerifyEmailCode(e,t,i){return"test-jwt-token-from-email-verification"}runtimeTestEmail(e){return!0}runtimeCreateUser(e,t,i){return new on("did:key:test123",!0)}runtimeLoginUser(e,t){return"test-jwt-token-from-password-login"}runtimeEmailTestModeEnable(){return!0}runtimeEmailTestModeDisable(){return!0}runtimeEmailTestGetCode(e){return"123456"}runtimeEmailTestClearCodes(){return!0}runtimeEmailTestSetExpiry(e,t,i){return!0}runtimeHostingUserInfo(){return new wi("test@example.com","100000000",null,!1)}runtimeComputeLog(e,t,i){return[]}runtimeSetHotWalletAddress(e){return!0}runtimeRequestPayment(e){return new Gt(!0,"Mock payment of "+e+" base units credited")}runtimeSetUserCredits(e,t){return!0}runtimeSetUserFreeAccess(e,t){return!0}runtimeReinstallUnytDna(){return new Gt(!0,"")}runtimeSendHot(e,t){return new Gt(!0,"")}runtimeSetUnytMembraneProof(e){return new Gt(!0,"")}runtimeHotWalletBalance(){return""}runtimeHotWalletHistory(e,t){return""}runtimeHotAgentPubkey(){return""}runtimeUnytAgentKey(){return""}runtimeUnytVersionInfo(){return""}};A([ae(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Boolean)],U.prototype,"runtimeQuit",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",Boolean)],U.prototype,"runtimeOpenLink",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",fa)],U.prototype,"runtimeInfo",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[Array]),g("design:returntype",Array)],U.prototype,"addTrustedAgents",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[Array]),g("design:returntype",Array)],U.prototype,"deleteTrustedAgents",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Array)],U.prototype,"getTrustedAgents",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Array)],U.prototype,"runtimeKnownLinkLanguageTemplates",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[Array]),g("design:returntype",Array)],U.prototype,"runtimeAddKnownLinkLanguageTemplates",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[Array]),g("design:returntype",Array)],U.prototype,"runtimeRemoveKnownLinkLanguageTemplates",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Array)],U.prototype,"runtimeFriends",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[Array]),g("design:returntype",Array)],U.prototype,"runtimeAddFriends",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[Array]),g("design:returntype",Array)],U.prototype,"runtimeRemoveFriends",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",String)],U.prototype,"runtimeHcAgentInfos",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",String)],U.prototype,"runtimeGetNetworkMetrics",null);A([ae(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Boolean)],U.prototype,"runtimeRestartHolochain",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[Object]),g("design:returntype",Boolean)],U.prototype,"runtimeHcAddAgentInfos",null);A([qe(),H(0,Q()),H(1,Q()),H(2,Q()),H(3,Q()),g("design:type",Function),g("design:paramtypes",[String,String,String,String]),g("design:returntype",void 0)],U.prototype,"runtimeVerifyStringSignedByDid",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[Sr]),g("design:returntype",Boolean)],U.prototype,"runtimeSetStatus",null);A([qe(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",an)],U.prototype,"runtimeFriendStatus",null);A([ae(),H(0,Q()),H(1,Q()),g("design:type",Function),g("design:paramtypes",[String,_c]),g("design:returntype",Boolean)],U.prototype,"runtimeFriendSendMessage",null);A([qe(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",Array)],U.prototype,"runtimeMessageInbox",null);A([qe(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",Array)],U.prototype,"runtimeMessageOutbox",null);A([fp(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",an)],U.prototype,"runtimeMessageReceived",null);A([fp(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",fn)],U.prototype,"exceptionOccurred",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[Jt]),g("design:returntype",String)],U.prototype,"runtimeRequestInstallNotification",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Array)],U.prototype,"runtimeNotifications",null);A([ae(),H(0,Q()),H(1,Q()),g("design:type",Function),g("design:paramtypes",[String,Jt]),g("design:returntype",Boolean)],U.prototype,"runtimeUpdateNotification",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",Boolean)],U.prototype,"runtimeRemoveNotification",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",Boolean)],U.prototype,"runtimeGrantNotification",null);A([fp(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",ha)],U.prototype,"runtimeNotificationTriggered",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",Boolean)],U.prototype,"runtimeExportDb",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",Boolean)],U.prototype,"runtimeImportDb",null);A([ae(),H(0,Q()),H(1,Q()),g("design:type",Function),g("design:paramtypes",[String,String]),g("design:returntype",Boolean)],U.prototype,"runtimeExportPerspective",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",Boolean)],U.prototype,"runtimeImportPerspective",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Boolean)],U.prototype,"runtimeMultiUserEnabled",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[Boolean]),g("design:returntype",Boolean)],U.prototype,"runtimeSetMultiUserEnabled",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Boolean)],U.prototype,"runtimeFreeHostingEnabled",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[Boolean]),g("design:returntype",Boolean)],U.prototype,"runtimeSetFreeHostingEnabled",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Array)],U.prototype,"runtimeListUsers",null);A([ae(),H(0,Q()),H(1,Q()),g("design:type",Function),g("design:paramtypes",[String,_r]),g("design:returntype",hn)],U.prototype,"runtimeRequestLoginVerification",null);A([ae(),H(0,Q()),H(1,Q()),H(2,Q()),g("design:type",Function),g("design:paramtypes",[String,String,String]),g("design:returntype",String)],U.prototype,"runtimeVerifyEmailCode",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",Boolean)],U.prototype,"runtimeTestEmail",null);A([ae(),H(0,Q()),H(1,Q()),H(2,Q()),g("design:type",Function),g("design:paramtypes",[String,String,_r]),g("design:returntype",on)],U.prototype,"runtimeCreateUser",null);A([ae(),H(0,Q()),H(1,Q()),g("design:type",Function),g("design:paramtypes",[String,String]),g("design:returntype",String)],U.prototype,"runtimeLoginUser",null);A([ae(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Boolean)],U.prototype,"runtimeEmailTestModeEnable",null);A([ae(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Boolean)],U.prototype,"runtimeEmailTestModeDisable",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",String)],U.prototype,"runtimeEmailTestGetCode",null);A([ae(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Boolean)],U.prototype,"runtimeEmailTestClearCodes",null);A([ae(),H(0,Q()),H(1,Q()),H(2,Q()),g("design:type",Function),g("design:paramtypes",[String,String,Number]),g("design:returntype",Boolean)],U.prototype,"runtimeEmailTestSetExpiry",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",wi)],U.prototype,"runtimeHostingUserInfo",null);A([qe(),H(0,Q()),H(1,Q()),H(2,Q()),g("design:type",Function),g("design:paramtypes",[String,Number,String]),g("design:returntype",Array)],U.prototype,"runtimeComputeLog",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",Boolean)],U.prototype,"runtimeSetHotWalletAddress",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",Gt)],U.prototype,"runtimeRequestPayment",null);A([ae(),H(0,Q()),H(1,Q()),g("design:type",Function),g("design:paramtypes",[String,Number]),g("design:returntype",Boolean)],U.prototype,"runtimeSetUserCredits",null);A([ae(),H(0,Q()),H(1,Q()),g("design:type",Function),g("design:paramtypes",[String,Boolean]),g("design:returntype",Boolean)],U.prototype,"runtimeSetUserFreeAccess",null);A([ae(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",Gt)],U.prototype,"runtimeReinstallUnytDna",null);A([ae(),H(0,Q()),H(1,Q()),g("design:type",Function),g("design:paramtypes",[String,String]),g("design:returntype",Gt)],U.prototype,"runtimeSendHot",null);A([ae(),H(0,Q()),g("design:type",Function),g("design:paramtypes",[String]),g("design:returntype",Gt)],U.prototype,"runtimeSetUnytMembraneProof",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",String)],U.prototype,"runtimeHotWalletBalance",null);A([qe(),H(0,Q()),H(1,Q()),g("design:type",Function),g("design:paramtypes",[Number,Number]),g("design:returntype",String)],U.prototype,"runtimeHotWalletHistory",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",String)],U.prototype,"runtimeHotAgentPubkey",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",String)],U.prototype,"runtimeUnytAgentKey",null);A([qe(),g("design:type",Function),g("design:paramtypes",[]),g("design:returntype",String)],U.prototype,"runtimeUnytVersionInfo",null);U=A([Gb()],U);var B1=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 Go(r,{include:e,exclude:t}={}){let i=n=>{let a=o=>typeof o=="string"?n===o:o.test(n);return e?e.some(a):t?!t.some(a):!0};for(let[n,a]of B1(r.constructor.prototype)){if(a==="constructor"||!i(a))continue;let o=Reflect.getOwnPropertyDescriptor(n,a);o&&typeof o.value=="function"&&(r[a]=r[a].bind(r))}return r}var V1="https://hosting.ad4m.dev";function Q1(r){try{return new URL(r),!0}catch(e){return!1}}function Tp(r){return V(this,null,function*(){let e=r||V1,t=yield fetch(`${e}/hosts`);if(!t.ok)throw new Error(`Failed to fetch hosts: ${t.status}`);let i=yield t.json();for(let n of i)n.profilePicUrl&&!Q1(n.profilePicUrl)&&(n.profilePicUrl=new URL(n.profilePicUrl,e).toString());return i})}function Og(r){return V(this,null,function*(){let e=yield r.agent.hostingUserInfo();return{email:e.email,remainingCredits:e.remainingCredits==="unlimited"?1/0:parseFloat(e.remainingCredits)||0,hotWalletAddress:e.hotWalletAddress||null,freeAccess:e.freeAccess}})}function $g(r,e){return V(this,null,function*(){return r.agent.requestPayment(e.toString())})}var H1=12e3,z1="https://hosting.ad4m.dev",W1=6e4,G1=10,Ko=class extends EventTarget{constructor(t){var n;super();this.connectionState="not-connected";this.authState="unauthenticated";this.activeSocket=null;this.requestedRestart=!1;this.connectedHost=null;this.userInfo=null;this.creditPollInterval=null;Go(this),this.options=t,this.port=t.port||parseInt(Ha("ad4m-port"))||H1,this.url=t.url||Ha("ad4m-url")||`ws://localhost:${this.port}/graphql`,this.token=Ha("ad4m-token")||"",this.embedded=js(),this.hostIndexUrl=t.hostIndexUrl||z1,this.lowCreditThreshold=(n=t.lowCreditThreshold)!=null?n:G1;let i=Ha("ad4m-last-host");if(i)try{let a=JSON.parse(i);a&&a.id&&a.url&&a.name&&(this.connectedHost={id:a.id,name:a.name,profilePicUrl:a.profilePicUrl||"",location:a.location||"",url:a.url,rates:a.rates||[],aiModels:a.aiModels||[]})}catch(a){}this.embedded&&this.initializeEmbeddedMode()}connect(){return V(this,null,function*(){if(this.embedded)return console.log("[Ad4m Connect] Embedded mode - waiting for AD4M config via postMessage"),new Promise((t,i)=>{let n=setTimeout(()=>{i(new Error("Timeout waiting for AD4M config from parent window"))},3e4);this.embeddedResolve=a=>{clearTimeout(n),console.log("[Ad4m Connect] Successfully connected in embedded mode"),t(a)},this.embeddedReject=a=>{clearTimeout(n),i(a)},this.ad4mClient&&(this.authState==="authenticated"?(clearTimeout(n),console.log("[Ad4m Connect] Client already initialized in embedded mode"),t(this.ad4mClient)):(clearTimeout(n),i(new Error(`Embedded auth state: ${this.authState}`))))});try{return yield Mi(this.url),dt("ad4m-url",this.url),this.ad4mClient=yield this.buildClient(),yield this.checkAuth(),this.ad4mClient}catch(t){throw console.error("[Ad4m Connect] Connection failed:",t),this.notifyConnectionChange("error"),t}})}buildClient(){return V(this,null,function*(){return this.notifyConnectionChange("connecting"),this.apolloClient&&this.wsClient&&(this.requestedRestart=!0,this.wsClient.dispose(),this.apolloClient.stop(),this.wsClient=null,this.apolloClient=null),this.wsClient=vu({url:this.url,connectionParams:()=>V(this,null,function*(){return{headers:{authorization:this.token}}}),on:{opened:t=>{this.activeSocket=t},error:t=>{this.notifyConnectionChange("error")},connected:()=>{this.notifyConnectionChange("connected")},closed:t=>V(this,null,function*(){if(!(t.wasClean||this.requestedRestart))if(!this.token)this.notifyConnectionChange("error");else try{this.ad4mClient=yield this.buildClient(),yield this.checkAuth()}catch(i){console.error("[Ad4m Connect] Reconnection failed:",i),this.notifyConnectionChange("error")}})}}),this.apolloClient=this.createApolloClient(this.wsClient),this.ad4mClient=new Uo(this.apolloClient),this.requestedRestart=!1,this.ad4mClient})}createApolloClient(t){return new gu({link:new Gf(t),cache:new Rs({resultCaching:!1,addTypename:!1}),defaultOptions:{watchQuery:{fetchPolicy:"no-cache"},query:{fetchPolicy:"no-cache"},mutate:{fetchPolicy:"no-cache"}}})}withTempClient(t,i){return V(this,null,function*(){let n=vu({url:t,connectionParams:()=>V(this,null,function*(){return{headers:{authorization:""}}})}),a=this.createApolloClient(n),o=new Uo(a);try{return yield i(o)}finally{n.dispose()}})}checkAuth(){return V(this,null,function*(){try{return console.log("[Ad4m Connect] Checking authentication status..."),(yield this.ad4mClient.agent.isLocked())?(console.log("[Ad4m Connect] Agent wallet is locked"),this.notifyAuthChange("locked")):(yield this.ad4mClient.agent.status(),this.notifyAuthChange("authenticated")),!0}catch(t){console.error("[Ad4m Connect] Authentication check failed:",t);let i="Cannot extractByTags from a ciphered wallet. You must unlock first.";return t.message===i?(this.notifyAuthChange("locked"),!0):(t.message==="InvalidSignature"&&(console.log("[Ad4m Connect] Clearing invalid token due to InvalidSignature"),this.token="",Wn("ad4m-token")),this.notifyAuthChange("unauthenticated"),!1)}})}disconnect(){return V(this,null,function*(){console.log("[Ad4m Connect] Disconnecting..."),this.wsClient&&(this.wsClient.dispose(),this.wsClient=null),this.apolloClient&&(this.apolloClient.stop(),this.apolloClient=null),this.ad4mClient=void 0,this.token="",Wn("ad4m-token"),this.notifyAuthChange("unauthenticated"),this.connectedHost=null,this.userInfo=null,this.stopCreditPolling(),Wn("ad4m-last-host"),this.notifyConnectionChange("not-connected"),console.log("[Ad4m Connect] Disconnected successfully")})}startCreditSubscription(){if(!!this.ad4mClient){try{this.ad4mClient.agent.addHostingUserInfoChangedListener(t=>{let i={email:t.email,remainingCredits:t.remainingCredits==="unlimited"?1/0:parseFloat(t.remainingCredits)||0,hotWalletAddress:t.hotWalletAddress||null,freeAccess:t.freeAccess};this.userInfo=i,this.dispatchEvent(new CustomEvent("userinfochange",{detail:i})),i.remainingCredits<=0&&this.dispatchEvent(new CustomEvent("creditdepleted")),i.remainingCredits<=this.lowCreditThreshold&&this.dispatchEvent(new CustomEvent("creditlow"))}),this.ad4mClient.agent.subscribeHostingUserInfoChanged()}catch(t){console.warn("[Ad4m Connect] Subscription not available, falling back to polling:",t)}try{this.ad4mClient.agent.addComputeLogUpdatedListener(t=>{this.dispatchEvent(new CustomEvent("computelogentry",{detail:t}))}),this.ad4mClient.agent.subscribeComputeLogUpdated()}catch(t){console.warn("[Ad4m Connect] Compute log subscription not available:",t)}this.startCreditPolling()}}startCreditPolling(){this.stopCreditPolling();let t=()=>V(this,null,function*(){try{if(!this.ad4mClient)return;let i=yield Og(this.ad4mClient);this.userInfo=i,this.dispatchEvent(new CustomEvent("userinfochange",{detail:i})),i.remainingCredits<=this.lowCreditThreshold&&this.dispatchEvent(new CustomEvent("creditlow")),i.remainingCredits<=0&&this.dispatchEvent(new CustomEvent("creditdepleted"))}catch(i){console.error("[Ad4m Connect] Credit polling error:",i)}});t(),this.creditPollInterval=setInterval(t,W1)}stopCreditPolling(){this.creditPollInterval&&(clearInterval(this.creditPollInterval),this.creditPollInterval=null)}requestTopUp(t){return V(this,null,function*(){if(!this.ad4mClient)throw new Error("Not connected");return $g(this.ad4mClient,t)})}fetchComputeLog(t,i){return V(this,null,function*(){if(!this.ad4mClient)throw new Error("Not connected");return this.ad4mClient.agent.computeLog(t,i)})}setConnectedHost(t){this.connectedHost=t,dt("ad4m-last-host",JSON.stringify({id:t.id,url:t.url,name:t.name,location:t.location}))}initializeEmbeddedMode(){console.log("[Ad4m Connect] Running in embedded mode - waiting for AD4M config from parent"),window.addEventListener("message",t=>V(this,null,function*(){var i;if(((i=t.data)==null?void 0:i.type)==="AD4M_CONFIG"){if(t.source!==window.parent){console.warn("[Ad4m Connect] Rejected AD4M_CONFIG from invalid source (not parent window)");return}if(this.options.allowedOrigins&&this.options.allowedOrigins.length>0&&(!t.origin||!this.options.allowedOrigins.includes(t.origin))){console.warn("[Ad4m Connect] Rejected AD4M_CONFIG from unauthorized origin:",t.origin),this.rejectEmbedded(new Error(`Unauthorized origin: ${t.origin}`));return}console.log("[Ad4m Connect] Received AD4M_CONFIG from parent:",{port:t.data.port,hasToken:!!t.data.token});let{port:n,token:a}=t.data;if(n==null){let c=new Error("AD4M_CONFIG missing required field: port");console.error("[Ad4m Connect]",c.message),this.rejectEmbedded(c);return}let o=parseInt(n,10);if(!Number.isFinite(o)||o<=0){let c=new Error(`AD4M_CONFIG invalid port: ${n} (must be a positive integer)`);console.error("[Ad4m Connect]",c.message),this.rejectEmbedded(c);return}let s=a!=null&&typeof a=="string"?a:"";try{this.port=o,this.token=s,this.url=`ws://localhost:${o}/graphql`,dt("ad4m-port",o.toString()),s?dt("ad4m-token",s):Wn("ad4m-token"),dt("ad4m-url",this.url),this.ad4mClient=yield this.buildClient(),yield this.checkAuth()}catch(c){console.error("[Ad4m Connect] Failed to initialize from AD4M_CONFIG:",c),this.rejectEmbedded(c)}}})),console.log("[Ad4m Connect] Requesting AD4M config from parent window"),window.parent.postMessage({type:"REQUEST_AD4M_CONFIG"},"*")}buildAppInfo(){return{appName:this.options.appInfo.name,appDesc:this.options.appInfo.description,appDomain:this.options.appInfo.url,appUrl:window.location.origin,appIconPath:this.options.appInfo.iconPath}}requestCapability(t=!1){return V(this,null,function*(){return t&&(this.token="",Wn("ad4m-token"),this.notifyConfigChange("token",this.token)),this.requestId=yield this.ad4mClient.agent.requestCapability({appName:this.options.appInfo.name,appDesc:this.options.appInfo.description,appUrl:this.options.appInfo.url,appDomain:this.options.appInfo.url,appIconPath:this.options.appInfo.iconPath,capabilities:this.options.capabilities}),this.requestId})}verifyLocalAd4mCode(t){return V(this,null,function*(){if(!this.requestId)return console.error("[Ad4m Connect] Cannot verify code: requestId is missing. Call requestCapability() first to obtain a requestId."),!1;try{let i=yield this.ad4mClient.agent.generateJwt(this.requestId,t);return this.token=i,dt("ad4m-token",this.token),yield this.connect(),!0}catch(i){return console.error("[Ad4m Connect] Code verification failed:",i),!1}})}isValidAd4mAPI(){return V(this,null,function*(){try{return yield this.withTempClient(this.url,t=>V(this,null,function*(){return yield t.runtime.info()})),!0}catch(t){return console.error("[Ad4m Connect] Failed to verify AD4M API:",t),!1}})}isMultiUser(){return V(this,null,function*(){try{return yield this.withTempClient(this.url,t=>V(this,null,function*(){return yield t.runtime.multiUserEnabled()}))}catch(t){return console.error("[Ad4m Connect] Failed to detect multi-user mode:",t),!1}})}submitEmail(t){return V(this,null,function*(){try{return yield this.withTempClient(this.url,i=>V(this,null,function*(){return yield i.agent.requestLoginVerification(t,this.buildAppInfo())}))}catch(i){return{success:!1,message:i.message||"Failed to process email. Please try again.",requiresPassword:!1,isExistingUser:!1}}})}verifyEmailCode(t,i){return V(this,null,function*(){try{let n=yield this.withTempClient(this.url,a=>V(this,null,function*(){return yield a.agent.verifyEmailCode(t,i,"login")}));return this.token=n,dt("ad4m-token",this.token),yield this.connect(),!0}catch(n){return console.error("[Ad4m Connect] Email code verification failed:",n),!1}})}loginWithPassword(t,i){return V(this,null,function*(){try{let n=yield this.withTempClient(this.url,a=>V(this,null,function*(){return yield a.agent.loginUser(t,i)}));return this.token=n,dt("ad4m-token",this.token),yield this.connect(),!0}catch(n){return console.error("[Ad4m Connect] Password login failed:",n),!1}})}createAccount(t,i){return V(this,null,function*(){try{let n=yield this.withTempClient(this.url,a=>V(this,null,function*(){let o=yield a.agent.createUser(t,i);if(o.success)return yield a.agent.loginUser(t,i);throw new Error(o.error||"Failed to create account")}));return this.token=n,dt("ad4m-token",this.token),yield this.connect(),!0}catch(n){return console.error("[Ad4m Connect] Account creation error:",n),!1}})}resolveEmbedded(t){this.embeddedResolve&&(this.embeddedResolve(t),this.embeddedResolve=void 0,this.embeddedReject=void 0)}rejectEmbedded(t){this.embeddedReject&&(this.embeddedReject(t),this.embeddedResolve=void 0,this.embeddedReject=void 0)}notifyConnectionChange(t){this.connectionState!==t&&(this.connectionState=t,this.dispatchEvent(new CustomEvent("connectionstatechange",{detail:t})))}notifyAuthChange(t){if(this.authState=t,this.dispatchEvent(new CustomEvent("authstatechange",{detail:t})),this.embedded&&(t==="authenticated"&&this.resolveEmbedded(this.ad4mClient),t==="unauthenticated"||t==="locked")){let i=t==="locked"?"Authentication failed: Agent is locked":"Authentication failed: Unauthenticated";this.rejectEmbedded(new Error(i))}}notifyConfigChange(t,i){this.dispatchEvent(new CustomEvent("configstatechange",{detail:{type:t,value:i}}))}};var Kc=window,Jc=Kc.ShadowRoot&&(Kc.ShadyCSS===void 0||Kc.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Cp=Symbol(),Pg=new WeakMap,Jo=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Cp)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(Jc&&e===void 0){let i=t!==void 0&&t.length===1;i&&(e=Pg.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Pg.set(t,e))}return e}toString(){return this.cssText}},Rg=r=>new Jo(typeof r=="string"?r:r+"",void 0,Cp),Ge=(r,...e)=>{let t=r.length===1?r[0]:e.reduce((i,n,a)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+r[a+1],r[0]);return new Jo(t,r,Cp)},Op=(r,e)=>{Jc?r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):e.forEach(t=>{let i=document.createElement("style"),n=Kc.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=t.cssText,r.appendChild(i)})},Zc=Jc?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return Rg(t)})(r):r;var $p,Yc=window,Lg=Yc.trustedTypes,K1=Lg?Lg.emptyScript:"",Ng=Yc.reactiveElementPolyfillSupport,Rp={toAttribute(r,e){switch(e){case Boolean:r=r?K1:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},Dg=(r,e)=>e!==r&&(e==e||r==r),Pp={attribute:!0,type:String,converter:Rp,reflect:!1,hasChanged:Dg},Lp="finalized",jr=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var t;this.finalize(),((t=this.h)!==null&&t!==void 0?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();let e=[];return this.elementProperties.forEach((t,i)=>{let n=this._$Ep(i,t);n!==void 0&&(this._$Ev.set(n,i),e.push(n))}),e}static createProperty(e,t=Pp){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){let i=typeof e=="symbol"?Symbol():"__"+e,n=this.getPropertyDescriptor(e,i,t);n!==void 0&&Object.defineProperty(this.prototype,e,n)}}static getPropertyDescriptor(e,t,i){return{get(){return this[t]},set(n){let a=this[e];this[t]=n,this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||Pp}static finalize(){if(this.hasOwnProperty(Lp))return!1;this[Lp]=!0;let e=Object.getPrototypeOf(this);if(e.finalize(),e.h!==void 0&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let t=this.properties,i=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(let n of i)this.createProperty(n,t[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let n of i)t.unshift(Zc(n))}else e!==void 0&&t.push(Zc(e));return t}static _$Ep(e,t){let i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(e=this.constructor.h)===null||e===void 0||e.forEach(t=>t(this))}addController(e){var t,i;((t=this._$ES)!==null&&t!==void 0?t:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((i=e.hostConnected)===null||i===void 0||i.call(e))}removeController(e){var t;(t=this._$ES)===null||t===void 0||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])})}createRenderRoot(){var e;let t=(e=this.shadowRoot)!==null&&e!==void 0?e:this.attachShadow(this.constructor.shadowRootOptions);return Op(t,this.constructor.elementStyles),t}connectedCallback(){var e;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$ES)===null||e===void 0||e.forEach(t=>{var i;return(i=t.hostConnected)===null||i===void 0?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(t=>{var i;return(i=t.hostDisconnected)===null||i===void 0?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t,i=Pp){var n;let a=this.constructor._$Ep(e,i);if(a!==void 0&&i.reflect===!0){let o=(((n=i.converter)===null||n===void 0?void 0:n.toAttribute)!==void 0?i.converter:Rp).toAttribute(t,i.type);this._$El=e,o==null?this.removeAttribute(a):this.setAttribute(a,o),this._$El=null}}_$AK(e,t){var i;let n=this.constructor,a=n._$Ev.get(e);if(a!==void 0&&this._$El!==a){let o=n.getPropertyOptions(a),s=typeof o.converter=="function"?{fromAttribute:o.converter}:((i=o.converter)===null||i===void 0?void 0:i.fromAttribute)!==void 0?o.converter:Rp;this._$El=a,this[a]=s.fromAttribute(t,o.type),this._$El=null}}requestUpdate(e,t,i){let n=!0;e!==void 0&&(((i=i||this.constructor.getPropertyOptions(e)).hasChanged||Dg)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,i))):n=!1),!this.isUpdatePending&&n&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((n,a)=>this[a]=n),this._$Ei=void 0);let t=!1,i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),(e=this._$ES)===null||e===void 0||e.forEach(n=>{var a;return(a=n.hostUpdate)===null||a===void 0?void 0:a.call(n)}),this.update(i)):this._$Ek()}catch(n){throw t=!1,this._$Ek(),n}t&&this._$AE(i)}willUpdate(e){}_$AE(e){var t;(t=this._$ES)===null||t===void 0||t.forEach(i=>{var n;return(n=i.hostUpdated)===null||n===void 0?void 0:n.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){this._$EC!==void 0&&(this._$EC.forEach((t,i)=>this._$EO(i,this[i],t)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};jr[Lp]=!0,jr.elementProperties=new Map,jr.elementStyles=[],jr.shadowRootOptions={mode:"open"},Ng?.({ReactiveElement:jr}),(($p=Yc.reactiveElementVersions)!==null&&$p!==void 0?$p:Yc.reactiveElementVersions=[]).push("1.6.3");var Np,Xc=window,Sa=Xc.trustedTypes,Fg=Sa?Sa.createPolicy("lit-html",{createHTML:r=>r}):void 0,Fp="$lit$",xi=`lit$${(Math.random()+"").slice(9)}$`,Qg="?"+xi,J1=`<${Qg}>`,kn=document,Yo=()=>kn.createComment(""),Xo=r=>r===null||typeof r!="object"&&typeof r!="function",Hg=Array.isArray,Z1=r=>Hg(r)||typeof r?.[Symbol.iterator]=="function",Dp=`[
1718
- \f\r]`,Zo=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Mg=/-->/g,Ug=/>/g,xn=RegExp(`>|${Dp}(?:([^\\s"'>=/]+)(${Dp}*=${Dp}*(?:[^
1719
- \f\r"'\`<>=]|("|')|))|$)`,"g"),jg=/'/g,qg=/"/g,zg=/^(?:script|style|textarea|title)$/i,Wg=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),P=Wg(1),P2=Wg(2),An=Symbol.for("lit-noChange"),et=Symbol.for("lit-nothing"),Bg=new WeakMap,En=kn.createTreeWalker(kn,129,null,!1);function Gg(r,e){if(!Array.isArray(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Fg!==void 0?Fg.createHTML(e):e}var Y1=(r,e)=>{let t=r.length-1,i=[],n,a=e===2?"<svg>":"",o=Zo;for(let s=0;s<t;s++){let c=r[s],l,u,d=-1,f=0;for(;f<c.length&&(o.lastIndex=f,u=o.exec(c),u!==null);)f=o.lastIndex,o===Zo?u[1]==="!--"?o=Mg:u[1]!==void 0?o=Ug:u[2]!==void 0?(zg.test(u[2])&&(n=RegExp("</"+u[2],"g")),o=xn):u[3]!==void 0&&(o=xn):o===xn?u[0]===">"?(o=n??Zo,d=-1):u[1]===void 0?d=-2:(d=o.lastIndex-u[2].length,l=u[1],o=u[3]===void 0?xn:u[3]==='"'?qg:jg):o===qg||o===jg?o=xn:o===Mg||o===Ug?o=Zo:(o=xn,n=void 0);let p=o===xn&&r[s+1].startsWith("/>")?" ":"";a+=o===Zo?c+J1:d>=0?(i.push(l),c.slice(0,d)+Fp+c.slice(d)+xi+p):c+xi+(d===-2?(i.push(void 0),s):p)}return[Gg(r,a+(r[t]||"<?>")+(e===2?"</svg>":"")),i]},In=class{constructor({strings:e,_$litType$:t},i){let n;this.parts=[];let a=0,o=0,s=e.length-1,c=this.parts,[l,u]=Y1(e,t);if(this.el=In.createElement(l,i),En.currentNode=this.el.content,t===2){let d=this.el.content,f=d.firstChild;f.remove(),d.append(...f.childNodes)}for(;(n=En.nextNode())!==null&&c.length<s;){if(n.nodeType===1){if(n.hasAttributes()){let d=[];for(let f of n.getAttributeNames())if(f.endsWith(Fp)||f.startsWith(xi)){let p=u[o++];if(d.push(f),p!==void 0){let h=n.getAttribute(p.toLowerCase()+Fp).split(xi),m=/([.?@])?(.*)/.exec(p);c.push({type:1,index:a,name:m[2],strings:h,ctor:m[1]==="."?Up:m[1]==="?"?jp:m[1]==="@"?qp:xa})}else c.push({type:6,index:a})}for(let f of d)n.removeAttribute(f)}if(zg.test(n.tagName)){let d=n.textContent.split(xi),f=d.length-1;if(f>0){n.textContent=Sa?Sa.emptyScript:"";for(let p=0;p<f;p++)n.append(d[p],Yo()),En.nextNode(),c.push({type:2,index:++a});n.append(d[f],Yo())}}}else if(n.nodeType===8)if(n.data===Qg)c.push({type:2,index:a});else{let d=-1;for(;(d=n.data.indexOf(xi,d+1))!==-1;)c.push({type:7,index:a}),d+=xi.length-1}a++}}static createElement(e,t){let i=kn.createElement("template");return i.innerHTML=e,i}};function _a(r,e,t=r,i){var n,a,o,s;if(e===An)return e;let c=i!==void 0?(n=t._$Co)===null||n===void 0?void 0:n[i]:t._$Cl,l=Xo(e)?void 0:e._$litDirective$;return c?.constructor!==l&&((a=c?._$AO)===null||a===void 0||a.call(c,!1),l===void 0?c=void 0:(c=new l(r),c._$AT(r,t,i)),i!==void 0?((o=(s=t)._$Co)!==null&&o!==void 0?o:s._$Co=[])[i]=c:t._$Cl=c),c!==void 0&&(e=_a(r,c._$AS(r,e.values),c,i)),e}var Mp=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var t;let{el:{content:i},parts:n}=this._$AD,a=((t=e?.creationScope)!==null&&t!==void 0?t:kn).importNode(i,!0);En.currentNode=a;let o=En.nextNode(),s=0,c=0,l=n[0];for(;l!==void 0;){if(s===l.index){let u;l.type===2?u=new Tn(o,o.nextSibling,this,e):l.type===1?u=new l.ctor(o,l.name,l.strings,this,e):l.type===6&&(u=new Bp(o,this,e)),this._$AV.push(u),l=n[++c]}s!==l?.index&&(o=En.nextNode(),s++)}return En.currentNode=kn,a}v(e){let t=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}},Tn=class{constructor(e,t,i,n){var a;this.type=2,this._$AH=et,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=n,this._$Cp=(a=n?.isConnected)===null||a===void 0||a}get _$AU(){var e,t;return(t=(e=this._$AM)===null||e===void 0?void 0:e._$AU)!==null&&t!==void 0?t:this._$Cp}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=_a(this,e,t),Xo(e)?e===et||e==null||e===""?(this._$AH!==et&&this._$AR(),this._$AH=et):e!==this._$AH&&e!==An&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):Z1(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==et&&Xo(this._$AH)?this._$AA.nextSibling.data=e:this.$(kn.createTextNode(e)),this._$AH=e}g(e){var t;let{values:i,_$litType$:n}=e,a=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=In.createElement(Gg(n.h,n.h[0]),this.options)),n);if(((t=this._$AH)===null||t===void 0?void 0:t._$AD)===a)this._$AH.v(i);else{let o=new Mp(a,this),s=o.u(this.options);o.v(i),this.$(s),this._$AH=o}}_$AC(e){let t=Bg.get(e.strings);return t===void 0&&Bg.set(e.strings,t=new In(e)),t}T(e){Hg(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,i,n=0;for(let a of e)n===t.length?t.push(i=new Tn(this.k(Yo()),this.k(Yo()),this,this.options)):i=t[n],i._$AI(a),n++;n<t.length&&(this._$AR(i&&i._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)===null||i===void 0||i.call(this,!1,!0,t);e&&e!==this._$AB;){let n=e.nextSibling;e.remove(),e=n}}setConnected(e){var t;this._$AM===void 0&&(this._$Cp=e,(t=this._$AP)===null||t===void 0||t.call(this,e))}},xa=class{constructor(e,t,i,n,a){this.type=1,this._$AH=et,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=a,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=et}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,i,n){let a=this.strings,o=!1;if(a===void 0)e=_a(this,e,t,0),o=!Xo(e)||e!==this._$AH&&e!==An,o&&(this._$AH=e);else{let s=e,c,l;for(e=a[0],c=0;c<a.length-1;c++)l=_a(this,s[i+c],t,c),l===An&&(l=this._$AH[c]),o||(o=!Xo(l)||l!==this._$AH[c]),l===et?e=et:e!==et&&(e+=(l??"")+a[c+1]),this._$AH[c]=l}o&&!n&&this.j(e)}j(e){e===et?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},Up=class extends xa{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===et?void 0:e}},X1=Sa?Sa.emptyScript:"",jp=class extends xa{constructor(){super(...arguments),this.type=4}j(e){e&&e!==et?this.element.setAttribute(this.name,X1):this.element.removeAttribute(this.name)}},qp=class extends xa{constructor(e,t,i,n,a){super(e,t,i,n,a),this.type=5}_$AI(e,t=this){var i;if((e=(i=_a(this,e,t,0))!==null&&i!==void 0?i:et)===An)return;let n=this._$AH,a=e===et&&n!==et||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,o=e!==et&&(n===et||a);a&&this.element.removeEventListener(this.name,this,n),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,i;typeof this._$AH=="function"?this._$AH.call((i=(t=this.options)===null||t===void 0?void 0:t.host)!==null&&i!==void 0?i:this.element,e):this._$AH.handleEvent(e)}},Bp=class{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){_a(this,e)}};var Vg=Xc.litHtmlPolyfillSupport;Vg?.(In,Tn),((Np=Xc.litHtmlVersions)!==null&&Np!==void 0?Np:Xc.litHtmlVersions=[]).push("2.8.0");var Kg=(r,e,t)=>{var i,n;let a=(i=t?.renderBefore)!==null&&i!==void 0?i:e,o=a._$litPart$;if(o===void 0){let s=(n=t?.renderBefore)!==null&&n!==void 0?n:null;a._$litPart$=o=new Tn(e.insertBefore(Yo(),s),s,void 0,t??{})}return o._$AI(r),o};var Vp,Qp;var Me=class extends jr{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;let i=super.createRenderRoot();return(e=(t=this.renderOptions).renderBefore)!==null&&e!==void 0||(t.renderBefore=i.firstChild),i}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Kg(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)===null||e===void 0||e.setConnected(!1)}render(){return An}};Me.finalized=!0,Me._$litElement$=!0,(Vp=globalThis.litElementHydrateSupport)===null||Vp===void 0||Vp.call(globalThis,{LitElement:Me});var Jg=globalThis.litElementPolyfillSupport;Jg?.({LitElement:Me});((Qp=globalThis.litElementVersions)!==null&&Qp!==void 0?Qp:globalThis.litElementVersions=[]).push("3.3.3");var ut=r=>e=>typeof e=="function"?((t,i)=>(customElements.define(t,i),i))(r,e):((t,i)=>{let{kind:n,elements:a}=i;return{kind:n,elements:a,finisher(o){customElements.define(t,o)}}})(r,e);var e_=(r,e)=>e.kind==="method"&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(t){t.createProperty(e.key,r)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){typeof e.initializer=="function"&&(this[e.key]=e.initializer.call(this))},finisher(t){t.createProperty(e.key,r)}},t_=(r,e,t)=>{e.constructor.createProperty(t,r)};function pe(r){return(e,t)=>t!==void 0?t_(r,e,t):e_(r,e)}function te(r){return pe({...r,state:!0})}var Hp,a$=((Hp=window.HTMLSlotElement)===null||Hp===void 0?void 0:Hp.prototype.assignedElements)!=null?(r,e)=>r.assignedElements(e):(r,e)=>r.assignedNodes(e).filter(t=>t.nodeType===Node.ELEMENT_NODE);function Cn(){return P`
144
+ `);(d.gt!==void 0||d.gte!==void 0||d.lt!==void 0||d.lte!==void 0||d.between!==void 0||d.contains!==void 0)&&r.push(`
145
+ ?source ${Z(o.predicate)} ?wTarget_cmp_${n} .`)}else r.push(`
146
+ ?source ${Z(o.predicate)} ${Z(String(a))} .`)}return{joins:r,filters:s}}var Xs=class{constructor(t,e,r){this.queryParams={},this.modelClassName=null,this.perspective=t,this.ctor=e,r&&(this.queryParams=r)}dispose(){this.currentSubscription&&(this.currentSubscription.dispose(),this.currentSubscription=void 0)}where(t){return this.queryParams.where=t,this}order(t){return this.queryParams.order=t,this}limit(t){return this.queryParams.limit=t,this}offset(t){return this.queryParams.offset=t,this}parent(t,e,r){let s=typeof t=="string"?t:t.id;if(typeof e=="object"&&e!==null&&!("prototype"in e)){if(typeof t=="string")throw new Error("parent() called with a string id and options object requires a model class as second argument");let a=t.constructor;return this.queryParams.parent={id:s,model:a,field:e.field},this}let n=r?.field;if(typeof e=="string")this.queryParams.parent={id:s,predicate:e};else if(typeof e=="function")this.queryParams.parent={id:s,model:e,...n&&{field:n}};else if(typeof t!="string")this.queryParams.parent={id:s,model:t.constructor,...n&&{field:n}};else throw new Error("parent() called with a string id requires a second argument: either a model class or a predicate string");return this}properties(t){return this.queryParams.properties=t,this}deepQuery(){return this.queryParams.deepQuery=!0,this}include(t){return this.queryParams.include=t,this}overrideModelClassName(t){return this.modelClassName=t,this}engine(t){return this}async get(){return await this.executeSparqlQuery()}async getSparql(){return this.executeSparqlQuery()}async executeSparqlQuery(){let{results:t}=await this.ctor.executeModelQuery(this.perspective,this.queryParams,this.modelClassName);return t}async first(){return this.queryParams.limit=1,(await this.get())[0]??null}async subscribe(t){this.dispose();let e=this.ctor,{className:r,queryJson:s,shapeJson:n}=e.prepareModelQueryParams(this.queryParams,this.modelClassName),{subscriptionId:a,result:o}=await this.perspective.modelSubscribe(r,s,n),c=u=>e.parseModelResult(this.perspective,u,this.queryParams.include,this.queryParams.properties),l=c(o),d=null,g=u=>u.length===0?"0:":JSON.stringify(u,(f,w)=>typeof w=="function"?void 0:w);d=g(l);let p=this.perspective.client.subscribeToQueryUpdates(a,u=>{if(!(u&&u.isInit))try{let f=c(u),w=g(f);if(w===d)return;d=w,t(f)}catch(f){console.error("Model subscription update parse error:",f)}}),h=setInterval(()=>{this.perspective.client.keepAliveQuery(this.perspective.uuid,a).catch(()=>{})},3e4);this.currentSubscription={dispose:()=>{clearInterval(h),p(),this.perspective.client.disposeQuerySubscription(this.perspective.uuid,a).catch(()=>{})}};for(let u of l)u.takeSnapshot?.(this.queryParams.include);return l}async subscribeSparql(t){return this.subscribe(t)}async count(){let{totalCount:t}=await this.ctor.executeModelQuery(this.perspective,{...this.queryParams,limit:0},this.modelClassName);return t}async countSparql(){return await this.count()}async countSubscribe(t){this.dispose();let e={...this.queryParams,limit:0},{className:r,queryJson:s,shapeJson:n}=this.ctor.prepareModelQueryParams(e,this.modelClassName),{subscriptionId:a,result:o}=await this.perspective.modelSubscribe(r,s,n),c=p=>(typeof p=="string"?JSON.parse(p):p).totalCount??0,l=c(o),d=this.perspective.client.subscribeToQueryUpdates(a,p=>{if(!(p&&p.isInit))try{t(c(p))}catch(h){console.error("Count subscription update parse error:",h)}}),g=setInterval(()=>{this.perspective.client.keepAliveQuery(this.perspective.uuid,a).catch(()=>{})},3e4);return this.currentSubscription={dispose:()=>{clearInterval(g),d(),this.perspective.client.disposeQuerySubscription(this.perspective.uuid,a).catch(()=>{})}},l}async countSubscribeSparql(t){return this.countSubscribe(t)}async paginate(t,e){let r={...this.queryParams||{},limit:t,offset:t*(e-1),count:!0},{results:s,totalCount:n}=await this.ctor.executeModelQuery(this.perspective,r,this.modelClassName);return{results:s,totalCount:n,pageSize:t,pageNumber:e}}async paginateSparql(t,e){return await this.paginate(t,e)}async paginateSubscribe(t,e,r){this.dispose();let s=this.ctor,n={...this.queryParams||{}};delete n.limit,delete n.offset;let{className:a,queryJson:o,shapeJson:c}=s.prepareModelQueryParams(n,this.modelClassName),{subscriptionId:l}=await this.perspective.modelSubscribe(a,o,c),d={...this.queryParams||{},limit:t,offset:t*(e-1),count:!0},g=async()=>{let{results:w,totalCount:v}=await s.executeModelQuery(this.perspective,d,this.modelClassName);r({results:w,totalCount:v,pageSize:t,pageNumber:e})},p=this.perspective.client.subscribeToQueryUpdates(l,w=>{w&&w.isInit||g().catch(v=>console.error("Paginate subscription error:",v))}),h=setInterval(()=>{this.perspective.client.keepAliveQuery(this.perspective.uuid,l).catch(()=>{})},3e4);this.currentSubscription={dispose:()=>{clearInterval(h),p(),this.perspective.client.disposeQuerySubscription(this.perspective.uuid,l).catch(()=>{})}};let{results:u,totalCount:f}=await s.executeModelQuery(this.perspective,d,this.modelClassName);return{results:u,totalCount:f,pageSize:t,pageNumber:e}}async paginateSubscribeSparql(t,e,r){return await this.paginateSubscribe(t,e,r)}};function xi(i){return Array.isArray(i)?i.map(t=>t&&typeof t=="object"&&typeof t.id=="string"?t.id:t):i}function Xh(i,t){let e=Hr(i,t);if(!e){let r=t?.prototype?.className||t?.name||"unknown";console.warn(`[Ad4mModel] buildConformanceGetter: no conditions found for target "${r}".`);return}return e.getter}async function Ja(i,t,e,r){`${i.id}`;let n=r?.requestedProperties&&r.requestedProperties.length>0?new Set(r.requestedProperties):null;if(!r?.skipPropertyGetters){for(let[a,o]of Object.entries(e.properties))if(!(n&&!n.has(a))&&o.getter)try{let c=o.getter,l=c.replace(/\?source\b/g,`<${i.id}>`).replace(/<Base>/g,`<${i.id}>`).replace(/Base/g,`<${i.id}>`),d=l.trim().toUpperCase();if(d.startsWith("SELECT")||d.startsWith("ASK")||d.startsWith("CONSTRUCT")){let g=await t.querySparql(l);if(d.startsWith("ASK"))i[a]=g===!0||g==="true";else if(g&&g.length>0){let p=g[0],h=Object.keys(p)[0],u=p[h]?.value??p[h];u!=null&&u!=="None"&&u!==""&&(i[a]=u)}}else console.warn(`Unsupported legacy getter syntax for property ${a} \u2014 use native SPARQL (SELECT/ASK): ${c.slice(0,100)}`)}catch(c){console.warn(`Failed to evaluate getter for ${a}:`,c)}}for(let[a,o]of Object.entries(e.relations)){if(n&&!n.has(a)&&!(r?.include&&a in r.include))continue;let c=o,l=c.getter;if(!l&&c.where&&c.direction!=="reverse")try{let g=c.target?.(),p=g?g.getModelMetadata?.()??null:null,h=!0;if(p)for(let u of Object.keys(c.where)){if(["id","author","timestamp"].includes(u))continue;let f=p.properties[u];if(f&&(!f.resolveLanguage||f.resolveLanguage==="literal")){h=!1;break}}else h=!1;if(h){let u=zr(c.where,p);u.length>0&&(l=`SELECT ?target WHERE { <Base> <${Xe(c.predicate)}> ?target . ${u.join(" ")} }`)}}catch(g){console.warn(`[Ad4mModel] where-clause compilation failed for relation "${a}":`,g)}if(!l&&c.target&&c.filter!==!1&&c.direction!=="reverse")try{let g=c.target();l=Xh(c.predicate,g),l||console.warn(`[Ad4mModel] buildConformanceGetter returned undefined for relation "${a}" (predicate: "${c.predicate}")`)}catch(g){console.warn(`[Ad4mModel] auto-generation failed for relation "${a}":`,g)}if(l)try{let g=l.replace(/\?source\b/g,`<${i.id}>`).replace(/<Base>/g,`<${i.id}>`).replace(/\bBase\b/g,`<${i.id}>`),p=g.trim().toUpperCase();if(p.startsWith("SELECT")||p.startsWith("ASK")||p.startsWith("CONSTRUCT")){let h=await t.querySparql(g);if(h&&h.length>0){let u=h.map(f=>{let w=Object.keys(f)[0];return f[w]?.value??f[w]}).filter(f=>f!=null&&f!==""&&f!=="None");i[a]=u}}else console.warn(`Unsupported legacy getter syntax for relation ${a} \u2014 use native SPARQL (SELECT/ASK): ${l.slice(0,100)}`)}catch(g){console.warn(`Failed to evaluate getter for ${a}:`,g)}let d=i[a];if(c.where&&Array.isArray(d)&&d.length>0){let g=c.target?.();if(g){let p=[];for(let h of d)try{let u=new g(t,h);await u.get();let f=!0;for(let[w,v]of Object.entries(c.where))if(u[w]!==v){f=!1;break}f&&p.push(h)}catch{p.push(h)}i[a]=p}}}}function Ys(i,t,e){for(let[r,s]of Object.entries(t)){if(!s)continue;let n=e[r];if(!n?.target)continue;let a=n.target(),o=JSON.parse(JSON.stringify(a.getModelMetadata()));i.relations[r]||(i.relations[r]={name:r,predicate:n.predicate,direction:n.kind==="belongsToMany"||n.kind==="belongsToOne"?"reverse":"forward"});let c=i.relations[r];c.kind=n.kind,c.maxCount=n.maxCount,c.targetShape=o,c.targetClassName=o.className;let l=typeof s=="object"&&s!==null?s.include:void 0;if(l){let d=ue(a);Ys(o,l,d)}}}function Vr(i,t,e,r,s){let n=new i(t,e.id||e.baseExpression);if(s){let a=new Set(Object.keys(e));for(let o of Object.getOwnPropertyNames(n))o==="id"||o==="baseExpression"||o==="perspective"||o.startsWith("_")||a.has(o)||delete n[o]}for(let[a,o]of Object.entries(e)){if(a==="baseExpression"||a==="id")continue;let c=!1,l=Object.getPrototypeOf(n);for(;l;){let d=Object.getOwnPropertyDescriptor(l,a);if(d){c=!!(d.get&&!d.set);break}l=Object.getPrototypeOf(l)}if(!c){if((a==="createdAt"||a==="updatedAt")&&typeof o=="string"&&o.includes("T")){n[a]=new Date(o).getTime();continue}n[a]=o}}try{let a=pt(i);for(let[o,c]of Object.entries(a)){let l=c;typeof l.transform!="function"||!(o in e)||l.resolveLanguage!=null&&l.resolveLanguage!=="literal"||(n[o]=l.transform(n[o]))}}catch{}if(r){let a=ue(i);for(let[o,c]of Object.entries(r)){if(!c)continue;let l=a[o];if(!l?.target)continue;let d=l.target(),g=typeof c=="object"&&c!==null?c.include:void 0,p=typeof c=="object"&&c!==null?c.properties:void 0,h=n[o];Array.isArray(h)?n[o]=h.map(u=>typeof u=="object"&&u!==null&&u.id?Vr(d,t,u,g,p):u):typeof h=="object"&&h!==null&&h.id&&(n[o]=Vr(d,t,h,g,p))}}return n}var ar=class{get timestamp(){return this.createdAt}static generateSDNA(){return{sdna:"",name:""}}static generateSHACL(){return{shape:null,name:""}}static async getClassName(t){if(this===ar)return await t.stringOrTemplateObjectToSubjectClassName(this);let r=this.classNamesByClass.get(this);r||(r={},this.classNamesByClass.set(this,r));let s=t.uuid;return r[s]||(r[s]=await t.stringOrTemplateObjectToSubjectClassName(this)),r[s]}static getModelMetadata(){let t=this.prototype;if(!t.className||t.className==="Ad4mModel")throw new Error("Model class must be decorated with @Model");let e=t.className,r={},s=pt(this);for(let[g,p]of Object.entries(s)){let h=p;r[g]={name:g,predicate:h.through||"",required:h.required||!1,readOnly:!(h.writable??!1),...h.initial!==void 0&&{initial:h.initial},...h.resolveLanguage!==void 0&&{resolveLanguage:h.resolveLanguage},...h.prologGetter!==void 0&&{prologGetter:h.prologGetter},...h.getter!==void 0&&{getter:h.getter},...h.prologSetter!==void 0&&{prologSetter:h.prologSetter},...h.local!==void 0&&{local:h.local},...h.transform!==void 0&&{transform:h.transform},...h.flag!==void 0&&{flag:h.flag}}}let n={},o=ue(this);for(let[g,p]of Object.entries(o)){let h=p;n[g]={name:g,predicate:h.predicate||"",...h.local!==void 0&&{local:h.local},...h.getter!==void 0&&{getter:h.getter},direction:h.kind==="belongsToMany"||h.kind==="belongsToOne"?"reverse":"forward",...h.kind!==void 0&&{kind:h.kind},...h.maxCount!==void 0&&{maxCount:h.maxCount},...h.target!==void 0&&{target:h.target},...h.filter!==void 0&&{filter:h.filter},...h.where!==void 0&&{where:h.where}}}let c=Object.keys(r).length>0,l=Object.keys(n).length>0;if(!(c||l)&&t.__jsonSchema){let g=t.__jsonSchema,p=t.__jsonSchemaOptions||{};if(g.properties)for(let[h,u]of Object.entries(g.properties)){let f=Do(u),w=Ho(g,h,u,zo(g,p),p);if(f)n[h]={name:h,predicate:w,...u["x-ad4m"]?.local!==void 0&&{local:u["x-ad4m"].local}};else{let v=g.required?.includes(h)||!1;r[h]={name:h,predicate:w,required:v,readOnly:u["x-ad4m"]?.writable===!1,...u["x-ad4m"]?.resolveLanguage&&{resolveLanguage:u["x-ad4m"].resolveLanguage},...u["x-ad4m"]?.initial&&{initial:u["x-ad4m"].initial},...u["x-ad4m"]?.local!==void 0&&{local:u["x-ad4m"].local}}}}}return{className:e,properties:r,relations:n}}constructor(t,e){this._snapshot=null,this._baseExpression=e||K.from(Ka(24)).toUrl(),this._perspective=t}get id(){return this._baseExpression}get perspective(){return this._perspective}getPropertyMetadata(t){let e=this.constructor;return pt(e)[t]}getRelationOptions(t){let e=this.constructor;return ue(e)[t]}generatePropertySetterAction(t,e){if(e.flag)throw new Error(`Property "${t}" is a @Flag and cannot be written. Flags are immutable type markers set at creation time.`);if(e.readOnly)throw new Error(`Property "${t}" is read-only and cannot be written`);if(e.prologSetter)throw new Error(`Custom Prolog setter for property "${t}" not yet supported without Prolog. Use standard @Property decorator or enable Prolog for custom setters.`);if(!e.through)throw new Error(`Property "${t}" has no 'through' predicate defined`);return[{action:"setSingleTarget",source:"this",predicate:e.through,target:"value",...e.local&&{local:!0}}]}generateRelationAction(t,e){let r=this.getRelationOptions(t);if(!r)throw new Error(`Relation "${t}" has no metadata defined`);if(!r.predicate)throw new Error(`Relation "${t}" has no predicate defined`);return[{action:{adder:"addLink",remover:"removeLink",setter:"collectionSetter"}[e],source:"this",predicate:r.predicate,target:"value",...r.local&&{local:!0}}]}takeSnapshot(t){let r=this.constructor.getModelMetadata(),s={};for(let n of Object.keys(r.properties)){let a=this[n];s[n]=xi(Array.isArray(a)?[...a]:a)}if(t===void 0)for(let n of Object.keys(r.relations)){let a=this[n];s[n]=xi(Array.isArray(a)?[...a]:a)}else if(t&&Object.keys(t).length>0){for(let n of Object.keys(t))if(n in r.relations){let a=this[n];s[n]=xi(Array.isArray(a)?[...a]:a)}}this._snapshot=s}isDirty(){return this._snapshot?this.changedFields().length>0:!0}changedFields(){let e=this.constructor.getModelMetadata();if(!this._snapshot)return[...Object.keys(e.properties),...Object.keys(e.relations)];let r=[],s=[...Object.keys(e.properties),...Object.keys(e.relations)];for(let n of s){if(!(n in this._snapshot))continue;let a=xi(this[n]),o=this._snapshot[n];if(Array.isArray(a)||Array.isArray(o)){let c=Array.isArray(a)?[...a].sort():[],l=Array.isArray(o)?[...o].sort():[];(c.length!==l.length||c.some((d,g)=>d!==l[g]))&&r.push(n)}else a!==o&&r.push(n)}return r}async getData(t){try{let e=this.constructor,r={where:{id:this._baseExpression},limit:1};t?.properties&&(r.properties=t.properties),t?.include&&(r.include=t.include);let{results:s}=await e.executeModelQuery(this._perspective,r,null);if(s.length>0){let n=s[0];for(let[a,o]of Object.entries(n)){if(a==="_baseExpression"||a==="_perspective"||a==="_snapshot"||a.startsWith("_"))continue;let c=!1,l=Object.getPrototypeOf(this);for(;l;){let d=Object.getOwnPropertyDescriptor(l,a);if(d){c=!!(d.get&&!d.set);break}l=Object.getPrototypeOf(l)}c||(this[a]=o)}}}catch(e){console.error(`getData via Rust model query failed for ${this._baseExpression}:`,e)}return this.takeSnapshot(t?.include),this}static async queryToSPARQL(t,e){let r=this.getModelMetadata(),s=ue(this);return Jh(r,s,e,this)}static prepareModelQueryParams(t={},e){let r=this.getModelMetadata(),s=e||r.className,n={};if(t.parent){let a=Zi(t.parent,this);n.parent={id:t.parent.id,predicate:a}}if(t.properties&&(n.properties=t.properties),t.include&&(n.include=t.include),t.where&&(n.where=t.where),t.order&&(n.order=Object.entries(t.order).map(([a,o])=>[a,o])),t.offset!==void 0&&(n.offset=t.offset),t.limit!==void 0&&(n.limit=t.limit),t.count!==void 0&&(n.count=t.count),t.include){let a=ue(this);Ys(r,t.include,a)}{let a=ue(this);for(let[o,c]of Object.entries(r.relations)){let l=c;if(l.getter||l.direction==="reverse"||l.filter===!1)continue;let d=a[o];if(!!d?.target)try{let g=d.target(),p=Hr(d.predicate,g),h=[];if(l.where)try{let u=g.getModelMetadata?.()??null,f=!0;if(u)for(let w of Object.keys(l.where)){if(["id","author","timestamp"].includes(w))continue;let v=u.properties[w];if(v&&(!v.resolveLanguage||v.resolveLanguage==="literal")){f=!1;break}}else f=!1;f&&(h=zr(l.where,u))}catch{}if(p){let u=p.getter;h.length>0&&(u=u.replace(/ \}$/,` ${h.join(" ")} }`)),l.getter=u}else if(h.length>0){let u=d.predicate.replace(/[<>"{}|\\^`\u0000-\u0020]/g,"");l.getter=`SELECT ?target WHERE { <Base> <${u}> ?target . ${h.join(" ")} }`}}catch{}}}return{className:s,queryJson:JSON.stringify(n),shapeJson:JSON.stringify(r)}}static parseModelResult(t,e,r,s){let n=typeof e=="string"?JSON.parse(e):e,a=n.instances||n;return Array.isArray(a)?a.map(o=>Vr(this,t,o,r,s)):[]}static async executeModelQuery(t,e={},r){let s=this.getModelMetadata(),n=r||s.className;if(e.includeAll){let f=ue(this),w={};for(let[v,x]of Object.entries(f))x.direction!=="reverse"&&(w[v]=!0);e={...e,include:{...w,...e.include}}}let a={};if(e.parent){let f=Zi(e.parent,this);a.parent={id:e.parent.id,predicate:f}}if(e.properties&&(a.properties=e.properties),e.include){let f={},w={};for(let[v,x]of Object.entries(e.include))v.startsWith("$")?w[v]=x:f[v]=x;if(Object.keys(f).length>0&&(a.include=f),Object.keys(w).length>0){let v=ue(this);for(let[,x]of Object.entries(w)){let S=v[x.from];if(!x.targetShape&&S?.target)try{let P=S.target().getModelMetadata?.();P&&(x.targetShape=P)}catch{}}a.projections=w}}if(e.where&&(a.where=e.where),e.order&&(a.order=Object.entries(e.order).map(([f,w])=>[f,w])),e.offset!==void 0&&(a.offset=e.offset),e.limit!==void 0&&(a.limit=e.limit),e.count!==void 0&&(a.count=e.count),a.include){let f=ue(this);Ys(s,a.include,f)}{let f=ue(this);for(let[w,v]of Object.entries(s.relations)){let x=v;if(x.getter||x.direction==="reverse"||x.filter===!1)continue;let S=f[w];if(!!S?.target)try{let _=S.target(),P=Hr(S.predicate,_),R=[];if(x.where)try{let k=_.getModelMetadata?.()??null,M=!0;if(k)for(let N of Object.keys(x.where)){if(["id","author","timestamp"].includes(N))continue;let A=k.properties[N];if(A&&(!A.resolveLanguage||A.resolveLanguage==="literal")){M=!1;break}}else M=!1;M&&(R=zr(x.where,k))}catch{}if(P){let k=P.getter;R.length>0&&(k=k.replace(/ \}$/,` ${R.join(" ")} }`)),x.getter=k}else if(R.length>0){let k=S.predicate.replace(/[<>"{}|\\^`\u0000-\u0020]/g,"");x.getter=`SELECT ?target WHERE { <Base> <${k}> ?target . ${R.join(" ")} }`}}catch{}}}let o=JSON.stringify(s),c=JSON.stringify(a),l=await t.modelQuery(n,c,o),d=l.instances.map(f=>Vr(this,t,f,e.include,e.properties)),g=pt(this),p=Object.entries(g).filter(([,f])=>f.resolveLanguage!=null&&f.resolveLanguage!=="literal");p.length>0&&await Promise.all(d.map(async f=>{for(let[w,v]of p){let x=f[w];if(!(typeof x!="string"||!x||x.startsWith("literal:")))try{let S=await t.getExpression(x);if(S){let _;try{_=JSON.parse(S.data)}catch{_=S.data}let P=v.transform;f[w]=typeof P=="function"?P(_):_}}catch{}}}));let h=a.include?new Set(Object.keys(a.include)):new Set;for(let f of d){let w={};for(let v of h)f[v]!==void 0&&(w[v]=f[v]);await Ja(f,t,s,{skipPropertyGetters:!0});for(let[v,x]of Object.entries(w))f[v]=x;for(let[v,x]of Object.entries(s.relations)){if(h.has(v))continue;let S=x.kind;if((S==="hasOne"||S==="belongsToOne")&&Array.isArray(f[v])){let _=f[v];f[v]=_.length>0?_[0]:null}}}let u=a.include;for(let f of d)f.takeSnapshot(u);return{results:d,totalCount:l.totalCount}}static async findAll(t,e={},r){if(e.properties&&e.properties.length===0)throw new Error("properties[] must not be empty \u2014 omit the field to return all properties, or specify at least one field name");let{results:s}=await this.executeModelQuery(t,e);return s}static async findOne(t,e={},r){let s={...e,limit:1};return(await this.findAll(t,s))[0]??null}static async findAllAndCount(t,e={},r){return await this.executeModelQuery(t,e)}static async paginate(t,e,r,s,n){let a={...s||{},limit:e,offset:e*(r-1),count:!0},{results:o,totalCount:c}=await this.executeModelQuery(t,a);return{results:o,totalCount:c,pageSize:e,pageNumber:r}}static async count(t,e={}){let{totalCount:r}=await this.executeModelQuery(t,{...e,limit:0});return r}async setProperty(t,e,r){let s=this.getPropertyMetadata(t);if(!s){console.warn(`Property "${t}" has no metadata, skipping`);return}let n=this.generatePropertySetterAction(t,s),a=s.resolveLanguage;e==null||e===""||(a&&(e=await this._perspective.createExpression(e,a)),await this._perspective.executeAction(n,this._baseExpression,[{name:"value",value:e}],r))}resolveRelationId(t){return typeof t=="string"?t:t&&typeof t=="object"&&typeof t.id=="string"?t.id:String(t)}async setRelationValues(t,e,r){if(!this.getRelationOptions(t)){console.warn(`Relation "${t}" has no metadata, skipping`);return}let n=this.generateRelationAction(t,"setter");e!=null&&(Array.isArray(e)?await this._perspective.executeAction(n,this._baseExpression,e.map(a=>({name:"value",value:this.resolveRelationId(a)})),r):await this._perspective.executeAction(n,this._baseExpression,[{name:"value",value:this.resolveRelationId(e)}],r))}async addRelationValue(t,e,r){if(!this.getRelationOptions(t)){console.warn(`Relation "${t}" has no metadata, skipping`);return}let n=this.generateRelationAction(t,"adder");e!=null&&(Array.isArray(e)?await Promise.all(e.map(a=>this._perspective.executeAction(n,this._baseExpression,[{name:"value",value:this.resolveRelationId(a)}],r))):await this._perspective.executeAction(n,this._baseExpression,[{name:"value",value:this.resolveRelationId(e)}],r))}async removeRelationValue(t,e,r){if(!this.getRelationOptions(t)){console.warn(`Relation "${t}" has no metadata, skipping`);return}let n=this.generateRelationAction(t,"remover");e!=null&&(Array.isArray(e)?await Promise.all(e.map(a=>this._perspective.executeAction(n,this._baseExpression,[{name:"value",value:this.resolveRelationId(a)}],r))):await this._perspective.executeAction(n,this._baseExpression,[{name:"value",value:this.resolveRelationId(e)}],r))}async save(t){if(this._snapshot){await this.innerUpdate(!0,t),t?this.takeSnapshot():await this.getData();return}let e=!1;t||(t=await this.perspective.createBatch(),e=!0);let r=this.constructor.getModelMetadata(),s=Object.values(r.properties).some(a=>a.required||a.flag||a.initial!==void 0),n=[];if(s){let a={};for(let[c,l]of Object.entries(this))if(l!=null&&!(Array.isArray(l)&&l.length>0)&&!l?.action){let d=r.properties[c];if(d?.resolveLanguage&&d.resolveLanguage!=="literal"&&typeof l=="object"){n.push(c);continue}a[c]=l}let o=await this.perspective.stringOrTemplateObjectToSubjectClassName(this);await this.perspective.createSubject(o,this._baseExpression,a,t)}await this.innerUpdate(!s,t);for(let a of n){let o=this[a];o!=null&&await this.setProperty(a,o,t)}e?(await this.perspective.commitBatch(t),await this.getData()):this.takeSnapshot()}cleanCopy(){let e=this.constructor.getModelMetadata(),r={},s=new Set([...Object.keys(e.properties),...Object.keys(e.relations)]);for(let n of s){let a=this[n];a!=null&&n!=="author"&&n!=="timestamp"&&(r[n]=a)}return r}async innerUpdate(t=!0,e){let r=this.constructor,s=this._snapshot?new Set(this.changedFields()):null,n=r.getModelMetadata(),a=new Set([...Object.keys(n.properties),...Object.keys(n.relations)]),o=Object.entries(this);for(let[c,l]of o){if(!a.has(c)||s&&!s.has(c))continue;let d=n.relations[c];if(!(d&&(d.getter||d.target&&d.filter!==!1&&Object.entries(n.relations).some(([p,h])=>p!==c&&h.predicate===d.predicate)))&&l!=null){if(l?.action)switch(l.action){case"setter":await this.setRelationValues(c,l.value,e);break;case"adder":await this.addRelationValue(c,l.value,e);break;case"remover":await this.removeRelationValue(c,l.value,e);break;default:await this.setRelationValues(c,l.value,e);break}else if(Array.isArray(l))await this.setRelationValues(c,l,e);else if(l!=null&&l!==""&&t){if(this.getRelationOptions(c)||this.getPropertyMetadata(c)?.flag)continue;await this.setProperty(c,l,e)}}}}static async evaluateGetters(t,e,r){if(t.length===0)return;let s=this.getModelMetadata(),n=r&&r.length>0?{requestedProperties:r}:void 0,a=[];for(let[o,c]of Object.entries(s.properties))c.getter&&(!r||r.length===0||r.includes(o))&&a.push(o);for(let o of t){await Ja(o,e,s,n);let c=o;if(c._snapshot)for(let l of a){let d=o[l];c._snapshot[l]=xi(Array.isArray(d)?[...d]:d)}}}async get(t){let e;return t?"include"in t||"properties"in t?e=t:e={include:t}:e=void 0,await this.getData(e)}async delete(t){let e=this.constructor.getModelMetadata();if(Object.values(e.properties).some(s=>s.required||s.flag||s.initial!==void 0))await this._perspective.removeSubject(this,this._baseExpression,t);else try{let s=new Set;for(let o of Object.values(e.properties))o.predicate&&s.add(o.predicate);for(let o of Object.values(e.relations))o.predicate&&s.add(o.predicate);let a=(await this._perspective.get(new Q({source:this._baseExpression}))).filter(o=>o.data.predicate&&s.has(o.data.predicate));a.length>0&&await this._perspective.removeLinks(a,t)}catch(s){console.warn(`delete(): failed to remove outgoing links for ${this._baseExpression}:`,s)}try{let s=await this._perspective.get(new Q({target:this._baseExpression}));s.length>0&&await this._perspective.removeLinks(s,t)}catch(s){console.warn(`delete(): failed to clean up incoming links for ${this._baseExpression}:`,s)}}static async create(t,e={},r){let s=new this(t);if(Object.assign(s,e),r?.parent&&!r?.batchId){let n=await t.createBatch();await s.save(n);let a=Zi(r.parent,this),o=new Re({source:r.parent.id,predicate:a,target:s.id});return await t.add(o,"shared",n),await t.commitBatch(n),await s.get(),s}if(await s.save(r?.batchId),r?.parent){let n=Zi(r.parent,this),a=new Re({source:r.parent.id,predicate:n,target:s.id});await t.add(a,"shared",r?.batchId)}return s}static async update(t,e,r){let s=new this(t,e);return await s.get(),Object.assign(s,r),await s.save(),s}static async remove(t,e){return this.delete(t,e)}static async delete(t,e){await new this(t,e).delete()}static async register(t){await t.ensureSDNASubjectClass(this)}static async transaction(t,e){let r=await t.createBatch(),s=await e({batchId:r});return await t.commitBatch(r),s}static query(t,e){return new Xs(t,this,e)}static fromJSONSchema(t,e){return Bh(this,t,e)}static fromSHACL(t,e){let r=class extends this{};r.className=e,r.prototype.className=e;let s=new Map;for(let a of t.constructor_actions??[])a.action==="addLink"&&typeof a.predicate=="string"&&typeof a.target=="string"&&a.target!=="value"&&!a.target.startsWith("literal:")&&s.set(a.predicate,a.target);for(let a of t.properties){let o=a.hasValue??s.get(a.path);if(o!==void 0){let l=a.name??`_flag_${a.path.replace(/[^a-zA-Z0-9_]/g,"_")}`;Ls(r,l,{through:a.path,required:!0,initial:o,flag:!0,writable:!1,readOnly:!0});continue}if(!a.name)continue;a.maxCount===void 0||a.maxCount>1?Xa(r,a.name,{predicate:a.path,kind:"hasMany",...a.local!==void 0&&{local:a.local},...a.getter!==void 0&&{getter:a.getter}}):Ls(r,a.name,{through:a.path,writable:a.writable??!0,...a.resolveLanguage!==void 0&&{resolveLanguage:a.resolveLanguage},...a.local!==void 0&&{local:a.local}})}return Ya({name:e})(r),r}};ar.classNamesByClass=new WeakMap;var Qa=class extends wt(){};var Yh=i=>{let t=new Set;do for(let e of Reflect.ownKeys(i))t.add([i,e]);while((i=Reflect.getPrototypeOf(i))&&i!==Object.prototype);return t};function hr(i,{include:t,exclude:e}={}){let r=s=>{let n=a=>typeof a=="string"?s===a:a.test(s);return t?t.some(n):e?!e.some(n):!0};for(let[s,n]of Yh(i.constructor.prototype)){if(n==="constructor"||!r(n))continue;let a=Reflect.getOwnPropertyDescriptor(s,n);a&&typeof a.value=="function"&&(i[n]=i[n].bind(i))}return i}var eu="https://hosting.ad4m.dev";function tu(i){try{return new URL(i),!0}catch(t){return!1}}function dn(i){return L(this,null,function*(){let t=i||eu,e=yield fetch(`${t}/hosts`);if(!e.ok)throw new Error(`Failed to fetch hosts: ${e.status}`);let r=yield e.json();for(let s of r)s.profilePicUrl&&!tu(s.profilePicUrl)&&(s.profilePicUrl=new URL(s.profilePicUrl,t).toString());return r})}function Wo(i){return L(this,null,function*(){let t=yield i.agent.hostingUserInfo();return{email:t.email,remainingCredits:t.remainingCredits==="unlimited"?1/0:parseFloat(t.remainingCredits)||0,hotWalletAddress:t.hotWalletAddress||null,freeAccess:t.freeAccess}})}function Bo(i,t){return L(this,null,function*(){return i.agent.requestPayment(t.toString())})}var iu=12e3,ru="https://hosting.ad4m.dev",su=6e4,nu=10,ur=class extends EventTarget{constructor(e){var s;super();this.connectionState="not-connected";this.authState="unauthenticated";this.requestedRestart=!1;this.connectedHost=null;this.userInfo=null;this.creditPollInterval=null;hr(this),this.options=e,this.port=e.port||parseInt(bi("ad4m-port"))||iu,this.url=e.url||bi("ad4m-url")||`http://localhost:${this.port}`,this.token=bi("ad4m-token")||"",this.embedded=br(),this.hostIndexUrl=e.hostIndexUrl||ru,this.lowCreditThreshold=(s=e.lowCreditThreshold)!=null?s:nu;let r=bi("ad4m-last-host");if(r)try{let n=JSON.parse(r);n&&n.id&&n.url&&n.name&&(this.connectedHost={id:n.id,name:n.name,profilePicUrl:n.profilePicUrl||"",location:n.location||"",url:n.url,rates:n.rates||[],aiModels:n.aiModels||[]})}catch(n){}this.embedded&&this.initializeEmbeddedMode()}get baseUrl(){return tt(this.url)}connect(){return L(this,null,function*(){if(this.embedded)return console.log("[Ad4m Connect] Embedded mode - waiting for AD4M config via postMessage"),new Promise((e,r)=>{let s=setTimeout(()=>{r(new Error("Timeout waiting for AD4M config from parent window"))},3e4);this.embeddedResolve=n=>{clearTimeout(s),console.log("[Ad4m Connect] Successfully connected in embedded mode"),e(n)},this.embeddedReject=n=>{clearTimeout(s),r(n)},this.ad4mClient&&(this.authState==="authenticated"?(clearTimeout(s),console.log("[Ad4m Connect] Client already initialized in embedded mode"),e(this.ad4mClient)):(clearTimeout(s),r(new Error(`Embedded auth state: ${this.authState}`))))});try{return yield it(this.baseUrl),ce("ad4m-url",this.url),this.ad4mClient=this.buildClient(),yield this.checkAuth(),this.ad4mClient}catch(e){throw console.error("[Ad4m Connect] Connection failed:",e),this.notifyConnectionChange("error"),e}})}buildClient(){return this.notifyConnectionChange("connecting"),this.ad4mClient&&typeof this.ad4mClient.close=="function"&&this.ad4mClient.close(),this.ad4mClient=new nr(this.baseUrl,this.token,!1),this.notifyConnectionChange("connected"),this.ad4mClient}withTempClient(e,r){return L(this,null,function*(){let s=tt(e),n=new nr(s,void 0,!1);try{return yield r(n)}finally{n.close()}})}checkAuth(){return L(this,null,function*(){try{console.log("[Ad4m Connect] Checking authentication status...");let e=!1;try{e=yield this.ad4mClient.agent.isLocked()}catch(r){let s=(r==null?void 0:r.message)||"";if(s==="Cannot extractByTags from a ciphered wallet. You must unlock first.")return console.log("[Ad4m Connect] Agent wallet is locked (error path)"),this.notifyAuthChange("locked"),!0;console.warn("[Ad4m Connect] isLocked check unavailable, assuming unlocked:",s)}return e?(console.log("[Ad4m Connect] Agent wallet is locked"),this.notifyAuthChange("locked")):(yield this.ad4mClient.agent.status(),this.ad4mClient.startSubscriptions(),this.notifyAuthChange("authenticated")),!0}catch(e){return console.error("[Ad4m Connect] Authentication check failed:",e),e.message==="InvalidSignature"&&(console.log("[Ad4m Connect] Clearing invalid token due to InvalidSignature"),this.token="",Xt("ad4m-token")),this.notifyAuthChange("unauthenticated"),!1}})}disconnect(){return L(this,null,function*(){console.log("[Ad4m Connect] Disconnecting..."),this.ad4mClient=void 0,this.token="",Xt("ad4m-token"),this.notifyAuthChange("unauthenticated"),this.connectedHost=null,this.userInfo=null,this.stopCreditPolling(),Xt("ad4m-last-host"),this.notifyConnectionChange("not-connected"),console.log("[Ad4m Connect] Disconnected successfully")})}startCreditSubscription(){if(!!this.ad4mClient){try{this.ad4mClient.agent.addHostingUserInfoChangedListener(e=>{let r={email:e.email,remainingCredits:e.remainingCredits==="unlimited"?1/0:parseFloat(e.remainingCredits)||0,hotWalletAddress:e.hotWalletAddress||null,freeAccess:e.freeAccess};this.userInfo=r,this.dispatchEvent(new CustomEvent("userinfochange",{detail:r})),!r.freeAccess&&r.remainingCredits<=0&&this.dispatchEvent(new CustomEvent("creditdepleted")),!r.freeAccess&&r.remainingCredits<=this.lowCreditThreshold&&this.dispatchEvent(new CustomEvent("creditlow"))}),this.ad4mClient.agent.subscribeHostingUserInfoChanged()}catch(e){console.warn("[Ad4m Connect] Subscription not available, falling back to polling:",e)}try{this.ad4mClient.agent.addComputeLogUpdatedListener(e=>{this.dispatchEvent(new CustomEvent("computelogentry",{detail:e}))}),this.ad4mClient.agent.subscribeComputeLogUpdated()}catch(e){console.warn("[Ad4m Connect] Compute log subscription not available:",e)}this.startCreditPolling()}}startCreditPolling(){this.stopCreditPolling();let e=()=>L(this,null,function*(){try{if(!this.ad4mClient)return;let r=yield Wo(this.ad4mClient);this.userInfo=r,this.dispatchEvent(new CustomEvent("userinfochange",{detail:r})),!r.freeAccess&&r.remainingCredits<=this.lowCreditThreshold&&this.dispatchEvent(new CustomEvent("creditlow")),!r.freeAccess&&r.remainingCredits<=0&&this.dispatchEvent(new CustomEvent("creditdepleted"))}catch(r){console.error("[Ad4m Connect] Credit polling error:",r)}});e(),this.creditPollInterval=setInterval(e,su)}stopCreditPolling(){this.creditPollInterval&&(clearInterval(this.creditPollInterval),this.creditPollInterval=null)}requestTopUp(e){return L(this,null,function*(){if(!this.ad4mClient)throw new Error("Not connected");return Bo(this.ad4mClient,e)})}fetchComputeLog(e,r){return L(this,null,function*(){if(!this.ad4mClient)throw new Error("Not connected");return this.ad4mClient.agent.computeLog(e,r)})}setConnectedHost(e){this.connectedHost=e,ce("ad4m-last-host",JSON.stringify({id:e.id,url:e.url,name:e.name,location:e.location}))}initializeEmbeddedMode(){var s;console.log("[Ad4m Connect] Running in embedded mode - waiting for AD4M config from parent"),window.addEventListener("message",n=>L(this,null,function*(){var a;if(((a=n.data)==null?void 0:a.type)==="AD4M_CONFIG"){if(n.source!==window.parent){console.warn("[Ad4m Connect] Rejected AD4M_CONFIG from invalid source (not parent window)");return}if(this.options.allowedOrigins&&this.options.allowedOrigins.length>0&&(!n.origin||!this.options.allowedOrigins.includes(n.origin))){console.warn("[Ad4m Connect] Rejected AD4M_CONFIG from unauthorized origin:",n.origin),this.rejectEmbedded(new Error(`Unauthorized origin: ${n.origin}`));return}console.log("[Ad4m Connect] Received AD4M_CONFIG from parent:",{port:n.data.port,hasToken:!!n.data.token});let{port:o,token:c}=n.data;if(o==null){let g=new Error("AD4M_CONFIG missing required field: port");console.error("[Ad4m Connect]",g.message),this.rejectEmbedded(g);return}let l=parseInt(o,10);if(!Number.isFinite(l)||l<=0){let g=new Error(`AD4M_CONFIG invalid port: ${o} (must be a positive integer)`);console.error("[Ad4m Connect]",g.message),this.rejectEmbedded(g);return}let d=c!=null&&typeof c=="string"?c:"";try{this.port=l,this.token=d,this.url=`http://localhost:${l}`,ce("ad4m-port",l.toString()),d?ce("ad4m-token",d):Xt("ad4m-token"),ce("ad4m-url",this.url),this.ad4mClient=this.buildClient(),yield this.checkAuth()}catch(g){console.error("[Ad4m Connect] Failed to initialize from AD4M_CONFIG:",g),this.rejectEmbedded(g)}}})),console.log("[Ad4m Connect] Requesting AD4M config from parent window");let e="*",r=document.referrer?new URL(document.referrer).origin:null;r&&((s=this.options.allowedOrigins)==null?void 0:s.includes(r))?e=r:this.options.allowedOrigins&&this.options.allowedOrigins.length===1&&(e=this.options.allowedOrigins[0]),window.parent.postMessage({type:"REQUEST_AD4M_CONFIG"},e)}buildAppInfo(){return{appName:this.options.appInfo.name,appDesc:this.options.appInfo.description,appDomain:this.options.appInfo.url,appUrl:window.location.origin,appIconPath:this.options.appInfo.iconPath}}requestCapability(e=!1){return L(this,null,function*(){return e&&(this.token="",Xt("ad4m-token"),this.notifyConfigChange("token",this.token)),this.requestId=yield this.ad4mClient.agent.requestCapability({appName:this.options.appInfo.name,appDesc:this.options.appInfo.description,appUrl:this.options.appInfo.url,appDomain:this.options.appInfo.url,appIconPath:this.options.appInfo.iconPath,capabilities:this.options.capabilities}),this.requestId})}verifyLocalAd4mCode(e){return L(this,null,function*(){if(!this.requestId)return console.error("[Ad4m Connect] Cannot verify code: requestId is missing. Call requestCapability() first to obtain a requestId."),!1;try{let r=yield this.ad4mClient.agent.generateJwt(this.requestId,e);return this.token=r,ce("ad4m-token",this.token),yield this.connect(),!0}catch(r){return console.error("[Ad4m Connect] Code verification failed:",r),!1}})}isValidAd4mAPI(){return L(this,null,function*(){try{return yield this.withTempClient(this.url,e=>L(this,null,function*(){return yield e.runtime.info()})),!0}catch(e){return console.error("[Ad4m Connect] Failed to verify AD4M API:",e),!1}})}isMultiUser(){return L(this,null,function*(){try{return yield this.withTempClient(this.url,e=>L(this,null,function*(){return yield e.runtime.multiUserEnabled()}))}catch(e){return console.error("[Ad4m Connect] Failed to detect multi-user mode:",e),!1}})}submitEmail(e){return L(this,null,function*(){try{return yield this.withTempClient(this.url,r=>L(this,null,function*(){return yield r.agent.requestLoginVerification(e,this.buildAppInfo())}))}catch(r){return{success:!1,message:r.message||"Failed to process email. Please try again.",requiresPassword:!1,isExistingUser:!1}}})}verifyEmailCode(e,r){return L(this,null,function*(){try{let s=yield this.withTempClient(this.url,n=>L(this,null,function*(){return yield n.agent.verifyEmailCode(e,r,"login")}));return this.token=s,ce("ad4m-token",this.token),yield this.connect(),!0}catch(s){return console.error("[Ad4m Connect] Email code verification failed:",s),!1}})}loginWithPassword(e,r){return L(this,null,function*(){try{let s=yield this.withTempClient(this.url,n=>L(this,null,function*(){return yield n.agent.loginUser(e,r)}));return this.token=s,ce("ad4m-token",this.token),yield this.connect(),!0}catch(s){return console.error("[Ad4m Connect] Password login failed:",s),!1}})}createAccount(e,r){return L(this,null,function*(){try{let s=yield this.withTempClient(this.url,n=>L(this,null,function*(){let a=yield n.agent.createUser(e,r);if(a.success)return yield n.agent.loginUser(e,r);throw new Error(a.error||"Failed to create account")}));return this.token=s,ce("ad4m-token",this.token),yield this.connect(),!0}catch(s){return console.error("[Ad4m Connect] Account creation error:",s),!1}})}resolveEmbedded(e){this.embeddedResolve&&(this.embeddedResolve(e),this.embeddedResolve=void 0,this.embeddedReject=void 0)}rejectEmbedded(e){this.embeddedReject&&(this.embeddedReject(e),this.embeddedResolve=void 0,this.embeddedReject=void 0)}notifyConnectionChange(e){this.connectionState!==e&&(this.connectionState=e,this.dispatchEvent(new CustomEvent("connectionstatechange",{detail:e})))}notifyAuthChange(e){if(this.authState=e,this.dispatchEvent(new CustomEvent("authstatechange",{detail:e})),this.embedded&&(e==="authenticated"&&this.resolveEmbedded(this.ad4mClient),e==="unauthenticated"||e==="locked")){let r=e==="locked"?"Authentication failed: Agent is locked":"Authentication failed: Unauthenticated";this.rejectEmbedded(new Error(r))}}notifyConfigChange(e,r){this.dispatchEvent(new CustomEvent("configstatechange",{detail:{type:e,value:r}}))}};var Xr=window,Yr=Xr.ShadowRoot&&(Xr.ShadyCSS===void 0||Xr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,hn=Symbol(),qo=new WeakMap,pr=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==hn)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(Yr&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=qo.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&qo.set(e,t))}return t}toString(){return this.cssText}},Zo=i=>new pr(typeof i=="string"?i:i+"",void 0,hn),re=(i,...t)=>{let e=i.length===1?i[0]:t.reduce((r,s,n)=>r+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+i[n+1],i[0]);return new pr(e,i,hn)},un=(i,t)=>{Yr?i.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):t.forEach(e=>{let r=document.createElement("style"),s=Xr.litNonce;s!==void 0&&r.setAttribute("nonce",s),r.textContent=e.cssText,i.appendChild(r)})},es=Yr?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return Zo(e)})(i):i;var pn,ts=window,Vo=ts.trustedTypes,au=Vo?Vo.emptyScript:"",Jo=ts.reactiveElementPolyfillSupport,gn={toAttribute(i,t){switch(t){case Boolean:i=i?au:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,t){let e=i;switch(t){case Boolean:e=i!==null;break;case Number:e=i===null?null:Number(i);break;case Object:case Array:try{e=JSON.parse(i)}catch{e=null}}return e}},Qo=(i,t)=>t!==i&&(t==t||i==i),fn={attribute:!0,type:String,converter:gn,reflect:!1,hasChanged:Qo},mn="finalized",Ye=class extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var e;this.finalize(),((e=this.h)!==null&&e!==void 0?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();let t=[];return this.elementProperties.forEach((e,r)=>{let s=this._$Ep(r,e);s!==void 0&&(this._$Ev.set(s,r),t.push(s))}),t}static createProperty(t,e=fn){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){let r=typeof t=="symbol"?Symbol():"__"+t,s=this.getPropertyDescriptor(t,r,e);s!==void 0&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,r){return{get(){return this[e]},set(s){let n=this[t];this[e]=s,this.requestUpdate(t,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||fn}static finalize(){if(this.hasOwnProperty(mn))return!1;this[mn]=!0;let t=Object.getPrototypeOf(this);if(t.finalize(),t.h!==void 0&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){let e=this.properties,r=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(let s of r)this.createProperty(s,e[s])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let s of r)e.unshift(es(s))}else t!==void 0&&e.push(es(t));return e}static _$Ep(t,e){let r=e.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$Eg(),this.requestUpdate(),(t=this.constructor.h)===null||t===void 0||t.forEach(e=>e(this))}addController(t){var e,r;((e=this._$ES)!==null&&e!==void 0?e:this._$ES=[]).push(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)===null||r===void 0||r.call(t))}removeController(t){var e;(e=this._$ES)===null||e===void 0||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])})}createRenderRoot(){var t;let e=(t=this.shadowRoot)!==null&&t!==void 0?t:this.attachShadow(this.constructor.shadowRootOptions);return un(e,this.constructor.elementStyles),e}connectedCallback(){var t;this.renderRoot===void 0&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)===null||t===void 0||t.forEach(e=>{var r;return(r=e.hostConnected)===null||r===void 0?void 0:r.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)===null||t===void 0||t.forEach(e=>{var r;return(r=e.hostDisconnected)===null||r===void 0?void 0:r.call(e)})}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$EO(t,e,r=fn){var s;let n=this.constructor._$Ep(t,r);if(n!==void 0&&r.reflect===!0){let a=(((s=r.converter)===null||s===void 0?void 0:s.toAttribute)!==void 0?r.converter:gn).toAttribute(e,r.type);this._$El=t,a==null?this.removeAttribute(n):this.setAttribute(n,a),this._$El=null}}_$AK(t,e){var r;let s=this.constructor,n=s._$Ev.get(t);if(n!==void 0&&this._$El!==n){let a=s.getPropertyOptions(n),o=typeof a.converter=="function"?{fromAttribute:a.converter}:((r=a.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?a.converter:gn;this._$El=n,this[n]=o.fromAttribute(e,a.type),this._$El=null}}requestUpdate(t,e,r){let s=!0;t!==void 0&&(((r=r||this.constructor.getPropertyOptions(t)).hasChanged||Qo)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),r.reflect===!0&&this._$El!==t&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(t,r))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach((s,n)=>this[n]=s),this._$Ei=void 0);let e=!1,r=this._$AL;try{e=this.shouldUpdate(r),e?(this.willUpdate(r),(t=this._$ES)===null||t===void 0||t.forEach(s=>{var n;return(n=s.hostUpdate)===null||n===void 0?void 0:n.call(s)}),this.update(r)):this._$Ek()}catch(s){throw e=!1,this._$Ek(),s}e&&this._$AE(r)}willUpdate(t){}_$AE(t){var e;(e=this._$ES)===null||e===void 0||e.forEach(r=>{var s;return(s=r.hostUpdated)===null||s===void 0?void 0:s.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){this._$EC!==void 0&&(this._$EC.forEach((e,r)=>this._$EO(r,this[r],e)),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}};Ye[mn]=!0,Ye.elementProperties=new Map,Ye.elementStyles=[],Ye.shadowRootOptions={mode:"open"},Jo?.({ReactiveElement:Ye}),((pn=ts.reactiveElementVersions)!==null&&pn!==void 0?pn:ts.reactiveElementVersions=[]).push("1.6.3");var wn,is=window,fi=is.trustedTypes,Ko=fi?fi.createPolicy("lit-html",{createHTML:i=>i}):void 0,bn="$lit$",yt=`lit$${(Math.random()+"").slice(9)}$`,rl="?"+yt,ou=`<${rl}>`,Vt=document,gr=()=>Vt.createComment(""),mr=i=>i===null||typeof i!="object"&&typeof i!="function",sl=Array.isArray,lu=i=>sl(i)||typeof i?.[Symbol.iterator]=="function",yn=`[
147
+ \f\r]`,fr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Go=/-->/g,Xo=/>/g,qt=RegExp(`>|${yn}(?:([^\\s"'>=/]+)(${yn}*=${yn}*(?:[^
148
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Yo=/'/g,el=/"/g,nl=/^(?:script|style|textarea|title)$/i,al=i=>(t,...e)=>({_$litType$:i,strings:t,values:e}),y=al(1),Uu=al(2),Jt=Symbol.for("lit-noChange"),ae=Symbol.for("lit-nothing"),tl=new WeakMap,Zt=Vt.createTreeWalker(Vt,129,null,!1);function ol(i,t){if(!Array.isArray(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ko!==void 0?Ko.createHTML(t):t}var cu=(i,t)=>{let e=i.length-1,r=[],s,n=t===2?"<svg>":"",a=fr;for(let o=0;o<e;o++){let c=i[o],l,d,g=-1,p=0;for(;p<c.length&&(a.lastIndex=p,d=a.exec(c),d!==null);)p=a.lastIndex,a===fr?d[1]==="!--"?a=Go:d[1]!==void 0?a=Xo:d[2]!==void 0?(nl.test(d[2])&&(s=RegExp("</"+d[2],"g")),a=qt):d[3]!==void 0&&(a=qt):a===qt?d[0]===">"?(a=s??fr,g=-1):d[1]===void 0?g=-2:(g=a.lastIndex-d[2].length,l=d[1],a=d[3]===void 0?qt:d[3]==='"'?el:Yo):a===el||a===Yo?a=qt:a===Go||a===Xo?a=fr:(a=qt,s=void 0);let h=a===qt&&i[o+1].startsWith("/>")?" ":"";n+=a===fr?c+ou:g>=0?(r.push(l),c.slice(0,g)+bn+c.slice(g)+yt+h):c+yt+(g===-2?(r.push(void 0),o):h)}return[ol(i,n+(i[e]||"<?>")+(t===2?"</svg>":"")),r]},Qt=class{constructor({strings:t,_$litType$:e},r){let s;this.parts=[];let n=0,a=0,o=t.length-1,c=this.parts,[l,d]=cu(t,e);if(this.el=Qt.createElement(l,r),Zt.currentNode=this.el.content,e===2){let g=this.el.content,p=g.firstChild;p.remove(),g.append(...p.childNodes)}for(;(s=Zt.nextNode())!==null&&c.length<o;){if(s.nodeType===1){if(s.hasAttributes()){let g=[];for(let p of s.getAttributeNames())if(p.endsWith(bn)||p.startsWith(yt)){let h=d[a++];if(g.push(p),h!==void 0){let u=s.getAttribute(h.toLowerCase()+bn).split(yt),f=/([.?@])?(.*)/.exec(h);c.push({type:1,index:n,name:f[2],strings:u,ctor:f[1]==="."?_n:f[1]==="?"?xn:f[1]==="@"?Cn:mi})}else c.push({type:6,index:n})}for(let p of g)s.removeAttribute(p)}if(nl.test(s.tagName)){let g=s.textContent.split(yt),p=g.length-1;if(p>0){s.textContent=fi?fi.emptyScript:"";for(let h=0;h<p;h++)s.append(g[h],gr()),Zt.nextNode(),c.push({type:2,index:++n});s.append(g[p],gr())}}}else if(s.nodeType===8)if(s.data===rl)c.push({type:2,index:n});else{let g=-1;for(;(g=s.data.indexOf(yt,g+1))!==-1;)c.push({type:7,index:n}),g+=yt.length-1}n++}}static createElement(t,e){let r=Vt.createElement("template");return r.innerHTML=t,r}};function gi(i,t,e=i,r){var s,n,a,o;if(t===Jt)return t;let c=r!==void 0?(s=e._$Co)===null||s===void 0?void 0:s[r]:e._$Cl,l=mr(t)?void 0:t._$litDirective$;return c?.constructor!==l&&((n=c?._$AO)===null||n===void 0||n.call(c,!1),l===void 0?c=void 0:(c=new l(i),c._$AT(i,e,r)),r!==void 0?((a=(o=e)._$Co)!==null&&a!==void 0?a:o._$Co=[])[r]=c:e._$Cl=c),c!==void 0&&(t=gi(i,c._$AS(i,t.values),c,r)),t}var vn=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;let{el:{content:r},parts:s}=this._$AD,n=((e=t?.creationScope)!==null&&e!==void 0?e:Vt).importNode(r,!0);Zt.currentNode=n;let a=Zt.nextNode(),o=0,c=0,l=s[0];for(;l!==void 0;){if(o===l.index){let d;l.type===2?d=new Kt(a,a.nextSibling,this,t):l.type===1?d=new l.ctor(a,l.name,l.strings,this,t):l.type===6&&(d=new Sn(a,this,t)),this._$AV.push(d),l=s[++c]}o!==l?.index&&(a=Zt.nextNode(),o++)}return Zt.currentNode=Vt,n}v(t){let e=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}},Kt=class{constructor(t,e,r,s){var n;this.type=2,this._$AH=ae,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=s,this._$Cp=(n=s?.isConnected)===null||n===void 0||n}get _$AU(){var t,e;return(e=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&e!==void 0?e:this._$Cp}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=gi(this,t,e),mr(t)?t===ae||t==null||t===""?(this._$AH!==ae&&this._$AR(),this._$AH=ae):t!==this._$AH&&t!==Jt&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):lu(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==ae&&mr(this._$AH)?this._$AA.nextSibling.data=t:this.$(Vt.createTextNode(t)),this._$AH=t}g(t){var e;let{values:r,_$litType$:s}=t,n=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=Qt.createElement(ol(s.h,s.h[0]),this.options)),s);if(((e=this._$AH)===null||e===void 0?void 0:e._$AD)===n)this._$AH.v(r);else{let a=new vn(n,this),o=a.u(this.options);a.v(r),this.$(o),this._$AH=a}}_$AC(t){let e=tl.get(t.strings);return e===void 0&&tl.set(t.strings,e=new Qt(t)),e}T(t){sl(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,r,s=0;for(let n of t)s===e.length?e.push(r=new Kt(this.k(gr()),this.k(gr()),this,this.options)):r=e[s],r._$AI(n),s++;s<e.length&&(this._$AR(r&&r._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var r;for((r=this._$AP)===null||r===void 0||r.call(this,!1,!0,e);t&&t!==this._$AB;){let s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cp=t,(e=this._$AP)===null||e===void 0||e.call(this,t))}},mi=class{constructor(t,e,r,s,n){this.type=1,this._$AH=ae,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=n,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ae}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,r,s){let n=this.strings,a=!1;if(n===void 0)t=gi(this,t,e,0),a=!mr(t)||t!==this._$AH&&t!==Jt,a&&(this._$AH=t);else{let o=t,c,l;for(t=n[0],c=0;c<n.length-1;c++)l=gi(this,o[r+c],e,c),l===Jt&&(l=this._$AH[c]),a||(a=!mr(l)||l!==this._$AH[c]),l===ae?t=ae:t!==ae&&(t+=(l??"")+n[c+1]),this._$AH[c]=l}a&&!s&&this.j(t)}j(t){t===ae?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},_n=class extends mi{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===ae?void 0:t}},du=fi?fi.emptyScript:"",xn=class extends mi{constructor(){super(...arguments),this.type=4}j(t){t&&t!==ae?this.element.setAttribute(this.name,du):this.element.removeAttribute(this.name)}},Cn=class extends mi{constructor(t,e,r,s,n){super(t,e,r,s,n),this.type=5}_$AI(t,e=this){var r;if((t=(r=gi(this,t,e,0))!==null&&r!==void 0?r:ae)===Jt)return;let s=this._$AH,n=t===ae&&s!==ae||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,a=t!==ae&&(s===ae||n);n&&this.element.removeEventListener(this.name,this,s),a&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,r;typeof this._$AH=="function"?this._$AH.call((r=(e=this.options)===null||e===void 0?void 0:e.host)!==null&&r!==void 0?r:this.element,t):this._$AH.handleEvent(t)}},Sn=class{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){gi(this,t)}};var il=is.litHtmlPolyfillSupport;il?.(Qt,Kt),((wn=is.litHtmlVersions)!==null&&wn!==void 0?wn:is.litHtmlVersions=[]).push("2.8.0");var ll=(i,t,e)=>{var r,s;let n=(r=e?.renderBefore)!==null&&r!==void 0?r:t,a=n._$litPart$;if(a===void 0){let o=(s=e?.renderBefore)!==null&&s!==void 0?s:null;n._$litPart$=a=new Kt(t.insertBefore(gr(),o),o,void 0,e??{})}return a._$AI(i),a};var kn,$n;var Y=class extends Ye{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;let r=super.createRenderRoot();return(t=(e=this.renderOptions).renderBefore)!==null&&t!==void 0||(e.renderBefore=r.firstChild),r}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=ll(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)===null||t===void 0||t.setConnected(!1)}render(){return Jt}};Y.finalized=!0,Y._$litElement$=!0,(kn=globalThis.litElementHydrateSupport)===null||kn===void 0||kn.call(globalThis,{LitElement:Y});var cl=globalThis.litElementPolyfillSupport;cl?.({LitElement:Y});(($n=globalThis.litElementVersions)!==null&&$n!==void 0?$n:globalThis.litElementVersions=[]).push("3.3.3");var de=i=>t=>typeof t=="function"?((e,r)=>(customElements.define(e,r),r))(i,t):((e,r)=>{let{kind:s,elements:n}=r;return{kind:s,elements:n,finisher(a){customElements.define(e,a)}}})(i,t);var hu=(i,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?{...t,finisher(e){e.createProperty(t.key,i)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(e){e.createProperty(t.key,i)}},uu=(i,t,e)=>{t.constructor.createProperty(e,i)};function W(i){return(t,e)=>e!==void 0?uu(i,t,e):hu(i,t)}function j(i){return W({...i,state:!0})}var An,dp=((An=window.HTMLSlotElement)===null||An===void 0?void 0:An.prototype.assignedElements)!=null?(i,t)=>i.assignedElements(t):(i,t)=>i.assignedNodes(t).filter(e=>e.nodeType===Node.ELEMENT_NODE);function Gt(){return y`
1720
149
  <svg viewBox="0 0 63.6 60" fill="none" xmlns="http://www.w3.org/2000/svg">
1721
150
  <path fill="currentColor" d="M63.2781 52.9928C62.4038 47.0393 59.8345 41.4763 55.9242 36.935C55.9403 36.5766 55.951 36.2182 55.951 35.8545C55.951 26.6328 50.7373 18.6039 43.0937 14.5333C41.093 9.35009 37.7352 4.72854 33.2402 1.14469L31.7705 0L30.2793 1.10725L30.2096 1.16074C25.7253 4.74458 22.3729 9.36079 20.3775 14.5386C12.7339 18.6039 7.52021 26.6328 7.52021 35.8599C7.52021 36.2236 7.53094 36.582 7.54703 36.9404C3.6421 41.471 1.06742 47.034 0.198465 52.9874L0 54.9131L1.70036 55.5817C5.40683 57.0313 9.32249 57.7695 13.3401 57.7695C15.668 57.7695 17.9369 57.5127 20.1254 57.0366C23.5744 58.9248 27.533 60 31.7383 60C35.9436 60 39.9022 58.9248 43.3512 57.0366C45.5397 57.5127 47.8086 57.7695 50.1365 57.7695C54.1541 57.7695 58.0698 57.0366 61.7762 55.5817L63.5624 54.881L63.2835 52.9874L63.2781 52.9928ZM42.5734 51.8802C40.0792 51.1581 37.7352 50.0829 35.595 48.7189C39.752 44.675 42.8041 39.5079 44.263 33.7202C46.1297 34.6938 47.8891 35.8866 49.4982 37.288C49.9917 37.716 50.4637 38.1653 50.9197 38.6253C50.1258 44.1294 46.9986 48.8954 42.568 51.8855L42.5734 51.8802ZM12.5516 38.62C13.0075 38.1599 13.4849 37.716 13.973 37.288C15.5822 35.8866 17.3415 34.6938 19.2082 33.7202C20.6672 39.5079 23.7192 44.675 27.8763 48.7189C25.7361 50.0829 23.392 51.1527 20.8978 51.8802C16.4672 48.8901 13.3401 44.1241 12.5462 38.62H12.5516ZM40.3957 25.9802C40.3957 26.3332 40.3903 26.6809 40.3742 27.0286C37.585 26.2477 34.6831 25.8411 31.7383 25.8411C28.7935 25.8411 25.8916 26.2477 23.1024 27.0286C23.0917 26.6809 23.0809 26.3279 23.0809 25.9802C23.0809 23.2362 23.494 20.5563 24.2825 18.0102C26.5782 17.0527 29.0993 16.5231 31.7383 16.5231C34.3773 16.5231 36.8984 17.0527 39.1941 18.0102C39.9826 20.5563 40.3957 23.2362 40.3957 25.9802ZM23.73 31.8641C26.3047 31.0671 29.0027 30.6553 31.7383 30.6553C34.4739 30.6553 37.1719 31.0671 39.7466 31.8641C38.5344 37.2827 35.6808 42.0915 31.7383 45.7395C27.7958 42.0861 24.9422 37.2773 23.73 31.8641ZM50.7641 32.1262C48.9887 30.8104 47.0898 29.6817 45.0998 28.7671C45.1803 27.847 45.2232 26.9163 45.2232 25.9802C45.2232 24.536 45.1266 23.1131 44.9335 21.7063C47.8676 24.4343 49.9595 28.0503 50.7641 32.1262ZM31.7383 6.19417C33.6639 7.97005 35.2946 9.99198 36.6087 12.1904C35.0371 11.8695 33.4065 11.6983 31.7383 11.6983C30.0701 11.6983 28.4395 11.8695 26.8679 12.1904C28.182 9.99198 29.8127 7.97005 31.7383 6.19417ZM18.5431 21.701C18.3553 23.1078 18.2534 24.5306 18.2534 25.9749C18.2534 26.9163 18.2963 27.8417 18.3768 28.7617C16.3868 29.6764 14.4879 30.805 12.7125 32.1209C13.5171 28.0449 15.6036 24.429 18.5377 21.701H18.5431ZM5.33173 51.7518C5.9915 48.7938 7.15547 45.9802 8.74855 43.418C9.95007 47.034 11.9776 50.2808 14.622 52.9179C14.1983 52.9393 13.7692 52.95 13.3401 52.95C10.5991 52.95 7.91178 52.5488 5.32637 51.7465L5.33173 51.7518ZM31.7383 55.1859C30.1506 55.1859 28.6058 54.988 27.1307 54.6296C28.7452 53.854 30.29 52.95 31.7383 51.923C33.1866 52.95 34.7314 53.854 36.3459 54.6296C34.8655 54.988 33.326 55.1859 31.7383 55.1859ZM50.1365 52.95C49.7074 52.95 49.2783 52.9339 48.8546 52.9179C51.499 50.2808 53.5265 47.0393 54.728 43.4234C56.3211 45.9802 57.4851 48.7938 58.1449 51.7518C55.5648 52.5488 52.8775 52.95 50.1365 52.95Z" />
1722
151
  </svg>
1723
- `}function Ea(){return P`
152
+ `}function wi(){return y`
1724
153
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
1725
154
  <circle cx="12" cy="12" r="10"></circle>
1726
155
  <circle cx="12" cy="12" r="3" fill="currentColor"></circle>
1727
156
  </svg>
1728
- `}function el(){return P`
157
+ `}function rs(){return y`
1729
158
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
1730
159
  <circle cx="12" cy="12" r="10"></circle>
1731
160
  <path d="M2 12h20"></path>
1732
161
  <path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path>
1733
162
  </svg>
1734
- `}function tl(){return P`
163
+ `}function ss(){return y`
1735
164
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1736
165
  <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
1737
166
  <polyline points="7 10 12 15 17 10"></polyline>
1738
167
  <line x1="12" y1="15" x2="12" y2="3"></line>
1739
168
  </svg>
1740
- `}function Ot(){return P`
169
+ `}function ve(){return y`
1741
170
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
1742
171
  <rect width="256" height="256" fill="none"/>
1743
172
  <polyline points="40 144 96 200 224 72" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
1744
173
  </svg>
1745
- `}function wt(){return P`
174
+ `}function fe(){return y`
1746
175
  <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256">
1747
176
  <path d="M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z"></path>
1748
177
  </svg>
1749
- `}function rl(){return P`
178
+ `}function ns(){return y`
1750
179
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-clockwise" viewBox="0 0 16 16">
1751
180
  <path fill-rule="evenodd" d="M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2z"/>
1752
181
  <path d="M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 4.658A.25.25 0 0 1 8 4.466"/>
1753
182
  </svg>
1754
- `}function il(){return P`
183
+ `}function as(){return y`
1755
184
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left-right" viewBox="0 0 16 16">
1756
185
  <path fill-rule="evenodd" d="M1 11.5a.5.5 0 0 0 .5.5h11.793l-3.147 3.146a.5.5 0 0 0 .708.708l4-4a.5.5 0 0 0 0-.708l-4-4a.5.5 0 0 0-.708.708L13.293 11H1.5a.5.5 0 0 0-.5.5m14-7a.5.5 0 0 1-.5.5H2.707l3.147 3.146a.5.5 0 1 1-.708.708l-4-4a.5.5 0 0 1 0-.708l4-4a.5.5 0 1 1 .708.708L2.707 4H14.5a.5.5 0 0 1 .5.5"/>
1757
186
  </svg>
1758
- `}function nl(){return P`
187
+ `}function os(){return y`
1759
188
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
1760
189
  <path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8"/>
1761
190
  </svg>
1762
- `}function al(){return P`
191
+ `}function ls(){return y`
1763
192
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
1764
193
  <circle cx="12" cy="12" r="10"></circle>
1765
194
  <path d="M2 12h20"></path>
1766
195
  <path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path>
1767
196
  </svg>
1768
- `}function Ei(){return P`
197
+ `}function bt(){return y`
1769
198
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
1770
199
  <circle cx="12" cy="12" r="10"></circle>
1771
200
  <path d="M12 6v12"></path>
1772
201
  <path d="M15.5 9.5a3 3 0 0 0-3-2.5H11a3 3 0 0 0 0 6h2a3 3 0 0 1 0 6h-1.5a3 3 0 0 1-3-2.5"></path>
1773
202
  </svg>
1774
- `}function ol(){return P`
203
+ `}function cs(){return y`
1775
204
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
1776
205
  <rect x="2" y="6" width="20" height="14" rx="2"></rect>
1777
206
  <path d="M2 10h20"></path>
1778
207
  <circle cx="16" cy="14" r="1" fill="currentColor"></circle>
1779
208
  </svg>
1780
- `}function ki(){return P`
209
+ `}function vt(){return y`
1781
210
  <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16">
1782
211
  <path d="M8 16s6-5.686 6-10A6 6 0 0 0 2 6c0 4.314 6 10 6 10m0-7a3 3 0 1 1 0-6 3 3 0 0 1 0 6"/>
1783
212
  </svg>
1784
- `}var $t=Ge`
213
+ `}var _e=re`
1785
214
  * {
1786
215
  box-sizing: border-box;
1787
216
  }
@@ -2084,7 +513,7 @@ input VoiceActivityParamsInput {
2084
513
  @keyframes spin {
2085
514
  to { transform: rotate(360deg); }
2086
515
  }
2087
- `;var jt=class extends Me{constructor(){super(...arguments);this.showHosting=!1;this.loading=!0;this.localNodeDetected=!1;this.newPort=0;this.isMobile=!1;this.checkMobile=()=>{this.isMobile=window.innerWidth<800}}changePort(){return V(this,null,function*(){this.dispatchEvent(new CustomEvent("change-port",{detail:{port:this.newPort},bubbles:!0,composed:!0}))})}connectLocalNode(){return V(this,null,function*(){this.dispatchEvent(new CustomEvent("connect-local-node",{bubbles:!0,composed:!0}))})}browseHosts(){this.dispatchEvent(new CustomEvent("browse-hosts",{bubbles:!0,composed:!0}))}detectLocalNode(){return V(this,null,function*(){try{yield Mi(`ws://localhost:${this.newPort}/graphql`,3e3),this.localNodeDetected=!0}catch(t){console.log("[Ad4m Connect] Local detection failed:",t),this.localNodeDetected=!1}})}refreshPort(){this.changePort(),this.detectLocalNode()}connectedCallback(){return V(this,null,function*(){Yp(jt.prototype,this,"connectedCallback").call(this),this.newPort=this.port,this.checkMobile(),window.addEventListener("resize",this.checkMobile),yield this.detectLocalNode(),this.loading=!1})}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.checkMobile)}willUpdate(t){t.has("port")&&(this.newPort=this.port)}render(){return this.loading?null:P`
516
+ `;var Se=class extends Y{constructor(){super(...arguments);this.showHosting=!1;this.loading=!0;this.localNodeDetected=!1;this.newPort=0;this.isMobile=!1;this.checkMobile=()=>{this.isMobile=window.innerWidth<800}}changePort(){return L(this,null,function*(){this.dispatchEvent(new CustomEvent("change-port",{detail:{port:this.newPort},bubbles:!0,composed:!0}))})}connectLocalNode(){return L(this,null,function*(){this.dispatchEvent(new CustomEvent("connect-local-node",{bubbles:!0,composed:!0}))})}browseHosts(){this.dispatchEvent(new CustomEvent("browse-hosts",{bubbles:!0,composed:!0}))}detectLocalNode(){return L(this,null,function*(){try{try{yield it(`http://127.0.0.1:${this.newPort}`,3e3)}catch(e){yield it(`http://localhost:${this.newPort}`,3e3)}this.localNodeDetected=!0}catch(e){console.log("[Ad4m Connect] Local detection failed:",e),this.localNodeDetected=!1}})}refreshPort(){this.changePort(),this.detectLocalNode()}connectedCallback(){return L(this,null,function*(){Rn(Se.prototype,this,"connectedCallback").call(this),this.newPort=this.port,this.checkMobile(),window.addEventListener("resize",this.checkMobile),yield this.detectLocalNode(),this.loading=!1})}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.checkMobile)}willUpdate(e){e.has("port")&&(this.newPort=this.port)}render(){return this.loading?null:y`
2088
517
  <div class="container">
2089
518
  <div class="header">
2090
519
  <h1>Connect AD4M</h1>
@@ -2092,31 +521,31 @@ input VoiceActivityParamsInput {
2092
521
  </div>
2093
522
 
2094
523
  <div class="options">
2095
- ${!this.isMobile||!this.showHosting?P`
524
+ ${!this.isMobile||!this.showHosting?y`
2096
525
  <div class="box">
2097
526
  <div class="box-header">
2098
- ${Ea()}
527
+ ${wi()}
2099
528
  <h3>Local Node</h3>
2100
529
  </div>
2101
530
 
2102
- ${this.localNodeDetected?P`
531
+ ${this.localNodeDetected?y`
2103
532
  <div class="state success">
2104
- ${Ot()}
533
+ ${ve()}
2105
534
  <p>Local node detected on port ${this.port}</p>
2106
535
  </div>
2107
536
 
2108
537
  <button class="primary" @click=${this.connectLocalNode}>
2109
538
  Connect to Local Node
2110
539
  </button>
2111
- `:P`
540
+ `:y`
2112
541
  <div class="state danger">
2113
- ${wt()}
542
+ ${fe()}
2114
543
  <p>No local node detected on port ${this.port}</p>
2115
544
  </div>
2116
545
 
2117
546
  <p style="margin-bottom: -12px">Download and install AD4M</p>
2118
547
  <button class="secondary" @click=${()=>window.open("https://github.com/coasys/ad4m/releases")}>
2119
- ${tl()} Download AD4M
548
+ ${ss()} Download AD4M
2120
549
  </button>
2121
550
  `}
2122
551
 
@@ -2126,20 +555,20 @@ input VoiceActivityParamsInput {
2126
555
  type="number"
2127
556
  placeholder="Port number..."
2128
557
  .value=${this.newPort!=null?this.newPort.toString():""}
2129
- @input=${t=>{let i=t.target,n=Number.parseInt(i.value,10);Number.isFinite(n)&&(this.newPort=n)}}
2130
- @keydown=${t=>{t.key==="Enter"&&this.refreshPort()}}
558
+ @input=${e=>{let r=e.target,s=Number.parseInt(r.value,10);Number.isFinite(s)&&(this.newPort=s)}}
559
+ @keydown=${e=>{e.key==="Enter"&&this.refreshPort()}}
2131
560
  />
2132
561
  <button class="primary" @click=${this.refreshPort}>
2133
- ${rl()}
562
+ ${ns()}
2134
563
  </button>
2135
564
  </div>
2136
565
  </div>
2137
566
  `:""}
2138
567
 
2139
- ${this.showHosting?P`
568
+ ${this.showHosting?y`
2140
569
  <div class="box">
2141
570
  <div class="box-header">
2142
- ${al()}
571
+ ${ls()}
2143
572
  <h3>Remote Node</h3>
2144
573
  </div>
2145
574
 
@@ -2152,7 +581,7 @@ input VoiceActivityParamsInput {
2152
581
  `:""}
2153
582
  </div>
2154
583
  </div>
2155
- `}};jt.styles=[$t,Ge`
584
+ `}};Se.styles=[_e,re`
2156
585
  .options {
2157
586
  display: flex;
2158
587
  flex-direction: column;
@@ -2181,7 +610,7 @@ input VoiceActivityParamsInput {
2181
610
  button {
2182
611
  width: 100%;
2183
612
  }
2184
- `],F([pe({type:Number})],jt.prototype,"port",2),F([pe({type:Boolean})],jt.prototype,"showHosting",2),F([te()],jt.prototype,"loading",2),F([te()],jt.prototype,"localNodeDetected",2),F([te()],jt.prototype,"newPort",2),F([te()],jt.prototype,"isMobile",2),jt=F([ut("connection-options")],jt);var Zt=class extends Me{constructor(){super(...arguments);this.capabilities=[];this.appname="";this.appiconpath="";this.verificationError=!1;this.requestSent=!1;this.securityCode="";this.verifying=!1}willUpdate(t){t.has("verificationError")&&this.verificationError&&(this.verifying=!1)}requestCapability(){this.dispatchEvent(new CustomEvent("request-capability",{bubbles:!0,composed:!0})),this.requestSent=!0}verifyCode(){this.verifying=!0,this.dispatchEvent(new CustomEvent("verify-code",{detail:{code:this.securityCode},bubbles:!0,composed:!0}))}onInputChange(t){this.dispatchEvent(new CustomEvent("clear-verification-error",{bubbles:!0,composed:!0}));let i=t.target,n=i.value.replace(/\D/g,"").slice(0,6);i.value=n,this.securityCode=n,this.securityCode.length===6&&this.verifyCode()}render(){return P`
613
+ `],C([W({type:Number})],Se.prototype,"port",2),C([W({type:Boolean})],Se.prototype,"showHosting",2),C([j()],Se.prototype,"loading",2),C([j()],Se.prototype,"localNodeDetected",2),C([j()],Se.prototype,"newPort",2),C([j()],Se.prototype,"isMobile",2),Se=C([de("connection-options")],Se);var Le=class extends Y{constructor(){super(...arguments);this.capabilities=[];this.appname="";this.appiconpath="";this.verificationError=!1;this.requestSent=!1;this.securityCode="";this.verifying=!1}willUpdate(e){e.has("verificationError")&&this.verificationError&&(this.verifying=!1)}requestCapability(){this.dispatchEvent(new CustomEvent("request-capability",{bubbles:!0,composed:!0})),this.requestSent=!0}verifyCode(){this.verifying=!0,this.dispatchEvent(new CustomEvent("verify-code",{detail:{code:this.securityCode},bubbles:!0,composed:!0}))}onInputChange(e){this.dispatchEvent(new CustomEvent("clear-verification-error",{bubbles:!0,composed:!0}));let r=e.target,s=r.value.replace(/\D/g,"").slice(0,6);r.value=s,this.securityCode=s,this.securityCode.length===6&&this.verifyCode()}render(){return y`
2185
614
  <div class="container">
2186
615
  <div class="header">
2187
616
  <h1>${this.appname}</h1>
@@ -2189,14 +618,14 @@ input VoiceActivityParamsInput {
2189
618
  </div>
2190
619
 
2191
620
  <div class="connection-icons">
2192
- ${this.appiconpath?P`<img class="app-image" src=${this.appiconpath} alt="App Logo" />`:P`<div class="app-initial">${this.appname.charAt(0).toUpperCase()}</div>`}
2193
- <div class="arrow-icon">${il()}</div>
2194
- <div class="ad4m-logo">${Cn()}</div>
621
+ ${this.appiconpath?y`<img class="app-image" src=${this.appiconpath} alt="App Logo" />`:y`<div class="app-initial">${this.appname.charAt(0).toUpperCase()}</div>`}
622
+ <div class="arrow-icon">${as()}</div>
623
+ <div class="ad4m-logo">${Gt()}</div>
2195
624
  </div>
2196
625
 
2197
- ${this.requestSent?P`
626
+ ${this.requestSent?y`
2198
627
  <div class="state success" style="margin-bottom: -12px">
2199
- ${Ot()}
628
+ ${ve()}
2200
629
  <p>Auth request sent to local AD4M node</p>
2201
630
  </div>
2202
631
 
@@ -2212,20 +641,20 @@ input VoiceActivityParamsInput {
2212
641
  .value=${this.securityCode||""}
2213
642
  @input=${this.onInputChange}
2214
643
  />
2215
- ${this.verifying?P`<div class="spinner"></div>`:""}
644
+ ${this.verifying?y`<div class="spinner"></div>`:""}
2216
645
  </div>
2217
646
 
2218
- ${this.verificationError?P`
647
+ ${this.verificationError?y`
2219
648
  <div class="state danger" style="margin-top: -32px; margin-bottom: 20px;">
2220
- ${wt()}
649
+ ${fe()}
2221
650
  <p>Verification failed. Please try again.</p>
2222
651
  </div>
2223
652
  `:""}
2224
- `:P`
653
+ `:y`
2225
654
  <p>This will allow ${this.appname} to</p>
2226
655
 
2227
656
  <ul class="box">
2228
- ${this.capabilities.map(t=>P`<li>${Ot()}<p>${Fm(t)}</p></li>`)}
657
+ ${this.capabilities.map(e=>y`<li>${ve()}<p>${Ga(e)}</p></li>`)}
2229
658
  </ul>
2230
659
 
2231
660
  <div class="row center">
@@ -2235,7 +664,7 @@ input VoiceActivityParamsInput {
2235
664
  </div>
2236
665
  `}
2237
666
  </div>
2238
- `}};Zt.styles=[$t,Ge`
667
+ `}};Le.styles=[_e,re`
2239
668
  h1 {
2240
669
  font-size: 34px;
2241
670
  }
@@ -2319,23 +748,23 @@ input VoiceActivityParamsInput {
2319
748
  .state {
2320
749
  justify-content: center;
2321
750
  }
2322
- `],F([pe({type:Array})],Zt.prototype,"capabilities",2),F([pe({type:String})],Zt.prototype,"appname",2),F([pe({type:String})],Zt.prototype,"appiconpath",2),F([pe({type:Boolean})],Zt.prototype,"verificationError",2),F([te()],Zt.prototype,"requestSent",2),F([te()],Zt.prototype,"securityCode",2),F([te()],Zt.prototype,"verifying",2),Zt=F([ut("local-authentication")],Zt);var St=class extends Me{constructor(){super(...arguments);this.remoteAuthState=null;this.remoteAuthLoading=!1;this.emailCodeError=!1;this.passwordError=!1;this.accountCreationError=!1;this.host=null;this.email="";this.password="";this.emailSecurityCode="";this.confirmPassword=""}emailLogin(){this.dispatchEvent(new CustomEvent("email-login",{detail:{email:this.email.trim()},bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.clearSensitiveState()}clearSensitiveState(){this.password="",this.confirmPassword="",this.emailSecurityCode="",this.email=""}tryAgain(){this.clearSensitiveState(),this.dispatchEvent(new CustomEvent("reset-auth-state",{bubbles:!0,composed:!0}))}verifyEmailCode(){this.dispatchEvent(new CustomEvent("verify-email-code",{detail:{email:this.email.trim(),code:this.emailSecurityCode},bubbles:!0,composed:!0}))}passwordLogin(){this.dispatchEvent(new CustomEvent("password-login",{detail:{email:this.email.trim(),password:this.password},bubbles:!0,composed:!0}))}createAccount(){this.dispatchEvent(new CustomEvent("create-account",{detail:{email:this.email.trim(),password:this.password},bubbles:!0,composed:!0}))}onEmailSecurityCodeChange(t){this.dispatchEvent(new CustomEvent("clear-email-code-error",{bubbles:!0,composed:!0}));let i=t.target,n=i.value.replace(/\D/g,"").slice(0,6);i.value=n,this.emailSecurityCode=n,this.emailSecurityCode.length===6&&!this.remoteAuthLoading&&this.verifyEmailCode()}get passwordsMatch(){return this.password.length>0&&this.password===this.confirmPassword}isValidEmail(){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(this.email.trim())}render(){let t=!this.remoteAuthState,i=this.remoteAuthState&&this.remoteAuthState.success&&!this.remoteAuthState.requiresPassword,n=this.remoteAuthState&&this.remoteAuthState.requiresPassword&&this.remoteAuthState.isExistingUser,a=this.remoteAuthState&&this.remoteAuthState.requiresPassword&&!this.remoteAuthState.isExistingUser,o=this.remoteAuthState&&!this.remoteAuthState.success&&!this.remoteAuthState.requiresPassword;return P`
751
+ `],C([W({type:Array})],Le.prototype,"capabilities",2),C([W({type:String})],Le.prototype,"appname",2),C([W({type:String})],Le.prototype,"appiconpath",2),C([W({type:Boolean})],Le.prototype,"verificationError",2),C([j()],Le.prototype,"requestSent",2),C([j()],Le.prototype,"securityCode",2),C([j()],Le.prototype,"verifying",2),Le=C([de("local-authentication")],Le);var ge=class extends Y{constructor(){super(...arguments);this.remoteAuthState=null;this.remoteAuthLoading=!1;this.emailCodeError=!1;this.passwordError=!1;this.accountCreationError=!1;this.host=null;this.email="";this.password="";this.emailSecurityCode="";this.confirmPassword=""}emailLogin(){this.dispatchEvent(new CustomEvent("email-login",{detail:{email:this.email.trim()},bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.clearSensitiveState()}clearSensitiveState(){this.password="",this.confirmPassword="",this.emailSecurityCode="",this.email=""}tryAgain(){this.clearSensitiveState(),this.dispatchEvent(new CustomEvent("reset-auth-state",{bubbles:!0,composed:!0}))}verifyEmailCode(){this.dispatchEvent(new CustomEvent("verify-email-code",{detail:{email:this.email.trim(),code:this.emailSecurityCode},bubbles:!0,composed:!0}))}passwordLogin(){this.dispatchEvent(new CustomEvent("password-login",{detail:{email:this.email.trim(),password:this.password},bubbles:!0,composed:!0}))}createAccount(){this.dispatchEvent(new CustomEvent("create-account",{detail:{email:this.email.trim(),password:this.password},bubbles:!0,composed:!0}))}onEmailSecurityCodeChange(e){this.dispatchEvent(new CustomEvent("clear-email-code-error",{bubbles:!0,composed:!0}));let r=e.target,s=r.value.replace(/\D/g,"").slice(0,6);r.value=s,this.emailSecurityCode=s,this.emailSecurityCode.length===6&&!this.remoteAuthLoading&&this.verifyEmailCode()}get passwordsMatch(){return this.password.length>0&&this.password===this.confirmPassword}isValidEmail(){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(this.email.trim())}render(){let e=!this.remoteAuthState,r=this.remoteAuthState&&this.remoteAuthState.success&&!this.remoteAuthState.requiresPassword,s=this.remoteAuthState&&this.remoteAuthState.requiresPassword&&this.remoteAuthState.isExistingUser,n=this.remoteAuthState&&this.remoteAuthState.requiresPassword&&!this.remoteAuthState.isExistingUser,a=this.remoteAuthState&&!this.remoteAuthState.success&&!this.remoteAuthState.requiresPassword;return y`
2323
752
  <div class="container">
2324
753
  <div class="header">
2325
- <h1 style="font-size: 28px;">${n?"Login":a?"Register":"Login or Register"}</h1>
2326
- ${this.host?P`<p style="font-size: 15px; color: rgba(255,255,255,0.4); margin-top: 10px;">${this.host.url}</p>`:""}
754
+ <h1 style="font-size: 28px;">${s?"Login":n?"Register":"Login or Register"}</h1>
755
+ ${this.host?y`<p style="font-size: 15px; color: rgba(255,255,255,0.4); margin-top: 10px;">${this.host.url}</p>`:""}
2327
756
  </div>
2328
757
 
2329
- ${t?P`
2330
- <h3>Enter your email to login to ${this.host?P`<strong>${this.host.name}</strong>`:"the remote node"}</h3>
758
+ ${e?y`
759
+ <h3>Enter your email to login to ${this.host?y`<strong>${this.host.name}</strong>`:"the remote node"}</h3>
2331
760
 
2332
761
  <div class="input-row">
2333
762
  <input
2334
763
  type="email"
2335
764
  placeholder="email@example.com"
2336
765
  .value=${this.email||""}
2337
- @input=${s=>{let c=s.target;this.email=c.value}}
2338
- @keydown=${s=>{s.key==="Enter"&&!this.remoteAuthLoading&&this.isValidEmail()&&this.emailLogin()}}
766
+ @input=${o=>{let c=o.target;this.email=c.value}}
767
+ @keydown=${o=>{o.key==="Enter"&&!this.remoteAuthLoading&&this.isValidEmail()&&this.emailLogin()}}
2339
768
  />
2340
769
  </div>
2341
770
 
@@ -2346,9 +775,9 @@ input VoiceActivityParamsInput {
2346
775
  </div>
2347
776
  `:""}
2348
777
 
2349
- ${o?P`
778
+ ${a?y`
2350
779
  <div class="state danger">
2351
- ${wt()}
780
+ ${fe()}
2352
781
  <p>${this.remoteAuthState.message||"Failed to process email. Please try again."}</p>
2353
782
  </div>
2354
783
  <div class="login-button" style="margin-top: 10px;">
@@ -2356,9 +785,9 @@ input VoiceActivityParamsInput {
2356
785
  </div>
2357
786
  `:""}
2358
787
 
2359
- ${i?P`
788
+ ${r?y`
2360
789
  <div class="state success" style="margin-bottom: -12px">
2361
- ${Ot()}
790
+ ${ve()}
2362
791
  <p>Email verification code sent</p>
2363
792
  </div>
2364
793
 
@@ -2374,20 +803,20 @@ input VoiceActivityParamsInput {
2374
803
  .value=${this.emailSecurityCode||""}
2375
804
  @input=${this.onEmailSecurityCodeChange}
2376
805
  />
2377
- ${this.remoteAuthLoading?P`<div class="spinner"></div>`:""}
806
+ ${this.remoteAuthLoading?y`<div class="spinner"></div>`:""}
2378
807
  </div>
2379
808
 
2380
- ${this.emailCodeError?P`
809
+ ${this.emailCodeError?y`
2381
810
  <div class="state danger" style="margin-top: -32px; margin-bottom: 20px;">
2382
- ${wt()}
811
+ ${fe()}
2383
812
  <p>Verification failed. Please try again.</p>
2384
813
  </div>
2385
814
  `:""}
2386
815
  `:""}
2387
816
 
2388
- ${n?P`
817
+ ${s?y`
2389
818
  <div class="state success" style="margin-bottom: -12px">
2390
- ${Ot()}
819
+ ${ve()}
2391
820
  <p>Account found</p>
2392
821
  </div>
2393
822
 
@@ -2398,8 +827,8 @@ input VoiceActivityParamsInput {
2398
827
  type="password"
2399
828
  placeholder="Password..."
2400
829
  .value=${this.password||""}
2401
- @input=${s=>{let c=s.target;this.password=c.value}}
2402
- @keydown=${s=>{s.key==="Enter"&&!this.remoteAuthLoading&&this.password.length&&this.passwordLogin()}}
830
+ @input=${o=>{let c=o.target;this.password=c.value}}
831
+ @keydown=${o=>{o.key==="Enter"&&!this.remoteAuthLoading&&this.password.length&&this.passwordLogin()}}
2403
832
  />
2404
833
  </div>
2405
834
 
@@ -2409,17 +838,17 @@ input VoiceActivityParamsInput {
2409
838
  </button>
2410
839
  </div>
2411
840
 
2412
- ${this.passwordError?P`
841
+ ${this.passwordError?y`
2413
842
  <div class="state danger" style="margin-top: -32px; margin-bottom: 20px;">
2414
- ${wt()}
843
+ ${fe()}
2415
844
  <p>Incorrect password. Please try again.</p>
2416
845
  </div>
2417
846
  `:""}
2418
847
  `:""}
2419
848
 
2420
- ${a?P`
849
+ ${n?y`
2421
850
  <div class="state success">
2422
- ${Ot()}
851
+ ${ve()}
2423
852
  <p>Creating a new account for <strong>${this.email}</strong></p>
2424
853
  </div>
2425
854
 
@@ -2430,7 +859,7 @@ input VoiceActivityParamsInput {
2430
859
  type="password"
2431
860
  placeholder="Password..."
2432
861
  .value=${this.password||""}
2433
- @input=${s=>{let c=s.target;this.password=c.value}}
862
+ @input=${o=>{let c=o.target;this.password=c.value}}
2434
863
  />
2435
864
  </div>
2436
865
 
@@ -2439,12 +868,12 @@ input VoiceActivityParamsInput {
2439
868
  type="password"
2440
869
  placeholder="Confirm password..."
2441
870
  .value=${this.confirmPassword||""}
2442
- @input=${s=>{let c=s.target;this.confirmPassword=c.value}}
2443
- @keydown=${s=>{s.key==="Enter"&&!this.remoteAuthLoading&&this.passwordsMatch&&this.createAccount()}}
871
+ @input=${o=>{let c=o.target;this.confirmPassword=c.value}}
872
+ @keydown=${o=>{o.key==="Enter"&&!this.remoteAuthLoading&&this.passwordsMatch&&this.createAccount()}}
2444
873
  />
2445
874
  </div>
2446
875
 
2447
- ${this.confirmPassword.length>0&&!this.passwordsMatch?P`<p style="font-size: 13px; color: var(--ac-danger-color); text-align: center;">Passwords do not match</p>`:""}
876
+ ${this.confirmPassword.length>0&&!this.passwordsMatch?y`<p style="font-size: 13px; color: var(--ac-danger-color); text-align: center;">Passwords do not match</p>`:""}
2448
877
 
2449
878
  <div class="login-button">
2450
879
  <button class="primary" @click=${this.createAccount} .disabled=${this.remoteAuthLoading||!this.passwordsMatch}>
@@ -2452,16 +881,16 @@ input VoiceActivityParamsInput {
2452
881
  </button>
2453
882
  </div>
2454
883
 
2455
- ${this.accountCreationError?P`
884
+ ${this.accountCreationError?y`
2456
885
  <div class="state danger" style="margin-top: -32px; margin-bottom: 20px;">
2457
- ${wt()}
886
+ ${fe()}
2458
887
  <p>Failed to create account. Please try again.</p>
2459
888
  </div>
2460
889
  `:""}
2461
890
  `:""}
2462
891
 
2463
892
  </div>
2464
- `}};St.styles=[$t,Ge`
893
+ `}};ge.styles=[_e,re`
2465
894
  .header h1 {
2466
895
  font-size: 32px;
2467
896
  margin-bottom: 0;
@@ -2509,10 +938,10 @@ input VoiceActivityParamsInput {
2509
938
  .state {
2510
939
  justify-content: center;
2511
940
  }
2512
- `],F([pe({type:Object})],St.prototype,"remoteAuthState",2),F([pe({type:Boolean})],St.prototype,"remoteAuthLoading",2),F([pe({type:Boolean})],St.prototype,"emailCodeError",2),F([pe({type:Boolean})],St.prototype,"passwordError",2),F([pe({type:Boolean})],St.prototype,"accountCreationError",2),F([pe({type:Object})],St.prototype,"host",2),F([te()],St.prototype,"email",2),F([te()],St.prototype,"password",2),F([te()],St.prototype,"emailSecurityCode",2),F([te()],St.prototype,"confirmPassword",2),St=F([ut("remote-authentication")],St);var Ai=class extends Me{constructor(){super(...arguments);this.url="";this.port=12e3;this.authState="unauthenticated"}get connectionType(){return this.url.includes("localhost")||this.url.includes("127.0.0.1")?"local":"remote"}close(){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}disconnect(){this.dispatchEvent(new CustomEvent("disconnect",{bubbles:!0,composed:!0}))}render(){let t=this.connectionType==="local";return P`
941
+ `],C([W({type:Object})],ge.prototype,"remoteAuthState",2),C([W({type:Boolean})],ge.prototype,"remoteAuthLoading",2),C([W({type:Boolean})],ge.prototype,"emailCodeError",2),C([W({type:Boolean})],ge.prototype,"passwordError",2),C([W({type:Boolean})],ge.prototype,"accountCreationError",2),C([W({type:Object})],ge.prototype,"host",2),C([j()],ge.prototype,"email",2),C([j()],ge.prototype,"password",2),C([j()],ge.prototype,"emailSecurityCode",2),C([j()],ge.prototype,"confirmPassword",2),ge=C([de("remote-authentication")],ge);var _t=class extends Y{constructor(){super(...arguments);this.url="";this.port=12e3;this.authState="unauthenticated"}get connectionType(){return this.url.includes("localhost")||this.url.includes("127.0.0.1")?"local":"remote"}close(){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}disconnect(){this.dispatchEvent(new CustomEvent("disconnect",{bubbles:!0,composed:!0}))}render(){let e=this.connectionType==="local";return y`
2513
942
  <div class="container">
2514
943
  <div class="close-button" @click=${this.close}>
2515
- ${wt()}
944
+ ${fe()}
2516
945
  </div>
2517
946
 
2518
947
  <div class="header">
@@ -2522,11 +951,11 @@ input VoiceActivityParamsInput {
2522
951
 
2523
952
  <div class="box">
2524
953
  <div class="box-header">
2525
- ${t?Ea():el()}
2526
- <h3>${t?"Local Node":"Remote Node"}</h3>
954
+ ${e?wi():rs()}
955
+ <h3>${e?"Local Node":"Remote Node"}</h3>
2527
956
  </div>
2528
957
 
2529
- ${t?P`
958
+ ${e?y`
2530
959
  <div class="row">
2531
960
  <span>Port:</span>
2532
961
  <span class="detail-value">${this.port}</span>
@@ -2535,7 +964,7 @@ input VoiceActivityParamsInput {
2535
964
  <span>URL:</span>
2536
965
  <span class="detail-value">${this.url}</span>
2537
966
  </div>
2538
- `:P`
967
+ `:y`
2539
968
  <div class="row">
2540
969
  <span>URL:</span>
2541
970
  <span class="detail-value">${this.url}</span>
@@ -2554,7 +983,7 @@ input VoiceActivityParamsInput {
2554
983
  </button>
2555
984
  </div>
2556
985
  </div>
2557
- `}};Ai.styles=[$t,Ge`
986
+ `}};_t.styles=[_e,re`
2558
987
  .box {
2559
988
  gap: 15px;
2560
989
  }
@@ -2589,7 +1018,7 @@ input VoiceActivityParamsInput {
2589
1018
  background: rgba(244, 54, 127, 0.2);
2590
1019
  color: var(--ac-danger-color);
2591
1020
  }
2592
- `],F([pe({type:String})],Ai.prototype,"url",2),F([pe({type:Number})],Ai.prototype,"port",2),F([pe({type:String})],Ai.prototype,"authState",2),Ai=F([ut("current-state")],Ai);function sl(r,e){let t=Jf(r.id||r.name),i=Kf(r.name);if(r.profilePicUrl){let n=a=>{let o=a.target,s=document.createElement("div");s.className=`${e} fallback`,s.style.background=`hsl(${t},60%,35%)`,s.textContent=i,o.replaceWith(s)};return P`<img class=${e} src=${r.profilePicUrl} alt="" @error=${n} />`}return P`<div class="${e} fallback" style="background:hsl(${t},60%,35%)">${i}</div>`}var Yt=class extends Me{constructor(){super(...arguments);this.hosts=[];this.loading=!1;this.error=null;this.lastHostId=null;this.defaultUrl="";this.manualUrl="";this.manualUrlError=null;this.defaultApplied=!1}willUpdate(t){t.has("defaultUrl")&&this.defaultUrl&&!this.defaultApplied&&(this.manualUrl=this.defaultUrl,this.defaultApplied=!0)}selectHost(t){this.dispatchEvent(new CustomEvent("select-host",{detail:{host:t},bubbles:!0,composed:!0}))}connectManualUrl(){let t=this.manualUrl.trim();if(!t)return;let i;try{i=new URL(t)}catch(a){this.manualUrlError="Invalid URL format";return}if(i.protocol!=="ws:"&&i.protocol!=="wss:"){this.manualUrlError="URL must use ws:// or wss:// protocol";return}this.manualUrlError=null;let n={id:`manual-${Date.now()}`,name:i.hostname,profilePicUrl:"",location:"Custom URL",url:t,rates:[],aiModels:[]};this.selectHost(n)}renderAvatar(t){return sl(t,"host-avatar")}retry(){this.dispatchEvent(new CustomEvent("retry",{bubbles:!0,composed:!0}))}formatPrice(t){return t===0?"0.00":t>=.01?t.toFixed(2):t>=1e-4?t.toFixed(4):t>=1e-6?t.toFixed(6):t.toExponential(2)}getLinkPrice(t){let i=t.find(n=>n.description.trim().toLowerCase()==="link write");return i?i.priceInHOT:null}getAvgTokenPrice(t){let i=t.filter(n=>n.description.trim().toLowerCase()!=="link write");return i.length===0?null:i.reduce((n,a)=>n+a.priceInHOT,0)/i.length}getSortedHosts(){if(!this.lastHostId)return this.hosts;let t=this.hosts.filter(n=>n.id===this.lastHostId),i=this.hosts.filter(n=>n.id!==this.lastHostId);return[...t,...i]}render(){return P`
1021
+ `],C([W({type:String})],_t.prototype,"url",2),C([W({type:Number})],_t.prototype,"port",2),C([W({type:String})],_t.prototype,"authState",2),_t=C([de("current-state")],_t);function ds(i,t){let e=Nn(i.id||i.name),r=Mn(i.name);if(i.profilePicUrl){let s=n=>{let a=n.target,o=document.createElement("div");o.className=`${t} fallback`,o.style.background=`hsl(${e},60%,35%)`,o.textContent=r,a.replaceWith(o)};return y`<img class=${t} src=${i.profilePicUrl} alt="" @error=${s} />`}return y`<div class="${t} fallback" style="background:hsl(${e},60%,35%)">${r}</div>`}var Pe=class extends Y{constructor(){super(...arguments);this.hosts=[];this.loading=!1;this.error=null;this.lastHostId=null;this.defaultUrl="";this.manualUrl="";this.manualUrlError=null;this.defaultApplied=!1}willUpdate(e){e.has("defaultUrl")&&this.defaultUrl&&!this.defaultApplied&&(this.manualUrl=this.defaultUrl,this.defaultApplied=!0)}selectHost(e){this.dispatchEvent(new CustomEvent("select-host",{detail:{host:e},bubbles:!0,composed:!0}))}connectManualUrl(){let e=this.manualUrl.trim();if(!e)return;let r;try{r=new URL(e)}catch(a){this.manualUrlError="Invalid URL format";return}if(!["http:","https:","ws:","wss:"].includes(r.protocol)){this.manualUrlError="URL must use http:// or https:// protocol";return}this.manualUrlError=null;let s=r.protocol==="ws:"||r.protocol==="wss:"?tt(e):e,n={id:`manual-${Date.now()}`,name:r.hostname,profilePicUrl:"",location:"Custom URL",url:s,rates:[],aiModels:[]};this.selectHost(n)}renderAvatar(e){return ds(e,"host-avatar")}retry(){this.dispatchEvent(new CustomEvent("retry",{bubbles:!0,composed:!0}))}formatPrice(e){return e===0?"0.00":e>=.01?e.toFixed(2):e>=1e-4?e.toFixed(4):e>=1e-6?e.toFixed(6):e.toExponential(2)}getLinkPrice(e){let r=e.find(s=>s.description.trim().toLowerCase()==="link write");return r?r.priceInHOT:null}getAvgTokenPrice(e){let r=e.filter(s=>s.description.trim().toLowerCase()!=="link write");return r.length===0?null:r.reduce((s,n)=>s+n.priceInHOT,0)/r.length}getSortedHosts(){if(!this.lastHostId)return this.hosts;let e=this.hosts.filter(s=>s.id===this.lastHostId),r=this.hosts.filter(s=>s.id!==this.lastHostId);return[...e,...r]}render(){return y`
2593
1022
  <div class="container">
2594
1023
  <div class="header">
2595
1024
  <h1>Remote Node</h1>
@@ -2605,37 +1034,37 @@ input VoiceActivityParamsInput {
2605
1034
  <span>By connecting to a remote host, you are trusting them to run AD4M on your behalf. Your data will be stored on their machine and they will have access to your agent's operations. Only connect to hosts you trust.</span>
2606
1035
  </div>
2607
1036
 
2608
- ${this.loading?P`
1037
+ ${this.loading?y`
2609
1038
  <div class="spinner-container"><div class="spinner"></div></div>
2610
- `:this.error?P`
1039
+ `:this.error?y`
2611
1040
  <div class="box">
2612
1041
  <p style="color: var(--ac-danger-color)">${this.error}</p>
2613
1042
  <button class="primary" @click=${this.retry}>Retry</button>
2614
1043
  </div>
2615
- `:P`
1044
+ `:y`
2616
1045
  <div class="host-list">
2617
- ${this.getSortedHosts().map(t=>P`
1046
+ ${this.getSortedHosts().map(e=>y`
2618
1047
  <div
2619
- class="host-card ${t.id===this.lastHostId?"pinned":""}"
1048
+ class="host-card ${e.id===this.lastHostId?"pinned":""}"
2620
1049
  tabindex="0"
2621
1050
  role="button"
2622
- aria-label="Connect to ${t.name}"
2623
- @click=${()=>this.selectHost(t)}
2624
- @keydown=${i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),this.selectHost(t))}}
1051
+ aria-label="Connect to ${e.name}"
1052
+ @click=${()=>this.selectHost(e)}
1053
+ @keydown=${r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),this.selectHost(e))}}
2625
1054
  >
2626
- ${this.renderAvatar(t)}
1055
+ ${this.renderAvatar(e)}
2627
1056
  <div class="host-info">
2628
1057
  <div style="display:flex;align-items:center;gap:8px;">
2629
- <p class="host-name">${t.name}</p>
2630
- ${t.id===this.lastHostId?P`<span class="pinned-label">Last used</span>`:""}
1058
+ <p class="host-name">${e.name}</p>
1059
+ ${e.id===this.lastHostId?y`<span class="pinned-label">Last used</span>`:""}
2631
1060
  </div>
2632
- <p class="host-location">${ki()}${t.location}</p>
1061
+ <p class="host-location">${vt()}${e.location}</p>
2633
1062
  <div class="host-meta">
2634
- ${t.aiModels.map(i=>P`<span class="model-chip">${i}</span>`)}
1063
+ ${e.aiModels.map(r=>y`<span class="model-chip">${r}</span>`)}
2635
1064
  </div>
2636
- ${t.rates.length>0?(()=>{let i=this.getLinkPrice(t.rates),n=this.getAvgTokenPrice(t.rates);return P`
1065
+ ${e.rates.length>0?(()=>{let r=this.getLinkPrice(e.rates),s=this.getAvgTokenPrice(e.rates);return y`
2637
1066
  <p class="rates-preview">
2638
- ${i!=null?P`Link: ${this.formatPrice(i)} wHOT`:""}${i!=null&&n!=null?" \xB7 ":""}${n!=null?P`Token: ~${this.formatPrice(n)} wHOT`:""}
1067
+ ${r!=null?y`Link: ${this.formatPrice(r)} wHOT`:""}${r!=null&&s!=null?" \xB7 ":""}${s!=null?y`Token: ~${this.formatPrice(s)} wHOT`:""}
2639
1068
  </p>
2640
1069
  `})():""}
2641
1070
  </div>
@@ -2649,10 +1078,10 @@ input VoiceActivityParamsInput {
2649
1078
  <div class="manual-entry">
2650
1079
  <input
2651
1080
  type="text"
2652
- placeholder="wss://your-host.example/graphql"
1081
+ placeholder="https://your-host.example"
2653
1082
  .value=${this.manualUrl}
2654
- @input=${t=>{this.manualUrl=t.target.value,this.manualUrlError=null}}
2655
- @keydown=${t=>{t.key==="Enter"&&this.connectManualUrl()}}
1083
+ @input=${e=>{this.manualUrl=e.target.value,this.manualUrlError=null}}
1084
+ @keydown=${e=>{e.key==="Enter"&&this.connectManualUrl()}}
2656
1085
  style="font-size: 14px;"
2657
1086
  />
2658
1087
  <button
@@ -2663,9 +1092,9 @@ input VoiceActivityParamsInput {
2663
1092
  Connect
2664
1093
  </button>
2665
1094
  </div>
2666
- ${this.manualUrlError?P`<p class="state danger" style="margin-top: 6px; font-size: 13px;">${this.manualUrlError}</p>`:""}
1095
+ ${this.manualUrlError?y`<p class="state danger" style="margin-top: 6px; font-size: 13px;">${this.manualUrlError}</p>`:""}
2667
1096
  </div>
2668
- `}};Yt.styles=[$t,Ge`
1097
+ `}};Pe.styles=[_e,re`
2669
1098
  :host {
2670
1099
  display: flex;
2671
1100
  flex-direction: column;
@@ -2853,38 +1282,38 @@ input VoiceActivityParamsInput {
2853
1282
  letter-spacing: 0.5px;
2854
1283
  font-weight: 600;
2855
1284
  }
2856
- `],F([pe({type:Array})],Yt.prototype,"hosts",2),F([pe({type:Boolean})],Yt.prototype,"loading",2),F([pe({type:String})],Yt.prototype,"error",2),F([pe({type:String})],Yt.prototype,"lastHostId",2),F([pe({type:String})],Yt.prototype,"defaultUrl",2),F([te()],Yt.prototype,"manualUrl",2),F([te()],Yt.prototype,"manualUrlError",2),Yt=F([ut("host-browser")],Yt);var qr=class extends Me{proceedToAuth(){this.dispatchEvent(new CustomEvent("proceed-to-auth",{detail:{host:this.host},bubbles:!0,composed:!0}))}renderAvatar(){return sl(this.host,"profile-pic")}isOperationRate(t){return qr.OPERATION_RATES.has(t.description)}rateLabel(t){return t==="link write"?"Link write":t}formatPrice(t){return t===0?"0.00":t>=.01?t.toFixed(2):t>=1e-4?t.toFixed(4):t>=1e-6?t.toFixed(6):t.toExponential(2)}render(){return this.host?P`
1285
+ `],C([W({type:Array})],Pe.prototype,"hosts",2),C([W({type:Boolean})],Pe.prototype,"loading",2),C([W({type:String})],Pe.prototype,"error",2),C([W({type:String})],Pe.prototype,"lastHostId",2),C([W({type:String})],Pe.prototype,"defaultUrl",2),C([j()],Pe.prototype,"manualUrl",2),C([j()],Pe.prototype,"manualUrlError",2),Pe=C([de("host-browser")],Pe);var et=class extends Y{proceedToAuth(){this.dispatchEvent(new CustomEvent("proceed-to-auth",{detail:{host:this.host},bubbles:!0,composed:!0}))}renderAvatar(){return ds(this.host,"profile-pic")}isOperationRate(e){return et.OPERATION_RATES.has(e.description)}rateLabel(e){return e==="link write"?"Link write":e}formatPrice(e){return e===0?"0.00":e>=.01?e.toFixed(2):e>=1e-4?e.toFixed(4):e>=1e-6?e.toFixed(6):e.toExponential(2)}render(){return this.host?y`
2857
1286
  <div class="container">
2858
1287
  <div class="profile">
2859
1288
  ${this.renderAvatar()}
2860
1289
  <p class="profile-name">${this.host.name}</p>
2861
- <p class="profile-location">${ki()}${this.host.location}</p>
2862
- ${this.host.description?P`<p class="profile-description">${this.host.description}</p>`:""}
1290
+ <p class="profile-location">${vt()}${this.host.location}</p>
1291
+ ${this.host.description?y`<p class="profile-description">${this.host.description}</p>`:""}
2863
1292
 
2864
- ${this.host.aiModels.length>0?P`
1293
+ ${this.host.aiModels.length>0?y`
2865
1294
  <div class="models">
2866
- ${this.host.aiModels.map(t=>P`<span class="model-chip">${t}</span>`)}
1295
+ ${this.host.aiModels.map(e=>y`<span class="model-chip">${e}</span>`)}
2867
1296
  </div>
2868
1297
  `:""}
2869
1298
  </div>
2870
1299
 
2871
- ${this.host.rates.length>0?P`
1300
+ ${this.host.rates.length>0?y`
2872
1301
  <div class="box">
2873
1302
  <div class="rates-section">
2874
1303
  <h3>Pricing</h3>
2875
1304
  <table class="rates-table">
2876
- ${this.host.rates.filter(t=>this.isOperationRate(t)).map(t=>P`
1305
+ ${this.host.rates.filter(e=>this.isOperationRate(e)).map(e=>y`
2877
1306
  <tr>
2878
- <td>${this.rateLabel(t.description)}</td>
2879
- <td>${this.formatPrice(t.priceInHOT)} wHOT</td>
1307
+ <td>${this.rateLabel(e.description)}</td>
1308
+ <td>${this.formatPrice(e.priceInHOT)} wHOT</td>
2880
1309
  </tr>
2881
1310
  `)}
2882
- ${this.host.rates.filter(t=>!this.isOperationRate(t)).length>0?P`
1311
+ ${this.host.rates.filter(e=>!this.isOperationRate(e)).length>0?y`
2883
1312
  <tr><td colspan="2" style="text-align:left;padding-top:12px;color:rgba(255,255,255,0.5);font-size:12px;text-transform:uppercase;letter-spacing:0.5px;">AI Models (cost per token)</td></tr>
2884
- ${this.host.rates.filter(t=>!this.isOperationRate(t)).map(t=>P`
1313
+ ${this.host.rates.filter(e=>!this.isOperationRate(e)).map(e=>y`
2885
1314
  <tr>
2886
- <td>${t.description}</td>
2887
- <td>${this.formatPrice(t.priceInHOT)} wHOT</td>
1315
+ <td>${e.description}</td>
1316
+ <td>${this.formatPrice(e.priceInHOT)} wHOT</td>
2888
1317
  </tr>
2889
1318
  `)}
2890
1319
  `:""}
@@ -2893,7 +1322,7 @@ input VoiceActivityParamsInput {
2893
1322
  </div>
2894
1323
  `:""}
2895
1324
 
2896
- ${this.host.computeSpecs?P`
1325
+ ${this.host.computeSpecs?y`
2897
1326
  <div class="box">
2898
1327
  <div class="rates-section">
2899
1328
  <h3>Compute</h3>
@@ -2906,7 +1335,7 @@ input VoiceActivityParamsInput {
2906
1335
  Connect to ${this.host.name}
2907
1336
  </button>
2908
1337
  </div>
2909
- `:null}};qr.styles=[$t,Ge`
1338
+ `:null}};et.styles=[_e,re`
2910
1339
  .profile {
2911
1340
  display: flex;
2912
1341
  flex-direction: column;
@@ -3026,43 +1455,43 @@ input VoiceActivityParamsInput {
3026
1455
  button.connect-button {
3027
1456
  width: 100%;
3028
1457
  }
3029
- `],qr.OPERATION_RATES=new Set(["link write"]),F([pe({type:Object})],qr.prototype,"host",2),qr=F([ut("host-detail")],qr);var Ke=class extends Me{constructor(){super(...arguments);this.connectedHost=null;this.userInfo=null;this.requestingPayment=!1;this.paymentError=null;this.forceOpen=!1;this.walletInput="";this.editingWallet=!1;this.walletSaveSuccess=!1;this.topUpAmount="";this.awaitingApproval=!1;this.creditsUpdated=!1;this.activityLogOpen=!1;this.activityLog=[];this.activityLogLoading=!1;this.previousCredits=null}close(){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}_useApp(){this.dispatchEvent(new CustomEvent("use-app",{bubbles:!0,composed:!0}))}disconnect(){this.dispatchEvent(new CustomEvent("disconnect",{bubbles:!0,composed:!0}))}setWalletAddress(){let t=this.walletInput.trim();!t||(this.editingWallet=!1,this.walletSaveSuccess=!0,setTimeout(()=>{this.walletSaveSuccess=!1},3e3),this.dispatchEvent(new CustomEvent("set-wallet-address",{detail:{address:t},bubbles:!0,composed:!0})))}requestTopUp(t){this.creditsUpdated=!1,this.dispatchEvent(new CustomEvent("request-top-up",{detail:{amountHOT:t},bubbles:!0,composed:!0}))}truncateMiddle(t,i=8,n=6){return t.length<=i+n+3?t:`${t.slice(0,i)}\u2026${t.slice(-n)}`}toggleActivityLog(){return V(this,null,function*(){this.activityLogOpen=!this.activityLogOpen,this.activityLogOpen&&this.activityLog.length===0&&(yield this.loadActivityLog())})}loadActivityLog(){return V(this,null,function*(){this.activityLogLoading=!0;try{this.dispatchEvent(new CustomEvent("fetch-compute-log",{bubbles:!0,composed:!0,detail:{callback:t=>{this.activityLog=t,this.activityLogLoading=!1}}}))}catch(t){this.activityLogLoading=!1}})}pushLogEntry(t){this.activityLog=[t,...this.activityLog].slice(0,100)}formatTimeAgo(t){let i=Date.now()-new Date(t).getTime(),n=Math.floor(i/1e3);if(n<60)return`${n}s ago`;let a=Math.floor(n/60);if(a<60)return`${a}m ago`;let o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}formatOperation(t){switch(t){case"ai_prompt":return"AI Prompt";case"ai_embed":return"AI Embed";case"ai_transcription":return"AI Transcription";case"link_write":return"Link Write";default:return t}}get hasWallet(){var t;return!!((t=this.userInfo)!=null&&t.hotWalletAddress)}get isFreeAccess(){var t;return!!((t=this.userInfo)!=null&&t.freeAccess)}get isDepleted(){return this.userInfo!=null&&!this.userInfo.freeAccess&&this.userInfo.remainingCredits<=0}get topUpDisabled(){return!this.hasWallet||this.requestingPayment||this.awaitingApproval}updated(t){var i,n,a,o,s;t.has("requestingPayment")&&!this.requestingPayment&&!this.paymentError&&t.get("requestingPayment")&&(this.awaitingApproval=!0,this.previousCredits=(n=(i=this.userInfo)==null?void 0:i.remainingCredits)!=null?n:null),t.has("userInfo")&&this.awaitingApproval&&this.previousCredits!==null&&((o=(a=this.userInfo)==null?void 0:a.remainingCredits)!=null?o:0)!==this.previousCredits&&(this.awaitingApproval=!1,this.creditsUpdated=!0,this.previousCredits=null,setTimeout(()=>{this.creditsUpdated=!1},4e3)),t.has("paymentError")&&this.paymentError&&(this.awaitingApproval=!1,this.previousCredits=null),t.has("userInfo")&&((s=this.userInfo)==null?void 0:s.hotWalletAddress)&&!this.walletInput&&(this.walletInput=this.userInfo.hotWalletAddress)}render(){var i,n,a;let t=(n=(i=this.userInfo)==null?void 0:i.remainingCredits)!=null?n:0;return P`
1458
+ `],et.OPERATION_RATES=new Set(["link write"]),C([W({type:Object})],et.prototype,"host",2),et=C([de("host-detail")],et);var se=class extends Y{constructor(){super(...arguments);this.connectedHost=null;this.userInfo=null;this.requestingPayment=!1;this.paymentError=null;this.forceOpen=!1;this.walletInput="";this.editingWallet=!1;this.walletSaveSuccess=!1;this.topUpAmount="";this.awaitingApproval=!1;this.creditsUpdated=!1;this.activityLogOpen=!1;this.activityLog=[];this.activityLogLoading=!1;this.previousCredits=null}close(){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}_useApp(){this.dispatchEvent(new CustomEvent("use-app",{bubbles:!0,composed:!0}))}disconnect(){this.dispatchEvent(new CustomEvent("disconnect",{bubbles:!0,composed:!0}))}setWalletAddress(){let e=this.walletInput.trim();!e||(this.editingWallet=!1,this.walletSaveSuccess=!0,setTimeout(()=>{this.walletSaveSuccess=!1},3e3),this.dispatchEvent(new CustomEvent("set-wallet-address",{detail:{address:e},bubbles:!0,composed:!0})))}requestTopUp(e){this.creditsUpdated=!1,this.dispatchEvent(new CustomEvent("request-top-up",{detail:{amountHOT:e},bubbles:!0,composed:!0}))}truncateMiddle(e,r=8,s=6){return e.length<=r+s+3?e:`${e.slice(0,r)}\u2026${e.slice(-s)}`}toggleActivityLog(){return L(this,null,function*(){this.activityLogOpen=!this.activityLogOpen,this.activityLogOpen&&this.activityLog.length===0&&(yield this.loadActivityLog())})}loadActivityLog(){return L(this,null,function*(){this.activityLogLoading=!0;try{this.dispatchEvent(new CustomEvent("fetch-compute-log",{bubbles:!0,composed:!0,detail:{callback:e=>{this.activityLog=e,this.activityLogLoading=!1}}}))}catch(e){this.activityLogLoading=!1}})}pushLogEntry(e){this.activityLog=[e,...this.activityLog].slice(0,100)}formatTimeAgo(e){let r=Date.now()-new Date(e).getTime(),s=Math.floor(r/1e3);if(s<60)return`${s}s ago`;let n=Math.floor(s/60);if(n<60)return`${n}m ago`;let a=Math.floor(n/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}formatOperation(e){switch(e){case"ai_prompt":return"AI Prompt";case"ai_embed":return"AI Embed";case"ai_transcription":return"AI Transcription";case"link_write":return"Link Write";default:return e}}get hasWallet(){var e;return!!((e=this.userInfo)!=null&&e.hotWalletAddress)}get isFreeAccess(){var e;return!!((e=this.userInfo)!=null&&e.freeAccess)}get isDepleted(){return this.userInfo!=null&&!this.userInfo.freeAccess&&this.userInfo.remainingCredits<=0}get topUpDisabled(){return!this.hasWallet||this.requestingPayment||this.awaitingApproval}updated(e){var r,s,n,a,o;e.has("requestingPayment")&&!this.requestingPayment&&!this.paymentError&&e.get("requestingPayment")&&(this.awaitingApproval=!0,this.previousCredits=(s=(r=this.userInfo)==null?void 0:r.remainingCredits)!=null?s:null),e.has("userInfo")&&this.awaitingApproval&&this.previousCredits!==null&&((a=(n=this.userInfo)==null?void 0:n.remainingCredits)!=null?a:0)!==this.previousCredits&&(this.awaitingApproval=!1,this.creditsUpdated=!0,this.previousCredits=null,setTimeout(()=>{this.creditsUpdated=!1},4e3)),e.has("paymentError")&&this.paymentError&&(this.awaitingApproval=!1,this.previousCredits=null),e.has("userInfo")&&((o=this.userInfo)==null?void 0:o.hotWalletAddress)&&!this.walletInput&&(this.walletInput=this.userInfo.hotWalletAddress)}render(){var r,s,n;let e=(s=(r=this.userInfo)==null?void 0:r.remainingCredits)!=null?s:0;return y`
3030
1459
  <div class="container">
3031
- ${this.forceOpen?"":P`<div class="close-button" @click=${this.close}>${wt()}</div>`}
1460
+ ${this.forceOpen?"":y`<div class="close-button" @click=${this.close}>${fe()}</div>`}
3032
1461
 
3033
1462
  <div class="dashboard-header">
3034
1463
  <h1>Dashboard</h1>
3035
- ${this.connectedHost?P`
1464
+ ${this.connectedHost?y`
3036
1465
  <div class="host-badge">
3037
1466
  Connected to <strong>${this.connectedHost.name}</strong>
3038
1467
  </div>
3039
1468
  <div class="host-badge">
3040
- ${ki()} ${this.connectedHost.location}
1469
+ ${vt()} ${this.connectedHost.location}
3041
1470
  </div>
3042
1471
  `:""}
3043
- ${(a=this.userInfo)!=null&&a.email?P`
1472
+ ${(n=this.userInfo)!=null&&n.email?y`
3044
1473
  <p class="email-display">${this.userInfo.email}</p>
3045
1474
  `:""}
3046
1475
  </div>
3047
1476
 
3048
1477
  <!-- Credit balance -->
3049
- ${this.isFreeAccess?P`
1478
+ ${this.isFreeAccess?y`
3050
1479
  <div class="credit-display free-access">
3051
- ${Ei()}
1480
+ ${bt()}
3052
1481
  <span class="credit-amount">Free Access</span>
3053
1482
  </div>
3054
- `:P`
1483
+ `:y`
3055
1484
  <div class="credit-display">
3056
- ${Ei()}
3057
- <span class="credit-amount">${t.toFixed(2)}</span>
1485
+ ${bt()}
1486
+ <span class="credit-amount">${e.toFixed(2)}</span>
3058
1487
  <span class="credit-label">wHOT</span>
3059
1488
  </div>
3060
1489
 
3061
- ${this.isDepleted?P`
1490
+ ${this.isDepleted?y`
3062
1491
  <div class="depleted-banner">Credits depleted — top up to continue using this host</div>
3063
1492
  `:""}
3064
1493
 
3065
- ${this.hasWallet?"":P`
1494
+ ${this.hasWallet?"":y`
3066
1495
  <p style="font-size:15px;color:rgba(255,255,255,0.5);text-align:center;">
3067
1496
  Set your wallet address to enable top-ups
3068
1497
  </p>
@@ -3070,27 +1499,27 @@ input VoiceActivityParamsInput {
3070
1499
 
3071
1500
  <!-- Wallet address -->
3072
1501
  <div class="wallet-section">
3073
- <label>${ol()} wHOT Wallet Address</label>
3074
- ${this.hasWallet&&!this.editingWallet?P`
1502
+ <label>${cs()} wHOT Wallet Address</label>
1503
+ ${this.hasWallet&&!this.editingWallet?y`
3075
1504
  <div class="wallet-row">
3076
1505
  <div class="wallet-display" title=${this.userInfo.hotWalletAddress}>${this.truncateMiddle(this.userInfo.hotWalletAddress||"")}</div>
3077
1506
  <button class="secondary" @click=${()=>{this.editingWallet=!0,this.walletInput=this.userInfo.hotWalletAddress||""}}>
3078
1507
  Change
3079
1508
  </button>
3080
1509
  </div>
3081
- ${this.walletSaveSuccess?P`
1510
+ ${this.walletSaveSuccess?y`
3082
1511
  <div class="success-message" style="display:flex;align-items:center;justify-content:center;gap:6px;">
3083
- ${Ot()} Wallet saved
1512
+ ${ve()} Wallet saved
3084
1513
  </div>
3085
1514
  `:""}
3086
- `:P`
1515
+ `:y`
3087
1516
  <div class="wallet-row">
3088
1517
  <input
3089
1518
  type="text"
3090
1519
  placeholder="Enter your wHOT wallet address"
3091
1520
  .value=${this.walletInput}
3092
- @input=${o=>{this.walletInput=o.target.value}}
3093
- @keydown=${o=>{o.key==="Enter"&&this.setWalletAddress()}}
1521
+ @input=${a=>{this.walletInput=a.target.value}}
1522
+ @keydown=${a=>{a.key==="Enter"&&this.setWalletAddress()}}
3094
1523
  style="font-size: 14px;"
3095
1524
  />
3096
1525
  <button
@@ -3106,15 +1535,15 @@ input VoiceActivityParamsInput {
3106
1535
 
3107
1536
  <!-- Top-up -->
3108
1537
  <div class="topup-section">
3109
- <label>${Ei()} Top Up Credits</label>
1538
+ <label>${bt()} Top Up Credits</label>
3110
1539
  <div class="wallet-row">
3111
1540
  <input
3112
1541
  type="number"
3113
1542
  min="1"
3114
1543
  placeholder="Amount in wHOT"
3115
1544
  .value=${this.topUpAmount}
3116
- @input=${o=>{this.topUpAmount=o.target.value}}
3117
- @keydown=${o=>{o.key==="Enter"&&this.topUpAmount&&Number(this.topUpAmount)>0&&this.requestTopUp(Number(this.topUpAmount))}}
1545
+ @input=${a=>{this.topUpAmount=a.target.value}}
1546
+ @keydown=${a=>{a.key==="Enter"&&this.topUpAmount&&Number(this.topUpAmount)>0&&this.requestTopUp(Number(this.topUpAmount))}}
3118
1547
  style="font-size: 14px;"
3119
1548
  />
3120
1549
  <button
@@ -3126,32 +1555,32 @@ input VoiceActivityParamsInput {
3126
1555
  </button>
3127
1556
  </div>
3128
1557
  <div class="topup-buttons">
3129
- ${[100,500,1e3].map(o=>P`
1558
+ ${[100,500,1e3].map(a=>y`
3130
1559
  <button
3131
1560
  class="secondary"
3132
1561
  ?disabled=${this.topUpDisabled}
3133
- @click=${()=>{this.topUpAmount=String(o),this.requestTopUp(o)}}
1562
+ @click=${()=>{this.topUpAmount=String(a),this.requestTopUp(a)}}
3134
1563
  >
3135
- ${o} wHOT
1564
+ ${a} wHOT
3136
1565
  </button>
3137
1566
  `)}
3138
1567
  </div>
3139
1568
  </div>
3140
1569
 
3141
- ${this.awaitingApproval?P`
1570
+ ${this.awaitingApproval?y`
3142
1571
  <div class="pending-message">
3143
1572
  <div class="spinner"></div>
3144
1573
  Open Unyt app and approve the transaction
3145
1574
  </div>
3146
1575
  `:""}
3147
1576
 
3148
- ${this.creditsUpdated?P`
1577
+ ${this.creditsUpdated?y`
3149
1578
  <div class="success-message" style="display:flex;align-items:center;justify-content:center;gap:6px;">
3150
- ${Ot()} Credits updated!
1579
+ ${ve()} Credits updated!
3151
1580
  </div>
3152
1581
  `:""}
3153
1582
 
3154
- ${this.paymentError?P`
1583
+ ${this.paymentError?y`
3155
1584
  <div class="error-message">${this.paymentError}</div>
3156
1585
  `:""}
3157
1586
  `}
@@ -3161,19 +1590,19 @@ input VoiceActivityParamsInput {
3161
1590
  <span>Activity Log</span>
3162
1591
  <span class="chevron ${this.activityLogOpen?"open":""}">&#9654;</span>
3163
1592
  </div>
3164
- ${this.activityLogOpen?P`
3165
- ${this.activityLogLoading?P`
1593
+ ${this.activityLogOpen?y`
1594
+ ${this.activityLogLoading?y`
3166
1595
  <div class="activity-log-empty">Loading...</div>
3167
- `:this.activityLog.length===0?P`
1596
+ `:this.activityLog.length===0?y`
3168
1597
  <div class="activity-log-empty">No activity yet</div>
3169
- `:P`
1598
+ `:y`
3170
1599
  <div class="activity-log-list">
3171
- ${this.activityLog.map(o=>P`
1600
+ ${this.activityLog.map(a=>y`
3172
1601
  <div class="activity-log-entry">
3173
- <span class="op-badge ${o.operation}">${this.formatOperation(o.operation)}</span>
3174
- <span class="summary" title=${o.summary||""}>${o.summary||""}</span>
3175
- <span class="cost">${o.cost.toFixed(2)}</span>
3176
- <span class="time">${this.formatTimeAgo(o.timestamp)}</span>
1602
+ <span class="op-badge ${a.operation}">${this.formatOperation(a.operation)}</span>
1603
+ <span class="summary" title=${a.summary||""}>${a.summary||""}</span>
1604
+ <span class="cost">${a.cost.toFixed(2)}</span>
1605
+ <span class="time">${this.formatTimeAgo(a.timestamp)}</span>
3177
1606
  </div>
3178
1607
  `)}
3179
1608
  </div>
@@ -3189,7 +1618,7 @@ input VoiceActivityParamsInput {
3189
1618
  </button>
3190
1619
  </div>
3191
1620
  </div>
3192
- `}};Ke.styles=[$t,Ge`
1621
+ `}};se.styles=[_e,re`
3193
1622
  .dashboard-header {
3194
1623
  text-align: center;
3195
1624
  }
@@ -3521,7 +1950,7 @@ input VoiceActivityParamsInput {
3521
1950
  color: rgba(255, 255, 255, 0.4);
3522
1951
  font-size: 13px;
3523
1952
  }
3524
- `],F([pe({type:Object})],Ke.prototype,"connectedHost",2),F([pe({type:Object})],Ke.prototype,"userInfo",2),F([pe({type:Boolean})],Ke.prototype,"requestingPayment",2),F([pe({type:String})],Ke.prototype,"paymentError",2),F([pe({type:Boolean})],Ke.prototype,"forceOpen",2),F([te()],Ke.prototype,"walletInput",2),F([te()],Ke.prototype,"editingWallet",2),F([te()],Ke.prototype,"walletSaveSuccess",2),F([te()],Ke.prototype,"topUpAmount",2),F([te()],Ke.prototype,"awaitingApproval",2),F([te()],Ke.prototype,"creditsUpdated",2),F([te()],Ke.prototype,"activityLogOpen",2),F([te()],Ke.prototype,"activityLog",2),F([te()],Ke.prototype,"activityLogLoading",2),Ke=F([ut("logged-in-dashboard")],Ke);var r_=Ge`
1953
+ `],C([W({type:Object})],se.prototype,"connectedHost",2),C([W({type:Object})],se.prototype,"userInfo",2),C([W({type:Boolean})],se.prototype,"requestingPayment",2),C([W({type:String})],se.prototype,"paymentError",2),C([W({type:Boolean})],se.prototype,"forceOpen",2),C([j()],se.prototype,"walletInput",2),C([j()],se.prototype,"editingWallet",2),C([j()],se.prototype,"walletSaveSuccess",2),C([j()],se.prototype,"topUpAmount",2),C([j()],se.prototype,"awaitingApproval",2),C([j()],se.prototype,"creditsUpdated",2),C([j()],se.prototype,"activityLogOpen",2),C([j()],se.prototype,"activityLog",2),C([j()],se.prototype,"activityLogLoading",2),se=C([de("logged-in-dashboard")],se);var pu=re`
3525
1954
  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap');
3526
1955
 
3527
1956
  :host {
@@ -3677,7 +2106,7 @@ input VoiceActivityParamsInput {
3677
2106
  0%, 100% { opacity: 1; }
3678
2107
  50% { opacity: 0.4; }
3679
2108
  }
3680
- `,Ue=class extends Me{constructor(){super(...arguments);this.modalOpen=!1;this.currentView="connection-options";this.verificationError=!1;this.remoteAuthLoading=!1;this.remoteAuthState=null;this.emailCodeError=!1;this.passwordError=!1;this.accountCreationError=!1;this.hosts=[];this.hostsLoading=!1;this.hostsError=null;this.selectedHost=null;this.userInfo=null;this.lowCredit=!1;this.requestingPayment=!1;this.paymentError=null;this.openedDueToCreditDepletion=!1}connectedCallback(){super.connectedCallback(),Go(this),this.core.addEventListener("authstatechange",t=>{t.detail==="unauthenticated"&&(this.currentView="connection-options",this.modalOpen=!0),this.requestUpdate()}),this.core.addEventListener("userinfochange",t=>{var n;let i=t.detail;((n=this.userInfo)==null?void 0:n.hotWalletAddress)&&!i.hotWalletAddress&&(i.hotWalletAddress=this.userInfo.hotWalletAddress),this.userInfo=i,this.lowCredit=this.userInfo.remainingCredits<=this.core.lowCreditThreshold,this.requestUpdate()}),this.core.addEventListener("creditdepleted",()=>{var t,i;if(this.lowCredit=!0,this.core.connectedHost){this.openedDueToCreditDepletion=!0;try{(i=(t=this.core.options).onCreditsDepleted)==null||i.call(t)}catch(n){console.error("[Ad4m Connect] onCreditsDepleted callback error:",n)}this.modalOpen||(this.currentView="logged-in-dashboard",this.modalOpen=!0)}this.requestUpdate()}),this.core.token?this.core.connect().then(()=>{this.core.connectedHost&&(this.selectedHost=this.core.connectedHost,this.core.startCreditSubscription())}).catch(t=>{console.error("[Ad4m Connect UI] Auto-connect failed:",t),this.currentView="connection-options",this.modalOpen=!0}):(this.currentView="connection-options",this.modalOpen=!0)}changePort(t){return V(this,null,function*(){this.core.port=t.detail.port,dt("ad4m-port",this.core.port.toString()),this.requestUpdate()})}connectLocalNode(){return V(this,null,function*(){this.core.url=`ws://localhost:${this.core.port}/graphql`,dt("ad4m-url",this.core.url);try{yield this.core.connect(),this.currentView="local-authentication"}catch(t){console.error("[Ad4m Connect UI] Local node connection failed:",t),this.currentView="connection-options"}})}verifyLocalAd4mCode(t){return V(this,null,function*(){let i=yield this.core.verifyLocalAd4mCode(t.detail.code);this.verificationError=!i,i&&(this.modalOpen=!1)})}browseHosts(){return V(this,null,function*(){this.hostsLoading=!0,this.hostsError=null,this.currentView="host-browser";try{this.hosts=yield Tp(this.core.hostIndexUrl)}catch(t){console.error("[Ad4m Connect UI] Failed to fetch hosts:",t),this.hostsError=t instanceof Error?t.message:"Failed to load hosts"}finally{this.hostsLoading=!1}})}retryFetchHosts(){return V(this,null,function*(){this.hostsLoading=!0,this.hostsError=null;try{this.hosts=yield Tp(this.core.hostIndexUrl)}catch(t){console.error("[Ad4m Connect UI] Failed to fetch hosts:",t),this.hostsError=t instanceof Error?t.message:"Failed to load hosts"}finally{this.hostsLoading=!1}})}selectHost(t){this.selectedHost=t.detail.host,this.currentView="host-detail"}proceedToAuth(t){return V(this,null,function*(){let i=t.detail.host;this.selectedHost=i;let n=i.url;try{yield Mi(n),console.log("[Ad4m Connect UI] Host connection successful:",i.name);let a=this.core.url;if(this.core.url=n,!(yield this.core.isValidAd4mAPI()))throw this.core.url=a,new Error("Server is reachable but doesn't appear to be an AD4M executor");dt("ad4m-url",n),this.currentView="remote-authentication"}catch(a){console.error("[Ad4m Connect UI] Host connection failed:",a),this.hostsError=a instanceof Error?a.message:"Connection failed",this.currentView="host-browser"}})}handleAuthSuccess(){return V(this,null,function*(){this.selectedHost?(this.core.setConnectedHost(this.selectedHost),this.core.startCreditSubscription(),this.currentView="logged-in-dashboard"):this.modalOpen=!1})}handleRequestTopUp(t){return V(this,null,function*(){this.requestingPayment=!0,this.paymentError=null;try{let i=yield this.core.requestTopUp(t.detail.amountHOT);i.success||(this.paymentError=i.message)}catch(i){this.paymentError=i instanceof Error?i.message:"Payment request failed"}finally{this.requestingPayment=!1}})}handleSetWalletAddress(t){return V(this,null,function*(){try{yield this.core.ad4mClient.agent.setHotWalletAddress(t.detail.address),this.userInfo&&(this.userInfo=Zp(Jp({},this.userInfo),{hotWalletAddress:t.detail.address}))}catch(i){console.error("[Ad4m Connect] Failed to set wallet address:",i)}})}connectRemoteNode(t){return V(this,null,function*(){this.core.url=t.detail.remoteUrl,dt("ad4m-url",this.core.url);try{if(yield Mi(t.detail.remoteUrl),!(yield this.core.isValidAd4mAPI()))throw new Error("Server is reachable but doesn't appear to be an AD4M executor");this.currentView="remote-authentication"}catch(i){console.error("[Ad4m Connect UI] Remote connection failed:",i)}})}emailLogin(t){return V(this,null,function*(){try{this.remoteAuthLoading=!0,this.remoteAuthState=yield this.core.submitEmail(t.detail.email)}finally{this.remoteAuthLoading=!1}})}verifyEmailCode(t){return V(this,null,function*(){try{this.remoteAuthLoading=!0;let i=yield this.core.verifyEmailCode(t.detail.email,t.detail.code);this.emailCodeError=!i,i&&(yield this.handleAuthSuccess())}catch(i){this.emailCodeError=!0}finally{this.remoteAuthLoading=!1}})}passwordLogin(t){return V(this,null,function*(){try{this.remoteAuthLoading=!0;let i=yield this.core.loginWithPassword(t.detail.email,t.detail.password);this.passwordError=!i,i&&(yield this.handleAuthSuccess())}catch(i){this.passwordError=!0}finally{this.remoteAuthLoading=!1}})}createAccount(t){return V(this,null,function*(){try{this.remoteAuthLoading=!0;let i=yield this.core.createAccount(t.detail.email,t.detail.password);this.accountCreationError=!i,i&&(yield this.handleAuthSuccess())}catch(i){this.accountCreationError=!0}finally{this.remoteAuthLoading=!1}})}disconnect(){return V(this,null,function*(){yield this.core.disconnect(),window.location.reload()})}get backTarget(){switch(this.currentView){case"local-authentication":return"connection-options";case"host-browser":return"connection-options";case"host-detail":return"host-browser";case"remote-authentication":return this.selectedHost?"host-detail":"connection-options";default:return null}}handleBack(){let t=this.backTarget;t&&(this.currentView==="remote-authentication"&&this.resetRemoteAuthState(),this.currentView=t)}resetRemoteAuthState(){this.remoteAuthState=null,this.remoteAuthLoading=!1,this.emailCodeError=!1,this.passwordError=!1,this.accountCreationError=!1}renderViews(){var t,i,n;if(this.currentView==="connection-options")return P`
2109
+ `,ee=class extends Y{constructor(){super(...arguments);this.modalOpen=!1;this.currentView="connection-options";this.verificationError=!1;this.remoteAuthLoading=!1;this.remoteAuthState=null;this.emailCodeError=!1;this.passwordError=!1;this.accountCreationError=!1;this.hosts=[];this.hostsLoading=!1;this.hostsError=null;this.selectedHost=null;this.userInfo=null;this.lowCredit=!1;this.requestingPayment=!1;this.paymentError=null;this.openedDueToCreditDepletion=!1}connectedCallback(){super.connectedCallback(),hr(this),this.core.addEventListener("authstatechange",e=>{e.detail==="unauthenticated"?(this.currentView="connection-options",this.modalOpen=!0):e.detail==="authenticated"&&(this.currentView="logged-in-dashboard",this.modalOpen=!1),this.requestUpdate()}),this.core.addEventListener("userinfochange",e=>{var s;let r=e.detail;((s=this.userInfo)==null?void 0:s.hotWalletAddress)&&!r.hotWalletAddress&&(r.hotWalletAddress=this.userInfo.hotWalletAddress),this.userInfo=r,this.lowCredit=this.userInfo.remainingCredits<=this.core.lowCreditThreshold,this.requestUpdate()}),this.core.addEventListener("creditdepleted",()=>{var e,r;if(this.lowCredit=!0,this.core.connectedHost){this.openedDueToCreditDepletion=!0;try{(r=(e=this.core.options).onCreditsDepleted)==null||r.call(e)}catch(s){console.error("[Ad4m Connect] onCreditsDepleted callback error:",s)}this.modalOpen||(this.currentView="logged-in-dashboard",this.modalOpen=!0)}this.requestUpdate()}),this.core.token?this.core.connect().then(()=>{this.core.connectedHost&&(this.selectedHost=this.core.connectedHost,this.core.startCreditSubscription())}).catch(e=>{console.error("[Ad4m Connect UI] Auto-connect failed:",e),this.currentView="connection-options",this.modalOpen=!0}):(this.currentView="connection-options",this.modalOpen=!0)}changePort(e){return L(this,null,function*(){this.core.port=e.detail.port,ce("ad4m-port",this.core.port.toString()),this.requestUpdate()})}connectLocalNode(){return L(this,null,function*(){try{let e=yield fetch(window.location.origin+"/health",{signal:AbortSignal.timeout(2e3)});if(!e.ok)throw new Error("probe failed");let r=yield e.json();if((r==null?void 0:r.status)!=="ok")throw new Error("not an ad4m executor");this.core.url=window.location.origin,ce("ad4m-url",this.core.url),console.log("[Ad4m Connect UI] Using same-origin proxy:",this.core.url)}catch(e){let r=window.location.hostname==="127.0.0.1"?"127.0.0.1":"localhost";this.core.url=`http://${r}:${this.core.port}`,ce("ad4m-url",this.core.url)}try{yield this.core.connect(),this.currentView="local-authentication"}catch(e){console.error("[Ad4m Connect UI] Local node connection failed:",e),this.currentView="connection-options"}})}verifyLocalAd4mCode(e){return L(this,null,function*(){let r=yield this.core.verifyLocalAd4mCode(e.detail.code);this.verificationError=!r,r&&(this.modalOpen=!1)})}browseHosts(){return L(this,null,function*(){this.hostsLoading=!0,this.hostsError=null,this.currentView="host-browser";try{this.hosts=yield dn(this.core.hostIndexUrl)}catch(e){console.error("[Ad4m Connect UI] Failed to fetch hosts:",e),this.hostsError=e instanceof Error?e.message:"Failed to load hosts"}finally{this.hostsLoading=!1}})}retryFetchHosts(){return L(this,null,function*(){this.hostsLoading=!0,this.hostsError=null;try{this.hosts=yield dn(this.core.hostIndexUrl)}catch(e){console.error("[Ad4m Connect UI] Failed to fetch hosts:",e),this.hostsError=e instanceof Error?e.message:"Failed to load hosts"}finally{this.hostsLoading=!1}})}selectHost(e){this.selectedHost=e.detail.host,this.currentView="host-detail"}proceedToAuth(e){return L(this,null,function*(){let r=e.detail.host;this.selectedHost=r;let s=r.url;try{yield it(tt(s)),console.log("[Ad4m Connect UI] Host connection successful:",r.name);let n=this.core.url;if(this.core.url=s,!(yield this.core.isValidAd4mAPI()))throw this.core.url=n,new Error("Server is reachable but doesn't appear to be an AD4M executor");ce("ad4m-url",s),this.currentView="remote-authentication"}catch(n){console.error("[Ad4m Connect UI] Host connection failed:",n),this.hostsError=n instanceof Error?n.message:"Connection failed",this.currentView="host-browser"}})}handleAuthSuccess(){return L(this,null,function*(){this.selectedHost?(this.core.setConnectedHost(this.selectedHost),this.core.startCreditSubscription(),this.currentView="logged-in-dashboard"):this.modalOpen=!1})}handleRequestTopUp(e){return L(this,null,function*(){this.requestingPayment=!0,this.paymentError=null;try{let r=yield this.core.requestTopUp(e.detail.amountHOT);r.success||(this.paymentError=r.message)}catch(r){this.paymentError=r instanceof Error?r.message:"Payment request failed"}finally{this.requestingPayment=!1}})}handleSetWalletAddress(e){return L(this,null,function*(){try{yield this.core.ad4mClient.agent.setHotWalletAddress(e.detail.address),this.userInfo&&(this.userInfo=On(In({},this.userInfo),{hotWalletAddress:e.detail.address}))}catch(r){console.error("[Ad4m Connect] Failed to set wallet address:",r)}})}connectRemoteNode(e){return L(this,null,function*(){this.core.url=e.detail.remoteUrl,ce("ad4m-url",this.core.url);try{if(yield it(tt(e.detail.remoteUrl)),!(yield this.core.isValidAd4mAPI()))throw new Error("Server is reachable but doesn't appear to be an AD4M executor");this.currentView="remote-authentication"}catch(r){console.error("[Ad4m Connect UI] Remote connection failed:",r)}})}emailLogin(e){return L(this,null,function*(){try{this.remoteAuthLoading=!0,this.remoteAuthState=yield this.core.submitEmail(e.detail.email)}finally{this.remoteAuthLoading=!1}})}verifyEmailCode(e){return L(this,null,function*(){try{this.remoteAuthLoading=!0;let r=yield this.core.verifyEmailCode(e.detail.email,e.detail.code);this.emailCodeError=!r,r&&(yield this.handleAuthSuccess())}catch(r){this.emailCodeError=!0}finally{this.remoteAuthLoading=!1}})}passwordLogin(e){return L(this,null,function*(){try{this.remoteAuthLoading=!0;let r=yield this.core.loginWithPassword(e.detail.email,e.detail.password);this.passwordError=!r,r&&(yield this.handleAuthSuccess())}catch(r){this.passwordError=!0}finally{this.remoteAuthLoading=!1}})}createAccount(e){return L(this,null,function*(){try{this.remoteAuthLoading=!0;let r=yield this.core.createAccount(e.detail.email,e.detail.password);this.accountCreationError=!r,r&&(yield this.handleAuthSuccess())}catch(r){this.accountCreationError=!0}finally{this.remoteAuthLoading=!1}})}disconnect(){return L(this,null,function*(){yield this.core.disconnect(),window.location.reload()})}get backTarget(){switch(this.currentView){case"local-authentication":return"connection-options";case"host-browser":return"connection-options";case"host-detail":return"host-browser";case"remote-authentication":return this.selectedHost?"host-detail":"connection-options";default:return null}}handleBack(){let e=this.backTarget;e&&(this.currentView==="remote-authentication"&&this.resetRemoteAuthState(),this.currentView=e)}resetRemoteAuthState(){this.remoteAuthState=null,this.remoteAuthLoading=!1,this.emailCodeError=!1,this.passwordError=!1,this.accountCreationError=!1}renderViews(){var e,r,s;if(this.currentView==="connection-options")return y`
3681
2110
  <connection-options
3682
2111
  .port=${this.core.port}
3683
2112
  .showHosting=${!!this.core.options.hosting}
@@ -3685,7 +2114,7 @@ input VoiceActivityParamsInput {
3685
2114
  @connect-local-node=${this.connectLocalNode}
3686
2115
  @browse-hosts=${this.browseHosts}
3687
2116
  ></connection-options>
3688
- `;if(this.currentView==="local-authentication")return P`
2117
+ `;if(this.currentView==="local-authentication")return y`
3689
2118
  <local-authentication
3690
2119
  .capabilities=${this.core.options.capabilities}
3691
2120
  .appname=${this.core.options.appInfo.name}
@@ -3696,24 +2125,24 @@ input VoiceActivityParamsInput {
3696
2125
  @verify-code=${this.verifyLocalAd4mCode}
3697
2126
  @clear-verification-error=${()=>{this.verificationError=!1}}
3698
2127
  ></local-authentication>
3699
- `;if(this.currentView==="host-browser")return P`
2128
+ `;if(this.currentView==="host-browser")return y`
3700
2129
  <host-browser
3701
2130
  .hosts=${this.hosts}
3702
2131
  .loading=${this.hostsLoading}
3703
2132
  .error=${this.hostsError}
3704
- .lastHostId=${(i=(t=this.core.connectedHost)==null?void 0:t.id)!=null?i:null}
3705
- .defaultUrl=${(n=this.core.options.remoteUrl)!=null?n:""}
2133
+ .lastHostId=${(r=(e=this.core.connectedHost)==null?void 0:e.id)!=null?r:null}
2134
+ .defaultUrl=${(s=this.core.options.remoteUrl)!=null?s:""}
3706
2135
  @select-host=${this.selectHost}
3707
2136
  @back=${()=>{this.currentView="connection-options"}}
3708
2137
  @retry=${this.retryFetchHosts}
3709
2138
  ></host-browser>
3710
- `;if(this.currentView==="host-detail")return P`
2139
+ `;if(this.currentView==="host-detail")return y`
3711
2140
  <host-detail
3712
2141
  .host=${this.selectedHost}
3713
2142
  @proceed-to-auth=${this.proceedToAuth}
3714
2143
  @back=${()=>{this.currentView="host-browser"}}
3715
2144
  ></host-detail>
3716
- `;if(this.currentView==="remote-authentication")return P`
2145
+ `;if(this.currentView==="remote-authentication")return y`
3717
2146
  <remote-authentication
3718
2147
  .host=${this.selectedHost}
3719
2148
  .remoteAuthLoading=${this.remoteAuthLoading}
@@ -3729,7 +2158,7 @@ input VoiceActivityParamsInput {
3729
2158
  @clear-email-code-error=${()=>{this.emailCodeError=!1}}
3730
2159
  @reset-auth-state=${()=>{this.resetRemoteAuthState()}}
3731
2160
  ></remote-authentication>
3732
- `;if(this.currentView==="logged-in-dashboard")return P`
2161
+ `;if(this.currentView==="logged-in-dashboard")return y`
3733
2162
  <logged-in-dashboard
3734
2163
  .connectedHost=${this.core.connectedHost}
3735
2164
  .userInfo=${this.userInfo}
@@ -3737,13 +2166,13 @@ input VoiceActivityParamsInput {
3737
2166
  .paymentError=${this.paymentError}
3738
2167
  .forceOpen=${this.openedDueToCreditDepletion}
3739
2168
  @close=${()=>{this.openedDueToCreditDepletion=!1,this.modalOpen=!1}}
3740
- @use-app=${()=>{var a,o;this.openedDueToCreditDepletion=!1;try{(o=(a=this.core.options).onUseApp)==null||o.call(a)}catch(s){console.error("[Ad4m Connect] onUseApp callback error:",s)}this.modalOpen=!1}}
2169
+ @use-app=${()=>{var n,a;this.openedDueToCreditDepletion=!1;try{(a=(n=this.core.options).onUseApp)==null||a.call(n)}catch(o){console.error("[Ad4m Connect] onUseApp callback error:",o)}this.modalOpen=!1}}
3741
2170
  @disconnect=${this.disconnect}
3742
2171
  @request-top-up=${this.handleRequestTopUp}
3743
2172
  @set-wallet-address=${this.handleSetWalletAddress}
3744
- @fetch-compute-log=${a=>{var s;let o=(s=a==null?void 0:a.detail)==null?void 0:s.callback;typeof o=="function"&&this.core.fetchComputeLog().then(o).catch(c=>{console.error("[Ad4m Connect] Failed to fetch compute log:",c),o([])})}}
2173
+ @fetch-compute-log=${n=>{var o;let a=(o=n==null?void 0:n.detail)==null?void 0:o.callback;typeof a=="function"&&this.core.fetchComputeLog().then(a).catch(c=>{console.error("[Ad4m Connect] Failed to fetch compute log:",c),a([])})}}
3745
2174
  ></logged-in-dashboard>
3746
- `;if(this.currentView==="current-state")return P`
2175
+ `;if(this.currentView==="current-state")return y`
3747
2176
  <current-state
3748
2177
  .url=${this.core.url}
3749
2178
  .port=${this.core.port}
@@ -3751,16 +2180,16 @@ input VoiceActivityParamsInput {
3751
2180
  @close=${()=>{this.modalOpen=!1}}
3752
2181
  @disconnect=${this.disconnect}
3753
2182
  ></current-state>
3754
- `}render(){var t;if(this.modalOpen)return P`
2183
+ `}render(){var e;if(this.modalOpen)return y`
3755
2184
  <div class="wrapper">
3756
2185
  <div class="modal">
3757
2186
  <header class="modal-header">
3758
- ${this.backTarget?P`
2187
+ ${this.backTarget?y`
3759
2188
  <button class="back-button" aria-label="Go back" @click=${this.handleBack}>
3760
- ${nl()} Back
2189
+ ${os()} Back
3761
2190
  </button>
3762
2191
  `:""}
3763
- ${Cn()}
2192
+ ${Gt()}
3764
2193
  </header>
3765
2194
  <main class="modal-content">
3766
2195
  ${this.renderViews()}
@@ -3768,11 +2197,11 @@ input VoiceActivityParamsInput {
3768
2197
  </div>
3769
2198
  <div class="backdrop" />
3770
2199
  </div>
3771
- `;if(this.core.authState==="authenticated"){let i=(t=this.userInfo)==null?void 0:t.remainingCredits;return P`
2200
+ `;if(this.core.authState==="authenticated"){let r=(e=this.userInfo)==null?void 0:e.remainingCredits,s=r!=null&&isFinite(r);return y`
3772
2201
  <div class="settings-bar">
3773
- ${i!=null?P`
2202
+ ${s?y`
3774
2203
  <span class="credit-badge ${this.lowCredit?"low-credit":""}">
3775
- ${Ei()} ${i.toFixed(2)} wHOT
2204
+ ${bt()} ${r.toFixed(2)} wHOT
3776
2205
  </span>
3777
2206
  `:""}
3778
2207
  <button
@@ -3781,10 +2210,10 @@ input VoiceActivityParamsInput {
3781
2210
  aria-label="Open settings"
3782
2211
  @click=${()=>{this.currentView=this.core.connectedHost?"logged-in-dashboard":"current-state",this.modalOpen=!0}}
3783
2212
  >
3784
- ${Cn()}
2213
+ ${Gt()}
3785
2214
  </button>
3786
2215
  </div>
3787
- `}return null}};Ue.styles=[r_],F([te()],Ue.prototype,"modalOpen",2),F([te()],Ue.prototype,"currentView",2),F([te()],Ue.prototype,"verificationError",2),F([te()],Ue.prototype,"remoteAuthLoading",2),F([te()],Ue.prototype,"remoteAuthState",2),F([te()],Ue.prototype,"emailCodeError",2),F([te()],Ue.prototype,"passwordError",2),F([te()],Ue.prototype,"accountCreationError",2),F([te()],Ue.prototype,"hosts",2),F([te()],Ue.prototype,"hostsLoading",2),F([te()],Ue.prototype,"hostsError",2),F([te()],Ue.prototype,"selectedHost",2),F([te()],Ue.prototype,"userInfo",2),F([te()],Ue.prototype,"lowCredit",2),F([te()],Ue.prototype,"requestingPayment",2),F([te()],Ue.prototype,"paymentError",2),Ue=F([ut("ad4m-connect")],Ue);function zp(r){let e=new Ue;return e.core=r,r.embedded?console.log("[Ad4m Connect] Running in embedded mode - UI will not be shown"):(console.log("[Ad4m Connect UI] Mounting UI to DOM"),document.body.appendChild(e)),e}function i_(r){let e=new Ko(r);if(js()){let t=e.connect();return{core:e,client:t}}else{zp(e);let t=new Promise(i=>{e.addEventListener("authstatechange",n=>{n.detail==="authenticated"&&e.ad4mClient&&i(e.ad4mClient)})});return{core:e,client:t}}}function OR(r){return V(this,null,function*(){let{client:e}=i_(r);return e})}export{OR as getAd4mClient,i_ as getAd4mConnect,js as isEmbedded};
2216
+ `}return null}};ee.styles=[pu],C([j()],ee.prototype,"modalOpen",2),C([j()],ee.prototype,"currentView",2),C([j()],ee.prototype,"verificationError",2),C([j()],ee.prototype,"remoteAuthLoading",2),C([j()],ee.prototype,"remoteAuthState",2),C([j()],ee.prototype,"emailCodeError",2),C([j()],ee.prototype,"passwordError",2),C([j()],ee.prototype,"accountCreationError",2),C([j()],ee.prototype,"hosts",2),C([j()],ee.prototype,"hostsLoading",2),C([j()],ee.prototype,"hostsError",2),C([j()],ee.prototype,"selectedHost",2),C([j()],ee.prototype,"userInfo",2),C([j()],ee.prototype,"lowCredit",2),C([j()],ee.prototype,"requestingPayment",2),C([j()],ee.prototype,"paymentError",2),ee=C([de("ad4m-connect")],ee);function En(i){let t=new ee;return t.core=i,i.embedded?console.log("[Ad4m Connect] Running in embedded mode - UI will not be shown"):(console.log("[Ad4m Connect UI] Mounting UI to DOM"),document.body.appendChild(t)),t}function fu(i){let t=new ur(i);if(br()){let e=t.connect();return{core:t,client:e}}else{En(t);let e=new Promise(r=>{t.addEventListener("authstatechange",s=>{s.detail==="authenticated"&&t.ad4mClient&&r(t.ad4mClient)})});return{core:t,client:e}}}function Ug(i){return L(this,null,function*(){let{client:t}=fu(i);return t})}export{Ug as getAd4mClient,fu as getAd4mConnect,br as isEmbedded};
3788
2217
  /*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */
3789
2218
  /**
3790
2219
  * @license