@coasys/ad4m-connect 0.12.1-dev → 0.13.0-test-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.js CHANGED
@@ -1,67 +1,71 @@
1
- var Uo=Object.defineProperty,Fu=Object.defineProperties,ju=Object.getOwnPropertyDescriptor,Bu=Object.getOwnPropertyDescriptors;var Oo=Object.getOwnPropertySymbols,qu=Object.getPrototypeOf,Hu=Object.prototype.hasOwnProperty,zu=Object.prototype.propertyIsEnumerable,Vu=Reflect.get;var Do=(i,e,t)=>e in i?Uo(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Mo=(i,e)=>{for(var t in e||={})Hu.call(e,t)&&Do(i,t,e[t]);if(Oo)for(var t of Oo(e))zu.call(e,t)&&Do(i,t,e[t]);return i},Fo=(i,e)=>Fu(i,Bu(e));var L=(i,e,t,r)=>{for(var n=r>1?void 0:r?ju(e,t):e,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=(r?s(e,t,n):s(n))||n);return r&&n&&Uo(e,t,n),n};var jo=(i,e,t)=>Vu(qu(i),t,e);var pe=(i,e,t)=>new Promise((r,n)=>{var a=l=>{try{o(t.next(l))}catch(c){n(c)}},s=l=>{try{o(t.throw(l))}catch(c){n(c)}},o=l=>l.done?r(l.value):Promise.resolve(l.value).then(a,s);o((t=t.apply(i,e)).next())});var Bn=window,qn=Bn.ShadowRoot&&(Bn.ShadyCSS===void 0||Bn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,cs=Symbol(),Bo=new WeakMap,Dr=class{constructor(e,t,r){if(this._$cssResult$=!0,r!==cs)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(qn&&e===void 0){let r=t!==void 0&&t.length===1;r&&(e=Bo.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Bo.set(t,e))}return e}toString(){return this.cssText}},qo=i=>new Dr(typeof i=="string"?i:i+"",void 0,cs),Ee=(i,...e)=>{let t=i.length===1?i[0]:e.reduce((r,n,a)=>r+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+i[a+1],i[0]);return new Dr(t,i,cs)},ls=(i,e)=>{qn?i.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):e.forEach(t=>{let r=document.createElement("style"),n=Bn.litNonce;n!==void 0&&r.setAttribute("nonce",n),r.textContent=t.cssText,i.appendChild(r)})},Hn=qn?i=>i:i=>i instanceof CSSStyleSheet?(e=>{let t="";for(let r of e.cssRules)t+=r.cssText;return qo(t)})(i):i;var us,zn=window,Ho=zn.trustedTypes,Wu=Ho?Ho.emptyScript:"",zo=zn.reactiveElementPolyfillSupport,ps={toAttribute(i,e){switch(e){case Boolean:i=i?Wu:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,e){let t=i;switch(e){case Boolean:t=i!==null;break;case Number:t=i===null?null:Number(i);break;case Object:case Array:try{t=JSON.parse(i)}catch{t=null}}return t}},Vo=(i,e)=>e!==i&&(e==e||i==i),ds={attribute:!0,type:String,converter:ps,reflect:!1,hasChanged:Vo},fs="finalized",Dt=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,r)=>{let n=this._$Ep(r,t);n!==void 0&&(this._$Ev.set(n,r),e.push(n))}),e}static createProperty(e,t=ds){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){let r=typeof e=="symbol"?Symbol():"__"+e,n=this.getPropertyDescriptor(e,r,t);n!==void 0&&Object.defineProperty(this.prototype,e,n)}}static getPropertyDescriptor(e,t,r){return{get(){return this[t]},set(n){let a=this[e];this[t]=n,this.requestUpdate(e,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||ds}static finalize(){if(this.hasOwnProperty(fs))return!1;this[fs]=!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,r=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(let n of r)this.createProperty(n,t[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let n of r)t.unshift(Hn(n))}else e!==void 0&&t.push(Hn(e));return t}static _$Ep(e,t){let r=t.attribute;return r===!1?void 0:typeof r=="string"?r: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,r;((t=this._$ES)!==null&&t!==void 0?t:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)===null||r===void 0||r.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 ls(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 r;return(r=t.hostConnected)===null||r===void 0?void 0:r.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(t=>{var r;return(r=t.hostDisconnected)===null||r===void 0?void 0:r.call(t)})}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$EO(e,t,r=ds){var n;let a=this.constructor._$Ep(e,r);if(a!==void 0&&r.reflect===!0){let s=(((n=r.converter)===null||n===void 0?void 0:n.toAttribute)!==void 0?r.converter:ps).toAttribute(t,r.type);this._$El=e,s==null?this.removeAttribute(a):this.setAttribute(a,s),this._$El=null}}_$AK(e,t){var r;let n=this.constructor,a=n._$Ev.get(e);if(a!==void 0&&this._$El!==a){let s=n.getPropertyOptions(a),o=typeof s.converter=="function"?{fromAttribute:s.converter}:((r=s.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?s.converter:ps;this._$El=a,this[a]=o.fromAttribute(t,s.type),this._$El=null}}requestUpdate(e,t,r){let n=!0;e!==void 0&&(((r=r||this.constructor.getPropertyOptions(e)).hasChanged||Vo)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),r.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,r))):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,r=this._$AL;try{t=this.shouldUpdate(r),t?(this.willUpdate(r),(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(r)):this._$Ek()}catch(n){throw t=!1,this._$Ek(),n}t&&this._$AE(r)}willUpdate(e){}_$AE(e){var t;(t=this._$ES)===null||t===void 0||t.forEach(r=>{var n;return(n=r.hostUpdated)===null||n===void 0?void 0:n.call(r)}),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,r)=>this._$EO(r,this[r],t)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};Dt[fs]=!0,Dt.elementProperties=new Map,Dt.elementStyles=[],Dt.shadowRootOptions={mode:"open"},zo?.({ReactiveElement:Dt}),((us=zn.reactiveElementVersions)!==null&&us!==void 0?us:zn.reactiveElementVersions=[]).push("1.6.3");var hs,Vn=window,nr=Vn.trustedTypes,Wo=nr?nr.createPolicy("lit-html",{createHTML:i=>i}):void 0,ms="$lit$",Wt=`lit$${(Math.random()+"").slice(9)}$`,Xo="?"+Wt,Ku=`<${Xo}>`,vi=document,Mr=()=>vi.createComment(""),Fr=i=>i===null||typeof i!="object"&&typeof i!="function",ec=Array.isArray,Qu=i=>ec(i)||typeof i?.[Symbol.iterator]=="function",gs=`[
2
- \f\r]`,Ur=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ko=/-->/g,Qo=/>/g,mi=RegExp(`>|${gs}(?:([^\\s"'>=/]+)(${gs}*=${gs}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Go=/'/g,Zo=/"/g,tc=/^(?:script|style|textarea|title)$/i,ic=i=>(e,...t)=>({_$litType$:i,strings:e,values:t}),I=ic(1),zg=ic(2),bi=Symbol.for("lit-noChange"),Ae=Symbol.for("lit-nothing"),Jo=new WeakMap,yi=vi.createTreeWalker(vi,129,null,!1);function rc(i,e){if(!Array.isArray(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return Wo!==void 0?Wo.createHTML(e):e}var Gu=(i,e)=>{let t=i.length-1,r=[],n,a=e===2?"<svg>":"",s=Ur;for(let o=0;o<t;o++){let l=i[o],c,u,m=-1,y=0;for(;y<l.length&&(s.lastIndex=y,u=s.exec(l),u!==null);)y=s.lastIndex,s===Ur?u[1]==="!--"?s=Ko:u[1]!==void 0?s=Qo:u[2]!==void 0?(tc.test(u[2])&&(n=RegExp("</"+u[2],"g")),s=mi):u[3]!==void 0&&(s=mi):s===mi?u[0]===">"?(s=n??Ur,m=-1):u[1]===void 0?m=-2:(m=s.lastIndex-u[2].length,c=u[1],s=u[3]===void 0?mi:u[3]==='"'?Zo:Go):s===Zo||s===Go?s=mi:s===Ko||s===Qo?s=Ur:(s=mi,n=void 0);let d=s===mi&&i[o+1].startsWith("/>")?" ":"";a+=s===Ur?l+Ku:m>=0?(r.push(c),l.slice(0,m)+ms+l.slice(m)+Wt+d):l+Wt+(m===-2?(r.push(void 0),o):d)}return[rc(i,a+(i[t]||"<?>")+(e===2?"</svg>":"")),r]},wi=class{constructor({strings:e,_$litType$:t},r){let n;this.parts=[];let a=0,s=0,o=e.length-1,l=this.parts,[c,u]=Gu(e,t);if(this.el=wi.createElement(c,r),yi.currentNode=this.el.content,t===2){let m=this.el.content,y=m.firstChild;y.remove(),m.append(...y.childNodes)}for(;(n=yi.nextNode())!==null&&l.length<o;){if(n.nodeType===1){if(n.hasAttributes()){let m=[];for(let y of n.getAttributeNames())if(y.endsWith(ms)||y.startsWith(Wt)){let d=u[s++];if(m.push(y),d!==void 0){let f=n.getAttribute(d.toLowerCase()+ms).split(Wt),g=/([.?@])?(.*)/.exec(d);l.push({type:1,index:a,name:g[2],strings:f,ctor:g[1]==="."?vs:g[1]==="?"?bs:g[1]==="@"?ws:sr})}else l.push({type:6,index:a})}for(let y of m)n.removeAttribute(y)}if(tc.test(n.tagName)){let m=n.textContent.split(Wt),y=m.length-1;if(y>0){n.textContent=nr?nr.emptyScript:"";for(let d=0;d<y;d++)n.append(m[d],Mr()),yi.nextNode(),l.push({type:2,index:++a});n.append(m[y],Mr())}}}else if(n.nodeType===8)if(n.data===Xo)l.push({type:2,index:a});else{let m=-1;for(;(m=n.data.indexOf(Wt,m+1))!==-1;)l.push({type:7,index:a}),m+=Wt.length-1}a++}}static createElement(e,t){let r=vi.createElement("template");return r.innerHTML=e,r}};function ar(i,e,t=i,r){var n,a,s,o;if(e===bi)return e;let l=r!==void 0?(n=t._$Co)===null||n===void 0?void 0:n[r]:t._$Cl,c=Fr(e)?void 0:e._$litDirective$;return l?.constructor!==c&&((a=l?._$AO)===null||a===void 0||a.call(l,!1),c===void 0?l=void 0:(l=new c(i),l._$AT(i,t,r)),r!==void 0?((s=(o=t)._$Co)!==null&&s!==void 0?s:o._$Co=[])[r]=l:t._$Cl=l),l!==void 0&&(e=ar(i,l._$AS(i,e.values),l,r)),e}var ys=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:r},parts:n}=this._$AD,a=((t=e?.creationScope)!==null&&t!==void 0?t:vi).importNode(r,!0);yi.currentNode=a;let s=yi.nextNode(),o=0,l=0,c=n[0];for(;c!==void 0;){if(o===c.index){let u;c.type===2?u=new Si(s,s.nextSibling,this,e):c.type===1?u=new c.ctor(s,c.name,c.strings,this,e):c.type===6&&(u=new Ss(s,this,e)),this._$AV.push(u),c=n[++l]}o!==c?.index&&(s=yi.nextNode(),o++)}return yi.currentNode=vi,a}v(e){let t=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}},Si=class{constructor(e,t,r,n){var a;this.type=2,this._$AH=Ae,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,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=ar(this,e,t),Fr(e)?e===Ae||e==null||e===""?(this._$AH!==Ae&&this._$AR(),this._$AH=Ae):e!==this._$AH&&e!==bi&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):Qu(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!==Ae&&Fr(this._$AH)?this._$AA.nextSibling.data=e:this.$(vi.createTextNode(e)),this._$AH=e}g(e){var t;let{values:r,_$litType$:n}=e,a=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=wi.createElement(rc(n.h,n.h[0]),this.options)),n);if(((t=this._$AH)===null||t===void 0?void 0:t._$AD)===a)this._$AH.v(r);else{let s=new ys(a,this),o=s.u(this.options);s.v(r),this.$(o),this._$AH=s}}_$AC(e){let t=Jo.get(e.strings);return t===void 0&&Jo.set(e.strings,t=new wi(e)),t}T(e){ec(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,r,n=0;for(let a of e)n===t.length?t.push(r=new Si(this.k(Mr()),this.k(Mr()),this,this.options)):r=t[n],r._$AI(a),n++;n<t.length&&(this._$AR(r&&r._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)===null||r===void 0||r.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))}},sr=class{constructor(e,t,r,n,a){this.type=1,this._$AH=Ae,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=a,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(e,t=this,r,n){let a=this.strings,s=!1;if(a===void 0)e=ar(this,e,t,0),s=!Fr(e)||e!==this._$AH&&e!==bi,s&&(this._$AH=e);else{let o=e,l,c;for(e=a[0],l=0;l<a.length-1;l++)c=ar(this,o[r+l],t,l),c===bi&&(c=this._$AH[l]),s||(s=!Fr(c)||c!==this._$AH[l]),c===Ae?e=Ae:e!==Ae&&(e+=(c??"")+a[l+1]),this._$AH[l]=c}s&&!n&&this.j(e)}j(e){e===Ae?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},vs=class extends sr{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Ae?void 0:e}},Zu=nr?nr.emptyScript:"",bs=class extends sr{constructor(){super(...arguments),this.type=4}j(e){e&&e!==Ae?this.element.setAttribute(this.name,Zu):this.element.removeAttribute(this.name)}},ws=class extends sr{constructor(e,t,r,n,a){super(e,t,r,n,a),this.type=5}_$AI(e,t=this){var r;if((e=(r=ar(this,e,t,0))!==null&&r!==void 0?r:Ae)===bi)return;let n=this._$AH,a=e===Ae&&n!==Ae||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,s=e!==Ae&&(n===Ae||a);a&&this.element.removeEventListener(this.name,this,n),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,r;typeof this._$AH=="function"?this._$AH.call((r=(t=this.options)===null||t===void 0?void 0:t.host)!==null&&r!==void 0?r:this.element,e):this._$AH.handleEvent(e)}},Ss=class{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){ar(this,e)}};var Yo=Vn.litHtmlPolyfillSupport;Yo?.(wi,Si),((hs=Vn.litHtmlVersions)!==null&&hs!==void 0?hs:Vn.litHtmlVersions=[]).push("2.8.0");var nc=(i,e,t)=>{var r,n;let a=(r=t?.renderBefore)!==null&&r!==void 0?r:e,s=a._$litPart$;if(s===void 0){let o=(n=t?.renderBefore)!==null&&n!==void 0?n:null;a._$litPart$=s=new Si(e.insertBefore(Mr(),o),o,void 0,t??{})}return s._$AI(i),s};var _s,xs;var ge=class extends Dt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;let r=super.createRenderRoot();return(e=(t=this.renderOptions).renderBefore)!==null&&e!==void 0||(t.renderBefore=r.firstChild),r}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=nc(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 bi}};ge.finalized=!0,ge._$litElement$=!0,(_s=globalThis.litElementHydrateSupport)===null||_s===void 0||_s.call(globalThis,{LitElement:ge});var ac=globalThis.litElementPolyfillSupport;ac?.({LitElement:ge});((xs=globalThis.litElementVersions)!==null&&xs!==void 0?xs:globalThis.litElementVersions=[]).push("3.3.3");var Ne=i=>e=>typeof e=="function"?((t,r)=>(customElements.define(t,r),r))(i,e):((t,r)=>{let{kind:n,elements:a}=r;return{kind:n,elements:a,finisher(s){customElements.define(t,s)}}})(i,e);var Ju=(i,e)=>e.kind==="method"&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(t){t.createProperty(e.key,i)}}:{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,i)}},Yu=(i,e,t)=>{e.constructor.createProperty(t,i)};function ie(i){return(e,t)=>t!==void 0?Yu(i,e,t):Ju(i,e)}function Y(i){return ie({...i,state:!0})}var Es,ym=((Es=window.HTMLSlotElement)===null||Es===void 0?void 0:Es.prototype.assignedElements)!=null?(i,e)=>i.assignedElements(e):(i,e)=>i.assignedNodes(e).filter(t=>t.nodeType===Node.ELEMENT_NODE);var Xu=i=>{let e=new Set;do for(let t of Reflect.ownKeys(i))e.add([i,t]);while((i=Reflect.getPrototypeOf(i))&&i!==Object.prototype);return e};function $s(i,{include:e,exclude:t}={}){let r=n=>{let a=s=>typeof s=="string"?n===s:s.test(n);return e?e.some(a):t?!t.some(a):!0};for(let[n,a]of Xu(i.constructor.prototype)){if(a==="constructor"||!r(a))continue;let s=Reflect.getOwnPropertyDescriptor(n,a);s&&typeof s.value=="function"&&(i[a]=i[a].bind(i))}return i}var sc="0.12.1-dev";function td(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(i){return!1}return!0}function Br(i,e){td()&&localStorage.setItem(`${sc}/${i}`,e)}function qr(i,e=1e4){return pe(this,null,function*(){return Promise.race([new Promise((t,r)=>{let n;try{n=new WebSocket(i,"graphql-transport-ws"),n.onopen=()=>{n.close(),t(n)},n.onerror=a=>{r(a)},n.onclose=a=>{a.code!==1e3&&r(new Error(`WebSocket closed with code ${a.code}: ${a.reason}`))}}catch(a){n&&n.close(),r(a)}}),new Promise((t,r)=>{setTimeout(()=>{r(new Error("WebSocket connection timed out"))},e)})])})}function oc(i){let e=i.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 cc(i){let e=0;for(let t=0;t<i.length;t++)e=i.charCodeAt(t)+((e<<5)-e);return(e%360+360)%360}function _i(){return I`
1
+ var Ko=Object.defineProperty,Yu=Object.defineProperties,ed=Object.getOwnPropertyDescriptor,td=Object.getOwnPropertyDescriptors;var Vo=Object.getOwnPropertySymbols,id=Object.getPrototypeOf,rd=Object.prototype.hasOwnProperty,nd=Object.prototype.propertyIsEnumerable,ad=Reflect.get;var Wo=(i,e,t)=>e in i?Ko(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Qo=(i,e)=>{for(var t in e||={})rd.call(e,t)&&Wo(i,t,e[t]);if(Vo)for(var t of Vo(e))nd.call(e,t)&&Wo(i,t,e[t]);return i},Go=(i,e)=>Yu(i,td(e));var C=(i,e,t,r)=>{for(var n=r>1?void 0:r?ed(e,t):e,a=i.length-1,s;a>=0;a--)(s=i[a])&&(n=(r?s(e,t,n):s(n))||n);return r&&n&&Ko(e,t,n),n};var Zo=(i,e,t)=>ad(id(i),t,e);var oe=(i,e,t)=>new Promise((r,n)=>{var a=c=>{try{o(t.next(c))}catch(l){n(l)}},s=c=>{try{o(t.throw(c))}catch(l){n(l)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(a,s);o((t=t.apply(i,e)).next())});var Zn=window,Jn=Zn.ShadowRoot&&(Zn.ShadyCSS===void 0||Zn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ys=Symbol(),Jo=new WeakMap,qr=class{constructor(e,t,r){if(this._$cssResult$=!0,r!==ys)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(Jn&&e===void 0){let r=t!==void 0&&t.length===1;r&&(e=Jo.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Jo.set(t,e))}return e}toString(){return this.cssText}},Xo=i=>new qr(typeof i=="string"?i:i+"",void 0,ys),$e=(i,...e)=>{let t=i.length===1?i[0]:e.reduce((r,n,a)=>r+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+i[a+1],i[0]);return new qr(t,i,ys)},vs=(i,e)=>{Jn?i.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):e.forEach(t=>{let r=document.createElement("style"),n=Zn.litNonce;n!==void 0&&r.setAttribute("nonce",n),r.textContent=t.cssText,i.appendChild(r)})},Xn=Jn?i=>i:i=>i instanceof CSSStyleSheet?(e=>{let t="";for(let r of e.cssRules)t+=r.cssText;return Xo(t)})(i):i;var bs,Yn=window,Yo=Yn.trustedTypes,sd=Yo?Yo.emptyScript:"",ec=Yn.reactiveElementPolyfillSupport,Ss={toAttribute(i,e){switch(e){case Boolean:i=i?sd:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,e){let t=i;switch(e){case Boolean:t=i!==null;break;case Number:t=i===null?null:Number(i);break;case Object:case Array:try{t=JSON.parse(i)}catch{t=null}}return t}},tc=(i,e)=>e!==i&&(e==e||i==i),ws={attribute:!0,type:String,converter:Ss,reflect:!1,hasChanged:tc},_s="finalized",Pt=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,r)=>{let n=this._$Ep(r,t);n!==void 0&&(this._$Ev.set(n,r),e.push(n))}),e}static createProperty(e,t=ws){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){let r=typeof e=="symbol"?Symbol():"__"+e,n=this.getPropertyDescriptor(e,r,t);n!==void 0&&Object.defineProperty(this.prototype,e,n)}}static getPropertyDescriptor(e,t,r){return{get(){return this[t]},set(n){let a=this[e];this[t]=n,this.requestUpdate(e,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||ws}static finalize(){if(this.hasOwnProperty(_s))return!1;this[_s]=!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,r=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(let n of r)this.createProperty(n,t[n])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let n of r)t.unshift(Xn(n))}else e!==void 0&&t.push(Xn(e));return t}static _$Ep(e,t){let r=t.attribute;return r===!1?void 0:typeof r=="string"?r: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,r;((t=this._$ES)!==null&&t!==void 0?t:this._$ES=[]).push(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)===null||r===void 0||r.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 vs(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 r;return(r=t.hostConnected)===null||r===void 0?void 0:r.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)===null||e===void 0||e.forEach(t=>{var r;return(r=t.hostDisconnected)===null||r===void 0?void 0:r.call(t)})}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$EO(e,t,r=ws){var n;let a=this.constructor._$Ep(e,r);if(a!==void 0&&r.reflect===!0){let s=(((n=r.converter)===null||n===void 0?void 0:n.toAttribute)!==void 0?r.converter:Ss).toAttribute(t,r.type);this._$El=e,s==null?this.removeAttribute(a):this.setAttribute(a,s),this._$El=null}}_$AK(e,t){var r;let n=this.constructor,a=n._$Ev.get(e);if(a!==void 0&&this._$El!==a){let s=n.getPropertyOptions(a),o=typeof s.converter=="function"?{fromAttribute:s.converter}:((r=s.converter)===null||r===void 0?void 0:r.fromAttribute)!==void 0?s.converter:Ss;this._$El=a,this[a]=o.fromAttribute(t,s.type),this._$El=null}}requestUpdate(e,t,r){let n=!0;e!==void 0&&(((r=r||this.constructor.getPropertyOptions(e)).hasChanged||tc)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),r.reflect===!0&&this._$El!==e&&(this._$EC===void 0&&(this._$EC=new Map),this._$EC.set(e,r))):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,r=this._$AL;try{t=this.shouldUpdate(r),t?(this.willUpdate(r),(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(r)):this._$Ek()}catch(n){throw t=!1,this._$Ek(),n}t&&this._$AE(r)}willUpdate(e){}_$AE(e){var t;(t=this._$ES)===null||t===void 0||t.forEach(r=>{var n;return(n=r.hostUpdated)===null||n===void 0?void 0:n.call(r)}),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,r)=>this._$EO(r,this[r],t)),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}};Pt[_s]=!0,Pt.elementProperties=new Map,Pt.elementStyles=[],Pt.shadowRootOptions={mode:"open"},ec?.({ReactiveElement:Pt}),((bs=Yn.reactiveElementVersions)!==null&&bs!==void 0?bs:Yn.reactiveElementVersions=[]).push("1.6.3");var xs,ea=window,lr=ea.trustedTypes,ic=lr?lr.createPolicy("lit-html",{createHTML:i=>i}):void 0,Es="$lit$",Vt=`lit$${(Math.random()+"").slice(9)}$`,lc="?"+Vt,od=`<${lc}>`,Si=document,Hr=()=>Si.createComment(""),zr=i=>i===null||typeof i!="object"&&typeof i!="function",uc=Array.isArray,cd=i=>uc(i)||typeof i?.[Symbol.iterator]=="function",$s=`[
2
+ \f\r]`,Br=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,rc=/-->/g,nc=/>/g,bi=RegExp(`>|${$s}(?:([^\\s"'>=/]+)(${$s}*=${$s}*(?:[^
3
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),ac=/'/g,sc=/"/g,dc=/^(?:script|style|textarea|title)$/i,pc=i=>(e,...t)=>({_$litType$:i,strings:e,values:t}),E=pc(1),gm=pc(2),_i=Symbol.for("lit-noChange"),ke=Symbol.for("lit-nothing"),oc=new WeakMap,wi=Si.createTreeWalker(Si,129,null,!1);function fc(i,e){if(!Array.isArray(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return ic!==void 0?ic.createHTML(e):e}var ld=(i,e)=>{let t=i.length-1,r=[],n,a=e===2?"<svg>":"",s=Br;for(let o=0;o<t;o++){let c=i[o],l,u,m=-1,y=0;for(;y<c.length&&(s.lastIndex=y,u=s.exec(c),u!==null);)y=s.lastIndex,s===Br?u[1]==="!--"?s=rc:u[1]!==void 0?s=nc:u[2]!==void 0?(dc.test(u[2])&&(n=RegExp("</"+u[2],"g")),s=bi):u[3]!==void 0&&(s=bi):s===bi?u[0]===">"?(s=n??Br,m=-1):u[1]===void 0?m=-2:(m=s.lastIndex-u[2].length,l=u[1],s=u[3]===void 0?bi:u[3]==='"'?sc:ac):s===sc||s===ac?s=bi:s===rc||s===nc?s=Br:(s=bi,n=void 0);let d=s===bi&&i[o+1].startsWith("/>")?" ":"";a+=s===Br?c+od:m>=0?(r.push(l),c.slice(0,m)+Es+c.slice(m)+Vt+d):c+Vt+(m===-2?(r.push(void 0),o):d)}return[fc(i,a+(i[t]||"<?>")+(e===2?"</svg>":"")),r]},xi=class{constructor({strings:e,_$litType$:t},r){let n;this.parts=[];let a=0,s=0,o=e.length-1,c=this.parts,[l,u]=ld(e,t);if(this.el=xi.createElement(l,r),wi.currentNode=this.el.content,t===2){let m=this.el.content,y=m.firstChild;y.remove(),m.append(...y.childNodes)}for(;(n=wi.nextNode())!==null&&c.length<o;){if(n.nodeType===1){if(n.hasAttributes()){let m=[];for(let y of n.getAttributeNames())if(y.endsWith(Es)||y.startsWith(Vt)){let d=u[s++];if(m.push(y),d!==void 0){let f=n.getAttribute(d.toLowerCase()+Es).split(Vt),h=/([.?@])?(.*)/.exec(d);c.push({type:1,index:a,name:h[2],strings:f,ctor:h[1]==="."?ks:h[1]==="?"?Is:h[1]==="@"?Ts:dr})}else c.push({type:6,index:a})}for(let y of m)n.removeAttribute(y)}if(dc.test(n.tagName)){let m=n.textContent.split(Vt),y=m.length-1;if(y>0){n.textContent=lr?lr.emptyScript:"";for(let d=0;d<y;d++)n.append(m[d],Hr()),wi.nextNode(),c.push({type:2,index:++a});n.append(m[y],Hr())}}}else if(n.nodeType===8)if(n.data===lc)c.push({type:2,index:a});else{let m=-1;for(;(m=n.data.indexOf(Vt,m+1))!==-1;)c.push({type:7,index:a}),m+=Vt.length-1}a++}}static createElement(e,t){let r=Si.createElement("template");return r.innerHTML=e,r}};function ur(i,e,t=i,r){var n,a,s,o;if(e===_i)return e;let c=r!==void 0?(n=t._$Co)===null||n===void 0?void 0:n[r]:t._$Cl,l=zr(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(i),c._$AT(i,t,r)),r!==void 0?((s=(o=t)._$Co)!==null&&s!==void 0?s:o._$Co=[])[r]=c:t._$Cl=c),c!==void 0&&(e=ur(i,c._$AS(i,e.values),c,r)),e}var As=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:r},parts:n}=this._$AD,a=((t=e?.creationScope)!==null&&t!==void 0?t:Si).importNode(r,!0);wi.currentNode=a;let s=wi.nextNode(),o=0,c=0,l=n[0];for(;l!==void 0;){if(o===l.index){let u;l.type===2?u=new $i(s,s.nextSibling,this,e):l.type===1?u=new l.ctor(s,l.name,l.strings,this,e):l.type===6&&(u=new Cs(s,this,e)),this._$AV.push(u),l=n[++c]}o!==l?.index&&(s=wi.nextNode(),o++)}return wi.currentNode=Si,a}v(e){let t=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}},$i=class{constructor(e,t,r,n){var a;this.type=2,this._$AH=ke,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,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=ur(this,e,t),zr(e)?e===ke||e==null||e===""?(this._$AH!==ke&&this._$AR(),this._$AH=ke):e!==this._$AH&&e!==_i&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):cd(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!==ke&&zr(this._$AH)?this._$AA.nextSibling.data=e:this.$(Si.createTextNode(e)),this._$AH=e}g(e){var t;let{values:r,_$litType$:n}=e,a=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=xi.createElement(fc(n.h,n.h[0]),this.options)),n);if(((t=this._$AH)===null||t===void 0?void 0:t._$AD)===a)this._$AH.v(r);else{let s=new As(a,this),o=s.u(this.options);s.v(r),this.$(o),this._$AH=s}}_$AC(e){let t=oc.get(e.strings);return t===void 0&&oc.set(e.strings,t=new xi(e)),t}T(e){uc(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,r,n=0;for(let a of e)n===t.length?t.push(r=new $i(this.k(Hr()),this.k(Hr()),this,this.options)):r=t[n],r._$AI(a),n++;n<t.length&&(this._$AR(r&&r._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)===null||r===void 0||r.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))}},dr=class{constructor(e,t,r,n,a){this.type=1,this._$AH=ke,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=a,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ke}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,r,n){let a=this.strings,s=!1;if(a===void 0)e=ur(this,e,t,0),s=!zr(e)||e!==this._$AH&&e!==_i,s&&(this._$AH=e);else{let o=e,c,l;for(e=a[0],c=0;c<a.length-1;c++)l=ur(this,o[r+c],t,c),l===_i&&(l=this._$AH[c]),s||(s=!zr(l)||l!==this._$AH[c]),l===ke?e=ke:e!==ke&&(e+=(l??"")+a[c+1]),this._$AH[c]=l}s&&!n&&this.j(e)}j(e){e===ke?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},ks=class extends dr{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ke?void 0:e}},ud=lr?lr.emptyScript:"",Is=class extends dr{constructor(){super(...arguments),this.type=4}j(e){e&&e!==ke?this.element.setAttribute(this.name,ud):this.element.removeAttribute(this.name)}},Ts=class extends dr{constructor(e,t,r,n,a){super(e,t,r,n,a),this.type=5}_$AI(e,t=this){var r;if((e=(r=ur(this,e,t,0))!==null&&r!==void 0?r:ke)===_i)return;let n=this._$AH,a=e===ke&&n!==ke||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,s=e!==ke&&(n===ke||a);a&&this.element.removeEventListener(this.name,this,n),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,r;typeof this._$AH=="function"?this._$AH.call((r=(t=this.options)===null||t===void 0?void 0:t.host)!==null&&r!==void 0?r:this.element,e):this._$AH.handleEvent(e)}},Cs=class{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){ur(this,e)}};var cc=ea.litHtmlPolyfillSupport;cc?.(xi,$i),((xs=ea.litHtmlVersions)!==null&&xs!==void 0?xs:ea.litHtmlVersions=[]).push("2.8.0");var hc=(i,e,t)=>{var r,n;let a=(r=t?.renderBefore)!==null&&r!==void 0?r:e,s=a._$litPart$;if(s===void 0){let o=(n=t?.renderBefore)!==null&&n!==void 0?n:null;a._$litPart$=s=new $i(e.insertBefore(Hr(),o),o,void 0,t??{})}return s._$AI(i),s};var Ls,Ps;var he=class extends Pt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;let r=super.createRenderRoot();return(e=(t=this.renderOptions).renderBefore)!==null&&e!==void 0||(t.renderBefore=r.firstChild),r}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=hc(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 _i}};he.finalized=!0,he._$litElement$=!0,(Ls=globalThis.litElementHydrateSupport)===null||Ls===void 0||Ls.call(globalThis,{LitElement:he});var gc=globalThis.litElementPolyfillSupport;gc?.({LitElement:he});((Ps=globalThis.litElementVersions)!==null&&Ps!==void 0?Ps:globalThis.litElementVersions=[]).push("3.3.3");var Ne=i=>e=>typeof e=="function"?((t,r)=>(customElements.define(t,r),r))(i,e):((t,r)=>{let{kind:n,elements:a}=r;return{kind:n,elements:a,finisher(s){customElements.define(t,s)}}})(i,e);var dd=(i,e)=>e.kind==="method"&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(t){t.createProperty(e.key,i)}}:{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,i)}},pd=(i,e,t)=>{e.constructor.createProperty(t,i)};function ie(i){return(e,t)=>t!==void 0?pd(i,e,t):dd(i,e)}function Z(i){return ie({...i,state:!0})}var Rs,Bm=((Rs=window.HTMLSlotElement)===null||Rs===void 0?void 0:Rs.prototype.assignedElements)!=null?(i,e)=>i.assignedElements(e):(i,e)=>i.assignedNodes(e).filter(t=>t.nodeType===Node.ELEMENT_NODE);var fd=i=>{let e=new Set;do for(let t of Reflect.ownKeys(i))e.add([i,t]);while((i=Reflect.getPrototypeOf(i))&&i!==Object.prototype);return e};function Ns(i,{include:e,exclude:t}={}){let r=n=>{let a=s=>typeof s=="string"?n===s:s.test(n);return e?e.some(a):t?!t.some(a):!0};for(let[n,a]of fd(i.constructor.prototype)){if(a==="constructor"||!r(a))continue;let s=Reflect.getOwnPropertyDescriptor(n,a);s&&typeof s.value=="function"&&(i[a]=i[a].bind(i))}return i}var mc="0.13.0-test-2";function gd(){try{localStorage.setItem("test",""),localStorage.removeItem("test")}catch(i){return!1}return!0}function Wr(i,e){gd()&&localStorage.setItem(`${mc}/${i}`,e)}function Kr(i,e=1e4){return oe(this,null,function*(){return Promise.race([new Promise((t,r)=>{let n;try{n=new WebSocket(i,"graphql-transport-ws"),n.onopen=()=>{n.close(),t(n)},n.onerror=a=>{r(a)},n.onclose=a=>{a.code!==1e3&&r(new Error(`WebSocket closed with code ${a.code}: ${a.reason}`))}}catch(a){n&&n.close(),r(a)}}),new Promise((t,r)=>{setTimeout(()=>{r(new Error("WebSocket connection timed out"))},e)})])})}function yc(i){let e=i.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 vc(i){let e=0;for(let t=0;t<i.length;t++)e=i.charCodeAt(t)+((e<<5)-e);return(e%360+360)%360}function Ei(){return E`
4
4
  <svg viewBox="0 0 63.6 60" fill="none" xmlns="http://www.w3.org/2000/svg">
5
5
  <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" />
6
6
  </svg>
7
- `}function or(){return I`
7
+ `}function pr(){return E`
8
8
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
9
9
  <circle cx="12" cy="12" r="10"></circle>
10
10
  <circle cx="12" cy="12" r="3" fill="currentColor"></circle>
11
11
  </svg>
12
- `}function Wn(){return I`
12
+ `}function ta(){return E`
13
13
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
14
14
  <circle cx="12" cy="12" r="10"></circle>
15
15
  <path d="M2 12h20"></path>
16
16
  <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>
17
17
  </svg>
18
- `}function Kn(){return I`
18
+ `}function ia(){return E`
19
19
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
20
20
  <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path>
21
21
  <polyline points="7 10 12 15 17 10"></polyline>
22
22
  <line x1="12" y1="15" x2="12" y2="3"></line>
23
23
  </svg>
24
- `}function mt(){return I`
24
+ `}function Ke(){return E`
25
25
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
26
26
  <rect width="256" height="256" fill="none"/>
27
27
  <polyline points="40 144 96 200 224 72" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/>
28
28
  </svg>
29
- `}function Ue(){return I`
29
+ `}function De(){return E`
30
30
  <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 256 256">
31
31
  <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>
32
32
  </svg>
33
- `}function Qn(){return I`
33
+ `}function ra(){return E`
34
34
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-clockwise" viewBox="0 0 16 16">
35
35
  <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"/>
36
36
  <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"/>
37
37
  </svg>
38
- `}function Gn(){return I`
38
+ `}function na(){return E`
39
39
  <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">
40
40
  <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"/>
41
41
  </svg>
42
- `}function wt(){return I`
42
+ `}function aa(){return E`
43
43
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
44
44
  <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"/>
45
45
  </svg>
46
- `}function Zn(){return I`
46
+ `}function sa(){return E`
47
47
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
48
48
  <circle cx="12" cy="12" r="10"></circle>
49
49
  <path d="M2 12h20"></path>
50
50
  <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>
51
51
  </svg>
52
- `}function Hr(){return I`
52
+ `}function Wt(){return E`
53
53
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
54
54
  <circle cx="12" cy="12" r="10"></circle>
55
55
  <path d="M12 6v12"></path>
56
56
  <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>
57
57
  </svg>
58
- `}function Jn(){return I`
58
+ `}function oa(){return E`
59
59
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
60
60
  <rect x="2" y="6" width="20" height="14" rx="2"></rect>
61
61
  <path d="M2 10h20"></path>
62
62
  <circle cx="16" cy="14" r="1" fill="currentColor"></circle>
63
63
  </svg>
64
- `}var id="https://hosting.ad4m.dev";function rd(i){try{return new URL(i),!0}catch(e){return!1}}function As(i){return pe(this,null,function*(){let e=i||id,t=yield fetch(`${e}/hosts`);if(!t.ok)throw new Error(`Failed to fetch hosts: ${t.status}`);let r=yield t.json();for(let n of r)n.profilePicUrl&&!rd(n.profilePicUrl)&&(n.profilePicUrl=new URL(n.profilePicUrl,e).toString());return r})}var Ke=Ee`
64
+ `}function Kt(){return E`
65
+ <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16">
66
+ <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"/>
67
+ </svg>
68
+ `}var md="https://hosting.ad4m.dev";function yd(i){try{return new URL(i),!0}catch(e){return!1}}function Os(i){return oe(this,null,function*(){let e=i||md,t=yield fetch(`${e}/hosts`);if(!t.ok)throw new Error(`Failed to fetch hosts: ${t.status}`);let r=yield t.json();for(let n of r)n.profilePicUrl&&!yd(n.profilePicUrl)&&(n.profilePicUrl=new URL(n.profilePicUrl,e).toString());return r})}var Qe=$e`
65
69
  * {
66
70
  box-sizing: border-box;
67
71
  }
@@ -169,6 +173,22 @@ var Uo=Object.defineProperty,Fu=Object.defineProperties,ju=Object.getOwnProperty
169
173
  box-shadow: 0 0 0 4px rgba(244, 54, 127, 0.2);
170
174
  }
171
175
 
176
+ button.danger-secondary {
177
+ background: #00091e5c;
178
+ color: var(--ac-danger-color);
179
+ border: 1px solid var(--ac-danger-color);
180
+ }
181
+
182
+ button.danger-secondary:hover:not(:disabled) {
183
+ background: rgba(244, 54, 127, 0.12);
184
+ }
185
+
186
+ button.danger-secondary:focus-visible:not(:disabled) {
187
+ outline: 2px solid var(--ac-danger-color);
188
+ outline-offset: 2px;
189
+ box-shadow: 0 0 0 4px rgba(244, 54, 127, 0.2);
190
+ }
191
+
172
192
  button:disabled {
173
193
  opacity: 0.5;
174
194
  cursor: not-allowed;
@@ -178,22 +198,13 @@ var Uo=Object.defineProperty,Fu=Object.defineProperties,ju=Object.getOwnProperty
178
198
  width: 100%;
179
199
  }
180
200
 
181
- .back-button,
182
201
  .close-button {
183
202
  position: absolute;
184
203
  top: 20px;
185
- cursor: pointer;
186
- }
187
-
188
- .back-button {
189
- left: 20px;
190
- }
191
-
192
- .close-button {
193
204
  right: 20px;
205
+ cursor: pointer;
194
206
  }
195
207
 
196
- .back-button svg,
197
208
  .close-button svg {
198
209
  width: 28px;
199
210
  height: 28px;
@@ -201,6 +212,25 @@ var Uo=Object.defineProperty,Fu=Object.defineProperties,ju=Object.getOwnProperty
201
212
  opacity: 0.5;
202
213
  }
203
214
 
215
+ .back-button {
216
+ all: unset;
217
+ display: inline-flex;
218
+ align-items: center;
219
+ gap: 4px;
220
+ cursor: pointer;
221
+ font-size: 14px;
222
+ color: rgba(255, 255, 255, 0.5);
223
+ }
224
+
225
+ .back-button svg {
226
+ width: 22px;
227
+ height: 22px;
228
+ }
229
+
230
+ .back-button:hover {
231
+ color: rgba(255, 255, 255, 0.8);
232
+ }
233
+
204
234
  /* Inputs */
205
235
  input {
206
236
  width: 100%;
@@ -324,7 +354,21 @@ var Uo=Object.defineProperty,Fu=Object.defineProperties,ju=Object.getOwnProperty
324
354
  .state.danger svg {
325
355
  color: var(--ac-danger-color);
326
356
  }
327
- `;var et=class extends ge{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 pe(this,null,function*(){this.dispatchEvent(new CustomEvent("change-port",{detail:{port:this.newPort},bubbles:!0,composed:!0}))})}connectLocalNode(){return pe(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 pe(this,null,function*(){try{yield qr(`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 pe(this,null,function*(){jo(et.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:I`
357
+
358
+ /* Spinners */
359
+ .spinner {
360
+ width: 24px;
361
+ height: 24px;
362
+ border: 3px solid var(--ac-border-color-light);
363
+ border-top-color: var(--ac-primary-color);
364
+ border-radius: 50%;
365
+ animation: spin 0.8s linear infinite;
366
+ }
367
+
368
+ @keyframes spin {
369
+ to { transform: rotate(360deg); }
370
+ }
371
+ `;var tt=class extends he{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 oe(this,null,function*(){this.dispatchEvent(new CustomEvent("change-port",{detail:{port:this.newPort},bubbles:!0,composed:!0}))})}connectLocalNode(){return oe(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 oe(this,null,function*(){try{yield Kr(`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 oe(this,null,function*(){Zo(tt.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:E`
328
372
  <div class="container">
329
373
  <div class="header">
330
374
  <h1>Connect AD4M</h1>
@@ -332,31 +376,31 @@ var Uo=Object.defineProperty,Fu=Object.defineProperties,ju=Object.getOwnProperty
332
376
  </div>
333
377
 
334
378
  <div class="options">
335
- ${!this.isMobile||!this.showHosting?I`
379
+ ${!this.isMobile||!this.showHosting?E`
336
380
  <div class="box">
337
381
  <div class="box-header">
338
- ${or()}
382
+ ${pr()}
339
383
  <h3>Local Node</h3>
340
384
  </div>
341
385
 
342
- ${this.localNodeDetected?I`
386
+ ${this.localNodeDetected?E`
343
387
  <div class="state success">
344
- ${mt()}
388
+ ${Ke()}
345
389
  <p>Local node detected on port ${this.port}</p>
346
390
  </div>
347
391
 
348
392
  <button class="primary" @click=${this.connectLocalNode}>
349
393
  Connect to Local Node
350
394
  </button>
351
- `:I`
395
+ `:E`
352
396
  <div class="state danger">
353
- ${Ue()}
397
+ ${De()}
354
398
  <p>No local node detected on port ${this.port}</p>
355
399
  </div>
356
400
 
357
401
  <p style="margin-bottom: -12px">Download and install AD4M</p>
358
402
  <button class="secondary" @click=${()=>window.open("https://github.com/coasys/ad4m/releases")}>
359
- ${Kn()} Download AD4M
403
+ ${ia()} Download AD4M
360
404
  </button>
361
405
  `}
362
406
 
@@ -370,16 +414,16 @@ var Uo=Object.defineProperty,Fu=Object.defineProperties,ju=Object.getOwnProperty
370
414
  @keydown=${t=>{t.key==="Enter"&&this.refreshPort()}}
371
415
  />
372
416
  <button class="primary" @click=${this.refreshPort}>
373
- ${Qn()}
417
+ ${ra()}
374
418
  </button>
375
419
  </div>
376
420
  </div>
377
421
  `:""}
378
422
 
379
- ${this.showHosting?I`
423
+ ${this.showHosting?E`
380
424
  <div class="box">
381
425
  <div class="box-header">
382
- ${Zn()}
426
+ ${sa()}
383
427
  <h3>Remote Node</h3>
384
428
  </div>
385
429
 
@@ -392,7 +436,7 @@ var Uo=Object.defineProperty,Fu=Object.defineProperties,ju=Object.getOwnProperty
392
436
  `:""}
393
437
  </div>
394
438
  </div>
395
- `}};et.styles=[Ke,Ee`
439
+ `}};tt.styles=[Qe,$e`
396
440
  .options {
397
441
  display: flex;
398
442
  flex-direction: column;
@@ -421,38 +465,38 @@ var Uo=Object.defineProperty,Fu=Object.defineProperties,ju=Object.getOwnProperty
421
465
  button {
422
466
  width: 100%;
423
467
  }
424
- `],L([ie({type:Number})],et.prototype,"port",2),L([ie({type:Boolean})],et.prototype,"showHosting",2),L([Y()],et.prototype,"loading",2),L([Y()],et.prototype,"localNodeDetected",2),L([Y()],et.prototype,"newPort",2),L([Y()],et.prototype,"isMobile",2),et=L([Ne("connection-options")],et);var Ia=function(){return Ia=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},Ia.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;function pa(i){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?pa=function(t){return typeof t}:pa=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pa(i)}function nd(i){return pa(i)=="object"&&i!==null}var Pl=typeof Symbol=="function"&&Symbol.toStringTag!=null?Symbol.toStringTag:"@@toStringTag";function Ws(i,e){for(var t=/\r\n|[\n\r]/g,r=1,n=e+1,a;(a=t.exec(i.body))&&a.index<e;)r+=1,n=e+1-(a.index+a[0].length);return{line:r,column:n}}function ad(i){return Rl(i.source,Ws(i.source,i.start))}function Rl(i,e){var t=i.locationOffset.column-1,r=fa(t)+i.body,n=e.line-1,a=i.locationOffset.line-1,s=e.line+a,o=e.line===1?t:0,l=e.column+o,c="".concat(i.name,":").concat(s,":").concat(l,`
425
- `),u=r.split(/\r\n|[\n\r]/g),m=u[n];if(m.length>120){for(var y=Math.floor(l/80),d=l%80,f=[],g=0;g<m.length;g+=80)f.push(m.slice(g,g+80));return c+lc([["".concat(s),f[0]]].concat(f.slice(1,y+1).map(function(_){return["",_]}),[[" ",fa(d-1)+"^"],["",f[y+1]]]))}return c+lc([["".concat(s-1),u[n-1]],["".concat(s),m],["",fa(l-1)+"^"],["".concat(s+1),u[n+1]]])}function lc(i){var e=i.filter(function(r){r[0];var n=r[1];return n!==void 0}),t=Math.max.apply(Math,e.map(function(r){var n=r[0];return n.length}));return e.map(function(r){var n=r[0],a=r[1];return sd(t,n)+(a?" | "+a:" |")}).join(`
426
- `)}function fa(i){return Array(i+1).join(" ")}function sd(i,e){return fa(i-e.length)+e}function ha(i){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ha=function(t){return typeof t}:ha=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ha(i)}function uc(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(i,n).enumerable})),t.push.apply(t,r)}return t}function od(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?uc(Object(t),!0).forEach(function(r){cd(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):uc(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function cd(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ld(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function dc(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function ud(i,e,t){return e&&dc(i.prototype,e),t&&dc(i,t),i}function dd(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&wn(i,e)}function pd(i){var e=Ol();return function(){var r=Sn(i),n;if(e){var a=Sn(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return Nl(this,n)}}function Nl(i,e){return e&&(ha(e)==="object"||typeof e=="function")?e:Qr(i)}function Qr(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function Ks(i){var e=typeof Map=="function"?new Map:void 0;return Ks=function(r){if(r===null||!fd(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(r))return e.get(r);e.set(r,n)}function n(){return ga(r,arguments,Sn(this).constructor)}return n.prototype=Object.create(r.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),wn(n,r)},Ks(i)}function ga(i,e,t){return Ol()?ga=Reflect.construct:ga=function(n,a,s){var o=[null];o.push.apply(o,a);var l=Function.bind.apply(n,o),c=new l;return s&&wn(c,s.prototype),c},ga.apply(null,arguments)}function Ol(){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 fd(i){return Function.toString.call(i).indexOf("[native code]")!==-1}function wn(i,e){return wn=Object.setPrototypeOf||function(r,n){return r.__proto__=n,r},wn(i,e)}function Sn(i){return Sn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Sn(i)}var hd=function(i){dd(t,i);var e=pd(t);function t(r,n,a,s,o,l,c){var u,m,y,d;ld(this,t),d=e.call(this,r),d.name="GraphQLError",d.originalError=l??void 0,d.nodes=pc(Array.isArray(n)?n:n?[n]:void 0);for(var f=[],g=0,_=(E=d.nodes)!==null&&E!==void 0?E:[];g<_.length;g++){var E,A=_[g],k=A.loc;k!=null&&f.push(k)}f=pc(f),d.source=a??((u=f)===null||u===void 0?void 0:u[0].source),d.positions=s??((m=f)===null||m===void 0?void 0:m.map(function(C){return C.start})),d.locations=s&&a?s.map(function(C){return Ws(a,C)}):(y=f)===null||y===void 0?void 0:y.map(function(C){return Ws(C.source,C.start)}),d.path=o??void 0;var w=l?.extensions;return c==null&&nd(w)?d.extensions=od({},w):d.extensions=c??{},Object.defineProperties(Qr(d),{message:{enumerable:!0},locations:{enumerable:d.locations!=null},path:{enumerable:d.path!=null},extensions:{enumerable:d.extensions!=null&&Object.keys(d.extensions).length>0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),l!=null&&l.stack?(Object.defineProperty(Qr(d),"stack",{value:l.stack,writable:!0,configurable:!0}),Nl(d)):(Error.captureStackTrace?Error.captureStackTrace(Qr(d),t):Object.defineProperty(Qr(d),"stack",{value:Error().stack,writable:!0,configurable:!0}),d)}return ud(t,[{key:"toString",value:function(){return gd(this)}},{key:Pl,get:function(){return"Object"}}]),t}(Ks(Error));function pc(i){return i===void 0||i.length===0?void 0:i}function gd(i){var e=i.message;if(i.nodes)for(var t=0,r=i.nodes;t<r.length;t++){var n=r[t];n.loc&&(e+=`
468
+ `],C([ie({type:Number})],tt.prototype,"port",2),C([ie({type:Boolean})],tt.prototype,"showHosting",2),C([Z()],tt.prototype,"loading",2),C([Z()],tt.prototype,"localNodeDetected",2),C([Z()],tt.prototype,"newPort",2),C([Z()],tt.prototype,"isMobile",2),tt=C([Ne("connection-options")],tt);var Da=function(){return Da=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e},Da.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;function Sa(i){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Sa=function(t){return typeof t}:Sa=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Sa(i)}function vd(i){return Sa(i)=="object"&&i!==null}var Vl=typeof Symbol=="function"&&Symbol.toStringTag!=null?Symbol.toStringTag:"@@toStringTag";function io(i,e){for(var t=/\r\n|[\n\r]/g,r=1,n=e+1,a;(a=t.exec(i.body))&&a.index<e;)r+=1,n=e+1-(a.index+a[0].length);return{line:r,column:n}}function bd(i){return Wl(i.source,io(i.source,i.start))}function Wl(i,e){var t=i.locationOffset.column-1,r=_a(t)+i.body,n=e.line-1,a=i.locationOffset.line-1,s=e.line+a,o=e.line===1?t:0,c=e.column+o,l="".concat(i.name,":").concat(s,":").concat(c,`
469
+ `),u=r.split(/\r\n|[\n\r]/g),m=u[n];if(m.length>120){for(var y=Math.floor(c/80),d=c%80,f=[],h=0;h<m.length;h+=80)f.push(m.slice(h,h+80));return l+bc([["".concat(s),f[0]]].concat(f.slice(1,y+1).map(function(S){return["",S]}),[[" ",_a(d-1)+"^"],["",f[y+1]]]))}return l+bc([["".concat(s-1),u[n-1]],["".concat(s),m],["",_a(c-1)+"^"],["".concat(s+1),u[n+1]]])}function bc(i){var e=i.filter(function(r){r[0];var n=r[1];return n!==void 0}),t=Math.max.apply(Math,e.map(function(r){var n=r[0];return n.length}));return e.map(function(r){var n=r[0],a=r[1];return wd(t,n)+(a?" | "+a:" |")}).join(`
470
+ `)}function _a(i){return Array(i+1).join(" ")}function wd(i,e){return _a(i-e.length)+e}function xa(i){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?xa=function(t){return typeof t}:xa=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xa(i)}function wc(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(n){return Object.getOwnPropertyDescriptor(i,n).enumerable})),t.push.apply(t,r)}return t}function Sd(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?wc(Object(t),!0).forEach(function(r){_d(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):wc(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function _d(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function xd(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function Sc(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function $d(i,e,t){return e&&Sc(i.prototype,e),t&&Sc(i,t),i}function Ed(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&Tn(i,e)}function Ad(i){var e=Ql();return function(){var r=Cn(i),n;if(e){var a=Cn(this).constructor;n=Reflect.construct(r,arguments,a)}else n=r.apply(this,arguments);return Kl(this,n)}}function Kl(i,e){return e&&(xa(e)==="object"||typeof e=="function")?e:Xr(i)}function Xr(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function ro(i){var e=typeof Map=="function"?new Map:void 0;return ro=function(r){if(r===null||!kd(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(r))return e.get(r);e.set(r,n)}function n(){return $a(r,arguments,Cn(this).constructor)}return n.prototype=Object.create(r.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Tn(n,r)},ro(i)}function $a(i,e,t){return Ql()?$a=Reflect.construct:$a=function(n,a,s){var o=[null];o.push.apply(o,a);var c=Function.bind.apply(n,o),l=new c;return s&&Tn(l,s.prototype),l},$a.apply(null,arguments)}function Ql(){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 kd(i){return Function.toString.call(i).indexOf("[native code]")!==-1}function Tn(i,e){return Tn=Object.setPrototypeOf||function(r,n){return r.__proto__=n,r},Tn(i,e)}function Cn(i){return Cn=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},Cn(i)}var Id=function(i){Ed(t,i);var e=Ad(t);function t(r,n,a,s,o,c,l){var u,m,y,d;xd(this,t),d=e.call(this,r),d.name="GraphQLError",d.originalError=c??void 0,d.nodes=_c(Array.isArray(n)?n:n?[n]:void 0);for(var f=[],h=0,S=(x=d.nodes)!==null&&x!==void 0?x:[];h<S.length;h++){var x,T=S[h],k=T.loc;k!=null&&f.push(k)}f=_c(f),d.source=a??((u=f)===null||u===void 0?void 0:u[0].source),d.positions=s??((m=f)===null||m===void 0?void 0:m.map(function(L){return L.start})),d.locations=s&&a?s.map(function(L){return io(a,L)}):(y=f)===null||y===void 0?void 0:y.map(function(L){return io(L.source,L.start)}),d.path=o??void 0;var _=c?.extensions;return l==null&&vd(_)?d.extensions=Sd({},_):d.extensions=l??{},Object.defineProperties(Xr(d),{message:{enumerable:!0},locations:{enumerable:d.locations!=null},path:{enumerable:d.path!=null},extensions:{enumerable:d.extensions!=null&&Object.keys(d.extensions).length>0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),c!=null&&c.stack?(Object.defineProperty(Xr(d),"stack",{value:c.stack,writable:!0,configurable:!0}),Kl(d)):(Error.captureStackTrace?Error.captureStackTrace(Xr(d),t):Object.defineProperty(Xr(d),"stack",{value:Error().stack,writable:!0,configurable:!0}),d)}return $d(t,[{key:"toString",value:function(){return Td(this)}},{key:Vl,get:function(){return"Object"}}]),t}(ro(Error));function _c(i){return i===void 0||i.length===0?void 0:i}function Td(i){var e=i.message;if(i.nodes)for(var t=0,r=i.nodes;t<r.length;t++){var n=r[t];n.loc&&(e+=`
427
471
 
428
- `+ad(n.loc))}else if(i.source&&i.locations)for(var a=0,s=i.locations;a<s.length;a++){var o=s[a];e+=`
472
+ `+bd(n.loc))}else if(i.source&&i.locations)for(var a=0,s=i.locations;a<s.length;a++){var o=s[a];e+=`
429
473
 
430
- `+Rl(i.source,o)}return e}function it(i,e,t){return new hd("Syntax Error: ".concat(t),void 0,i,[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 md(i,e){var t=Boolean(i);if(!t)throw new Error(e??"Unexpected invariant triggered.")}var yd=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):void 0,Qs=yd;function Dl(i){var e=i.prototype.toJSON;typeof e=="function"||md(0),i.prototype.inspect=e,Qs&&(i.prototype[Qs]=e)}var Ul=function(){function i(t,r,n){this.start=t.start,this.end=r.end,this.startToken=t,this.endToken=r,this.source=n}var e=i.prototype;return e.toJSON=function(){return{start:this.start,end:this.end}},i}();Dl(Ul);var ve=function(){function i(t,r,n,a,s,o,l){this.kind=t,this.start=r,this.end=n,this.line=a,this.column=s,this.value=l,this.prev=o,this.next=null}var e=i.prototype;return e.toJSON=function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}},i}();Dl(ve);var $=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 ma(i){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ma=function(t){return typeof t}:ma=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ma(i)}var vd=10,Ml=2;function bd(i){return Ja(i,[])}function Ja(i,e){switch(ma(i)){case"string":return JSON.stringify(i);case"function":return i.name?"[function ".concat(i.name,"]"):"[function]";case"object":return i===null?"null":wd(i,e);default:return String(i)}}function wd(i,e){if(e.indexOf(i)!==-1)return"[Circular]";var t=[].concat(e,[i]),r=xd(i);if(r!==void 0){var n=r.call(i);if(n!==i)return typeof n=="string"?n:Ja(n,t)}else if(Array.isArray(i))return _d(i,t);return Sd(i,t)}function Sd(i,e){var t=Object.keys(i);if(t.length===0)return"{}";if(e.length>Ml)return"["+Ed(i)+"]";var r=t.map(function(n){var a=Ja(i[n],e);return n+": "+a});return"{ "+r.join(", ")+" }"}function _d(i,e){if(i.length===0)return"[]";if(e.length>Ml)return"[Array]";for(var t=Math.min(vd,i.length),r=i.length-t,n=[],a=0;a<t;++a)n.push(Ja(i[a],e));return r===1?n.push("... 1 more item"):r>1&&n.push("... ".concat(r," more items")),"["+n.join(", ")+"]"}function xd(i){var e=i[String(Qs)];if(typeof e=="function")return e;if(typeof i.inspect=="function")return i.inspect}function Ed(i){var e=Object.prototype.toString.call(i).replace(/^\[object /,"").replace(/]$/,"");if(e==="Object"&&typeof i.constructor=="function"){var t=i.constructor.name;if(typeof t=="string"&&t!=="")return t}return e}function ks(i,e){var t=Boolean(i);if(!t)throw new Error(e)}var $d=function(e,t){return e instanceof t};function fc(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function Ad(i,e,t){return e&&fc(i.prototype,e),t&&fc(i,t),i}var Fl=function(){function i(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GraphQL request",r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{line:1,column:1};typeof e=="string"||ks(0,"Body must be a string. Received: ".concat(bd(e),".")),this.body=e,this.name=t,this.locationOffset=r,this.locationOffset.line>0||ks(0,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||ks(0,"column in locationOffset is 1-indexed and must be positive.")}return Ad(i,[{key:Pl,get:function(){return"Source"}}]),i}();function kd(i){return $d(i,Fl)}var Id=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 Td(i){var e=i.split(/\r\n|[\n\r]/g),t=Cd(i);if(t!==0)for(var r=1;r<e.length;r++)e[r]=e[r].slice(t);for(var n=0;n<e.length&&hc(e[n]);)++n;for(var a=e.length;a>n&&hc(e[a-1]);)--a;return e.slice(n,a).join(`
431
- `)}function hc(i){for(var e=0;e<i.length;++e)if(i[e]!==" "&&i[e]!==" ")return!1;return!0}function Cd(i){for(var e,t=!0,r=!0,n=0,a=null,s=0;s<i.length;++s)switch(i.charCodeAt(s)){case 13:i.charCodeAt(s+1)===10&&++s;case 10:t=!1,r=!0,n=0;break;case 9:case 32:++n;break;default:r&&!t&&(a===null||n<a)&&(a=n),r=!1}return(e=a)!==null&&e!==void 0?e:0}var Ld=function(){function i(t){var r=new ve($.SOF,0,0,0,0,null);this.source=t,this.lastToken=r,this.token=r,this.line=1,this.lineStart=0}var e=i.prototype;return e.advance=function(){this.lastToken=this.token;var r=this.token=this.lookahead();return r},e.lookahead=function(){var r=this.token;if(r.kind!==$.EOF)do{var n;r=(n=r.next)!==null&&n!==void 0?n:r.next=Rd(this,r)}while(r.kind===$.COMMENT);return r},i}();function Pd(i){return i===$.BANG||i===$.DOLLAR||i===$.AMP||i===$.PAREN_L||i===$.PAREN_R||i===$.SPREAD||i===$.COLON||i===$.EQUALS||i===$.AT||i===$.BRACKET_L||i===$.BRACKET_R||i===$.BRACE_L||i===$.PIPE||i===$.BRACE_R}function Mi(i){return isNaN(i)?$.EOF:i<127?JSON.stringify(String.fromCharCode(i)):'"\\u'.concat(("00"+i.toString(16).toUpperCase()).slice(-4),'"')}function Rd(i,e){for(var t=i.source,r=t.body,n=r.length,a=e.end;a<n;){var s=r.charCodeAt(a),o=i.line,l=1+a-i.lineStart;switch(s){case 65279:case 9:case 32:case 44:++a;continue;case 10:++a,++i.line,i.lineStart=a;continue;case 13:r.charCodeAt(a+1)===10?a+=2:++a,++i.line,i.lineStart=a;continue;case 33:return new ve($.BANG,a,a+1,o,l,e);case 35:return Od(t,a,o,l,e);case 36:return new ve($.DOLLAR,a,a+1,o,l,e);case 38:return new ve($.AMP,a,a+1,o,l,e);case 40:return new ve($.PAREN_L,a,a+1,o,l,e);case 41:return new ve($.PAREN_R,a,a+1,o,l,e);case 46:if(r.charCodeAt(a+1)===46&&r.charCodeAt(a+2)===46)return new ve($.SPREAD,a,a+3,o,l,e);break;case 58:return new ve($.COLON,a,a+1,o,l,e);case 61:return new ve($.EQUALS,a,a+1,o,l,e);case 64:return new ve($.AT,a,a+1,o,l,e);case 91:return new ve($.BRACKET_L,a,a+1,o,l,e);case 93:return new ve($.BRACKET_R,a,a+1,o,l,e);case 123:return new ve($.BRACE_L,a,a+1,o,l,e);case 124:return new ve($.PIPE,a,a+1,o,l,e);case 125:return new ve($.BRACE_R,a,a+1,o,l,e);case 34:return r.charCodeAt(a+1)===34&&r.charCodeAt(a+2)===34?Md(t,a,o,l,e,i):Ud(t,a,o,l,e);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return Dd(t,a,s,o,l,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 jd(t,a,o,l,e)}throw it(t,a,Nd(s))}var c=i.line,u=1+a-i.lineStart;return new ve($.EOF,n,n,c,u,e)}function Nd(i){return i<32&&i!==9&&i!==10&&i!==13?"Cannot contain the invalid character ".concat(Mi(i),"."):i===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:"Cannot parse the unexpected character ".concat(Mi(i),".")}function Od(i,e,t,r,n){var a=i.body,s,o=e;do s=a.charCodeAt(++o);while(!isNaN(s)&&(s>31||s===9));return new ve($.COMMENT,e,o,t,r,n,a.slice(e+1,o))}function Dd(i,e,t,r,n,a){var s=i.body,o=t,l=e,c=!1;if(o===45&&(o=s.charCodeAt(++l)),o===48){if(o=s.charCodeAt(++l),o>=48&&o<=57)throw it(i,l,"Invalid number, unexpected digit after 0: ".concat(Mi(o),"."))}else l=Is(i,l,o),o=s.charCodeAt(l);if(o===46&&(c=!0,o=s.charCodeAt(++l),l=Is(i,l,o),o=s.charCodeAt(l)),(o===69||o===101)&&(c=!0,o=s.charCodeAt(++l),(o===43||o===45)&&(o=s.charCodeAt(++l)),l=Is(i,l,o),o=s.charCodeAt(l)),o===46||Bd(o))throw it(i,l,"Invalid number, expected digit but got: ".concat(Mi(o),"."));return new ve(c?$.FLOAT:$.INT,e,l,r,n,a,s.slice(e,l))}function Is(i,e,t){var r=i.body,n=e,a=t;if(a>=48&&a<=57){do a=r.charCodeAt(++n);while(a>=48&&a<=57);return n}throw it(i,n,"Invalid number, expected digit but got: ".concat(Mi(a),"."))}function Ud(i,e,t,r,n){for(var a=i.body,s=e+1,o=s,l=0,c="";s<a.length&&!isNaN(l=a.charCodeAt(s))&&l!==10&&l!==13;){if(l===34)return c+=a.slice(o,s),new ve($.STRING,e,s+1,t,r,n,c);if(l<32&&l!==9)throw it(i,s,"Invalid character within String: ".concat(Mi(l),"."));if(++s,l===92){switch(c+=a.slice(o,s-1),l=a.charCodeAt(s),l){case 34:c+='"';break;case 47:c+="/";break;case 92:c+="\\";break;case 98:c+="\b";break;case 102:c+="\f";break;case 110:c+=`
432
- `;break;case 114:c+="\r";break;case 116:c+=" ";break;case 117:{var u=Fd(a.charCodeAt(s+1),a.charCodeAt(s+2),a.charCodeAt(s+3),a.charCodeAt(s+4));if(u<0){var m=a.slice(s+1,s+5);throw it(i,s,"Invalid character escape sequence: \\u".concat(m,"."))}c+=String.fromCharCode(u),s+=4;break}default:throw it(i,s,"Invalid character escape sequence: \\".concat(String.fromCharCode(l),"."))}++s,o=s}}throw it(i,s,"Unterminated string.")}function Md(i,e,t,r,n,a){for(var s=i.body,o=e+3,l=o,c=0,u="";o<s.length&&!isNaN(c=s.charCodeAt(o));){if(c===34&&s.charCodeAt(o+1)===34&&s.charCodeAt(o+2)===34)return u+=s.slice(l,o),new ve($.BLOCK_STRING,e,o+3,t,r,n,Td(u));if(c<32&&c!==9&&c!==10&&c!==13)throw it(i,o,"Invalid character within String: ".concat(Mi(c),"."));c===10?(++o,++a.line,a.lineStart=o):c===13?(s.charCodeAt(o+1)===10?o+=2:++o,++a.line,a.lineStart=o):c===92&&s.charCodeAt(o+1)===34&&s.charCodeAt(o+2)===34&&s.charCodeAt(o+3)===34?(u+=s.slice(l,o)+'"""',o+=4,l=o):++o}throw it(i,o,"Unterminated string.")}function Fd(i,e,t,r){return Yn(i)<<12|Yn(e)<<8|Yn(t)<<4|Yn(r)}function Yn(i){return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:-1}function jd(i,e,t,r,n){for(var a=i.body,s=a.length,o=e+1,l=0;o!==s&&!isNaN(l=a.charCodeAt(o))&&(l===95||l>=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122);)++o;return new ve($.NAME,e,o,t,r,n,a.slice(e,o))}function Bd(i){return i===95||i>=65&&i<=90||i>=97&&i<=122}function qd(i,e){var t=new Hd(i,e);return t.parseDocument()}var Hd=function(){function i(t,r){var n=kd(t)?t:new Fl(t);this._lexer=new Ld(n),this._options=r}var e=i.prototype;return e.parseName=function(){var r=this.expectToken($.NAME);return{kind:z.NAME,value:r.value,loc:this.loc(r)}},e.parseDocument=function(){var r=this._lexer.token;return{kind:z.DOCUMENT,definitions:this.many($.SOF,this.parseDefinition,$.EOF),loc:this.loc(r)}},e.parseDefinition=function(){if(this.peek($.NAME))switch(this._lexer.token.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"schema":case"scalar":case"type":case"interface":case"union":case"enum":case"input":case"directive":return this.parseTypeSystemDefinition();case"extend":return this.parseTypeSystemExtension()}else{if(this.peek($.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},e.parseOperationDefinition=function(){var r=this._lexer.token;if(this.peek($.BRACE_L))return{kind:z.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(r)};var n=this.parseOperationType(),a;return this.peek($.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(r)}},e.parseOperationType=function(){var r=this.expectToken($.NAME);switch(r.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(r)},e.parseVariableDefinitions=function(){return this.optionalMany($.PAREN_L,this.parseVariableDefinition,$.PAREN_R)},e.parseVariableDefinition=function(){var r=this._lexer.token;return{kind:z.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken($.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken($.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(r)}},e.parseVariable=function(){var r=this._lexer.token;return this.expectToken($.DOLLAR),{kind:z.VARIABLE,name:this.parseName(),loc:this.loc(r)}},e.parseSelectionSet=function(){var r=this._lexer.token;return{kind:z.SELECTION_SET,selections:this.many($.BRACE_L,this.parseSelection,$.BRACE_R),loc:this.loc(r)}},e.parseSelection=function(){return this.peek($.SPREAD)?this.parseFragment():this.parseField()},e.parseField=function(){var r=this._lexer.token,n=this.parseName(),a,s;return this.expectOptionalToken($.COLON)?(a=n,s=this.parseName()):s=n,{kind:z.FIELD,alias:a,name:s,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek($.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(r)}},e.parseArguments=function(r){var n=r?this.parseConstArgument:this.parseArgument;return this.optionalMany($.PAREN_L,n,$.PAREN_R)},e.parseArgument=function(){var r=this._lexer.token,n=this.parseName();return this.expectToken($.COLON),{kind:z.ARGUMENT,name:n,value:this.parseValueLiteral(!1),loc:this.loc(r)}},e.parseConstArgument=function(){var r=this._lexer.token;return{kind:z.ARGUMENT,name:this.parseName(),value:(this.expectToken($.COLON),this.parseValueLiteral(!0)),loc:this.loc(r)}},e.parseFragment=function(){var r=this._lexer.token;this.expectToken($.SPREAD);var n=this.expectOptionalKeyword("on");return!n&&this.peek($.NAME)?{kind:z.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(r)}:{kind:z.INLINE_FRAGMENT,typeCondition:n?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(r)}},e.parseFragmentDefinition=function(){var r,n=this._lexer.token;return this.expectKeyword("fragment"),((r=this._options)===null||r===void 0?void 0:r.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(r){var n=this._lexer.token;switch(n.kind){case $.BRACKET_L:return this.parseList(r);case $.BRACE_L:return this.parseObject(r);case $.INT:return this._lexer.advance(),{kind:z.INT,value:n.value,loc:this.loc(n)};case $.FLOAT:return this._lexer.advance(),{kind:z.FLOAT,value:n.value,loc:this.loc(n)};case $.STRING:case $.BLOCK_STRING:return this.parseStringLiteral();case $.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 $.DOLLAR:if(!r)return this.parseVariable();break}throw this.unexpected()},e.parseStringLiteral=function(){var r=this._lexer.token;return this._lexer.advance(),{kind:z.STRING,value:r.value,block:r.kind===$.BLOCK_STRING,loc:this.loc(r)}},e.parseList=function(r){var n=this,a=this._lexer.token,s=function(){return n.parseValueLiteral(r)};return{kind:z.LIST,values:this.any($.BRACKET_L,s,$.BRACKET_R),loc:this.loc(a)}},e.parseObject=function(r){var n=this,a=this._lexer.token,s=function(){return n.parseObjectField(r)};return{kind:z.OBJECT,fields:this.any($.BRACE_L,s,$.BRACE_R),loc:this.loc(a)}},e.parseObjectField=function(r){var n=this._lexer.token,a=this.parseName();return this.expectToken($.COLON),{kind:z.OBJECT_FIELD,name:a,value:this.parseValueLiteral(r),loc:this.loc(n)}},e.parseDirectives=function(r){for(var n=[];this.peek($.AT);)n.push(this.parseDirective(r));return n},e.parseDirective=function(r){var n=this._lexer.token;return this.expectToken($.AT),{kind:z.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(r),loc:this.loc(n)}},e.parseTypeReference=function(){var r=this._lexer.token,n;return this.expectOptionalToken($.BRACKET_L)?(n=this.parseTypeReference(),this.expectToken($.BRACKET_R),n={kind:z.LIST_TYPE,type:n,loc:this.loc(r)}):n=this.parseNamedType(),this.expectOptionalToken($.BANG)?{kind:z.NON_NULL_TYPE,type:n,loc:this.loc(r)}:n},e.parseNamedType=function(){var r=this._lexer.token;return{kind:z.NAMED_TYPE,name:this.parseName(),loc:this.loc(r)}},e.parseTypeSystemDefinition=function(){var r=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(r.kind===$.NAME)switch(r.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(r)},e.peekDescription=function(){return this.peek($.STRING)||this.peek($.BLOCK_STRING)},e.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},e.parseSchemaDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("schema");var a=this.parseDirectives(!0),s=this.many($.BRACE_L,this.parseOperationTypeDefinition,$.BRACE_R);return{kind:z.SCHEMA_DEFINITION,description:n,directives:a,operationTypes:s,loc:this.loc(r)}},e.parseOperationTypeDefinition=function(){var r=this._lexer.token,n=this.parseOperationType();this.expectToken($.COLON);var a=this.parseNamedType();return{kind:z.OPERATION_TYPE_DEFINITION,operation:n,type:a,loc:this.loc(r)}},e.parseScalarTypeDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("scalar");var a=this.parseName(),s=this.parseDirectives(!0);return{kind:z.SCALAR_TYPE_DEFINITION,description:n,name:a,directives:s,loc:this.loc(r)}},e.parseObjectTypeDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("type");var a=this.parseName(),s=this.parseImplementsInterfaces(),o=this.parseDirectives(!0),l=this.parseFieldsDefinition();return{kind:z.OBJECT_TYPE_DEFINITION,description:n,name:a,interfaces:s,directives:o,fields:l,loc:this.loc(r)}},e.parseImplementsInterfaces=function(){var r;if(!this.expectOptionalKeyword("implements"))return[];if(((r=this._options)===null||r===void 0?void 0:r.allowLegacySDLImplementsInterfaces)===!0){var n=[];this.expectOptionalToken($.AMP);do n.push(this.parseNamedType());while(this.expectOptionalToken($.AMP)||this.peek($.NAME));return n}return this.delimitedMany($.AMP,this.parseNamedType)},e.parseFieldsDefinition=function(){var r;return((r=this._options)===null||r===void 0?void 0:r.allowLegacySDLEmptyFields)===!0&&this.peek($.BRACE_L)&&this._lexer.lookahead().kind===$.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany($.BRACE_L,this.parseFieldDefinition,$.BRACE_R)},e.parseFieldDefinition=function(){var r=this._lexer.token,n=this.parseDescription(),a=this.parseName(),s=this.parseArgumentDefs();this.expectToken($.COLON);var o=this.parseTypeReference(),l=this.parseDirectives(!0);return{kind:z.FIELD_DEFINITION,description:n,name:a,arguments:s,type:o,directives:l,loc:this.loc(r)}},e.parseArgumentDefs=function(){return this.optionalMany($.PAREN_L,this.parseInputValueDef,$.PAREN_R)},e.parseInputValueDef=function(){var r=this._lexer.token,n=this.parseDescription(),a=this.parseName();this.expectToken($.COLON);var s=this.parseTypeReference(),o;this.expectOptionalToken($.EQUALS)&&(o=this.parseValueLiteral(!0));var l=this.parseDirectives(!0);return{kind:z.INPUT_VALUE_DEFINITION,description:n,name:a,type:s,defaultValue:o,directives:l,loc:this.loc(r)}},e.parseInterfaceTypeDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("interface");var a=this.parseName(),s=this.parseImplementsInterfaces(),o=this.parseDirectives(!0),l=this.parseFieldsDefinition();return{kind:z.INTERFACE_TYPE_DEFINITION,description:n,name:a,interfaces:s,directives:o,fields:l,loc:this.loc(r)}},e.parseUnionTypeDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("union");var a=this.parseName(),s=this.parseDirectives(!0),o=this.parseUnionMemberTypes();return{kind:z.UNION_TYPE_DEFINITION,description:n,name:a,directives:s,types:o,loc:this.loc(r)}},e.parseUnionMemberTypes=function(){return this.expectOptionalToken($.EQUALS)?this.delimitedMany($.PIPE,this.parseNamedType):[]},e.parseEnumTypeDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("enum");var a=this.parseName(),s=this.parseDirectives(!0),o=this.parseEnumValuesDefinition();return{kind:z.ENUM_TYPE_DEFINITION,description:n,name:a,directives:s,values:o,loc:this.loc(r)}},e.parseEnumValuesDefinition=function(){return this.optionalMany($.BRACE_L,this.parseEnumValueDefinition,$.BRACE_R)},e.parseEnumValueDefinition=function(){var r=this._lexer.token,n=this.parseDescription(),a=this.parseName(),s=this.parseDirectives(!0);return{kind:z.ENUM_VALUE_DEFINITION,description:n,name:a,directives:s,loc:this.loc(r)}},e.parseInputObjectTypeDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("input");var a=this.parseName(),s=this.parseDirectives(!0),o=this.parseInputFieldsDefinition();return{kind:z.INPUT_OBJECT_TYPE_DEFINITION,description:n,name:a,directives:s,fields:o,loc:this.loc(r)}},e.parseInputFieldsDefinition=function(){return this.optionalMany($.BRACE_L,this.parseInputValueDef,$.BRACE_R)},e.parseTypeSystemExtension=function(){var r=this._lexer.lookahead();if(r.kind===$.NAME)switch(r.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(r)},e.parseSchemaExtension=function(){var r=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var n=this.parseDirectives(!0),a=this.optionalMany($.BRACE_L,this.parseOperationTypeDefinition,$.BRACE_R);if(n.length===0&&a.length===0)throw this.unexpected();return{kind:z.SCHEMA_EXTENSION,directives:n,operationTypes:a,loc:this.loc(r)}},e.parseScalarTypeExtension=function(){var r=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(r)}},e.parseObjectTypeExtension=function(){var r=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var n=this.parseName(),a=this.parseImplementsInterfaces(),s=this.parseDirectives(!0),o=this.parseFieldsDefinition();if(a.length===0&&s.length===0&&o.length===0)throw this.unexpected();return{kind:z.OBJECT_TYPE_EXTENSION,name:n,interfaces:a,directives:s,fields:o,loc:this.loc(r)}},e.parseInterfaceTypeExtension=function(){var r=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var n=this.parseName(),a=this.parseImplementsInterfaces(),s=this.parseDirectives(!0),o=this.parseFieldsDefinition();if(a.length===0&&s.length===0&&o.length===0)throw this.unexpected();return{kind:z.INTERFACE_TYPE_EXTENSION,name:n,interfaces:a,directives:s,fields:o,loc:this.loc(r)}},e.parseUnionTypeExtension=function(){var r=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var n=this.parseName(),a=this.parseDirectives(!0),s=this.parseUnionMemberTypes();if(a.length===0&&s.length===0)throw this.unexpected();return{kind:z.UNION_TYPE_EXTENSION,name:n,directives:a,types:s,loc:this.loc(r)}},e.parseEnumTypeExtension=function(){var r=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var n=this.parseName(),a=this.parseDirectives(!0),s=this.parseEnumValuesDefinition();if(a.length===0&&s.length===0)throw this.unexpected();return{kind:z.ENUM_TYPE_EXTENSION,name:n,directives:a,values:s,loc:this.loc(r)}},e.parseInputObjectTypeExtension=function(){var r=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var n=this.parseName(),a=this.parseDirectives(!0),s=this.parseInputFieldsDefinition();if(a.length===0&&s.length===0)throw this.unexpected();return{kind:z.INPUT_OBJECT_TYPE_EXTENSION,name:n,directives:a,fields:s,loc:this.loc(r)}},e.parseDirectiveDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("directive"),this.expectToken($.AT);var a=this.parseName(),s=this.parseArgumentDefs(),o=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var l=this.parseDirectiveLocations();return{kind:z.DIRECTIVE_DEFINITION,description:n,name:a,arguments:s,repeatable:o,locations:l,loc:this.loc(r)}},e.parseDirectiveLocations=function(){return this.delimitedMany($.PIPE,this.parseDirectiveLocation)},e.parseDirectiveLocation=function(){var r=this._lexer.token,n=this.parseName();if(Id[n.value]!==void 0)return n;throw this.unexpected(r)},e.loc=function(r){var n;if(((n=this._options)===null||n===void 0?void 0:n.noLocation)!==!0)return new Ul(r,this._lexer.lastToken,this._lexer.source)},e.peek=function(r){return this._lexer.token.kind===r},e.expectToken=function(r){var n=this._lexer.token;if(n.kind===r)return this._lexer.advance(),n;throw it(this._lexer.source,n.start,"Expected ".concat(jl(r),", found ").concat(Ts(n),"."))},e.expectOptionalToken=function(r){var n=this._lexer.token;if(n.kind===r)return this._lexer.advance(),n},e.expectKeyword=function(r){var n=this._lexer.token;if(n.kind===$.NAME&&n.value===r)this._lexer.advance();else throw it(this._lexer.source,n.start,'Expected "'.concat(r,'", found ').concat(Ts(n),"."))},e.expectOptionalKeyword=function(r){var n=this._lexer.token;return n.kind===$.NAME&&n.value===r?(this._lexer.advance(),!0):!1},e.unexpected=function(r){var n=r??this._lexer.token;return it(this._lexer.source,n.start,"Unexpected ".concat(Ts(n),"."))},e.any=function(r,n,a){this.expectToken(r);for(var s=[];!this.expectOptionalToken(a);)s.push(n.call(this));return s},e.optionalMany=function(r,n,a){if(this.expectOptionalToken(r)){var s=[];do s.push(n.call(this));while(!this.expectOptionalToken(a));return s}return[]},e.many=function(r,n,a){this.expectToken(r);var s=[];do s.push(n.call(this));while(!this.expectOptionalToken(a));return s},e.delimitedMany=function(r,n){this.expectOptionalToken(r);var a=[];do a.push(n.call(this));while(this.expectOptionalToken(r));return a},i}();function Ts(i){var e=i.value;return jl(i.kind)+(e!=null?' "'.concat(e,'"'):"")}function jl(i){return Pd(i)?'"'.concat(i,'"'):i}var ya=new Map,Gs=new Map,Bl=!0,Ta=!1;function ql(i){return i.replace(/[\s,]+/g," ").trim()}function zd(i){return ql(i.source.body.substring(i.start,i.end))}function Vd(i){var e=new Set,t=[];return i.definitions.forEach(function(r){if(r.kind==="FragmentDefinition"){var n=r.name.value,a=zd(r.loc),s=Gs.get(n);s&&!s.has(a)?Bl&&console.warn("Warning: fragment with name "+n+` already exists.
474
+ `+Wl(i.source,o)}return e}function rt(i,e,t){return new Id("Syntax Error: ".concat(t),void 0,i,[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 Cd(i,e){var t=Boolean(i);if(!t)throw new Error(e??"Unexpected invariant triggered.")}var Ld=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):void 0,no=Ld;function Gl(i){var e=i.prototype.toJSON;typeof e=="function"||Cd(0),i.prototype.inspect=e,no&&(i.prototype[no]=e)}var Zl=function(){function i(t,r,n){this.start=t.start,this.end=r.end,this.startToken=t,this.endToken=r,this.source=n}var e=i.prototype;return e.toJSON=function(){return{start:this.start,end:this.end}},i}();Gl(Zl);var ye=function(){function i(t,r,n,a,s,o,c){this.kind=t,this.start=r,this.end=n,this.line=a,this.column=s,this.value=c,this.prev=o,this.next=null}var e=i.prototype;return e.toJSON=function(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}},i}();Gl(ye);var A=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 Ea(i){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ea=function(t){return typeof t}:Ea=function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ea(i)}var Pd=10,Jl=2;function Rd(i){return ss(i,[])}function ss(i,e){switch(Ea(i)){case"string":return JSON.stringify(i);case"function":return i.name?"[function ".concat(i.name,"]"):"[function]";case"object":return i===null?"null":Nd(i,e);default:return String(i)}}function Nd(i,e){if(e.indexOf(i)!==-1)return"[Circular]";var t=[].concat(e,[i]),r=Dd(i);if(r!==void 0){var n=r.call(i);if(n!==i)return typeof n=="string"?n:ss(n,t)}else if(Array.isArray(i))return Ud(i,t);return Od(i,t)}function Od(i,e){var t=Object.keys(i);if(t.length===0)return"{}";if(e.length>Jl)return"["+Md(i)+"]";var r=t.map(function(n){var a=ss(i[n],e);return n+": "+a});return"{ "+r.join(", ")+" }"}function Ud(i,e){if(i.length===0)return"[]";if(e.length>Jl)return"[Array]";for(var t=Math.min(Pd,i.length),r=i.length-t,n=[],a=0;a<t;++a)n.push(ss(i[a],e));return r===1?n.push("... 1 more item"):r>1&&n.push("... ".concat(r," more items")),"["+n.join(", ")+"]"}function Dd(i){var e=i[String(no)];if(typeof e=="function")return e;if(typeof i.inspect=="function")return i.inspect}function Md(i){var e=Object.prototype.toString.call(i).replace(/^\[object /,"").replace(/]$/,"");if(e==="Object"&&typeof i.constructor=="function"){var t=i.constructor.name;if(typeof t=="string"&&t!=="")return t}return e}function Us(i,e){var t=Boolean(i);if(!t)throw new Error(e)}var Fd=function(e,t){return e instanceof t};function xc(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function jd(i,e,t){return e&&xc(i.prototype,e),t&&xc(i,t),i}var Xl=function(){function i(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"GraphQL request",r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{line:1,column:1};typeof e=="string"||Us(0,"Body must be a string. Received: ".concat(Rd(e),".")),this.body=e,this.name=t,this.locationOffset=r,this.locationOffset.line>0||Us(0,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||Us(0,"column in locationOffset is 1-indexed and must be positive.")}return jd(i,[{key:Vl,get:function(){return"Source"}}]),i}();function qd(i){return Fd(i,Xl)}var Bd=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 Hd(i){var e=i.split(/\r\n|[\n\r]/g),t=zd(i);if(t!==0)for(var r=1;r<e.length;r++)e[r]=e[r].slice(t);for(var n=0;n<e.length&&$c(e[n]);)++n;for(var a=e.length;a>n&&$c(e[a-1]);)--a;return e.slice(n,a).join(`
475
+ `)}function $c(i){for(var e=0;e<i.length;++e)if(i[e]!==" "&&i[e]!==" ")return!1;return!0}function zd(i){for(var e,t=!0,r=!0,n=0,a=null,s=0;s<i.length;++s)switch(i.charCodeAt(s)){case 13:i.charCodeAt(s+1)===10&&++s;case 10:t=!1,r=!0,n=0;break;case 9:case 32:++n;break;default:r&&!t&&(a===null||n<a)&&(a=n),r=!1}return(e=a)!==null&&e!==void 0?e:0}var Vd=function(){function i(t){var r=new ye(A.SOF,0,0,0,0,null);this.source=t,this.lastToken=r,this.token=r,this.line=1,this.lineStart=0}var e=i.prototype;return e.advance=function(){this.lastToken=this.token;var r=this.token=this.lookahead();return r},e.lookahead=function(){var r=this.token;if(r.kind!==A.EOF)do{var n;r=(n=r.next)!==null&&n!==void 0?n:r.next=Kd(this,r)}while(r.kind===A.COMMENT);return r},i}();function Wd(i){return i===A.BANG||i===A.DOLLAR||i===A.AMP||i===A.PAREN_L||i===A.PAREN_R||i===A.SPREAD||i===A.COLON||i===A.EQUALS||i===A.AT||i===A.BRACKET_L||i===A.BRACKET_R||i===A.BRACE_L||i===A.PIPE||i===A.BRACE_R}function Bi(i){return isNaN(i)?A.EOF:i<127?JSON.stringify(String.fromCharCode(i)):'"\\u'.concat(("00"+i.toString(16).toUpperCase()).slice(-4),'"')}function Kd(i,e){for(var t=i.source,r=t.body,n=r.length,a=e.end;a<n;){var s=r.charCodeAt(a),o=i.line,c=1+a-i.lineStart;switch(s){case 65279:case 9:case 32:case 44:++a;continue;case 10:++a,++i.line,i.lineStart=a;continue;case 13:r.charCodeAt(a+1)===10?a+=2:++a,++i.line,i.lineStart=a;continue;case 33:return new ye(A.BANG,a,a+1,o,c,e);case 35:return Gd(t,a,o,c,e);case 36:return new ye(A.DOLLAR,a,a+1,o,c,e);case 38:return new ye(A.AMP,a,a+1,o,c,e);case 40:return new ye(A.PAREN_L,a,a+1,o,c,e);case 41:return new ye(A.PAREN_R,a,a+1,o,c,e);case 46:if(r.charCodeAt(a+1)===46&&r.charCodeAt(a+2)===46)return new ye(A.SPREAD,a,a+3,o,c,e);break;case 58:return new ye(A.COLON,a,a+1,o,c,e);case 61:return new ye(A.EQUALS,a,a+1,o,c,e);case 64:return new ye(A.AT,a,a+1,o,c,e);case 91:return new ye(A.BRACKET_L,a,a+1,o,c,e);case 93:return new ye(A.BRACKET_R,a,a+1,o,c,e);case 123:return new ye(A.BRACE_L,a,a+1,o,c,e);case 124:return new ye(A.PIPE,a,a+1,o,c,e);case 125:return new ye(A.BRACE_R,a,a+1,o,c,e);case 34:return r.charCodeAt(a+1)===34&&r.charCodeAt(a+2)===34?Xd(t,a,o,c,e,i):Jd(t,a,o,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 Zd(t,a,s,o,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 ep(t,a,o,c,e)}throw rt(t,a,Qd(s))}var l=i.line,u=1+a-i.lineStart;return new ye(A.EOF,n,n,l,u,e)}function Qd(i){return i<32&&i!==9&&i!==10&&i!==13?"Cannot contain the invalid character ".concat(Bi(i),"."):i===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:"Cannot parse the unexpected character ".concat(Bi(i),".")}function Gd(i,e,t,r,n){var a=i.body,s,o=e;do s=a.charCodeAt(++o);while(!isNaN(s)&&(s>31||s===9));return new ye(A.COMMENT,e,o,t,r,n,a.slice(e+1,o))}function Zd(i,e,t,r,n,a){var s=i.body,o=t,c=e,l=!1;if(o===45&&(o=s.charCodeAt(++c)),o===48){if(o=s.charCodeAt(++c),o>=48&&o<=57)throw rt(i,c,"Invalid number, unexpected digit after 0: ".concat(Bi(o),"."))}else c=Ds(i,c,o),o=s.charCodeAt(c);if(o===46&&(l=!0,o=s.charCodeAt(++c),c=Ds(i,c,o),o=s.charCodeAt(c)),(o===69||o===101)&&(l=!0,o=s.charCodeAt(++c),(o===43||o===45)&&(o=s.charCodeAt(++c)),c=Ds(i,c,o),o=s.charCodeAt(c)),o===46||tp(o))throw rt(i,c,"Invalid number, expected digit but got: ".concat(Bi(o),"."));return new ye(l?A.FLOAT:A.INT,e,c,r,n,a,s.slice(e,c))}function Ds(i,e,t){var r=i.body,n=e,a=t;if(a>=48&&a<=57){do a=r.charCodeAt(++n);while(a>=48&&a<=57);return n}throw rt(i,n,"Invalid number, expected digit but got: ".concat(Bi(a),"."))}function Jd(i,e,t,r,n){for(var a=i.body,s=e+1,o=s,c=0,l="";s<a.length&&!isNaN(c=a.charCodeAt(s))&&c!==10&&c!==13;){if(c===34)return l+=a.slice(o,s),new ye(A.STRING,e,s+1,t,r,n,l);if(c<32&&c!==9)throw rt(i,s,"Invalid character within String: ".concat(Bi(c),"."));if(++s,c===92){switch(l+=a.slice(o,s-1),c=a.charCodeAt(s),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+=`
476
+ `;break;case 114:l+="\r";break;case 116:l+=" ";break;case 117:{var u=Yd(a.charCodeAt(s+1),a.charCodeAt(s+2),a.charCodeAt(s+3),a.charCodeAt(s+4));if(u<0){var m=a.slice(s+1,s+5);throw rt(i,s,"Invalid character escape sequence: \\u".concat(m,"."))}l+=String.fromCharCode(u),s+=4;break}default:throw rt(i,s,"Invalid character escape sequence: \\".concat(String.fromCharCode(c),"."))}++s,o=s}}throw rt(i,s,"Unterminated string.")}function Xd(i,e,t,r,n,a){for(var s=i.body,o=e+3,c=o,l=0,u="";o<s.length&&!isNaN(l=s.charCodeAt(o));){if(l===34&&s.charCodeAt(o+1)===34&&s.charCodeAt(o+2)===34)return u+=s.slice(c,o),new ye(A.BLOCK_STRING,e,o+3,t,r,n,Hd(u));if(l<32&&l!==9&&l!==10&&l!==13)throw rt(i,o,"Invalid character within String: ".concat(Bi(l),"."));l===10?(++o,++a.line,a.lineStart=o):l===13?(s.charCodeAt(o+1)===10?o+=2:++o,++a.line,a.lineStart=o):l===92&&s.charCodeAt(o+1)===34&&s.charCodeAt(o+2)===34&&s.charCodeAt(o+3)===34?(u+=s.slice(c,o)+'"""',o+=4,c=o):++o}throw rt(i,o,"Unterminated string.")}function Yd(i,e,t,r){return ca(i)<<12|ca(e)<<8|ca(t)<<4|ca(r)}function ca(i){return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:-1}function ep(i,e,t,r,n){for(var a=i.body,s=a.length,o=e+1,c=0;o!==s&&!isNaN(c=a.charCodeAt(o))&&(c===95||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122);)++o;return new ye(A.NAME,e,o,t,r,n,a.slice(e,o))}function tp(i){return i===95||i>=65&&i<=90||i>=97&&i<=122}function ip(i,e){var t=new rp(i,e);return t.parseDocument()}var rp=function(){function i(t,r){var n=qd(t)?t:new Xl(t);this._lexer=new Vd(n),this._options=r}var e=i.prototype;return e.parseName=function(){var r=this.expectToken(A.NAME);return{kind:z.NAME,value:r.value,loc:this.loc(r)}},e.parseDocument=function(){var r=this._lexer.token;return{kind:z.DOCUMENT,definitions:this.many(A.SOF,this.parseDefinition,A.EOF),loc:this.loc(r)}},e.parseDefinition=function(){if(this.peek(A.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(A.BRACE_L))return this.parseOperationDefinition();if(this.peekDescription())return this.parseTypeSystemDefinition()}throw this.unexpected()},e.parseOperationDefinition=function(){var r=this._lexer.token;if(this.peek(A.BRACE_L))return{kind:z.OPERATION_DEFINITION,operation:"query",name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet(),loc:this.loc(r)};var n=this.parseOperationType(),a;return this.peek(A.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(r)}},e.parseOperationType=function(){var r=this.expectToken(A.NAME);switch(r.value){case"query":return"query";case"mutation":return"mutation";case"subscription":return"subscription"}throw this.unexpected(r)},e.parseVariableDefinitions=function(){return this.optionalMany(A.PAREN_L,this.parseVariableDefinition,A.PAREN_R)},e.parseVariableDefinition=function(){var r=this._lexer.token;return{kind:z.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(A.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(A.EQUALS)?this.parseValueLiteral(!0):void 0,directives:this.parseDirectives(!0),loc:this.loc(r)}},e.parseVariable=function(){var r=this._lexer.token;return this.expectToken(A.DOLLAR),{kind:z.VARIABLE,name:this.parseName(),loc:this.loc(r)}},e.parseSelectionSet=function(){var r=this._lexer.token;return{kind:z.SELECTION_SET,selections:this.many(A.BRACE_L,this.parseSelection,A.BRACE_R),loc:this.loc(r)}},e.parseSelection=function(){return this.peek(A.SPREAD)?this.parseFragment():this.parseField()},e.parseField=function(){var r=this._lexer.token,n=this.parseName(),a,s;return this.expectOptionalToken(A.COLON)?(a=n,s=this.parseName()):s=n,{kind:z.FIELD,alias:a,name:s,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(A.BRACE_L)?this.parseSelectionSet():void 0,loc:this.loc(r)}},e.parseArguments=function(r){var n=r?this.parseConstArgument:this.parseArgument;return this.optionalMany(A.PAREN_L,n,A.PAREN_R)},e.parseArgument=function(){var r=this._lexer.token,n=this.parseName();return this.expectToken(A.COLON),{kind:z.ARGUMENT,name:n,value:this.parseValueLiteral(!1),loc:this.loc(r)}},e.parseConstArgument=function(){var r=this._lexer.token;return{kind:z.ARGUMENT,name:this.parseName(),value:(this.expectToken(A.COLON),this.parseValueLiteral(!0)),loc:this.loc(r)}},e.parseFragment=function(){var r=this._lexer.token;this.expectToken(A.SPREAD);var n=this.expectOptionalKeyword("on");return!n&&this.peek(A.NAME)?{kind:z.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1),loc:this.loc(r)}:{kind:z.INLINE_FRAGMENT,typeCondition:n?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet(),loc:this.loc(r)}},e.parseFragmentDefinition=function(){var r,n=this._lexer.token;return this.expectKeyword("fragment"),((r=this._options)===null||r===void 0?void 0:r.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(r){var n=this._lexer.token;switch(n.kind){case A.BRACKET_L:return this.parseList(r);case A.BRACE_L:return this.parseObject(r);case A.INT:return this._lexer.advance(),{kind:z.INT,value:n.value,loc:this.loc(n)};case A.FLOAT:return this._lexer.advance(),{kind:z.FLOAT,value:n.value,loc:this.loc(n)};case A.STRING:case A.BLOCK_STRING:return this.parseStringLiteral();case A.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 A.DOLLAR:if(!r)return this.parseVariable();break}throw this.unexpected()},e.parseStringLiteral=function(){var r=this._lexer.token;return this._lexer.advance(),{kind:z.STRING,value:r.value,block:r.kind===A.BLOCK_STRING,loc:this.loc(r)}},e.parseList=function(r){var n=this,a=this._lexer.token,s=function(){return n.parseValueLiteral(r)};return{kind:z.LIST,values:this.any(A.BRACKET_L,s,A.BRACKET_R),loc:this.loc(a)}},e.parseObject=function(r){var n=this,a=this._lexer.token,s=function(){return n.parseObjectField(r)};return{kind:z.OBJECT,fields:this.any(A.BRACE_L,s,A.BRACE_R),loc:this.loc(a)}},e.parseObjectField=function(r){var n=this._lexer.token,a=this.parseName();return this.expectToken(A.COLON),{kind:z.OBJECT_FIELD,name:a,value:this.parseValueLiteral(r),loc:this.loc(n)}},e.parseDirectives=function(r){for(var n=[];this.peek(A.AT);)n.push(this.parseDirective(r));return n},e.parseDirective=function(r){var n=this._lexer.token;return this.expectToken(A.AT),{kind:z.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(r),loc:this.loc(n)}},e.parseTypeReference=function(){var r=this._lexer.token,n;return this.expectOptionalToken(A.BRACKET_L)?(n=this.parseTypeReference(),this.expectToken(A.BRACKET_R),n={kind:z.LIST_TYPE,type:n,loc:this.loc(r)}):n=this.parseNamedType(),this.expectOptionalToken(A.BANG)?{kind:z.NON_NULL_TYPE,type:n,loc:this.loc(r)}:n},e.parseNamedType=function(){var r=this._lexer.token;return{kind:z.NAMED_TYPE,name:this.parseName(),loc:this.loc(r)}},e.parseTypeSystemDefinition=function(){var r=this.peekDescription()?this._lexer.lookahead():this._lexer.token;if(r.kind===A.NAME)switch(r.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(r)},e.peekDescription=function(){return this.peek(A.STRING)||this.peek(A.BLOCK_STRING)},e.parseDescription=function(){if(this.peekDescription())return this.parseStringLiteral()},e.parseSchemaDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("schema");var a=this.parseDirectives(!0),s=this.many(A.BRACE_L,this.parseOperationTypeDefinition,A.BRACE_R);return{kind:z.SCHEMA_DEFINITION,description:n,directives:a,operationTypes:s,loc:this.loc(r)}},e.parseOperationTypeDefinition=function(){var r=this._lexer.token,n=this.parseOperationType();this.expectToken(A.COLON);var a=this.parseNamedType();return{kind:z.OPERATION_TYPE_DEFINITION,operation:n,type:a,loc:this.loc(r)}},e.parseScalarTypeDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("scalar");var a=this.parseName(),s=this.parseDirectives(!0);return{kind:z.SCALAR_TYPE_DEFINITION,description:n,name:a,directives:s,loc:this.loc(r)}},e.parseObjectTypeDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("type");var a=this.parseName(),s=this.parseImplementsInterfaces(),o=this.parseDirectives(!0),c=this.parseFieldsDefinition();return{kind:z.OBJECT_TYPE_DEFINITION,description:n,name:a,interfaces:s,directives:o,fields:c,loc:this.loc(r)}},e.parseImplementsInterfaces=function(){var r;if(!this.expectOptionalKeyword("implements"))return[];if(((r=this._options)===null||r===void 0?void 0:r.allowLegacySDLImplementsInterfaces)===!0){var n=[];this.expectOptionalToken(A.AMP);do n.push(this.parseNamedType());while(this.expectOptionalToken(A.AMP)||this.peek(A.NAME));return n}return this.delimitedMany(A.AMP,this.parseNamedType)},e.parseFieldsDefinition=function(){var r;return((r=this._options)===null||r===void 0?void 0:r.allowLegacySDLEmptyFields)===!0&&this.peek(A.BRACE_L)&&this._lexer.lookahead().kind===A.BRACE_R?(this._lexer.advance(),this._lexer.advance(),[]):this.optionalMany(A.BRACE_L,this.parseFieldDefinition,A.BRACE_R)},e.parseFieldDefinition=function(){var r=this._lexer.token,n=this.parseDescription(),a=this.parseName(),s=this.parseArgumentDefs();this.expectToken(A.COLON);var o=this.parseTypeReference(),c=this.parseDirectives(!0);return{kind:z.FIELD_DEFINITION,description:n,name:a,arguments:s,type:o,directives:c,loc:this.loc(r)}},e.parseArgumentDefs=function(){return this.optionalMany(A.PAREN_L,this.parseInputValueDef,A.PAREN_R)},e.parseInputValueDef=function(){var r=this._lexer.token,n=this.parseDescription(),a=this.parseName();this.expectToken(A.COLON);var s=this.parseTypeReference(),o;this.expectOptionalToken(A.EQUALS)&&(o=this.parseValueLiteral(!0));var c=this.parseDirectives(!0);return{kind:z.INPUT_VALUE_DEFINITION,description:n,name:a,type:s,defaultValue:o,directives:c,loc:this.loc(r)}},e.parseInterfaceTypeDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("interface");var a=this.parseName(),s=this.parseImplementsInterfaces(),o=this.parseDirectives(!0),c=this.parseFieldsDefinition();return{kind:z.INTERFACE_TYPE_DEFINITION,description:n,name:a,interfaces:s,directives:o,fields:c,loc:this.loc(r)}},e.parseUnionTypeDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("union");var a=this.parseName(),s=this.parseDirectives(!0),o=this.parseUnionMemberTypes();return{kind:z.UNION_TYPE_DEFINITION,description:n,name:a,directives:s,types:o,loc:this.loc(r)}},e.parseUnionMemberTypes=function(){return this.expectOptionalToken(A.EQUALS)?this.delimitedMany(A.PIPE,this.parseNamedType):[]},e.parseEnumTypeDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("enum");var a=this.parseName(),s=this.parseDirectives(!0),o=this.parseEnumValuesDefinition();return{kind:z.ENUM_TYPE_DEFINITION,description:n,name:a,directives:s,values:o,loc:this.loc(r)}},e.parseEnumValuesDefinition=function(){return this.optionalMany(A.BRACE_L,this.parseEnumValueDefinition,A.BRACE_R)},e.parseEnumValueDefinition=function(){var r=this._lexer.token,n=this.parseDescription(),a=this.parseName(),s=this.parseDirectives(!0);return{kind:z.ENUM_VALUE_DEFINITION,description:n,name:a,directives:s,loc:this.loc(r)}},e.parseInputObjectTypeDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("input");var a=this.parseName(),s=this.parseDirectives(!0),o=this.parseInputFieldsDefinition();return{kind:z.INPUT_OBJECT_TYPE_DEFINITION,description:n,name:a,directives:s,fields:o,loc:this.loc(r)}},e.parseInputFieldsDefinition=function(){return this.optionalMany(A.BRACE_L,this.parseInputValueDef,A.BRACE_R)},e.parseTypeSystemExtension=function(){var r=this._lexer.lookahead();if(r.kind===A.NAME)switch(r.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(r)},e.parseSchemaExtension=function(){var r=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");var n=this.parseDirectives(!0),a=this.optionalMany(A.BRACE_L,this.parseOperationTypeDefinition,A.BRACE_R);if(n.length===0&&a.length===0)throw this.unexpected();return{kind:z.SCHEMA_EXTENSION,directives:n,operationTypes:a,loc:this.loc(r)}},e.parseScalarTypeExtension=function(){var r=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(r)}},e.parseObjectTypeExtension=function(){var r=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");var n=this.parseName(),a=this.parseImplementsInterfaces(),s=this.parseDirectives(!0),o=this.parseFieldsDefinition();if(a.length===0&&s.length===0&&o.length===0)throw this.unexpected();return{kind:z.OBJECT_TYPE_EXTENSION,name:n,interfaces:a,directives:s,fields:o,loc:this.loc(r)}},e.parseInterfaceTypeExtension=function(){var r=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");var n=this.parseName(),a=this.parseImplementsInterfaces(),s=this.parseDirectives(!0),o=this.parseFieldsDefinition();if(a.length===0&&s.length===0&&o.length===0)throw this.unexpected();return{kind:z.INTERFACE_TYPE_EXTENSION,name:n,interfaces:a,directives:s,fields:o,loc:this.loc(r)}},e.parseUnionTypeExtension=function(){var r=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");var n=this.parseName(),a=this.parseDirectives(!0),s=this.parseUnionMemberTypes();if(a.length===0&&s.length===0)throw this.unexpected();return{kind:z.UNION_TYPE_EXTENSION,name:n,directives:a,types:s,loc:this.loc(r)}},e.parseEnumTypeExtension=function(){var r=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");var n=this.parseName(),a=this.parseDirectives(!0),s=this.parseEnumValuesDefinition();if(a.length===0&&s.length===0)throw this.unexpected();return{kind:z.ENUM_TYPE_EXTENSION,name:n,directives:a,values:s,loc:this.loc(r)}},e.parseInputObjectTypeExtension=function(){var r=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");var n=this.parseName(),a=this.parseDirectives(!0),s=this.parseInputFieldsDefinition();if(a.length===0&&s.length===0)throw this.unexpected();return{kind:z.INPUT_OBJECT_TYPE_EXTENSION,name:n,directives:a,fields:s,loc:this.loc(r)}},e.parseDirectiveDefinition=function(){var r=this._lexer.token,n=this.parseDescription();this.expectKeyword("directive"),this.expectToken(A.AT);var a=this.parseName(),s=this.parseArgumentDefs(),o=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");var c=this.parseDirectiveLocations();return{kind:z.DIRECTIVE_DEFINITION,description:n,name:a,arguments:s,repeatable:o,locations:c,loc:this.loc(r)}},e.parseDirectiveLocations=function(){return this.delimitedMany(A.PIPE,this.parseDirectiveLocation)},e.parseDirectiveLocation=function(){var r=this._lexer.token,n=this.parseName();if(Bd[n.value]!==void 0)return n;throw this.unexpected(r)},e.loc=function(r){var n;if(((n=this._options)===null||n===void 0?void 0:n.noLocation)!==!0)return new Zl(r,this._lexer.lastToken,this._lexer.source)},e.peek=function(r){return this._lexer.token.kind===r},e.expectToken=function(r){var n=this._lexer.token;if(n.kind===r)return this._lexer.advance(),n;throw rt(this._lexer.source,n.start,"Expected ".concat(Yl(r),", found ").concat(Ms(n),"."))},e.expectOptionalToken=function(r){var n=this._lexer.token;if(n.kind===r)return this._lexer.advance(),n},e.expectKeyword=function(r){var n=this._lexer.token;if(n.kind===A.NAME&&n.value===r)this._lexer.advance();else throw rt(this._lexer.source,n.start,'Expected "'.concat(r,'", found ').concat(Ms(n),"."))},e.expectOptionalKeyword=function(r){var n=this._lexer.token;return n.kind===A.NAME&&n.value===r?(this._lexer.advance(),!0):!1},e.unexpected=function(r){var n=r??this._lexer.token;return rt(this._lexer.source,n.start,"Unexpected ".concat(Ms(n),"."))},e.any=function(r,n,a){this.expectToken(r);for(var s=[];!this.expectOptionalToken(a);)s.push(n.call(this));return s},e.optionalMany=function(r,n,a){if(this.expectOptionalToken(r)){var s=[];do s.push(n.call(this));while(!this.expectOptionalToken(a));return s}return[]},e.many=function(r,n,a){this.expectToken(r);var s=[];do s.push(n.call(this));while(!this.expectOptionalToken(a));return s},e.delimitedMany=function(r,n){this.expectOptionalToken(r);var a=[];do a.push(n.call(this));while(this.expectOptionalToken(r));return a},i}();function Ms(i){var e=i.value;return Yl(i.kind)+(e!=null?' "'.concat(e,'"'):"")}function Yl(i){return Wd(i)?'"'.concat(i,'"'):i}var Aa=new Map,ao=new Map,eu=!0,Ma=!1;function tu(i){return i.replace(/[\s,]+/g," ").trim()}function np(i){return tu(i.source.body.substring(i.start,i.end))}function ap(i){var e=new Set,t=[];return i.definitions.forEach(function(r){if(r.kind==="FragmentDefinition"){var n=r.name.value,a=np(r.loc),s=ao.get(n);s&&!s.has(a)?eu&&console.warn("Warning: fragment with name "+n+` already exists.
433
477
  graphql-tag enforces all fragment names across your application to be unique; read more about
434
- this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):s||Gs.set(n,s=new Set),s.add(a),e.has(a)||(e.add(a),t.push(r))}else t.push(r)}),Ia(Ia({},i),{definitions:t})}function Wd(i){var e=new Set(i.definitions);e.forEach(function(r){r.loc&&delete r.loc,Object.keys(r).forEach(function(n){var a=r[n];a&&typeof a=="object"&&e.add(a)})});var t=i.loc;return t&&(delete t.startToken,delete t.endToken),i}function Kd(i){var e=ql(i);if(!ya.has(e)){var t=qd(i,{experimentalFragmentVariables:Ta,allowLegacyFragmentVariables:Ta});if(!t||t.kind!=="Document")throw new Error("Not a valid GraphQL document.");ya.set(e,Wd(Vd(t)))}return ya.get(e)}function v(i){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];typeof i=="string"&&(i=[i]);var r=i[0];return e.forEach(function(n,a){n&&n.kind==="Document"?r+=n.loc.source.body:r+=n,r+=i[a+1]}),Kd(r)}function Qd(){ya.clear(),Gs.clear()}function Gd(){Bl=!1}function Zd(){Ta=!0}function Jd(){Ta=!1}var zr={gql:v,resetCaches:Qd,disableFragmentWarnings:Gd,enableExperimentalFragmentVariables:Zd,disableExperimentalFragmentVariables:Jd};(function(i){i.gql=zr.gql,i.resetCaches=zr.resetCaches,i.disableFragmentWarnings=zr.disableFragmentWarnings,i.enableExperimentalFragmentVariables=zr.enableExperimentalFragmentVariables,i.disableExperimentalFragmentVariables=zr.disableExperimentalFragmentVariables})(v||(v={}));v.default=v;function b(i){if(!i)throw"Got no result from Apollo";if(i.error)throw i.error;if(i.errors)throw i.errors;return i.data}function Yd(){}function fi(){return Yd}var F=fi,h=fi,Te=fi,J=fi,H=fi,Ce=fi,Xd=fi,wo=fi,Hl=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},zl=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Fi=class{constructor(e){this.code=e}};Hl([h(),zl("design:type",String)],Fi.prototype,"code",void 0);Fi=Hl([H(),zl("design:paramtypes",[String])],Fi);var So=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},_o=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},It=class{constructor(e,t){this.address=e,this.name=t}};So([h(),_o("design:type",String)],It.prototype,"address",void 0);So([h(),_o("design:type",String)],It.prototype,"name",void 0);It=So([H(),_o("design:paramtypes",[String,String])],It);var he=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},xe=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Ht=class{constructor(e,t){this.key=t,this.signature=e}};he([h(),xe("design:type",String)],Ht.prototype,"signature",void 0);he([h(),xe("design:type",String)],Ht.prototype,"key",void 0);he([h(),xe("design:type",Boolean)],Ht.prototype,"valid",void 0);he([h(),xe("design:type",Boolean)],Ht.prototype,"invalid",void 0);Ht=he([H(),Te(),xe("design:paramtypes",[String,String])],Ht);var ji=class{};he([h(),xe("design:type",String)],ji.prototype,"signature",void 0);he([h(),xe("design:type",String)],ji.prototype,"key",void 0);he([h(),xe("design:type",Boolean)],ji.prototype,"valid",void 0);he([h(),xe("design:type",Boolean)],ji.prototype,"invalid",void 0);ji=he([Te()],ji);function hi(i){let e=class{constructor(r,n,a,s){this.author=r,this.timestamp=n,this.data=a,this.proof=s}};return he([h(),xe("design:type",String)],e.prototype,"author",void 0),he([h(),xe("design:type",String)],e.prototype,"timestamp",void 0),he([h(),xe("design:type",Object)],e.prototype,"data",void 0),he([h(),xe("design:type",Ht)],e.prototype,"proof",void 0),e=he([H(),xe("design:paramtypes",[String,String,Object,Ht])],e),e}function ep(i){let e=class{};return he([h(),xe("design:type",String)],e.prototype,"author",void 0),he([h(),xe("design:type",String)],e.prototype,"timestamp",void 0),he([h(),xe("design:type",Object)],e.prototype,"data",void 0),he([h(),xe("design:type",ji)],e.prototype,"proof",void 0),e=he([Te()],e),e}var gc=class extends hi(){};gc=he([H()],gc);var Ca=class extends hi(){};he([h(),xe("design:type",It)],Ca.prototype,"language",void 0);he([h(),xe("design:type",Fi)],Ca.prototype,"icon",void 0);Ca=he([H()],Ca);function Wy(i){return i&&i.author&&i.timestamp&&i.data}var we=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Re=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Je=class{constructor(e){this.source=e.source?e.source:"",this.target=e.target?e.target:"",this.predicate=e.predicate?e.predicate:""}};we([h(),Re("design:type",String)],Je.prototype,"source",void 0);we([h(),Re("design:type",String)],Je.prototype,"target",void 0);we([h(),Re("design:type",String)],Je.prototype,"predicate",void 0);Je=we([H(),Re("design:paramtypes",[Object])],Je);var La=class{};we([h(),Re("design:type",Array)],La.prototype,"additions",void 0);we([h(),Re("design:type",Array)],La.prototype,"removals",void 0);La=we([Te()],La);var Pa=class{constructor(e,t){this.additions=e,this.removals=t}};we([h(),Re("design:type",Array)],Pa.prototype,"additions",void 0);we([h(),Re("design:type",Array)],Pa.prototype,"removals",void 0);Pa=we([H(),Re("design:paramtypes",[Array,Array])],Pa);var _n=class{};we([h(),Re("design:type",String)],_n.prototype,"source",void 0);we([h(),Re("design:type",String)],_n.prototype,"target",void 0);we([h(),Re("design:type",String)],_n.prototype,"predicate",void 0);_n=we([Te()],_n);var si=class extends hi(){hash(){let e=JSON.stringify(this.data,Object.keys(this.data).sort())+JSON.stringify(this.author)+this.timestamp,t=0,r,n;for(r=0;r<e.length;r++)n=e.charCodeAt(r),t=(t<<5)-t+n,t|=0;return t}};we([h(),Re("design:type",String)],si.prototype,"status",void 0);si=we([H()],si);var Zs=class extends ep(){};we([h(),Re("design:type",String)],Zs.prototype,"status",void 0);Zs=we([Te()],Zs);function Xy(i,e){return i.author==e.author&&i.timestamp==e.timestamp&&i.data.source==e.data.source&&i.data.predicate==e.data.predicate&&i.data.target==e.data.target}function e0(i){return i&&i.source&&i.target}var Ra=class{constructor(e,t){this.oldLink=e,this.newLink=t}};we([h(),Re("design:type",si)],Ra.prototype,"oldLink",void 0);we([h(),Re("design:type",si)],Ra.prototype,"newLink",void 0);Ra=we([H(),Re("design:paramtypes",[si,si])],Ra);var Zi=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Nn=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Js,Pt=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 r=JSON.parse(JSON.stringify(this.links));return e.target&&(r=r.filter(n=>n.data.target===e.target)),e.predicate&&(r=r.filter(n=>n.data.predicate===e.predicate)),e.fromDate&&(r=r.filter(n=>new Date(n.timestamp)>=e.fromDate)),e.untilDate&&(r=r.filter(n=>new Date(n.timestamp)<=e.untilDate)),e.limit&&(r=r.slice(0,e.limit)),r}if(e.target){let r=JSON.parse(JSON.stringify(this.links));return e.predicate&&(r=r.filter(n=>n.data.predicate===e.predicate)),e.fromDate&&(r=r.filter(n=>new Date(n.timestamp)>=e.fromDate)),e.untilDate&&(r=r.filter(n=>new Date(n.timestamp)<=e.untilDate)),e.limit&&(r=r.slice(0,e.limit)),r}let t=JSON.parse(JSON.stringify(this.links));return t=t.filter(r=>r.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}};Zi([h(),Nn("design:type",Array)],Pt.prototype,"links",void 0);Pt=Zi([H(),Nn("design:paramtypes",[Array])],Pt);var Na=class{};Zi([h(),Nn("design:type",Array)],Na.prototype,"links",void 0);Na=Zi([Te()],Na);var Ys=Js=class{constructor(e){e?this.links=e:this.links=[]}static fromLink(e){let t=new Js;return t.links.push(e),t}};Zi([h(),Nn("design:type",Array)],Ys.prototype,"links",void 0);Ys=Js=Zi([Te(),Nn("design:paramtypes",[Array])],Ys);var Bi=class extends hi(){};Bi=Zi([H()],Bi);var M=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},B=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},ti=class{constructor(e,t){this.did=e,t?this.perspective=t:this.perspective=new Pt}};M([h(),B("design:type",String)],ti.prototype,"did",void 0);M([h(),B("design:type",Pt)],ti.prototype,"perspective",void 0);M([h(),B("design:type",String)],ti.prototype,"directMessageLanguage",void 0);ti=M([H(),B("design:paramtypes",[String,Pt])],ti);var mc=class extends hi(){};mc=M([H()],mc);var oi=class{constructor(e,t,r,n,a,s){this.did=e,this.didSigningKeyId=t,this.deviceKeyType=r,this.deviceKey=n,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=s}};M([h(),B("design:type",String)],oi.prototype,"did",void 0);M([h(),B("design:type",String)],oi.prototype,"didSigningKeyId",void 0);M([h(),B("design:type",String)],oi.prototype,"deviceKeyType",void 0);M([h(),B("design:type",String)],oi.prototype,"deviceKey",void 0);M([h(),B("design:type",String)],oi.prototype,"deviceKeySignedByDid",void 0);M([h(),B("design:type",String)],oi.prototype,"didSignedByDeviceKey",void 0);oi=M([H(),B("design:paramtypes",[String,String,String,String,String,String])],oi);var ci=class{constructor(e,t,r,n,a,s){this.did=e,this.didSigningKeyId=t,this.deviceKeyType=r,this.deviceKey=n,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=s}};M([h(),B("design:type",String)],ci.prototype,"did",void 0);M([h(),B("design:type",String)],ci.prototype,"didSigningKeyId",void 0);M([h(),B("design:type",String)],ci.prototype,"deviceKeyType",void 0);M([h(),B("design:type",String)],ci.prototype,"deviceKey",void 0);M([h(),B("design:type",String)],ci.prototype,"deviceKeySignedByDid",void 0);M([h(),B("design:type",String)],ci.prototype,"didSignedByDeviceKey",void 0);ci=M([Te(),B("design:paramtypes",[String,String,String,String,String,String])],ci);var Oa=class{constructor(e,t){this.signature=e,this.publicKey=t}};M([h(),B("design:type",String)],Oa.prototype,"signature",void 0);M([h(),B("design:type",String)],Oa.prototype,"publicKey",void 0);Oa=M([H(),B("design:paramtypes",[String,String])],Oa);var vr=class{constructor(e,t){this.domain=e,this.pointers=t}};M([h(),B("design:type",String)],vr.prototype,"domain",void 0);M([h(),B("design:type",Array)],vr.prototype,"pointers",void 0);vr=M([H(),B("design:paramtypes",[String,Array])],vr);var Da=class{constructor(e,t){this.with=e,this.can=t}};M([h(),B("design:type",vr)],Da.prototype,"with",void 0);M([h(),B("design:type",Array)],Da.prototype,"can",void 0);Da=M([H(),B("design:paramtypes",[vr,Array])],Da);var zt=class{constructor(e,t,r,n,a){this.appName=e,this.appDesc=t,this.appIconPath=a,this.appUrl=r,this.capabilities=n}};M([h(),B("design:type",String)],zt.prototype,"appName",void 0);M([h(),B("design:type",String)],zt.prototype,"appDesc",void 0);M([h(),B("design:type",String)],zt.prototype,"appUrl",void 0);M([h(),B("design:type",String)],zt.prototype,"appIconPath",void 0);M([h(),B("design:type",Array)],zt.prototype,"capabilities",void 0);zt=M([H(),B("design:paramtypes",[String,String,String,Array,String])],zt);var br=class{constructor(e,t,r,n){this.requestId=e,this.auth=t,this.token=r,this.revoked=n}};M([h(),B("design:type",String)],br.prototype,"requestId",void 0);M([h(),B("design:type",String)],br.prototype,"token",void 0);M([h(),B("design:type",Boolean)],br.prototype,"revoked",void 0);M([h(),B("design:type",zt)],br.prototype,"auth",void 0);br=M([H(),B("design:paramtypes",[String,zt,String,Boolean])],br);var wr=class{constructor(e,t){this.domain=e,this.pointers=t}};M([h(),B("design:type",String)],wr.prototype,"domain",void 0);M([h(),B("design:type",Array)],wr.prototype,"pointers",void 0);wr=M([Te(),B("design:paramtypes",[String,Array])],wr);var Ua=class{constructor(e,t){this.with=e,this.can=t}};M([h(),B("design:type",wr)],Ua.prototype,"with",void 0);M([h(),B("design:type",Array)],Ua.prototype,"can",void 0);Ua=M([Te(),B("design:paramtypes",[wr,Array])],Ua);var Rt=class{constructor(e,t,r,n,a,s){this.appName=e,this.appDesc=t,this.appUrl=n,this.appDomain=r,this.capabilities=s,this.appIconPath=a}};M([h(),B("design:type",String)],Rt.prototype,"appName",void 0);M([h(),B("design:type",String)],Rt.prototype,"appDesc",void 0);M([h(),B("design:type",String)],Rt.prototype,"appDomain",void 0);M([h(),B("design:type",String)],Rt.prototype,"appUrl",void 0);M([h(),B("design:type",String)],Rt.prototype,"appIconPath",void 0);M([h(),B("design:type",Array)],Rt.prototype,"capabilities",void 0);Rt=M([Te(),B("design:paramtypes",[String,String,String,String,String,Array])],Rt);var qi=class{constructor(e,t,r){this.did=e,this.success=t,this.error=r}};M([h(),B("design:type",String)],qi.prototype,"did",void 0);M([h(),B("design:type",Boolean)],qi.prototype,"success",void 0);M([h(),B("design:type",String)],qi.prototype,"error",void 0);qi=M([H(),B("design:paramtypes",[String,Boolean,String])],qi);var Ir=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Tr=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},lt=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)}};Ir([h(),Tr("design:type",Boolean)],lt.prototype,"isInitialized",void 0);Ir([h(),Tr("design:type",Boolean)],lt.prototype,"isUnlocked",void 0);Ir([h(),Tr("design:type",String)],lt.prototype,"did",void 0);Ir([h(),Tr("design:type",String)],lt.prototype,"didDocument",void 0);Ir([h(),Tr("design:type",String)],lt.prototype,"error",void 0);lt=Ir([H(),Tr("design:paramtypes",[Object])],lt);var yc=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},me=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Qe,Ge,Xs=class{constructor(e,t){Qe.set(this,void 0),Ge.set(this,void 0),yc(this,Qe,e,"f"),yc(this,Ge,t,"f")}async otherAgents(){return await me(this,Qe,"f").otherAgents(me(this,Ge,"f"))}async hasTelepresenceAdapter(){return await me(this,Qe,"f").hasTelepresenceAdapter(me(this,Ge,"f"))}async onlineAgents(){return await me(this,Qe,"f").onlineAgents(me(this,Ge,"f"))}async setOnlineStatus(e){return await me(this,Qe,"f").setOnlineStatus(me(this,Ge,"f"),e)}async setOnlineStatusU(e){return await me(this,Qe,"f").setOnlineStatusU(me(this,Ge,"f"),e)}async sendSignal(e,t){return await me(this,Qe,"f").sendSignal(me(this,Ge,"f"),e,t)}async sendSignalU(e,t){return await me(this,Qe,"f").sendSignalU(me(this,Ge,"f"),e,t)}async sendBroadcast(e,t=!1){return await me(this,Qe,"f").sendBroadcast(me(this,Ge,"f"),e,t)}async sendBroadcastU(e,t=!1){return await me(this,Qe,"f").sendBroadcastU(me(this,Ge,"f"),e,t)}async addSignalHandler(e){await me(this,Qe,"f").addSignalHandler(me(this,Ge,"f"),e)}removeSignalHandler(e){me(this,Qe,"f").removeSignalHandler(me(this,Ge,"f"),e)}};Qe=new WeakMap,Ge=new WeakMap;var Ji=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Yi=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},ae=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)}};Ji([h(),Yi("design:type",String)],ae.prototype,"source",void 0);Ji([h(),Yi("design:type",String)],ae.prototype,"target",void 0);Ji([h(),Yi("design:type",String)],ae.prototype,"predicate",void 0);Ji([h(),Yi("design:type",Date)],ae.prototype,"fromDate",void 0);Ji([h(),Yi("design:type",Date)],ae.prototype,"untilDate",void 0);Ji([h(),Yi("design:type",Number)],ae.prototype,"limit",void 0);ae=Ji([H(),Te(),Yi("design:paramtypes",[Object])],ae);var vc=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},Le=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Ze,Mt;function Xn(i){return encodeURIComponent(i).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}var le=class{constructor(){Ze.set(this,void 0),Mt.set(this,void 0)}static fromUrl(e){if(!e||!e.startsWith("literal://"))throw new Error("Can't create Literal from non-literal URL");let t=new le;return vc(t,Mt,e,"f"),t}static from(e){let t=new le;return vc(t,Ze,e,"f"),t}toUrl(){if(Le(this,Mt,"f")&&!Le(this,Ze,"f"))return Le(this,Mt,"f");if(!Le(this,Mt,"f")&&(Le(this,Ze,"f")===void 0||Le(this,Ze,"f")===""||Le(this,Ze,"f")===null))throw new Error("Can't turn empty Literal into URL");let e;switch(typeof Le(this,Ze,"f")){case"string":e=`string:${Xn(Le(this,Ze,"f"))}`;break;case"number":e=`number:${Xn(Le(this,Ze,"f"))}`;break;case"boolean":e=`boolean:${Xn(Le(this,Ze,"f"))}`;break;case"object":e=`json:${Xn(JSON.stringify(Le(this,Ze,"f")))}`;break}return`literal://${e}`}get(){if(Le(this,Ze,"f"))return Le(this,Ze,"f");if(!Le(this,Mt,"f"))throw new Error("Can't render empty Literal");if(!Le(this,Mt,"f").startsWith("literal://"))throw new Error("Can't render Literal from non-literal URL");let e=Le(this,Mt,"f").substring(10);if(e.startsWith("string:"))return decodeURIComponent(e.substring(7));if(e.startsWith("number:")){let t=e.substring(7);return parseFloat(t)}if(e.startsWith("json:")){let t=e.substring(5);return JSON.parse(decodeURIComponent(t))}throw new Error(`Can't parse unknown literal: ${e}`)}};Ze=new WeakMap,Mt=new WeakMap;function He(i){return i.charAt(0).toUpperCase()+i.slice(1)}function Ya(i){return`set${He(i)}`}function Vl(i){return i.endsWith("ies")?i.slice(0,-3)+"y":i.endsWith("s")?i.slice(0,-1):i}function tp(i){return`add${He(Vl(i))}`}function ip(i){return`remove${He(Vl(i))}`}function rp(i){return`set${He(i)}`}function Wl(i){let e="",t="abcdefghijklmnopqrstuvwxyz",r=t.length;for(let n=0;n<i;n++)e+=t.charAt(Math.floor(Math.random()*r));return e}function Ei(i){if(Array.isArray(i))return`[${i.map(Ei).join(", ")}]`;let e=Object.keys(i),t=[];for(let r of e){let n=JSON.stringify(i[r]),a=`${r}: ${n}`;t.push(a)}return`{${t.join(", ")}}`}var Cs=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},K=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Fe,je,ye,gn=class{constructor(i,e,t){Fe.set(this,void 0),je.set(this,void 0),ye.set(this,void 0),Cs(this,Fe,e,"f"),Cs(this,je,t,"f"),Cs(this,ye,i,"f")}get baseExpression(){return K(this,Fe,"f")}async init(){let isInstance=await K(this,ye,"f").isSubjectInstance(K(this,Fe,"f"),K(this,je,"f"));if(!isInstance)throw`Not a valid subject instance of ${K(this,je,"f")} for ${K(this,Fe,"f")}`;let results=await K(this,ye,"f").infer(`subject_class("${K(this,je,"f")}", C), property(C, Property)`),properties=results.map(i=>i.Property);for(let i of properties)await K(this,ye,"f").infer(`subject_class("${K(this,je,"f")}", C), property_resolve(C, "${i}")`),Object.defineProperty(this,i,{configurable:!0,get:async()=>{try{return await K(this,ye,"f").getPropertyValueViaSurreal(K(this,Fe,"f"),K(this,je,"f"),i)}catch(e){console.warn(`Failed to get property ${i} via SurrealDB:`,e);return}}});let setters=await K(this,ye,"f").infer(`subject_class("${K(this,je,"f")}", C), property_setter(C, Property, Setter)`);for(let setter of setters||[])if(setter){let property=setter.Property,actions=eval(setter.Setter),resolveLanguageResults=await K(this,ye,"f").infer(`subject_class("${K(this,je,"f")}", C), property_resolve_language(C, "${property}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),this[Ya(property)]=async i=>{resolveLanguage&&(i=await K(this,ye,"f").createExpression(i,resolveLanguage)),await K(this,ye,"f").executeAction(actions,K(this,Fe,"f"),[{name:"value",value:i}])}}let results2=await K(this,ye,"f").infer(`subject_class("${K(this,je,"f")}", C), collection(C, Collection)`);results2||(results2=[]);let relations=results2.map(i=>i.Collection);for(let i of relations)Object.defineProperty(this,i,{configurable:!0,get:async()=>{try{return await K(this,ye,"f").getRelationValuesViaSurreal(K(this,Fe,"f"),K(this,je,"f"),i)}catch(e){return console.warn(`Failed to get relation ${i} via SurrealDB:`,e),[]}}});let adders=await K(this,ye,"f").infer(`subject_class("${K(this,je,"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[tp(relation)]=async i=>{Array.isArray(i)?await Promise.all(i.map(e=>K(this,ye,"f").executeAction(actions,K(this,Fe,"f"),[{name:"value",value:e}]))):await K(this,ye,"f").executeAction(actions,K(this,Fe,"f"),[{name:"value",value:i}])}}let removers=await K(this,ye,"f").infer(`subject_class("${K(this,je,"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[ip(relation)]=async i=>{Array.isArray(i)?await Promise.all(i.map(e=>K(this,ye,"f").executeAction(actions,K(this,Fe,"f"),[{name:"value",value:e}]))):await K(this,ye,"f").executeAction(actions,K(this,Fe,"f"),[{name:"value",value:i}])}}let relationSetters=await K(this,ye,"f").infer(`subject_class("${K(this,je,"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[rp(relation)]=async i=>{Array.isArray(i)?await K(this,ye,"f").executeAction(actions,K(this,Fe,"f"),i.map(e=>({name:"value",value:e}))):await K(this,ye,"f").executeAction(actions,K(this,Fe,"f"),[{name:"value",value:i}])}}}};Fe=new WeakMap,je=new WeakMap,ye=new WeakMap;function np(i,e,t,r){let n="",a=Wl(8);n+=`subject_class("${i}", ${a}).
435
- `;let s=[],o=[];e.subjectConstructor&&e.subjectConstructor.length&&(o=o.concat(e.subjectConstructor));let l=[];e.isSubjectInstance&&e.isSubjectInstance.length&&(l=l.concat(e.isSubjectInstance));let c=[];for(let d in t){let f=`property(${a}, "${d}").
436
- `,{through:g,initial:_,required:E,resolveLanguage:A,writable:k,flag:w,prologGetter:C,prologSetter:U,local:P}=t[d];if(A&&(f+=`property_resolve(${a}, "${d}").
437
- `,f+=`property_resolve_language(${a}, "${d}", "${A}").
438
- `),C?f+=`property_getter(${a}, Base, "${d}", Value) :- ${C}.
439
- `:g&&(f+=`property_getter(${a}, Base, "${d}", Value) :- triple(Base, "${g}", Value).
440
- `,E&&(w?l.push(`triple(Base, "${g}", "${_}")`):l.push(`triple(Base, "${g}", _)`))),U)f+=`property_setter(${a}, "${d}", Actions) :- ${U}.
441
- `;else if(k&&g&&typeof e[Ya(d)]=="function"){let R=[{action:"setSingleTarget",source:"this",predicate:g,target:"value",...P&&{local:!0}}];f+=`property_setter(${a}, "${d}", '${Ei(R)}').
442
- `}c.push(f);let Q=_??(E&&k&&!w&&g?"literal://string:":void 0);Q&&(o.push({action:"addLink",source:"this",predicate:g,target:Q}),s.push({action:"removeLink",source:"this",predicate:g,target:"*"}))}let u=[],m=Object.fromEntries(Object.entries(r).filter(([,d])=>d.kind==="hasMany"||d.kind==="belongsToMany"));for(let d in m){let f=`collection(${a}, "${d}").
443
- `,{predicate:g,local:_}=m[d];if(g){f+=`collection_getter(${a}, Base, "${d}", List) :- findall(C, triple(Base, "${g}", C), List).
444
- `;let E=[{action:"addLink",source:"this",predicate:g,target:"value",..._&&{local:!0}}],A=[{action:"removeLink",source:"this",predicate:g,target:"value"}],k=[{action:"collectionSetter",source:"this",predicate:g,target:"value",..._&&{local:!0}}];f+=`collection_adder(${a}, "${d}", '${Ei(E)}').
445
- `,f+=`collection_remover(${a}, "${d}", '${Ei(A)}').
446
- `,f+=`collection_setter(${a}, "${d}", '${Ei(k)}').
447
- `}u.push(f)}let y=Ei(o);if(n+=`constructor(${a}, '${y}').
448
- `,l.length>0){let d=l.join(", ");n+=`instance(${a}, Base) :- ${d}.
478
+ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):s||ao.set(n,s=new Set),s.add(a),e.has(a)||(e.add(a),t.push(r))}else t.push(r)}),Da(Da({},i),{definitions:t})}function sp(i){var e=new Set(i.definitions);e.forEach(function(r){r.loc&&delete r.loc,Object.keys(r).forEach(function(n){var a=r[n];a&&typeof a=="object"&&e.add(a)})});var t=i.loc;return t&&(delete t.startToken,delete t.endToken),i}function op(i){var e=tu(i);if(!Aa.has(e)){var t=ip(i,{experimentalFragmentVariables:Ma,allowLegacyFragmentVariables:Ma});if(!t||t.kind!=="Document")throw new Error("Not a valid GraphQL document.");Aa.set(e,sp(ap(t)))}return Aa.get(e)}function v(i){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];typeof i=="string"&&(i=[i]);var r=i[0];return e.forEach(function(n,a){n&&n.kind==="Document"?r+=n.loc.source.body:r+=n,r+=i[a+1]}),op(r)}function cp(){Aa.clear(),ao.clear()}function lp(){eu=!1}function up(){Ma=!0}function dp(){Ma=!1}var Qr={gql:v,resetCaches:cp,disableFragmentWarnings:lp,enableExperimentalFragmentVariables:up,disableExperimentalFragmentVariables:dp};(function(i){i.gql=Qr.gql,i.resetCaches=Qr.resetCaches,i.disableFragmentWarnings=Qr.disableFragmentWarnings,i.enableExperimentalFragmentVariables=Qr.enableExperimentalFragmentVariables,i.disableExperimentalFragmentVariables=Qr.disableExperimentalFragmentVariables})(v||(v={}));v.default=v;function b(i){if(!i)throw"Got no result from Apollo";if(i.error)throw i.error;if(i.errors)throw i.errors;return i.data}function pp(){}function mi(){return pp}var M=mi,g=mi,Ce=mi,ee=mi,H=mi,be=mi,fp=mi,Co=mi,iu=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},ru=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Hi=class{constructor(e){this.code=e}};iu([g(),ru("design:type",String)],Hi.prototype,"code",void 0);Hi=iu([H(),ru("design:paramtypes",[String])],Hi);var Lo=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Po=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},$t=class{constructor(e,t){this.address=e,this.name=t}};Lo([g(),Po("design:type",String)],$t.prototype,"address",void 0);Lo([g(),Po("design:type",String)],$t.prototype,"name",void 0);$t=Lo([H(),Po("design:paramtypes",[String,String])],$t);var fe=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},xe=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},jt=class{constructor(e,t){this.key=t,this.signature=e}};fe([g(),xe("design:type",String)],jt.prototype,"signature",void 0);fe([g(),xe("design:type",String)],jt.prototype,"key",void 0);fe([g(),xe("design:type",Boolean)],jt.prototype,"valid",void 0);fe([g(),xe("design:type",Boolean)],jt.prototype,"invalid",void 0);jt=fe([H(),Ce(),xe("design:paramtypes",[String,String])],jt);var zi=class{};fe([g(),xe("design:type",String)],zi.prototype,"signature",void 0);fe([g(),xe("design:type",String)],zi.prototype,"key",void 0);fe([g(),xe("design:type",Boolean)],zi.prototype,"valid",void 0);fe([g(),xe("design:type",Boolean)],zi.prototype,"invalid",void 0);zi=fe([Ce()],zi);function yi(i){let e=class{constructor(r,n,a,s){this.author=r,this.timestamp=n,this.data=a,this.proof=s}};return fe([g(),xe("design:type",String)],e.prototype,"author",void 0),fe([g(),xe("design:type",String)],e.prototype,"timestamp",void 0),fe([g(),xe("design:type",Object)],e.prototype,"data",void 0),fe([g(),xe("design:type",jt)],e.prototype,"proof",void 0),e=fe([H(),xe("design:paramtypes",[String,String,Object,jt])],e),e}function hp(i){let e=class{};return fe([g(),xe("design:type",String)],e.prototype,"author",void 0),fe([g(),xe("design:type",String)],e.prototype,"timestamp",void 0),fe([g(),xe("design:type",Object)],e.prototype,"data",void 0),fe([g(),xe("design:type",zi)],e.prototype,"proof",void 0),e=fe([Ce()],e),e}var Ec=class extends yi(){};Ec=fe([H()],Ec);var Fa=class extends yi(){};fe([g(),xe("design:type",$t)],Fa.prototype,"language",void 0);fe([g(),xe("design:type",Hi)],Fa.prototype,"icon",void 0);Fa=fe([H()],Fa);function w0(i){return i&&i.author&&i.timestamp&&i.data}var we=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Re=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Xe=class{constructor(e){this.source=e.source?e.source:"",this.target=e.target?e.target:"",this.predicate=e.predicate?e.predicate:""}};we([g(),Re("design:type",String)],Xe.prototype,"source",void 0);we([g(),Re("design:type",String)],Xe.prototype,"target",void 0);we([g(),Re("design:type",String)],Xe.prototype,"predicate",void 0);Xe=we([H(),Re("design:paramtypes",[Object])],Xe);var ja=class{};we([g(),Re("design:type",Array)],ja.prototype,"additions",void 0);we([g(),Re("design:type",Array)],ja.prototype,"removals",void 0);ja=we([Ce()],ja);var qa=class{constructor(e,t){this.additions=e,this.removals=t}};we([g(),Re("design:type",Array)],qa.prototype,"additions",void 0);we([g(),Re("design:type",Array)],qa.prototype,"removals",void 0);qa=we([H(),Re("design:paramtypes",[Array,Array])],qa);var Ln=class{};we([g(),Re("design:type",String)],Ln.prototype,"source",void 0);we([g(),Re("design:type",String)],Ln.prototype,"target",void 0);we([g(),Re("design:type",String)],Ln.prototype,"predicate",void 0);Ln=we([Ce()],Ln);var li=class extends yi(){hash(){let e=JSON.stringify(this.data,Object.keys(this.data).sort())+JSON.stringify(this.author)+this.timestamp,t=0,r,n;for(r=0;r<e.length;r++)n=e.charCodeAt(r),t=(t<<5)-t+n,t|=0;return t}};we([g(),Re("design:type",String)],li.prototype,"status",void 0);li=we([H()],li);var so=class extends hp(){};we([g(),Re("design:type",String)],so.prototype,"status",void 0);so=we([Ce()],so);function k0(i,e){return i.author==e.author&&i.timestamp==e.timestamp&&i.data.source==e.data.source&&i.data.predicate==e.data.predicate&&i.data.target==e.data.target}function I0(i){return i&&i.source&&i.target}var Ba=class{constructor(e,t){this.oldLink=e,this.newLink=t}};we([g(),Re("design:type",li)],Ba.prototype,"oldLink",void 0);we([g(),Re("design:type",li)],Ba.prototype,"newLink",void 0);Ba=we([H(),Re("design:paramtypes",[li,li])],Ba);var tr=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Hn=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},oo,It=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 r=JSON.parse(JSON.stringify(this.links));return e.target&&(r=r.filter(n=>n.data.target===e.target)),e.predicate&&(r=r.filter(n=>n.data.predicate===e.predicate)),e.fromDate&&(r=r.filter(n=>new Date(n.timestamp)>=e.fromDate)),e.untilDate&&(r=r.filter(n=>new Date(n.timestamp)<=e.untilDate)),e.limit&&(r=r.slice(0,e.limit)),r}if(e.target){let r=JSON.parse(JSON.stringify(this.links));return e.predicate&&(r=r.filter(n=>n.data.predicate===e.predicate)),e.fromDate&&(r=r.filter(n=>new Date(n.timestamp)>=e.fromDate)),e.untilDate&&(r=r.filter(n=>new Date(n.timestamp)<=e.untilDate)),e.limit&&(r=r.slice(0,e.limit)),r}let t=JSON.parse(JSON.stringify(this.links));return t=t.filter(r=>r.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}};tr([g(),Hn("design:type",Array)],It.prototype,"links",void 0);It=tr([H(),Hn("design:paramtypes",[Array])],It);var Ha=class{};tr([g(),Hn("design:type",Array)],Ha.prototype,"links",void 0);Ha=tr([Ce()],Ha);var co=oo=class{constructor(e){e?this.links=e:this.links=[]}static fromLink(e){let t=new oo;return t.links.push(e),t}};tr([g(),Hn("design:type",Array)],co.prototype,"links",void 0);co=oo=tr([Ce(),Hn("design:paramtypes",[Array])],co);var Vi=class extends yi(){};Vi=tr([H()],Vi);var j=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},q=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},ni=class{constructor(e,t){this.did=e,t?this.perspective=t:this.perspective=new It}};j([g(),q("design:type",String)],ni.prototype,"did",void 0);j([g(),q("design:type",It)],ni.prototype,"perspective",void 0);j([g(),q("design:type",String)],ni.prototype,"directMessageLanguage",void 0);ni=j([H(),q("design:paramtypes",[String,It])],ni);var Ac=class extends yi(){};Ac=j([H()],Ac);var ui=class{constructor(e,t,r,n,a,s){this.did=e,this.didSigningKeyId=t,this.deviceKeyType=r,this.deviceKey=n,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=s}};j([g(),q("design:type",String)],ui.prototype,"did",void 0);j([g(),q("design:type",String)],ui.prototype,"didSigningKeyId",void 0);j([g(),q("design:type",String)],ui.prototype,"deviceKeyType",void 0);j([g(),q("design:type",String)],ui.prototype,"deviceKey",void 0);j([g(),q("design:type",String)],ui.prototype,"deviceKeySignedByDid",void 0);j([g(),q("design:type",String)],ui.prototype,"didSignedByDeviceKey",void 0);ui=j([H(),q("design:paramtypes",[String,String,String,String,String,String])],ui);var di=class{constructor(e,t,r,n,a,s){this.did=e,this.didSigningKeyId=t,this.deviceKeyType=r,this.deviceKey=n,this.deviceKeySignedByDid=a,this.didSignedByDeviceKey=s}};j([g(),q("design:type",String)],di.prototype,"did",void 0);j([g(),q("design:type",String)],di.prototype,"didSigningKeyId",void 0);j([g(),q("design:type",String)],di.prototype,"deviceKeyType",void 0);j([g(),q("design:type",String)],di.prototype,"deviceKey",void 0);j([g(),q("design:type",String)],di.prototype,"deviceKeySignedByDid",void 0);j([g(),q("design:type",String)],di.prototype,"didSignedByDeviceKey",void 0);di=j([Ce(),q("design:paramtypes",[String,String,String,String,String,String])],di);var za=class{constructor(e,t){this.signature=e,this.publicKey=t}};j([g(),q("design:type",String)],za.prototype,"signature",void 0);j([g(),q("design:type",String)],za.prototype,"publicKey",void 0);za=j([H(),q("design:paramtypes",[String,String])],za);var $r=class{constructor(e,t){this.domain=e,this.pointers=t}};j([g(),q("design:type",String)],$r.prototype,"domain",void 0);j([g(),q("design:type",Array)],$r.prototype,"pointers",void 0);$r=j([H(),q("design:paramtypes",[String,Array])],$r);var Va=class{constructor(e,t){this.with=e,this.can=t}};j([g(),q("design:type",$r)],Va.prototype,"with",void 0);j([g(),q("design:type",Array)],Va.prototype,"can",void 0);Va=j([H(),q("design:paramtypes",[$r,Array])],Va);var qt=class{constructor(e,t,r,n,a){this.appName=e,this.appDesc=t,this.appIconPath=a,this.appUrl=r,this.capabilities=n}};j([g(),q("design:type",String)],qt.prototype,"appName",void 0);j([g(),q("design:type",String)],qt.prototype,"appDesc",void 0);j([g(),q("design:type",String)],qt.prototype,"appUrl",void 0);j([g(),q("design:type",String)],qt.prototype,"appIconPath",void 0);j([g(),q("design:type",Array)],qt.prototype,"capabilities",void 0);qt=j([H(),q("design:paramtypes",[String,String,String,Array,String])],qt);var Er=class{constructor(e,t,r,n){this.requestId=e,this.auth=t,this.token=r,this.revoked=n}};j([g(),q("design:type",String)],Er.prototype,"requestId",void 0);j([g(),q("design:type",String)],Er.prototype,"token",void 0);j([g(),q("design:type",Boolean)],Er.prototype,"revoked",void 0);j([g(),q("design:type",qt)],Er.prototype,"auth",void 0);Er=j([H(),q("design:paramtypes",[String,qt,String,Boolean])],Er);var Ar=class{constructor(e,t){this.domain=e,this.pointers=t}};j([g(),q("design:type",String)],Ar.prototype,"domain",void 0);j([g(),q("design:type",Array)],Ar.prototype,"pointers",void 0);Ar=j([Ce(),q("design:paramtypes",[String,Array])],Ar);var Wa=class{constructor(e,t){this.with=e,this.can=t}};j([g(),q("design:type",Ar)],Wa.prototype,"with",void 0);j([g(),q("design:type",Array)],Wa.prototype,"can",void 0);Wa=j([Ce(),q("design:paramtypes",[Ar,Array])],Wa);var Tt=class{constructor(e,t,r,n,a,s){this.appName=e,this.appDesc=t,this.appUrl=n,this.appDomain=r,this.capabilities=s,this.appIconPath=a}};j([g(),q("design:type",String)],Tt.prototype,"appName",void 0);j([g(),q("design:type",String)],Tt.prototype,"appDesc",void 0);j([g(),q("design:type",String)],Tt.prototype,"appDomain",void 0);j([g(),q("design:type",String)],Tt.prototype,"appUrl",void 0);j([g(),q("design:type",String)],Tt.prototype,"appIconPath",void 0);j([g(),q("design:type",Array)],Tt.prototype,"capabilities",void 0);Tt=j([Ce(),q("design:paramtypes",[String,String,String,String,String,Array])],Tt);var Wi=class{constructor(e,t,r){this.did=e,this.success=t,this.error=r}};j([g(),q("design:type",String)],Wi.prototype,"did",void 0);j([g(),q("design:type",Boolean)],Wi.prototype,"success",void 0);j([g(),q("design:type",String)],Wi.prototype,"error",void 0);Wi=j([H(),q("design:paramtypes",[String,Boolean,String])],Wi);var Nr=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Or=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},ut=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)}};Nr([g(),Or("design:type",Boolean)],ut.prototype,"isInitialized",void 0);Nr([g(),Or("design:type",Boolean)],ut.prototype,"isUnlocked",void 0);Nr([g(),Or("design:type",String)],ut.prototype,"did",void 0);Nr([g(),Or("design:type",String)],ut.prototype,"didDocument",void 0);Nr([g(),Or("design:type",String)],ut.prototype,"error",void 0);ut=Nr([H(),Or("design:paramtypes",[Object])],ut);var kc=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},ge=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Ge,Ze,lo=class{constructor(e,t){Ge.set(this,void 0),Ze.set(this,void 0),kc(this,Ge,e,"f"),kc(this,Ze,t,"f")}async otherAgents(){return await ge(this,Ge,"f").otherAgents(ge(this,Ze,"f"))}async hasTelepresenceAdapter(){return await ge(this,Ge,"f").hasTelepresenceAdapter(ge(this,Ze,"f"))}async onlineAgents(){return await ge(this,Ge,"f").onlineAgents(ge(this,Ze,"f"))}async setOnlineStatus(e){return await ge(this,Ge,"f").setOnlineStatus(ge(this,Ze,"f"),e)}async setOnlineStatusU(e){return await ge(this,Ge,"f").setOnlineStatusU(ge(this,Ze,"f"),e)}async sendSignal(e,t){return await ge(this,Ge,"f").sendSignal(ge(this,Ze,"f"),e,t)}async sendSignalU(e,t){return await ge(this,Ge,"f").sendSignalU(ge(this,Ze,"f"),e,t)}async sendBroadcast(e,t=!1){return await ge(this,Ge,"f").sendBroadcast(ge(this,Ze,"f"),e,t)}async sendBroadcastU(e,t=!1){return await ge(this,Ge,"f").sendBroadcastU(ge(this,Ze,"f"),e,t)}async addSignalHandler(e){await ge(this,Ge,"f").addSignalHandler(ge(this,Ze,"f"),e)}removeSignalHandler(e){ge(this,Ge,"f").removeSignalHandler(ge(this,Ze,"f"),e)}};Ge=new WeakMap,Ze=new WeakMap;var ir=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},rr=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},B=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)}};ir([g(),rr("design:type",String)],B.prototype,"source",void 0);ir([g(),rr("design:type",String)],B.prototype,"target",void 0);ir([g(),rr("design:type",String)],B.prototype,"predicate",void 0);ir([g(),rr("design:type",Date)],B.prototype,"fromDate",void 0);ir([g(),rr("design:type",Date)],B.prototype,"untilDate",void 0);ir([g(),rr("design:type",Number)],B.prototype,"limit",void 0);B=ir([H(),Ce(),rr("design:paramtypes",[Object])],B);var Ic=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},Le=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Je,Nt;function la(i){return encodeURIComponent(i).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)}var le=class{constructor(){Je.set(this,void 0),Nt.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 le;return Ic(t,Nt,e,"f"),t}static from(e){let t=new le;return Ic(t,Je,e,"f"),t}toUrl(){if(Le(this,Nt,"f")&&!Le(this,Je,"f"))return Le(this,Nt,"f");if(!Le(this,Nt,"f")&&(Le(this,Je,"f")===void 0||Le(this,Je,"f")===""||Le(this,Je,"f")===null))throw new Error("Can't turn empty Literal into URL");let e;switch(typeof Le(this,Je,"f")){case"string":e=`string:${la(Le(this,Je,"f"))}`;break;case"number":e=`number:${la(Le(this,Je,"f"))}`;break;case"boolean":e=`boolean:${la(Le(this,Je,"f"))}`;break;case"object":e=`json:${la(JSON.stringify(Le(this,Je,"f")))}`;break}return`literal:${e}`}get(){if(Le(this,Je,"f"))return Le(this,Je,"f");if(!Le(this,Nt,"f"))throw new Error("Can't render empty Literal");if(!Le(this,Nt,"f").startsWith("literal:"))throw new Error("Can't render Literal from non-literal URL");let e=Le(this,Nt,"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}`)}};Je=new WeakMap,Nt=new WeakMap;function He(i){return i.charAt(0).toUpperCase()+i.slice(1)}function os(i){return`set${He(i)}`}function nu(i){return i.endsWith("ies")?i.slice(0,-3)+"y":i.endsWith("s")?i.slice(0,-1):i}function gp(i){return`add${He(nu(i))}`}function mp(i){return`remove${He(nu(i))}`}function yp(i){return`set${He(i)}`}function au(i){let e="",t="abcdefghijklmnopqrstuvwxyz",r=t.length;for(let n=0;n<i;n++)e+=t.charAt(Math.floor(Math.random()*r));return e}function ki(i){if(Array.isArray(i))return`[${i.map(ki).join(", ")}]`;let e=Object.keys(i),t=[];for(let r of e){let n=JSON.stringify(i[r]),a=`${r}: ${n}`;t.push(a)}return`{${t.join(", ")}}`}var Fs=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},J=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Fe,je,me,$n=class{constructor(i,e,t){Fe.set(this,void 0),je.set(this,void 0),me.set(this,void 0),Fs(this,Fe,e,"f"),Fs(this,je,t,"f"),Fs(this,me,i,"f")}get baseExpression(){return J(this,Fe,"f")}async init(){let isInstance=await J(this,me,"f").isSubjectInstance(J(this,Fe,"f"),J(this,je,"f"));if(!isInstance)throw`Not a valid subject instance of ${J(this,je,"f")} for ${J(this,Fe,"f")}`;let results=await J(this,me,"f").infer(`subject_class("${J(this,je,"f")}", C), property(C, Property)`),properties=results.map(i=>i.Property);for(let i of properties)await J(this,me,"f").infer(`subject_class("${J(this,je,"f")}", C), property_resolve(C, "${i}")`),Object.defineProperty(this,i,{configurable:!0,get:async()=>{try{return await J(this,me,"f").getPropertyValueViaSparql(J(this,Fe,"f"),J(this,je,"f"),i)}catch(e){console.warn(`Failed to get property ${i} via SPARQL:`,e);return}}});let setters=await J(this,me,"f").infer(`subject_class("${J(this,je,"f")}", C), property_setter(C, Property, Setter)`);for(let setter of setters||[])if(setter){let property=setter.Property,actions=eval(setter.Setter),resolveLanguageResults=await J(this,me,"f").infer(`subject_class("${J(this,je,"f")}", C), property_resolve_language(C, "${property}", Language)`),resolveLanguage;resolveLanguageResults&&resolveLanguageResults.length>0&&(resolveLanguage=resolveLanguageResults[0].Language),this[os(property)]=async i=>{resolveLanguage&&(i=await J(this,me,"f").createExpression(i,resolveLanguage)),await J(this,me,"f").executeAction(actions,J(this,Fe,"f"),[{name:"value",value:i}])}}let results2=await J(this,me,"f").infer(`subject_class("${J(this,je,"f")}", C), collection(C, Collection)`);results2||(results2=[]);let relations=results2.map(i=>i.Collection);for(let i of relations)Object.defineProperty(this,i,{configurable:!0,get:async()=>{try{return await J(this,me,"f").getRelationValuesViaSparql(J(this,Fe,"f"),J(this,je,"f"),i)}catch(e){return console.warn(`Failed to get relation ${i} via SPARQL:`,e),[]}}});let adders=await J(this,me,"f").infer(`subject_class("${J(this,je,"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[gp(relation)]=async i=>{Array.isArray(i)?await Promise.all(i.map(e=>J(this,me,"f").executeAction(actions,J(this,Fe,"f"),[{name:"value",value:e}]))):await J(this,me,"f").executeAction(actions,J(this,Fe,"f"),[{name:"value",value:i}])}}let removers=await J(this,me,"f").infer(`subject_class("${J(this,je,"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[mp(relation)]=async i=>{Array.isArray(i)?await Promise.all(i.map(e=>J(this,me,"f").executeAction(actions,J(this,Fe,"f"),[{name:"value",value:e}]))):await J(this,me,"f").executeAction(actions,J(this,Fe,"f"),[{name:"value",value:i}])}}let relationSetters=await J(this,me,"f").infer(`subject_class("${J(this,je,"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[yp(relation)]=async i=>{Array.isArray(i)?await J(this,me,"f").executeAction(actions,J(this,Fe,"f"),i.map(e=>({name:"value",value:e}))):await J(this,me,"f").executeAction(actions,J(this,Fe,"f"),[{name:"value",value:i}])}}}};Fe=new WeakMap,je=new WeakMap,me=new WeakMap;function vp(i,e,t,r){let n="",a=au(8);n+=`subject_class("${i}", ${a}).
479
+ `;let s=[],o=[];e.subjectConstructor&&e.subjectConstructor.length&&(o=o.concat(e.subjectConstructor));let c=[];e.isSubjectInstance&&e.isSubjectInstance.length&&(c=c.concat(e.isSubjectInstance));let l=[];for(let d in t){let f=`property(${a}, "${d}").
480
+ `,{through:h,initial:S,required:x,resolveLanguage:T,writable:k,flag:_,prologGetter:L,prologSetter:D,local:P}=t[d];if(T&&(f+=`property_resolve(${a}, "${d}").
481
+ `,f+=`property_resolve_language(${a}, "${d}", "${T}").
482
+ `),L?f+=`property_getter(${a}, Base, "${d}", Value) :- ${L}.
483
+ `:h&&(f+=`property_getter(${a}, Base, "${d}", Value) :- triple(Base, "${h}", Value).
484
+ `,x&&(_?c.push(`triple(Base, "${h}", "${S}")`):c.push(`triple(Base, "${h}", _)`))),D)f+=`property_setter(${a}, "${d}", Actions) :- ${D}.
485
+ `;else if(k&&h&&typeof e[os(d)]=="function"){let R=[{action:"setSingleTarget",source:"this",predicate:h,target:"value",...P&&{local:!0}}];f+=`property_setter(${a}, "${d}", '${ki(R)}').
486
+ `}l.push(f);let W=S??(x&&k&&!_&&h?"literal:string:":void 0);W&&(o.push({action:"addLink",source:"this",predicate:h,target:W}),s.push({action:"removeLink",source:"this",predicate:h,target:"*"}))}let u=[],m=Object.fromEntries(Object.entries(r).filter(([,d])=>d.kind==="hasMany"||d.kind==="belongsToMany"));for(let d in m){let f=`collection(${a}, "${d}").
487
+ `,{predicate:h,local:S}=m[d];if(h){f+=`collection_getter(${a}, Base, "${d}", List) :- findall(C, triple(Base, "${h}", C), List).
488
+ `;let x=[{action:"addLink",source:"this",predicate:h,target:"value",...S&&{local:!0}}],T=[{action:"removeLink",source:"this",predicate:h,target:"value"}],k=[{action:"collectionSetter",source:"this",predicate:h,target:"value",...S&&{local:!0}}];f+=`collection_adder(${a}, "${d}", '${ki(x)}').
489
+ `,f+=`collection_remover(${a}, "${d}", '${ki(T)}').
490
+ `,f+=`collection_setter(${a}, "${d}", '${ki(k)}').
491
+ `}u.push(f)}let y=ki(o);if(n+=`constructor(${a}, '${y}').
492
+ `,c.length>0){let d=c.join(", ");n+=`instance(${a}, Base) :- ${d}.
449
493
  `,n+=`
450
- `}return n+=`destructor(${a}, '${Ei(s)}').
494
+ `}return n+=`destructor(${a}, '${ki(s)}').
451
495
  `,n+=`
452
- `,n+=c.join(`
496
+ `,n+=l.join(`
453
497
  `),n+=`
454
498
  `,n+=u.join(`
455
- `),{sdna:n,name:i}}function bc(i){let e=i.lastIndexOf("#");if(e!==-1)return i.substring(0,e+1);let t=i.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 r=i.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:)/);return r?r[1]:""}function wc(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 Sc(i){let e=i.lastIndexOf("#");if(e!==-1)return i.substring(e+1);let t=i.lastIndexOf("/");if(t!==-1&&t<i.length-1)return i.substring(t+1);let r=i.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:(.+)$/);return r?r[1]:i}var ii=class{constructor(e,t){if(t!==void 0)this.nodeShapeUri=e,this.targetClass=t;else{this.targetClass=e;let r=bc(e),n=Sc(e);this.nodeShapeUri=`${r}${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#> .
499
+ `),{sdna:n,name:i}}function Tc(i){let e=i.lastIndexOf("#");if(e!==-1)return i.substring(0,e+1);let t=i.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 r=i.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:)/);return r?r[1]:""}function Cc(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 Lc(i){let e=i.lastIndexOf("#");if(e!==-1)return i.substring(e+1);let t=i.lastIndexOf("/");if(t!==-1&&t<i.length-1)return i.substring(t+1);let r=i.match(/^[a-zA-Z][a-zA-Z0-9+.-]*:(.+)$/);return r?r[1]:i}var ai=class{constructor(e,t){if(t!==void 0)this.nodeShapeUri=e,this.targetClass=t;else{this.targetClass=e;let r=Tc(e),n=Lc(e);this.nodeShapeUri=`${r}${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#> .
456
500
  `;e+=`@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
457
501
  `,e+=`@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
458
502
  `,e+=`@prefix ad4m: <ad4m://> .
@@ -467,27 +511,25 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):s
467
511
  `),r.nodeKind&&(e+=` sh:nodeKind sh:${r.nodeKind} ;
468
512
  `),r.minCount!==void 0&&(e+=` sh:minCount ${r.minCount} ;
469
513
  `),r.maxCount!==void 0&&(e+=` sh:maxCount ${r.maxCount} ;
470
- `),r.pattern&&(e+=` sh:pattern "${wc(r.pattern)}" ;
514
+ `),r.pattern&&(e+=` sh:pattern "${Cc(r.pattern)}" ;
471
515
  `),r.minInclusive!==void 0&&(e+=` sh:minInclusive ${r.minInclusive} ;
472
516
  `),r.maxInclusive!==void 0&&(e+=` sh:maxInclusive ${r.maxInclusive} ;
473
- `),r.hasValue&&(e+=` sh:hasValue "${wc(r.hasValue)}" ;
517
+ `),r.hasValue&&(e+=` sh:hasValue "${Cc(r.hasValue)}" ;
474
518
  `),r.local!==void 0&&(e+=` ad4m:local ${r.local} ;
475
519
  `),r.writable!==void 0&&(e+=` ad4m:writable ${r.writable} ;
476
520
  `),e=e.slice(0,-2)+`
477
521
  `,e+=n?` ] .
478
522
  `:` ] ;
479
- `}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 r=this.properties[t],n;if(r.name&&this.targetClass){let a=bc(this.targetClass),s=Sc(this.targetClass);n=`${a}${s}.${r.name}`}else n=`_:propShape${t}`;e.push({source:this.nodeShapeUri,predicate:"sh://property",target:n}),e.push({source:n,predicate:"sh://path",target:r.path}),r.datatype&&e.push({source:n,predicate:"sh://datatype",target:r.datatype}),r.nodeKind&&e.push({source:n,predicate:"sh://nodeKind",target:`sh://${r.nodeKind}`}),r.minCount!==void 0&&e.push({source:n,predicate:"sh://minCount",target:`literal://${r.minCount}^^xsd:integer`}),r.maxCount!==void 0&&e.push({source:n,predicate:"sh://maxCount",target:`literal://${r.maxCount}^^xsd:integer`}),r.pattern&&e.push({source:n,predicate:"sh://pattern",target:`literal://${r.pattern}`}),r.minInclusive!==void 0&&e.push({source:n,predicate:"sh://minInclusive",target:`literal://${r.minInclusive}`}),r.maxInclusive!==void 0&&e.push({source:n,predicate:"sh://maxInclusive",target:`literal://${r.maxInclusive}`}),r.hasValue&&e.push({source:n,predicate:"sh://hasValue",target:`literal://${r.hasValue}`}),r.local!==void 0&&e.push({source:n,predicate:"ad4m://local",target:`literal://${r.local}`}),r.writable!==void 0&&e.push({source:n,predicate:"ad4m://writable",target:`literal://${r.writable}`}),r.resolveLanguage&&e.push({source:n,predicate:"ad4m://resolveLanguage",target:`literal://string:${r.resolveLanguage}`}),r.setter&&r.setter.length>0&&e.push({source:n,predicate:"ad4m://setter",target:`literal://string:${JSON.stringify(r.setter)}`}),r.adder&&r.adder.length>0&&e.push({source:n,predicate:"ad4m://adder",target:`literal://string:${JSON.stringify(r.adder)}`}),r.remover&&r.remover.length>0&&e.push({source:n,predicate:"ad4m://remover",target:`literal://string:${JSON.stringify(r.remover)}`}),r.getter&&e.push({source:n,predicate:"ad4m://getter",target:`literal://string:${r.getter}`}),r.conformanceConditions&&r.conformanceConditions.length>0&&e.push({source:n,predicate:"ad4m://conformanceConditions",target:`literal://string:${JSON.stringify(r.conformanceConditions)}`}),r.class&&e.push({source:n,predicate:"sh://class",target:r.class})}return e}static fromLinks(e,t){let r=e.find(l=>l.source===t&&l.predicate==="sh://targetClass"),n=new ii(t,r?.target),a=e.find(l=>l.source===t&&l.predicate==="ad4m://constructor");if(a)try{let l=a.target.replace("literal://string:","");n.constructor_actions=JSON.parse(l)}catch{}let s=e.find(l=>l.source===t&&l.predicate==="ad4m://destructor");if(s)try{let l=s.target.replace("literal://string:","");n.destructor_actions=JSON.parse(l)}catch{}let o=e.filter(l=>l.source===t&&l.predicate==="sh://property");for(let l of o){let c=l.target,u=e.find(T=>T.source===c&&T.predicate==="sh://path");if(!u)continue;let m;if(!c.startsWith("_:")){let T=c.lastIndexOf(".");T!==-1&&(m=c.substring(T+1))}let y={name:m,path:u.target},d=e.find(T=>T.source===c&&T.predicate==="sh://datatype");d&&(y.datatype=d.target);let f=e.find(T=>T.source===c&&T.predicate==="sh://nodeKind");f&&(y.nodeKind=f.target.replace("sh://",""));let g=e.find(T=>T.source===c&&T.predicate==="sh://minCount");if(g){let T=g.target.replace("literal://","").replace(/\^\^.*$/,"");T.startsWith("number:")&&(T=T.substring(7)),y.minCount=parseInt(T)}let _=e.find(T=>T.source===c&&T.predicate==="sh://maxCount");if(_){let T=_.target.replace("literal://","").replace(/\^\^.*$/,"");T.startsWith("number:")&&(T=T.substring(7)),y.maxCount=parseInt(T)}let E=e.find(T=>T.source===c&&T.predicate==="sh://pattern");E&&(y.pattern=E.target.replace("literal://",""));let A=e.find(T=>T.source===c&&T.predicate==="sh://minInclusive");if(A){let T=A.target.replace("literal://","");T.startsWith("number:")&&(T=T.substring(7)),y.minInclusive=parseFloat(T)}let k=e.find(T=>T.source===c&&T.predicate==="sh://maxInclusive");if(k){let T=k.target.replace("literal://","");T.startsWith("number:")&&(T=T.substring(7)),y.maxInclusive=parseFloat(T)}let w=e.find(T=>T.source===c&&T.predicate==="sh://hasValue");w&&(y.hasValue=w.target.replace("literal://",""));let C=e.find(T=>T.source===c&&T.predicate==="ad4m://local");if(C){let T=C.target.replace("literal://","");T.startsWith("boolean:")&&(T=T.substring(8)),y.local=T==="true"}let U=e.find(T=>T.source===c&&T.predicate==="ad4m://writable");if(U){let T=U.target.replace("literal://","");T.startsWith("boolean:")&&(T=T.substring(8)),y.writable=T==="true"}let P=e.find(T=>T.source===c&&T.predicate==="ad4m://resolveLanguage");P&&(y.resolveLanguage=P.target.replace("literal://string:",""));let Q=e.find(T=>T.source===c&&T.predicate==="ad4m://setter");if(Q)try{let T=Q.target.replace("literal://string:","");y.setter=JSON.parse(T)}catch{}let V=e.find(T=>T.source===c&&T.predicate==="ad4m://adder");if(V)try{let T=V.target.replace("literal://string:","");y.adder=JSON.parse(T)}catch{}let R=e.find(T=>T.source===c&&T.predicate==="ad4m://remover");if(R)try{let T=R.target.replace("literal://string:","");y.remover=JSON.parse(T)}catch{}let W=e.find(T=>T.source===c&&T.predicate==="ad4m://getter");W&&(y.getter=W.target.replace("literal://string:",""));let We=e.find(T=>T.source===c&&T.predicate==="ad4m://conformanceConditions");if(We)try{let T=We.target.replace("literal://string:","");y.conformanceConditions=JSON.parse(T)}catch{}let Or=e.find(T=>T.source===c&&T.predicate==="sh://class");Or&&(y.class=Or.target),n.addProperty(y)}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 ii(e.node_shape_uri,e.target_class):new ii(e.target_class);for(let r of e.properties||[])t.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});if(e.constructor_actions&&(t.constructor_actions=e.constructor_actions),e.destructor_actions&&(t.destructor_actions=e.destructor_actions),e.parent_shapes)for(let r of e.parent_shapes)t.addParentShape(r);return t}};function _c(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 Kl(i){let e=i.can.includes("*")?["READ","WRITE","UPDATE"]:i.can,t=i.with.domain==="*"?"":i.with.domain,r=i.with.pointers.includes("*")?["all AD4M data"]:i.with.pointers;return`${_c(e)} your ${t} actions, with access to ${_c(r)}`}function ee(i){return i.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function ce(i){return typeof i=="string"?`'${i.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`:typeof i=="number"||typeof i=="boolean"?String(i):Array.isArray(i)?`[${i.map(e=>ce(e)).join(", ")}]`:String(i)}function ap(i,e,t){let r=ee(i),n=t?.resolveLanguage==="literal"?"fn::parse_literal(out.uri)":"out.uri";if(Array.isArray(e)){let a=e.map(s=>ce(s)).join(", ");return`count(->link[WHERE predicate = '${r}' AND ${n} IN [${a}]]) > 0`}else if(typeof e=="object"&&e!==null){let a=e,s=[];if(a.not!==void 0)if(Array.isArray(a.not)){let l=a.not.map(c=>ce(c)).join(", ");s.push(`count(->link[WHERE predicate = '${r}' AND ${n} IN [${l}]]) = 0`)}else s.push(`count(->link[WHERE predicate = '${r}' AND ${n} = ${ce(a.not)}]) = 0`);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)&&s.push(`count(->link[WHERE predicate = '${r}']) > 0`),s.join(" AND ")}else return`count(->link[WHERE predicate = '${r}' AND ${n} = ${ce(e)}]) > 0`}function Ql(i,e){let t=[];for(let[r,n]of Object.entries(i)){if(["id","author","timestamp"].includes(r))continue;let a,s;if(e){let l=e.properties[r];l?(a=l.predicate,s=l.resolveLanguage):a=r}else a=r;let o=ap(a,n,{resolveLanguage:s});o&&t.push(o)}return t}function sp(i,e,t,r,n){let a=e.prototype,s="ad4m://",o=Object.fromEntries(Object.entries(r).filter(([,f])=>f.kind==="hasMany"||f.kind==="belongsToMany"));if(Object.keys(t).length>0){let f=t[Object.keys(t)[0]];if(f.through){let g=f.through.match(/^([^:]+:\/\/)/);g&&(s=g[1])}}else if(Object.keys(o).length>0){let f=o[Object.keys(o)[0]];if(f.predicate){let g=f.predicate.match(/^([^:]+:\/\/)/);g&&(s=g[1])}}let l=`${s}${i}Shape`,c=`${s}${i}`,u=new ii(l,c),m=Object.getPrototypeOf(e);if(m&&typeof m.generateSHACL=="function"){let f=m.generateSHACL();f?.shape?.nodeShapeUri&&u.addParentShape(f.shape.nodeShapeUri)}let y=[];a.subjectConstructor&&a.subjectConstructor.length&&(y=y.concat(a.subjectConstructor));let d=[];for(let f in t){let g=t[f];if(!g.through)continue;let _={name:f,path:g.through};if(g.resolveLanguage==="literal")_.datatype="xsd://string";else if(g.initial){let A=typeof a[f];A==="number"?_.datatype="xsd://integer":A==="boolean"?_.datatype="xsd://boolean":A==="string"&&(_.datatype="xsd://string")}g.required&&(_.minCount=1),_.maxCount=1,g.flag&&g.initial&&(_.hasValue=g.initial),g.local!==void 0&&(_.local=g.local),g.writable!==void 0&&(_.writable=g.writable),g.resolveLanguage&&(_.resolveLanguage=g.resolveLanguage),g.prologSetter?console.warn(`[SHACL Generation] Custom Prolog setter for property '${f}' 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.`):g.writable&&g.through&&typeof a[Ya(f)]=="function"&&(_.setter=[{action:"setSingleTarget",source:"this",predicate:g.through,target:"value",...g.local&&{local:!0}}]);let E=g.initial??(g.required&&g.writable&&!g.flag&&g.through?"literal://string:":void 0);E&&(y.push({action:"addLink",source:"this",predicate:g.through,target:E}),d.push({action:"removeLink",source:"this",predicate:g.through,target:"*"})),u.addProperty(_)}for(let f in o){let g=o[f];if(!g.predicate)continue;let _={name:f,path:g.predicate};if(_.nodeKind="IRI",g.local!==void 0&&(_.local=g.local),_.adder=[{action:"addLink",source:"this",predicate:g.predicate,target:"value",...g.local&&{local:!0}}],_.remover=[{action:"removeLink",source:"this",predicate:g.predicate,target:"value",...g.local&&{local:!0}}],g.getter)_.getter=g.getter;else if(g.where)try{let E=g.target?.(),A=E?E.getModelMetadata?.()??null:null,k=Ql(g.where,A);if(k.length>0){let w=ee(g.predicate);_.getter=`(->link[WHERE predicate = '${w}'].out[WHERE ${k.join(" AND ")}].uri)`}}catch{}else if(g.target&&g.filter!==!1)try{let E=g.target(),A=n(g.predicate,E);A&&(_.getter=A.getter,_.conformanceConditions=A.conformanceConditions)}catch{}if(g.target)try{let A=g.target().generateSHACL?.();A?.shape?.nodeShapeUri&&(_.class=A.shape.nodeShapeUri)}catch{}u.addProperty(_)}return u.setConstructorActions(y),u.setDestructorActions(d),{shape:u,name:i}}var Tt=new WeakMap,De=new WeakMap;function Hi(i){let e={},t=[],r=i;for(;r&&r!==Object;)t.unshift(r),r=Object.getPrototypeOf(r);for(let n of t){let a=Tt.get(n);a&&Object.assign(e,a)}return e}function $t(i){let e={},t=[],r=i;for(;r&&r!==Object;)t.unshift(r),r=Object.getPrototypeOf(r);for(let n of t){let a=De.get(n);a&&Object.assign(e,a)}return e}function op(i,e,t){Tt.has(i)||Tt.set(i,{}),Tt.get(i)[e]=t}function cp(i,e,t){De.has(i)||De.set(i,{}),De.get(i)[e]=t}function Gl(i,e){try{let t=Hi(e),r=[],n=[];for(let[o,l]of Object.entries(t))l.flag&&l.initial&&l.through&&(r.push({type:"flag",predicate:l.through,value:l.initial}),n.push(`count(->link[WHERE predicate = '${ee(l.through)}' AND out.uri = '${ee(l.initial)}']) > 0`));for(let[o,l]of Object.entries(t))l.required&&!l.flag&&!l.getter&&l.through&&(r.push({type:"required",predicate:l.through}),n.push(`count(->link[WHERE predicate = '${ee(l.through)}']) > 0`));return r.length===0?void 0:{getter:`(->link[WHERE predicate = '${ee(i)}'].out[WHERE ${n.join(" AND ")}].uri)`,conformanceConditions:r}}catch{return}}function Xa(i){return function(e,t){let r=i.readOnly?!1:!!i.through;if(i.required&&!i.initial)throw new Error("SubjectProperty requires an 'initial' option if 'required' is true");if(!i.through&&!i.prologGetter)throw new Error("SubjectProperty requires either 'through' or 'prologGetter' option");let n=e.constructor;if(Tt.has(n)||Tt.set(n,{}),Tt.get(n)[t]={...i,writable:r},r){let a=t;e[`set${He(a)}`]=()=>{}}Object.defineProperty(e,t,{configurable:!0,writable:!0})}}function S0(i){return Xa({...i,required:i.required??!1,readOnly:i.readOnly??!1})}function _0(i){return function(e,t){if(!i.through&&!i.value)throw new Error("SubjectFlag requires a 'through' and 'value' option");if(!i.through)throw new Error("SubjectFlag requires a 'through' option");if(!i.value)throw new Error("SubjectFlag requires a 'value' option");let r={through:i.through,required:!0,initial:i.value,flag:!0,readOnly:!0,writable:!1},n=e.constructor;Tt.has(n)||Tt.set(n,{}),Tt.get(n)[t]=r,e[t]=i.value,Object.defineProperty(e,t,{configurable:!0,writable:!0})}}function lp(i){return function(e){e.prototype.className=i.name,e.className=i.name,e.generateSDNA=function(){return np(i.name,e.prototype,Hi(e),$t(e))},e.generateSHACL=function(){return sp(i.name,e,Hi(e),$t(e),Gl)},Object.defineProperty(e,"type",{configurable:!0})}}function up(i){let e=i.required??!1;return Xa({...i,required:e,readOnly:i.readOnly??!1,resolveLanguage:i.resolveLanguage??"literal",initial:i.initial??(e?"literal://string:uninitialized":void 0)})}function x0(i){return up({...i,readOnly:!0})}function es(i,e){let t=typeof i=="function"?{...e||{},target:i}:i;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 SurrealQL.");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 E0(i,e){let t=es(i,e);return function(r,n){let a=r.constructor;De.has(a)||De.set(a,{});let s=De.get(a);s[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 o=n;t.through&&(r[`add${He(o)}`]=async function(l,c){return this.addRelationValue(o,l,c)},r[`remove${He(o)}`]=async function(l,c){return this.removeRelationValue(o,l,c)},r[`set${He(o)}`]=async function(l,c){return this.setRelationValues(o,l,c)}),Object.defineProperty(r,o,{configurable:!0,writable:!0})}}function $0(i,e){let t=es(i,e);return function(r,n){let a=r.constructor;De.has(a)||De.set(a,{});let s=De.get(a);s[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 o=n;t.through?(Xa({through:t.through,readOnly:!1,local:t.local})(r,n),r[`add${He(o)}`]=async function(l){return this.addRelationValue(o,l)},r[`remove${He(o)}`]=async function(l){return this.removeRelationValue(o,l)},r[`set${He(o)}`]=async function(l){return this.setRelationValues(o,l)}):Object.defineProperty(r,o,{configurable:!0,writable:!0})}}function A0(i,e){let t=es(i,e);return function(r,n){let a=r.constructor;De.has(a)||De.set(a,{});let s=De.get(a);s[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?Xa({through:t.through,readOnly:!0,local:t.local})(r,n):Object.defineProperty(r,n,{configurable:!0,writable:!0})}}function k0(i,e){let t=es(i,e);return function(r,n){let a=r.constructor;De.has(a)||De.set(a,{});let s=De.get(a);s[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(r,n,{configurable:!0,writable:!0})}}var Sr=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:le.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 r of this._states){let n=this.stateUri(r.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:le.from(r.name).toUrl()}),e.push({source:n,predicate:"ad4m://stateValue",target:le.from(r.value).toUrl()}),e.push({source:n,predicate:"ad4m://stateCheck",target:`literal://string:${encodeURIComponent(JSON.stringify(r.stateCheck))}`})}for(let r of this._transitions){let n=this.transitionUri(r.fromState,r.toState),a=this.stateUri(r.fromState),s=this.stateUri(r.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:le.from(r.actionName).toUrl()}),e.push({source:n,predicate:"ad4m://fromState",target:a}),e.push({source:n,predicate:"ad4m://toState",target:s}),e.push({source:n,predicate:"ad4m://transitionActions",target:`literal://string:${encodeURIComponent(JSON.stringify(r.actions))}`})}return e}static fromLinks(e,t){let r="Flow";if(!t.endsWith(r))throw new Error(`Invalid flow URI: ${t} (must end with 'Flow')`);let n=t.slice(0,-r.length),a=Math.max(n.lastIndexOf("/"),n.lastIndexOf(":")),s=n.slice(0,a+1),o=n.slice(a+1),l=new Sr(o,s),c=e.find(f=>f.source===t&&f.predicate==="ad4m://flowable");if(c)if(c.target==="ad4m://any")l.flowable="any";else try{let f=c.target.replace("literal://string:","");l.flowable=JSON.parse(decodeURIComponent(f))}catch{l.flowable="any"}let u=e.find(f=>f.source===t&&f.predicate==="ad4m://startAction");if(u)try{let f=u.target.replace("literal://string:","");l.startAction=JSON.parse(decodeURIComponent(f))}catch{}let m=e.filter(f=>f.source===t&&f.predicate==="ad4m://hasState"),y=new Map;for(let f of m){let g=f.target,_=e.find(U=>U.source===g&&U.predicate==="ad4m://stateName"),E=_?le.fromUrl(_.target).get():"";y.set(g,E);let A=e.find(U=>U.source===g&&U.predicate==="ad4m://stateValue"),k=A?le.fromUrl(A.target).get():0,w=e.find(U=>U.source===g&&U.predicate==="ad4m://stateCheck"),C={predicate:"",target:""};if(w)try{let U=w.target.replace("literal://string:","");C=JSON.parse(decodeURIComponent(U))}catch{}l.addState({name:E,value:k,stateCheck:C})}let d=e.filter(f=>f.source===t&&f.predicate==="ad4m://hasTransition");for(let f of d){let g=f.target,_=e.find(R=>R.source===g&&R.predicate==="ad4m://actionName"),E=_?le.fromUrl(_.target).get():"",k=e.find(R=>R.source===g&&R.predicate==="ad4m://fromState")?.target||"",w=y.get(k)||"",U=e.find(R=>R.source===g&&R.predicate==="ad4m://toState")?.target||"",P=y.get(U)||"",Q=e.find(R=>R.source===g&&R.predicate==="ad4m://transitionActions"),V=[];if(Q)try{let R=Q.target.replace("literal://string:","");V=JSON.parse(decodeURIComponent(R))}catch{}l.addTransition({actionName:E,fromState:w,toState:P,actions:V})}return l}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 Sr(e.name,e.namespace);t.flowable=e.flowable||"any",t.startAction=e.startAction||[];for(let r of e.states||[])t.addState(r);for(let r of e.transitions||[])t.addTransition(r);return t}},oe=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},x=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},va,Ft,_t,xt,Ri,Zt,Jt,$i,Gr,ba,Ai,ki,ot,hr,eo,re,ne,Ii,Ti,Ci,Zr,Ma=class{constructor(e,t,r){va.add(this),Ft.set(this,void 0),_t.set(this,void 0),xt.set(this,void 0),Ri.set(this,void 0),Zt.set(this,void 0),Jt.set(this,void 0),$i.set(this,void 0),Gr.set(this,!1),ba.set(this,void 0),Ai.set(this,void 0),ki.set(this,void 0),ot.set(this,void 0),hr.set(this,void 0),this.isSurrealDB=!1,oe(this,Ft,e,"f"),oe(this,hr,t,"f"),oe(this,xt,r,"f"),oe(this,Ri,new Set,"f"),oe(this,$i,null,"f"),oe(this,ba,new Promise((n,a)=>{oe(this,Ai,n,"f"),oe(this,ki,a,"f")}),"f")}async subscribe(){x(this,Jt,"f")&&(x(this,Jt,"f").call(this),oe(this,Jt,void 0,"f")),x(this,ot,"f")&&(clearTimeout(x(this,ot,"f")),oe(this,ot,void 0,"f")),x(this,Zt,"f")&&(clearTimeout(x(this,Zt,"f")),oe(this,Zt,void 0,"f"));try{let t;this.isSurrealDB?t=await x(this,xt,"f").perspectiveSubscribeSurrealQuery(x(this,Ft,"f"),x(this,hr,"f")):t=await x(this,xt,"f").subscribeQuery(x(this,Ft,"f"),x(this,hr,"f")),oe(this,_t,t.subscriptionId,"f"),t.result?(oe(this,$i,t.result,"f"),x(this,va,"m",eo).call(this,t.result)):console.warn("\u26A0\uFE0F No initial result returned from subscribeQuery!"),oe(this,ot,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"),oe(this,Jt,x(this,xt,"f").subscribeToQueryUpdates(x(this,_t,"f"),r=>{x(this,ot,"f")&&(clearTimeout(x(this,ot,"f")),oe(this,ot,void 0,"f")),x(this,Ai,"f")&&(x(this,Ai,"f").call(this,!0),oe(this,Ai,void 0,"f"),oe(this,ki,void 0,"f")),!(r.isInit&&x(this,$i,"f"))&&(oe(this,$i,r,"f"),x(this,va,"m",eo).call(this,r))}),"f")}catch(t){throw console.error("Error setting up subscription:",t),x(this,ki,"f")&&(x(this,ki,"f").call(this,t),oe(this,Ai,void 0,"f"),oe(this,ki,void 0,"f")),t}let e=async()=>{if(!x(this,Gr,"f")){try{this.isSurrealDB?await x(this,xt,"f").perspectiveKeepAliveSurrealQuery(x(this,Ft,"f"),x(this,_t,"f")):await x(this,xt,"f").keepAliveQuery(x(this,Ft,"f"),x(this,_t,"f"))}catch(t){console.error("Error in keepalive:",t),console.log("Reinitializing subscription for query:",x(this,hr,"f"));try{await this.subscribe(),console.log("Subscription reinitialized")}catch(r){console.error("Error during resubscription from keepalive:",r);return}}x(this,Gr,"f")||oe(this,Zt,setTimeout(e,3e4),"f")}};oe(this,Zt,setTimeout(e,3e4),"f")}get id(){return x(this,_t,"f")}get initialized(){return x(this,ba,"f")}get result(){return x(this,$i,"f")}onResult(e){return x(this,Ri,"f").add(e),()=>x(this,Ri,"f").delete(e)}dispose(){oe(this,Gr,!0,"f"),clearTimeout(x(this,Zt,"f")),x(this,Jt,"f")&&x(this,Jt,"f").call(this),x(this,Ri,"f").clear(),x(this,ot,"f")&&(clearTimeout(x(this,ot,"f")),oe(this,ot,void 0,"f")),x(this,_t,"f")&&(this.isSurrealDB?x(this,xt,"f").perspectiveDisposeSurrealQuerySubscription(x(this,Ft,"f"),x(this,_t,"f")).catch(e=>console.error("Error disposing surreal query subscription:",e)):x(this,xt,"f").disposeQuerySubscription(x(this,Ft,"f"),x(this,_t,"f")).catch(e=>console.error("Error disposing query subscription:",e)))}};Ft=new WeakMap,_t=new WeakMap,xt=new WeakMap,Ri=new WeakMap,Zt=new WeakMap,Jt=new WeakMap,$i=new WeakMap,Gr=new WeakMap,ba=new WeakMap,Ai=new WeakMap,ki=new WeakMap,ot=new WeakMap,hr=new WeakMap,va=new WeakSet,eo=function i(e){for(let t of x(this,Ri,"f"))try{t(e)}catch(r){console.error("Error in query subscription callback:",r)}};var mr=class{constructor(e,t){re.set(this,void 0),ne.set(this,void 0),Ii.set(this,void 0),Ti.set(this,void 0),Ci.set(this,void 0),Zr.set(this,void 0),oe(this,Ii,[],"f"),oe(this,Ti,[],"f"),oe(this,Ci,[],"f"),oe(this,Zr,[],"f"),oe(this,re,e,"f"),oe(this,ne,t,"f"),this.uuid=x(this,re,"f").uuid,this.name=x(this,re,"f").name,this.owners=x(this,re,"f").owners,this.sharedUrl=x(this,re,"f").sharedUrl,this.neighbourhood=x(this,re,"f").neighbourhood,this.state=x(this,re,"f").state,x(this,ne,"f").addPerspectiveLinkAddedListener(x(this,re,"f").uuid,x(this,Ii,"f")),x(this,ne,"f").addPerspectiveLinkRemovedListener(x(this,re,"f").uuid,x(this,Ti,"f")),x(this,ne,"f").addPerspectiveLinkUpdatedListener(x(this,re,"f").uuid,x(this,Ci,"f")),x(this,ne,"f").addPerspectiveSyncStateChangeListener(x(this,re,"f").uuid,x(this,Zr,"f"))}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async executeAction(e,t,r,n){return await x(this,ne,"f").executeCommands(x(this,re,"f").uuid,JSON.stringify(e),t,JSON.stringify(r),n)}async get(e){return await x(this,ne,"f").queryLinks(x(this,re,"f").uuid,e)}async infer(e){return await x(this,ne,"f").queryProlog(x(this,re,"f").uuid,e)}async querySurrealDB(e){return await x(this,ne,"f").querySurrealDB(x(this,re,"f").uuid,e)}async add(e,t="shared",r){return await x(this,ne,"f").addLink(x(this,re,"f").uuid,e,t,r)}async addLinks(e,t="shared",r){return await x(this,ne,"f").addLinks(x(this,re,"f").uuid,e,t,r)}async removeLinks(e,t){return await x(this,ne,"f").removeLinks(x(this,re,"f").uuid,e,t)}async linkMutations(e,t="shared"){return await x(this,ne,"f").linkMutations(x(this,re,"f").uuid,e,t)}async addLinkExpression(e,t="shared",r){return await x(this,ne,"f").addLinkExpression(x(this,re,"f").uuid,e,t,r)}async update(e,t,r){return await x(this,ne,"f").updateLink(x(this,re,"f").uuid,e,t,r)}async remove(e,t){return await x(this,ne,"f").removeLink(x(this,re,"f").uuid,e,t)}async createBatch(){return await x(this,ne,"f").createBatch(x(this,re,"f").uuid)}async commitBatch(e){return await x(this,ne,"f").commitBatch(x(this,re,"f").uuid,e)}async getExpression(e){return await x(this,ne,"f").getExpression(e)}async createExpression(e,t){return await x(this,ne,"f").createExpression(e,t)}async addListener(e,t){e==="link-added"?x(this,Ii,"f").push(t):e==="link-removed"?x(this,Ti,"f").push(t):e==="link-updated"&&x(this,Ci,"f").push(t)}async addSyncStateChangeListener(e){x(this,Zr,"f").push(e)}async removeListener(e,t){if(e==="link-added"){let r=x(this,Ii,"f").indexOf(t);x(this,Ii,"f").splice(r,1)}else if(e==="link-removed"){let r=x(this,Ti,"f").indexOf(t);x(this,Ti,"f").splice(r,1)}else if(e==="link-updated"){let r=x(this,Ci,"f").indexOf(t);x(this,Ci,"f").splice(r,1)}}async snapshot(){return x(this,ne,"f").snapshotByUUID(x(this,re,"f").uuid)}async loadSnapshot(e){let t=JSON.parse(JSON.stringify(e));delete t.__typename,t.links.forEach(r=>{delete r.data.__typename});for(let r of t.links)await this.addLinkExpression(r)}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 r=new ae({source:e.source,predicate:e.predicate}),n=await this.get(r),a=[];for(let o of n)delete o.__typename,delete o.data.__typename,delete o.proof.__typename,a.push(o);let s=[e];await this.linkMutations({additions:s,removals:a},t)}async sdnaFlows(){return(await this.get(new ae({source:"ad4m://self",predicate:"ad4m://has_flow"}))).map(t=>{try{return le.fromUrl(t.data.target).get()}catch{return t.data.target}})}async availableFlows(e){let t=await this.sdnaFlows(),r=[];for(let n of t){let a=await this.getFlow(n);if(!!a)if(a.flowable==="any")r.push(n);else{let s=a.flowable,o=s.source||e;(await this.get(new ae({source:o,predicate:s.predicate,target:s.target}))).length>0&&r.push(n)}}return r}async startFlow(e,t){let r=await this.getFlow(e);if(!r)throw`Flow "${e}" not found`;if(r.startAction.length===0)throw`Flow "${e}" has no start action`;await this.executeAction(r.startAction,t,void 0)}async expressionsInFlowState(e,t){let r=await this.getFlow(e);if(!r)return[];let n=r.states.find(o=>o.value===t);if(!n)return[];let a=n.stateCheck;return(await this.get(new ae({predicate:a.predicate,target:a.target}))).map(o=>a.source?o.data.target:o.data.source)}async flowState(e,t){let r=await this.getFlow(e);if(!r)throw`Flow "${e}" not found`;for(let n of r.states){let a=n.stateCheck,s=a.source||t;if((await this.get(new ae({source:s,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 r=await this.getFlow(e);if(!r)return[];let n=null;for(let a of r.states){let s=a.stateCheck,o=s.source||t;if((await this.get(new ae({source:o,predicate:s.predicate,target:s.target}))).length>0){n=a.name;break}}return n?r.transitions.filter(a=>a.fromState===n).map(a=>a.actionName):[]}async runFlowAction(e,t,r){let n=await this.getFlow(e);if(!n)throw`Flow "${e}" not found`;let a=n.transitions.find(s=>s.actionName===r);if(!a)throw`Action "${r}" 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 r of e){let n=await this.get(new ae({source:"ad4m://self",predicate:r}));for(let a of n){let s=a.data.target,o=await this.get(new ae({source:s,predicate:"ad4m://sdna"}));for(let l of o){let c=le.fromUrl(l.data.target).get();typeof c=="string"&&t.push(c)}}}return t}async getSdnaForClass(e){let t=le.from(e);if((await this.get(new ae({source:"ad4m://self",target:t.toUrl(),predicate:"ad4m://has_subject_class"}))).length===0)return null;let n=await this.get(new ae({source:t.toUrl(),predicate:"ad4m://sdna"}));if(n.length===0)return null;let a=le.fromUrl(n[0].data.target).get();return typeof a=="string"?a:null}async addSdna(e,t,r,n){return x(this,ne,"f").addSdna(x(this,re,"f").uuid,e,t,r,n)}async addShacl(e,t){let r=t.toLinks(),n=le.fromUrl(`literal://string:shacl://${e}`),a=[...r.map(s=>new Je({source:s.source,predicate:s.predicate,target:s.target})),new Je({source:"ad4m://self",predicate:"ad4m://has_shacl",target:n.toUrl()}),new Je({source:n.toUrl(),predicate:"ad4m://shacl_shape_uri",target:t.nodeShapeUri})];await this.addLinks(a)}async getShacl(e){let t=le.fromUrl(`literal://string:shacl://${e}`),r=await this.get(new ae({source:t.toUrl(),predicate:"ad4m://shacl_shape_uri"}));if(r.length===0)return null;let n=r[0].data.target;ee(n);let a=await this.get(new ae({source:n,predicate:"sh://property"})),l=`SELECT in.uri AS source, predicate, out.uri AS target FROM link WHERE in.uri IN [${[n,...a.map(m=>m.data.target)].map(m=>`'${ee(m)}'`).join(", ")}]`,u=(await this.querySurrealDB(l)||[]).map(m=>({source:m.source,predicate:m.predicate,target:m.target}));return ii.fromLinks(u,n)}async getAllShacl(){let e=await this.get(new ae({source:"ad4m://self",predicate:"ad4m://has_shacl"})),t=[];for(let r of e){let n=r.data.target,s=le.fromUrl(n).get().replace("shacl://",""),o=await this.getShacl(s);o&&t.push({name:s,shape:o})}return t}async addFlow(e,t){let r=t.toLinks(),n=le.from(e).toUrl(),a=[...r.map(s=>new Je({source:s.source,predicate:s.predicate,target:s.target})),new Je({source:"ad4m://self",predicate:"ad4m://has_flow",target:n}),new Je({source:n,predicate:"ad4m://flow_uri",target:t.flowUri})];await this.addLinks(a)}async getFlow(e){let t=le.from(e).toUrl(),r=await this.get(new ae({source:t,predicate:"ad4m://flow_uri"}));if(r.length===0)return null;let n=r[0].data.target,a=ee(n),s=n.endsWith("Flow")?n.slice(0,-4)+".":n+".",o=ee(s),l=`SELECT in.uri AS source, predicate, out.uri AS target FROM link WHERE in.uri = '${a}' OR string::starts_with(in.uri, '${o}')`,u=(await this.querySurrealDB(l)||[]).map(m=>({source:m.source,predicate:m.predicate,target:m.target}));return Sr.fromLinks(u,n)}async subjectClasses(){try{let t=(await this.get(new ae({predicate:"rdf://type",target:"ad4m://SubjectClass"}))).map(r=>{let a=r.data.source.split("://");return a[a.length-1].split("/").pop()||""}).filter(r=>r.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,r,n){let a;if(typeof e=="string")a=e,await x(this,ne,"f").createSubject(x(this,re,"f").uuid,JSON.stringify({className:a,initialValues:r}),t,r?JSON.stringify(r):void 0,n);else{let s=e,o=s.className||s.constructor?.className||s.constructor?.prototype?.className||await this.findClassByProperties(s);if(!o)throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");await x(this,ne,"f").createSubject(x(this,re,"f").uuid,JSON.stringify({className:o,initialValues:r}),t,r?JSON.stringify(r):void 0,n)}return n?t:this.getSubjectProxy(t,e)}async getSubjectData(e,t){if(typeof e=="string")return JSON.parse(await x(this,ne,"f").getSubjectData(x(this,re,"f").uuid,JSON.stringify({className:e}),t));let r=e,n=r.className||r.constructor?.className||r.constructor?.prototype?.className||await this.findClassByProperties(r);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 x(this,ne,"f").getSubjectData(x(this,re,"f").uuid,JSON.stringify({className:n}),t))}async getActionsFromSHACL(e,t){let r=this.escapeRegExp(e),n=new RegExp(`[/:#]${r}Shape$`),a=await this.get(new ae({predicate:t}));for(let s of a)if(n.test(s.data.source)){let o="literal://string:";if(s.data.target.startsWith(o)){let l=s.data.target.slice(o.length),c=l;try{c=decodeURIComponent(l)}catch{}try{return JSON.parse(c)}catch(u){return console.warn(`Failed to parse SHACL actions JSON for ${e}:`,u),null}}}return null}async removeSubject(e,t,r){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,r)}async isSubjectInstance(e,t){let r=await this.stringOrTemplateObjectToSubjectClassName(t),n=await this.getSubjectClassMetadataFromSDNA(r);if(!n)return console.warn(`isSubjectInstance: No SHACL metadata found for class ${r}`),!1;if(n.requiredTriples.length===0){let s=`SELECT count() AS count FROM link WHERE in.uri = '${ee(e)}'`,l=(await this.querySurrealDB(s))[0]?.count??0;return(typeof l=="object"&&l?.Int!==void 0?l.Int:l)>0}for(let a of n.requiredTriples){let s=ee(e),o=ee(a.predicate),l;if(a.target){let y=ee(a.target);l=`SELECT count() AS count FROM link WHERE in.uri = '${s}' AND predicate = '${o}' AND out.uri = '${y}'`}else l=`SELECT count() AS count FROM link WHERE in.uri = '${s}' AND predicate = '${o}'`;let c=await this.querySurrealDB(l);if(!c||c.length===0)return!1;let u=c[0]?.count??0;if((typeof u=="object"&&u?.Int!==void 0?u.Int:u)===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 r=await this.stringOrTemplateObjectToSubjectClassName(t),n=new gn(this,e,r);return await n.init(),n}async getSubjectClassMetadataFromSDNA(e){try{let t=await this.getShacl(e);if(!t)return console.warn(`No SHACL metadata found for ${e}`),null;let r=[],n=[],a=new Map,s=new Map,o=new Set;for(let l of t.properties){if(!l.path||!l.name)continue;l.writable&&o.add(l.path),l.adder&&l.adder.length>0?s.set(l.name,{predicate:l.path}):a.set(l.name,{predicate:l.path,resolveLanguage:l.resolveLanguage})}if(t.constructor_actions){for(let l of t.constructor_actions)if(l.predicate){r.push(l.predicate);let c=o.has(l.predicate);l.target&&l.target!=="value"&&!c?n.push({predicate:l.predicate,target:l.target}):n.push({predicate:l.predicate})}}return{requiredPredicates:r,requiredTriples:n,properties:a,relations:s}}catch(t){return console.error(`Error getting SHACL metadata for ${e}:`,t),null}}generateSurrealInstanceQuery(e){return e.requiredTriples.length===0?"SELECT DISTINCT uri AS base FROM node WHERE count(->link) > 0":`SELECT uri AS base FROM node WHERE ${e.requiredTriples.map(r=>{let n=ee(r.predicate);if(r.target){let a=ee(r.target);return`count(->link[WHERE predicate = '${n}' AND out.uri = '${a}']) > 0`}else return`count(->link[WHERE predicate = '${n}']) > 0`}).join(" AND ")}`}async getPropertyValueViaSurreal(e,t,r){let n=await this.getSubjectClassMetadataFromSDNA(t);if(!n)return;let a=n.properties.get(r);if(!a)return;let s=ee(e),o=ee(a.predicate),l=`SELECT out.uri AS value FROM link WHERE in.uri = '${s}' AND predicate = '${o}' LIMIT 1`,c=await this.querySurrealDB(l);if(!c||c.length===0)return;let u=c[0].value;if(a.resolveLanguage&&u)try{let m=await this.getExpression(u);try{return JSON.parse(m.data)}catch{return m.data}}catch{return u}return u}async getRelationValuesViaSurreal(e,t,r){let n=await this.getSubjectClassMetadataFromSDNA(t);if(!n)return[];let a=n.relations.get(r);if(!a)return[];let s=ee(e),o=ee(a.predicate),l=`SELECT out.uri AS value, timestamp FROM link WHERE in.uri = '${s}' AND predicate = '${o}' ORDER BY timestamp ASC`,c=await this.querySurrealDB(l);if(!c||c.length===0)return[];let u=c.map(m=>m.value).filter(m=>m!==""&&m!=="");if(a.condition&&u.length>0)try{let m=[];for(let y of u){let d=a.condition.replace(/\$perspective/g,`'${this.uuid}'`).replace(/\$base/g,`'${e}'`).replace(/Target/g,`'${y.replace(/'/g,"\\'")}'`);d.trim().startsWith("WHERE")&&(d=`array::len(SELECT * FROM link ${d}) > 0`);let f=await this.querySurrealDB(`RETURN ${d}`);(f===!0||Array.isArray(f)&&f.length>0&&f[0]===!0)&&m.push(y)}u=m}catch(m){console.warn(`Failed to apply condition filter for ${r}:`,m)}if(a.instanceFilter)try{let m=await this.getSubjectClassMetadataFromSDNA(a.instanceFilter);return m?await this.batchCheckSubjectInstances(u,m):this.filterInstancesSequential(u,a.instanceFilter)}catch{return this.filterInstancesSequential(u,a.instanceFilter)}return u}async batchCheckSubjectInstances(e,t){if(e.length===0)return[];if(t.requiredTriples.length===0){let s=`SELECT in.uri AS uri FROM link WHERE in.uri IN [${e.map(l=>`'${ee(l)}'`).join(", ")}] GROUP BY in.uri HAVING count() > 0`;return(await this.querySurrealDB(s)).map(l=>l.uri)}let r=[];for(let a of t.requiredTriples){let s=e.map(u=>`'${ee(u)}'`).join(", "),o=ee(a.predicate),l;if(a.target){let u=ee(a.target);l=`SELECT in.uri AS uri FROM link WHERE in.uri IN [${s}] AND predicate = '${o}' AND out.uri = '${u}'`}else l=`SELECT in.uri AS uri FROM link WHERE in.uri IN [${s}] AND predicate = '${o}'`;let c=await this.querySurrealDB(l);r.push(new Set(c.map(u=>u.uri)))}return r.length===0?e:e.filter(a=>r.every(s=>s.has(a)))}async filterInstancesSequential(e,t){let r=[];for(let n of e)try{await this.isSubjectInstance(n,t)&&r.push(n)}catch{continue}return r}async getAllSubjectInstances(e){let t=[],r=typeof e=="function";typeof e=="string"?t=[e]:r?t=[e.name]:t=await this.subjectClassesByTemplate(e);let n=[];for(let a of t){let s=await this.getSubjectClassMetadataFromSDNA(a);if(s){let o=this.generateSurrealInstanceQuery(s),l=await this.querySurrealDB(o);for(let c of l||[])try{let u;r?(u=new e(this,c.base),await u.get()):(u=new gn(this,c.base,a),await u.init()),n.push(u)}catch{}}}return n}async getAllSubjectProxies(e){let t=[];typeof e=="string"?t=[e]:t=await this.subjectClassesByTemplate(e);let r=[];for(let n of t){let a=await this.getSubjectClassMetadataFromSDNA(n);if(a){let s=this.generateSurrealInstanceQuery(a),o=await this.querySurrealDB(s);for(let l of o||[])try{let c=new gn(this,l.base,n);await c.init(),r.push(c)}catch{}}}return r}async findClassByProperties(e){let t=[],r=[],a=Object.getPrototypeOf(e)?.constructor,s=a?Hi(a):{};Object.keys(s).length>0?t=Object.keys(s):t=Object.keys(e).filter(m=>!Array.isArray(e[m]));let o=a?Object.fromEntries(Object.entries($t(a)).filter(([,m])=>m.kind==="hasMany"||m.kind==="belongsToMany")):{};if(Object.keys(o).length>0?r=Object.keys(o).filter(m=>m!=="isSubjectInstance"):r=Object.keys(e).filter(m=>Array.isArray(e[m])&&m!=="isSubjectInstance"),t.length===0&&r.length===0)return null;let l=`SELECT
480
- in.uri AS shape_source,
481
- predicate,
482
- out.uri AS target
483
- FROM link
484
- WHERE predicate IN ['rdf://type', 'sh://property', 'sh://collection']`,c=await this.querySurrealDB(l);if(!c||c.length===0)return null;let u=new Map;for(let m of c)if(m.predicate==="rdf://type"&&m.target==="ad4m://SubjectClass"){let y=m.shape_source,d=y.indexOf("://");if(d<0)continue;let f=y.substring(d+3).split("/").pop();if(!f)continue;u.set(f,{shapeUri:y,properties:[],relations:[]})}for(let m of c)if(m.predicate==="sh://property"||m.predicate==="sh://collection"){for(let[y,d]of u)if(m.shape_source.endsWith(`${y}Shape`)){let f=m.target.lastIndexOf(".");if(f<0)continue;let g=m.target.substring(f+1);m.predicate==="sh://property"?d.properties.push(g):d.relations.push(g)}}for(let[m,y]of u){let d=t.every(g=>y.properties.includes(g)),f=r.every(g=>y.relations.includes(g));if(d&&f)return m}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){let t=e.className||e.prototype?.className||e.name;if(!e.generateSHACL)throw new Error(`Class ${e.name} must have generateSHACL(). Use @Model decorator.`);let{shape:r}=e.generateSHACL(),n=JSON.stringify(r.toJSON());await this.addSdna(t,"","subject_class",n)}getNeighbourhoodProxy(){return x(this,ne,"f").getNeighbourhoodProxy(x(this,re,"f").uuid)}get ai(){return x(this,ne,"f").aiClient}async subscribeInfer(e){let t=new Ma(this.uuid,e,x(this,ne,"f"));return await t.subscribe(),await t.initialized,t}async subscribeSurrealDB(e){let t=new Ma(this.uuid,e,x(this,ne,"f"));return t.isSurrealDB=!0,await t.subscribe(),await t.initialized,t}};re=new WeakMap,ne=new WeakMap,Ii=new WeakMap,Ti=new WeakMap,Ci=new WeakMap,Zr=new WeakMap;var Kt=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},q=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},G,Jr,Yr,Xr,wa,en,Sa,_a,Me=`
523
+ `}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 r=this.properties[t],n;if(r.name&&this.targetClass){let a=Tc(this.targetClass),s=Lc(this.targetClass);n=`${a}${s}.${r.name}`}else n=`_:propShape${t}`;e.push({source:this.nodeShapeUri,predicate:"sh://property",target:n}),e.push({source:n,predicate:"sh://path",target:r.path}),r.datatype&&e.push({source:n,predicate:"sh://datatype",target:r.datatype}),r.nodeKind&&e.push({source:n,predicate:"sh://nodeKind",target:`sh://${r.nodeKind}`}),r.minCount!==void 0&&e.push({source:n,predicate:"sh://minCount",target:`literal:${r.minCount}^^xsd:integer`}),r.maxCount!==void 0&&e.push({source:n,predicate:"sh://maxCount",target:`literal:${r.maxCount}^^xsd:integer`}),r.pattern&&e.push({source:n,predicate:"sh://pattern",target:`literal:${r.pattern}`}),r.minInclusive!==void 0&&e.push({source:n,predicate:"sh://minInclusive",target:`literal:${r.minInclusive}`}),r.maxInclusive!==void 0&&e.push({source:n,predicate:"sh://maxInclusive",target:`literal:${r.maxInclusive}`}),r.hasValue&&e.push({source:n,predicate:"sh://hasValue",target:`literal:${r.hasValue}`}),r.local!==void 0&&e.push({source:n,predicate:"ad4m://local",target:`literal:${r.local}`}),r.writable!==void 0&&e.push({source:n,predicate:"ad4m://writable",target:`literal:${r.writable}`}),r.resolveLanguage&&e.push({source:n,predicate:"ad4m://resolveLanguage",target:`literal:string:${r.resolveLanguage}`}),r.setter&&r.setter.length>0&&e.push({source:n,predicate:"ad4m://setter",target:`literal:string:${JSON.stringify(r.setter)}`}),r.adder&&r.adder.length>0&&e.push({source:n,predicate:"ad4m://adder",target:`literal:string:${JSON.stringify(r.adder)}`}),r.remover&&r.remover.length>0&&e.push({source:n,predicate:"ad4m://remover",target:`literal:string:${JSON.stringify(r.remover)}`}),r.getter&&e.push({source:n,predicate:"ad4m://getter",target:`literal:string:${r.getter}`}),r.conformanceConditions&&r.conformanceConditions.length>0&&e.push({source:n,predicate:"ad4m://conformanceConditions",target:`literal:string:${JSON.stringify(r.conformanceConditions)}`}),r.class&&e.push({source:n,predicate:"sh://class",target:r.class})}return e}static fromLinks(e,t){let r=e.find(c=>c.source===t&&c.predicate==="sh://targetClass"),n=new ai(t,r?.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 s=e.find(c=>c.source===t&&c.predicate==="ad4m://destructor");if(s)try{let c=s.target.replace(/^literal:\/\/string:|^literal:string:/,"");n.destructor_actions=JSON.parse(c)}catch{}let o=e.filter(c=>c.source===t&&c.predicate==="sh://property");for(let c of o){let l=c.target,u=e.find(I=>I.source===l&&I.predicate==="sh://path");if(!u)continue;let m;if(!l.startsWith("_:")){let I=l.lastIndexOf(".");I!==-1&&(m=l.substring(I+1))}let y={name:m,path:u.target},d=e.find(I=>I.source===l&&I.predicate==="sh://datatype");d&&(y.datatype=d.target);let f=e.find(I=>I.source===l&&I.predicate==="sh://nodeKind");f&&(y.nodeKind=f.target.replace("sh://",""));let h=e.find(I=>I.source===l&&I.predicate==="sh://minCount");if(h){let I=h.target.replace(/^literal:\/\/|^literal:/,"").replace(/\^\^.*$/,"");I.startsWith("number:")&&(I=I.substring(7)),y.minCount=parseInt(I)}let S=e.find(I=>I.source===l&&I.predicate==="sh://maxCount");if(S){let I=S.target.replace(/^literal:\/\/|^literal:/,"").replace(/\^\^.*$/,"");I.startsWith("number:")&&(I=I.substring(7)),y.maxCount=parseInt(I)}let x=e.find(I=>I.source===l&&I.predicate==="sh://pattern");x&&(y.pattern=x.target.replace(/^literal:\/\/|^literal:/,""));let T=e.find(I=>I.source===l&&I.predicate==="sh://minInclusive");if(T){let I=T.target.replace(/^literal:\/\/|^literal:/,"");I.startsWith("number:")&&(I=I.substring(7)),y.minInclusive=parseFloat(I)}let k=e.find(I=>I.source===l&&I.predicate==="sh://maxInclusive");if(k){let I=k.target.replace(/^literal:\/\/|^literal:/,"");I.startsWith("number:")&&(I=I.substring(7)),y.maxInclusive=parseFloat(I)}let _=e.find(I=>I.source===l&&I.predicate==="sh://hasValue");_&&(y.hasValue=_.target.replace(/^literal:\/\/|^literal:/,""));let L=e.find(I=>I.source===l&&I.predicate==="ad4m://local");if(L){let I=L.target.replace(/^literal:\/\/|^literal:/,"");I.startsWith("boolean:")&&(I=I.substring(8)),y.local=I==="true"}let D=e.find(I=>I.source===l&&I.predicate==="ad4m://writable");if(D){let I=D.target.replace(/^literal:\/\/|^literal:/,"");I.startsWith("boolean:")&&(I=I.substring(8)),y.writable=I==="true"}let P=e.find(I=>I.source===l&&I.predicate==="ad4m://resolveLanguage");P&&(y.resolveLanguage=P.target.replace(/^literal:\/\/string:|^literal:string:/,""));let W=e.find(I=>I.source===l&&I.predicate==="ad4m://setter");if(W)try{let I=W.target.replace(/^literal:\/\/string:|^literal:string:/,"");y.setter=JSON.parse(I)}catch{}let K=e.find(I=>I.source===l&&I.predicate==="ad4m://adder");if(K)try{let I=K.target.replace(/^literal:\/\/string:|^literal:string:/,"");y.adder=JSON.parse(I)}catch{}let R=e.find(I=>I.source===l&&I.predicate==="ad4m://remover");if(R)try{let I=R.target.replace(/^literal:\/\/string:|^literal:string:/,"");y.remover=JSON.parse(I)}catch{}let G=e.find(I=>I.source===l&&I.predicate==="ad4m://getter");G&&(y.getter=G.target.replace(/^literal:\/\/string:|^literal:string:/,""));let We=e.find(I=>I.source===l&&I.predicate==="ad4m://conformanceConditions");if(We)try{let I=We.target.replace(/^literal:\/\/string:|^literal:string:/,"");y.conformanceConditions=JSON.parse(I)}catch{}let jr=e.find(I=>I.source===l&&I.predicate==="sh://class");jr&&(y.class=jr.target),n.addProperty(y)}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 ai(e.node_shape_uri,e.target_class):new ai(e.target_class);for(let r of e.properties||[])t.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});if(e.constructor_actions&&(t.constructor_actions=e.constructor_actions),e.destructor_actions&&(t.destructor_actions=e.destructor_actions),e.parent_shapes)for(let r of e.parent_shapes)t.addParentShape(r);return t}};function Pc(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 su(i){let e=i.can.includes("*")?["READ","WRITE","UPDATE"]:i.can,t=i.with.domain==="*"?"":i.with.domain,r=i.with.pointers.includes("*")?["all AD4M data"]:i.with.pointers;return`${Pc(e)} your ${t} actions, with access to ${Pc(r)}`}function Mt(i){return i.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function bp(i){return typeof i=="string"?`'${i.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}'`:typeof i=="number"||typeof i=="boolean"?String(i):Array.isArray(i)?`[${i.map(e=>bp(e)).join(", ")}]`:String(i)}function wp(i,e,t){let r=Mt(i),n=!t?.resolveLanguage||t.resolveLanguage==="literal";function a(s){return typeof s=="string"?n?`<literal:string:${Mt(s)}>`:`<${Mt(s)}>`:`<literal:string:${s}>`}if(Array.isArray(e)){let s=e.map(a).join(", ");return`FILTER EXISTS { ?target <${r}> ?_val . FILTER(?_val IN (${s})) }`}else if(typeof e=="object"&&e!==null){let s=e,o=[];if(s.not!==void 0)if(Array.isArray(s.not)){let l=s.not.map(u=>a(u)).join(", ");o.push(`FILTER NOT EXISTS { ?target <${r}> ?_nval . FILTER(?_nval IN (${l})) }`)}else o.push(`FILTER NOT EXISTS { ?target <${r}> ${a(s.not)} }`);return(s.gt!==void 0||s.gte!==void 0||s.lt!==void 0||s.lte!==void 0||s.between!==void 0||s.contains!==void 0)&&o.push(`FILTER EXISTS { ?target <${r}> ?_cmp }`),o.join(" ")}else return`?target <${r}> ${a(e)} .`}function ou(i,e){let t=[];for(let[r,n]of Object.entries(i)){if(["id","author","timestamp"].includes(r))continue;let a,s;if(e){let c=e.properties[r];c?(a=c.predicate,s=c.resolveLanguage):a=r}else a=r;let o=wp(a,n,{resolveLanguage:s});o&&t.push(o)}return t}function Sp(i,e,t,r,n){let a=e.prototype,s="ad4m://",o=Object.fromEntries(Object.entries(r).filter(([,f])=>f.kind==="hasMany"||f.kind==="belongsToMany"));if(Object.keys(t).length>0){let f=t[Object.keys(t)[0]];if(f.through){let h=f.through.match(/^([^:]+:\/\/)/);h&&(s=h[1])}}else if(Object.keys(o).length>0){let f=o[Object.keys(o)[0]];if(f.predicate){let h=f.predicate.match(/^([^:]+:\/\/)/);h&&(s=h[1])}}let c=`${s}${i}Shape`,l=`${s}${i}`,u=new ai(c,l),m=Object.getPrototypeOf(e);if(m&&typeof m.generateSHACL=="function"){let f=m.generateSHACL();f?.shape?.nodeShapeUri&&u.addParentShape(f.shape.nodeShapeUri)}let y=[];a.subjectConstructor&&a.subjectConstructor.length&&(y=y.concat(a.subjectConstructor));let d=[];for(let f in t){let h=t[f];if(!h.through)continue;let S={name:f,path:h.through};if(h.resolveLanguage==="literal")S.datatype="xsd://string";else if(h.initial){let T=typeof a[f];T==="number"?S.datatype="xsd://integer":T==="boolean"?S.datatype="xsd://boolean":T==="string"&&(S.datatype="xsd://string")}h.required&&(S.minCount=1),S.maxCount=1,h.flag&&h.initial&&(S.hasValue=h.initial),h.local!==void 0&&(S.local=h.local),h.writable!==void 0&&(S.writable=h.writable),h.resolveLanguage&&(S.resolveLanguage=h.resolveLanguage),h.prologSetter?console.warn(`[SHACL Generation] Custom Prolog setter for property '${f}' 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.`):h.writable&&h.through&&typeof a[os(f)]=="function"&&(S.setter=[{action:"setSingleTarget",source:"this",predicate:h.through,target:"value",...h.local&&{local:!0}}]);let x=h.initial??(h.required&&h.writable&&!h.flag&&h.through?"literal:string:":void 0);x&&(y.push({action:"addLink",source:"this",predicate:h.through,target:x}),d.push({action:"removeLink",source:"this",predicate:h.through,target:"*"})),u.addProperty(S)}for(let f in o){let h=o[f];if(!h.predicate)continue;let S={name:f,path:h.predicate};if(S.nodeKind="IRI",h.local!==void 0&&(S.local=h.local),S.adder=[{action:"addLink",source:"this",predicate:h.predicate,target:"value",...h.local&&{local:!0}}],S.remover=[{action:"removeLink",source:"this",predicate:h.predicate,target:"value",...h.local&&{local:!0}}],h.getter)S.getter=h.getter;else if(h.where)try{let x=h.target?.(),T=x?x.getModelMetadata?.()??null:null,k=ou(h.where,T);if(k.length>0){let _=Mt(h.predicate);S.getter=`SELECT ?target WHERE { <Base> <${_}> ?target . ${k.join(" ")} }`}}catch{}else if(h.target&&h.filter!==!1){let x=h.target,T=h.predicate,k=!1,_,L,D=()=>{if(!k){k=!0;try{let P=x(),W=n(T,P);W&&(_=W.getter,L=W.conformanceConditions)}catch{}}};Object.defineProperty(S,"getter",{get(){return D(),_},set(P){k=!0,_=P},enumerable:!0,configurable:!0}),Object.defineProperty(S,"conformanceConditions",{get(){return D(),L},set(P){k=!0,L=P},enumerable:!0,configurable:!0})}if(h.target)try{let T=h.target().generateSHACL?.();T?.shape?.nodeShapeUri&&(S.class=T.shape.nodeShapeUri)}catch{}u.addProperty(S)}return u.setConstructorActions(y),u.setDestructorActions(d),{shape:u,name:i}}var Et=new WeakMap,Ue=new WeakMap,Rc=new WeakMap,Nc=new WeakMap,Oc=new WeakMap;function Ki(i){let e=Rc.get(i);if(e)return e;let t={},r=[],n=i;for(;n&&n!==Object;)r.unshift(n),n=Object.getPrototypeOf(n);for(let a of r){let s=Et.get(a);s&&Object.assign(t,s)}return Rc.set(i,t),t}function St(i){let e=Nc.get(i);if(e)return e;let t={},r=[],n=i;for(;n&&n!==Object;)r.unshift(n),n=Object.getPrototypeOf(n);for(let a of r){let s=Ue.get(a);s&&Object.assign(t,s)}return Nc.set(i,t),t}function _p(i,e){let t=Oc.get(i);if(t)return t;let r=e();return Oc.set(i,r),r}function xp(i,e,t){Et.has(i)||Et.set(i,{}),Et.get(i)[e]=t}function $p(i,e,t){Ue.has(i)||Ue.set(i,{}),Ue.get(i)[e]=t}function cu(i,e){try{let t=Ki(e),r=[],n=[],a=0;for(let[o,c]of Object.entries(t))c.flag&&c.initial&&c.through&&(r.push({type:"flag",predicate:c.through,value:c.initial}),n.push(`?target <${Mt(c.through)}> <${Mt(c.initial)}> .`));for(let[o,c]of Object.entries(t))c.required&&!c.flag&&!c.getter&&c.through&&(r.push({type:"required",predicate:c.through}),n.push(`?target <${Mt(c.through)}> ?_v${a++} .`));return r.length===0?void 0:{getter:`SELECT ?target WHERE { <Base> <${Mt(i)}> ?target . ${n.join(" ")} }`,conformanceConditions:r}}catch{return}}function cs(i){return function(e,t){let r=i.readOnly?!1:!!i.through;if(i.required&&!i.initial)throw new Error("SubjectProperty requires an 'initial' option if 'required' is true");if(!i.through&&!i.prologGetter&&!i.getter)throw new Error("SubjectProperty requires either 'through' or 'prologGetter' or 'getter' option");let n=e.constructor;if(Et.has(n)||Et.set(n,{}),Et.get(n)[t]={...i,writable:r},r){let a=t;e[`set${He(a)}`]=()=>{}}Object.defineProperty(e,t,{configurable:!0,writable:!0})}}function G0(i){return cs({...i,required:i.required??!1,readOnly:i.readOnly??!1})}function Z0(i){return function(e,t){if(!i.through&&!i.value)throw new Error("SubjectFlag requires a 'through' and 'value' option");if(!i.through)throw new Error("SubjectFlag requires a 'through' option");if(!i.value)throw new Error("SubjectFlag requires a 'value' option");let r={through:i.through,required:!0,initial:i.value,flag:!0,readOnly:!0,writable:!1},n=e.constructor;Et.has(n)||Et.set(n,{}),Et.get(n)[t]=r,e[t]=i.value,Object.defineProperty(e,t,{configurable:!0,writable:!0})}}function Ep(i){return function(e){e.prototype.className=i.name,e.className=i.name,e.generateSDNA=function(){return vp(i.name,e.prototype,Ki(e),St(e))},e.generateSHACL=function(){return _p(e,()=>Sp(i.name,e,Ki(e),St(e),cu))},Object.defineProperty(e,"type",{configurable:!0})}}function Ap(i){let e=i.required??!1;return cs({...i,required:e,readOnly:i.readOnly??!1,resolveLanguage:i.resolveLanguage??"literal",initial:i.initial??(e?"literal:string:uninitialized":void 0)})}function J0(i){return Ap({...i,readOnly:!0})}function ls(i,e){let t=typeof i=="function"?{...e||{},target:i}:i;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 X0(i,e){let t=ls(i,e);return function(r,n){let a=r.constructor;Ue.has(a)||Ue.set(a,{});let s=Ue.get(a);s[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 o=n;t.through&&(r[`add${He(o)}`]=async function(c,l){return this.addRelationValue(o,c,l)},r[`remove${He(o)}`]=async function(c,l){return this.removeRelationValue(o,c,l)},r[`set${He(o)}`]=async function(c,l){return this.setRelationValues(o,c,l)}),Object.defineProperty(r,o,{configurable:!0,writable:!0})}}function Y0(i,e){let t=ls(i,e);return function(r,n){let a=r.constructor;Ue.has(a)||Ue.set(a,{});let s=Ue.get(a);s[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 o=n;t.through?(cs({through:t.through,readOnly:!1,local:t.local})(r,n),r[`add${He(o)}`]=async function(c){return this.addRelationValue(o,c)},r[`remove${He(o)}`]=async function(c){return this.removeRelationValue(o,c)},r[`set${He(o)}`]=async function(c){return this.setRelationValues(o,c)}):Object.defineProperty(r,o,{configurable:!0,writable:!0})}}function ev(i,e){let t=ls(i,e);return function(r,n){let a=r.constructor;Ue.has(a)||Ue.set(a,{});let s=Ue.get(a);s[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?cs({through:t.through,readOnly:!0,local:t.local})(r,n):Object.defineProperty(r,n,{configurable:!0,writable:!0})}}function tv(i,e){let t=ls(i,e);return function(r,n){let a=r.constructor;Ue.has(a)||Ue.set(a,{});let s=Ue.get(a);s[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(r,n,{configurable:!0,writable:!0})}}var Ft=new Map,kp=200;function lu(i,e){return`${i}:${e}`}function Ip(i,e){let t=lu(i,e),r=Ft.get(t);if(!!r){if(Date.now()>r.expiry){Ft.delete(t);return}return r.result}}function Tp(i,e,t,r=kp){let n=Date.now();for(let[s,o]of Ft)n>o.expiry&&Ft.delete(s);let a=lu(i,e);Ft.set(a,{result:t,expiry:n+r})}function Qt(i){let e=i+":";for(let[t]of Ft)t.startsWith(e)&&Ft.delete(t)}function iv(){Ft.clear()}function rv(){return Ft.size}var kr=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:le.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 r of this._states){let n=this.stateUri(r.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:le.from(r.name).toUrl()}),e.push({source:n,predicate:"ad4m://stateValue",target:le.from(r.value).toUrl()}),e.push({source:n,predicate:"ad4m://stateCheck",target:`literal:string:${encodeURIComponent(JSON.stringify(r.stateCheck))}`})}for(let r of this._transitions){let n=this.transitionUri(r.fromState,r.toState),a=this.stateUri(r.fromState),s=this.stateUri(r.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:le.from(r.actionName).toUrl()}),e.push({source:n,predicate:"ad4m://fromState",target:a}),e.push({source:n,predicate:"ad4m://toState",target:s}),e.push({source:n,predicate:"ad4m://transitionActions",target:`literal:string:${encodeURIComponent(JSON.stringify(r.actions))}`})}return e}static fromLinks(e,t){let r="Flow";if(!t.endsWith(r))throw new Error(`Invalid flow URI: ${t} (must end with 'Flow')`);let n=t.slice(0,-r.length),a=Math.max(n.lastIndexOf("/"),n.lastIndexOf(":")),s=n.slice(0,a+1),o=n.slice(a+1),c=new kr(o,s),l=e.find(f=>f.source===t&&f.predicate==="ad4m://flowable");if(l)if(l.target==="ad4m://any")c.flowable="any";else try{let f=l.target.replace(/^literal:\/\/string:|^literal:string:/,"");c.flowable=JSON.parse(decodeURIComponent(f))}catch{c.flowable="any"}let u=e.find(f=>f.source===t&&f.predicate==="ad4m://startAction");if(u)try{let f=u.target.replace(/^literal:\/\/string:|^literal:string:/,"");c.startAction=JSON.parse(decodeURIComponent(f))}catch{}let m=e.filter(f=>f.source===t&&f.predicate==="ad4m://hasState"),y=new Map;for(let f of m){let h=f.target,S=e.find(D=>D.source===h&&D.predicate==="ad4m://stateName"),x=S?le.fromUrl(S.target).get():"";y.set(h,x);let T=e.find(D=>D.source===h&&D.predicate==="ad4m://stateValue"),k=T?le.fromUrl(T.target).get():0,_=e.find(D=>D.source===h&&D.predicate==="ad4m://stateCheck"),L={predicate:"",target:""};if(_)try{let D=_.target.replace(/^literal:\/\/string:|^literal:string:/,"");L=JSON.parse(decodeURIComponent(D))}catch{}c.addState({name:x,value:k,stateCheck:L})}let d=e.filter(f=>f.source===t&&f.predicate==="ad4m://hasTransition");for(let f of d){let h=f.target,S=e.find(R=>R.source===h&&R.predicate==="ad4m://actionName"),x=S?le.fromUrl(S.target).get():"",k=e.find(R=>R.source===h&&R.predicate==="ad4m://fromState")?.target||"",_=y.get(k)||"",D=e.find(R=>R.source===h&&R.predicate==="ad4m://toState")?.target||"",P=y.get(D)||"",W=e.find(R=>R.source===h&&R.predicate==="ad4m://transitionActions"),K=[];if(W)try{let R=W.target.replace(/^literal:\/\/string:|^literal:string:/,"");K=JSON.parse(decodeURIComponent(R))}catch{}c.addTransition({actionName:x,fromState:_,toState:P,actions:K})}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 kr(e.name,e.namespace);t.flowable=e.flowable||"any",t.startAction=e.startAction||[];for(let r of e.states||[])t.addState(r);for(let r of e.transitions||[])t.addTransition(r);return t}},se=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},$=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},ka,wr,Xt,Ii,Di,Yt,ei,Ti,Yr,Ia,Ci,Li,ct,en,uo,X,ne,Pi,Ri,Ni,tn,rn,Ka=class{constructor(e,t,r){ka.add(this),wr.set(this,void 0),Xt.set(this,void 0),Ii.set(this,void 0),Di.set(this,void 0),Yt.set(this,void 0),ei.set(this,void 0),Ti.set(this,void 0),Yr.set(this,!1),Ia.set(this,void 0),Ci.set(this,void 0),Li.set(this,void 0),ct.set(this,void 0),en.set(this,void 0),se(this,wr,e,"f"),se(this,en,t,"f"),se(this,Ii,r,"f"),se(this,Di,new Set,"f"),se(this,Ti,null,"f"),se(this,Ia,new Promise((n,a)=>{se(this,Ci,n,"f"),se(this,Li,a,"f")}),"f")}async subscribe(){$(this,ei,"f")&&($(this,ei,"f").call(this),se(this,ei,void 0,"f")),$(this,ct,"f")&&(clearTimeout($(this,ct,"f")),se(this,ct,void 0,"f")),$(this,Yt,"f")&&(clearTimeout($(this,Yt,"f")),se(this,Yt,void 0,"f"));try{let t;t=await $(this,Ii,"f").subscribeQuery($(this,wr,"f"),$(this,en,"f")),se(this,Xt,t.subscriptionId,"f"),t.result?(se(this,Ti,t.result,"f"),$(this,ka,"m",uo).call(this,t.result)):console.warn("\u26A0\uFE0F No initial result returned from subscribeQuery!"),se(this,ct,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"),se(this,ei,$(this,Ii,"f").subscribeToQueryUpdates($(this,Xt,"f"),r=>{$(this,ct,"f")&&(clearTimeout($(this,ct,"f")),se(this,ct,void 0,"f")),$(this,Ci,"f")&&($(this,Ci,"f").call(this,!0),se(this,Ci,void 0,"f"),se(this,Li,void 0,"f")),!(r.isInit&&$(this,Ti,"f"))&&(se(this,Ti,r,"f"),$(this,ka,"m",uo).call(this,r))}),"f")}catch(t){throw console.error("Error setting up subscription:",t),$(this,Li,"f")&&($(this,Li,"f").call(this,t),se(this,Ci,void 0,"f"),se(this,Li,void 0,"f")),t}let e=async()=>{if(!$(this,Yr,"f")){try{await $(this,Ii,"f").keepAliveQuery($(this,wr,"f"),$(this,Xt,"f"))}catch(t){console.error("Error in keepalive:",t),console.log("Reinitializing subscription for query:",$(this,en,"f"));try{await this.subscribe(),console.log("Subscription reinitialized")}catch(r){console.error("Error during resubscription from keepalive:",r);return}}$(this,Yr,"f")||se(this,Yt,setTimeout(e,3e4),"f")}};se(this,Yt,setTimeout(e,3e4),"f")}get id(){return $(this,Xt,"f")}get initialized(){return $(this,Ia,"f")}get result(){return $(this,Ti,"f")}onResult(e){return $(this,Di,"f").add(e),()=>$(this,Di,"f").delete(e)}dispose(){se(this,Yr,!0,"f"),clearTimeout($(this,Yt,"f")),$(this,ei,"f")&&$(this,ei,"f").call(this),$(this,Di,"f").clear(),$(this,ct,"f")&&(clearTimeout($(this,ct,"f")),se(this,ct,void 0,"f")),$(this,Xt,"f")&&$(this,Ii,"f").disposeQuerySubscription($(this,wr,"f"),$(this,Xt,"f")).catch(e=>console.error("Error disposing query subscription:",e))}};wr=new WeakMap,Xt=new WeakMap,Ii=new WeakMap,Di=new WeakMap,Yt=new WeakMap,ei=new WeakMap,Ti=new WeakMap,Yr=new WeakMap,Ia=new WeakMap,Ci=new WeakMap,Li=new WeakMap,ct=new WeakMap,en=new WeakMap,ka=new WeakSet,uo=function i(e){for(let t of $(this,Di,"f"))try{t(e)}catch(r){console.error("Error in query subscription callback:",r)}};var _r=class{constructor(e,t){X.set(this,void 0),ne.set(this,void 0),Pi.set(this,void 0),Ri.set(this,void 0),Ni.set(this,void 0),tn.set(this,void 0),rn.set(this,new Set),se(this,Pi,[],"f"),se(this,Ri,[],"f"),se(this,Ni,[],"f"),se(this,tn,[],"f"),se(this,X,e,"f"),se(this,ne,t,"f"),this.uuid=$(this,X,"f").uuid,this.name=$(this,X,"f").name,this.owners=$(this,X,"f").owners,this.sharedUrl=$(this,X,"f").sharedUrl,this.neighbourhood=$(this,X,"f").neighbourhood,this.state=$(this,X,"f").state,$(this,ne,"f").addPerspectiveLinkAddedListener($(this,X,"f").uuid,$(this,Pi,"f")),$(this,ne,"f").addPerspectiveLinkRemovedListener($(this,X,"f").uuid,$(this,Ri,"f")),$(this,ne,"f").addPerspectiveLinkUpdatedListener($(this,X,"f").uuid,$(this,Ni,"f")),$(this,ne,"f").addPerspectiveSyncStateChangeListener($(this,X,"f").uuid,$(this,tn,"f"))}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}async executeAction(e,t,r,n){let a=await $(this,ne,"f").executeCommands($(this,X,"f").uuid,JSON.stringify(e),t,JSON.stringify(r),n);return Qt($(this,X,"f").uuid),a}async get(e){return await $(this,ne,"f").queryLinks($(this,X,"f").uuid,e)}async infer(e){return await $(this,ne,"f").queryProlog($(this,X,"f").uuid,e)}async querySparql(e){let t=Ip($(this,X,"f").uuid,e);if(t!==void 0)return t;let r=await $(this,ne,"f").querySparql($(this,X,"f").uuid,e);return Tp($(this,X,"f").uuid,e,r),r}async add(e,t="shared",r){let n=await $(this,ne,"f").addLink($(this,X,"f").uuid,e,t,r);return Qt($(this,X,"f").uuid),n}async addLinks(e,t="shared",r){let n=await $(this,ne,"f").addLinks($(this,X,"f").uuid,e,t,r);return Qt($(this,X,"f").uuid),n}async removeLinks(e,t){let r=await $(this,ne,"f").removeLinks($(this,X,"f").uuid,e,t);return Qt($(this,X,"f").uuid),r}async linkMutations(e,t="shared"){let r=await $(this,ne,"f").linkMutations($(this,X,"f").uuid,e,t);return Qt($(this,X,"f").uuid),r}async addLinkExpression(e,t="shared",r){return await $(this,ne,"f").addLinkExpression($(this,X,"f").uuid,e,t,r)}async update(e,t,r){let n=await $(this,ne,"f").updateLink($(this,X,"f").uuid,e,t,r);return Qt($(this,X,"f").uuid),n}async remove(e,t){let r=await $(this,ne,"f").removeLink($(this,X,"f").uuid,e,t);return Qt($(this,X,"f").uuid),r}async createBatch(){return await $(this,ne,"f").createBatch($(this,X,"f").uuid)}async commitBatch(e){let t=await $(this,ne,"f").commitBatch($(this,X,"f").uuid,e);return Qt($(this,X,"f").uuid),t}async getExpression(e){return await $(this,ne,"f").getExpression(e)}async createExpression(e,t){return await $(this,ne,"f").createExpression(e,t)}async addListener(e,t){e==="link-added"?$(this,Pi,"f").push(t):e==="link-removed"?$(this,Ri,"f").push(t):e==="link-updated"&&$(this,Ni,"f").push(t)}async addSyncStateChangeListener(e){$(this,tn,"f").push(e)}async removeListener(e,t){if(e==="link-added"){let r=$(this,Pi,"f").indexOf(t);$(this,Pi,"f").splice(r,1)}else if(e==="link-removed"){let r=$(this,Ri,"f").indexOf(t);$(this,Ri,"f").splice(r,1)}else if(e==="link-updated"){let r=$(this,Ni,"f").indexOf(t);$(this,Ni,"f").splice(r,1)}}async snapshot(){return $(this,ne,"f").snapshotByUUID($(this,X,"f").uuid)}async loadSnapshot(e){let t=JSON.parse(JSON.stringify(e));delete t.__typename,t.links.forEach(r=>{delete r.data.__typename});for(let r of t.links)await this.addLinkExpression(r)}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 r=new B({source:e.source,predicate:e.predicate}),n=await this.get(r),a=[];for(let o of n)delete o.__typename,delete o.data.__typename,delete o.proof.__typename,a.push(o);let s=[e];await this.linkMutations({additions:s,removals:a},t)}async sdnaFlows(){return(await this.get(new B({source:"ad4m://self",predicate:"ad4m://has_flow"}))).map(t=>{try{return le.fromUrl(t.data.target).get()}catch{return t.data.target}})}async availableFlows(e){let t=await this.sdnaFlows(),r=[];for(let n of t){let a=await this.getFlow(n);if(!!a)if(a.flowable==="any")r.push(n);else{let s=a.flowable,o=s.source||e;(await this.get(new B({source:o,predicate:s.predicate,target:s.target}))).length>0&&r.push(n)}}return r}async startFlow(e,t){let r=await this.getFlow(e);if(!r)throw`Flow "${e}" not found`;if(r.startAction.length===0)throw`Flow "${e}" has no start action`;await this.executeAction(r.startAction,t,void 0)}async expressionsInFlowState(e,t){let r=await this.getFlow(e);if(!r)return[];let n=r.states.find(o=>o.value===t);if(!n)return[];let a=n.stateCheck;return(await this.get(new B({predicate:a.predicate,target:a.target}))).map(o=>a.source?o.data.target:o.data.source)}async flowState(e,t){let r=await this.getFlow(e);if(!r)throw`Flow "${e}" not found`;for(let n of r.states){let a=n.stateCheck,s=a.source||t;if((await this.get(new B({source:s,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 r=await this.getFlow(e);if(!r)return[];let n=null;for(let a of r.states){let s=a.stateCheck,o=s.source||t;if((await this.get(new B({source:o,predicate:s.predicate,target:s.target}))).length>0){n=a.name;break}}return n?r.transitions.filter(a=>a.fromState===n).map(a=>a.actionName):[]}async runFlowAction(e,t,r){let n=await this.getFlow(e);if(!n)throw`Flow "${e}" not found`;let a=n.transitions.find(s=>s.actionName===r);if(!a)throw`Action "${r}" 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 r of e){let n=await this.get(new B({source:"ad4m://self",predicate:r}));for(let a of n){let s=a.data.target,o=await this.get(new B({source:s,predicate:"ad4m://sdna"}));for(let c of o){let l=le.fromUrl(c.data.target).get();typeof l=="string"&&t.push(l)}}}return t}async getSdnaForClass(e){let t=le.from(e);if((await this.get(new B({source:"ad4m://self",target:t.toUrl(),predicate:"ad4m://has_subject_class"}))).length===0)return null;let n=await this.get(new B({source:t.toUrl(),predicate:"ad4m://sdna"}));if(n.length===0)return null;let a=le.fromUrl(n[0].data.target).get();return typeof a=="string"?a:null}async addSdna(e,t,r,n){return $(this,ne,"f").addSdna($(this,X,"f").uuid,e,t,r,n)}async addSubjectClass(e,t){return this.addSdna(e,"","subject_class",t)}async addShacl(e,t){let r=t.toLinks(),n=le.fromUrl(`literal:string:shacl://${e}`),a=[...r.map(s=>new Xe({source:s.source,predicate:s.predicate,target:s.target})),new Xe({source:"ad4m://self",predicate:"ad4m://has_shacl",target:n.toUrl()}),new Xe({source:n.toUrl(),predicate:"ad4m://shacl_shape_uri",target:t.nodeShapeUri})];await this.addLinks(a)}async getShacl(e){let t=le.fromUrl(`literal:string:shacl://${e}`),r=await this.get(new B({source:t.toUrl(),predicate:"ad4m://shacl_shape_uri"}));if(r.length===0)return null;let n=r[0].data.target,a=await this.get(new B({source:n,predicate:"sh://property"})),s=[n,...a.map(l=>l.data.target)],o=[];for(let l of s){let u=await this.get(new B({source:l}));for(let m of u)o.push({source:m.data.source,predicate:m.data.predicate,target:m.data.target})}let c=o;return ai.fromLinks(c,n)}async getAllShacl(){let e=await this.get(new B({source:"ad4m://self",predicate:"ad4m://has_shacl"})),t=[];for(let r of e){let n=r.data.target,s=le.fromUrl(n).get().replace("shacl://",""),o=await this.getShacl(s);o&&t.push({name:s,shape:o})}return t}async addFlow(e,t){let r=t.toLinks(),n=le.from(e).toUrl(),a=[...r.map(s=>new Xe({source:s.source,predicate:s.predicate,target:s.target})),new Xe({source:"ad4m://self",predicate:"ad4m://has_flow",target:n}),new Xe({source:n,predicate:"ad4m://flow_uri",target:t.flowUri})];await this.addLinks(a)}async getFlow(e){let t=le.from(e).toUrl(),r=await this.get(new B({source:t,predicate:"ad4m://flow_uri"}));if(r.length===0)return null;let n=r[0].data.target,a=n.endsWith("Flow")?n.slice(0,-4)+".":n+".",s=`SELECT ?s ?p ?o WHERE {
524
+ ?s ?p ?o .
525
+ FILTER(?s = <${n}> || STRSTARTS(STR(?s), "${a}"))
526
+ }`,c=(await this.querySparql(s)||[]).map(l=>({source:l.s,predicate:l.p,target:l.o}));return kr.fromLinks(c,n)}async subjectClasses(){try{let t=(await this.get(new B({predicate:"rdf://type",target:"ad4m://SubjectClass"}))).map(r=>{let a=r.data.source.split("://");return a[a.length-1].split("/").pop()||""}).filter(r=>r.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,r,n){let a;if(typeof e=="string")a=e,await $(this,ne,"f").createSubject($(this,X,"f").uuid,JSON.stringify({className:a,initialValues:r}),t,r?JSON.stringify(r):void 0,n);else{let s=e,o=s.className||s.constructor?.className||s.constructor?.prototype?.className||await this.findClassByProperties(s);if(!o)throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");await $(this,ne,"f").createSubject($(this,X,"f").uuid,JSON.stringify({className:o,initialValues:r}),t,r?JSON.stringify(r):void 0,n)}return n?t:this.getSubjectProxy(t,e)}async getSubjectData(e,t){if(typeof e=="string")return JSON.parse(await $(this,ne,"f").getSubjectData($(this,X,"f").uuid,JSON.stringify({className:e}),t));let r=e,n=r.className||r.constructor?.className||r.constructor?.prototype?.className||await this.findClassByProperties(r);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 $(this,ne,"f").getSubjectData($(this,X,"f").uuid,JSON.stringify({className:n}),t))}async getActionsFromSHACL(e,t){let r=this.escapeRegExp(e),n=new RegExp(`[/:#]${r}Shape$`),a=await this.get(new B({predicate:t}));for(let s of a)if(n.test(s.data.source)){let o="literal:string:";if(s.data.target.startsWith(o)){let c=s.data.target.slice(o.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,r){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,r)}async isSubjectInstance(e,t){let r=await this.stringOrTemplateObjectToSubjectClassName(t),n=await this.getSubjectClassMetadataFromSDNA(r);if(!n)return console.warn(`isSubjectInstance: No SHACL metadata found for class ${r}`),!1;if(n.requiredTriples.length===0)return(await this.get(new B({source:e}))).length>0;for(let a of n.requiredTriples){let s;a.target?s=new B({source:e,predicate:a.predicate,target:a.target}):s=new B({source:e,predicate:a.predicate});let o=await this.get(s);if(!o||o.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 r=await this.stringOrTemplateObjectToSubjectClassName(t),n=new $n(this,e,r);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 r=[],n=[],a=new Map,s=new Map,o=new Set;for(let c of t.properties){if(!c.path||!c.name)continue;c.writable&&o.add(c.path),c.adder&&c.adder.length>0?s.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){r.push(c.predicate);let l=o.has(c.predicate);c.target&&c.target!=="value"&&!l?n.push({predicate:c.predicate,target:c.target}):n.push({predicate:c.predicate})}}return{requiredPredicates:r,requiredTriples:n,properties:a,relations:s}}catch(t){return console.error(`Error getting SHACL metadata for ${e}:`,t),null}}async findInstancesByMetadata(e){if(e.requiredTriples.length===0){let s=await this.get(new B({})),o=new Set(s.map(c=>c.data.source));return Array.from(o).map(c=>({base:c}))}let t=e.requiredTriples[0],r;t.target?r=new B({predicate:t.predicate,target:t.target}):r=new B({predicate:t.predicate});let n=await this.get(r),a=[...new Set(n.map(s=>s.data.source))];for(let s=1;s<e.requiredTriples.length;s++){let o=e.requiredTriples[s],c=[];for(let l of a){let u;o.target?u=new B({source:l,predicate:o.predicate,target:o.target}):u=new B({source:l,predicate:o.predicate}),(await this.get(u)).length>0&&c.push(l)}a=c}return a.map(s=>({base:s}))}async getPropertyValueViaSparql(e,t,r){let n=await this.getSubjectClassMetadataFromSDNA(t);if(!n)return;let a=n.properties.get(r);if(!a)return;let s=await this.get(new B({source:e,predicate:a.predicate}));if(!s||s.length===0)return;let o=s[0].data.target;if(a.resolveLanguage&&o)try{let c=await this.getExpression(o);try{return JSON.parse(c.data)}catch{return c.data}}catch{return o}return o}async getRelationValuesViaSparql(e,t,r){let n=await this.getSubjectClassMetadataFromSDNA(t);if(!n)return[];let a=n.relations.get(r);if(!a)return[];let s=await this.get(new B({source:e,predicate:a.predicate}));if(!s||s.length===0)return[];s.sort((c,l)=>new Date(c.timestamp).getTime()-new Date(l.timestamp).getTime());let o=s.map(c=>c.data.target).filter(c=>c!==""&&c!=="");if(a.condition&&o.length>0)try{let c=[];for(let l of o){let u=a.condition.replace(/\$perspective/g,`'${this.uuid}'`).replace(/\$base/g,`'${e}'`).replace(/Target/g,`'${l.replace(/'/g,"\\'")}'`),m=u.match(/in\.uri\s*=\s*'([^']+)'/),y=u.match(/predicate\s*=\s*'([^']+)'/),d=u.match(/out\.uri\s*=\s*'([^']+)'/);if(m||y||d){let f={};m&&(f.source=m[1]),y&&(f.predicate=y[1]),d&&(f.target=d[1]),(await this.get(new B(f))).length>0&&c.push(l)}else c.push(l)}o=c}catch(c){console.warn(`Failed to apply condition filter for ${r}:`,c)}if(a.instanceFilter)try{let c=await this.getSubjectClassMetadataFromSDNA(a.instanceFilter);return c?await this.batchCheckSubjectInstances(o,c):this.filterInstancesSequential(o,a.instanceFilter)}catch{return this.filterInstancesSequential(o,a.instanceFilter)}return o}async batchCheckSubjectInstances(e,t){if(e.length===0)return[];if(t.requiredTriples.length===0){let a=[];for(let s of e)(await this.get(new B({source:s}))).length>0&&a.push(s);return a}let r=[];for(let a of t.requiredTriples){let s=new Set;for(let o of e){let c;a.target?c=new B({source:o,predicate:a.predicate,target:a.target}):c=new B({source:o,predicate:a.predicate}),(await this.get(c)).length>0&&s.add(o)}r.push(s)}return r.length===0?e:e.filter(a=>r.every(s=>s.has(a)))}async filterInstancesSequential(e,t){let r=[];for(let n of e)try{await this.isSubjectInstance(n,t)&&r.push(n)}catch{continue}return r}async getAllSubjectInstances(e){let t=[],r=typeof e=="function";typeof e=="string"?t=[e]:r?t=[e.name]:t=await this.subjectClassesByTemplate(e);let n=[];for(let a of t){let s=await this.getSubjectClassMetadataFromSDNA(a);if(s){let o=await this.findInstancesByMetadata(s);for(let c of o||[])try{let l;r?(l=new e(this,c.base),await l.get()):(l=new $n(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 r=[];for(let n of t){let a=await this.getSubjectClassMetadataFromSDNA(n);if(a){let s=await this.findInstancesByMetadata(a);for(let o of s||[])try{let c=new $n(this,o.base,n);await c.init(),r.push(c)}catch{}}}return r}async findClassByProperties(e){let t=[],r=[],a=Object.getPrototypeOf(e)?.constructor,s=a?Ki(a):{};Object.keys(s).length>0?t=Object.keys(s):t=Object.keys(e).filter(d=>!Array.isArray(e[d]));let o=a?Object.fromEntries(Object.entries(St(a)).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(e).filter(d=>Array.isArray(e[d])&&d!=="isSubjectInstance"),t.length===0&&r.length===0)return null;let c=await this.get(new B({predicate:"rdf://type",target:"ad4m://SubjectClass"})),l=await this.get(new B({predicate:"sh://property"})),u=await this.get(new B({predicate:"sh://collection"})),m=[...c.map(d=>({shape_source:d.data.source,predicate:d.data.predicate,target:d.data.target})),...l.map(d=>({shape_source:d.data.source,predicate:d.data.predicate,target:d.data.target})),...u.map(d=>({shape_source:d.data.source,predicate:d.data.predicate,target:d.data.target}))];if(m.length===0)return null;let y=new Map;for(let d of m)if(d.predicate==="rdf://type"&&d.target==="ad4m://SubjectClass"){let f=d.shape_source,h=f.indexOf("://");if(h<0)continue;let S=f.substring(h+3).split("/").pop();if(!S)continue;y.set(S,{shapeUri:f,properties:[],relations:[]})}for(let d of m)if(d.predicate==="sh://property"||d.predicate==="sh://collection"){for(let[f,h]of y)if(d.shape_source.endsWith(`${f}Shape`)){let S=d.target.lastIndexOf(".");if(S<0)continue;let x=d.target.substring(S+1);d.predicate==="sh://property"?h.properties.push(x):h.relations.push(x)}}for(let[d,f]of y){let h=t.every(x=>f.properties.includes(x)),S=r.every(x=>f.relations.includes(x));if(h&&S)return d}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($(this,rn,"f").has(t))return;if(!e.generateSHACL)throw new Error(`Class ${e.name} must have generateSHACL(). Use @Model decorator.`);let{shape:r}=e.generateSHACL(),n=JSON.stringify(r.toJSON());await this.addSdna(t,"","subject_class",n),$(this,rn,"f").add(t)}clearEnsuredSubjectClasses(){$(this,rn,"f").clear()}getNeighbourhoodProxy(){return $(this,ne,"f").getNeighbourhoodProxy($(this,X,"f").uuid)}get ai(){return $(this,ne,"f").aiClient}async subscribeInfer(e){let t=new Ka(this.uuid,e,$(this,ne,"f"));return await t.subscribe(),await t.initialized,t}async subscribeQuery(e){let t=new Ka(this.uuid,e,$(this,ne,"f"));return await t.subscribe(),await t.initialized,t}};X=new WeakMap,ne=new WeakMap,Pi=new WeakMap,Ri=new WeakMap,Ni=new WeakMap,tn=new WeakMap,rn=new WeakMap;var Gt=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},Q=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},te,nn,an,sn,Ta,on,Ca,La,Me=`
485
527
  author
486
528
  timestamp
487
529
  status
488
530
  data { source, predicate, target }
489
531
  proof { valid, invalid, signature, key }
490
- `,cr=`
532
+ `,fr=`
491
533
  uuid
492
534
  name
493
535
  sharedUrl
@@ -508,73 +550,64 @@ neighbourhood {
508
550
  }
509
551
  author
510
552
  }
511
- `,Fa=class{constructor(e,t=!0){G.set(this,void 0),Jr.set(this,void 0),Yr.set(this,void 0),Xr.set(this,void 0),wa.set(this,void 0),en.set(this,void 0),Sa.set(this,void 0),_a.set(this,void 0),Kt(this,G,e,"f"),Kt(this,Jr,[],"f"),Kt(this,Yr,[],"f"),Kt(this,Xr,[],"f"),Kt(this,wa,[],"f"),t&&(this.subscribePerspectiveAdded(),this.subscribePerspectiveUpdated(),this.subscribePerspectiveRemoved())}setExpressionClient(e){Kt(this,en,e,"f")}setNeighbourhoodClient(e){Kt(this,Sa,e,"f")}setAIClient(e){Kt(this,_a,e,"f")}get aiClient(){return q(this,_a,"f")}async all(){let{perspectives:e}=b(await q(this,G,"f").query({query:v`query perspectives {
553
+ `,Qa=class{constructor(e,t=!0){te.set(this,void 0),nn.set(this,void 0),an.set(this,void 0),sn.set(this,void 0),Ta.set(this,void 0),on.set(this,void 0),Ca.set(this,void 0),La.set(this,void 0),Gt(this,te,e,"f"),Gt(this,nn,[],"f"),Gt(this,an,[],"f"),Gt(this,sn,[],"f"),Gt(this,Ta,[],"f"),t&&(this.subscribePerspectiveAdded(),this.subscribePerspectiveUpdated(),this.subscribePerspectiveRemoved())}setExpressionClient(e){Gt(this,on,e,"f")}setNeighbourhoodClient(e){Gt(this,Ca,e,"f")}setAIClient(e){Gt(this,La,e,"f")}get aiClient(){return Q(this,La,"f")}async all(){let{perspectives:e}=b(await Q(this,te,"f").query({query:v`query perspectives {
512
554
  perspectives {
513
- ${cr}
555
+ ${fr}
514
556
  }
515
- }`}));return e.map(t=>new mr(t,this))}async byUUID(e){let{perspective:t}=b(await q(this,G,"f").query({query:v`query perspective($uuid: String!) {
557
+ }`}));return e.map(t=>new _r(t,this))}async byUUID(e){let{perspective:t}=b(await Q(this,te,"f").query({query:v`query perspective($uuid: String!) {
516
558
  perspective(uuid: $uuid) {
517
- ${cr}
559
+ ${fr}
518
560
  }
519
- }`,variables:{uuid:e}}));return t?new mr(t,this):null}async snapshotByUUID(e){let{perspectiveSnapshot:t}=b(await q(this,G,"f").query({query:v`query perspectiveSnapshot($uuid: String!) {
561
+ }`,variables:{uuid:e}}));return t?new _r(t,this):null}async snapshotByUUID(e){let{perspectiveSnapshot:t}=b(await Q(this,te,"f").query({query:v`query perspectiveSnapshot($uuid: String!) {
520
562
  perspectiveSnapshot(uuid: $uuid) {
521
563
  links { ${Me} }
522
564
  }
523
- }`,variables:{uuid:e}}));return t}async publishSnapshotByUUID(e){let{perspectivePublishSnapshot:t}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectivePublishSnapshot($uuid: String!) {
565
+ }`,variables:{uuid:e}}));return t}async publishSnapshotByUUID(e){let{perspectivePublishSnapshot:t}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectivePublishSnapshot($uuid: String!) {
524
566
  perspectivePublishSnapshot(uuid: $uuid)
525
- }`,variables:{uuid:e}}));return t}async queryLinks(e,t){let{perspectiveQueryLinks:r}=b(await q(this,G,"f").query({query:v`query perspectiveQueryLinks($uuid: String!, $query: LinkQuery!) {
567
+ }`,variables:{uuid:e}}));return t}async queryLinks(e,t){let{perspectiveQueryLinks:r}=b(await Q(this,te,"f").query({query:v`query perspectiveQueryLinks($uuid: String!, $query: LinkQuery!) {
526
568
  perspectiveQueryLinks(query: $query, uuid: $uuid) {
527
569
  ${Me}
528
570
  }
529
- }`,variables:{uuid:e,query:t}}));return r}async queryProlog(e,t){let{perspectiveQueryProlog:r}=b(await q(this,G,"f").query({query:v`query perspectiveQueryProlog($uuid: String!, $query: String!) {
571
+ }`,variables:{uuid:e,query:t}}));return r}async queryProlog(e,t){let{perspectiveQueryProlog:r}=b(await Q(this,te,"f").query({query:v`query perspectiveQueryProlog($uuid: String!, $query: String!) {
530
572
  perspectiveQueryProlog(uuid: $uuid, query: $query)
531
- }`,variables:{uuid:e,query:t}}));return JSON.parse(r)}async querySurrealDB(e,t){let{perspectiveQuerySurrealDb:r}=b(await q(this,G,"f").query({query:v`query perspectiveQuerySurrealDb($uuid: String!, $query: String!) {
532
- perspectiveQuerySurrealDb(uuid: $uuid, query: $query)
533
- }`,variables:{uuid:e,query:t}}));return JSON.parse(r)}async subscribeQuery(e,t){let{perspectiveSubscribeQuery:r}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveSubscribeQuery($uuid: String!, $query: String!) {
573
+ }`,variables:{uuid:e,query:t}}));return JSON.parse(r)}async querySparql(e,t){let{perspectiveQuerySparql:r}=b(await Q(this,te,"f").query({query:v`query perspectiveQuerySparql($uuid: String!, $query: String!) {
574
+ perspectiveQuerySparql(uuid: $uuid, query: $query)
575
+ }`,variables:{uuid:e,query:t}}));return JSON.parse(r)}async subscribeQuery(e,t){let{perspectiveSubscribeQuery:r}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveSubscribeQuery($uuid: String!, $query: String!) {
534
576
  perspectiveSubscribeQuery(uuid: $uuid, query: $query) {
535
577
  subscriptionId
536
578
  result
537
579
  }
538
- }`,variables:{uuid:e,query:t}})),{subscriptionId:n,result:a}=r,s=a,o=!1;s.startsWith("#init#")&&(s=s.substring(6),o=!0);try{s=JSON.parse(s)}catch(l){console.error("Error parsing perspectiveSubscribeQuery result:",l)}return{subscriptionId:n,result:s,isInit:o}}async perspectiveSubscribeSurrealQuery(e,t){let{perspectiveSubscribeSurrealQuery:r}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveSubscribeSurrealQuery($uuid: String!, $query: String!) {
539
- perspectiveSubscribeSurrealQuery(uuid: $uuid, query: $query) {
540
- subscriptionId
541
- result
542
- }
543
- }`,variables:{uuid:e,query:t}})),{subscriptionId:n,result:a}=r,s=a,o=!1;s.startsWith("#init#")&&(s=s.substring(6),o=!0);try{s=JSON.parse(s)}catch(l){console.error("Error parsing perspectiveSubscribeSurrealQuery result:",l)}return{subscriptionId:n,result:s,isInit:o}}async perspectiveKeepAliveSurrealQuery(e,t){let{perspectiveKeepAliveSurrealQuery:r}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveKeepAliveSurrealQuery($uuid: String!, $subscriptionId: String!) {
544
- perspectiveKeepAliveSurrealQuery(uuid: $uuid, subscriptionId: $subscriptionId)
545
- }`,variables:{uuid:e,subscriptionId:t}}));return r}async perspectiveDisposeSurrealQuerySubscription(e,t){let{perspectiveDisposeSurrealQuerySubscription:r}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveDisposeSurrealQuerySubscription($uuid: String!, $subscriptionId: String!) {
546
- perspectiveDisposeSurrealQuerySubscription(uuid: $uuid, subscriptionId: $subscriptionId)
547
- }`,variables:{uuid:e,subscriptionId:t}}));return r}subscribeToQueryUpdates(e,t){let r=q(this,G,"f").subscribe({query:v`
580
+ }`,variables:{uuid:e,query:t}})),{subscriptionId:n,result:a}=r,s=a,o=!1;s.startsWith("#init#")&&(s=s.substring(6),o=!0);try{s=JSON.parse(s)}catch(c){console.error("Error parsing perspectiveSubscribeQuery result:",c)}return{subscriptionId:n,result:s,isInit:o}}subscribeToQueryUpdates(e,t){let r=Q(this,te,"f").subscribe({query:v`
548
581
  subscription perspectiveQuerySubscription($subscriptionId: String!) {
549
582
  perspectiveQuerySubscription(subscriptionId: $subscriptionId)
550
583
  }
551
- `,variables:{subscriptionId:e}}).subscribe({next:n=>{if(n.data&&n.data.perspectiveQuerySubscription){let a=n.data.perspectiveQuerySubscription,s=!1;a.startsWith("#init#")&&(a=a.substring(6),s=!0);try{a=JSON.parse(a),s&&typeof a=="object"&&(a.isInit=!0)}catch(o){console.error("Error parsing perspectiveQuerySubscription:",o)}t(a)}},error:n=>console.error("Error in query subscription:",n)});return()=>r.unsubscribe()}async keepAliveQuery(e,t){let{perspectiveKeepAliveQuery:r}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveKeepAliveQuery($uuid: String!, $subscriptionId: String!) {
584
+ `,variables:{subscriptionId:e}}).subscribe({next:n=>{if(n.data&&n.data.perspectiveQuerySubscription){let a=n.data.perspectiveQuerySubscription,s=!1;a.startsWith("#init#")&&(a=a.substring(6),s=!0);try{a=JSON.parse(a),s&&typeof a=="object"&&(a.isInit=!0)}catch(o){console.error("Error parsing perspectiveQuerySubscription:",o)}t(a)}},error:n=>console.error("Error in query subscription:",n)});return()=>r.unsubscribe()}async keepAliveQuery(e,t){let{perspectiveKeepAliveQuery:r}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveKeepAliveQuery($uuid: String!, $subscriptionId: String!) {
552
585
  perspectiveKeepAliveQuery(uuid: $uuid, subscriptionId: $subscriptionId)
553
- }`,variables:{uuid:e,subscriptionId:t}}));return r}async disposeQuerySubscription(e,t){let{perspectiveDisposeQuerySubscription:r}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveDisposeQuerySubscription($uuid: String!, $subscriptionId: String!) {
586
+ }`,variables:{uuid:e,subscriptionId:t}}));return r}async disposeQuerySubscription(e,t){let{perspectiveDisposeQuerySubscription:r}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveDisposeQuerySubscription($uuid: String!, $subscriptionId: String!) {
554
587
  perspectiveDisposeQuerySubscription(uuid: $uuid, subscriptionId: $subscriptionId)
555
- }`,variables:{uuid:e,subscriptionId:t}}));return r}async add(e){let{perspectiveAdd:t}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveAdd($name: String!) {
588
+ }`,variables:{uuid:e,subscriptionId:t}}));return r}async add(e){let{perspectiveAdd:t}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveAdd($name: String!) {
556
589
  perspectiveAdd(name: $name) {
557
- ${cr}
590
+ ${fr}
558
591
  }
559
- }`,variables:{name:e}}));return new mr(t,this)}async update(e,t){let{perspectiveUpdate:r}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveUpdate($uuid: String!, $name: String!) {
592
+ }`,variables:{name:e}}));return new _r(t,this)}async update(e,t){let{perspectiveUpdate:r}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveUpdate($uuid: String!, $name: String!) {
560
593
  perspectiveUpdate(uuid: $uuid, name: $name) {
561
- ${cr}
594
+ ${fr}
562
595
  }
563
- }`,variables:{uuid:e,name:t}}));return new mr(r,this)}async remove(e){return b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveRemove($uuid: String!) {
596
+ }`,variables:{uuid:e,name:t}}));return new _r(r,this)}async remove(e){return b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveRemove($uuid: String!) {
564
597
  perspectiveRemove(uuid: $uuid)
565
- }`,variables:{uuid:e}}))}async addLink(e,t,r="shared",n){let{perspectiveAddLink:a}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String!, $batchId: String) {
598
+ }`,variables:{uuid:e}}))}async addLink(e,t,r="shared",n){let{perspectiveAddLink:a}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveAddLink($uuid: String!, $link: LinkInput!, $status: String!, $batchId: String) {
566
599
  perspectiveAddLink(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
567
600
  ${Me}
568
601
  }
569
- }`,variables:{uuid:e,link:t,status:r,batchId:n}}));return a}async addLinks(e,t,r="shared",n){let{perspectiveAddLinks:a}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String!, $batchId: String) {
602
+ }`,variables:{uuid:e,link:t,status:r,batchId:n}}));return a}async addLinks(e,t,r="shared",n){let{perspectiveAddLinks:a}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveAddLinks($uuid: String!, $links: [LinkInput!]!, $status: String!, $batchId: String) {
570
603
  perspectiveAddLinks(uuid: $uuid, links: $links, status: $status, batchId: $batchId) {
571
604
  ${Me}
572
605
  }
573
- }`,variables:{uuid:e,links:t,status:r,batchId:n}}));return a}async removeLinks(e,t,r){let{perspectiveRemoveLinks:n}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]!, $batchId: String) {
606
+ }`,variables:{uuid:e,links:t,status:r,batchId:n}}));return a}async removeLinks(e,t,r){let{perspectiveRemoveLinks:n}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveRemoveLinks($uuid: String!, $links: [LinkExpressionInput!]!, $batchId: String) {
574
607
  perspectiveRemoveLinks(uuid: $uuid, links: $links, batchId: $batchId) {
575
608
  ${Me}
576
609
  }
577
- }`,variables:{uuid:e,links:t,batchId:r}}));return n}async linkMutations(e,t,r){let{perspectiveLinkMutations:n}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveLinkMutations($uuid: String!, $mutations: LinkMutations!, $status: String){
610
+ }`,variables:{uuid:e,links:t,batchId:r}}));return n}async linkMutations(e,t,r){let{perspectiveLinkMutations:n}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveLinkMutations($uuid: String!, $mutations: LinkMutations!, $status: String){
578
611
  perspectiveLinkMutations(mutations: $mutations, uuid: $uuid, status: $status) {
579
612
  additions {
580
613
  ${Me}
@@ -583,43 +616,43 @@ neighbourhood {
583
616
  ${Me}
584
617
  }
585
618
  }
586
- }`,variables:{uuid:e,mutations:t,status:r}}));return n}async addLinkExpression(e,t,r="shared",n){let{perspectiveAddLinkExpression:a}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String!, $batchId: String) {
619
+ }`,variables:{uuid:e,mutations:t,status:r}}));return n}async addLinkExpression(e,t,r="shared",n){let{perspectiveAddLinkExpression:a}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveAddLinkExpression($uuid: String!, $link: LinkExpressionInput!, $status: String!, $batchId: String) {
587
620
  perspectiveAddLinkExpression(uuid: $uuid, link: $link, status: $status, batchId: $batchId) {
588
621
  ${Me}
589
622
  }
590
- }`,variables:{uuid:e,link:t,status:r,batchId:n}}));return a}async updateLink(e,t,r,n){let{perspectiveUpdateLink:a}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveUpdateLink($uuid: String!, $oldLink: LinkExpressionInput!, $newLink: LinkInput!, $batchId: String) {
623
+ }`,variables:{uuid:e,link:t,status:r,batchId:n}}));return a}async updateLink(e,t,r,n){let{perspectiveUpdateLink:a}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveUpdateLink($uuid: String!, $oldLink: LinkExpressionInput!, $newLink: LinkInput!, $batchId: String) {
591
624
  perspectiveUpdateLink(uuid: $uuid, oldLink: $oldLink, newLink: $newLink, batchId: $batchId) {
592
625
  ${Me}
593
626
  }
594
- }`,variables:{uuid:e,oldLink:t,newLink:r,batchId:n}}));return a}async removeLink(e,t,r){delete t.__typename,delete t.data.__typename,delete t.proof.__typename,delete t.status;let{perspectiveRemoveLink:n}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveRemoveLink($link: LinkExpressionInput!, $uuid: String!, $batchId: String) {
627
+ }`,variables:{uuid:e,oldLink:t,newLink:r,batchId:n}}));return a}async removeLink(e,t,r){delete t.__typename,delete t.data.__typename,delete t.proof.__typename,delete t.status;let{perspectiveRemoveLink:n}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveRemoveLink($link: LinkExpressionInput!, $uuid: String!, $batchId: String) {
595
628
  perspectiveRemoveLink(link: $link, uuid: $uuid, batchId: $batchId)
596
- }`,variables:{uuid:e,link:t,batchId:r}}));return n}async addSdna(e,t,r,n,a){return b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveAddSdna($uuid: String!, $name: String!, $sdnaCode: String, $sdnaType: String!, $shaclJson: String) {
629
+ }`,variables:{uuid:e,link:t,batchId:r}}));return n}async addSdna(e,t,r,n,a){return b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveAddSdna($uuid: String!, $name: String!, $sdnaCode: String, $sdnaType: String!, $shaclJson: String) {
597
630
  perspectiveAddSdna(uuid: $uuid, name: $name, sdnaCode: $sdnaCode, sdnaType: $sdnaType, shaclJson: $shaclJson)
598
- }`,variables:{uuid:e,name:t,sdnaCode:r||"",sdnaType:n,shaclJson:a}})).perspectiveAddSdna}async executeCommands(e,t,r,n,a){return b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveExecuteCommands($uuid: String!, $commands: String!, $expression: String!, $parameters: String, $batchId: String) {
631
+ }`,variables:{uuid:e,name:t,sdnaCode:r||"",sdnaType:n,shaclJson:a}})).perspectiveAddSdna}async executeCommands(e,t,r,n,a){return b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveExecuteCommands($uuid: String!, $commands: String!, $expression: String!, $parameters: String, $batchId: String) {
599
632
  perspectiveExecuteCommands(uuid: $uuid, commands: $commands, expression: $expression, parameters: $parameters, batchId: $batchId)
600
- }`,variables:{uuid:e,commands:t,expression:r,parameters:n,batchId:a}})).perspectiveExecuteCommands}async createSubject(e,t,r,n,a){return b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveCreateSubject($uuid: String!, $subjectClass: String!, $expressionAddress: String!, $initialValues: String, $batchId: String) {
633
+ }`,variables:{uuid:e,commands:t,expression:r,parameters:n,batchId:a}})).perspectiveExecuteCommands}async createSubject(e,t,r,n,a){return b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveCreateSubject($uuid: String!, $subjectClass: String!, $expressionAddress: String!, $initialValues: String, $batchId: String) {
601
634
  perspectiveCreateSubject(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress, initialValues: $initialValues, batchId: $batchId)
602
- }`,variables:{uuid:e,subjectClass:t,expressionAddress:r,initialValues:n,batchId:a}})).perspectiveCreateSubject}async getSubjectData(e,t,r){return b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveGetSubjectData($uuid: String!, $subjectClass: String!, $expressionAddress: String!) {
635
+ }`,variables:{uuid:e,subjectClass:t,expressionAddress:r,initialValues:n,batchId:a}})).perspectiveCreateSubject}async getSubjectData(e,t,r){return b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveGetSubjectData($uuid: String!, $subjectClass: String!, $expressionAddress: String!) {
603
636
  perspectiveGetSubjectData(uuid: $uuid, subjectClass: $subjectClass, expressionAddress: $expressionAddress)
604
- }`,variables:{uuid:e,subjectClass:t,expressionAddress:r}})).perspectiveGetSubjectData}async getExpression(e){return await q(this,en,"f").get(e)}async createExpression(e,t){return await q(this,en,"f").create(e,t)}addPerspectiveAddedListener(e){q(this,Jr,"f").push(e)}subscribePerspectiveAdded(){q(this,G,"f").subscribe({query:v` subscription {
605
- perspectiveAdded { ${cr} }
637
+ }`,variables:{uuid:e,subjectClass:t,expressionAddress:r}})).perspectiveGetSubjectData}async getExpression(e){return await Q(this,on,"f").get(e)}async createExpression(e,t){return await Q(this,on,"f").create(e,t)}addPerspectiveAddedListener(e){Q(this,nn,"f").push(e)}subscribePerspectiveAdded(){Q(this,te,"f").subscribe({query:v` subscription {
638
+ perspectiveAdded { ${fr} }
606
639
  }
607
- `}).subscribe({next:e=>{q(this,Jr,"f").forEach(t=>{t(e.data.perspectiveAdded)})},error:e=>console.error(e)})}addPerspectiveUpdatedListener(e){q(this,Yr,"f").push(e)}subscribePerspectiveUpdated(){q(this,G,"f").subscribe({query:v` subscription {
608
- perspectiveUpdated { ${cr} }
640
+ `}).subscribe({next:e=>{Q(this,nn,"f").forEach(t=>{t(e.data.perspectiveAdded)})},error:e=>console.error(e)})}addPerspectiveUpdatedListener(e){Q(this,an,"f").push(e)}subscribePerspectiveUpdated(){Q(this,te,"f").subscribe({query:v` subscription {
641
+ perspectiveUpdated { ${fr} }
609
642
  }
610
- `}).subscribe({next:e=>{q(this,Yr,"f").forEach(t=>{t(e.data.perspectiveUpdated)})},error:e=>console.error(e)})}addPerspectiveSyncedListener(e){q(this,wa,"f").push(e)}async addPerspectiveSyncStateChangeListener(e,t){q(this,G,"f").subscribe({query:v` subscription {
643
+ `}).subscribe({next:e=>{Q(this,an,"f").forEach(t=>{t(e.data.perspectiveUpdated)})},error:e=>console.error(e)})}addPerspectiveSyncedListener(e){Q(this,Ta,"f").push(e)}async addPerspectiveSyncStateChangeListener(e,t){Q(this,te,"f").subscribe({query:v` subscription {
611
644
  perspectiveSyncStateChange(uuid: "${e}")
612
645
  }
613
- `}).subscribe({next:r=>{t.forEach(n=>{n(r.data.perspectiveSyncStateChange)})},error:r=>console.error(r)}),await new Promise(r=>setTimeout(r,500))}addPerspectiveRemovedListener(e){q(this,Xr,"f").push(e)}subscribePerspectiveRemoved(){q(this,G,"f").subscribe({query:v` subscription {
646
+ `}).subscribe({next:r=>{t.forEach(n=>{n(r.data.perspectiveSyncStateChange)})},error:r=>console.error(r)}),await new Promise(r=>setTimeout(r,500))}addPerspectiveRemovedListener(e){Q(this,sn,"f").push(e)}subscribePerspectiveRemoved(){Q(this,te,"f").subscribe({query:v` subscription {
614
647
  perspectiveRemoved
615
648
  }
616
- `}).subscribe({next:e=>{q(this,Xr,"f").forEach(t=>{t(e.data.perspectiveRemoved)})},error:e=>console.error(e)})}async addPerspectiveLinkAddedListener(e,t){q(this,G,"f").subscribe({query:v` subscription {
649
+ `}).subscribe({next:e=>{Q(this,sn,"f").forEach(t=>{t(e.data.perspectiveRemoved)})},error:e=>console.error(e)})}async addPerspectiveLinkAddedListener(e,t){Q(this,te,"f").subscribe({query:v` subscription {
617
650
  perspectiveLinkAdded(uuid: "${e}") { ${Me} }
618
651
  }
619
- `}).subscribe({next:r=>{t.forEach(n=>{n(r.data.perspectiveLinkAdded)})},error:r=>console.error(r)}),await new Promise(r=>setTimeout(r,500))}async addPerspectiveLinkRemovedListener(e,t){q(this,G,"f").subscribe({query:v` subscription {
652
+ `}).subscribe({next:r=>{t.forEach(n=>{n(r.data.perspectiveLinkAdded)})},error:r=>console.error(r)}),await new Promise(r=>setTimeout(r,500))}async addPerspectiveLinkRemovedListener(e,t){Q(this,te,"f").subscribe({query:v` subscription {
620
653
  perspectiveLinkRemoved(uuid: "${e}") { ${Me} }
621
654
  }
622
- `}).subscribe({next:r=>{t.forEach(n=>{r.data.perspectiveLinkRemoved.status||delete r.data.perspectiveLinkRemoved.status,n(r.data.perspectiveLinkRemoved)})},error:r=>console.error(r)}),await new Promise(r=>setTimeout(r,500))}async addPerspectiveLinkUpdatedListener(e,t){q(this,G,"f").subscribe({query:v` subscription {
655
+ `}).subscribe({next:r=>{t.forEach(n=>{r.data.perspectiveLinkRemoved.status||delete r.data.perspectiveLinkRemoved.status,n(r.data.perspectiveLinkRemoved)})},error:r=>console.error(r)}),await new Promise(r=>setTimeout(r,500))}async addPerspectiveLinkUpdatedListener(e,t){Q(this,te,"f").subscribe({query:v` subscription {
623
656
  perspectiveLinkUpdated(uuid: "${e}") {
624
657
  oldLink {
625
658
  ${Me}
@@ -629,9 +662,9 @@ neighbourhood {
629
662
  }
630
663
  }
631
664
  }
632
- `}).subscribe({next:r=>{t.forEach(n=>{r.data.perspectiveLinkUpdated.newLink.status||delete r.data.perspectiveLinkUpdated.newLink.status,r.data.perspectiveLinkUpdated.oldLink.status||delete r.data.perspectiveLinkUpdated.oldLink.status,n(r.data.perspectiveLinkUpdated)})},error:r=>console.error(r)}),await new Promise(r=>setTimeout(r,500))}getNeighbourhoodProxy(e){return new Xs(q(this,Sa,"f"),e)}async createBatch(e){let{perspectiveCreateBatch:t}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveCreateBatch($uuid: String!) {
665
+ `}).subscribe({next:r=>{t.forEach(n=>{r.data.perspectiveLinkUpdated.newLink.status||delete r.data.perspectiveLinkUpdated.newLink.status,r.data.perspectiveLinkUpdated.oldLink.status||delete r.data.perspectiveLinkUpdated.oldLink.status,n(r.data.perspectiveLinkUpdated)})},error:r=>console.error(r)}),await new Promise(r=>setTimeout(r,500))}getNeighbourhoodProxy(e){return new lo(Q(this,Ca,"f"),e)}async createBatch(e){let{perspectiveCreateBatch:t}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveCreateBatch($uuid: String!) {
633
666
  perspectiveCreateBatch(uuid: $uuid)
634
- }`,variables:{uuid:e}}));return t}async commitBatch(e,t){let{perspectiveCommitBatch:r}=b(await q(this,G,"f").mutate({mutation:v`mutation perspectiveCommitBatch($uuid: String!, $batchId: String!) {
667
+ }`,variables:{uuid:e}}));return t}async commitBatch(e,t){let{perspectiveCommitBatch:r}=b(await Q(this,te,"f").mutate({mutation:v`mutation perspectiveCommitBatch($uuid: String!, $batchId: String!) {
635
668
  perspectiveCommitBatch(uuid: $uuid, batchId: $batchId) {
636
669
  additions {
637
670
  ${Me}
@@ -640,7 +673,7 @@ neighbourhood {
640
673
  ${Me}
641
674
  }
642
675
  }
643
- }`,variables:{uuid:e,batchId:t}}));return r}};G=new WeakMap,Jr=new WeakMap,Yr=new WeakMap,Xr=new WeakMap,wa=new WeakMap,en=new WeakMap,Sa=new WeakMap,_a=new WeakMap;var ea=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},Z=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},X,tn,rn,nn,Vr=`
676
+ }`,variables:{uuid:e,batchId:t}}));return r}};te=new WeakMap,nn=new WeakMap,an=new WeakMap,sn=new WeakMap,Ta=new WeakMap,on=new WeakMap,Ca=new WeakMap,La=new WeakMap;var hr=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},V=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Y,cn,ln,un,dn,pn,Gr=`
644
677
  did
645
678
  directMessageLanguage
646
679
  perspective {
@@ -654,7 +687,7 @@ neighbourhood {
654
687
  }
655
688
  }
656
689
  }
657
- `,ta=`
690
+ `,ua=`
658
691
  requestId
659
692
  revoked
660
693
  auth {
@@ -670,159 +703,186 @@ neighbourhood {
670
703
  can
671
704
  }
672
705
  }
673
- `,lr=`
706
+ `,gr=`
674
707
  isInitialized
675
708
  isUnlocked
676
709
  did
677
710
  didDocument
678
711
  error
679
- `,ia=`
712
+ `,da=`
680
713
  did
681
714
  didSigningKeyId
682
715
  deviceKeyType
683
716
  deviceKey
684
717
  deviceKeySignedByDid
685
718
  didSignedByDeviceKey
686
- `,dp=`
719
+ `,Cp=`
687
720
  signature
688
721
  publicKey
689
- `,xn=class{constructor(e,t=!0){X.set(this,void 0),tn.set(this,void 0),rn.set(this,void 0),nn.set(this,void 0),ea(this,X,e,"f"),ea(this,rn,[],"f"),ea(this,nn,[],"f"),ea(this,tn,[],"f"),t&&(this.subscribeAgentUpdated(),this.subscribeAgentStatusChanged(),this.subscribeAppsChanged())}async me(){let{agent:e}=b(await Z(this,X,"f").query({query:v`query agent { agent { ${Vr} } }`})),t=new ti(e.did,e.perspective);return t.directMessageLanguage=e.directMessageLanguage,t}async status(){let{agentStatus:e}=b(await Z(this,X,"f").query({query:v`query agentStatus {
722
+ `,Pn=class{constructor(e,t=!0){Y.set(this,void 0),cn.set(this,void 0),ln.set(this,void 0),un.set(this,void 0),dn.set(this,void 0),pn.set(this,void 0),hr(this,Y,e,"f"),hr(this,ln,[],"f"),hr(this,un,[],"f"),hr(this,cn,[],"f"),hr(this,dn,[],"f"),hr(this,pn,[],"f"),t&&(this.subscribeAgentUpdated(),this.subscribeAgentStatusChanged(),this.subscribeAppsChanged())}async me(){let{agent:e}=b(await V(this,Y,"f").query({query:v`query agent { agent { ${Gr} } }`})),t=new ni(e.did,e.perspective);return t.directMessageLanguage=e.directMessageLanguage,t}async status(){let{agentStatus:e}=b(await V(this,Y,"f").query({query:v`query agentStatus {
690
723
  agentStatus {
691
- ${lr}
724
+ ${gr}
692
725
  }
693
- }`}));return new lt(e)}async generate(e){let{agentGenerate:t}=b(await Z(this,X,"f").mutate({mutation:v`mutation agentGenerate(
726
+ }`}));return new ut(e)}async generate(e){let{agentGenerate:t}=b(await V(this,Y,"f").mutate({mutation:v`mutation agentGenerate(
694
727
  $passphrase: String!
695
728
  ) {
696
729
  agentGenerate(passphrase: $passphrase) {
697
- ${lr}
730
+ ${gr}
698
731
  }
699
- }`,variables:{passphrase:e}}));return new lt(t)}async import(e){let{did:t,didDocument:r,keystore:n,passphrase:a}=e,{agentImport:s}=b(await Z(this,X,"f").mutate({mutation:v`mutation agentImport(
732
+ }`,variables:{passphrase:e}}));return new ut(t)}async import(e){let{did:t,didDocument:r,keystore:n,passphrase:a}=e,{agentImport:s}=b(await V(this,Y,"f").mutate({mutation:v`mutation agentImport(
700
733
  $did: String!,
701
734
  $didDocument: String!,
702
735
  $keystore: String!,
703
736
  $passphrase: String!
704
737
  ) {
705
738
  agentImport(did: $did, didDocument: $didDocument, keystore: $keystore, passphrase: $passphrase) {
706
- ${lr}
739
+ ${gr}
707
740
  }
708
- }`,variables:{did:t,didDocument:r,keystore:n,passphrase:a}}));return new lt(s)}async lock(e){let{agentLock:t}=b(await Z(this,X,"f").mutate({mutation:v`mutation agentLock($passphrase: String!) {
741
+ }`,variables:{did:t,didDocument:r,keystore:n,passphrase:a}}));return new ut(s)}async lock(e){let{agentLock:t}=b(await V(this,Y,"f").mutate({mutation:v`mutation agentLock($passphrase: String!) {
709
742
  agentLock(passphrase: $passphrase) {
710
- ${lr}
743
+ ${gr}
711
744
  }
712
- }`,variables:{passphrase:e}}));return new lt(t)}async unlock(e,t=!0){let{agentUnlock:r}=b(await Z(this,X,"f").mutate({mutation:v`mutation agentUnlock($passphrase: String!, $holochain: Boolean!) {
745
+ }`,variables:{passphrase:e}}));return new ut(t)}async unlock(e,t=!0){let{agentUnlock:r}=b(await V(this,Y,"f").mutate({mutation:v`mutation agentUnlock($passphrase: String!, $holochain: Boolean!) {
713
746
  agentUnlock(passphrase: $passphrase, holochain: $holochain) {
714
- ${lr}
747
+ ${gr}
715
748
  }
716
- }`,variables:{passphrase:e,holochain:t}}));return new lt(r)}async byDID(e){let{agentByDID:t}=b(await Z(this,X,"f").query({query:v`query agentByDID($did: String!) {
749
+ }`,variables:{passphrase:e,holochain:t}}));return new ut(r)}async byDID(e){let{agentByDID:t}=b(await V(this,Y,"f").query({query:v`query agentByDID($did: String!) {
717
750
  agentByDID(did: $did) {
718
- ${Vr}
751
+ ${Gr}
719
752
  }
720
- }`,variables:{did:e}}));return t}async updatePublicPerspective(e){let t=JSON.parse(JSON.stringify(e));delete t.__typename,t.links.forEach(s=>{delete s.__typename,delete s.data.__typename,delete s.proof.__typename,delete s.status});let{agentUpdatePublicPerspective:r}=b(await Z(this,X,"f").mutate({mutation:v`mutation agentUpdatePublicPerspective($perspective: PerspectiveInput!) {
753
+ }`,variables:{did:e}}));return t}async updatePublicPerspective(e){let t=JSON.parse(JSON.stringify(e));delete t.__typename,t.links.forEach(s=>{delete s.__typename,delete s.data.__typename,delete s.proof.__typename,delete s.status});let{agentUpdatePublicPerspective:r}=b(await V(this,Y,"f").mutate({mutation:v`mutation agentUpdatePublicPerspective($perspective: PerspectiveInput!) {
721
754
  agentUpdatePublicPerspective(perspective: $perspective) {
722
- ${Vr}
755
+ ${Gr}
723
756
  }
724
- }`,variables:{perspective:t}})),n=r,a=new ti(n.did,n.perspective);return a.directMessageLanguage=n.directMessageLanguage,a}async mutatePublicPerspective(e){let t=new Fa(Z(this,X,"f")),r=new xn(Z(this,X,"f")),n=await t.add("Agent Perspective Proxy"),a=await r.me();a.perspective&&await n.loadSnapshot(a.perspective);for(let l of e.additions)await n.add(l);for(let l of e.removals)await n.remove(l);let s=await n.snapshot(),o=await this.updatePublicPerspective(s);return await t.remove(n.uuid),o}async updateDirectMessageLanguage(e){let{agentUpdateDirectMessageLanguage:t}=b(await Z(this,X,"f").mutate({mutation:v`mutation agentUpdateDirectMessageLanguage($directMessageLanguage: String!) {
757
+ }`,variables:{perspective:t}})),n=r,a=new ni(n.did,n.perspective);return a.directMessageLanguage=n.directMessageLanguage,a}async mutatePublicPerspective(e){let t=new Qa(V(this,Y,"f")),r=new Pn(V(this,Y,"f")),n=await t.add("Agent Perspective Proxy"),a=await r.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 s=await n.snapshot(),o=await this.updatePublicPerspective(s);return await t.remove(n.uuid),o}async updateDirectMessageLanguage(e){let{agentUpdateDirectMessageLanguage:t}=b(await V(this,Y,"f").mutate({mutation:v`mutation agentUpdateDirectMessageLanguage($directMessageLanguage: String!) {
725
758
  agentUpdateDirectMessageLanguage(directMessageLanguage: $directMessageLanguage) {
726
- ${Vr}
759
+ ${Gr}
727
760
  }
728
- }`,variables:{directMessageLanguage:e}})),r=t,n=new ti(r.did,r.perspective);return n.directMessageLanguage=r.directMessageLanguage,n}async addEntanglementProofs(e){let{agentAddEntanglementProofs:t}=b(await Z(this,X,"f").mutate({mutation:v`mutation agentAddEntanglementProofs($proofs: [EntanglementProofInput!]!) {
761
+ }`,variables:{directMessageLanguage:e}})),r=t,n=new ni(r.did,r.perspective);return n.directMessageLanguage=r.directMessageLanguage,n}async addEntanglementProofs(e){let{agentAddEntanglementProofs:t}=b(await V(this,Y,"f").mutate({mutation:v`mutation agentAddEntanglementProofs($proofs: [EntanglementProofInput!]!) {
729
762
  agentAddEntanglementProofs(proofs: $proofs) {
730
- ${ia}
763
+ ${da}
731
764
  }
732
- }`,variables:{proofs:e}}));return t}async deleteEntanglementProofs(e){let{agentDeleteEntanglementProofs:t}=b(await Z(this,X,"f").mutate({mutation:v`mutation agentDeleteEntanglementProofs($proofs: [EntanglementProofInput!]!) {
765
+ }`,variables:{proofs:e}}));return t}async deleteEntanglementProofs(e){let{agentDeleteEntanglementProofs:t}=b(await V(this,Y,"f").mutate({mutation:v`mutation agentDeleteEntanglementProofs($proofs: [EntanglementProofInput!]!) {
733
766
  agentDeleteEntanglementProofs(proofs: $proofs) {
734
- ${ia}
767
+ ${da}
735
768
  }
736
- }`,variables:{proofs:e}}));return t}async getEntanglementProofs(){let{agentGetEntanglementProofs:e}=b(await Z(this,X,"f").query({query:v`query agentGetEntanglementProofs {
769
+ }`,variables:{proofs:e}}));return t}async getEntanglementProofs(){let{agentGetEntanglementProofs:e}=b(await V(this,Y,"f").query({query:v`query agentGetEntanglementProofs {
737
770
  agentGetEntanglementProofs {
738
- ${ia}
771
+ ${da}
739
772
  }
740
- }`}));return e}async entanglementProofPreFlight(e,t){let{agentEntanglementProofPreFlight:r}=b(await Z(this,X,"f").mutate({mutation:v`mutation agentEntanglementProofPreFlight($deviceKey: String!, $deviceKeyType: String!) {
773
+ }`}));return e}async entanglementProofPreFlight(e,t){let{agentEntanglementProofPreFlight:r}=b(await V(this,Y,"f").mutate({mutation:v`mutation agentEntanglementProofPreFlight($deviceKey: String!, $deviceKeyType: String!) {
741
774
  agentEntanglementProofPreFlight(deviceKey: $deviceKey, deviceKeyType: $deviceKeyType) {
742
- ${ia}
775
+ ${da}
743
776
  }
744
- }`,variables:{deviceKey:e,deviceKeyType:t}}));return r}addUpdatedListener(e){Z(this,rn,"f").push(e)}addAppChangedListener(e){Z(this,tn,"f").push(e)}subscribeAgentUpdated(){Z(this,X,"f").subscribe({query:v` subscription {
745
- agentUpdated { ${Vr} }
777
+ }`,variables:{deviceKey:e,deviceKeyType:t}}));return r}addUpdatedListener(e){V(this,ln,"f").push(e)}addAppChangedListener(e){V(this,cn,"f").push(e)}subscribeAgentUpdated(){V(this,Y,"f").subscribe({query:v` subscription {
778
+ agentUpdated { ${Gr} }
746
779
  }
747
- `}).subscribe({next:e=>{let t=e.data.agentUpdated;Z(this,rn,"f").forEach(r=>{r(t)})},error:e=>console.error(e)})}subscribeAppsChanged(){Z(this,X,"f").subscribe({query:v` subscription {
780
+ `}).subscribe({next:e=>{let t=e.data.agentUpdated;V(this,ln,"f").forEach(r=>{r(t)})},error:e=>console.error(e)})}subscribeAppsChanged(){V(this,Y,"f").subscribe({query:v` subscription {
748
781
  agentAppsChanged {
749
- ${ta}
782
+ ${ua}
750
783
  }
751
784
  }
752
- `}).subscribe({next:e=>{Z(this,tn,"f").forEach(t=>{t()})},error:e=>console.error(e)})}addAgentStatusChangedListener(e){Z(this,nn,"f").push(e)}subscribeAgentStatusChanged(){Z(this,X,"f").subscribe({query:v` subscription {
753
- agentStatusChanged { ${lr} }
785
+ `}).subscribe({next:e=>{V(this,cn,"f").forEach(t=>{t()})},error:e=>console.error(e)})}addAgentStatusChangedListener(e){V(this,un,"f").push(e)}subscribeAgentStatusChanged(){V(this,Y,"f").subscribe({query:v` subscription {
786
+ agentStatusChanged { ${gr} }
754
787
  }
755
- `}).subscribe({next:e=>{let t=e.data.agentStatusChanged;Z(this,nn,"f").forEach(r=>{r(t)})},error:e=>console.error(e)})}async requestCapability(e){let{agentRequestCapability:t}=b(await Z(this,X,"f").mutate({mutation:v`
788
+ `}).subscribe({next:e=>{let t=e.data.agentStatusChanged;V(this,un,"f").forEach(r=>{r(t)})},error:e=>console.error(e)})}addHostingUserInfoChangedListener(e){V(this,dn,"f").push(e)}subscribeHostingUserInfoChanged(){V(this,Y,"f").subscribe({query:v`subscription {
789
+ runtimeHostingUserInfoChanged {
790
+ email
791
+ remainingCredits
792
+ hotWalletAddress
793
+ freeAccess
794
+ }
795
+ }`}).subscribe({next:e=>{let t=e.data.runtimeHostingUserInfoChanged;V(this,dn,"f").forEach(r=>r(t))},error:e=>console.error(e)})}addComputeLogUpdatedListener(e){V(this,pn,"f").push(e)}subscribeComputeLogUpdated(){V(this,Y,"f").subscribe({query:v`subscription {
796
+ runtimeComputeLogUpdated {
797
+ id
798
+ userEmail
799
+ timestamp
800
+ operation
801
+ summary
802
+ cost
803
+ creditsAfter
804
+ }
805
+ }`}).subscribe({next:e=>{let t=e.data.runtimeComputeLogUpdated;V(this,pn,"f").forEach(r=>r(t))},error:e=>console.error(e)})}async requestCapability(e){let{agentRequestCapability:t}=b(await V(this,Y,"f").mutate({mutation:v`
756
806
  mutation agentRequestCapability($authInfo: AuthInfoInput!) {
757
807
  agentRequestCapability(authInfo: $authInfo)
758
808
  }
759
- `,variables:{authInfo:e}}));return t}async permitCapability(e){let{agentPermitCapability:t}=b(await Z(this,X,"f").mutate({mutation:v`
809
+ `,variables:{authInfo:e}}));return t}async permitCapability(e){let{agentPermitCapability:t}=b(await V(this,Y,"f").mutate({mutation:v`
760
810
  mutation agentPermitCapability($auth: String!) {
761
811
  agentPermitCapability(auth: $auth)
762
812
  }
763
- `,variables:{auth:e}}));return t}async generateJwt(e,t){let{agentGenerateJwt:r}=b(await Z(this,X,"f").mutate({mutation:v`
813
+ `,variables:{auth:e}}));return t}async generateJwt(e,t){let{agentGenerateJwt:r}=b(await V(this,Y,"f").mutate({mutation:v`
764
814
  mutation agentGenerateJwt($requestId: String!, $rand: String!) {
765
815
  agentGenerateJwt(requestId: $requestId, rand: $rand)
766
816
  }
767
- `,variables:{requestId:e,rand:t}}));return r}async getApps(){let{agentGetApps:e}=b(await Z(this,X,"f").mutate({mutation:v`query agentGetApps {
817
+ `,variables:{requestId:e,rand:t}}));return r}async getApps(){let{agentGetApps:e}=b(await V(this,Y,"f").mutate({mutation:v`query agentGetApps {
768
818
  agentGetApps {
769
- ${ta}
819
+ ${ua}
770
820
  }
771
- }`}));return e}async removeApp(e){let{agentRemoveApp:t}=b(await Z(this,X,"f").mutate({mutation:v`mutation agentRemoveApp($requestId: String!) {
821
+ }`}));return e}async removeApp(e){let{agentRemoveApp:t}=b(await V(this,Y,"f").mutate({mutation:v`mutation agentRemoveApp($requestId: String!) {
772
822
  agentRemoveApp(requestId: $requestId) {
773
- ${ta}
823
+ ${ua}
774
824
  }
775
- }`,variables:{requestId:e}}));return t}async revokeToken(e){let{agentRevokeToken:t}=b(await Z(this,X,"f").mutate({mutation:v`mutation agentRevokeToken($requestId: String!) {
825
+ }`,variables:{requestId:e}}));return t}async revokeToken(e){let{agentRevokeToken:t}=b(await V(this,Y,"f").mutate({mutation:v`mutation agentRevokeToken($requestId: String!) {
776
826
  agentRevokeToken(requestId: $requestId) {
777
- ${ta}
827
+ ${ua}
778
828
  }
779
- }`,variables:{requestId:e}}));return t}async isLocked(){let{agentIsLocked:e}=b(await Z(this,X,"f").mutate({mutation:v`
829
+ }`,variables:{requestId:e}}));return t}async isLocked(){let{agentIsLocked:e}=b(await V(this,Y,"f").mutate({mutation:v`
780
830
  query agentIsLocked {
781
831
  agentIsLocked
782
832
  }
783
- `}));return e}async signMessage(e){let{agentSignMessage:t}=b(await Z(this,X,"f").mutate({mutation:v`mutation agentSignMessage($message: String!) {
833
+ `}));return e}async signMessage(e){let{agentSignMessage:t}=b(await V(this,Y,"f").mutate({mutation:v`mutation agentSignMessage($message: String!) {
784
834
  agentSignMessage(message: $message) {
785
- ${dp}
835
+ ${Cp}
786
836
  }
787
- }`,variables:{message:e}}));return t}async createUser(e,t,r){let{runtimeCreateUser:n}=b(await Z(this,X,"f").mutate({mutation:v`mutation runtimeCreateUser($email: String!, $password: String!, $appInfo: AuthInfoInput) {
837
+ }`,variables:{message:e}}));return t}async createUser(e,t,r){let{runtimeCreateUser:n}=b(await V(this,Y,"f").mutate({mutation:v`mutation runtimeCreateUser($email: String!, $password: String!, $appInfo: AuthInfoInput) {
788
838
  runtimeCreateUser(email: $email, password: $password, appInfo: $appInfo) {
789
839
  did
790
840
  success
791
841
  error
792
842
  }
793
- }`,variables:{email:e,password:t,appInfo:r}}));return n}async loginUser(e,t){let{runtimeLoginUser:r}=b(await Z(this,X,"f").mutate({mutation:v`mutation runtimeLoginUser($email: String!, $password: String!) {
843
+ }`,variables:{email:e,password:t,appInfo:r}}));return n}async loginUser(e,t){let{runtimeLoginUser:r}=b(await V(this,Y,"f").mutate({mutation:v`mutation runtimeLoginUser($email: String!, $password: String!) {
794
844
  runtimeLoginUser(email: $email, password: $password)
795
- }`,variables:{email:e,password:t}}));return r}async requestLoginVerification(e,t){let{runtimeRequestLoginVerification:r}=b(await Z(this,X,"f").mutate({mutation:v`mutation runtimeRequestLoginVerification($email: String!, $appInfo: AuthInfoInput) {
845
+ }`,variables:{email:e,password:t}}));return r}async requestLoginVerification(e,t){let{runtimeRequestLoginVerification:r}=b(await V(this,Y,"f").mutate({mutation:v`mutation runtimeRequestLoginVerification($email: String!, $appInfo: AuthInfoInput) {
796
846
  runtimeRequestLoginVerification(email: $email, appInfo: $appInfo) {
797
847
  success
798
848
  message
799
849
  requiresPassword
800
850
  isExistingUser
801
851
  }
802
- }`,variables:{email:e,appInfo:t}}));return r}async verifyEmailCode(e,t,r){let{runtimeVerifyEmailCode:n}=b(await Z(this,X,"f").mutate({mutation:v`mutation runtimeVerifyEmailCode($email: String!, $code: String!, $verificationType: String!) {
852
+ }`,variables:{email:e,appInfo:t}}));return r}async verifyEmailCode(e,t,r){let{runtimeVerifyEmailCode:n}=b(await V(this,Y,"f").mutate({mutation:v`mutation runtimeVerifyEmailCode($email: String!, $code: String!, $verificationType: String!) {
803
853
  runtimeVerifyEmailCode(email: $email, code: $code, verificationType: $verificationType)
804
- }`,variables:{email:e,code:t,verificationType:r}}));return n}async hostingUserInfo(){let{runtimeHostingUserInfo:e}=b(await Z(this,X,"f").query({query:v`query runtimeHostingUserInfo {
854
+ }`,variables:{email:e,code:t,verificationType:r}}));return n}async hostingUserInfo(){let{runtimeHostingUserInfo:e}=b(await V(this,Y,"f").query({query:v`query runtimeHostingUserInfo {
805
855
  runtimeHostingUserInfo {
806
856
  email
807
857
  remainingCredits
808
858
  hotWalletAddress
809
859
  freeAccess
810
860
  }
811
- }`}));return e}async setHotWalletAddress(e){let{runtimeSetHotWalletAddress:t}=b(await Z(this,X,"f").mutate({mutation:v`mutation runtimeSetHotWalletAddress($address: String!) {
861
+ }`}));return e}async computeLog(e,t,r){let{runtimeComputeLog:n}=b(await V(this,Y,"f").query({query:v`query runtimeComputeLog($since: String, $limit: Int, $userEmail: String) {
862
+ runtimeComputeLog(since: $since, limit: $limit, userEmail: $userEmail) {
863
+ id
864
+ userEmail
865
+ timestamp
866
+ operation
867
+ summary
868
+ cost
869
+ creditsAfter
870
+ }
871
+ }`,variables:{since:e,limit:t,userEmail:r},fetchPolicy:"network-only"}));return n}async setHotWalletAddress(e){let{runtimeSetHotWalletAddress:t}=b(await V(this,Y,"f").mutate({mutation:v`mutation runtimeSetHotWalletAddress($address: String!) {
812
872
  runtimeSetHotWalletAddress(address: $address)
813
- }`,variables:{address:e}}));return t}async requestPayment(e){let{runtimeRequestPayment:t}=b(await Z(this,X,"f").mutate({mutation:v`mutation runtimeRequestPayment($amountHOT: String!) {
873
+ }`,variables:{address:e}}));return t}async requestPayment(e){let{runtimeRequestPayment:t}=b(await V(this,Y,"f").mutate({mutation:v`mutation runtimeRequestPayment($amountHOT: String!) {
814
874
  runtimeRequestPayment(amountHOT: $amountHOT) {
815
875
  success
816
876
  message
817
877
  }
818
- }`,variables:{amountHOT:e}}));return t}};X=new WeakMap,tn=new WeakMap,rn=new WeakMap,nn=new WeakMap;var pp=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},Qt=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},yt,xc=`
878
+ }`,variables:{amountHOT:e}}));return t}};Y=new WeakMap,cn=new WeakMap,ln=new WeakMap,un=new WeakMap,dn=new WeakMap,pn=new WeakMap;var Lp=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},Zt=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},yt,Uc=`
819
879
  name
820
880
  address
821
881
  settings
822
882
  icon { code }
823
883
  constructorIcon { code }
824
884
  settingsIcon { code }
825
- `,Ec=`
885
+ `,Dc=`
826
886
  name
827
887
  address
828
888
  description
@@ -832,45 +892,45 @@ neighbourhood {
832
892
  templateAppliedParams
833
893
  possibleTemplateParams
834
894
  sourceCodeLink
835
- `,to=class{constructor(e){yt.set(this,void 0),pp(this,yt,e,"f")}async byAddress(e){let{language:t}=b(await Qt(this,yt,"f").query({query:v`query byAddress($address: String!) {
895
+ `,po=class{constructor(e){yt.set(this,void 0),Lp(this,yt,e,"f")}async byAddress(e){let{language:t}=b(await Zt(this,yt,"f").query({query:v`query byAddress($address: String!) {
836
896
  language(address: $address) {
837
- ${xc}
897
+ ${Uc}
838
898
  }
839
- }`,variables:{address:e}}));return t}async byFilter(e){let{languages:t}=b(await Qt(this,yt,"f").query({query:v`query byFilter($filter: String!) {
899
+ }`,variables:{address:e}}));return t}async byFilter(e){let{languages:t}=b(await Zt(this,yt,"f").query({query:v`query byFilter($filter: String!) {
840
900
  languages(filter: $filter) {
841
- ${xc}
901
+ ${Uc}
842
902
  }
843
- }`,variables:{filter:e}}));return t}async all(){return this.byFilter("")}async writeSettings(e,t){let{languageWriteSettings:r}=b(await Qt(this,yt,"f").mutate({mutation:v`mutation writeSettings($languageAddress: String!, $settings: String!) {
903
+ }`,variables:{filter:e}}));return t}async all(){return this.byFilter("")}async writeSettings(e,t){let{languageWriteSettings:r}=b(await Zt(this,yt,"f").mutate({mutation:v`mutation writeSettings($languageAddress: String!, $settings: String!) {
844
904
  languageWriteSettings(languageAddress: $languageAddress, settings: $settings)
845
- }`,variables:{languageAddress:e,settings:t}}));return r}async applyTemplateAndPublish(e,t){let{languageApplyTemplateAndPublish:r}=b(await Qt(this,yt,"f").mutate({mutation:v`mutation languageApplyTemplateAndPublish(
905
+ }`,variables:{languageAddress:e,settings:t}}));return r}async applyTemplateAndPublish(e,t){let{languageApplyTemplateAndPublish:r}=b(await Zt(this,yt,"f").mutate({mutation:v`mutation languageApplyTemplateAndPublish(
846
906
  $sourceLanguageHash: String!,
847
907
  $templateData: String!,
848
908
  ) {
849
909
  languageApplyTemplateAndPublish(sourceLanguageHash: $sourceLanguageHash, templateData: $templateData) {
850
910
  name, address
851
911
  }
852
- }`,variables:{sourceLanguageHash:e,templateData:t}}));return r}async publish(e,t){let{languagePublish:r}=b(await Qt(this,yt,"f").mutate({mutation:v`mutation languagePublish(
912
+ }`,variables:{sourceLanguageHash:e,templateData:t}}));return r}async publish(e,t){let{languagePublish:r}=b(await Zt(this,yt,"f").mutate({mutation:v`mutation languagePublish(
853
913
  $languagePath: String!,
854
914
  $languageMeta: LanguageMetaInput!,
855
915
  ) {
856
916
  languagePublish(languagePath: $languagePath, languageMeta: $languageMeta) {
857
- ${Ec}
917
+ ${Dc}
858
918
  }
859
- }`,variables:{languagePath:e,languageMeta:t}}));return r}async meta(e){let{languageMeta:t}=b(await Qt(this,yt,"f").query({query:v`query languageMeta(
919
+ }`,variables:{languagePath:e,languageMeta:t}}));return r}async meta(e){let{languageMeta:t}=b(await Zt(this,yt,"f").query({query:v`query languageMeta(
860
920
  $address: String!,
861
921
  ) {
862
922
  languageMeta(address: $address) {
863
- ${Ec}
923
+ ${Dc}
864
924
  }
865
- }`,variables:{address:e}}));return t}async source(e){let{languageSource:t}=b(await Qt(this,yt,"f").query({query:v`query languageSource(
925
+ }`,variables:{address:e}}));return t}async source(e){let{languageSource:t}=b(await Zt(this,yt,"f").query({query:v`query languageSource(
866
926
  $address: String!,
867
927
  ) {
868
928
  languageSource(address: $address)
869
- }`,variables:{address:e}}));return t}async remove(e){let{languageRemove:t}=b(await Qt(this,yt,"f").mutate({mutation:v`mutation languageRemove(
929
+ }`,variables:{address:e}}));return t}async remove(e){let{languageRemove:t}=b(await Zt(this,yt,"f").mutate({mutation:v`mutation languageRemove(
870
930
  $address: String!,
871
931
  ) {
872
932
  languageRemove(address: $address)
873
- }`,variables:{address:e}}));return t}};yt=new WeakMap;var fp=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},Oe=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Be,gr,io=class{constructor(e){Be.set(this,void 0),gr.set(this,new Map),fp(this,Be,e,"f")}async publishFromPerspective(e,t,r){let{neighbourhoodPublishFromPerspective:n}=b(await Oe(this,Be,"f").mutate({mutation:v`mutation neighbourhoodPublishFromPerspective(
933
+ }`,variables:{address:e}}));return t}};yt=new WeakMap;var Pp=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},Oe=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},qe,Sr,fo=class{constructor(e){qe.set(this,void 0),Sr.set(this,new Map),Pp(this,qe,e,"f")}async publishFromPerspective(e,t,r){let{neighbourhoodPublishFromPerspective:n}=b(await Oe(this,qe,"f").mutate({mutation:v`mutation neighbourhoodPublishFromPerspective(
874
934
  $linkLanguage: String!,
875
935
  $meta: PerspectiveInput!,
876
936
  $perspectiveUUID: String!
@@ -880,7 +940,7 @@ neighbourhood {
880
940
  meta: $meta,
881
941
  perspectiveUUID: $perspectiveUUID
882
942
  )
883
- }`,variables:{perspectiveUUID:e,linkLanguage:t,meta:r}}));return n}async joinFromUrl(e){let{neighbourhoodJoinFromUrl:t}=b(await Oe(this,Be,"f").mutate({mutation:v`mutation neighbourhoodJoinFromUrl($url: String!) {
943
+ }`,variables:{perspectiveUUID:e,linkLanguage:t,meta:r}}));return n}async joinFromUrl(e){let{neighbourhoodJoinFromUrl:t}=b(await Oe(this,qe,"f").mutate({mutation:v`mutation neighbourhoodJoinFromUrl($url: String!) {
884
944
  neighbourhoodJoinFromUrl(url: $url) {
885
945
  uuid
886
946
  name
@@ -902,11 +962,11 @@ neighbourhood {
902
962
  author
903
963
  }
904
964
  }
905
- }`,variables:{url:e}}));return t}async otherAgents(e){let{neighbourhoodOtherAgents:t}=b(await Oe(this,Be,"f").query({query:v`query neighbourhoodOtherAgents($perspectiveUUID: String!) {
965
+ }`,variables:{url:e}}));return t}async otherAgents(e){let{neighbourhoodOtherAgents:t}=b(await Oe(this,qe,"f").query({query:v`query neighbourhoodOtherAgents($perspectiveUUID: String!) {
906
966
  neighbourhoodOtherAgents(perspectiveUUID: $perspectiveUUID)
907
- }`,variables:{perspectiveUUID:e}}));return t}async hasTelepresenceAdapter(e){let{neighbourhoodHasTelepresenceAdapter:t}=b(await Oe(this,Be,"f").query({query:v`query neighbourhoodHasTelepresenceAdapter($perspectiveUUID: String!) {
967
+ }`,variables:{perspectiveUUID:e}}));return t}async hasTelepresenceAdapter(e){let{neighbourhoodHasTelepresenceAdapter:t}=b(await Oe(this,qe,"f").query({query:v`query neighbourhoodHasTelepresenceAdapter($perspectiveUUID: String!) {
908
968
  neighbourhoodHasTelepresenceAdapter(perspectiveUUID: $perspectiveUUID)
909
- }`,variables:{perspectiveUUID:e}}));return t}async onlineAgents(e){let{neighbourhoodOnlineAgents:t}=b(await Oe(this,Be,"f").query({query:v`query neighbourhoodOnlineAgents($perspectiveUUID: String!) {
969
+ }`,variables:{perspectiveUUID:e}}));return t}async onlineAgents(e){let{neighbourhoodOnlineAgents:t}=b(await Oe(this,qe,"f").query({query:v`query neighbourhoodOnlineAgents($perspectiveUUID: String!) {
910
970
  neighbourhoodOnlineAgents(perspectiveUUID: $perspectiveUUID) {
911
971
  did
912
972
  status {
@@ -923,7 +983,7 @@ neighbourhood {
923
983
  proof { valid, invalid, signature, key }
924
984
  }
925
985
  }
926
- }`,variables:{perspectiveUUID:e}}));return t}async setOnlineStatus(e,t){let{neighbourhoodSetOnlineStatus:r}=b(await Oe(this,Be,"f").mutate({mutation:v`mutation neighbourhoodSetOnlineStatus(
986
+ }`,variables:{perspectiveUUID:e}}));return t}async setOnlineStatus(e,t){let{neighbourhoodSetOnlineStatus:r}=b(await Oe(this,qe,"f").mutate({mutation:v`mutation neighbourhoodSetOnlineStatus(
927
987
  $perspectiveUUID: String!,
928
988
  $status: PerspectiveInput!
929
989
  ) {
@@ -931,7 +991,7 @@ neighbourhood {
931
991
  perspectiveUUID: $perspectiveUUID,
932
992
  status: $status
933
993
  )
934
- }`,variables:{perspectiveUUID:e,status:t}}));return r}async setOnlineStatusU(e,t){let{neighbourhoodSetOnlineStatusU:r}=b(await Oe(this,Be,"f").mutate({mutation:v`mutation neighbourhoodSetOnlineStatusU(
994
+ }`,variables:{perspectiveUUID:e,status:t}}));return r}async setOnlineStatusU(e,t){let{neighbourhoodSetOnlineStatusU:r}=b(await Oe(this,qe,"f").mutate({mutation:v`mutation neighbourhoodSetOnlineStatusU(
935
995
  $perspectiveUUID: String!,
936
996
  $status: PerspectiveUnsignedInput!
937
997
  ) {
@@ -939,7 +999,7 @@ neighbourhood {
939
999
  perspectiveUUID: $perspectiveUUID,
940
1000
  status: $status
941
1001
  )
942
- }`,variables:{perspectiveUUID:e,status:t}}));return r}async sendSignal(e,t,r){let{neighbourhoodSendSignal:n}=b(await Oe(this,Be,"f").mutate({mutation:v`mutation neighbourhoodSendSignal(
1002
+ }`,variables:{perspectiveUUID:e,status:t}}));return r}async sendSignal(e,t,r){let{neighbourhoodSendSignal:n}=b(await Oe(this,qe,"f").mutate({mutation:v`mutation neighbourhoodSendSignal(
943
1003
  $perspectiveUUID: String!,
944
1004
  $remoteAgentDid: String!,
945
1005
  $payload: PerspectiveInput!
@@ -949,7 +1009,7 @@ neighbourhood {
949
1009
  remoteAgentDid: $remoteAgentDid,
950
1010
  payload: $payload
951
1011
  )
952
- }`,variables:{perspectiveUUID:e,remoteAgentDid:t,payload:r}}));return n}async sendSignalU(e,t,r){let{neighbourhoodSendSignalU:n}=b(await Oe(this,Be,"f").mutate({mutation:v`mutation neighbourhoodSendSignalU(
1012
+ }`,variables:{perspectiveUUID:e,remoteAgentDid:t,payload:r}}));return n}async sendSignalU(e,t,r){let{neighbourhoodSendSignalU:n}=b(await Oe(this,qe,"f").mutate({mutation:v`mutation neighbourhoodSendSignalU(
953
1013
  $perspectiveUUID: String!,
954
1014
  $remoteAgentDid: String!,
955
1015
  $payload: PerspectiveUnsignedInput!
@@ -959,7 +1019,7 @@ neighbourhood {
959
1019
  remoteAgentDid: $remoteAgentDid,
960
1020
  payload: $payload
961
1021
  )
962
- }`,variables:{perspectiveUUID:e,remoteAgentDid:t,payload:r}}));return n}async sendBroadcast(e,t,r=!1){let{neighbourhoodSendBroadcast:n}=b(await Oe(this,Be,"f").mutate({mutation:v`mutation neighbourhoodSendBroadcast(
1022
+ }`,variables:{perspectiveUUID:e,remoteAgentDid:t,payload:r}}));return n}async sendBroadcast(e,t,r=!1){let{neighbourhoodSendBroadcast:n}=b(await Oe(this,qe,"f").mutate({mutation:v`mutation neighbourhoodSendBroadcast(
963
1023
  $perspectiveUUID: String!,
964
1024
  $payload: PerspectiveInput!,
965
1025
  $loopback: Boolean
@@ -969,7 +1029,7 @@ neighbourhood {
969
1029
  payload: $payload,
970
1030
  loopback: $loopback
971
1031
  )
972
- }`,variables:{perspectiveUUID:e,payload:t,loopback:r}}));return n}async sendBroadcastU(e,t,r=!1){let{neighbourhoodSendBroadcastU:n}=b(await Oe(this,Be,"f").mutate({mutation:v`mutation neighbourhoodSendBroadcastU(
1032
+ }`,variables:{perspectiveUUID:e,payload:t,loopback:r}}));return n}async sendBroadcastU(e,t,r=!1){let{neighbourhoodSendBroadcastU:n}=b(await Oe(this,qe,"f").mutate({mutation:v`mutation neighbourhoodSendBroadcastU(
973
1033
  $perspectiveUUID: String!,
974
1034
  $payload: PerspectiveUnsignedInput!,
975
1035
  $loopback: Boolean
@@ -979,7 +1039,7 @@ neighbourhood {
979
1039
  payload: $payload,
980
1040
  loopback: $loopback
981
1041
  )
982
- }`,variables:{perspectiveUUID:e,payload:t,loopback:r}}));return n}dispatchSignal(e,t){let r=Oe(this,gr,"f").get(e);if(r)for(let n of r)try{n(t)}catch(a){console.error("Error in signal handler:",a)}}async subscribeToSignals(e){let t=this;Oe(this,Be,"f").subscribe({query:v`subscription neighbourhoodSignal($perspectiveUUID: String!) {
1042
+ }`,variables:{perspectiveUUID:e,payload:t,loopback:r}}));return n}dispatchSignal(e,t){let r=Oe(this,Sr,"f").get(e);if(r)for(let n of r)try{n(t)}catch(a){console.error("Error in signal handler:",a)}}async subscribeToSignals(e){let t=this;Oe(this,qe,"f").subscribe({query:v`subscription neighbourhoodSignal($perspectiveUUID: String!) {
983
1043
  neighbourhoodSignal(perspectiveUUID: $perspectiveUUID) {
984
1044
  author
985
1045
  timestamp
@@ -994,7 +1054,7 @@ neighbourhood {
994
1054
  }
995
1055
  proof { valid, invalid, signature, key }
996
1056
  }
997
- }`,variables:{perspectiveUUID:e}}).subscribe({next:r=>{try{let{neighbourhoodSignal:n}=b(r);t.dispatchSignal(e,n)}catch(n){console.error("Error in signal subscription:",n)}},error:r=>{console.error("Signal subscription error for perspective",e,r)}})}async addSignalHandler(e,t){let r=Oe(this,gr,"f").get(e);r?r.push(t):(r=[],Oe(this,gr,"f").set(e,r),r.push(t),await this.subscribeToSignals(e))}removeSignalHandler(e,t){let r=Oe(this,gr,"f").get(e);if(r){let n=r.indexOf(t);n>-1&&r.splice(n,1)}}};Be=new WeakMap,gr=new WeakMap;var ra=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},N=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},D,an,sn,on,Zl,na=`
1057
+ }`,variables:{perspectiveUUID:e}}).subscribe({next:r=>{try{let{neighbourhoodSignal:n}=b(r);t.dispatchSignal(e,n)}catch(n){console.error("Error in signal subscription:",n)}},error:r=>{console.error("Signal subscription error for perspective",e,r)}})}async addSignalHandler(e,t){let r=Oe(this,Sr,"f").get(e);r?r.push(t):(r=[],Oe(this,Sr,"f").set(e,r),r.push(t),await this.subscribeToSignals(e))}removeSignalHandler(e,t){let r=Oe(this,Sr,"f").get(e);if(r){let n=r.indexOf(t);n>-1&&r.splice(n,1)}}};qe=new WeakMap,Sr=new WeakMap;var pa=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},O=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},U,fn,hn,gn,uu,fa=`
998
1058
  author
999
1059
  timestamp
1000
1060
  data {
@@ -1006,7 +1066,7 @@ data {
1006
1066
  }
1007
1067
  }
1008
1068
  proof { valid, invalid, signature, key }
1009
- `,hp=`
1069
+ `,Rp=`
1010
1070
  description
1011
1071
  appName
1012
1072
  appUrl
@@ -1015,74 +1075,74 @@ trigger
1015
1075
  perspectiveIds
1016
1076
  webhookUrl
1017
1077
  webhookAuth
1018
- `,Jl=`
1078
+ `,du=`
1019
1079
  id
1020
1080
  granted
1021
- ${hp}
1022
- `,gp=`
1023
- notification { ${Jl} }
1081
+ ${Rp}
1082
+ `,Np=`
1083
+ notification { ${du} }
1024
1084
  perspectiveId
1025
1085
  triggerMatch
1026
- `,ro=class{constructor(e,t=!0){D.set(this,void 0),an.set(this,void 0),sn.set(this,void 0),on.set(this,void 0),Zl.set(this,void 0),ra(this,D,e,"f"),ra(this,an,[],"f"),ra(this,sn,[],"f"),ra(this,on,[],"f"),t&&(this.subscribeMessageReceived(),this.subscribeExceptionOccurred(),this.subscribeNotificationTriggered())}async info(){let{runtimeInfo:e}=b(await N(this,D,"f").query({query:v`query runtimeInfo {
1086
+ `,ho=class{constructor(e,t=!0){U.set(this,void 0),fn.set(this,void 0),hn.set(this,void 0),gn.set(this,void 0),uu.set(this,void 0),pa(this,U,e,"f"),pa(this,fn,[],"f"),pa(this,hn,[],"f"),pa(this,gn,[],"f"),t&&(this.subscribeMessageReceived(),this.subscribeExceptionOccurred(),this.subscribeNotificationTriggered())}async info(){let{runtimeInfo:e}=b(await O(this,U,"f").query({query:v`query runtimeInfo {
1027
1087
  runtimeInfo {
1028
1088
  ad4mExecutorVersion,
1029
1089
  isInitialized,
1030
1090
  isUnlocked
1031
1091
  }
1032
- }`}));return e}async tlsDomain(){let{runtimeTlsDomain:e}=b(await N(this,D,"f").query({query:v`query runtimeTlsDomain {
1092
+ }`}));return e}async tlsDomain(){let{runtimeTlsDomain:e}=b(await O(this,U,"f").query({query:v`query runtimeTlsDomain {
1033
1093
  runtimeTlsDomain
1034
- }`}));return e}async quit(){return b(await N(this,D,"f").mutate({mutation:v`mutation runtimeQuit { runtimeQuit }`})).runtimeQuit}async openLink(e){let{runtimeOpenLink:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeOpenLink($url: String!) {
1094
+ }`}));return e}async quit(){return b(await O(this,U,"f").mutate({mutation:v`mutation runtimeQuit { runtimeQuit }`})).runtimeQuit}async openLink(e){let{runtimeOpenLink:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeOpenLink($url: String!) {
1035
1095
  runtimeOpenLink(url: $url)
1036
- }`,variables:{url:e}}));return t}async addTrustedAgents(e){let{addTrustedAgents:t}=b(await N(this,D,"f").mutate({mutation:v`mutation addTrustedAgents($agents: [String!]!) {
1096
+ }`,variables:{url:e}}));return t}async addTrustedAgents(e){let{addTrustedAgents:t}=b(await O(this,U,"f").mutate({mutation:v`mutation addTrustedAgents($agents: [String!]!) {
1037
1097
  addTrustedAgents(agents: $agents)
1038
- }`,variables:{agents:e}}));return t}async deleteTrustedAgents(e){let{deleteTrustedAgents:t}=b(await N(this,D,"f").mutate({mutation:v`mutation deleteTrustedAgents($agents: [String!]!) {
1098
+ }`,variables:{agents:e}}));return t}async deleteTrustedAgents(e){let{deleteTrustedAgents:t}=b(await O(this,U,"f").mutate({mutation:v`mutation deleteTrustedAgents($agents: [String!]!) {
1039
1099
  deleteTrustedAgents(agents: $agents)
1040
- }`,variables:{agents:e}}));return t}async getTrustedAgents(){let{getTrustedAgents:e}=b(await N(this,D,"f").query({query:v`query getTrustedAgents {
1100
+ }`,variables:{agents:e}}));return t}async getTrustedAgents(){let{getTrustedAgents:e}=b(await O(this,U,"f").query({query:v`query getTrustedAgents {
1041
1101
  getTrustedAgents
1042
- }`}));return e}async addKnownLinkLanguageTemplates(e){let{runtimeAddKnownLinkLanguageTemplates:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeAddKnownLinkLanguageTemplates($addresses: [String!]!) {
1102
+ }`}));return e}async addKnownLinkLanguageTemplates(e){let{runtimeAddKnownLinkLanguageTemplates:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeAddKnownLinkLanguageTemplates($addresses: [String!]!) {
1043
1103
  runtimeAddKnownLinkLanguageTemplates(addresses: $addresses)
1044
- }`,variables:{addresses:e}}));return t}async removeKnownLinkLanguageTemplates(e){let{runtimeRemoveKnownLinkLanguageTemplates:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeRemoveKnownLinkLanguageTemplates($addresses: [String!]!) {
1104
+ }`,variables:{addresses:e}}));return t}async removeKnownLinkLanguageTemplates(e){let{runtimeRemoveKnownLinkLanguageTemplates:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeRemoveKnownLinkLanguageTemplates($addresses: [String!]!) {
1045
1105
  runtimeRemoveKnownLinkLanguageTemplates(addresses: $addresses)
1046
- }`,variables:{addresses:e}}));return t}async knownLinkLanguageTemplates(){let{runtimeKnownLinkLanguageTemplates:e}=b(await N(this,D,"f").query({query:v`query runtimeKnownLinkLanguageTemplates {
1106
+ }`,variables:{addresses:e}}));return t}async knownLinkLanguageTemplates(){let{runtimeKnownLinkLanguageTemplates:e}=b(await O(this,U,"f").query({query:v`query runtimeKnownLinkLanguageTemplates {
1047
1107
  runtimeKnownLinkLanguageTemplates
1048
- }`}));return e}async addFriends(e){let{runtimeAddFriends:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeAddFriends($dids: [String!]!) {
1108
+ }`}));return e}async addFriends(e){let{runtimeAddFriends:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeAddFriends($dids: [String!]!) {
1049
1109
  runtimeAddFriends(dids: $dids)
1050
- }`,variables:{dids:e}}));return t}async removeFriends(e){let{runtimeRemoveFriends:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeRemoveFriends($dids: [String!]!) {
1110
+ }`,variables:{dids:e}}));return t}async removeFriends(e){let{runtimeRemoveFriends:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeRemoveFriends($dids: [String!]!) {
1051
1111
  runtimeRemoveFriends(dids: $dids)
1052
- }`,variables:{dids:e}}));return t}async friends(){let{runtimeFriends:e}=b(await N(this,D,"f").query({query:v`query runtimeFriends {
1112
+ }`,variables:{dids:e}}));return t}async friends(){let{runtimeFriends:e}=b(await O(this,U,"f").query({query:v`query runtimeFriends {
1053
1113
  runtimeFriends
1054
- }`}));return e}async hcAgentInfos(){let{runtimeHcAgentInfos:e}=b(await N(this,D,"f").query({query:v`query runtimeHcAgentInfos {
1114
+ }`}));return e}async hcAgentInfos(){let{runtimeHcAgentInfos:e}=b(await O(this,U,"f").query({query:v`query runtimeHcAgentInfos {
1055
1115
  runtimeHcAgentInfos
1056
- }`}));return e}async getNetworkMetrics(){let{runtimeGetNetworkMetrics:e}=b(await N(this,D,"f").query({query:v`query runtimeGetNetworkMetrics {
1116
+ }`}));return e}async getNetworkMetrics(){let{runtimeGetNetworkMetrics:e}=b(await O(this,U,"f").query({query:v`query runtimeGetNetworkMetrics {
1057
1117
  runtimeGetNetworkMetrics
1058
- }`}));return e}async restartHolochain(){let{runtimeRestartHolochain:e}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeRestartHolochain {
1118
+ }`}));return e}async restartHolochain(){let{runtimeRestartHolochain:e}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeRestartHolochain {
1059
1119
  runtimeRestartHolochain
1060
- }`}));return e}async hcAddAgentInfos(e){let{runtimeHcAddAgentInfos:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeHcAddAgentInfos($agentInfos: String!) {
1120
+ }`}));return e}async hcAddAgentInfos(e){let{runtimeHcAddAgentInfos:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeHcAddAgentInfos($agentInfos: String!) {
1061
1121
  runtimeHcAddAgentInfos(agentInfos: $agentInfos)
1062
- }`,variables:{agentInfos:e}}));return t}async verifyStringSignedByDid(e,t,r,n){let{runtimeVerifyStringSignedByDid:a}=b(await N(this,D,"f").mutate({mutation:v`query runtimeVerifyStringSignedByDid($did: String!, $didSigningKeyId: String!, $data: String!, $signedData: String!) {
1122
+ }`,variables:{agentInfos:e}}));return t}async verifyStringSignedByDid(e,t,r,n){let{runtimeVerifyStringSignedByDid:a}=b(await O(this,U,"f").mutate({mutation:v`query runtimeVerifyStringSignedByDid($did: String!, $didSigningKeyId: String!, $data: String!, $signedData: String!) {
1063
1123
  runtimeVerifyStringSignedByDid(did: $did, didSigningKeyId: $didSigningKeyId, data: $data, signedData: $signedData)
1064
- }`,variables:{did:e,didSigningKeyId:t,data:r,signedData:n}}));return a}async setStatus(e){let{runtimeSetStatus:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeSetStatus($status: PerspectiveInput!) {
1124
+ }`,variables:{did:e,didSigningKeyId:t,data:r,signedData:n}}));return a}async setStatus(e){let{runtimeSetStatus:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeSetStatus($status: PerspectiveInput!) {
1065
1125
  runtimeSetStatus(status: $status)
1066
- }`,variables:{status:e}}));return t}async friendStatus(e){let{runtimeFriendStatus:t}=b(await N(this,D,"f").query({query:v`query runtimeFriendStatus($did: String!) {
1067
- runtimeFriendStatus(did: $did) { ${na} }
1068
- }`,variables:{did:e}}));return t}async friendSendMessage(e,t){let{runtimeFriendSendMessage:r}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeFriendSendMessage($did: String!, $message: PerspectiveInput!) {
1126
+ }`,variables:{status:e}}));return t}async friendStatus(e){let{runtimeFriendStatus:t}=b(await O(this,U,"f").query({query:v`query runtimeFriendStatus($did: String!) {
1127
+ runtimeFriendStatus(did: $did) { ${fa} }
1128
+ }`,variables:{did:e}}));return t}async friendSendMessage(e,t){let{runtimeFriendSendMessage:r}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeFriendSendMessage($did: String!, $message: PerspectiveInput!) {
1069
1129
  runtimeFriendSendMessage(did: $did, message: $message)
1070
- }`,variables:{did:e,message:t}}));return r}async messageInbox(e){let{runtimeMessageInbox:t}=b(await N(this,D,"f").query({query:v`query runtimeMessageInbox($filter: String) {
1071
- runtimeMessageInbox(filter: $filter) { ${na} }
1072
- }`,variables:{filter:e}}));return t}async messageOutbox(e){let{runtimeMessageOutbox:t}=b(await N(this,D,"f").query({query:v`query runtimeMessageOutbox($filter: String) {
1130
+ }`,variables:{did:e,message:t}}));return r}async messageInbox(e){let{runtimeMessageInbox:t}=b(await O(this,U,"f").query({query:v`query runtimeMessageInbox($filter: String) {
1131
+ runtimeMessageInbox(filter: $filter) { ${fa} }
1132
+ }`,variables:{filter:e}}));return t}async messageOutbox(e){let{runtimeMessageOutbox:t}=b(await O(this,U,"f").query({query:v`query runtimeMessageOutbox($filter: String) {
1073
1133
  runtimeMessageOutbox(filter: $filter) {
1074
1134
  recipient,
1075
1135
  message {
1076
- ${na}
1136
+ ${fa}
1077
1137
  }
1078
1138
  }
1079
- }`,variables:{filter:e}}));return t}async requestInstallNotification(e){let{runtimeRequestInstallNotification:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeRequestInstallNotification($notification: NotificationInput!) {
1139
+ }`,variables:{filter:e}}));return t}async requestInstallNotification(e){let{runtimeRequestInstallNotification:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeRequestInstallNotification($notification: NotificationInput!) {
1080
1140
  runtimeRequestInstallNotification(notification: $notification)
1081
- }`,variables:{notification:e}}));return t}async grantNotification(e){let{runtimeGrantNotification:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeGrantNotification($id: String!) {
1141
+ }`,variables:{notification:e}}));return t}async grantNotification(e){let{runtimeGrantNotification:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeGrantNotification($id: String!) {
1082
1142
  runtimeGrantNotification(id: $id)
1083
- }`,variables:{id:e}}));return t}async exportDb(e){let{runtimeExportDb:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeExportDb($filePath: String!) {
1143
+ }`,variables:{id:e}}));return t}async exportDb(e){let{runtimeExportDb:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeExportDb($filePath: String!) {
1084
1144
  runtimeExportDb(filePath: $filePath)
1085
- }`,variables:{filePath:e}}));return t}async importDb(e){let{runtimeImportDb:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeImportDb($filePath: String!) {
1145
+ }`,variables:{filePath:e}}));return t}async importDb(e){let{runtimeImportDb:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeImportDb($filePath: String!) {
1086
1146
  runtimeImportDb(filePath: $filePath) {
1087
1147
  perspectives { total imported failed omitted errors }
1088
1148
  links { total imported failed omitted errors }
@@ -1096,21 +1156,25 @@ triggerMatch
1096
1156
  trustedAgents { total imported failed omitted errors }
1097
1157
  knownLinkLanguages { total imported failed omitted errors }
1098
1158
  }
1099
- }`,variables:{filePath:e}}));return t}async notifications(){let{runtimeNotifications:e}=b(await N(this,D,"f").query({query:v`query runtimeNotifications {
1100
- runtimeNotifications { ${Jl} }
1101
- }`}));return e}async updateNotification(e,t){let{runtimeUpdateNotification:r}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeUpdateNotification($id: String!, $notification: NotificationInput!) {
1159
+ }`,variables:{filePath:e}}));return t}async notifications(){let{runtimeNotifications:e}=b(await O(this,U,"f").query({query:v`query runtimeNotifications {
1160
+ runtimeNotifications { ${du} }
1161
+ }`}));return e}async updateNotification(e,t){let{runtimeUpdateNotification:r}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeUpdateNotification($id: String!, $notification: NotificationInput!) {
1102
1162
  runtimeUpdateNotification(id: $id, notification: $notification)
1103
- }`,variables:{id:e,notification:t}}));return r}async removeNotification(e){let{runtimeRemoveNotification:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeRemoveNotification($id: String!) {
1163
+ }`,variables:{id:e,notification:t}}));return r}async removeNotification(e){let{runtimeRemoveNotification:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeRemoveNotification($id: String!) {
1104
1164
  runtimeRemoveNotification(id: $id)
1105
- }`,variables:{id:e}}));return t}async exportPerspective(e,t){let{runtimeExportPerspective:r}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeExportPerspective($perspectiveUuid: String!, $filePath: String!) {
1165
+ }`,variables:{id:e}}));return t}async exportPerspective(e,t){let{runtimeExportPerspective:r}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeExportPerspective($perspectiveUuid: String!, $filePath: String!) {
1106
1166
  runtimeExportPerspective(perspectiveUuid: $perspectiveUuid, filePath: $filePath)
1107
- }`,variables:{perspectiveUuid:e,filePath:t}}));return r}async importPerspective(e){let{runtimeImportPerspective:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeImportPerspective($filePath: String!) {
1167
+ }`,variables:{perspectiveUuid:e,filePath:t}}));return r}async importPerspective(e){let{runtimeImportPerspective:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeImportPerspective($filePath: String!) {
1108
1168
  runtimeImportPerspective(filePath: $filePath)
1109
- }`,variables:{filePath:e}}));return t}async multiUserEnabled(){let{runtimeMultiUserEnabled:e}=b(await N(this,D,"f").query({query:v`query runtimeMultiUserEnabled {
1169
+ }`,variables:{filePath:e}}));return t}async multiUserEnabled(){let{runtimeMultiUserEnabled:e}=b(await O(this,U,"f").query({query:v`query runtimeMultiUserEnabled {
1110
1170
  runtimeMultiUserEnabled
1111
- }`}));return e}async setMultiUserEnabled(e){let{runtimeSetMultiUserEnabled:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeSetMultiUserEnabled($enabled: Boolean!) {
1171
+ }`}));return e}async setMultiUserEnabled(e){let{runtimeSetMultiUserEnabled:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeSetMultiUserEnabled($enabled: Boolean!) {
1112
1172
  runtimeSetMultiUserEnabled(enabled: $enabled)
1113
- }`,variables:{enabled:e}}));return t}async listUsers(){let{runtimeListUsers:e}=b(await N(this,D,"f").query({query:v`query runtimeListUsers {
1173
+ }`,variables:{enabled:e}}));return t}async freeHostingEnabled(){let{runtimeFreeHostingEnabled:e}=b(await O(this,U,"f").query({query:v`query runtimeFreeHostingEnabled {
1174
+ runtimeFreeHostingEnabled
1175
+ }`}));return e}async setFreeHostingEnabled(e){let{runtimeSetFreeHostingEnabled:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeSetFreeHostingEnabled($enabled: Boolean!) {
1176
+ runtimeSetFreeHostingEnabled(enabled: $enabled)
1177
+ }`,variables:{enabled:e}}));return t}async listUsers(){let{runtimeListUsers:e}=b(await O(this,U,"f").query({query:v`query runtimeListUsers {
1114
1178
  runtimeListUsers {
1115
1179
  email
1116
1180
  did
@@ -1120,48 +1184,48 @@ triggerMatch
1120
1184
  freeAccess
1121
1185
  hotWalletAddress
1122
1186
  }
1123
- }`}));return e}async userWalletAddress(e){let{runtimeUserWalletAddress:t}=b(await N(this,D,"f").query({query:v`query runtimeUserWalletAddress($email: String!) {
1187
+ }`}));return e}async userWalletAddress(e){let{runtimeUserWalletAddress:t}=b(await O(this,U,"f").query({query:v`query runtimeUserWalletAddress($email: String!) {
1124
1188
  runtimeUserWalletAddress(email: $email)
1125
- }`,variables:{email:e}}));return t}async emailTestModeEnable(){let{runtimeEmailTestModeEnable:e}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeEmailTestModeEnable {
1189
+ }`,variables:{email:e}}));return t}async emailTestModeEnable(){let{runtimeEmailTestModeEnable:e}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeEmailTestModeEnable {
1126
1190
  runtimeEmailTestModeEnable
1127
- }`}));return e}async emailTestModeDisable(){let{runtimeEmailTestModeDisable:e}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeEmailTestModeDisable {
1191
+ }`}));return e}async emailTestModeDisable(){let{runtimeEmailTestModeDisable:e}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeEmailTestModeDisable {
1128
1192
  runtimeEmailTestModeDisable
1129
- }`}));return e}async emailTestGetCode(e){let{runtimeEmailTestGetCode:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeEmailTestGetCode($email: String!) {
1193
+ }`}));return e}async emailTestGetCode(e){let{runtimeEmailTestGetCode:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeEmailTestGetCode($email: String!) {
1130
1194
  runtimeEmailTestGetCode(email: $email)
1131
- }`,variables:{email:e}}));return t}async emailTestClearCodes(){let{runtimeEmailTestClearCodes:e}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeEmailTestClearCodes {
1195
+ }`,variables:{email:e}}));return t}async emailTestClearCodes(){let{runtimeEmailTestClearCodes:e}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeEmailTestClearCodes {
1132
1196
  runtimeEmailTestClearCodes
1133
- }`}));return e}async emailTestSetExpiry(e,t,r){let{runtimeEmailTestSetExpiry:n}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeEmailTestSetExpiry($email: String!, $verificationType: String!, $expiresAt: Int!) {
1197
+ }`}));return e}async emailTestSetExpiry(e,t,r){let{runtimeEmailTestSetExpiry:n}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeEmailTestSetExpiry($email: String!, $verificationType: String!, $expiresAt: Int!) {
1134
1198
  runtimeEmailTestSetExpiry(email: $email, verificationType: $verificationType, expiresAt: $expiresAt)
1135
- }`,variables:{email:e,verificationType:t,expiresAt:r}}));return n}async unytAgentKey(){let{runtimeUnytAgentKey:e}=b(await N(this,D,"f").query({query:v`query runtimeUnytAgentKey { runtimeUnytAgentKey }`,fetchPolicy:"network-only"}));return e}async unytHotAgentPubkey(){let{runtimeHotAgentPubkey:e}=b(await N(this,D,"f").query({query:v`query runtimeHotAgentPubkey { runtimeHotAgentPubkey }`,fetchPolicy:"network-only"}));return e}async unytWalletBalance(){let{runtimeHotWalletBalance:e}=b(await N(this,D,"f").query({query:v`query runtimeHotWalletBalance { runtimeHotWalletBalance }`,fetchPolicy:"network-only"}));return e}async unytWalletHistory(e,t){let{runtimeHotWalletHistory:r}=b(await N(this,D,"f").query({query:v`query runtimeHotWalletHistory($page: Int, $perPage: Int) {
1199
+ }`,variables:{email:e,verificationType:t,expiresAt:r}}));return n}async unytAgentKey(){let{runtimeUnytAgentKey:e}=b(await O(this,U,"f").query({query:v`query runtimeUnytAgentKey { runtimeUnytAgentKey }`,fetchPolicy:"network-only"}));return e}async unytHotAgentPubkey(){let{runtimeHotAgentPubkey:e}=b(await O(this,U,"f").query({query:v`query runtimeHotAgentPubkey { runtimeHotAgentPubkey }`,fetchPolicy:"network-only"}));return e}async unytWalletBalance(){let{runtimeHotWalletBalance:e}=b(await O(this,U,"f").query({query:v`query runtimeHotWalletBalance { runtimeHotWalletBalance }`,fetchPolicy:"network-only"}));return e}async unytWalletHistory(e,t){let{runtimeHotWalletHistory:r}=b(await O(this,U,"f").query({query:v`query runtimeHotWalletHistory($page: Int, $perPage: Int) {
1136
1200
  runtimeHotWalletHistory(page: $page, perPage: $perPage)
1137
- }`,variables:{page:e,perPage:t},fetchPolicy:"network-only"}));return r}async unytVersionInfo(){let{runtimeUnytVersionInfo:e}=b(await N(this,D,"f").query({query:v`query runtimeUnytVersionInfo { runtimeUnytVersionInfo }`,fetchPolicy:"network-only"}));return e}async unytSetMembraneProof(e){let{runtimeSetUnytMembraneProof:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeSetUnytMembraneProof($proof: String!) {
1201
+ }`,variables:{page:e,perPage:t},fetchPolicy:"network-only"}));return r}async unytVersionInfo(){let{runtimeUnytVersionInfo:e}=b(await O(this,U,"f").query({query:v`query runtimeUnytVersionInfo { runtimeUnytVersionInfo }`,fetchPolicy:"network-only"}));return e}async unytSetMembraneProof(e){let{runtimeSetUnytMembraneProof:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeSetUnytMembraneProof($proof: String!) {
1138
1202
  runtimeSetUnytMembraneProof(proof: $proof) { success message }
1139
- }`,variables:{proof:e}}));return t}async unytReinstallDna(){let{runtimeReinstallUnytDna:e}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeReinstallUnytDna {
1203
+ }`,variables:{proof:e}}));return t}async unytReinstallDna(){let{runtimeReinstallUnytDna:e}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeReinstallUnytDna {
1140
1204
  runtimeReinstallUnytDna { success message }
1141
- }`}));return e}async unytSendHot(e,t){let{runtimeSendHot:r}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeSendHot($recipient: String!, $amount: String!) {
1205
+ }`}));return e}async unytSendHot(e,t){let{runtimeSendHot:r}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeSendHot($recipient: String!, $amount: String!) {
1142
1206
  runtimeSendHot(recipient: $recipient, amount: $amount) { success message }
1143
- }`,variables:{recipient:e,amount:t}}));return r}async setUserCredits(e,t){let{runtimeSetUserCredits:r}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeSetUserCredits($email: String!, $amount: Float!) {
1207
+ }`,variables:{recipient:e,amount:t}}));return r}async setUserCredits(e,t){let{runtimeSetUserCredits:r}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeSetUserCredits($email: String!, $amount: Float!) {
1144
1208
  runtimeSetUserCredits(email: $email, amount: $amount)
1145
- }`,variables:{email:e,amount:t}}));return r}async setUserFreeAccess(e,t){let{runtimeSetUserFreeAccess:r}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeSetUserFreeAccess($email: String!, $enabled: Boolean!) {
1209
+ }`,variables:{email:e,amount:t}}));return r}async setUserFreeAccess(e,t){let{runtimeSetUserFreeAccess:r}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeSetUserFreeAccess($email: String!, $enabled: Boolean!) {
1146
1210
  runtimeSetUserFreeAccess(email: $email, enabled: $enabled)
1147
- }`,variables:{email:e,enabled:t}}));return r}async setHostRates(e){let{runtimeSetHostRates:t}=b(await N(this,D,"f").mutate({mutation:v`mutation runtimeSetHostRates($ratesJson: String!) {
1211
+ }`,variables:{email:e,enabled:t}}));return r}async setHostRates(e){let{runtimeSetHostRates:t}=b(await O(this,U,"f").mutate({mutation:v`mutation runtimeSetHostRates($ratesJson: String!) {
1148
1212
  runtimeSetHostRates(ratesJson: $ratesJson)
1149
- }`,variables:{ratesJson:e}}));return t}async getHostRates(){let{runtimeHostRates:e}=b(await N(this,D,"f").query({query:v`query runtimeHostRates {
1213
+ }`,variables:{ratesJson:e}}));return t}async getHostRates(){let{runtimeHostRates:e}=b(await O(this,U,"f").query({query:v`query runtimeHostRates {
1150
1214
  runtimeHostRates
1151
- }`,fetchPolicy:"network-only"}));try{return JSON.parse(e)}catch{return[]}}addNotificationTriggeredCallback(e){N(this,on,"f").push(e)}subscribeNotificationTriggered(){N(this,D,"f").subscribe({query:v` subscription {
1152
- runtimeNotificationTriggered { ${gp} }
1215
+ }`,fetchPolicy:"network-only"}));try{return JSON.parse(e)}catch{return[]}}addNotificationTriggeredCallback(e){O(this,gn,"f").push(e)}subscribeNotificationTriggered(){O(this,U,"f").subscribe({query:v` subscription {
1216
+ runtimeNotificationTriggered { ${Np} }
1153
1217
  }
1154
- `}).subscribe({next:e=>{N(this,on,"f").forEach(t=>{t(e.data.runtimeNotificationTriggered)})},error:e=>console.error(e)})}addMessageCallback(e){N(this,an,"f").push(e)}subscribeMessageReceived(){N(this,D,"f").subscribe({query:v` subscription {
1155
- runtimeMessageReceived { ${na} }
1218
+ `}).subscribe({next:e=>{O(this,gn,"f").forEach(t=>{t(e.data.runtimeNotificationTriggered)})},error:e=>console.error(e)})}addMessageCallback(e){O(this,fn,"f").push(e)}subscribeMessageReceived(){O(this,U,"f").subscribe({query:v` subscription {
1219
+ runtimeMessageReceived { ${fa} }
1156
1220
  }
1157
- `}).subscribe({next:e=>{N(this,an,"f").forEach(t=>{t(e.data.runtimeMessageReceived)})},error:e=>console.error(e)})}addExceptionCallback(e){N(this,sn,"f").push(e)}subscribeExceptionOccurred(){N(this,D,"f").subscribe({query:v` subscription {
1221
+ `}).subscribe({next:e=>{O(this,fn,"f").forEach(t=>{t(e.data.runtimeMessageReceived)})},error:e=>console.error(e)})}addExceptionCallback(e){O(this,hn,"f").push(e)}subscribeExceptionOccurred(){O(this,U,"f").subscribe({query:v` subscription {
1158
1222
  exceptionOccurred {
1159
1223
  title
1160
1224
  message
1161
1225
  type
1162
1226
  addon
1163
1227
  }
1164
- }`}).subscribe({next:e=>{N(this,sn,"f").forEach(t=>{t(e.data.exceptionOccurred)})},error:e=>console.error(e)})}};D=new WeakMap,an=new WeakMap,sn=new WeakMap,on=new WeakMap,Zl=new WeakMap;var mp=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},ur=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},jt,no=class{constructor(e){jt.set(this,void 0),mp(this,jt,e,"f")}async get(e,t=!1){if(!t)try{let n=le.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:r}=b(await ur(this,jt,"f").query({query:v`query expression($url: String!) {
1228
+ }`}).subscribe({next:e=>{O(this,hn,"f").forEach(t=>{t(e.data.exceptionOccurred)})},error:e=>console.error(e)})}};U=new WeakMap,fn=new WeakMap,hn=new WeakMap,gn=new WeakMap,uu=new WeakMap;var Op=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},mr=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Ot,go=class{constructor(e){Ot.set(this,void 0),Op(this,Ot,e,"f")}async get(e,t=!1){if(!t)try{let n=le.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:r}=b(await mr(this,Ot,"f").query({query:v`query expression($url: String!) {
1165
1229
  expression(url: $url) {
1166
1230
  author
1167
1231
  timestamp
@@ -1174,7 +1238,7 @@ triggerMatch
1174
1238
  invalid
1175
1239
  }
1176
1240
  }
1177
- }`,variables:{url:e}}));return r}async getMany(e){let{expressionMany:t}=b(await ur(this,jt,"f").query({query:v`query expressionMany($urls: [String!]!) {
1241
+ }`,variables:{url:e}}));return r}async getMany(e){let{expressionMany:t}=b(await mr(this,Ot,"f").query({query:v`query expressionMany($urls: [String!]!) {
1178
1242
  expressionMany(urls: $urls) {
1179
1243
  author
1180
1244
  timestamp
@@ -1187,19 +1251,19 @@ triggerMatch
1187
1251
  invalid
1188
1252
  }
1189
1253
  }
1190
- }`,variables:{urls:e}}));return t}async getRaw(e){let{expressionRaw:t}=b(await ur(this,jt,"f").query({query:v`query expressionRaw($url: String!) {
1254
+ }`,variables:{urls:e}}));return t}async getRaw(e){let{expressionRaw:t}=b(await mr(this,Ot,"f").query({query:v`query expressionRaw($url: String!) {
1191
1255
  expressionRaw(url: $url)
1192
- }`,variables:{url:e}}));return t}async create(e,t){e=JSON.stringify(e);let{expressionCreate:r}=b(await ur(this,jt,"f").mutate({mutation:v`mutation expressionCreate($content: String!, $languageAddress: String!){
1256
+ }`,variables:{url:e}}));return t}async create(e,t){e=JSON.stringify(e);let{expressionCreate:r}=b(await mr(this,Ot,"f").mutate({mutation:v`mutation expressionCreate($content: String!, $languageAddress: String!){
1193
1257
  expressionCreate(content: $content, languageAddress: $languageAddress)
1194
- }`,variables:{content:e,languageAddress:t}}));return r}async interactions(e){let{expressionInteractions:t}=b(await ur(this,jt,"f").query({query:v`query expressionInteractions($url: String!) {
1258
+ }`,variables:{content:e,languageAddress:t}}));return r}async interactions(e){let{expressionInteractions:t}=b(await mr(this,Ot,"f").query({query:v`query expressionInteractions($url: String!) {
1195
1259
  expressionInteractions(url: $url) {
1196
1260
  label
1197
1261
  name
1198
1262
  parameters { name, type }
1199
1263
  }
1200
- }`,variables:{url:e}}));return t}async interact(e,t){let{expressionInteract:r}=b(await ur(this,jt,"f").mutate({mutation:v`mutation expressionInteract($url: String!, $interactionCall: InteractionCall!){
1264
+ }`,variables:{url:e}}));return t}async interact(e,t){let{expressionInteract:r}=b(await mr(this,Ot,"f").mutate({mutation:v`mutation expressionInteract($url: String!, $interactionCall: InteractionCall!){
1201
1265
  expressionInteract(url: $url, interactionCall: $interactionCall)
1202
- }`,variables:{url:e,interactionCall:t}}));return r}};jt=new WeakMap;var ts={};ts.byteLength=vp;ts.toByteArray=wp;ts.fromByteArray=xp;var At=[],ct=[],yp=typeof Uint8Array<"u"?Uint8Array:Array,Ls="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(xi=0,$c=Ls.length;xi<$c;++xi)At[xi]=Ls[xi],ct[Ls.charCodeAt(xi)]=xi;var xi,$c;ct["-".charCodeAt(0)]=62;ct["_".charCodeAt(0)]=63;function Yl(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function vp(i){var e=Yl(i),t=e[0],r=e[1];return(t+r)*3/4-r}function bp(i,e,t){return(e+t)*3/4-t}function wp(i){var e,t=Yl(i),r=t[0],n=t[1],a=new yp(bp(i,r,n)),s=0,o=n>0?r-4:r,l;for(l=0;l<o;l+=4)e=ct[i.charCodeAt(l)]<<18|ct[i.charCodeAt(l+1)]<<12|ct[i.charCodeAt(l+2)]<<6|ct[i.charCodeAt(l+3)],a[s++]=e>>16&255,a[s++]=e>>8&255,a[s++]=e&255;return n===2&&(e=ct[i.charCodeAt(l)]<<2|ct[i.charCodeAt(l+1)]>>4,a[s++]=e&255),n===1&&(e=ct[i.charCodeAt(l)]<<10|ct[i.charCodeAt(l+1)]<<4|ct[i.charCodeAt(l+2)]>>2,a[s++]=e>>8&255,a[s++]=e&255),a}function Sp(i){return At[i>>18&63]+At[i>>12&63]+At[i>>6&63]+At[i&63]}function _p(i,e,t){for(var r,n=[],a=e;a<t;a+=3)r=(i[a]<<16&16711680)+(i[a+1]<<8&65280)+(i[a+2]&255),n.push(Sp(r));return n.join("")}function xp(i){for(var e,t=i.length,r=t%3,n=[],a=16383,s=0,o=t-r;s<o;s+=a)n.push(_p(i,s,s+a>o?o:s+a));return r===1?(e=i[t-1],n.push(At[e>>2]+At[e<<4&63]+"==")):r===2&&(e=(i[t-2]<<8)+i[t-1],n.push(At[e>>10]+At[e>>4&63]+At[e<<2&63]+"=")),n.join("")}var Ep=4,Ac=0,kc=1,$p=2;function Cr(i){let e=i.length;for(;--e>=0;)i[e]=0}var Ap=0,Xl=1,kp=2,Ip=3,Tp=258,xo=29,On=256,En=On+1+xo,yr=30,Eo=19,eu=2*En+1,Ni=15,Ps=16,Cp=7,$o=256,tu=16,iu=17,ru=18,ao=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]),xa=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]),Lp=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),nu=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Pp=512,Bt=new Array((En+2)*2);Cr(Bt);var mn=new Array(yr*2);Cr(mn);var $n=new Array(Pp);Cr($n);var An=new Array(Tp-Ip+1);Cr(An);var Ao=new Array(xo);Cr(Ao);var ja=new Array(yr);Cr(ja);function Rs(i,e,t,r,n){this.static_tree=i,this.extra_bits=e,this.extra_base=t,this.elems=r,this.max_length=n,this.has_stree=i&&i.length}var au,su,ou;function Ns(i,e){this.dyn_tree=i,this.max_code=0,this.stat_desc=e}var cu=i=>i<256?$n[i]:$n[256+(i>>>7)],kn=(i,e)=>{i.pending_buf[i.pending++]=e&255,i.pending_buf[i.pending++]=e>>>8&255},Ye=(i,e,t)=>{i.bi_valid>Ps-t?(i.bi_buf|=e<<i.bi_valid&65535,kn(i,i.bi_buf),i.bi_buf=e>>Ps-i.bi_valid,i.bi_valid+=t-Ps):(i.bi_buf|=e<<i.bi_valid&65535,i.bi_valid+=t)},kt=(i,e,t)=>{Ye(i,t[e*2],t[e*2+1])},lu=(i,e)=>{let t=0;do t|=i&1,i>>>=1,t<<=1;while(--e>0);return t>>>1},Rp=i=>{i.bi_valid===16?(kn(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)},Np=(i,e)=>{let t=e.dyn_tree,r=e.max_code,n=e.stat_desc.static_tree,a=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,l=e.stat_desc.max_length,c,u,m,y,d,f,g=0;for(y=0;y<=Ni;y++)i.bl_count[y]=0;for(t[i.heap[i.heap_max]*2+1]=0,c=i.heap_max+1;c<eu;c++)u=i.heap[c],y=t[t[u*2+1]*2+1]+1,y>l&&(y=l,g++),t[u*2+1]=y,!(u>r)&&(i.bl_count[y]++,d=0,u>=o&&(d=s[u-o]),f=t[u*2],i.opt_len+=f*(y+d),a&&(i.static_len+=f*(n[u*2+1]+d)));if(g!==0){do{for(y=l-1;i.bl_count[y]===0;)y--;i.bl_count[y]--,i.bl_count[y+1]+=2,i.bl_count[l]--,g-=2}while(g>0);for(y=l;y!==0;y--)for(u=i.bl_count[y];u!==0;)m=i.heap[--c],!(m>r)&&(t[m*2+1]!==y&&(i.opt_len+=(y-t[m*2+1])*t[m*2],t[m*2+1]=y),u--)}},uu=(i,e,t)=>{let r=new Array(Ni+1),n=0,a,s;for(a=1;a<=Ni;a++)n=n+t[a-1]<<1,r[a]=n;for(s=0;s<=e;s++){let o=i[s*2+1];o!==0&&(i[s*2]=lu(r[o]++,o))}},Op=()=>{let i,e,t,r,n,a=new Array(Ni+1);for(t=0,r=0;r<xo-1;r++)for(Ao[r]=t,i=0;i<1<<ao[r];i++)An[t++]=r;for(An[t-1]=r,n=0,r=0;r<16;r++)for(ja[r]=n,i=0;i<1<<xa[r];i++)$n[n++]=r;for(n>>=7;r<yr;r++)for(ja[r]=n<<7,i=0;i<1<<xa[r]-7;i++)$n[256+n++]=r;for(e=0;e<=Ni;e++)a[e]=0;for(i=0;i<=143;)Bt[i*2+1]=8,i++,a[8]++;for(;i<=255;)Bt[i*2+1]=9,i++,a[9]++;for(;i<=279;)Bt[i*2+1]=7,i++,a[7]++;for(;i<=287;)Bt[i*2+1]=8,i++,a[8]++;for(uu(Bt,En+1,a),i=0;i<yr;i++)mn[i*2+1]=5,mn[i*2]=lu(i,5);au=new Rs(Bt,ao,On+1,En,Ni),su=new Rs(mn,xa,0,yr,Ni),ou=new Rs(new Array(0),Lp,0,Eo,Cp)},du=i=>{let e;for(e=0;e<En;e++)i.dyn_ltree[e*2]=0;for(e=0;e<yr;e++)i.dyn_dtree[e*2]=0;for(e=0;e<Eo;e++)i.bl_tree[e*2]=0;i.dyn_ltree[$o*2]=1,i.opt_len=i.static_len=0,i.sym_next=i.matches=0},pu=i=>{i.bi_valid>8?kn(i,i.bi_buf):i.bi_valid>0&&(i.pending_buf[i.pending++]=i.bi_buf),i.bi_buf=0,i.bi_valid=0},Ic=(i,e,t,r)=>{let n=e*2,a=t*2;return i[n]<i[a]||i[n]===i[a]&&r[e]<=r[t]},Os=(i,e,t)=>{let r=i.heap[t],n=t<<1;for(;n<=i.heap_len&&(n<i.heap_len&&Ic(e,i.heap[n+1],i.heap[n],i.depth)&&n++,!Ic(e,r,i.heap[n],i.depth));)i.heap[t]=i.heap[n],t=n,n<<=1;i.heap[t]=r},Tc=(i,e,t)=>{let r,n,a=0,s,o;if(i.sym_next!==0)do r=i.pending_buf[i.sym_buf+a++]&255,r+=(i.pending_buf[i.sym_buf+a++]&255)<<8,n=i.pending_buf[i.sym_buf+a++],r===0?kt(i,n,e):(s=An[n],kt(i,s+On+1,e),o=ao[s],o!==0&&(n-=Ao[s],Ye(i,n,o)),r--,s=cu(r),kt(i,s,t),o=xa[s],o!==0&&(r-=ja[s],Ye(i,r,o)));while(a<i.sym_next);kt(i,$o,e)},so=(i,e)=>{let t=e.dyn_tree,r=e.stat_desc.static_tree,n=e.stat_desc.has_stree,a=e.stat_desc.elems,s,o,l=-1,c;for(i.heap_len=0,i.heap_max=eu,s=0;s<a;s++)t[s*2]!==0?(i.heap[++i.heap_len]=l=s,i.depth[s]=0):t[s*2+1]=0;for(;i.heap_len<2;)c=i.heap[++i.heap_len]=l<2?++l:0,t[c*2]=1,i.depth[c]=0,i.opt_len--,n&&(i.static_len-=r[c*2+1]);for(e.max_code=l,s=i.heap_len>>1;s>=1;s--)Os(i,t,s);c=a;do s=i.heap[1],i.heap[1]=i.heap[i.heap_len--],Os(i,t,1),o=i.heap[1],i.heap[--i.heap_max]=s,i.heap[--i.heap_max]=o,t[c*2]=t[s*2]+t[o*2],i.depth[c]=(i.depth[s]>=i.depth[o]?i.depth[s]:i.depth[o])+1,t[s*2+1]=t[o*2+1]=c,i.heap[1]=c++,Os(i,t,1);while(i.heap_len>=2);i.heap[--i.heap_max]=i.heap[1],Np(i,e),uu(t,l,i.bl_count)},Cc=(i,e,t)=>{let r,n=-1,a,s=e[0*2+1],o=0,l=7,c=4;for(s===0&&(l=138,c=3),e[(t+1)*2+1]=65535,r=0;r<=t;r++)a=s,s=e[(r+1)*2+1],!(++o<l&&a===s)&&(o<c?i.bl_tree[a*2]+=o:a!==0?(a!==n&&i.bl_tree[a*2]++,i.bl_tree[tu*2]++):o<=10?i.bl_tree[iu*2]++:i.bl_tree[ru*2]++,o=0,n=a,s===0?(l=138,c=3):a===s?(l=6,c=3):(l=7,c=4))},Lc=(i,e,t)=>{let r,n=-1,a,s=e[0*2+1],o=0,l=7,c=4;for(s===0&&(l=138,c=3),r=0;r<=t;r++)if(a=s,s=e[(r+1)*2+1],!(++o<l&&a===s)){if(o<c)do kt(i,a,i.bl_tree);while(--o!==0);else a!==0?(a!==n&&(kt(i,a,i.bl_tree),o--),kt(i,tu,i.bl_tree),Ye(i,o-3,2)):o<=10?(kt(i,iu,i.bl_tree),Ye(i,o-3,3)):(kt(i,ru,i.bl_tree),Ye(i,o-11,7));o=0,n=a,s===0?(l=138,c=3):a===s?(l=6,c=3):(l=7,c=4)}},Dp=i=>{let e;for(Cc(i,i.dyn_ltree,i.l_desc.max_code),Cc(i,i.dyn_dtree,i.d_desc.max_code),so(i,i.bl_desc),e=Eo-1;e>=3&&i.bl_tree[nu[e]*2+1]===0;e--);return i.opt_len+=3*(e+1)+5+5+4,e},Up=(i,e,t,r)=>{let n;for(Ye(i,e-257,5),Ye(i,t-1,5),Ye(i,r-4,4),n=0;n<r;n++)Ye(i,i.bl_tree[nu[n]*2+1],3);Lc(i,i.dyn_ltree,e-1),Lc(i,i.dyn_dtree,t-1)},Mp=i=>{let e=4093624447,t;for(t=0;t<=31;t++,e>>>=1)if(e&1&&i.dyn_ltree[t*2]!==0)return Ac;if(i.dyn_ltree[9*2]!==0||i.dyn_ltree[10*2]!==0||i.dyn_ltree[13*2]!==0)return kc;for(t=32;t<On;t++)if(i.dyn_ltree[t*2]!==0)return kc;return Ac},Pc=!1,Fp=i=>{Pc||(Op(),Pc=!0),i.l_desc=new Ns(i.dyn_ltree,au),i.d_desc=new Ns(i.dyn_dtree,su),i.bl_desc=new Ns(i.bl_tree,ou),i.bi_buf=0,i.bi_valid=0,du(i)},fu=(i,e,t,r)=>{Ye(i,(Ap<<1)+(r?1:0),3),pu(i),kn(i,t),kn(i,~t),t&&i.pending_buf.set(i.window.subarray(e,e+t),i.pending),i.pending+=t},jp=i=>{Ye(i,Xl<<1,3),kt(i,$o,Bt),Rp(i)},Bp=(i,e,t,r)=>{let n,a,s=0;i.level>0?(i.strm.data_type===$p&&(i.strm.data_type=Mp(i)),so(i,i.l_desc),so(i,i.d_desc),s=Dp(i),n=i.opt_len+3+7>>>3,a=i.static_len+3+7>>>3,a<=n&&(n=a)):n=a=t+5,t+4<=n&&e!==-1?fu(i,e,t,r):i.strategy===Ep||a===n?(Ye(i,(Xl<<1)+(r?1:0),3),Tc(i,Bt,mn)):(Ye(i,(kp<<1)+(r?1:0),3),Up(i,i.l_desc.max_code+1,i.d_desc.max_code+1,s+1),Tc(i,i.dyn_ltree,i.dyn_dtree)),du(i),r&&pu(i)},qp=(i,e,t)=>(i.pending_buf[i.sym_buf+i.sym_next++]=e,i.pending_buf[i.sym_buf+i.sym_next++]=e>>8,i.pending_buf[i.sym_buf+i.sym_next++]=t,e===0?i.dyn_ltree[t*2]++:(i.matches++,e--,i.dyn_ltree[(An[t]+On+1)*2]++,i.dyn_dtree[cu(e)*2]++),i.sym_next===i.sym_end),Hp=Fp,zp=fu,Vp=Bp,Wp=qp,Kp=jp,Qp={_tr_init:Hp,_tr_stored_block:zp,_tr_flush_block:Vp,_tr_tally:Wp,_tr_align:Kp},Gp=(i,e,t,r)=>{let n=i&65535|0,a=i>>>16&65535|0,s=0;for(;t!==0;){s=t>2e3?2e3:t,t-=s;do n=n+e[r++]|0,a=a+n|0;while(--s);n%=65521,a%=65521}return n|a<<16|0},In=Gp,Zp=()=>{let i,e=[];for(var t=0;t<256;t++){i=t;for(var r=0;r<8;r++)i=i&1?3988292384^i>>>1:i>>>1;e[t]=i}return e},Jp=new Uint32Array(Zp()),Yp=(i,e,t,r)=>{let n=Jp,a=r+t;i^=-1;for(let s=r;s<a;s++)i=i>>>8^n[(i^e[s])&255];return i^-1},ke=Yp,zi={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"},Xi={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:Xp,_tr_stored_block:oo,_tr_flush_block:ef,_tr_tally:ri,_tr_align:tf}=Qp,{Z_NO_FLUSH:ni,Z_PARTIAL_FLUSH:rf,Z_FULL_FLUSH:nf,Z_FINISH:ut,Z_BLOCK:Rc,Z_OK:Pe,Z_STREAM_END:Nc,Z_STREAM_ERROR:Ct,Z_DATA_ERROR:af,Z_BUF_ERROR:Ds,Z_DEFAULT_COMPRESSION:sf,Z_FILTERED:of,Z_HUFFMAN_ONLY:aa,Z_RLE:cf,Z_FIXED:lf,Z_DEFAULT_STRATEGY:uf,Z_UNKNOWN:df,Z_DEFLATED:is}=Xi,pf=9,ff=15,hf=8,gf=29,mf=256,co=mf+1+gf,yf=30,vf=19,bf=2*co+1,wf=15,te=3,Xt=258,Lt=Xt+te+1,Sf=32,_r=42,ko=57,lo=69,uo=73,po=91,fo=103,Oi=113,cn=666,qe=1,Lr=2,Vi=3,Pr=4,_f=3,Di=(i,e)=>(i.msg=zi[e],e),Oc=i=>i*2-(i>4?9:0),Yt=i=>{let e=i.length;for(;--e>=0;)i[e]=0},xf=i=>{let e,t,r,n=i.w_size;e=i.hash_size,r=e;do t=i.head[--r],i.head[r]=t>=n?t-n:0;while(--e);e=n,r=e;do t=i.prev[--r],i.prev[r]=t>=n?t-n:0;while(--e)},Ef=(i,e,t)=>(e<<i.hash_shift^t)&i.hash_mask,ai=Ef,tt=i=>{let e=i.state,t=e.pending;t>i.avail_out&&(t=i.avail_out),t!==0&&(i.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+t),i.next_out),i.next_out+=t,e.pending_out+=t,i.total_out+=t,i.avail_out-=t,e.pending-=t,e.pending===0&&(e.pending_out=0))},rt=(i,e)=>{ef(i,i.block_start>=0?i.block_start:-1,i.strstart-i.block_start,e),i.block_start=i.strstart,tt(i.strm)},se=(i,e)=>{i.pending_buf[i.pending++]=e},Wr=(i,e)=>{i.pending_buf[i.pending++]=e>>>8&255,i.pending_buf[i.pending++]=e&255},ho=(i,e,t,r)=>{let n=i.avail_in;return n>r&&(n=r),n===0?0:(i.avail_in-=n,e.set(i.input.subarray(i.next_in,i.next_in+n),t),i.state.wrap===1?i.adler=In(i.adler,e,n,t):i.state.wrap===2&&(i.adler=ke(i.adler,e,n,t)),i.next_in+=n,i.total_in+=n,n)},hu=(i,e)=>{let t=i.max_chain_length,r=i.strstart,n,a,s=i.prev_length,o=i.nice_match,l=i.strstart>i.w_size-Lt?i.strstart-(i.w_size-Lt):0,c=i.window,u=i.w_mask,m=i.prev,y=i.strstart+Xt,d=c[r+s-1],f=c[r+s];i.prev_length>=i.good_match&&(t>>=2),o>i.lookahead&&(o=i.lookahead);do if(n=e,!(c[n+s]!==f||c[n+s-1]!==d||c[n]!==c[r]||c[++n]!==c[r+1])){r+=2,n++;do;while(c[++r]===c[++n]&&c[++r]===c[++n]&&c[++r]===c[++n]&&c[++r]===c[++n]&&c[++r]===c[++n]&&c[++r]===c[++n]&&c[++r]===c[++n]&&c[++r]===c[++n]&&r<y);if(a=Xt-(y-r),r=y-Xt,a>s){if(i.match_start=e,s=a,a>=o)break;d=c[r+s-1],f=c[r+s]}}while((e=m[e&u])>l&&--t!==0);return s<=i.lookahead?s:i.lookahead},xr=i=>{let e=i.w_size,t,r,n;do{if(r=i.window_size-i.lookahead-i.strstart,i.strstart>=e+(e-Lt)&&(i.window.set(i.window.subarray(e,e+e-r),0),i.match_start-=e,i.strstart-=e,i.block_start-=e,i.insert>i.strstart&&(i.insert=i.strstart),xf(i),r+=e),i.strm.avail_in===0)break;if(t=ho(i.strm,i.window,i.strstart+i.lookahead,r),i.lookahead+=t,i.lookahead+i.insert>=te)for(n=i.strstart-i.insert,i.ins_h=i.window[n],i.ins_h=ai(i,i.ins_h,i.window[n+1]);i.insert&&(i.ins_h=ai(i,i.ins_h,i.window[n+te-1]),i.prev[n&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=n,n++,i.insert--,!(i.lookahead+i.insert<te)););}while(i.lookahead<Lt&&i.strm.avail_in!==0)},gu=(i,e)=>{let t=i.pending_buf_size-5>i.w_size?i.w_size:i.pending_buf_size-5,r,n,a,s=0,o=i.strm.avail_in;do{if(r=65535,a=i.bi_valid+42>>3,i.strm.avail_out<a||(a=i.strm.avail_out-a,n=i.strstart-i.block_start,r>n+i.strm.avail_in&&(r=n+i.strm.avail_in),r>a&&(r=a),r<t&&(r===0&&e!==ut||e===ni||r!==n+i.strm.avail_in)))break;s=e===ut&&r===n+i.strm.avail_in?1:0,oo(i,0,0,s),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,tt(i.strm),n&&(n>r&&(n=r),i.strm.output.set(i.window.subarray(i.block_start,i.block_start+n),i.strm.next_out),i.strm.next_out+=n,i.strm.avail_out-=n,i.strm.total_out+=n,i.block_start+=n,r-=n),r&&(ho(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(s===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),s?Pr:e!==ni&&e!==ut&&i.strm.avail_in===0&&i.strstart===i.block_start?Lr:(a=i.window_size-i.strstart,i.strm.avail_in>a&&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++,a+=i.w_size,i.insert>i.strstart&&(i.insert=i.strstart)),a>i.strm.avail_in&&(a=i.strm.avail_in),a&&(ho(i.strm,i.window,i.strstart,a),i.strstart+=a,i.insert+=a>i.w_size-i.insert?i.w_size-i.insert:a),i.high_water<i.strstart&&(i.high_water=i.strstart),a=i.bi_valid+42>>3,a=i.pending_buf_size-a>65535?65535:i.pending_buf_size-a,t=a>i.w_size?i.w_size:a,n=i.strstart-i.block_start,(n>=t||(n||e===ut)&&e!==ni&&i.strm.avail_in===0&&n<=a)&&(r=n>a?a:n,s=e===ut&&i.strm.avail_in===0&&r===n?1:0,oo(i,i.block_start,r,s),i.block_start+=r,tt(i.strm)),s?Vi:qe)},Us=(i,e)=>{let t,r;for(;;){if(i.lookahead<Lt){if(xr(i),i.lookahead<Lt&&e===ni)return qe;if(i.lookahead===0)break}if(t=0,i.lookahead>=te&&(i.ins_h=ai(i,i.ins_h,i.window[i.strstart+te-1]),t=i.prev[i.strstart&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=i.strstart),t!==0&&i.strstart-t<=i.w_size-Lt&&(i.match_length=hu(i,t)),i.match_length>=te)if(r=ri(i,i.strstart-i.match_start,i.match_length-te),i.lookahead-=i.match_length,i.match_length<=i.max_lazy_match&&i.lookahead>=te){i.match_length--;do i.strstart++,i.ins_h=ai(i,i.ins_h,i.window[i.strstart+te-1]),t=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=ai(i,i.ins_h,i.window[i.strstart+1]);else r=ri(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++;if(r&&(rt(i,!1),i.strm.avail_out===0))return qe}return i.insert=i.strstart<te-1?i.strstart:te-1,e===ut?(rt(i,!0),i.strm.avail_out===0?Vi:Pr):i.sym_next&&(rt(i,!1),i.strm.avail_out===0)?qe:Lr},dr=(i,e)=>{let t,r,n;for(;;){if(i.lookahead<Lt){if(xr(i),i.lookahead<Lt&&e===ni)return qe;if(i.lookahead===0)break}if(t=0,i.lookahead>=te&&(i.ins_h=ai(i,i.ins_h,i.window[i.strstart+te-1]),t=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=te-1,t!==0&&i.prev_length<i.max_lazy_match&&i.strstart-t<=i.w_size-Lt&&(i.match_length=hu(i,t),i.match_length<=5&&(i.strategy===of||i.match_length===te&&i.strstart-i.match_start>4096)&&(i.match_length=te-1)),i.prev_length>=te&&i.match_length<=i.prev_length){n=i.strstart+i.lookahead-te,r=ri(i,i.strstart-1-i.prev_match,i.prev_length-te),i.lookahead-=i.prev_length-1,i.prev_length-=2;do++i.strstart<=n&&(i.ins_h=ai(i,i.ins_h,i.window[i.strstart+te-1]),t=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=te-1,i.strstart++,r&&(rt(i,!1),i.strm.avail_out===0))return qe}else if(i.match_available){if(r=ri(i,0,i.window[i.strstart-1]),r&&rt(i,!1),i.strstart++,i.lookahead--,i.strm.avail_out===0)return qe}else i.match_available=1,i.strstart++,i.lookahead--}return i.match_available&&(r=ri(i,0,i.window[i.strstart-1]),i.match_available=0),i.insert=i.strstart<te-1?i.strstart:te-1,e===ut?(rt(i,!0),i.strm.avail_out===0?Vi:Pr):i.sym_next&&(rt(i,!1),i.strm.avail_out===0)?qe:Lr},$f=(i,e)=>{let t,r,n,a,s=i.window;for(;;){if(i.lookahead<=Xt){if(xr(i),i.lookahead<=Xt&&e===ni)return qe;if(i.lookahead===0)break}if(i.match_length=0,i.lookahead>=te&&i.strstart>0&&(n=i.strstart-1,r=s[n],r===s[++n]&&r===s[++n]&&r===s[++n])){a=i.strstart+Xt;do;while(r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&n<a);i.match_length=Xt-(a-n),i.match_length>i.lookahead&&(i.match_length=i.lookahead)}if(i.match_length>=te?(t=ri(i,1,i.match_length-te),i.lookahead-=i.match_length,i.strstart+=i.match_length,i.match_length=0):(t=ri(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++),t&&(rt(i,!1),i.strm.avail_out===0))return qe}return i.insert=0,e===ut?(rt(i,!0),i.strm.avail_out===0?Vi:Pr):i.sym_next&&(rt(i,!1),i.strm.avail_out===0)?qe:Lr},Af=(i,e)=>{let t;for(;;){if(i.lookahead===0&&(xr(i),i.lookahead===0)){if(e===ni)return qe;break}if(i.match_length=0,t=ri(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++,t&&(rt(i,!1),i.strm.avail_out===0))return qe}return i.insert=0,e===ut?(rt(i,!0),i.strm.avail_out===0?Vi:Pr):i.sym_next&&(rt(i,!1),i.strm.avail_out===0)?qe:Lr};function St(i,e,t,r,n){this.good_length=i,this.max_lazy=e,this.nice_length=t,this.max_chain=r,this.func=n}var ln=[new St(0,0,0,0,gu),new St(4,4,8,4,Us),new St(4,5,16,8,Us),new St(4,6,32,32,Us),new St(4,4,16,16,dr),new St(8,16,32,32,dr),new St(8,16,128,128,dr),new St(8,32,128,256,dr),new St(32,128,258,1024,dr),new St(32,258,258,4096,dr)],kf=i=>{i.window_size=2*i.w_size,Yt(i.head),i.max_lazy_match=ln[i.level].max_lazy,i.good_match=ln[i.level].good_length,i.nice_match=ln[i.level].nice_length,i.max_chain_length=ln[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=te-1,i.match_available=0,i.ins_h=0};function If(){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=is,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(bf*2),this.dyn_dtree=new Uint16Array((2*yf+1)*2),this.bl_tree=new Uint16Array((2*vf+1)*2),Yt(this.dyn_ltree),Yt(this.dyn_dtree),Yt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(wf+1),this.heap=new Uint16Array(2*co+1),Yt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*co+1),Yt(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 Dn=i=>{if(!i)return 1;let e=i.state;return!e||e.strm!==i||e.status!==_r&&e.status!==ko&&e.status!==lo&&e.status!==uo&&e.status!==po&&e.status!==fo&&e.status!==Oi&&e.status!==cn?1:0},mu=i=>{if(Dn(i))return Di(i,Ct);i.total_in=i.total_out=0,i.data_type=df;let e=i.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?ko:e.wrap?_r:Oi,i.adler=e.wrap===2?0:1,e.last_flush=-2,Xp(e),Pe},yu=i=>{let e=mu(i);return e===Pe&&kf(i.state),e},Tf=(i,e)=>Dn(i)||i.state.wrap!==2?Ct:(i.state.gzhead=e,Pe),vu=(i,e,t,r,n,a)=>{if(!i)return Ct;let s=1;if(e===sf&&(e=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),n<1||n>pf||t!==is||r<8||r>15||e<0||e>9||a<0||a>lf||r===8&&s!==1)return Di(i,Ct);r===8&&(r=9);let o=new If;return i.state=o,o.strm=i,o.status=_r,o.wrap=s,o.gzhead=null,o.w_bits=r,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+te-1)/te),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<<n+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=e,o.strategy=a,o.method=t,yu(i)},Cf=(i,e)=>vu(i,e,is,ff,hf,uf),Lf=(i,e)=>{if(Dn(i)||e>Rc||e<0)return i?Di(i,Ct):Ct;let t=i.state;if(!i.output||i.avail_in!==0&&!i.input||t.status===cn&&e!==ut)return Di(i,i.avail_out===0?Ds:Ct);let r=t.last_flush;if(t.last_flush=e,t.pending!==0){if(tt(i),i.avail_out===0)return t.last_flush=-1,Pe}else if(i.avail_in===0&&Oc(e)<=Oc(r)&&e!==ut)return Di(i,Ds);if(t.status===cn&&i.avail_in!==0)return Di(i,Ds);if(t.status===_r&&t.wrap===0&&(t.status=Oi),t.status===_r){let n=is+(t.w_bits-8<<4)<<8,a=-1;if(t.strategy>=aa||t.level<2?a=0:t.level<6?a=1:t.level===6?a=2:a=3,n|=a<<6,t.strstart!==0&&(n|=Sf),n+=31-n%31,Wr(t,n),t.strstart!==0&&(Wr(t,i.adler>>>16),Wr(t,i.adler&65535)),i.adler=1,t.status=Oi,tt(i),t.pending!==0)return t.last_flush=-1,Pe}if(t.status===ko){if(i.adler=0,se(t,31),se(t,139),se(t,8),t.gzhead)se(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)),se(t,t.gzhead.time&255),se(t,t.gzhead.time>>8&255),se(t,t.gzhead.time>>16&255),se(t,t.gzhead.time>>24&255),se(t,t.level===9?2:t.strategy>=aa||t.level<2?4:0),se(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(se(t,t.gzhead.extra.length&255),se(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(i.adler=ke(i.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=lo;else if(se(t,0),se(t,0),se(t,0),se(t,0),se(t,0),se(t,t.level===9?2:t.strategy>=aa||t.level<2?4:0),se(t,_f),t.status=Oi,tt(i),t.pending!==0)return t.last_flush=-1,Pe}if(t.status===lo){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 o=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+o),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>n&&(i.adler=ke(i.adler,t.pending_buf,t.pending-n,n)),t.gzindex+=o,tt(i),t.pending!==0)return t.last_flush=-1,Pe;n=0,a-=o}let s=new Uint8Array(t.gzhead.extra);t.pending_buf.set(s.subarray(t.gzindex,t.gzindex+a),t.pending),t.pending+=a,t.gzhead.hcrc&&t.pending>n&&(i.adler=ke(i.adler,t.pending_buf,t.pending-n,n)),t.gzindex=0}t.status=uo}if(t.status===uo){if(t.gzhead.name){let n=t.pending,a;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>n&&(i.adler=ke(i.adler,t.pending_buf,t.pending-n,n)),tt(i),t.pending!==0)return t.last_flush=-1,Pe;n=0}t.gzindex<t.gzhead.name.length?a=t.gzhead.name.charCodeAt(t.gzindex++)&255:a=0,se(t,a)}while(a!==0);t.gzhead.hcrc&&t.pending>n&&(i.adler=ke(i.adler,t.pending_buf,t.pending-n,n)),t.gzindex=0}t.status=po}if(t.status===po){if(t.gzhead.comment){let n=t.pending,a;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>n&&(i.adler=ke(i.adler,t.pending_buf,t.pending-n,n)),tt(i),t.pending!==0)return t.last_flush=-1,Pe;n=0}t.gzindex<t.gzhead.comment.length?a=t.gzhead.comment.charCodeAt(t.gzindex++)&255:a=0,se(t,a)}while(a!==0);t.gzhead.hcrc&&t.pending>n&&(i.adler=ke(i.adler,t.pending_buf,t.pending-n,n))}t.status=fo}if(t.status===fo){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(tt(i),t.pending!==0))return t.last_flush=-1,Pe;se(t,i.adler&255),se(t,i.adler>>8&255),i.adler=0}if(t.status=Oi,tt(i),t.pending!==0)return t.last_flush=-1,Pe}if(i.avail_in!==0||t.lookahead!==0||e!==ni&&t.status!==cn){let n=t.level===0?gu(t,e):t.strategy===aa?Af(t,e):t.strategy===cf?$f(t,e):ln[t.level].func(t,e);if((n===Vi||n===Pr)&&(t.status=cn),n===qe||n===Vi)return i.avail_out===0&&(t.last_flush=-1),Pe;if(n===Lr&&(e===rf?tf(t):e!==Rc&&(oo(t,0,0,!1),e===nf&&(Yt(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),tt(i),i.avail_out===0))return t.last_flush=-1,Pe}return e!==ut?Pe:t.wrap<=0?Nc:(t.wrap===2?(se(t,i.adler&255),se(t,i.adler>>8&255),se(t,i.adler>>16&255),se(t,i.adler>>24&255),se(t,i.total_in&255),se(t,i.total_in>>8&255),se(t,i.total_in>>16&255),se(t,i.total_in>>24&255)):(Wr(t,i.adler>>>16),Wr(t,i.adler&65535)),tt(i),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?Pe:Nc)},Pf=i=>{if(Dn(i))return Ct;let e=i.state.status;return i.state=null,e===Oi?Di(i,af):Pe},Rf=(i,e)=>{let t=e.length;if(Dn(i))return Ct;let r=i.state,n=r.wrap;if(n===2||n===1&&r.status!==_r||r.lookahead)return Ct;if(n===1&&(i.adler=In(i.adler,e,t,0)),r.wrap=0,t>=r.w_size){n===0&&(Yt(r.head),r.strstart=0,r.block_start=0,r.insert=0);let l=new Uint8Array(r.w_size);l.set(e.subarray(t-r.w_size,t),0),e=l,t=r.w_size}let a=i.avail_in,s=i.next_in,o=i.input;for(i.avail_in=t,i.next_in=0,i.input=e,xr(r);r.lookahead>=te;){let l=r.strstart,c=r.lookahead-(te-1);do r.ins_h=ai(r,r.ins_h,r.window[l+te-1]),r.prev[l&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=l,l++;while(--c);r.strstart=l,r.lookahead=te-1,xr(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=te-1,r.match_available=0,i.next_in=s,i.input=o,i.avail_in=a,r.wrap=n,Pe},Nf=Cf,Of=vu,Df=yu,Uf=mu,Mf=Tf,Ff=Lf,jf=Pf,Bf=Rf,qf="pako deflate (from Nodeca project)",yn={deflateInit:Nf,deflateInit2:Of,deflateReset:Df,deflateResetKeep:Uf,deflateSetHeader:Mf,deflate:Ff,deflateEnd:jf,deflateSetDictionary:Bf,deflateInfo:qf},Hf=(i,e)=>Object.prototype.hasOwnProperty.call(i,e),zf=function(i){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 r in t)Hf(t,r)&&(i[r]=t[r])}}return i},Vf=i=>{let e=0;for(let r=0,n=i.length;r<n;r++)e+=i[r].length;let t=new Uint8Array(e);for(let r=0,n=0,a=i.length;r<a;r++){let s=i[r];t.set(s,n),n+=s.length}return t},rs={assign:zf,flattenChunks:Vf},bu=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(i){bu=!1}var Tn=new Uint8Array(256);for(let i=0;i<256;i++)Tn[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;Tn[254]=Tn[254]=1;var Wf=i=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(i);let e,t,r,n,a,s=i.length,o=0;for(n=0;n<s;n++)t=i.charCodeAt(n),(t&64512)===55296&&n+1<s&&(r=i.charCodeAt(n+1),(r&64512)===56320&&(t=65536+(t-55296<<10)+(r-56320),n++)),o+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(o),a=0,n=0;a<o;n++)t=i.charCodeAt(n),(t&64512)===55296&&n+1<s&&(r=i.charCodeAt(n+1),(r&64512)===56320&&(t=65536+(t-55296<<10)+(r-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},Kf=(i,e)=>{if(e<65534&&i.subarray&&bu)return String.fromCharCode.apply(null,i.length===e?i:i.subarray(0,e));let t="";for(let r=0;r<e;r++)t+=String.fromCharCode(i[r]);return t},Qf=(i,e)=>{let t=e||i.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(i.subarray(0,e));let r,n,a=new Array(t*2);for(n=0,r=0;r<t;){let s=i[r++];if(s<128){a[n++]=s;continue}let o=Tn[s];if(o>4){a[n++]=65533,r+=o-1;continue}for(s&=o===2?31:o===3?15:7;o>1&&r<t;)s=s<<6|i[r++]&63,o--;if(o>1){a[n++]=65533;continue}s<65536?a[n++]=s:(s-=65536,a[n++]=55296|s>>10&1023,a[n++]=56320|s&1023)}return Kf(a,n)},Gf=(i,e)=>{e=e||i.length,e>i.length&&(e=i.length);let t=e-1;for(;t>=0&&(i[t]&192)===128;)t--;return t<0||t===0?e:t+Tn[i[t]]>e?t:e},Cn={string2buf:Wf,buf2string:Qf,utf8border:Gf};function Zf(){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 wu=Zf,Su=Object.prototype.toString,{Z_NO_FLUSH:Jf,Z_SYNC_FLUSH:Yf,Z_FULL_FLUSH:Xf,Z_FINISH:eh,Z_OK:Ba,Z_STREAM_END:th,Z_DEFAULT_COMPRESSION:ih,Z_DEFAULT_STRATEGY:rh,Z_DEFLATED:nh}=Xi;function Un(i){this.options=rs.assign({level:ih,method:nh,chunkSize:16384,windowBits:15,memLevel:8,strategy:rh},i||{});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 wu,this.strm.avail_out=0;let t=yn.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(t!==Ba)throw new Error(zi[t]);if(e.header&&yn.deflateSetHeader(this.strm,e.header),e.dictionary){let r;if(typeof e.dictionary=="string"?r=Cn.string2buf(e.dictionary):Su.call(e.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(e.dictionary):r=e.dictionary,t=yn.deflateSetDictionary(this.strm,r),t!==Ba)throw new Error(zi[t]);this._dict_set=!0}}Un.prototype.push=function(i,e){let t=this.strm,r=this.options.chunkSize,n,a;if(this.ended)return!1;for(e===~~e?a=e:a=e===!0?eh:Jf,typeof i=="string"?t.input=Cn.string2buf(i):Su.call(i)==="[object ArrayBuffer]"?t.input=new Uint8Array(i):t.input=i,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(r),t.next_out=0,t.avail_out=r),(a===Yf||a===Xf)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(n=yn.deflate(t,a),n===th)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),n=yn.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Ba;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};Un.prototype.onData=function(i){this.chunks.push(i)};Un.prototype.onEnd=function(i){i===Ba&&(this.result=rs.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function Io(i,e){let t=new Un(e);if(t.push(i,!0),t.err)throw t.msg||zi[t.err];return t.result}function ah(i,e){return e=e||{},e.raw=!0,Io(i,e)}function sh(i,e){return e=e||{},e.gzip=!0,Io(i,e)}var oh=Un,ch=Io,lh=ah,uh=sh,dh=Xi,ph={Deflate:oh,deflate:ch,deflateRaw:lh,gzip:uh,constants:dh},sa=16209,fh=16191,hh=function i(e,t){let r,n,a,s,o,l,c,u,m,y,d,f,g,_,E,A,k,w,C,U,P,Q,V,R,W=e.state;r=e.next_in,V=e.input,n=r+(e.avail_in-5),a=e.next_out,R=e.output,s=a-(t-e.avail_out),o=a+(e.avail_out-257),l=W.dmax,c=W.wsize,u=W.whave,m=W.wnext,y=W.window,d=W.hold,f=W.bits,g=W.lencode,_=W.distcode,E=(1<<W.lenbits)-1,A=(1<<W.distbits)-1;e:do{f<15&&(d+=V[r++]<<f,f+=8,d+=V[r++]<<f,f+=8),k=g[d&E];t:for(;;){if(w=k>>>24,d>>>=w,f-=w,w=k>>>16&255,w===0)R[a++]=k&65535;else if(w&16){C=k&65535,w&=15,w&&(f<w&&(d+=V[r++]<<f,f+=8),C+=d&(1<<w)-1,d>>>=w,f-=w),f<15&&(d+=V[r++]<<f,f+=8,d+=V[r++]<<f,f+=8),k=_[d&A];i:for(;;){if(w=k>>>24,d>>>=w,f-=w,w=k>>>16&255,w&16){if(U=k&65535,w&=15,f<w&&(d+=V[r++]<<f,f+=8,f<w&&(d+=V[r++]<<f,f+=8)),U+=d&(1<<w)-1,U>l){e.msg="invalid distance too far back",W.mode=sa;break e}if(d>>>=w,f-=w,w=a-s,U>w){if(w=U-w,w>u&&W.sane){e.msg="invalid distance too far back",W.mode=sa;break e}if(P=0,Q=y,m===0){if(P+=c-w,w<C){C-=w;do R[a++]=y[P++];while(--w);P=a-U,Q=R}}else if(m<w){if(P+=c+m-w,w-=m,w<C){C-=w;do R[a++]=y[P++];while(--w);if(P=0,m<C){w=m,C-=w;do R[a++]=y[P++];while(--w);P=a-U,Q=R}}}else if(P+=m-w,w<C){C-=w;do R[a++]=y[P++];while(--w);P=a-U,Q=R}for(;C>2;)R[a++]=Q[P++],R[a++]=Q[P++],R[a++]=Q[P++],C-=3;C&&(R[a++]=Q[P++],C>1&&(R[a++]=Q[P++]))}else{P=a-U;do R[a++]=R[P++],R[a++]=R[P++],R[a++]=R[P++],C-=3;while(C>2);C&&(R[a++]=R[P++],C>1&&(R[a++]=R[P++]))}}else if((w&64)===0){k=_[(k&65535)+(d&(1<<w)-1)];continue i}else{e.msg="invalid distance code",W.mode=sa;break e}break}}else if((w&64)===0){k=g[(k&65535)+(d&(1<<w)-1)];continue t}else if(w&32){W.mode=fh;break e}else{e.msg="invalid literal/length code",W.mode=sa;break e}break}}while(r<n&&a<o);C=f>>3,r-=C,f-=C<<3,d&=(1<<f)-1,e.next_in=r,e.next_out=a,e.avail_in=r<n?5+(n-r):5-(r-n),e.avail_out=a<o?257+(o-a):257-(a-o),W.hold=d,W.bits=f},pr=15,Dc=852,Uc=592,Mc=0,Ms=1,Fc=2,gh=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]),mh=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]),yh=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]),vh=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]),bh=(i,e,t,r,n,a,s,o)=>{let l=o.bits,c=0,u=0,m=0,y=0,d=0,f=0,g=0,_=0,E=0,A=0,k,w,C,U,P,Q=null,V,R=new Uint16Array(pr+1),W=new Uint16Array(pr+1),We=null,Or,T,jn;for(c=0;c<=pr;c++)R[c]=0;for(u=0;u<r;u++)R[e[t+u]]++;for(d=l,y=pr;y>=1&&R[y]===0;y--);if(d>y&&(d=y),y===0)return n[a++]=1<<24|64<<16|0,n[a++]=1<<24|64<<16|0,o.bits=1,0;for(m=1;m<y&&R[m]===0;m++);for(d<m&&(d=m),_=1,c=1;c<=pr;c++)if(_<<=1,_-=R[c],_<0)return-1;if(_>0&&(i===Mc||y!==1))return-1;for(W[1]=0,c=1;c<pr;c++)W[c+1]=W[c]+R[c];for(u=0;u<r;u++)e[t+u]!==0&&(s[W[e[t+u]]++]=u);if(i===Mc?(Q=We=s,V=20):i===Ms?(Q=gh,We=mh,V=257):(Q=yh,We=vh,V=0),A=0,u=0,c=m,P=a,f=d,g=0,C=-1,E=1<<d,U=E-1,i===Ms&&E>Dc||i===Fc&&E>Uc)return 1;for(;;){Or=c-g,s[u]+1<V?(T=0,jn=s[u]):s[u]>=V?(T=We[s[u]-V],jn=Q[s[u]-V]):(T=32+64,jn=0),k=1<<c-g,w=1<<f,m=w;do w-=k,n[P+(A>>g)+w]=Or<<24|T<<16|jn|0;while(w!==0);for(k=1<<c-1;A&k;)k>>=1;if(k!==0?(A&=k-1,A+=k):A=0,u++,--R[c]===0){if(c===y)break;c=e[t+s[u]]}if(c>d&&(A&U)!==C){for(g===0&&(g=d),P+=m,f=c-g,_=1<<f;f+g<y&&(_-=R[f+g],!(_<=0));)f++,_<<=1;if(E+=1<<f,i===Ms&&E>Dc||i===Fc&&E>Uc)return 1;C=A&U,n[C]=d<<24|f<<16|P-a|0}}return A!==0&&(n[P+A]=c-g<<24|64<<16|0),o.bits=d,0},vn=bh,wh=0,_u=1,xu=2,{Z_FINISH:jc,Z_BLOCK:Sh,Z_TREES:oa,Z_OK:Wi,Z_STREAM_END:_h,Z_NEED_DICT:xh,Z_STREAM_ERROR:pt,Z_DATA_ERROR:Eu,Z_MEM_ERROR:$u,Z_BUF_ERROR:Eh,Z_DEFLATED:Bc}=Xi,ns=16180,qc=16181,Hc=16182,zc=16183,Vc=16184,Wc=16185,Kc=16186,Qc=16187,Gc=16188,Zc=16189,qa=16190,Ut=16191,Fs=16192,Jc=16193,js=16194,Yc=16195,Xc=16196,el=16197,tl=16198,ca=16199,la=16200,il=16201,rl=16202,nl=16203,al=16204,sl=16205,Bs=16206,ol=16207,cl=16208,fe=16209,Au=16210,ku=16211,$h=852,Ah=592,kh=15,Ih=kh,ll=i=>(i>>>24&255)+(i>>>8&65280)+((i&65280)<<8)+((i&255)<<24);function Th(){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 er=i=>{if(!i)return 1;let e=i.state;return!e||e.strm!==i||e.mode<ns||e.mode>ku?1:0},Iu=i=>{if(er(i))return pt;let e=i.state;return i.total_in=i.total_out=e.total=0,i.msg="",e.wrap&&(i.adler=e.wrap&1),e.mode=ns,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($h),e.distcode=e.distdyn=new Int32Array(Ah),e.sane=1,e.back=-1,Wi},Tu=i=>{if(er(i))return pt;let e=i.state;return e.wsize=0,e.whave=0,e.wnext=0,Iu(i)},Cu=(i,e)=>{let t;if(er(i))return pt;let r=i.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?pt:(r.window!==null&&r.wbits!==e&&(r.window=null),r.wrap=t,r.wbits=e,Tu(i))},Lu=(i,e)=>{if(!i)return pt;let t=new Th;i.state=t,t.strm=i,t.window=null,t.mode=ns;let r=Cu(i,e);return r!==Wi&&(i.state=null),r},Ch=i=>Lu(i,Ih),ul=!0,qs,Hs,Lh=i=>{if(ul){qs=new Int32Array(512),Hs=new Int32Array(32);let e=0;for(;e<144;)i.lens[e++]=8;for(;e<256;)i.lens[e++]=9;for(;e<280;)i.lens[e++]=7;for(;e<288;)i.lens[e++]=8;for(vn(_u,i.lens,0,288,qs,0,i.work,{bits:9}),e=0;e<32;)i.lens[e++]=5;vn(xu,i.lens,0,32,Hs,0,i.work,{bits:5}),ul=!1}i.lencode=qs,i.lenbits=9,i.distcode=Hs,i.distbits=5},Pu=(i,e,t,r)=>{let n,a=i.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),r>=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>r&&(n=r),a.window.set(e.subarray(t-r,t-r+n),a.wnext),r-=n,r?(a.window.set(e.subarray(t-r,t),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=n))),0},Ph=(i,e)=>{let t,r,n,a,s,o,l,c,u,m,y,d,f,g,_=0,E,A,k,w,C,U,P,Q,V=new Uint8Array(4),R,W,We=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(er(i)||!i.output||!i.input&&i.avail_in!==0)return pt;t=i.state,t.mode===Ut&&(t.mode=Fs),s=i.next_out,n=i.output,l=i.avail_out,a=i.next_in,r=i.input,o=i.avail_in,c=t.hold,u=t.bits,m=o,y=l,Q=Wi;e:for(;;)switch(t.mode){case ns:if(t.wrap===0){t.mode=Fs;break}for(;u<16;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}if(t.wrap&2&&c===35615){t.wbits===0&&(t.wbits=15),t.check=0,V[0]=c&255,V[1]=c>>>8&255,t.check=ke(t.check,V,2,0),c=0,u=0,t.mode=qc;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((c&255)<<8)+(c>>8))%31){i.msg="incorrect header check",t.mode=fe;break}if((c&15)!==Bc){i.msg="unknown compression method",t.mode=fe;break}if(c>>>=4,u-=4,P=(c&15)+8,t.wbits===0&&(t.wbits=P),P>15||P>t.wbits){i.msg="invalid window size",t.mode=fe;break}t.dmax=1<<t.wbits,t.flags=0,i.adler=t.check=1,t.mode=c&512?Zc:Ut,c=0,u=0;break;case qc:for(;u<16;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}if(t.flags=c,(t.flags&255)!==Bc){i.msg="unknown compression method",t.mode=fe;break}if(t.flags&57344){i.msg="unknown header flags set",t.mode=fe;break}t.head&&(t.head.text=c>>8&1),t.flags&512&&t.wrap&4&&(V[0]=c&255,V[1]=c>>>8&255,t.check=ke(t.check,V,2,0)),c=0,u=0,t.mode=Hc;case Hc:for(;u<32;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}t.head&&(t.head.time=c),t.flags&512&&t.wrap&4&&(V[0]=c&255,V[1]=c>>>8&255,V[2]=c>>>16&255,V[3]=c>>>24&255,t.check=ke(t.check,V,4,0)),c=0,u=0,t.mode=zc;case zc:for(;u<16;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}t.head&&(t.head.xflags=c&255,t.head.os=c>>8),t.flags&512&&t.wrap&4&&(V[0]=c&255,V[1]=c>>>8&255,t.check=ke(t.check,V,2,0)),c=0,u=0,t.mode=Vc;case Vc:if(t.flags&1024){for(;u<16;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}t.length=c,t.head&&(t.head.extra_len=c),t.flags&512&&t.wrap&4&&(V[0]=c&255,V[1]=c>>>8&255,t.check=ke(t.check,V,2,0)),c=0,u=0}else t.head&&(t.head.extra=null);t.mode=Wc;case Wc:if(t.flags&1024&&(d=t.length,d>o&&(d=o),d&&(t.head&&(P=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(r.subarray(a,a+d),P)),t.flags&512&&t.wrap&4&&(t.check=ke(t.check,r,d,a)),o-=d,a+=d,t.length-=d),t.length))break e;t.length=0,t.mode=Kc;case Kc:if(t.flags&2048){if(o===0)break e;d=0;do P=r[a+d++],t.head&&P&&t.length<65536&&(t.head.name+=String.fromCharCode(P));while(P&&d<o);if(t.flags&512&&t.wrap&4&&(t.check=ke(t.check,r,d,a)),o-=d,a+=d,P)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=Qc;case Qc:if(t.flags&4096){if(o===0)break e;d=0;do P=r[a+d++],t.head&&P&&t.length<65536&&(t.head.comment+=String.fromCharCode(P));while(P&&d<o);if(t.flags&512&&t.wrap&4&&(t.check=ke(t.check,r,d,a)),o-=d,a+=d,P)break e}else t.head&&(t.head.comment=null);t.mode=Gc;case Gc:if(t.flags&512){for(;u<16;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}if(t.wrap&4&&c!==(t.check&65535)){i.msg="header crc mismatch",t.mode=fe;break}c=0,u=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),i.adler=t.check=0,t.mode=Ut;break;case Zc:for(;u<32;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}i.adler=t.check=ll(c),c=0,u=0,t.mode=qa;case qa:if(t.havedict===0)return i.next_out=s,i.avail_out=l,i.next_in=a,i.avail_in=o,t.hold=c,t.bits=u,xh;i.adler=t.check=1,t.mode=Ut;case Ut:if(e===Sh||e===oa)break e;case Fs:if(t.last){c>>>=u&7,u-=u&7,t.mode=Bs;break}for(;u<3;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}switch(t.last=c&1,c>>>=1,u-=1,c&3){case 0:t.mode=Jc;break;case 1:if(Lh(t),t.mode=ca,e===oa){c>>>=2,u-=2;break e}break;case 2:t.mode=Xc;break;case 3:i.msg="invalid block type",t.mode=fe}c>>>=2,u-=2;break;case Jc:for(c>>>=u&7,u-=u&7;u<32;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}if((c&65535)!==(c>>>16^65535)){i.msg="invalid stored block lengths",t.mode=fe;break}if(t.length=c&65535,c=0,u=0,t.mode=js,e===oa)break e;case js:t.mode=Yc;case Yc:if(d=t.length,d){if(d>o&&(d=o),d>l&&(d=l),d===0)break e;n.set(r.subarray(a,a+d),s),o-=d,a+=d,l-=d,s+=d,t.length-=d;break}t.mode=Ut;break;case Xc:for(;u<14;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}if(t.nlen=(c&31)+257,c>>>=5,u-=5,t.ndist=(c&31)+1,c>>>=5,u-=5,t.ncode=(c&15)+4,c>>>=4,u-=4,t.nlen>286||t.ndist>30){i.msg="too many length or distance symbols",t.mode=fe;break}t.have=0,t.mode=el;case el:for(;t.have<t.ncode;){for(;u<3;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}t.lens[We[t.have++]]=c&7,c>>>=3,u-=3}for(;t.have<19;)t.lens[We[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,R={bits:t.lenbits},Q=vn(wh,t.lens,0,19,t.lencode,0,t.work,R),t.lenbits=R.bits,Q){i.msg="invalid code lengths set",t.mode=fe;break}t.have=0,t.mode=tl;case tl:for(;t.have<t.nlen+t.ndist;){for(;_=t.lencode[c&(1<<t.lenbits)-1],E=_>>>24,A=_>>>16&255,k=_&65535,!(E<=u);){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}if(k<16)c>>>=E,u-=E,t.lens[t.have++]=k;else{if(k===16){for(W=E+2;u<W;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}if(c>>>=E,u-=E,t.have===0){i.msg="invalid bit length repeat",t.mode=fe;break}P=t.lens[t.have-1],d=3+(c&3),c>>>=2,u-=2}else if(k===17){for(W=E+3;u<W;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}c>>>=E,u-=E,P=0,d=3+(c&7),c>>>=3,u-=3}else{for(W=E+7;u<W;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}c>>>=E,u-=E,P=0,d=11+(c&127),c>>>=7,u-=7}if(t.have+d>t.nlen+t.ndist){i.msg="invalid bit length repeat",t.mode=fe;break}for(;d--;)t.lens[t.have++]=P}}if(t.mode===fe)break;if(t.lens[256]===0){i.msg="invalid code -- missing end-of-block",t.mode=fe;break}if(t.lenbits=9,R={bits:t.lenbits},Q=vn(_u,t.lens,0,t.nlen,t.lencode,0,t.work,R),t.lenbits=R.bits,Q){i.msg="invalid literal/lengths set",t.mode=fe;break}if(t.distbits=6,t.distcode=t.distdyn,R={bits:t.distbits},Q=vn(xu,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,R),t.distbits=R.bits,Q){i.msg="invalid distances set",t.mode=fe;break}if(t.mode=ca,e===oa)break e;case ca:t.mode=la;case la:if(o>=6&&l>=258){i.next_out=s,i.avail_out=l,i.next_in=a,i.avail_in=o,t.hold=c,t.bits=u,hh(i,y),s=i.next_out,n=i.output,l=i.avail_out,a=i.next_in,r=i.input,o=i.avail_in,c=t.hold,u=t.bits,t.mode===Ut&&(t.back=-1);break}for(t.back=0;_=t.lencode[c&(1<<t.lenbits)-1],E=_>>>24,A=_>>>16&255,k=_&65535,!(E<=u);){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}if(A&&(A&240)===0){for(w=E,C=A,U=k;_=t.lencode[U+((c&(1<<w+C)-1)>>w)],E=_>>>24,A=_>>>16&255,k=_&65535,!(w+E<=u);){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}c>>>=w,u-=w,t.back+=w}if(c>>>=E,u-=E,t.back+=E,t.length=k,A===0){t.mode=sl;break}if(A&32){t.back=-1,t.mode=Ut;break}if(A&64){i.msg="invalid literal/length code",t.mode=fe;break}t.extra=A&15,t.mode=il;case il:if(t.extra){for(W=t.extra;u<W;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}t.length+=c&(1<<t.extra)-1,c>>>=t.extra,u-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=rl;case rl:for(;_=t.distcode[c&(1<<t.distbits)-1],E=_>>>24,A=_>>>16&255,k=_&65535,!(E<=u);){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}if((A&240)===0){for(w=E,C=A,U=k;_=t.distcode[U+((c&(1<<w+C)-1)>>w)],E=_>>>24,A=_>>>16&255,k=_&65535,!(w+E<=u);){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}c>>>=w,u-=w,t.back+=w}if(c>>>=E,u-=E,t.back+=E,A&64){i.msg="invalid distance code",t.mode=fe;break}t.offset=k,t.extra=A&15,t.mode=nl;case nl:if(t.extra){for(W=t.extra;u<W;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}t.offset+=c&(1<<t.extra)-1,c>>>=t.extra,u-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){i.msg="invalid distance too far back",t.mode=fe;break}t.mode=al;case al:if(l===0)break e;if(d=y-l,t.offset>d){if(d=t.offset-d,d>t.whave&&t.sane){i.msg="invalid distance too far back",t.mode=fe;break}d>t.wnext?(d-=t.wnext,f=t.wsize-d):f=t.wnext-d,d>t.length&&(d=t.length),g=t.window}else g=n,f=s-t.offset,d=t.length;d>l&&(d=l),l-=d,t.length-=d;do n[s++]=g[f++];while(--d);t.length===0&&(t.mode=la);break;case sl:if(l===0)break e;n[s++]=t.length,l--,t.mode=la;break;case Bs:if(t.wrap){for(;u<32;){if(o===0)break e;o--,c|=r[a++]<<u,u+=8}if(y-=l,i.total_out+=y,t.total+=y,t.wrap&4&&y&&(i.adler=t.check=t.flags?ke(t.check,n,y,s-y):In(t.check,n,y,s-y)),y=l,t.wrap&4&&(t.flags?c:ll(c))!==t.check){i.msg="incorrect data check",t.mode=fe;break}c=0,u=0}t.mode=ol;case ol:if(t.wrap&&t.flags){for(;u<32;){if(o===0)break e;o--,c+=r[a++]<<u,u+=8}if(t.wrap&4&&c!==(t.total&4294967295)){i.msg="incorrect length check",t.mode=fe;break}c=0,u=0}t.mode=cl;case cl:Q=_h;break e;case fe:Q=Eu;break e;case Au:return $u;case ku:default:return pt}return i.next_out=s,i.avail_out=l,i.next_in=a,i.avail_in=o,t.hold=c,t.bits=u,(t.wsize||y!==i.avail_out&&t.mode<fe&&(t.mode<Bs||e!==jc))&&Pu(i,i.output,i.next_out,y-i.avail_out),m-=i.avail_in,y-=i.avail_out,i.total_in+=m,i.total_out+=y,t.total+=y,t.wrap&4&&y&&(i.adler=t.check=t.flags?ke(t.check,n,y,i.next_out-y):In(t.check,n,y,i.next_out-y)),i.data_type=t.bits+(t.last?64:0)+(t.mode===Ut?128:0)+(t.mode===ca||t.mode===js?256:0),(m===0&&y===0||e===jc)&&Q===Wi&&(Q=Eh),Q},Rh=i=>{if(er(i))return pt;let e=i.state;return e.window&&(e.window=null),i.state=null,Wi},Nh=(i,e)=>{if(er(i))return pt;let t=i.state;return(t.wrap&2)===0?pt:(t.head=e,e.done=!1,Wi)},Oh=(i,e)=>{let t=e.length,r,n,a;return er(i)||(r=i.state,r.wrap!==0&&r.mode!==qa)?pt:r.mode===qa&&(n=1,n=In(n,e,t,0),n!==r.check)?Eu:(a=Pu(i,e,t,t),a?(r.mode=Au,$u):(r.havedict=1,Wi))},Dh=Tu,Uh=Cu,Mh=Iu,Fh=Ch,jh=Lu,Bh=Ph,qh=Rh,Hh=Nh,zh=Oh,Vh="pako inflate (from Nodeca project)",qt={inflateReset:Dh,inflateReset2:Uh,inflateResetKeep:Mh,inflateInit:Fh,inflateInit2:jh,inflate:Bh,inflateEnd:qh,inflateGetHeader:Hh,inflateSetDictionary:zh,inflateInfo:Vh};function Wh(){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 Kh=Wh,Ru=Object.prototype.toString,{Z_NO_FLUSH:Qh,Z_FINISH:Gh,Z_OK:Ln,Z_STREAM_END:zs,Z_NEED_DICT:Vs,Z_STREAM_ERROR:Zh,Z_DATA_ERROR:dl,Z_MEM_ERROR:Jh}=Xi;function Mn(i){this.options=rs.assign({chunkSize:1024*64,windowBits:15,to:""},i||{});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&&!(i&&i.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 wu,this.strm.avail_out=0;let t=qt.inflateInit2(this.strm,e.windowBits);if(t!==Ln)throw new Error(zi[t]);if(this.header=new Kh,qt.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Cn.string2buf(e.dictionary):Ru.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=qt.inflateSetDictionary(this.strm,e.dictionary),t!==Ln)))throw new Error(zi[t])}Mn.prototype.push=function(i,e){let t=this.strm,r=this.options.chunkSize,n=this.options.dictionary,a,s,o;if(this.ended)return!1;for(e===~~e?s=e:s=e===!0?Gh:Qh,Ru.call(i)==="[object ArrayBuffer]"?t.input=new Uint8Array(i):t.input=i,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(r),t.next_out=0,t.avail_out=r),a=qt.inflate(t,s),a===Vs&&n&&(a=qt.inflateSetDictionary(t,n),a===Ln?a=qt.inflate(t,s):a===dl&&(a=Vs));t.avail_in>0&&a===zs&&t.state.wrap>0&&i[t.next_in]!==0;)qt.inflateReset(t),a=qt.inflate(t,s);switch(a){case Zh:case dl:case Vs:case Jh:return this.onEnd(a),this.ended=!0,!1}if(o=t.avail_out,t.next_out&&(t.avail_out===0||a===zs))if(this.options.to==="string"){let l=Cn.utf8border(t.output,t.next_out),c=t.next_out-l,u=Cn.buf2string(t.output,l);t.next_out=c,t.avail_out=r-c,c&&t.output.set(t.output.subarray(l,l+c),0),this.onData(u)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(a===Ln&&o===0)){if(a===zs)return a=qt.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};Mn.prototype.onData=function(i){this.chunks.push(i)};Mn.prototype.onEnd=function(i){i===Ln&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=rs.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function To(i,e){let t=new Mn(e);if(t.push(i),t.err)throw t.msg||zi[t.err];return t.result}function Yh(i,e){return e=e||{},e.raw=!0,To(i,e)}var Xh=Mn,eg=To,tg=Yh,ig=To,rg=Xi,ng={Inflate:Xh,inflate:eg,inflateRaw:tg,ungzip:ig,constants:rg},{Deflate:ag,deflate:sg,deflateRaw:og,gzip:cg}=ph,{Inflate:lg,inflate:ug,inflateRaw:dg,ungzip:pg}=ng,fg=ag,hg=sg,gg=og,mg=cg,yg=lg,vg=ug,bg=dg,wg=pg,Sg=Xi,_g={Deflate:fg,deflate:hg,deflateRaw:gg,gzip:mg,Inflate:yg,inflate:vg,inflateRaw:bg,ungzip:wg,constants:Sg},ue=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},de=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Ha=class{constructor(e,t){this.input=e,this.output=t}};ue([h(),de("design:type",String)],Ha.prototype,"input",void 0);ue([h(),de("design:type",String)],Ha.prototype,"output",void 0);Ha=ue([Te(),de("design:paramtypes",[String,String])],Ha);var za=class{constructor(e,t){this.input=e,this.output=t}};ue([h(),de("design:type",String)],za.prototype,"input",void 0);ue([h(),de("design:type",String)],za.prototype,"output",void 0);za=ue([H(),de("design:paramtypes",[String,String])],za);var li=class{constructor(e,t,r,n,a){this.name=e,this.modelId=t,this.systemPrompt=r,this.promptExamples=n,this.metaData=a}};ue([h(),de("design:type",String)],li.prototype,"name",void 0);ue([h(),de("design:type",String)],li.prototype,"modelId",void 0);ue([h(),de("design:type",String)],li.prototype,"systemPrompt",void 0);ue([h(),de("design:type",Array)],li.prototype,"promptExamples",void 0);ue([h(),de("design:type",String)],li.prototype,"metaData",void 0);li=ue([Te(),de("design:paramtypes",[String,String,String,Array,String])],li);var Nt=class{constructor(e,t,r,n,a,s,o,l){this.name=e,this.modelId=t,this.taskId=r,this.systemPrompt=n,this.promptExamples=a,this.metaData=s,this.createdAt=o,this.updatedAt=l}};ue([h(),de("design:type",String)],Nt.prototype,"name",void 0);ue([h(),de("design:type",String)],Nt.prototype,"modelId",void 0);ue([h(),de("design:type",String)],Nt.prototype,"taskId",void 0);ue([h(),de("design:type",String)],Nt.prototype,"systemPrompt",void 0);ue([h(),de("design:type",Array)],Nt.prototype,"promptExamples",void 0);ue([h(),de("design:type",String)],Nt.prototype,"metaData",void 0);ue([h(),de("design:type",String)],Nt.prototype,"createdAt",void 0);ue([h(),de("design:type",String)],Nt.prototype,"updatedAt",void 0);Nt=ue([H(),de("design:paramtypes",[String,String,String,String,Array,String,String,String])],Nt);var Ki=class{constructor(e,t,r,n,a){this.model=e,this.status=t,this.progress=r,this.downloaded=n,this.loaded=a}};ue([h(),de("design:type",String)],Ki.prototype,"model",void 0);ue([h(),de("design:type",String)],Ki.prototype,"status",void 0);ue([h(),de("design:type",Number)],Ki.prototype,"progress",void 0);ue([h(),de("design:type",Boolean)],Ki.prototype,"downloaded",void 0);ue([h(),de("design:type",Boolean)],Ki.prototype,"loaded",void 0);Ki=ue([H(),de("design:paramtypes",[String,String,Number,Boolean,Boolean])],Ki);var xg=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},$e=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},_e,Ea,go=class{constructor(e,t=!0){_e.set(this,void 0),Ea.set(this,new Map),xg(this,_e,e,"f")}async getModels(){let e=await $e(this,_e,"f").query({query:v`
1266
+ }`,variables:{url:e,interactionCall:t}}));return r}};Ot=new WeakMap;var us={};us.byteLength=Dp;us.toByteArray=Fp;us.fromByteArray=Bp;var _t=[],lt=[],Up=typeof Uint8Array<"u"?Uint8Array:Array,js="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Ai=0,Mc=js.length;Ai<Mc;++Ai)_t[Ai]=js[Ai],lt[js.charCodeAt(Ai)]=Ai;var Ai,Mc;lt["-".charCodeAt(0)]=62;lt["_".charCodeAt(0)]=63;function pu(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function Dp(i){var e=pu(i),t=e[0],r=e[1];return(t+r)*3/4-r}function Mp(i,e,t){return(e+t)*3/4-t}function Fp(i){var e,t=pu(i),r=t[0],n=t[1],a=new Up(Mp(i,r,n)),s=0,o=n>0?r-4:r,c;for(c=0;c<o;c+=4)e=lt[i.charCodeAt(c)]<<18|lt[i.charCodeAt(c+1)]<<12|lt[i.charCodeAt(c+2)]<<6|lt[i.charCodeAt(c+3)],a[s++]=e>>16&255,a[s++]=e>>8&255,a[s++]=e&255;return n===2&&(e=lt[i.charCodeAt(c)]<<2|lt[i.charCodeAt(c+1)]>>4,a[s++]=e&255),n===1&&(e=lt[i.charCodeAt(c)]<<10|lt[i.charCodeAt(c+1)]<<4|lt[i.charCodeAt(c+2)]>>2,a[s++]=e>>8&255,a[s++]=e&255),a}function jp(i){return _t[i>>18&63]+_t[i>>12&63]+_t[i>>6&63]+_t[i&63]}function qp(i,e,t){for(var r,n=[],a=e;a<t;a+=3)r=(i[a]<<16&16711680)+(i[a+1]<<8&65280)+(i[a+2]&255),n.push(jp(r));return n.join("")}function Bp(i){for(var e,t=i.length,r=t%3,n=[],a=16383,s=0,o=t-r;s<o;s+=a)n.push(qp(i,s,s+a>o?o:s+a));return r===1?(e=i[t-1],n.push(_t[e>>2]+_t[e<<4&63]+"==")):r===2&&(e=(i[t-2]<<8)+i[t-1],n.push(_t[e>>10]+_t[e>>4&63]+_t[e<<2&63]+"=")),n.join("")}var Hp=4,Fc=0,jc=1,zp=2;function Ur(i){let e=i.length;for(;--e>=0;)i[e]=0}var Vp=0,fu=1,Wp=2,Kp=3,Qp=258,Ro=29,zn=256,Rn=zn+1+Ro,xr=30,No=19,hu=2*Rn+1,Mi=15,qs=16,Gp=7,Oo=256,gu=16,mu=17,yu=18,mo=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]),Pa=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]),Zp=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),vu=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Jp=512,Ut=new Array((Rn+2)*2);Ur(Ut);var En=new Array(xr*2);Ur(En);var Nn=new Array(Jp);Ur(Nn);var On=new Array(Qp-Kp+1);Ur(On);var Uo=new Array(Ro);Ur(Uo);var Ga=new Array(xr);Ur(Ga);function Bs(i,e,t,r,n){this.static_tree=i,this.extra_bits=e,this.extra_base=t,this.elems=r,this.max_length=n,this.has_stree=i&&i.length}var bu,wu,Su;function Hs(i,e){this.dyn_tree=i,this.max_code=0,this.stat_desc=e}var _u=i=>i<256?Nn[i]:Nn[256+(i>>>7)],Un=(i,e)=>{i.pending_buf[i.pending++]=e&255,i.pending_buf[i.pending++]=e>>>8&255},Ye=(i,e,t)=>{i.bi_valid>qs-t?(i.bi_buf|=e<<i.bi_valid&65535,Un(i,i.bi_buf),i.bi_buf=e>>qs-i.bi_valid,i.bi_valid+=t-qs):(i.bi_buf|=e<<i.bi_valid&65535,i.bi_valid+=t)},xt=(i,e,t)=>{Ye(i,t[e*2],t[e*2+1])},xu=(i,e)=>{let t=0;do t|=i&1,i>>>=1,t<<=1;while(--e>0);return t>>>1},Xp=i=>{i.bi_valid===16?(Un(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)},Yp=(i,e)=>{let t=e.dyn_tree,r=e.max_code,n=e.stat_desc.static_tree,a=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,c=e.stat_desc.max_length,l,u,m,y,d,f,h=0;for(y=0;y<=Mi;y++)i.bl_count[y]=0;for(t[i.heap[i.heap_max]*2+1]=0,l=i.heap_max+1;l<hu;l++)u=i.heap[l],y=t[t[u*2+1]*2+1]+1,y>c&&(y=c,h++),t[u*2+1]=y,!(u>r)&&(i.bl_count[y]++,d=0,u>=o&&(d=s[u-o]),f=t[u*2],i.opt_len+=f*(y+d),a&&(i.static_len+=f*(n[u*2+1]+d)));if(h!==0){do{for(y=c-1;i.bl_count[y]===0;)y--;i.bl_count[y]--,i.bl_count[y+1]+=2,i.bl_count[c]--,h-=2}while(h>0);for(y=c;y!==0;y--)for(u=i.bl_count[y];u!==0;)m=i.heap[--l],!(m>r)&&(t[m*2+1]!==y&&(i.opt_len+=(y-t[m*2+1])*t[m*2],t[m*2+1]=y),u--)}},$u=(i,e,t)=>{let r=new Array(Mi+1),n=0,a,s;for(a=1;a<=Mi;a++)n=n+t[a-1]<<1,r[a]=n;for(s=0;s<=e;s++){let o=i[s*2+1];o!==0&&(i[s*2]=xu(r[o]++,o))}},ef=()=>{let i,e,t,r,n,a=new Array(Mi+1);for(t=0,r=0;r<Ro-1;r++)for(Uo[r]=t,i=0;i<1<<mo[r];i++)On[t++]=r;for(On[t-1]=r,n=0,r=0;r<16;r++)for(Ga[r]=n,i=0;i<1<<Pa[r];i++)Nn[n++]=r;for(n>>=7;r<xr;r++)for(Ga[r]=n<<7,i=0;i<1<<Pa[r]-7;i++)Nn[256+n++]=r;for(e=0;e<=Mi;e++)a[e]=0;for(i=0;i<=143;)Ut[i*2+1]=8,i++,a[8]++;for(;i<=255;)Ut[i*2+1]=9,i++,a[9]++;for(;i<=279;)Ut[i*2+1]=7,i++,a[7]++;for(;i<=287;)Ut[i*2+1]=8,i++,a[8]++;for($u(Ut,Rn+1,a),i=0;i<xr;i++)En[i*2+1]=5,En[i*2]=xu(i,5);bu=new Bs(Ut,mo,zn+1,Rn,Mi),wu=new Bs(En,Pa,0,xr,Mi),Su=new Bs(new Array(0),Zp,0,No,Gp)},Eu=i=>{let e;for(e=0;e<Rn;e++)i.dyn_ltree[e*2]=0;for(e=0;e<xr;e++)i.dyn_dtree[e*2]=0;for(e=0;e<No;e++)i.bl_tree[e*2]=0;i.dyn_ltree[Oo*2]=1,i.opt_len=i.static_len=0,i.sym_next=i.matches=0},Au=i=>{i.bi_valid>8?Un(i,i.bi_buf):i.bi_valid>0&&(i.pending_buf[i.pending++]=i.bi_buf),i.bi_buf=0,i.bi_valid=0},qc=(i,e,t,r)=>{let n=e*2,a=t*2;return i[n]<i[a]||i[n]===i[a]&&r[e]<=r[t]},zs=(i,e,t)=>{let r=i.heap[t],n=t<<1;for(;n<=i.heap_len&&(n<i.heap_len&&qc(e,i.heap[n+1],i.heap[n],i.depth)&&n++,!qc(e,r,i.heap[n],i.depth));)i.heap[t]=i.heap[n],t=n,n<<=1;i.heap[t]=r},Bc=(i,e,t)=>{let r,n,a=0,s,o;if(i.sym_next!==0)do r=i.pending_buf[i.sym_buf+a++]&255,r+=(i.pending_buf[i.sym_buf+a++]&255)<<8,n=i.pending_buf[i.sym_buf+a++],r===0?xt(i,n,e):(s=On[n],xt(i,s+zn+1,e),o=mo[s],o!==0&&(n-=Uo[s],Ye(i,n,o)),r--,s=_u(r),xt(i,s,t),o=Pa[s],o!==0&&(r-=Ga[s],Ye(i,r,o)));while(a<i.sym_next);xt(i,Oo,e)},yo=(i,e)=>{let t=e.dyn_tree,r=e.stat_desc.static_tree,n=e.stat_desc.has_stree,a=e.stat_desc.elems,s,o,c=-1,l;for(i.heap_len=0,i.heap_max=hu,s=0;s<a;s++)t[s*2]!==0?(i.heap[++i.heap_len]=c=s,i.depth[s]=0):t[s*2+1]=0;for(;i.heap_len<2;)l=i.heap[++i.heap_len]=c<2?++c:0,t[l*2]=1,i.depth[l]=0,i.opt_len--,n&&(i.static_len-=r[l*2+1]);for(e.max_code=c,s=i.heap_len>>1;s>=1;s--)zs(i,t,s);l=a;do s=i.heap[1],i.heap[1]=i.heap[i.heap_len--],zs(i,t,1),o=i.heap[1],i.heap[--i.heap_max]=s,i.heap[--i.heap_max]=o,t[l*2]=t[s*2]+t[o*2],i.depth[l]=(i.depth[s]>=i.depth[o]?i.depth[s]:i.depth[o])+1,t[s*2+1]=t[o*2+1]=l,i.heap[1]=l++,zs(i,t,1);while(i.heap_len>=2);i.heap[--i.heap_max]=i.heap[1],Yp(i,e),$u(t,c,i.bl_count)},Hc=(i,e,t)=>{let r,n=-1,a,s=e[0*2+1],o=0,c=7,l=4;for(s===0&&(c=138,l=3),e[(t+1)*2+1]=65535,r=0;r<=t;r++)a=s,s=e[(r+1)*2+1],!(++o<c&&a===s)&&(o<l?i.bl_tree[a*2]+=o:a!==0?(a!==n&&i.bl_tree[a*2]++,i.bl_tree[gu*2]++):o<=10?i.bl_tree[mu*2]++:i.bl_tree[yu*2]++,o=0,n=a,s===0?(c=138,l=3):a===s?(c=6,l=3):(c=7,l=4))},zc=(i,e,t)=>{let r,n=-1,a,s=e[0*2+1],o=0,c=7,l=4;for(s===0&&(c=138,l=3),r=0;r<=t;r++)if(a=s,s=e[(r+1)*2+1],!(++o<c&&a===s)){if(o<l)do xt(i,a,i.bl_tree);while(--o!==0);else a!==0?(a!==n&&(xt(i,a,i.bl_tree),o--),xt(i,gu,i.bl_tree),Ye(i,o-3,2)):o<=10?(xt(i,mu,i.bl_tree),Ye(i,o-3,3)):(xt(i,yu,i.bl_tree),Ye(i,o-11,7));o=0,n=a,s===0?(c=138,l=3):a===s?(c=6,l=3):(c=7,l=4)}},tf=i=>{let e;for(Hc(i,i.dyn_ltree,i.l_desc.max_code),Hc(i,i.dyn_dtree,i.d_desc.max_code),yo(i,i.bl_desc),e=No-1;e>=3&&i.bl_tree[vu[e]*2+1]===0;e--);return i.opt_len+=3*(e+1)+5+5+4,e},rf=(i,e,t,r)=>{let n;for(Ye(i,e-257,5),Ye(i,t-1,5),Ye(i,r-4,4),n=0;n<r;n++)Ye(i,i.bl_tree[vu[n]*2+1],3);zc(i,i.dyn_ltree,e-1),zc(i,i.dyn_dtree,t-1)},nf=i=>{let e=4093624447,t;for(t=0;t<=31;t++,e>>>=1)if(e&1&&i.dyn_ltree[t*2]!==0)return Fc;if(i.dyn_ltree[9*2]!==0||i.dyn_ltree[10*2]!==0||i.dyn_ltree[13*2]!==0)return jc;for(t=32;t<zn;t++)if(i.dyn_ltree[t*2]!==0)return jc;return Fc},Vc=!1,af=i=>{Vc||(ef(),Vc=!0),i.l_desc=new Hs(i.dyn_ltree,bu),i.d_desc=new Hs(i.dyn_dtree,wu),i.bl_desc=new Hs(i.bl_tree,Su),i.bi_buf=0,i.bi_valid=0,Eu(i)},ku=(i,e,t,r)=>{Ye(i,(Vp<<1)+(r?1:0),3),Au(i),Un(i,t),Un(i,~t),t&&i.pending_buf.set(i.window.subarray(e,e+t),i.pending),i.pending+=t},sf=i=>{Ye(i,fu<<1,3),xt(i,Oo,Ut),Xp(i)},of=(i,e,t,r)=>{let n,a,s=0;i.level>0?(i.strm.data_type===zp&&(i.strm.data_type=nf(i)),yo(i,i.l_desc),yo(i,i.d_desc),s=tf(i),n=i.opt_len+3+7>>>3,a=i.static_len+3+7>>>3,a<=n&&(n=a)):n=a=t+5,t+4<=n&&e!==-1?ku(i,e,t,r):i.strategy===Hp||a===n?(Ye(i,(fu<<1)+(r?1:0),3),Bc(i,Ut,En)):(Ye(i,(Wp<<1)+(r?1:0),3),rf(i,i.l_desc.max_code+1,i.d_desc.max_code+1,s+1),Bc(i,i.dyn_ltree,i.dyn_dtree)),Eu(i),r&&Au(i)},cf=(i,e,t)=>(i.pending_buf[i.sym_buf+i.sym_next++]=e,i.pending_buf[i.sym_buf+i.sym_next++]=e>>8,i.pending_buf[i.sym_buf+i.sym_next++]=t,e===0?i.dyn_ltree[t*2]++:(i.matches++,e--,i.dyn_ltree[(On[t]+zn+1)*2]++,i.dyn_dtree[_u(e)*2]++),i.sym_next===i.sym_end),lf=af,uf=ku,df=of,pf=cf,ff=sf,hf={_tr_init:lf,_tr_stored_block:uf,_tr_flush_block:df,_tr_tally:pf,_tr_align:ff},gf=(i,e,t,r)=>{let n=i&65535|0,a=i>>>16&65535|0,s=0;for(;t!==0;){s=t>2e3?2e3:t,t-=s;do n=n+e[r++]|0,a=a+n|0;while(--s);n%=65521,a%=65521}return n|a<<16|0},Dn=gf,mf=()=>{let i,e=[];for(var t=0;t<256;t++){i=t;for(var r=0;r<8;r++)i=i&1?3988292384^i>>>1:i>>>1;e[t]=i}return e},yf=new Uint32Array(mf()),vf=(i,e,t,r)=>{let n=yf,a=r+t;i^=-1;for(let s=r;s<a;s++)i=i>>>8^n[(i^e[s])&255];return i^-1},Ie=vf,Qi={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"},nr={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:bf,_tr_stored_block:vo,_tr_flush_block:wf,_tr_tally:si,_tr_align:Sf}=hf,{Z_NO_FLUSH:oi,Z_PARTIAL_FLUSH:_f,Z_FULL_FLUSH:xf,Z_FINISH:dt,Z_BLOCK:Wc,Z_OK:Pe,Z_STREAM_END:Kc,Z_STREAM_ERROR:At,Z_DATA_ERROR:$f,Z_BUF_ERROR:Vs,Z_DEFAULT_COMPRESSION:Ef,Z_FILTERED:Af,Z_HUFFMAN_ONLY:ha,Z_RLE:kf,Z_FIXED:If,Z_DEFAULT_STRATEGY:Tf,Z_UNKNOWN:Cf,Z_DEFLATED:ds}=nr,Lf=9,Pf=15,Rf=8,Nf=29,Of=256,bo=Of+1+Nf,Uf=30,Df=19,Mf=2*bo+1,Ff=15,re=3,ii=258,kt=ii+re+1,jf=32,Ir=42,Do=57,wo=69,So=73,_o=91,xo=103,Fi=113,mn=666,Be=1,Dr=2,Gi=3,Mr=4,qf=3,ji=(i,e)=>(i.msg=Qi[e],e),Qc=i=>i*2-(i>4?9:0),ti=i=>{let e=i.length;for(;--e>=0;)i[e]=0},Bf=i=>{let e,t,r,n=i.w_size;e=i.hash_size,r=e;do t=i.head[--r],i.head[r]=t>=n?t-n:0;while(--e);e=n,r=e;do t=i.prev[--r],i.prev[r]=t>=n?t-n:0;while(--e)},Hf=(i,e,t)=>(e<<i.hash_shift^t)&i.hash_mask,ci=Hf,it=i=>{let e=i.state,t=e.pending;t>i.avail_out&&(t=i.avail_out),t!==0&&(i.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+t),i.next_out),i.next_out+=t,e.pending_out+=t,i.total_out+=t,i.avail_out-=t,e.pending-=t,e.pending===0&&(e.pending_out=0))},nt=(i,e)=>{wf(i,i.block_start>=0?i.block_start:-1,i.strstart-i.block_start,e),i.block_start=i.strstart,it(i.strm)},ae=(i,e)=>{i.pending_buf[i.pending++]=e},Zr=(i,e)=>{i.pending_buf[i.pending++]=e>>>8&255,i.pending_buf[i.pending++]=e&255},$o=(i,e,t,r)=>{let n=i.avail_in;return n>r&&(n=r),n===0?0:(i.avail_in-=n,e.set(i.input.subarray(i.next_in,i.next_in+n),t),i.state.wrap===1?i.adler=Dn(i.adler,e,n,t):i.state.wrap===2&&(i.adler=Ie(i.adler,e,n,t)),i.next_in+=n,i.total_in+=n,n)},Iu=(i,e)=>{let t=i.max_chain_length,r=i.strstart,n,a,s=i.prev_length,o=i.nice_match,c=i.strstart>i.w_size-kt?i.strstart-(i.w_size-kt):0,l=i.window,u=i.w_mask,m=i.prev,y=i.strstart+ii,d=l[r+s-1],f=l[r+s];i.prev_length>=i.good_match&&(t>>=2),o>i.lookahead&&(o=i.lookahead);do if(n=e,!(l[n+s]!==f||l[n+s-1]!==d||l[n]!==l[r]||l[++n]!==l[r+1])){r+=2,n++;do;while(l[++r]===l[++n]&&l[++r]===l[++n]&&l[++r]===l[++n]&&l[++r]===l[++n]&&l[++r]===l[++n]&&l[++r]===l[++n]&&l[++r]===l[++n]&&l[++r]===l[++n]&&r<y);if(a=ii-(y-r),r=y-ii,a>s){if(i.match_start=e,s=a,a>=o)break;d=l[r+s-1],f=l[r+s]}}while((e=m[e&u])>c&&--t!==0);return s<=i.lookahead?s:i.lookahead},Tr=i=>{let e=i.w_size,t,r,n;do{if(r=i.window_size-i.lookahead-i.strstart,i.strstart>=e+(e-kt)&&(i.window.set(i.window.subarray(e,e+e-r),0),i.match_start-=e,i.strstart-=e,i.block_start-=e,i.insert>i.strstart&&(i.insert=i.strstart),Bf(i),r+=e),i.strm.avail_in===0)break;if(t=$o(i.strm,i.window,i.strstart+i.lookahead,r),i.lookahead+=t,i.lookahead+i.insert>=re)for(n=i.strstart-i.insert,i.ins_h=i.window[n],i.ins_h=ci(i,i.ins_h,i.window[n+1]);i.insert&&(i.ins_h=ci(i,i.ins_h,i.window[n+re-1]),i.prev[n&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=n,n++,i.insert--,!(i.lookahead+i.insert<re)););}while(i.lookahead<kt&&i.strm.avail_in!==0)},Tu=(i,e)=>{let t=i.pending_buf_size-5>i.w_size?i.w_size:i.pending_buf_size-5,r,n,a,s=0,o=i.strm.avail_in;do{if(r=65535,a=i.bi_valid+42>>3,i.strm.avail_out<a||(a=i.strm.avail_out-a,n=i.strstart-i.block_start,r>n+i.strm.avail_in&&(r=n+i.strm.avail_in),r>a&&(r=a),r<t&&(r===0&&e!==dt||e===oi||r!==n+i.strm.avail_in)))break;s=e===dt&&r===n+i.strm.avail_in?1:0,vo(i,0,0,s),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,it(i.strm),n&&(n>r&&(n=r),i.strm.output.set(i.window.subarray(i.block_start,i.block_start+n),i.strm.next_out),i.strm.next_out+=n,i.strm.avail_out-=n,i.strm.total_out+=n,i.block_start+=n,r-=n),r&&($o(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(s===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),s?Mr:e!==oi&&e!==dt&&i.strm.avail_in===0&&i.strstart===i.block_start?Dr:(a=i.window_size-i.strstart,i.strm.avail_in>a&&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++,a+=i.w_size,i.insert>i.strstart&&(i.insert=i.strstart)),a>i.strm.avail_in&&(a=i.strm.avail_in),a&&($o(i.strm,i.window,i.strstart,a),i.strstart+=a,i.insert+=a>i.w_size-i.insert?i.w_size-i.insert:a),i.high_water<i.strstart&&(i.high_water=i.strstart),a=i.bi_valid+42>>3,a=i.pending_buf_size-a>65535?65535:i.pending_buf_size-a,t=a>i.w_size?i.w_size:a,n=i.strstart-i.block_start,(n>=t||(n||e===dt)&&e!==oi&&i.strm.avail_in===0&&n<=a)&&(r=n>a?a:n,s=e===dt&&i.strm.avail_in===0&&r===n?1:0,vo(i,i.block_start,r,s),i.block_start+=r,it(i.strm)),s?Gi:Be)},Ws=(i,e)=>{let t,r;for(;;){if(i.lookahead<kt){if(Tr(i),i.lookahead<kt&&e===oi)return Be;if(i.lookahead===0)break}if(t=0,i.lookahead>=re&&(i.ins_h=ci(i,i.ins_h,i.window[i.strstart+re-1]),t=i.prev[i.strstart&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=i.strstart),t!==0&&i.strstart-t<=i.w_size-kt&&(i.match_length=Iu(i,t)),i.match_length>=re)if(r=si(i,i.strstart-i.match_start,i.match_length-re),i.lookahead-=i.match_length,i.match_length<=i.max_lazy_match&&i.lookahead>=re){i.match_length--;do i.strstart++,i.ins_h=ci(i,i.ins_h,i.window[i.strstart+re-1]),t=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=ci(i,i.ins_h,i.window[i.strstart+1]);else r=si(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++;if(r&&(nt(i,!1),i.strm.avail_out===0))return Be}return i.insert=i.strstart<re-1?i.strstart:re-1,e===dt?(nt(i,!0),i.strm.avail_out===0?Gi:Mr):i.sym_next&&(nt(i,!1),i.strm.avail_out===0)?Be:Dr},yr=(i,e)=>{let t,r,n;for(;;){if(i.lookahead<kt){if(Tr(i),i.lookahead<kt&&e===oi)return Be;if(i.lookahead===0)break}if(t=0,i.lookahead>=re&&(i.ins_h=ci(i,i.ins_h,i.window[i.strstart+re-1]),t=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=re-1,t!==0&&i.prev_length<i.max_lazy_match&&i.strstart-t<=i.w_size-kt&&(i.match_length=Iu(i,t),i.match_length<=5&&(i.strategy===Af||i.match_length===re&&i.strstart-i.match_start>4096)&&(i.match_length=re-1)),i.prev_length>=re&&i.match_length<=i.prev_length){n=i.strstart+i.lookahead-re,r=si(i,i.strstart-1-i.prev_match,i.prev_length-re),i.lookahead-=i.prev_length-1,i.prev_length-=2;do++i.strstart<=n&&(i.ins_h=ci(i,i.ins_h,i.window[i.strstart+re-1]),t=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=re-1,i.strstart++,r&&(nt(i,!1),i.strm.avail_out===0))return Be}else if(i.match_available){if(r=si(i,0,i.window[i.strstart-1]),r&&nt(i,!1),i.strstart++,i.lookahead--,i.strm.avail_out===0)return Be}else i.match_available=1,i.strstart++,i.lookahead--}return i.match_available&&(r=si(i,0,i.window[i.strstart-1]),i.match_available=0),i.insert=i.strstart<re-1?i.strstart:re-1,e===dt?(nt(i,!0),i.strm.avail_out===0?Gi:Mr):i.sym_next&&(nt(i,!1),i.strm.avail_out===0)?Be:Dr},zf=(i,e)=>{let t,r,n,a,s=i.window;for(;;){if(i.lookahead<=ii){if(Tr(i),i.lookahead<=ii&&e===oi)return Be;if(i.lookahead===0)break}if(i.match_length=0,i.lookahead>=re&&i.strstart>0&&(n=i.strstart-1,r=s[n],r===s[++n]&&r===s[++n]&&r===s[++n])){a=i.strstart+ii;do;while(r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&r===s[++n]&&n<a);i.match_length=ii-(a-n),i.match_length>i.lookahead&&(i.match_length=i.lookahead)}if(i.match_length>=re?(t=si(i,1,i.match_length-re),i.lookahead-=i.match_length,i.strstart+=i.match_length,i.match_length=0):(t=si(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++),t&&(nt(i,!1),i.strm.avail_out===0))return Be}return i.insert=0,e===dt?(nt(i,!0),i.strm.avail_out===0?Gi:Mr):i.sym_next&&(nt(i,!1),i.strm.avail_out===0)?Be:Dr},Vf=(i,e)=>{let t;for(;;){if(i.lookahead===0&&(Tr(i),i.lookahead===0)){if(e===oi)return Be;break}if(i.match_length=0,t=si(i,0,i.window[i.strstart]),i.lookahead--,i.strstart++,t&&(nt(i,!1),i.strm.avail_out===0))return Be}return i.insert=0,e===dt?(nt(i,!0),i.strm.avail_out===0?Gi:Mr):i.sym_next&&(nt(i,!1),i.strm.avail_out===0)?Be:Dr};function bt(i,e,t,r,n){this.good_length=i,this.max_lazy=e,this.nice_length=t,this.max_chain=r,this.func=n}var yn=[new bt(0,0,0,0,Tu),new bt(4,4,8,4,Ws),new bt(4,5,16,8,Ws),new bt(4,6,32,32,Ws),new bt(4,4,16,16,yr),new bt(8,16,32,32,yr),new bt(8,16,128,128,yr),new bt(8,32,128,256,yr),new bt(32,128,258,1024,yr),new bt(32,258,258,4096,yr)],Wf=i=>{i.window_size=2*i.w_size,ti(i.head),i.max_lazy_match=yn[i.level].max_lazy,i.good_match=yn[i.level].good_length,i.nice_match=yn[i.level].nice_length,i.max_chain_length=yn[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=re-1,i.match_available=0,i.ins_h=0};function Kf(){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=ds,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(Mf*2),this.dyn_dtree=new Uint16Array((2*Uf+1)*2),this.bl_tree=new Uint16Array((2*Df+1)*2),ti(this.dyn_ltree),ti(this.dyn_dtree),ti(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Ff+1),this.heap=new Uint16Array(2*bo+1),ti(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*bo+1),ti(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 Vn=i=>{if(!i)return 1;let e=i.state;return!e||e.strm!==i||e.status!==Ir&&e.status!==Do&&e.status!==wo&&e.status!==So&&e.status!==_o&&e.status!==xo&&e.status!==Fi&&e.status!==mn?1:0},Cu=i=>{if(Vn(i))return ji(i,At);i.total_in=i.total_out=0,i.data_type=Cf;let e=i.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap===2?Do:e.wrap?Ir:Fi,i.adler=e.wrap===2?0:1,e.last_flush=-2,bf(e),Pe},Lu=i=>{let e=Cu(i);return e===Pe&&Wf(i.state),e},Qf=(i,e)=>Vn(i)||i.state.wrap!==2?At:(i.state.gzhead=e,Pe),Pu=(i,e,t,r,n,a)=>{if(!i)return At;let s=1;if(e===Ef&&(e=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),n<1||n>Lf||t!==ds||r<8||r>15||e<0||e>9||a<0||a>If||r===8&&s!==1)return ji(i,At);r===8&&(r=9);let o=new Kf;return i.state=o,o.strm=i,o.status=Ir,o.wrap=s,o.gzhead=null,o.w_bits=r,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+re-1)/re),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<<n+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=e,o.strategy=a,o.method=t,Lu(i)},Gf=(i,e)=>Pu(i,e,ds,Pf,Rf,Tf),Zf=(i,e)=>{if(Vn(i)||e>Wc||e<0)return i?ji(i,At):At;let t=i.state;if(!i.output||i.avail_in!==0&&!i.input||t.status===mn&&e!==dt)return ji(i,i.avail_out===0?Vs:At);let r=t.last_flush;if(t.last_flush=e,t.pending!==0){if(it(i),i.avail_out===0)return t.last_flush=-1,Pe}else if(i.avail_in===0&&Qc(e)<=Qc(r)&&e!==dt)return ji(i,Vs);if(t.status===mn&&i.avail_in!==0)return ji(i,Vs);if(t.status===Ir&&t.wrap===0&&(t.status=Fi),t.status===Ir){let n=ds+(t.w_bits-8<<4)<<8,a=-1;if(t.strategy>=ha||t.level<2?a=0:t.level<6?a=1:t.level===6?a=2:a=3,n|=a<<6,t.strstart!==0&&(n|=jf),n+=31-n%31,Zr(t,n),t.strstart!==0&&(Zr(t,i.adler>>>16),Zr(t,i.adler&65535)),i.adler=1,t.status=Fi,it(i),t.pending!==0)return t.last_flush=-1,Pe}if(t.status===Do){if(i.adler=0,ae(t,31),ae(t,139),ae(t,8),t.gzhead)ae(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)),ae(t,t.gzhead.time&255),ae(t,t.gzhead.time>>8&255),ae(t,t.gzhead.time>>16&255),ae(t,t.gzhead.time>>24&255),ae(t,t.level===9?2:t.strategy>=ha||t.level<2?4:0),ae(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(ae(t,t.gzhead.extra.length&255),ae(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(i.adler=Ie(i.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=wo;else if(ae(t,0),ae(t,0),ae(t,0),ae(t,0),ae(t,0),ae(t,t.level===9?2:t.strategy>=ha||t.level<2?4:0),ae(t,qf),t.status=Fi,it(i),t.pending!==0)return t.last_flush=-1,Pe}if(t.status===wo){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 o=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+o),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>n&&(i.adler=Ie(i.adler,t.pending_buf,t.pending-n,n)),t.gzindex+=o,it(i),t.pending!==0)return t.last_flush=-1,Pe;n=0,a-=o}let s=new Uint8Array(t.gzhead.extra);t.pending_buf.set(s.subarray(t.gzindex,t.gzindex+a),t.pending),t.pending+=a,t.gzhead.hcrc&&t.pending>n&&(i.adler=Ie(i.adler,t.pending_buf,t.pending-n,n)),t.gzindex=0}t.status=So}if(t.status===So){if(t.gzhead.name){let n=t.pending,a;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>n&&(i.adler=Ie(i.adler,t.pending_buf,t.pending-n,n)),it(i),t.pending!==0)return t.last_flush=-1,Pe;n=0}t.gzindex<t.gzhead.name.length?a=t.gzhead.name.charCodeAt(t.gzindex++)&255:a=0,ae(t,a)}while(a!==0);t.gzhead.hcrc&&t.pending>n&&(i.adler=Ie(i.adler,t.pending_buf,t.pending-n,n)),t.gzindex=0}t.status=_o}if(t.status===_o){if(t.gzhead.comment){let n=t.pending,a;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>n&&(i.adler=Ie(i.adler,t.pending_buf,t.pending-n,n)),it(i),t.pending!==0)return t.last_flush=-1,Pe;n=0}t.gzindex<t.gzhead.comment.length?a=t.gzhead.comment.charCodeAt(t.gzindex++)&255:a=0,ae(t,a)}while(a!==0);t.gzhead.hcrc&&t.pending>n&&(i.adler=Ie(i.adler,t.pending_buf,t.pending-n,n))}t.status=xo}if(t.status===xo){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(it(i),t.pending!==0))return t.last_flush=-1,Pe;ae(t,i.adler&255),ae(t,i.adler>>8&255),i.adler=0}if(t.status=Fi,it(i),t.pending!==0)return t.last_flush=-1,Pe}if(i.avail_in!==0||t.lookahead!==0||e!==oi&&t.status!==mn){let n=t.level===0?Tu(t,e):t.strategy===ha?Vf(t,e):t.strategy===kf?zf(t,e):yn[t.level].func(t,e);if((n===Gi||n===Mr)&&(t.status=mn),n===Be||n===Gi)return i.avail_out===0&&(t.last_flush=-1),Pe;if(n===Dr&&(e===_f?Sf(t):e!==Wc&&(vo(t,0,0,!1),e===xf&&(ti(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),it(i),i.avail_out===0))return t.last_flush=-1,Pe}return e!==dt?Pe:t.wrap<=0?Kc:(t.wrap===2?(ae(t,i.adler&255),ae(t,i.adler>>8&255),ae(t,i.adler>>16&255),ae(t,i.adler>>24&255),ae(t,i.total_in&255),ae(t,i.total_in>>8&255),ae(t,i.total_in>>16&255),ae(t,i.total_in>>24&255)):(Zr(t,i.adler>>>16),Zr(t,i.adler&65535)),it(i),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?Pe:Kc)},Jf=i=>{if(Vn(i))return At;let e=i.state.status;return i.state=null,e===Fi?ji(i,$f):Pe},Xf=(i,e)=>{let t=e.length;if(Vn(i))return At;let r=i.state,n=r.wrap;if(n===2||n===1&&r.status!==Ir||r.lookahead)return At;if(n===1&&(i.adler=Dn(i.adler,e,t,0)),r.wrap=0,t>=r.w_size){n===0&&(ti(r.head),r.strstart=0,r.block_start=0,r.insert=0);let c=new Uint8Array(r.w_size);c.set(e.subarray(t-r.w_size,t),0),e=c,t=r.w_size}let a=i.avail_in,s=i.next_in,o=i.input;for(i.avail_in=t,i.next_in=0,i.input=e,Tr(r);r.lookahead>=re;){let c=r.strstart,l=r.lookahead-(re-1);do r.ins_h=ci(r,r.ins_h,r.window[c+re-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=re-1,Tr(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=re-1,r.match_available=0,i.next_in=s,i.input=o,i.avail_in=a,r.wrap=n,Pe},Yf=Gf,eh=Pu,th=Lu,ih=Cu,rh=Qf,nh=Zf,ah=Jf,sh=Xf,oh="pako deflate (from Nodeca project)",An={deflateInit:Yf,deflateInit2:eh,deflateReset:th,deflateResetKeep:ih,deflateSetHeader:rh,deflate:nh,deflateEnd:ah,deflateSetDictionary:sh,deflateInfo:oh},ch=(i,e)=>Object.prototype.hasOwnProperty.call(i,e),lh=function(i){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 r in t)ch(t,r)&&(i[r]=t[r])}}return i},uh=i=>{let e=0;for(let r=0,n=i.length;r<n;r++)e+=i[r].length;let t=new Uint8Array(e);for(let r=0,n=0,a=i.length;r<a;r++){let s=i[r];t.set(s,n),n+=s.length}return t},ps={assign:lh,flattenChunks:uh},Ru=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(i){Ru=!1}var Mn=new Uint8Array(256);for(let i=0;i<256;i++)Mn[i]=i>=252?6:i>=248?5:i>=240?4:i>=224?3:i>=192?2:1;Mn[254]=Mn[254]=1;var dh=i=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(i);let e,t,r,n,a,s=i.length,o=0;for(n=0;n<s;n++)t=i.charCodeAt(n),(t&64512)===55296&&n+1<s&&(r=i.charCodeAt(n+1),(r&64512)===56320&&(t=65536+(t-55296<<10)+(r-56320),n++)),o+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(o),a=0,n=0;a<o;n++)t=i.charCodeAt(n),(t&64512)===55296&&n+1<s&&(r=i.charCodeAt(n+1),(r&64512)===56320&&(t=65536+(t-55296<<10)+(r-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},ph=(i,e)=>{if(e<65534&&i.subarray&&Ru)return String.fromCharCode.apply(null,i.length===e?i:i.subarray(0,e));let t="";for(let r=0;r<e;r++)t+=String.fromCharCode(i[r]);return t},fh=(i,e)=>{let t=e||i.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(i.subarray(0,e));let r,n,a=new Array(t*2);for(n=0,r=0;r<t;){let s=i[r++];if(s<128){a[n++]=s;continue}let o=Mn[s];if(o>4){a[n++]=65533,r+=o-1;continue}for(s&=o===2?31:o===3?15:7;o>1&&r<t;)s=s<<6|i[r++]&63,o--;if(o>1){a[n++]=65533;continue}s<65536?a[n++]=s:(s-=65536,a[n++]=55296|s>>10&1023,a[n++]=56320|s&1023)}return ph(a,n)},hh=(i,e)=>{e=e||i.length,e>i.length&&(e=i.length);let t=e-1;for(;t>=0&&(i[t]&192)===128;)t--;return t<0||t===0?e:t+Mn[i[t]]>e?t:e},Fn={string2buf:dh,buf2string:fh,utf8border:hh};function gh(){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 Nu=gh,Ou=Object.prototype.toString,{Z_NO_FLUSH:mh,Z_SYNC_FLUSH:yh,Z_FULL_FLUSH:vh,Z_FINISH:bh,Z_OK:Za,Z_STREAM_END:wh,Z_DEFAULT_COMPRESSION:Sh,Z_DEFAULT_STRATEGY:_h,Z_DEFLATED:xh}=nr;function Wn(i){this.options=ps.assign({level:Sh,method:xh,chunkSize:16384,windowBits:15,memLevel:8,strategy:_h},i||{});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 Nu,this.strm.avail_out=0;let t=An.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(t!==Za)throw new Error(Qi[t]);if(e.header&&An.deflateSetHeader(this.strm,e.header),e.dictionary){let r;if(typeof e.dictionary=="string"?r=Fn.string2buf(e.dictionary):Ou.call(e.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(e.dictionary):r=e.dictionary,t=An.deflateSetDictionary(this.strm,r),t!==Za)throw new Error(Qi[t]);this._dict_set=!0}}Wn.prototype.push=function(i,e){let t=this.strm,r=this.options.chunkSize,n,a;if(this.ended)return!1;for(e===~~e?a=e:a=e===!0?bh:mh,typeof i=="string"?t.input=Fn.string2buf(i):Ou.call(i)==="[object ArrayBuffer]"?t.input=new Uint8Array(i):t.input=i,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(r),t.next_out=0,t.avail_out=r),(a===yh||a===vh)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(n=An.deflate(t,a),n===wh)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),n=An.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Za;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};Wn.prototype.onData=function(i){this.chunks.push(i)};Wn.prototype.onEnd=function(i){i===Za&&(this.result=ps.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function Mo(i,e){let t=new Wn(e);if(t.push(i,!0),t.err)throw t.msg||Qi[t.err];return t.result}function $h(i,e){return e=e||{},e.raw=!0,Mo(i,e)}function Eh(i,e){return e=e||{},e.gzip=!0,Mo(i,e)}var Ah=Wn,kh=Mo,Ih=$h,Th=Eh,Ch=nr,Lh={Deflate:Ah,deflate:kh,deflateRaw:Ih,gzip:Th,constants:Ch},ga=16209,Ph=16191,Rh=function i(e,t){let r,n,a,s,o,c,l,u,m,y,d,f,h,S,x,T,k,_,L,D,P,W,K,R,G=e.state;r=e.next_in,K=e.input,n=r+(e.avail_in-5),a=e.next_out,R=e.output,s=a-(t-e.avail_out),o=a+(e.avail_out-257),c=G.dmax,l=G.wsize,u=G.whave,m=G.wnext,y=G.window,d=G.hold,f=G.bits,h=G.lencode,S=G.distcode,x=(1<<G.lenbits)-1,T=(1<<G.distbits)-1;e:do{f<15&&(d+=K[r++]<<f,f+=8,d+=K[r++]<<f,f+=8),k=h[d&x];t:for(;;){if(_=k>>>24,d>>>=_,f-=_,_=k>>>16&255,_===0)R[a++]=k&65535;else if(_&16){L=k&65535,_&=15,_&&(f<_&&(d+=K[r++]<<f,f+=8),L+=d&(1<<_)-1,d>>>=_,f-=_),f<15&&(d+=K[r++]<<f,f+=8,d+=K[r++]<<f,f+=8),k=S[d&T];i:for(;;){if(_=k>>>24,d>>>=_,f-=_,_=k>>>16&255,_&16){if(D=k&65535,_&=15,f<_&&(d+=K[r++]<<f,f+=8,f<_&&(d+=K[r++]<<f,f+=8)),D+=d&(1<<_)-1,D>c){e.msg="invalid distance too far back",G.mode=ga;break e}if(d>>>=_,f-=_,_=a-s,D>_){if(_=D-_,_>u&&G.sane){e.msg="invalid distance too far back",G.mode=ga;break e}if(P=0,W=y,m===0){if(P+=l-_,_<L){L-=_;do R[a++]=y[P++];while(--_);P=a-D,W=R}}else if(m<_){if(P+=l+m-_,_-=m,_<L){L-=_;do R[a++]=y[P++];while(--_);if(P=0,m<L){_=m,L-=_;do R[a++]=y[P++];while(--_);P=a-D,W=R}}}else if(P+=m-_,_<L){L-=_;do R[a++]=y[P++];while(--_);P=a-D,W=R}for(;L>2;)R[a++]=W[P++],R[a++]=W[P++],R[a++]=W[P++],L-=3;L&&(R[a++]=W[P++],L>1&&(R[a++]=W[P++]))}else{P=a-D;do R[a++]=R[P++],R[a++]=R[P++],R[a++]=R[P++],L-=3;while(L>2);L&&(R[a++]=R[P++],L>1&&(R[a++]=R[P++]))}}else if((_&64)===0){k=S[(k&65535)+(d&(1<<_)-1)];continue i}else{e.msg="invalid distance code",G.mode=ga;break e}break}}else if((_&64)===0){k=h[(k&65535)+(d&(1<<_)-1)];continue t}else if(_&32){G.mode=Ph;break e}else{e.msg="invalid literal/length code",G.mode=ga;break e}break}}while(r<n&&a<o);L=f>>3,r-=L,f-=L<<3,d&=(1<<f)-1,e.next_in=r,e.next_out=a,e.avail_in=r<n?5+(n-r):5-(r-n),e.avail_out=a<o?257+(o-a):257-(a-o),G.hold=d,G.bits=f},vr=15,Gc=852,Zc=592,Jc=0,Ks=1,Xc=2,Nh=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]),Oh=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]),Uh=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]),Dh=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]),Mh=(i,e,t,r,n,a,s,o)=>{let c=o.bits,l=0,u=0,m=0,y=0,d=0,f=0,h=0,S=0,x=0,T=0,k,_,L,D,P,W=null,K,R=new Uint16Array(vr+1),G=new Uint16Array(vr+1),We=null,jr,I,Gn;for(l=0;l<=vr;l++)R[l]=0;for(u=0;u<r;u++)R[e[t+u]]++;for(d=c,y=vr;y>=1&&R[y]===0;y--);if(d>y&&(d=y),y===0)return n[a++]=1<<24|64<<16|0,n[a++]=1<<24|64<<16|0,o.bits=1,0;for(m=1;m<y&&R[m]===0;m++);for(d<m&&(d=m),S=1,l=1;l<=vr;l++)if(S<<=1,S-=R[l],S<0)return-1;if(S>0&&(i===Jc||y!==1))return-1;for(G[1]=0,l=1;l<vr;l++)G[l+1]=G[l]+R[l];for(u=0;u<r;u++)e[t+u]!==0&&(s[G[e[t+u]]++]=u);if(i===Jc?(W=We=s,K=20):i===Ks?(W=Nh,We=Oh,K=257):(W=Uh,We=Dh,K=0),T=0,u=0,l=m,P=a,f=d,h=0,L=-1,x=1<<d,D=x-1,i===Ks&&x>Gc||i===Xc&&x>Zc)return 1;for(;;){jr=l-h,s[u]+1<K?(I=0,Gn=s[u]):s[u]>=K?(I=We[s[u]-K],Gn=W[s[u]-K]):(I=32+64,Gn=0),k=1<<l-h,_=1<<f,m=_;do _-=k,n[P+(T>>h)+_]=jr<<24|I<<16|Gn|0;while(_!==0);for(k=1<<l-1;T&k;)k>>=1;if(k!==0?(T&=k-1,T+=k):T=0,u++,--R[l]===0){if(l===y)break;l=e[t+s[u]]}if(l>d&&(T&D)!==L){for(h===0&&(h=d),P+=m,f=l-h,S=1<<f;f+h<y&&(S-=R[f+h],!(S<=0));)f++,S<<=1;if(x+=1<<f,i===Ks&&x>Gc||i===Xc&&x>Zc)return 1;L=T&D,n[L]=d<<24|f<<16|P-a|0}}return T!==0&&(n[P+T]=l-h<<24|64<<16|0),o.bits=d,0},kn=Mh,Fh=0,Uu=1,Du=2,{Z_FINISH:Yc,Z_BLOCK:jh,Z_TREES:ma,Z_OK:Zi,Z_STREAM_END:qh,Z_NEED_DICT:Bh,Z_STREAM_ERROR:ft,Z_DATA_ERROR:Mu,Z_MEM_ERROR:Fu,Z_BUF_ERROR:Hh,Z_DEFLATED:el}=nr,fs=16180,tl=16181,il=16182,rl=16183,nl=16184,al=16185,sl=16186,ol=16187,cl=16188,ll=16189,Ja=16190,Rt=16191,Qs=16192,ul=16193,Gs=16194,dl=16195,pl=16196,fl=16197,hl=16198,ya=16199,va=16200,gl=16201,ml=16202,yl=16203,vl=16204,bl=16205,Zs=16206,wl=16207,Sl=16208,pe=16209,ju=16210,qu=16211,zh=852,Vh=592,Wh=15,Kh=Wh,_l=i=>(i>>>24&255)+(i>>>8&65280)+((i&65280)<<8)+((i&255)<<24);function Qh(){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 ar=i=>{if(!i)return 1;let e=i.state;return!e||e.strm!==i||e.mode<fs||e.mode>qu?1:0},Bu=i=>{if(ar(i))return ft;let e=i.state;return i.total_in=i.total_out=e.total=0,i.msg="",e.wrap&&(i.adler=e.wrap&1),e.mode=fs,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(zh),e.distcode=e.distdyn=new Int32Array(Vh),e.sane=1,e.back=-1,Zi},Hu=i=>{if(ar(i))return ft;let e=i.state;return e.wsize=0,e.whave=0,e.wnext=0,Bu(i)},zu=(i,e)=>{let t;if(ar(i))return ft;let r=i.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?ft:(r.window!==null&&r.wbits!==e&&(r.window=null),r.wrap=t,r.wbits=e,Hu(i))},Vu=(i,e)=>{if(!i)return ft;let t=new Qh;i.state=t,t.strm=i,t.window=null,t.mode=fs;let r=zu(i,e);return r!==Zi&&(i.state=null),r},Gh=i=>Vu(i,Kh),xl=!0,Js,Xs,Zh=i=>{if(xl){Js=new Int32Array(512),Xs=new Int32Array(32);let e=0;for(;e<144;)i.lens[e++]=8;for(;e<256;)i.lens[e++]=9;for(;e<280;)i.lens[e++]=7;for(;e<288;)i.lens[e++]=8;for(kn(Uu,i.lens,0,288,Js,0,i.work,{bits:9}),e=0;e<32;)i.lens[e++]=5;kn(Du,i.lens,0,32,Xs,0,i.work,{bits:5}),xl=!1}i.lencode=Js,i.lenbits=9,i.distcode=Xs,i.distbits=5},Wu=(i,e,t,r)=>{let n,a=i.state;return a.window===null&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new Uint8Array(a.wsize)),r>=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>r&&(n=r),a.window.set(e.subarray(t-r,t-r+n),a.wnext),r-=n,r?(a.window.set(e.subarray(t-r,t),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=n))),0},Jh=(i,e)=>{let t,r,n,a,s,o,c,l,u,m,y,d,f,h,S=0,x,T,k,_,L,D,P,W,K=new Uint8Array(4),R,G,We=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(ar(i)||!i.output||!i.input&&i.avail_in!==0)return ft;t=i.state,t.mode===Rt&&(t.mode=Qs),s=i.next_out,n=i.output,c=i.avail_out,a=i.next_in,r=i.input,o=i.avail_in,l=t.hold,u=t.bits,m=o,y=c,W=Zi;e:for(;;)switch(t.mode){case fs:if(t.wrap===0){t.mode=Qs;break}for(;u<16;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}if(t.wrap&2&&l===35615){t.wbits===0&&(t.wbits=15),t.check=0,K[0]=l&255,K[1]=l>>>8&255,t.check=Ie(t.check,K,2,0),l=0,u=0,t.mode=tl;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((l&255)<<8)+(l>>8))%31){i.msg="incorrect header check",t.mode=pe;break}if((l&15)!==el){i.msg="unknown compression method",t.mode=pe;break}if(l>>>=4,u-=4,P=(l&15)+8,t.wbits===0&&(t.wbits=P),P>15||P>t.wbits){i.msg="invalid window size",t.mode=pe;break}t.dmax=1<<t.wbits,t.flags=0,i.adler=t.check=1,t.mode=l&512?ll:Rt,l=0,u=0;break;case tl:for(;u<16;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}if(t.flags=l,(t.flags&255)!==el){i.msg="unknown compression method",t.mode=pe;break}if(t.flags&57344){i.msg="unknown header flags set",t.mode=pe;break}t.head&&(t.head.text=l>>8&1),t.flags&512&&t.wrap&4&&(K[0]=l&255,K[1]=l>>>8&255,t.check=Ie(t.check,K,2,0)),l=0,u=0,t.mode=il;case il:for(;u<32;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}t.head&&(t.head.time=l),t.flags&512&&t.wrap&4&&(K[0]=l&255,K[1]=l>>>8&255,K[2]=l>>>16&255,K[3]=l>>>24&255,t.check=Ie(t.check,K,4,0)),l=0,u=0,t.mode=rl;case rl:for(;u<16;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}t.head&&(t.head.xflags=l&255,t.head.os=l>>8),t.flags&512&&t.wrap&4&&(K[0]=l&255,K[1]=l>>>8&255,t.check=Ie(t.check,K,2,0)),l=0,u=0,t.mode=nl;case nl:if(t.flags&1024){for(;u<16;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}t.length=l,t.head&&(t.head.extra_len=l),t.flags&512&&t.wrap&4&&(K[0]=l&255,K[1]=l>>>8&255,t.check=Ie(t.check,K,2,0)),l=0,u=0}else t.head&&(t.head.extra=null);t.mode=al;case al:if(t.flags&1024&&(d=t.length,d>o&&(d=o),d&&(t.head&&(P=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(r.subarray(a,a+d),P)),t.flags&512&&t.wrap&4&&(t.check=Ie(t.check,r,d,a)),o-=d,a+=d,t.length-=d),t.length))break e;t.length=0,t.mode=sl;case sl:if(t.flags&2048){if(o===0)break e;d=0;do P=r[a+d++],t.head&&P&&t.length<65536&&(t.head.name+=String.fromCharCode(P));while(P&&d<o);if(t.flags&512&&t.wrap&4&&(t.check=Ie(t.check,r,d,a)),o-=d,a+=d,P)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=ol;case ol:if(t.flags&4096){if(o===0)break e;d=0;do P=r[a+d++],t.head&&P&&t.length<65536&&(t.head.comment+=String.fromCharCode(P));while(P&&d<o);if(t.flags&512&&t.wrap&4&&(t.check=Ie(t.check,r,d,a)),o-=d,a+=d,P)break e}else t.head&&(t.head.comment=null);t.mode=cl;case cl:if(t.flags&512){for(;u<16;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}if(t.wrap&4&&l!==(t.check&65535)){i.msg="header crc mismatch",t.mode=pe;break}l=0,u=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),i.adler=t.check=0,t.mode=Rt;break;case ll:for(;u<32;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}i.adler=t.check=_l(l),l=0,u=0,t.mode=Ja;case Ja:if(t.havedict===0)return i.next_out=s,i.avail_out=c,i.next_in=a,i.avail_in=o,t.hold=l,t.bits=u,Bh;i.adler=t.check=1,t.mode=Rt;case Rt:if(e===jh||e===ma)break e;case Qs:if(t.last){l>>>=u&7,u-=u&7,t.mode=Zs;break}for(;u<3;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}switch(t.last=l&1,l>>>=1,u-=1,l&3){case 0:t.mode=ul;break;case 1:if(Zh(t),t.mode=ya,e===ma){l>>>=2,u-=2;break e}break;case 2:t.mode=pl;break;case 3:i.msg="invalid block type",t.mode=pe}l>>>=2,u-=2;break;case ul:for(l>>>=u&7,u-=u&7;u<32;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}if((l&65535)!==(l>>>16^65535)){i.msg="invalid stored block lengths",t.mode=pe;break}if(t.length=l&65535,l=0,u=0,t.mode=Gs,e===ma)break e;case Gs:t.mode=dl;case dl:if(d=t.length,d){if(d>o&&(d=o),d>c&&(d=c),d===0)break e;n.set(r.subarray(a,a+d),s),o-=d,a+=d,c-=d,s+=d,t.length-=d;break}t.mode=Rt;break;case pl:for(;u<14;){if(o===0)break e;o--,l+=r[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){i.msg="too many length or distance symbols",t.mode=pe;break}t.have=0,t.mode=fl;case fl:for(;t.have<t.ncode;){for(;u<3;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}t.lens[We[t.have++]]=l&7,l>>>=3,u-=3}for(;t.have<19;)t.lens[We[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,R={bits:t.lenbits},W=kn(Fh,t.lens,0,19,t.lencode,0,t.work,R),t.lenbits=R.bits,W){i.msg="invalid code lengths set",t.mode=pe;break}t.have=0,t.mode=hl;case hl:for(;t.have<t.nlen+t.ndist;){for(;S=t.lencode[l&(1<<t.lenbits)-1],x=S>>>24,T=S>>>16&255,k=S&65535,!(x<=u);){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}if(k<16)l>>>=x,u-=x,t.lens[t.have++]=k;else{if(k===16){for(G=x+2;u<G;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}if(l>>>=x,u-=x,t.have===0){i.msg="invalid bit length repeat",t.mode=pe;break}P=t.lens[t.have-1],d=3+(l&3),l>>>=2,u-=2}else if(k===17){for(G=x+3;u<G;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}l>>>=x,u-=x,P=0,d=3+(l&7),l>>>=3,u-=3}else{for(G=x+7;u<G;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}l>>>=x,u-=x,P=0,d=11+(l&127),l>>>=7,u-=7}if(t.have+d>t.nlen+t.ndist){i.msg="invalid bit length repeat",t.mode=pe;break}for(;d--;)t.lens[t.have++]=P}}if(t.mode===pe)break;if(t.lens[256]===0){i.msg="invalid code -- missing end-of-block",t.mode=pe;break}if(t.lenbits=9,R={bits:t.lenbits},W=kn(Uu,t.lens,0,t.nlen,t.lencode,0,t.work,R),t.lenbits=R.bits,W){i.msg="invalid literal/lengths set",t.mode=pe;break}if(t.distbits=6,t.distcode=t.distdyn,R={bits:t.distbits},W=kn(Du,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,R),t.distbits=R.bits,W){i.msg="invalid distances set",t.mode=pe;break}if(t.mode=ya,e===ma)break e;case ya:t.mode=va;case va:if(o>=6&&c>=258){i.next_out=s,i.avail_out=c,i.next_in=a,i.avail_in=o,t.hold=l,t.bits=u,Rh(i,y),s=i.next_out,n=i.output,c=i.avail_out,a=i.next_in,r=i.input,o=i.avail_in,l=t.hold,u=t.bits,t.mode===Rt&&(t.back=-1);break}for(t.back=0;S=t.lencode[l&(1<<t.lenbits)-1],x=S>>>24,T=S>>>16&255,k=S&65535,!(x<=u);){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}if(T&&(T&240)===0){for(_=x,L=T,D=k;S=t.lencode[D+((l&(1<<_+L)-1)>>_)],x=S>>>24,T=S>>>16&255,k=S&65535,!(_+x<=u);){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,t.back+=_}if(l>>>=x,u-=x,t.back+=x,t.length=k,T===0){t.mode=bl;break}if(T&32){t.back=-1,t.mode=Rt;break}if(T&64){i.msg="invalid literal/length code",t.mode=pe;break}t.extra=T&15,t.mode=gl;case gl:if(t.extra){for(G=t.extra;u<G;){if(o===0)break e;o--,l+=r[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=ml;case ml:for(;S=t.distcode[l&(1<<t.distbits)-1],x=S>>>24,T=S>>>16&255,k=S&65535,!(x<=u);){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}if((T&240)===0){for(_=x,L=T,D=k;S=t.distcode[D+((l&(1<<_+L)-1)>>_)],x=S>>>24,T=S>>>16&255,k=S&65535,!(_+x<=u);){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,t.back+=_}if(l>>>=x,u-=x,t.back+=x,T&64){i.msg="invalid distance code",t.mode=pe;break}t.offset=k,t.extra=T&15,t.mode=yl;case yl:if(t.extra){for(G=t.extra;u<G;){if(o===0)break e;o--,l+=r[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){i.msg="invalid distance too far back",t.mode=pe;break}t.mode=vl;case vl:if(c===0)break e;if(d=y-c,t.offset>d){if(d=t.offset-d,d>t.whave&&t.sane){i.msg="invalid distance too far back",t.mode=pe;break}d>t.wnext?(d-=t.wnext,f=t.wsize-d):f=t.wnext-d,d>t.length&&(d=t.length),h=t.window}else h=n,f=s-t.offset,d=t.length;d>c&&(d=c),c-=d,t.length-=d;do n[s++]=h[f++];while(--d);t.length===0&&(t.mode=va);break;case bl:if(c===0)break e;n[s++]=t.length,c--,t.mode=va;break;case Zs:if(t.wrap){for(;u<32;){if(o===0)break e;o--,l|=r[a++]<<u,u+=8}if(y-=c,i.total_out+=y,t.total+=y,t.wrap&4&&y&&(i.adler=t.check=t.flags?Ie(t.check,n,y,s-y):Dn(t.check,n,y,s-y)),y=c,t.wrap&4&&(t.flags?l:_l(l))!==t.check){i.msg="incorrect data check",t.mode=pe;break}l=0,u=0}t.mode=wl;case wl:if(t.wrap&&t.flags){for(;u<32;){if(o===0)break e;o--,l+=r[a++]<<u,u+=8}if(t.wrap&4&&l!==(t.total&4294967295)){i.msg="incorrect length check",t.mode=pe;break}l=0,u=0}t.mode=Sl;case Sl:W=qh;break e;case pe:W=Mu;break e;case ju:return Fu;case qu:default:return ft}return i.next_out=s,i.avail_out=c,i.next_in=a,i.avail_in=o,t.hold=l,t.bits=u,(t.wsize||y!==i.avail_out&&t.mode<pe&&(t.mode<Zs||e!==Yc))&&Wu(i,i.output,i.next_out,y-i.avail_out),m-=i.avail_in,y-=i.avail_out,i.total_in+=m,i.total_out+=y,t.total+=y,t.wrap&4&&y&&(i.adler=t.check=t.flags?Ie(t.check,n,y,i.next_out-y):Dn(t.check,n,y,i.next_out-y)),i.data_type=t.bits+(t.last?64:0)+(t.mode===Rt?128:0)+(t.mode===ya||t.mode===Gs?256:0),(m===0&&y===0||e===Yc)&&W===Zi&&(W=Hh),W},Xh=i=>{if(ar(i))return ft;let e=i.state;return e.window&&(e.window=null),i.state=null,Zi},Yh=(i,e)=>{if(ar(i))return ft;let t=i.state;return(t.wrap&2)===0?ft:(t.head=e,e.done=!1,Zi)},eg=(i,e)=>{let t=e.length,r,n,a;return ar(i)||(r=i.state,r.wrap!==0&&r.mode!==Ja)?ft:r.mode===Ja&&(n=1,n=Dn(n,e,t,0),n!==r.check)?Mu:(a=Wu(i,e,t,t),a?(r.mode=ju,Fu):(r.havedict=1,Zi))},tg=Hu,ig=zu,rg=Bu,ng=Gh,ag=Vu,sg=Jh,og=Xh,cg=Yh,lg=eg,ug="pako inflate (from Nodeca project)",Dt={inflateReset:tg,inflateReset2:ig,inflateResetKeep:rg,inflateInit:ng,inflateInit2:ag,inflate:sg,inflateEnd:og,inflateGetHeader:cg,inflateSetDictionary:lg,inflateInfo:ug};function dg(){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 pg=dg,Ku=Object.prototype.toString,{Z_NO_FLUSH:fg,Z_FINISH:hg,Z_OK:jn,Z_STREAM_END:Ys,Z_NEED_DICT:eo,Z_STREAM_ERROR:gg,Z_DATA_ERROR:$l,Z_MEM_ERROR:mg}=nr;function Kn(i){this.options=ps.assign({chunkSize:1024*64,windowBits:15,to:""},i||{});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&&!(i&&i.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 Nu,this.strm.avail_out=0;let t=Dt.inflateInit2(this.strm,e.windowBits);if(t!==jn)throw new Error(Qi[t]);if(this.header=new pg,Dt.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Fn.string2buf(e.dictionary):Ku.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=Dt.inflateSetDictionary(this.strm,e.dictionary),t!==jn)))throw new Error(Qi[t])}Kn.prototype.push=function(i,e){let t=this.strm,r=this.options.chunkSize,n=this.options.dictionary,a,s,o;if(this.ended)return!1;for(e===~~e?s=e:s=e===!0?hg:fg,Ku.call(i)==="[object ArrayBuffer]"?t.input=new Uint8Array(i):t.input=i,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(r),t.next_out=0,t.avail_out=r),a=Dt.inflate(t,s),a===eo&&n&&(a=Dt.inflateSetDictionary(t,n),a===jn?a=Dt.inflate(t,s):a===$l&&(a=eo));t.avail_in>0&&a===Ys&&t.state.wrap>0&&i[t.next_in]!==0;)Dt.inflateReset(t),a=Dt.inflate(t,s);switch(a){case gg:case $l:case eo:case mg:return this.onEnd(a),this.ended=!0,!1}if(o=t.avail_out,t.next_out&&(t.avail_out===0||a===Ys))if(this.options.to==="string"){let c=Fn.utf8border(t.output,t.next_out),l=t.next_out-c,u=Fn.buf2string(t.output,c);t.next_out=l,t.avail_out=r-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===jn&&o===0)){if(a===Ys)return a=Dt.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};Kn.prototype.onData=function(i){this.chunks.push(i)};Kn.prototype.onEnd=function(i){i===jn&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=ps.flattenChunks(this.chunks)),this.chunks=[],this.err=i,this.msg=this.strm.msg};function Fo(i,e){let t=new Kn(e);if(t.push(i),t.err)throw t.msg||Qi[t.err];return t.result}function yg(i,e){return e=e||{},e.raw=!0,Fo(i,e)}var vg=Kn,bg=Fo,wg=yg,Sg=Fo,_g=nr,xg={Inflate:vg,inflate:bg,inflateRaw:wg,ungzip:Sg,constants:_g},{Deflate:$g,deflate:Eg,deflateRaw:Ag,gzip:kg}=Lh,{Inflate:Ig,inflate:Tg,inflateRaw:Cg,ungzip:Lg}=xg,Pg=$g,Rg=Eg,Ng=Ag,Og=kg,Ug=Ig,Dg=Tg,Mg=Cg,Fg=Lg,jg=nr,qg={Deflate:Pg,deflate:Rg,deflateRaw:Ng,gzip:Og,Inflate:Ug,inflate:Dg,inflateRaw:Mg,ungzip:Fg,constants:jg},ue=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},de=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Xa=class{constructor(e,t){this.input=e,this.output=t}};ue([g(),de("design:type",String)],Xa.prototype,"input",void 0);ue([g(),de("design:type",String)],Xa.prototype,"output",void 0);Xa=ue([Ce(),de("design:paramtypes",[String,String])],Xa);var Ya=class{constructor(e,t){this.input=e,this.output=t}};ue([g(),de("design:type",String)],Ya.prototype,"input",void 0);ue([g(),de("design:type",String)],Ya.prototype,"output",void 0);Ya=ue([H(),de("design:paramtypes",[String,String])],Ya);var pi=class{constructor(e,t,r,n,a){this.name=e,this.modelId=t,this.systemPrompt=r,this.promptExamples=n,this.metaData=a}};ue([g(),de("design:type",String)],pi.prototype,"name",void 0);ue([g(),de("design:type",String)],pi.prototype,"modelId",void 0);ue([g(),de("design:type",String)],pi.prototype,"systemPrompt",void 0);ue([g(),de("design:type",Array)],pi.prototype,"promptExamples",void 0);ue([g(),de("design:type",String)],pi.prototype,"metaData",void 0);pi=ue([Ce(),de("design:paramtypes",[String,String,String,Array,String])],pi);var Ct=class{constructor(e,t,r,n,a,s,o,c){this.name=e,this.modelId=t,this.taskId=r,this.systemPrompt=n,this.promptExamples=a,this.metaData=s,this.createdAt=o,this.updatedAt=c}};ue([g(),de("design:type",String)],Ct.prototype,"name",void 0);ue([g(),de("design:type",String)],Ct.prototype,"modelId",void 0);ue([g(),de("design:type",String)],Ct.prototype,"taskId",void 0);ue([g(),de("design:type",String)],Ct.prototype,"systemPrompt",void 0);ue([g(),de("design:type",Array)],Ct.prototype,"promptExamples",void 0);ue([g(),de("design:type",String)],Ct.prototype,"metaData",void 0);ue([g(),de("design:type",String)],Ct.prototype,"createdAt",void 0);ue([g(),de("design:type",String)],Ct.prototype,"updatedAt",void 0);Ct=ue([H(),de("design:paramtypes",[String,String,String,String,Array,String,String,String])],Ct);var Ji=class{constructor(e,t,r,n,a){this.model=e,this.status=t,this.progress=r,this.downloaded=n,this.loaded=a}};ue([g(),de("design:type",String)],Ji.prototype,"model",void 0);ue([g(),de("design:type",String)],Ji.prototype,"status",void 0);ue([g(),de("design:type",Number)],Ji.prototype,"progress",void 0);ue([g(),de("design:type",Boolean)],Ji.prototype,"downloaded",void 0);ue([g(),de("design:type",Boolean)],Ji.prototype,"loaded",void 0);Ji=ue([H(),de("design:paramtypes",[String,String,Number,Boolean,Boolean])],Ji);var Bg=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},Ee=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},_e,Ra,Eo=class{constructor(e,t=!0){_e.set(this,void 0),Ra.set(this,new Map),Bg(this,_e,e,"f")}async getModels(){let e=await Ee(this,_e,"f").query({query:v`
1203
1267
  query {
1204
1268
  aiGetModels {
1205
1269
  id
@@ -1223,23 +1287,23 @@ triggerMatch
1223
1287
  modelType
1224
1288
  }
1225
1289
  }
1226
- `});return b(e).aiGetModels}async addModel(e){let t=await $e(this,_e,"f").mutate({mutation:v`
1290
+ `});return b(e).aiGetModels}async addModel(e){let t=await Ee(this,_e,"f").mutate({mutation:v`
1227
1291
  mutation($model: ModelInput!) {
1228
1292
  aiAddModel(model: $model)
1229
1293
  }
1230
- `,variables:{model:e}});return b(t).aiAddModel}async updateModel(e,t){let r=await $e(this,_e,"f").mutate({mutation:v`
1294
+ `,variables:{model:e}});return b(t).aiAddModel}async updateModel(e,t){let r=await Ee(this,_e,"f").mutate({mutation:v`
1231
1295
  mutation($modelId: String!, $model: ModelInput!) {
1232
1296
  aiUpdateModel(modelId: $modelId, model: $model)
1233
1297
  }
1234
- `,variables:{modelId:e,model:t}});return b(r).aiUpdateModel}async removeModel(e){let t=await $e(this,_e,"f").mutate({mutation:v`
1298
+ `,variables:{modelId:e,model:t}});return b(r).aiUpdateModel}async removeModel(e){let t=await Ee(this,_e,"f").mutate({mutation:v`
1235
1299
  mutation($modelId: String!) {
1236
1300
  aiRemoveModel(modelId: $modelId)
1237
1301
  }
1238
- `,variables:{modelId:e}});return b(t).aiRemoveModel}async setDefaultModel(e,t){let r=await $e(this,_e,"f").mutate({mutation:v`
1302
+ `,variables:{modelId:e}});return b(t).aiRemoveModel}async setDefaultModel(e,t){let r=await Ee(this,_e,"f").mutate({mutation:v`
1239
1303
  mutation($modelType: ModelType!, $modelId: String!) {
1240
1304
  aiSetDefaultModel(modelType: $modelType modelId: $modelId)
1241
1305
  }
1242
- `,variables:{modelId:t,modelType:e}});return b(r).aiSetDefaultModel}async getDefaultModel(e){let t=await $e(this,_e,"f").query({query:v`
1306
+ `,variables:{modelId:t,modelType:e}});return b(r).aiSetDefaultModel}async getDefaultModel(e){let t=await Ee(this,_e,"f").query({query:v`
1243
1307
  query($modelType: ModelType!) {
1244
1308
  aiGetDefaultModel(modelType: $modelType) {
1245
1309
  id
@@ -1263,7 +1327,7 @@ triggerMatch
1263
1327
  modelType
1264
1328
  }
1265
1329
  }
1266
- `,variables:{modelType:e}});return b(t).aiGetDefaultModel}async tasks(){let{aiTasks:e}=b(await $e(this,_e,"f").query({query:v`
1330
+ `,variables:{modelType:e}});return b(t).aiGetDefaultModel}async tasks(){let{aiTasks:e}=b(await Ee(this,_e,"f").query({query:v`
1267
1331
  query {
1268
1332
  aiTasks {
1269
1333
  name
@@ -1279,7 +1343,7 @@ triggerMatch
1279
1343
  updatedAt
1280
1344
  }
1281
1345
  }
1282
- `}));return e}async addTask(e,t,r,n,a){let s=new li(e,t,r,n,a),{aiAddTask:o}=b(await $e(this,_e,"f").mutate({mutation:v`
1346
+ `}));return e}async addTask(e,t,r,n,a){let s=new pi(e,t,r,n,a),{aiAddTask:o}=b(await Ee(this,_e,"f").mutate({mutation:v`
1283
1347
  mutation AiAddTask($task: AITaskInput!) {
1284
1348
  aiAddTask(task: $task) {
1285
1349
  name
@@ -1295,7 +1359,7 @@ triggerMatch
1295
1359
  updatedAt
1296
1360
  }
1297
1361
  }
1298
- `,variables:{task:s}}));return o}async removeTask(e){let{aiRemoveTask:t}=b(await $e(this,_e,"f").mutate({mutation:v`
1362
+ `,variables:{task:s}}));return o}async removeTask(e){let{aiRemoveTask:t}=b(await Ee(this,_e,"f").mutate({mutation:v`
1299
1363
  mutation AiRemoveTask($taskId: String!) {
1300
1364
  aiRemoveTask(taskId: $taskId) {
1301
1365
  name
@@ -1311,7 +1375,7 @@ triggerMatch
1311
1375
  updatedAt
1312
1376
  }
1313
1377
  }
1314
- `,variables:{taskId:e}}));return t}async updateTask(e,t){let{aiUpdateTask:r}=b(await $e(this,_e,"f").mutate({mutation:v`
1378
+ `,variables:{taskId:e}}));return t}async updateTask(e,t){let{aiUpdateTask:r}=b(await Ee(this,_e,"f").mutate({mutation:v`
1315
1379
  mutation AiUpdateTask($taskId: String!, $task: AITaskInput!) {
1316
1380
  aiUpdateTask(taskId: $taskId, task: $task) {
1317
1381
  name
@@ -1327,7 +1391,7 @@ triggerMatch
1327
1391
  updatedAt
1328
1392
  }
1329
1393
  }
1330
- `,variables:{taskId:e,task:{name:t.name,modelId:t.modelId,systemPrompt:t.systemPrompt,promptExamples:t.promptExamples}}}));return r}async modelLoadingStatus(e){let{aiModelLoadingStatus:t}=b(await $e(this,_e,"f").query({query:v`
1394
+ `,variables:{taskId:e,task:{name:t.name,modelId:t.modelId,systemPrompt:t.systemPrompt,promptExamples:t.promptExamples}}}));return r}async modelLoadingStatus(e){let{aiModelLoadingStatus:t}=b(await Ee(this,_e,"f").query({query:v`
1331
1395
  query AiModelLoadingStatus($model: String!) {
1332
1396
  aiModelLoadingStatus(model: $model) {
1333
1397
  model
@@ -1337,30 +1401,30 @@ triggerMatch
1337
1401
  downloaded
1338
1402
  }
1339
1403
  }
1340
- `,variables:{model:e}}));return t}async prompt(e,t){let{aiPrompt:r}=b(await $e(this,_e,"f").mutate({mutation:v`
1404
+ `,variables:{model:e}}));return t}async prompt(e,t){let{aiPrompt:r}=b(await Ee(this,_e,"f").mutate({mutation:v`
1341
1405
  mutation AiPrompt($taskId: String!, $prompt: String!) {
1342
1406
  aiPrompt(taskId: $taskId, prompt: $prompt)
1343
1407
  }
1344
- `,variables:{taskId:e,prompt:t}}));return r}async embed(e,t){let{aiEmbed:r}=b(await $e(this,_e,"f").mutate({mutation:v`
1408
+ `,variables:{taskId:e,prompt:t}}));return r}async embed(e,t){let{aiEmbed:r}=b(await Ee(this,_e,"f").mutate({mutation:v`
1345
1409
  mutation aiEmbed($modelId: String!, $text: String!) {
1346
1410
  aiEmbed(modelId: $modelId, text: $text)
1347
1411
  }
1348
- `,variables:{modelId:e,text:t}})),n=ts.toByteArray(r);return JSON.parse(_g.inflate(n,{to:"string"}))}async openTranscriptionStream(e,t,r){let{aiOpenTranscriptionStream:n}=b(await $e(this,_e,"f").mutate({mutation:v`
1412
+ `,variables:{modelId:e,text:t}})),n=us.toByteArray(r);return JSON.parse(qg.inflate(n,{to:"string"}))}async openTranscriptionStream(e,t,r){let{aiOpenTranscriptionStream:n}=b(await Ee(this,_e,"f").mutate({mutation:v`
1349
1413
  mutation AiOpenTranscriptionStream($modelId: String!, $params: VoiceActivityParamsInput) {
1350
1414
  aiOpenTranscriptionStream(modelId: $modelId, params: $params)
1351
1415
  }
1352
- `,variables:{modelId:e,params:r}})),a=$e(this,_e,"f").subscribe({query:v` subscription {
1416
+ `,variables:{modelId:e,params:r}})),a=Ee(this,_e,"f").subscribe({query:v` subscription {
1353
1417
  aiTranscriptionText(streamId: "${n}")
1354
- }`}).subscribe({next(s){return t(s.data.aiTranscriptionText),s.data.aiTranscriptionText},error(s){console.error(s)}});return $e(this,Ea,"f").set(n,a),n}async closeTranscriptionStream(e){let{aiCloseTranscriptionStream:t}=b(await $e(this,_e,"f").mutate({mutation:v`
1418
+ }`}).subscribe({next(s){return t(s.data.aiTranscriptionText),s.data.aiTranscriptionText},error(s){console.error(s)}});return Ee(this,Ra,"f").set(n,a),n}async closeTranscriptionStream(e){let{aiCloseTranscriptionStream:t}=b(await Ee(this,_e,"f").mutate({mutation:v`
1355
1419
  mutation aiCloseTranscriptionStream($streamId: String!) {
1356
1420
  aiCloseTranscriptionStream(streamId: $streamId)
1357
1421
  }
1358
- `,variables:{streamId:e}})),r=$e(this,Ea,"f").get(e);return r.closed||r.unsubscribe(),t}async feedTranscriptionStream(e,t){let{aiFeedTranscriptionStream:r}=b(await $e(this,_e,"f").mutate({mutation:v`
1422
+ `,variables:{streamId:e}})),r=Ee(this,Ra,"f").get(e);return r.closed||r.unsubscribe(),t}async feedTranscriptionStream(e,t){let{aiFeedTranscriptionStream:r}=b(await Ee(this,_e,"f").mutate({mutation:v`
1359
1423
  mutation AiFeedTranscriptionStream($streamIds: [String!]!, $audio: [Float!]!) {
1360
1424
  aiFeedTranscriptionStream(streamIds: $streamIds, audio: $audio)
1361
1425
  }
1362
- `,variables:{streamIds:Array.isArray(e)?e:[e],audio:t}}));return r}};_e=new WeakMap,Ea=new WeakMap;var Gt=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},Se=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Et,$a,un,Aa,dn,Li,ka,pn,pl=class{constructor(e,t=!0){Et.set(this,void 0),$a.set(this,void 0),un.set(this,void 0),Aa.set(this,void 0),dn.set(this,void 0),Li.set(this,void 0),ka.set(this,void 0),pn.set(this,void 0),Gt(this,Et,e,"f"),Gt(this,$a,new xn(Se(this,Et,"f"),t),"f"),Gt(this,un,new no(Se(this,Et,"f")),"f"),Gt(this,Aa,new to(Se(this,Et,"f")),"f"),Gt(this,dn,new io(Se(this,Et,"f")),"f"),Gt(this,pn,new go(Se(this,Et,"f"),t),"f"),Gt(this,Li,new Fa(Se(this,Et,"f"),t),"f"),Se(this,Li,"f").setExpressionClient(Se(this,un,"f")),Se(this,Li,"f").setNeighbourhoodClient(Se(this,dn,"f")),Se(this,Li,"f").setAIClient(Se(this,pn,"f")),Gt(this,ka,new ro(Se(this,Et,"f"),t),"f")}get agent(){return Se(this,$a,"f")}get expression(){return Se(this,un,"f")}get languages(){return Se(this,Aa,"f")}get neighbourhood(){return Se(this,dn,"f")}get perspective(){return Se(this,Li,"f")}get runtime(){return Se(this,ka,"f")}get ai(){return Se(this,pn,"f")}};Et=new WeakMap,$a=new WeakMap,un=new WeakMap,Aa=new WeakMap,dn=new WeakMap,Li=new WeakMap,ka=new WeakMap,pn=new WeakMap;var mo;(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"})(mo||(mo={}));var Co=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Lo=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Ui=class{constructor(e,t){this.language=e,this.expression=t}};Co([h(),Lo("design:type",It)],Ui.prototype,"language",void 0);Co([h(),Lo("design:type",String)],Ui.prototype,"expression",void 0);Ui=Co([H(),Lo("design:paramtypes",[It,String])],Ui);function N0(i){return i.language.address==="did"?i.expression.toString():`${i.language.address}://${i.expression}`}function O0(i){if(i.startsWith("literal://")){let a=new It;a.address="literal",a.name="literal";let s=i.substring(10);return new Ui(a,s)}let t=/^([^:^\s]+):\/\/([\s\S]+)$/.exec(i);if(t&&t.length==3){let a=t[1],s=t[2],o=new It;return o.address=a,new Ui(o,s)}let n=/^did:([^\s]+)$/.exec(i);if(n&&n.length==2){let a=new It;return a.address="did",new Ui(a,i)}throw new Error("Couldn't parse string as expression URL or DID: "+i)}var st=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Ot=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Va=class{};st([h(),Ot("design:type",String)],Va.prototype,"name",void 0);st([h(),Ot("design:type",String)],Va.prototype,"type",void 0);Va=st([H()],Va);var Pn=class{};st([h(),Ot("design:type",String)],Pn.prototype,"label",void 0);st([h(),Ot("design:type",String)],Pn.prototype,"name",void 0);st([h(),Ot("design:type",Array)],Pn.prototype,"parameters",void 0);Pn=st([H()],Pn);var Wa=class{get parameters(){return JSON.parse(this.parametersStringified)}constructor(e,t){this.name=e,this.parametersStringified=JSON.stringify(t)}};st([h(),Ot("design:type",String)],Wa.prototype,"name",void 0);st([h(),Ot("design:type",String)],Wa.prototype,"parametersStringified",void 0);Wa=st([Te(),Ot("design:paramtypes",[String,Object])],Wa);var Ka=class{};st([h(),Ot("design:type",String)],Ka.prototype,"did",void 0);st([h(),Ot("design:type",Bi)],Ka.prototype,"status",void 0);Ka=st([H()],Ka);var fl=class{},tr=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Rr=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},ui=class{};tr([h(),Rr("design:type",String)],ui.prototype,"name",void 0);tr([h(),Rr("design:type",String)],ui.prototype,"address",void 0);tr([h(),Rr("design:type",String)],ui.prototype,"settings",void 0);tr([h(),Rr("design:type",Fi)],ui.prototype,"icon",void 0);tr([h(),Rr("design:type",Fi)],ui.prototype,"constructorIcon",void 0);tr([h(),Rr("design:type",Fi)],ui.prototype,"settingsIcon",void 0);ui=tr([H()],ui);var ze=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Xe=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},vt=class{};ze([h(),Xe("design:type",String)],vt.prototype,"name",void 0);ze([h(),Xe("design:type",String)],vt.prototype,"address",void 0);ze([h(),Xe("design:type",String)],vt.prototype,"description",void 0);ze([h(),Xe("design:type",String)],vt.prototype,"author",void 0);ze([h(),Xe("design:type",Boolean)],vt.prototype,"templated",void 0);ze([h(),Xe("design:type",String)],vt.prototype,"templateSourceLanguageAddress",void 0);ze([h(),Xe("design:type",String)],vt.prototype,"templateAppliedParams",void 0);ze([h(),Xe("design:type",Array)],vt.prototype,"possibleTemplateParams",void 0);ze([h(),Xe("design:type",String)],vt.prototype,"sourceCodeLink",void 0);vt=ze([H()],vt);var Er=class{constructor(e,t){this.name=e,this.description=t,this.description||(this.description="")}};ze([h(),Xe("design:type",String)],Er.prototype,"name",void 0);ze([h(),Xe("design:type",String)],Er.prototype,"description",void 0);ze([h(),Xe("design:type",Array)],Er.prototype,"possibleTemplateParams",void 0);ze([h(),Xe("design:type",String)],Er.prototype,"sourceCodeLink",void 0);Er=ze([Te(),Xe("design:paramtypes",[String,String])],Er);var hl=class{},gl=class extends hi(){},ml=class{},as=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Po=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Qa=class{constructor(e,t){this.linkLanguage=e,this.meta=t}};as([h(),Po("design:type",String)],Qa.prototype,"linkLanguage",void 0);as([h(),Po("design:type",Pt)],Qa.prototype,"meta",void 0);Qa=as([H(),Po("design:paramtypes",[String,Pt])],Qa);var yo=class extends hi(){};yo=as([H()],yo);var ir=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},rr=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},vo;(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"})(vo||(vo={}));var di=class{constructor(e,t,r){this.uuid=e,this.name=t,r?this.state=r:this.state=vo.Private}};ir([h(),rr("design:type",String)],di.prototype,"uuid",void 0);ir([h(),rr("design:type",String)],di.prototype,"name",void 0);ir([h(),rr("design:type",String)],di.prototype,"state",void 0);ir([h(),rr("design:type",String)],di.prototype,"sharedUrl",void 0);ir([h(),rr("design:type",yo)],di.prototype,"neighbourhood",void 0);ir([h(),rr("design:type",Array)],di.prototype,"owners",void 0);di=ir([H(),rr("design:paramtypes",[String,String,String])],di);var yl=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}: SurrealQL query:
1363
- ${e.query}`);let r=new t(e.perspective,e.query,this.perspectiveClient);r.isSurrealDB=!0,r.initialized&&typeof r.initialized.catch=="function"&&r.initialized.catch(()=>{});try{await r.subscribe(),await r.initialized}catch(a){let s=a?.message??String(a);this.logger.warn(`[waker] ${e.id}: subscription failed \u2014 ${s}`);try{r.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`),r.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 s=this.seenMessages.get(e.id)??new Set,o=[];for(let u of a)u&&u.source&&!s.has(u.source)&&o.push(u.source);if(o.length===0){this.logger.info(`[waker] ${e.id}: all ${a.length} items already seen, skipping`);return}this.logger.info(`[waker] ${e.id}: ${o.length} new message(s) out of ${a.length} total`);let l=[];for(let u of o){let m=[];try{let d=`SELECT * FROM link WHERE predicate = 'ad4m://has_child' AND target = '${u.replace(/'/g,"\\'")}'`;this.logger.info(`[waker] ${e.id}: resolving parents for ${u}`);let f=await this.perspectiveClient.querySurrealDB(e.perspective,d);if(Array.isArray(f))for(let g of f)g&&g.source&&m.push(g.source)}catch(y){this.logger.warn(`[waker] ${e.id}: parent resolution failed for ${u} \u2014 ${y?.message??y}`)}this.logger.info(`[waker] ${e.id}: message ${u} has ${m.length} parent(s): ${m.join(", ")}`),l.push({address:u,parents:m})}for(let u of o)s.add(u);this.seenMessages.set(e.id,s);let c=this.debounceTimers.get(e.id);c&&clearTimeout(c),this.debounceTimers.set(e.id,setTimeout(()=>{this.onWake(e,a,l),this.debounceTimers.delete(e.id),this.persist()},this.debounceMs))}else{this.logger.info(`[waker] ${e.id}: channel update (${a.length} items)`);let s=this.debounceTimers.get(e.id);s&&clearTimeout(s),this.debounceTimers.set(e.id,setTimeout(()=>{this.onWake(e,a),this.debounceTimers.delete(e.id)},this.debounceMs))}}),this.proxies.set(e.id,r),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 r=this.proxies.get(e);if(r){try{r.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,r]of this.seenMessages)e[t]=Array.from(r);this.onPersist(this.getActive(),e)}}},ss=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Nu=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Ga=class{};ss([h(),Nu("design:type",Array)],Ga.prototype,"additions",void 0);ss([h(),Nu("design:type",Array)],Ga.prototype,"removals",void 0);Ga=ss([H()],Ga);var vl=class extends hi(){};vl=ss([H()],vl);var bl=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},fr=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},fn,Pi,ua="smart_literal://content";function Eg(i){let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=t.length;for(let n=0;n<i;n++)e+=t.charAt(Math.floor(Math.random()*r));return e}var Rn=class{constructor(e,t){fn.set(this,void 0),Pi.set(this,void 0),bl(this,fn,e,"f"),bl(this,Pi,t,"f")}get base(){return fr(this,Pi,"f")}static async create(e,t){let r=le.from(Eg(10)).toUrl(),n=new Rn(e,r);return await n.set(t),n}static async isSmartLiteralBase(e,t){return(await e.get(new ae({source:t,predicate:ua}))).length>0}static async getAllSmartLiterals(e){return(await e.get(new ae({predicate:ua}))).map(r=>new Rn(e,r.data.source))}async get(){let e=await fr(this,fn,"f").getSingleTarget(new ae({source:fr(this,Pi,"f"),predicate:ua}));if(!e)throw`No content for smart literal ${fr(this,Pi,"f")}`;return le.fromUrl(e).get()}async set(e){let t=le.from(e);await fr(this,fn,"f").setSingleTarget(new Je({source:fr(this,Pi,"f"),predicate:ua,target:t.toUrl()}))}};fn=new WeakMap,Pi=new WeakMap;function hn(i,e){if("predicate"in i)return i.predicate;let{model:t}=i,r=$t(t);if(i.field){let n=r[i.field];if(!n)throw new Error(`parent(): field "${i.field}" is not a registered relation on ${t.name}`);return n.predicate}for(let[,n]of Object.entries(r))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 wl(i,e){return!i||!e?"":`triple("${i.id}", "${e}", Base)`}function Sl(){return`
1426
+ `,variables:{streamIds:Array.isArray(e)?e:[e],audio:t}}));return r}};_e=new WeakMap,Ra=new WeakMap;var Jt=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},Se=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},wt,Na,vn,Oa,bn,Oi,Ua,wn,El=class{constructor(e,t=!0){wt.set(this,void 0),Na.set(this,void 0),vn.set(this,void 0),Oa.set(this,void 0),bn.set(this,void 0),Oi.set(this,void 0),Ua.set(this,void 0),wn.set(this,void 0),Jt(this,wt,e,"f"),Jt(this,Na,new Pn(Se(this,wt,"f"),t),"f"),Jt(this,vn,new go(Se(this,wt,"f")),"f"),Jt(this,Oa,new po(Se(this,wt,"f")),"f"),Jt(this,bn,new fo(Se(this,wt,"f")),"f"),Jt(this,wn,new Eo(Se(this,wt,"f"),t),"f"),Jt(this,Oi,new Qa(Se(this,wt,"f"),t),"f"),Se(this,Oi,"f").setExpressionClient(Se(this,vn,"f")),Se(this,Oi,"f").setNeighbourhoodClient(Se(this,bn,"f")),Se(this,Oi,"f").setAIClient(Se(this,wn,"f")),Jt(this,Ua,new ho(Se(this,wt,"f"),t),"f")}get agent(){return Se(this,Na,"f")}get expression(){return Se(this,vn,"f")}get languages(){return Se(this,Oa,"f")}get neighbourhood(){return Se(this,bn,"f")}get perspective(){return Se(this,Oi,"f")}get runtime(){return Se(this,Ua,"f")}get ai(){return Se(this,wn,"f")}};wt=new WeakMap,Na=new WeakMap,vn=new WeakMap,Oa=new WeakMap,bn=new WeakMap,Oi=new WeakMap,Ua=new WeakMap,wn=new WeakMap;var Ao;(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"})(Ao||(Ao={}));var jo=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},qo=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},qi=class{constructor(e,t){this.language=e,this.expression=t}};jo([g(),qo("design:type",$t)],qi.prototype,"language",void 0);jo([g(),qo("design:type",String)],qi.prototype,"expression",void 0);qi=jo([H(),qo("design:paramtypes",[$t,String])],qi);function uv(i){return i.language.address==="did"?i.expression.toString():`${i.language.address}://${i.expression}`}function dv(i){if(i.startsWith("literal:")){let a=new $t;a.address="literal",a.name="literal";let s=i.substring(8);return new qi(a,s)}let t=/^([^:^\s]+):\/\/([\s\S]+)$/.exec(i);if(t&&t.length==3){let a=t[1],s=t[2],o=new $t;return o.address=a,new qi(o,s)}let n=/^did:([^\s]+)$/.exec(i);if(n&&n.length==2){let a=new $t;return a.address="did",new qi(a,i)}throw new Error("Couldn't parse string as expression URL or DID: "+i)}var ot=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Lt=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},es=class{};ot([g(),Lt("design:type",String)],es.prototype,"name",void 0);ot([g(),Lt("design:type",String)],es.prototype,"type",void 0);es=ot([H()],es);var qn=class{};ot([g(),Lt("design:type",String)],qn.prototype,"label",void 0);ot([g(),Lt("design:type",String)],qn.prototype,"name",void 0);ot([g(),Lt("design:type",Array)],qn.prototype,"parameters",void 0);qn=ot([H()],qn);var ts=class{get parameters(){return JSON.parse(this.parametersStringified)}constructor(e,t){this.name=e,this.parametersStringified=JSON.stringify(t)}};ot([g(),Lt("design:type",String)],ts.prototype,"name",void 0);ot([g(),Lt("design:type",String)],ts.prototype,"parametersStringified",void 0);ts=ot([Ce(),Lt("design:paramtypes",[String,Object])],ts);var is=class{};ot([g(),Lt("design:type",String)],is.prototype,"did",void 0);ot([g(),Lt("design:type",Vi)],is.prototype,"status",void 0);is=ot([H()],is);var Al=class{},sr=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Fr=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},fi=class{};sr([g(),Fr("design:type",String)],fi.prototype,"name",void 0);sr([g(),Fr("design:type",String)],fi.prototype,"address",void 0);sr([g(),Fr("design:type",String)],fi.prototype,"settings",void 0);sr([g(),Fr("design:type",Hi)],fi.prototype,"icon",void 0);sr([g(),Fr("design:type",Hi)],fi.prototype,"constructorIcon",void 0);sr([g(),Fr("design:type",Hi)],fi.prototype,"settingsIcon",void 0);fi=sr([H()],fi);var ze=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},et=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},vt=class{};ze([g(),et("design:type",String)],vt.prototype,"name",void 0);ze([g(),et("design:type",String)],vt.prototype,"address",void 0);ze([g(),et("design:type",String)],vt.prototype,"description",void 0);ze([g(),et("design:type",String)],vt.prototype,"author",void 0);ze([g(),et("design:type",Boolean)],vt.prototype,"templated",void 0);ze([g(),et("design:type",String)],vt.prototype,"templateSourceLanguageAddress",void 0);ze([g(),et("design:type",String)],vt.prototype,"templateAppliedParams",void 0);ze([g(),et("design:type",Array)],vt.prototype,"possibleTemplateParams",void 0);ze([g(),et("design:type",String)],vt.prototype,"sourceCodeLink",void 0);vt=ze([H()],vt);var Cr=class{constructor(e,t){this.name=e,this.description=t,this.description||(this.description="")}};ze([g(),et("design:type",String)],Cr.prototype,"name",void 0);ze([g(),et("design:type",String)],Cr.prototype,"description",void 0);ze([g(),et("design:type",Array)],Cr.prototype,"possibleTemplateParams",void 0);ze([g(),et("design:type",String)],Cr.prototype,"sourceCodeLink",void 0);Cr=ze([Ce(),et("design:paramtypes",[String,String])],Cr);var kl=class{},Il=class extends yi(){},Tl=class{},hs=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Bo=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},rs=class{constructor(e,t){this.linkLanguage=e,this.meta=t}};hs([g(),Bo("design:type",String)],rs.prototype,"linkLanguage",void 0);hs([g(),Bo("design:type",It)],rs.prototype,"meta",void 0);rs=hs([H(),Bo("design:paramtypes",[String,It])],rs);var ko=class extends yi(){};ko=hs([H()],ko);var or=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},cr=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},Io;(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"})(Io||(Io={}));var hi=class{constructor(e,t,r){this.uuid=e,this.name=t,r?this.state=r:this.state=Io.Private}};or([g(),cr("design:type",String)],hi.prototype,"uuid",void 0);or([g(),cr("design:type",String)],hi.prototype,"name",void 0);or([g(),cr("design:type",String)],hi.prototype,"state",void 0);or([g(),cr("design:type",String)],hi.prototype,"sharedUrl",void 0);or([g(),cr("design:type",ko)],hi.prototype,"neighbourhood",void 0);or([g(),cr("design:type",Array)],hi.prototype,"owners",void 0);hi=or([H(),cr("design:paramtypes",[String,String,String])],hi);var Cl=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:
1427
+ ${e.query}`);let r=new t(e.perspective,e.query,this.perspectiveClient);r.isSPARQL=!0,r.initialized&&typeof r.initialized.catch=="function"&&r.initialized.catch(()=>{});try{await r.subscribe(),await r.initialized}catch(a){let s=a?.message??String(a);this.logger.warn(`[waker] ${e.id}: subscription failed \u2014 ${s}`);try{r.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`),r.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 s=this.seenMessages.get(e.id)??new Set,o=[];for(let u of a)u&&u.source&&!s.has(u.source)&&o.push(u.source);if(o.length===0){this.logger.info(`[waker] ${e.id}: all ${a.length} items already seen, skipping`);return}this.logger.info(`[waker] ${e.id}: ${o.length} new message(s) out of ${a.length} total`);let c=[];for(let u of o){let m=[];try{let y=`SELECT ?source WHERE { ?source <ad4m://has_child> <${u}> . }`;this.logger.info(`[waker] ${e.id}: resolving parents for ${u}`);let d=await this.perspectiveClient.querySparql(e.perspective,y);if(Array.isArray(d))for(let f of d)f&&f.source&&m.push(f.source)}catch(y){this.logger.warn(`[waker] ${e.id}: parent resolution failed for ${u} \u2014 ${y?.message??y}`)}this.logger.info(`[waker] ${e.id}: message ${u} has ${m.length} parent(s): ${m.join(", ")}`),c.push({address:u,parents:m})}for(let u of o)s.add(u);this.seenMessages.set(e.id,s);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 s=this.debounceTimers.get(e.id);s&&clearTimeout(s),this.debounceTimers.set(e.id,setTimeout(()=>{this.onWake(e,a),this.debounceTimers.delete(e.id)},this.debounceMs))}}),this.proxies.set(e.id,r),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 r=this.proxies.get(e);if(r){try{r.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,r]of this.seenMessages)e[t]=Array.from(r);this.onPersist(this.getActive(),e)}}},gs=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},Qu=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},ns=class{};gs([g(),Qu("design:type",Array)],ns.prototype,"additions",void 0);gs([g(),Qu("design:type",Array)],ns.prototype,"removals",void 0);ns=gs([H()],ns);var Ll=class extends yi(){};Ll=gs([H()],Ll);var Pl=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},br=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Sn,Ui,ba="smart_literal://content";function Hg(i){let e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=t.length;for(let n=0;n<i;n++)e+=t.charAt(Math.floor(Math.random()*r));return e}var Bn=class{constructor(e,t){Sn.set(this,void 0),Ui.set(this,void 0),Pl(this,Sn,e,"f"),Pl(this,Ui,t,"f")}get base(){return br(this,Ui,"f")}static async create(e,t){let r=le.from(Hg(10)).toUrl(),n=new Bn(e,r);return await n.set(t),n}static async isSmartLiteralBase(e,t){return(await e.get(new B({source:t,predicate:ba}))).length>0}static async getAllSmartLiterals(e){return(await e.get(new B({predicate:ba}))).map(r=>new Bn(e,r.data.source))}async get(){let e=await br(this,Sn,"f").getSingleTarget(new B({source:br(this,Ui,"f"),predicate:ba}));if(!e)throw`No content for smart literal ${br(this,Ui,"f")}`;return le.fromUrl(e).get()}async set(e){let t=le.from(e);await br(this,Sn,"f").setSingleTarget(new Xe({source:br(this,Ui,"f"),predicate:ba,target:t.toUrl()}))}};Sn=new WeakMap,Ui=new WeakMap;function _n(i,e){if("predicate"in i)return i.predicate;let{model:t}=i,r=St(t);if(i.field){let n=r[i.field];if(!n)throw new Error(`parent(): field "${i.field}" is not a registered relation on ${t.name}`);return n.predicate}for(let[,n]of Object.entries(r))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 Rl(i,e){return!i||!e?"":`triple("${i.id}", "${e}", Base)`}function Nl(){return`
1364
1428
  findall(
1365
1429
  [T, A],
1366
1430
  link(Base, _, _, T, A),
@@ -1368,52 +1432,80 @@ ${e.query}`);let r=new t(e.perspective,e.query,this.perspectiveClient);r.isSurre
1368
1432
  ),
1369
1433
  sort(AllLinks, SortedLinks),
1370
1434
  SortedLinks = [[Timestamp, Author]|_]
1371
- `}function $g(i){return`
1435
+ `}function zg(i){return`
1372
1436
  findall([PropertyName, PropertyValue, Resolve], (
1373
1437
  % Constrain to specified properties if provided
1374
1438
  ${i?`member(PropertyName, [${i.map(e=>`"${e}"`).join(", ")}]),`:""}
1375
1439
  resolve_property(SubjectClass, Base, PropertyName, PropertyValue, Resolve)
1376
1440
  ), Properties)
1377
- `}function _l(i={}){function e(t){return typeof t=="string"?`"${t}"`:t}return Object.entries(i).map(([t,r])=>{let n=["id","author","timestamp"].includes(t),a=`resolve_property(SubjectClass, Base, "${t}", Value${t}, _)`,s=t==="id"?"Base":He(t);if(Array.isArray(r)){let o=r.map(l=>e(l)).join(", ");return n?`member(${s}, [${o}])`:`${a}, member(Value${t}, [${o}])`}if(typeof r=="object"&&r!==null){let{not:o,between:l,lt:c,lte:u,gt:m,gte:y}=r;if(o!==void 0)if(Array.isArray(o)){let f=o.map(g=>e(g)).join(", ");return n?`\\+ member(${s}, [${f}])`:`${a}, \\+ member(Value${t}, [${f}])`}else return n?`${s} \\= ${e(o)}`:`${a}, Value${t} \\= ${e(o)}`;if(l!==void 0&&Array.isArray(l)&&l.length===2)return n?`${s} >= ${l[0]}, ${s} =< ${l[1]}`:`${a}, Value${t} >= ${l[0]}, Value${t} =< ${l[1]}`;let d=[{value:c,symbol:"<"},{value:u,symbol:"=<"},{value:m,symbol:">"},{value:y,symbol:">="}];for(let{value:f,symbol:g}of d)if(f!==void 0)return n?`${s} ${g} ${f}`:`${a}, Value${t} ${g} ${f}`}return n?`${s} = ${e(r)}`:`${a}, Value${t} = ${e(r)}`}).join(", ")}function xl(i){return i?"length(UnsortedInstances, TotalCount)":""}function El(i){if(!i)return"SortedInstances = UnsortedInstances";let e=Object.entries(i);if(e.length===1){let[r,n]=e[0];return`sort_instances(UnsortedInstances, "${r}", "${n}", SortedInstances)`}let t=[];for(let r=e.length-1;r>=0;r--){let[n,a]=e[r],s=r===e.length-1?"UnsortedInstances":`MultiSortIntermediate${r+1}`,o=r===0?"SortedInstances":`MultiSortIntermediate${r}`;t.push(`sort_instances(${s}, "${n}", "${a}", ${o})`)}return t.join(`,
1378
- `)}function $l(i){return!i||i<0?"InstancesWithOffset = SortedInstances":`skipN(SortedInstances, ${i}, InstancesWithOffset)`}function Al(i){return!i||i<0?"AllInstances = InstancesWithOffset":`takeN(InstancesWithOffset, ${i}, AllInstances)`}function kl(i){if(!i)return"";if(i.includes("://")){let[e,t]=i.split("://"),r=(t||"").replace(/\/+$/,"");return`${e}://${r}`}else return i.replace(/\/+$/,"")}function Ro(i){if(!!i){if(typeof i=="string")return i;if(Array.isArray(i)&&i.length>0)return i.find(t=>t!=="null")||i[0]}}function Ou(i,e){return Ro(i.type)===e}function Du(i){return Ou(i,"array")}function Il(i){return Ou(i,"object")}function Ag(i){let e=Ro(i.type);return e==="number"||e==="integer"}function Uu(i,e){if(e.namespace)return e.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(n=>n);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:
1441
+ `}function Ol(i={}){function e(t){return typeof t=="string"?`"${t}"`:t}return Object.entries(i).map(([t,r])=>{let n=["id","author","timestamp"].includes(t),a=`resolve_property(SubjectClass, Base, "${t}", Value${t}, _)`,s=t==="id"?"Base":He(t);if(Array.isArray(r)){let o=r.map(c=>e(c)).join(", ");return n?`member(${s}, [${o}])`:`${a}, member(Value${t}, [${o}])`}if(typeof r=="object"&&r!==null){let{not:o,between:c,lt:l,lte:u,gt:m,gte:y}=r;if(o!==void 0)if(Array.isArray(o)){let f=o.map(h=>e(h)).join(", ");return n?`\\+ member(${s}, [${f}])`:`${a}, \\+ member(Value${t}, [${f}])`}else return n?`${s} \\= ${e(o)}`:`${a}, Value${t} \\= ${e(o)}`;if(c!==void 0&&Array.isArray(c)&&c.length===2)return n?`${s} >= ${c[0]}, ${s} =< ${c[1]}`:`${a}, Value${t} >= ${c[0]}, Value${t} =< ${c[1]}`;let d=[{value:l,symbol:"<"},{value:u,symbol:"=<"},{value:m,symbol:">"},{value:y,symbol:">="}];for(let{value:f,symbol:h}of d)if(f!==void 0)return n?`${s} ${h} ${f}`:`${a}, Value${t} ${h} ${f}`}return n?`${s} = ${e(r)}`:`${a}, Value${t} = ${e(r)}`}).join(", ")}function Ul(i){return i?"length(UnsortedInstances, TotalCount)":""}function Dl(i){if(!i)return"SortedInstances = UnsortedInstances";let e=Object.entries(i);if(e.length===1){let[r,n]=e[0];return`sort_instances(UnsortedInstances, "${r}", "${n}", SortedInstances)`}let t=[];for(let r=e.length-1;r>=0;r--){let[n,a]=e[r],s=r===e.length-1?"UnsortedInstances":`MultiSortIntermediate${r+1}`,o=r===0?"SortedInstances":`MultiSortIntermediate${r}`;t.push(`sort_instances(${s}, "${n}", "${a}", ${o})`)}return t.join(`,
1442
+ `)}function Ml(i){return!i||i<0?"InstancesWithOffset = SortedInstances":`skipN(SortedInstances, ${i}, InstancesWithOffset)`}function Fl(i){return!i||i<0?"AllInstances = InstancesWithOffset":`takeN(InstancesWithOffset, ${i}, AllInstances)`}function jl(i){if(!i)return"";if(i.includes("://")){let[e,t]=i.split("://"),r=(t||"").replace(/\/+$/,"");return`${e}://${r}`}else return i.replace(/\/+$/,"")}function Ho(i){if(!!i){if(typeof i=="string")return i;if(Array.isArray(i)&&i.length>0)return i.find(t=>t!=="null")||i[0]}}function Gu(i,e){return Ho(i.type)===e}function Zu(i){return Gu(i,"array")}function ql(i){return Gu(i,"object")}function Vg(i){let e=Ho(i.type);return e==="number"||e==="integer"}function Ju(i,e){if(e.namespace)return e.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(n=>n);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:
1379
1443
  - options.namespace
1380
1444
  - schema["x-ad4m"].namespace
1381
1445
  - schema.title
1382
- - valid schema.$id`)}function Mu(i,e,t,r,n){if(n.propertyMapping?.[e])return n.propertyMapping[e];if(t["x-ad4m"]?.through)return t["x-ad4m"].through;if(n.predicateTemplate){let s=kl(r),[o,l]=s.includes("://")?s.split("://"):["",s],c=l||"";return n.predicateTemplate.replace("${namespace}",c).replace("${scheme}",o).replace("${ns}",c).replace("${title}",i.title||"").replace("${property}",e)}if(n.predicateGenerator)return n.predicateGenerator(i.title||"",e);let a=kl(r);return a.includes("://")?`${a}${e}`:`${a}://${e}`}function Kr(i,e,t,r,n){return t.propertyOptions?.[i]?.[r]!==void 0?t.propertyOptions[i][r]:e["x-ad4m"]?.[r]!==void 0?e["x-ad4m"][r]:t[r]!==void 0?t[r]:n}function kg(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 Ig(i,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 r=Uu(e,t),n=class extends i{};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={},s={};if(e.properties)for(let[l,c]of Object.entries(e.properties)){let u=Mu(e,l,c,r,t),m=e.required?.includes(l)||!1,y=Ro(c.type);if(Du(c)){s[l]={through:u,local:Kr(l,c,t,"local")},Object.defineProperty(n.prototype,l,{configurable:!0,writable:!0,value:[]});let f=`add${He(l)}`,g=`remove${He(l)}`,_=`set${He(l)}`;n.prototype[f]=function(){},n.prototype[g]=function(){},n.prototype[_]=function(){}}else{let f=Kr(l,c,t,"resolveLanguage");!f&&t.resolveLanguage&&(f=t.resolveLanguage);let g=Kr(l,c,t,"local"),_=Kr(l,c,t,"readOnly");if(_===void 0){let k=c["x-ad4m"]?.writable;_=k!==void 0?!k:!1}let E=!_,A=Kr(l,c,t,"initial");if(Il(c)&&!f&&(f="literal",console.warn(`Property "${l}" is an object type. It will be stored as JSON. Consider flattening complex objects for better semantic querying.`)),f==null&&Ag(c)&&(f="literal"),f==null&&(f="literal"),m&&!A&&(Il(c)?A="literal://json:{}":A="ad4m://undefined"),a[l]={through:u,required:m,writable:E,...f&&{resolveLanguage:f},...g!==void 0&&{local:g},...A&&{initial:A}},Object.defineProperty(n.prototype,l,{configurable:!0,writable:!0,value:kg(y)}),E){let k=Ya(l);n.prototype[k]=function(){}}}}for(let[l,c]of Object.entries(a))op(n,l,c);for(let[l,c]of Object.entries(s))cp(n,l,{predicate:c.through||"",kind:"hasMany",...c.getter!==void 0&&{getter:c.getter},...c.local!==void 0&&{local:c.local}});return n.prototype.__jsonSchema=e,n.prototype.__jsonSchemaOptions=t,lp({name:t.name})(n),n}function Tg(i,e,t){if(!t)return"";let r=[];for(let[n,a]of Object.entries(t))if(["id","author","timestamp"].includes(n)){if(n==="author"||n==="timestamp")continue;let o="uri";if(Array.isArray(a)){let l=a.map(c=>ce(c)).join(", ");r.push(`${o} IN [${l}]`)}else if(typeof a=="object"&&a!==null){let l=a;if(l.not!==void 0)if(Array.isArray(l.not)){let c=l.not.map(u=>ce(u)).join(", ");r.push(`${o} NOT IN [${c}]`)}else r.push(`${o} != ${ce(l.not)}`);l.between!==void 0&&Array.isArray(l.between)&&l.between.length===2&&r.push(`${o} >= ${ce(l.between[0])} AND ${o} <= ${ce(l.between[1])}`),l.gt!==void 0&&r.push(`${o} > ${ce(l.gt)}`),l.gte!==void 0&&r.push(`${o} >= ${ce(l.gte)}`),l.lt!==void 0&&r.push(`${o} < ${ce(l.lt)}`),l.lte!==void 0&&r.push(`${o} <= ${ce(l.lte)}`),l.contains!==void 0&&r.push(`${o} CONTAINS ${ce(l.contains)}`)}else r.push(`${o} = ${ce(a)}`)}else{let o=e[n],l=o?.kind==="belongsToOne"||o?.kind==="belongsToMany";if(o){let y=ee(o.predicate);if(Array.isArray(a)){let d=a.map(f=>ce(f)).join(", ");l?r.push(`count(<-link[WHERE predicate = '${y}' AND in.uri IN [${d}]]) > 0`):r.push(`count(->link[WHERE predicate = '${y}' AND out.uri IN [${d}]]) > 0`)}else if(typeof a=="object"&&a!==null){let d=a;if(d.not!==void 0)if(Array.isArray(d.not)){let f=d.not.map(g=>ce(g)).join(", ");l?r.push(`count(<-link[WHERE predicate = '${y}' AND in.uri IN [${f}]]) = 0`):r.push(`count(->link[WHERE predicate = '${y}' AND out.uri IN [${f}]]) = 0`)}else l?r.push(`count(<-link[WHERE predicate = '${y}' AND in.uri = ${ce(d.not)}]) = 0`):r.push(`count(->link[WHERE predicate = '${y}' AND out.uri = ${ce(d.not)}]) = 0`)}else l?r.push(`count(<-link[WHERE predicate = '${y}' AND in.uri = ${ce(a)}]) > 0`):r.push(`count(->link[WHERE predicate = '${y}' AND out.uri = ${ce(a)}]) > 0`);continue}let c=i.properties[n];if(!c)continue;let u=ee(c.predicate),m=c.resolveLanguage==="literal"?"fn::parse_literal(out.uri)":"out.uri";if(Array.isArray(a)){let y=a.map(d=>ce(d)).join(", ");r.push(`count(->link[WHERE predicate = '${u}' AND ${m} IN [${y}]]) > 0`)}else if(typeof a=="object"&&a!==null){let y=a;if(y.not!==void 0)if(Array.isArray(y.not)){let f=y.not.map(g=>ce(g)).join(", ");r.push(`count(->link[WHERE predicate = '${u}' AND ${m} IN [${f}]]) = 0`)}else r.push(`count(->link[WHERE predicate = '${u}' AND ${m} = ${ce(y.not)}]) = 0`);(y.gt!==void 0||y.gte!==void 0||y.lt!==void 0||y.lte!==void 0||y.between!==void 0||y.contains!==void 0)&&r.push(`count(->link[WHERE predicate = '${u}']) > 0`)}else r.push(`count(->link[WHERE predicate = '${u}' AND ${m} = ${ce(a)}]) > 0`)}return r.join(" AND ")}function Cg(i,e,t,r){let{where:n}=t,a=[];if(t.parent){let c=hn(t.parent,r);a.push(`count(<-link[WHERE in.uri = ${ce(t.parent.id)} AND predicate = '${ee(c)}']) > 0`)}for(let[,c]of Object.entries(i.properties))if(c.required){if(c.getter)continue;c.flag&&c.initial?a.push(`count(->link[WHERE predicate = '${ee(c.predicate)}' AND out.uri = '${ee(c.initial)}']) > 0`):a.push(`count(->link[WHERE predicate = '${ee(c.predicate)}']) > 0`)}if(a.length===0){for(let[,c]of Object.entries(i.properties))if(c.initial){c.flag?a.push(`count(->link[WHERE predicate = '${ee(c.predicate)}' AND out.uri = '${ee(c.initial)}']) > 0`):a.push(`count(->link[WHERE predicate = '${ee(c.predicate)}']) > 0`);break}}if(a.length===0){let c=[];for(let[,u]of Object.entries(i.properties))u.predicate&&c.push(`predicate = '${ee(u.predicate)}'`);if(i.relations)for(let[,u]of Object.entries(i.relations))u.predicate&&c.push(`predicate = '${ee(u.predicate)}'`);c.length>0&&a.push(`count(->link[WHERE (${c.join(" OR ")})]) > 0`)}let s=Tg(i,e,n),o=[];return o.push(...a),s&&o.push(s),o.push("count(->link) > 0"),`
1383
- SELECT
1384
- id AS source,
1385
- uri AS source_uri,
1386
- ->link AS links
1387
- FROM node
1388
- WHERE ${o.join(" AND ")}
1389
- FETCH links
1390
- `.trim()}var bo=class{constructor(e,t,r){this.queryParams={},this.modelClassName=null,this.useSurrealDBFlag=!0,this.perspective=e,this.ctor=t,r&&(this.queryParams=r)}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,r){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 s=e.constructor;return this.queryParams.parent={id:n,model:s,field:t.field},this}let a=r?.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}useSurrealDB(e=!0){return this.useSurrealDBFlag=e,this}async get(){let e;if(this.useSurrealDBFlag){let t=await this.ctor.queryToSurrealQL(this.perspective,this.queryParams),r=await this.perspective.querySurrealDB(t);({results:e}=await this.ctor.instancesFromSurrealResult(this.perspective,this.queryParams,r))}else{let t=await this.ctor.queryToProlog(this.perspective,this.queryParams,this.modelClassName),r=await this.perspective.infer(t);({results:e}=await this.ctor.instancesFromPrologResult(this.perspective,this.queryParams,r))}return e}async first(){return this.queryParams.limit=1,(await this.get())[0]??null}async subscribe(e){this.dispose();let t=this.ctor;if(this.useSurrealDBFlag){let r=await t.queryToSurrealQL(this.perspective,this.queryParams);this.currentSubscription=await this.perspective.subscribeSurrealDB(r);let n=async s=>{let{results:o}=await t.instancesFromSurrealResult(this.perspective,this.queryParams,s);e(o)};this.currentSubscription.onResult(n);let{results:a}=await t.instancesFromSurrealResult(this.perspective,this.queryParams,this.currentSubscription.result);return e(a),a}else{let r=await t.queryToProlog(this.perspective,this.queryParams,this.modelClassName);this.currentSubscription=await this.perspective.subscribeInfer(r);let n=async s=>{let{results:o}=await t.instancesFromPrologResult(this.perspective,this.queryParams,s);e(o)};this.currentSubscription.onResult(n);let{results:a}=await t.instancesFromPrologResult(this.perspective,this.queryParams,this.currentSubscription.result);return e(a),a}}async count(){if(this.useSurrealDBFlag){let e=await this.ctor.queryToSurrealQL(this.perspective,this.queryParams),t=await this.perspective.querySurrealDB(e),{totalCount:r}=await this.ctor.instancesFromSurrealResult(this.perspective,this.queryParams,t);return r}else{let e=await this.ctor.countQueryToProlog(this.perspective,this.queryParams,this.modelClassName);return(await this.perspective.infer(e))?.[0]?.TotalCount||0}}async countSubscribe(e){if(this.dispose(),this.useSurrealDBFlag){let t=await this.ctor.queryToSurrealQL(this.perspective,this.queryParams);this.currentSubscription=await this.perspective.subscribeSurrealDB(t);let r=async a=>{let{totalCount:s}=await this.ctor.instancesFromSurrealResult(this.perspective,this.queryParams,a);e(s)};this.currentSubscription.onResult(r);let{totalCount:n}=await this.ctor.instancesFromSurrealResult(this.perspective,this.queryParams,this.currentSubscription.result);return e(n),n}else{let t=await this.ctor.countQueryToProlog(this.perspective,this.queryParams,this.modelClassName);this.currentSubscription=await this.perspective.subscribeInfer(t);let r=async a=>{let s=a?.[0]?.TotalCount||0;e(s)};this.currentSubscription.onResult(r);let n=this.currentSubscription.result?.[0]?.TotalCount||0;return e(n),n}}async paginate(e,t){let r={...this.queryParams||{},limit:e,offset:e*(t-1),count:!0};if(this.useSurrealDBFlag){let n=await this.ctor.queryToSurrealQL(this.perspective,r),a=await this.perspective.querySurrealDB(n),{results:s,totalCount:o}=await this.ctor.instancesFromSurrealResult(this.perspective,r,a);return{results:s,totalCount:o,pageSize:e,pageNumber:t}}else{let n=await this.ctor.queryToProlog(this.perspective,r,this.modelClassName),a=await this.perspective.infer(n),{results:s,totalCount:o}=await this.ctor.instancesFromPrologResult(this.perspective,r,a);return{results:s,totalCount:o,pageSize:e,pageNumber:t}}}async paginateSubscribe(e,t,r){this.dispose();let n={...this.queryParams||{},limit:e,offset:e*(t-1),count:!0};if(this.useSurrealDBFlag){let a=await this.ctor.queryToSurrealQL(this.perspective,n);this.currentSubscription=await this.perspective.subscribeSurrealDB(a);let s=async u=>{let{results:m,totalCount:y}=await this.ctor.instancesFromSurrealResult(this.perspective,n,u);r({results:m,totalCount:y,pageSize:e,pageNumber:t})};this.currentSubscription.onResult(s);let{results:o,totalCount:l}=await this.ctor.instancesFromSurrealResult(this.perspective,n,this.currentSubscription.result),c={results:o,totalCount:l,pageSize:e,pageNumber:t};return r(c),c}else{let a=await this.ctor.queryToProlog(this.perspective,n,this.modelClassName);this.currentSubscription=await this.perspective.subscribeInfer(a);let s=async u=>{let{results:m,totalCount:y}=await this.ctor.instancesFromPrologResult(this.perspective,this.queryParams,u);r({results:m,totalCount:y,pageSize:e,pageNumber:t})};this.currentSubscription.onResult(s);let{results:o,totalCount:l}=await this.ctor.instancesFromPrologResult(this.perspective,n,this.currentSubscription.result),c={results:o,totalCount:l,pageSize:e,pageNumber:t};return r(c),c}}};function da(i){return Array.isArray(i)?i.map(e=>e&&typeof e=="object"&&typeof e.id=="string"?e.id:e):i}function Tl(i,e){if(Array.isArray(e))return e.includes(i);if(typeof e=="object"&&e!==null){let t=e;if(t.not!==void 0)return Array.isArray(t.not)?!t.not.includes(i):i!==t.not;if(t.between!==void 0&&Array.isArray(t.between)&&t.between.length===2)return i>=t.between[0]&&i<=t.between[1];let r=!0;return t.gt!==void 0&&(r=r&&i>t.gt),t.gte!==void 0&&(r=r&&i>=t.gte),t.lt!==void 0&&(r=r&&i<t.lt),t.lte!==void 0&&(r=r&&i<=t.lte),t.contains!==void 0&&(typeof i=="string"?r=r&&i.includes(String(t.contains)):Array.isArray(i)?r=r&&i.includes(t.contains):r=!1),r}return i===e}async function Lg(i,e,t,r){let n=i;if(i!=null&&i!=="")if(e.resolveLanguage!=null&&e.resolveLanguage!=="literal"&&typeof i=="string"&&!i.startsWith("literal://"))try{let a=await t.getExpression(i);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 i=="string"&&i.startsWith("literal://"))try{let a=le.fromUrl(i).get();n=a.data!==void 0?a.data:a}catch{}else typeof i=="string"&&r&&(r==="number"?n=Number(i):r==="boolean"&&(n=i==="true"||i==="1"));return e.transform&&typeof e.transform=="function"&&(n=e.transform(n)),n}async function Cl(i,e,t,r,n){if(!e||e.length===0)return;let a=null,s=null,o=null,l=n&&n.length>0?new Set(n):null,c=new Map;for(let[f,g]of Object.entries(t.properties))g.getter||l&&!l.has(f)||c.set(g.predicate,[f,g]);let u=new Map,m=[];for(let[f,g]of Object.entries(t.relations))if(!g.getter){if(g.target&&g.filter!==!1){m.push([f,g]);continue}u.set(g.predicate,[f,g])}for(let[f,g]of m)u.has(g.predicate)||u.set(g.predicate,[f,g]);let y=new Map,d=new Map;for(let f=0;f<e.length;f++){let g=e[f],{predicate:_,target:E,author:A,timestamp:k}=g;if(E==="None"||E===void 0||E===null)continue;k!=null&&((a==null||k<a)&&(a=k,o=A??null),(s==null||k>s)&&(s=k));let w=c.get(_);if(w){y.get(w[0]),y.set(w[0],{target:E,timestamp:k});continue}let C=u.get(_);if(C){let[U]=C,P=d.get(U);P||(P=[],d.set(U,P)),P.push({target:E,timestamp:k??"",index:f})}}for(let[f,{target:g}]of y){let[,_]=c.get(t.properties[f].predicate),E=typeof i[f];i[f]=await Lg(g,_,r,E!=="undefined"?E:void 0)}for(let[f,g]of d)g.sort((_,E)=>{let A=String(_.timestamp).localeCompare(String(E.timestamp));return A!==0?A:_.index-E.index}),i[f]=g.map(_=>_.target).filter(_=>_!=null&&_!==""&&_!=="None");o&&(i.author=o),a!=null&&(i.createdAt=typeof a=="string"&&a.includes("T")?new Date(a).getTime():typeof a=="string"?isNaN(parseInt(a,10))?a:parseInt(a,10):a),s!=null&&(i.updatedAt=typeof s=="string"&&s.includes("T")?new Date(s).getTime():typeof s=="string"?isNaN(parseInt(s,10))?s:parseInt(s,10):s)}async function Pg(i,e,t){let r=Object.fromEntries(await Promise.all(t.map(async([a,s,o])=>{let l=s;if(!o&&typeof s=="string"){let m=Array.from(s,f=>f.codePointAt(0)),y=m.every(f=>f<=255),d=m.some(f=>f>=128);if(y&&d)try{let f=Uint8Array.from(m),g=new TextDecoder("utf-8",{fatal:!0}).decode(f);g!==s&&(l=g)}catch(f){console.warn(`UTF-8 byte reconstruction failed for property "${a}"`,{value:s,error:f})}}if(o){let m=await i.getExpression(s);if(m)try{l=JSON.parse(m.data)}catch{l=m.data}}let u=Hi(e.constructor)[a]?.transform;return u&&typeof u=="function"&&(l=u(l)),[a,l]}))),n=Object.fromEntries(Object.entries(r).filter(([a])=>{let s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),a);return s?s.get!==void 0||s.set!==void 0?s.set!==void 0:s.writable!==!1:!0}));Object.assign(e,n)}function Rg(i,e){let t=Gl(i,e);if(!t){let r=e?.prototype?.className||e?.name||"unknown";console.warn(`[Ad4mModel] buildConformanceGetter: no conditions found for target "${r}".`);return}return t.getter}async function Ll(i,e,t,r){let n=ce(i.id),s=r?.requestedProperties&&r.requestedProperties.length>0?new Set(r.requestedProperties):null;for(let[o,l]of Object.entries(t.properties))if(!(s&&!s.has(o))&&l.getter)try{let c=l.getter.replace(/Base/g,n),u=await e.querySurrealDB(`SELECT (${c}) AS value FROM node WHERE uri = ${n}`);u&&u.length>0&&u[0].value!==void 0&&u[0].value!==null&&u[0].value!=="None"&&u[0].value!==""&&(i[o]=u[0].value)}catch(c){console.warn(`Failed to evaluate getter for ${o}:`,c)}for(let[o,l]of Object.entries(t.relations)){if(s&&!s.has(o)&&!(r?.include&&o in r.include))continue;let c=l,u=c.getter;if(!u&&c.where&&c.direction!=="reverse")try{let m=c.target?.(),y=m?m.getModelMetadata?.()??null:null,d=Ql(c.where,y);d.length>0&&(u=`(->link[WHERE predicate = '${ee(c.predicate)}'].out[WHERE ${d.join(" AND ")}].uri)`)}catch{}if(!u&&c.target&&c.filter!==!1&&c.direction!=="reverse")try{let m=c.target();u=Rg(c.predicate,m),u||console.warn(`[Ad4mModel] buildConformanceGetter returned undefined for relation "${o}" (predicate: "${c.predicate}")`)}catch(m){console.warn(`[Ad4mModel] auto-generation failed for relation "${o}":`,m)}if(u)try{let y=`SELECT (${u.replace(/Base/g,n)}) AS value FROM node WHERE uri = ${n}`,d=await e.querySurrealDB(y);if(d&&d.length>0&&d[0].value!==void 0&&d[0].value!==null){let f=d[0].value;i[o]=Array.isArray(f)?f.filter(g=>g!=null&&g!==""&&g!=="None"):f}}catch(m){console.warn(`Failed to evaluate getter for ${o}:`,m)}}}async function bn(i,e,t,r){if(!r||Object.keys(r).length===0)return;let n=$t(i);for(let[a,s]of Object.entries(r)){let o=n[a];if(!o){console.warn(`include: relation "${a}" not found in metadata, skipping`);continue}let l=o.target(),c=typeof s=="object"&&s!==null?s:void 0,u=c?.include;if(o.kind==="belongsToOne"||o.kind==="belongsToMany"){for(let E of e){let k=(await t.get(new ae({predicate:o.predicate,target:E.id}))).filter(w=>w.data.target===E.id).map(w=>w.data.source);if(o.kind==="belongsToOne"){if(k.length===0){E[a]=null;continue}let w=k[k.length-1];try{let C=new l(t,w);await C.get(),E[a]=C}catch{E[a]=null}}else{let w=[];if(c&&(c.where||c.order||c.properties)){let C={id:k,...c.where??{}};w=await l.findAll(t,{where:C,...c.order&&{order:c.order},...c.properties&&{properties:c.properties}})}else await Promise.all(k.map(async C=>{try{let U=new l(t,C);await U.get(c?.properties?{properties:c.properties}:void 0),w.push(U)}catch{}}));if(c?.order&&!(c.where||c.properties)){let C=Object.entries(c.order);w=w.sort((U,P)=>{for(let[Q,V]of C){let R=String(U[Q]??""),W=String(P[Q]??""),We=R.localeCompare(W);if(We!==0)return V==="DESC"?-We:We}return 0})}if(c?.offset!=null||c?.limit!=null){let C=c.offset??0,U=c.limit!=null?C+c.limit:void 0;w=w.slice(C,U)}E[a]=w,u&&w.length>0&&await bn(l,w,t,u)}}continue}let m=new Set,y=new Map;for(let E of e){let A=E[a];if(y.set(E,Array.isArray(A)?[...A]:A),A!=null)if(Array.isArray(A))for(let k of A)typeof k=="string"?m.add(k):k&&typeof k=="object"&&typeof k.id=="string"&&m.add(k.id);else typeof A=="string"?m.add(A):A&&typeof A=="object"&&typeof A.id=="string"&&m.add(A.id)}if(m.size===0)continue;let d=new Map,g={where:{id:Array.from(m),...c?.where??{}},...c?.order&&{order:c.order},...c?.properties&&{properties:c.properties}},_=await l.findAll(t,g);for(let E of _)d.set(E.id,E);for(let E of e){let A=y.get(E);if(A!=null)if(Array.isArray(A)){let k=A.map(w=>typeof w=="string"?d.has(w)?d.get(w):null:w&&typeof w=="object"&&typeof w.id=="string"?d.has(w.id)?d.get(w.id):w:null).filter(w=>w!==null);if(c?.order){let w=Object.entries(c.order);k=k.sort((C,U)=>{for(let[P,Q]of w){let V=String(C[P]??""),R=String(U[P]??""),W=V.localeCompare(R);if(W!==0)return Q==="DESC"?-W:W}return 0})}if(c?.offset!=null||c?.limit!=null){let w=c.offset??0,C=c.limit!=null?w+c.limit:void 0;k=k.slice(w,C)}o.maxCount===1?(k.length>1&&console.warn(`include: relation "${a}" has maxCount 1 but ${k.length} values found; keeping the last`),E[a]=k.length>0?k[k.length-1]:null):E[a]=k}else typeof A=="string"&&d.has(A)?E[a]=d.get(A):A&&typeof A=="object"&&typeof A.id=="string"&&(E[a]=d.has(A.id)?d.get(A.id):A)}if(u){let E=Array.from(d.values());await bn(l,E,t,u)}}}var $r=class{static generateSDNA(){return{sdna:"",name:""}}static generateSHACL(){return{shape:null,name:""}}static async getClassName(e){if(this===$r)return await e.stringOrTemplateObjectToSubjectClassName(this);let r=this.classNamesByClass.get(this);r||(r={},this.classNamesByClass.set(this,r));let n=e.uuid;return r[n]||(r[n]=await e.stringOrTemplateObjectToSubjectClassName(this)),r[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,r={},n=Hi(this);for(let[m,y]of Object.entries(n)){let d=y;r[m]={name:m,predicate:d.through||"",required:d.required||!1,readOnly:!(d.writable??!1),...d.initial!==void 0&&{initial:d.initial},...d.resolveLanguage!==void 0&&{resolveLanguage:d.resolveLanguage},...d.prologGetter!==void 0&&{prologGetter:d.prologGetter},...d.getter!==void 0&&{getter:d.getter},...d.prologSetter!==void 0&&{prologSetter:d.prologSetter},...d.local!==void 0&&{local:d.local},...d.transform!==void 0&&{transform:d.transform},...d.flag!==void 0&&{flag:d.flag}}}let a={},s=$t(this),o=Object.fromEntries(Object.entries(s).filter(([,m])=>m.kind==="hasMany"||m.kind==="belongsToMany"));for(let[m,y]of Object.entries(o)){let d=y;a[m]={name:m,predicate:d.predicate||"",...d.local!==void 0&&{local:d.local},...d.getter!==void 0&&{getter:d.getter},direction:d.kind==="belongsToMany"||d.kind==="belongsToOne"?"reverse":"forward",...d.target!==void 0&&{target:d.target},...d.filter!==void 0&&{filter:d.filter},...d.where!==void 0&&{where:d.where}}}let l=Object.keys(r).length>0,c=Object.keys(a).length>0;if(!(l||c)&&e.__jsonSchema){let m=e.__jsonSchema,y=e.__jsonSchemaOptions||{};if(m.properties)for(let[d,f]of Object.entries(m.properties)){let g=Du(f),_=Mu(m,d,f,Uu(m,y),y);if(g)a[d]={name:d,predicate:_,...f["x-ad4m"]?.local!==void 0&&{local:f["x-ad4m"].local}};else{let E=m.required?.includes(d)||!1;r[d]={name:d,predicate:_,required:E,readOnly:f["x-ad4m"]?.writable===!1,...f["x-ad4m"]?.resolveLanguage&&{resolveLanguage:f["x-ad4m"].resolveLanguage},...f["x-ad4m"]?.initial&&{initial:f["x-ad4m"].initial},...f["x-ad4m"]?.local!==void 0&&{local:f["x-ad4m"].local}}}}}return{className:t,properties:r,relations:a}}constructor(e,t){this._snapshot=null,this._baseExpression=t||le.from(Wl(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 Hi(t)[e]}getRelationOptions(e){let t=this.constructor;return $t(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 r=this.getRelationOptions(e);if(!r)throw new Error(`Relation "${e}" has no metadata defined`);if(!r.predicate)throw new Error(`Relation "${e}" has no predicate defined`);return[{action:{adder:"addLink",remover:"removeLink",setter:"collectionSetter"}[t],source:"this",predicate:r.predicate,target:"value",...r.local&&{local:!0}}]}static async assignValuesToInstance(e,t,r){return Pg(e,t,r)}takeSnapshot(e){let r=this.constructor.getModelMetadata(),n={};for(let a of Object.keys(r.properties)){let s=this[a];n[a]=da(Array.isArray(s)?[...s]:s)}if(e===void 0)for(let a of Object.keys(r.relations)){let s=this[a];n[a]=da(Array.isArray(s)?[...s]:s)}else if(e&&Object.keys(e).length>0){for(let a of Object.keys(e))if(a in r.relations){let s=this[a];n[a]=da(Array.isArray(s)?[...s]:s)}}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 r=[],n=[...Object.keys(t.properties),...Object.keys(t.relations)];for(let a of n){if(!(a in this._snapshot))continue;let s=da(this[a]),o=this._snapshot[a];if(Array.isArray(s)||Array.isArray(o)){let l=Array.isArray(s)?[...s].sort():[],c=Array.isArray(o)?[...o].sort():[];(l.length!==c.length||l.some((u,m)=>u!==c[m]))&&r.push(a)}else s!==o&&r.push(a)}return r}async getData(e){try{let t=this.constructor,r=t.getModelMetadata(),a=`
1391
- SELECT id, predicate, out.uri AS target, author, timestamp
1392
- FROM link
1393
- WHERE in.uri = ${ce(this._baseExpression)}
1394
- ORDER BY timestamp ASC
1395
- `,s=await this._perspective.querySurrealDB(a);if(s&&s.length>0){let u=e?.properties&&e.properties.length>0?e.properties:void 0;await Cl(this,s,r,this._perspective,u)}let o=$t(t),l=e?.properties&&e.properties.length>0?new Set(e.properties):null;for(let[u,m]of Object.entries(o)){if(m.kind!=="belongsToOne"&&m.kind!=="belongsToMany"||l&&!l.has(u))continue;let d=(await this._perspective.get(new ae({predicate:m.predicate,target:this._baseExpression}))).filter(f=>f.data.target===this._baseExpression).map(f=>f.data.source);m.kind==="belongsToOne"?this[u]=d.length>0?d[d.length-1]:null:this[u]=d}let c=e?.properties||e?.include?{requestedProperties:e?.properties,include:e?.include}:void 0;await Ll(this,this._perspective,r,c),e?.include&&await bn(t,[this],this._perspective,e.include)}catch(t){console.error(`SurrealDB getData also failed for ${this._baseExpression}:`,t)}return this.takeSnapshot(),this}static async queryToProlog(e,t,r){let{properties:n,where:a,order:s,offset:o,limit:l,count:c}=t,u=r||await this.getClassName(e),m=t.parent?hn(t.parent,this):void 0,y=[Sl(),wl(t.parent,m),$g(n),_l(a)],d=[xl(c),El(s),$l(o),Al(l)];return`
1446
+ - valid schema.$id`)}function Xu(i,e,t,r,n){if(n.propertyMapping?.[e])return n.propertyMapping[e];if(t["x-ad4m"]?.through)return t["x-ad4m"].through;if(n.predicateTemplate){let s=jl(r),[o,c]=s.includes("://")?s.split("://"):["",s],l=c||"";return n.predicateTemplate.replace("${namespace}",l).replace("${scheme}",o).replace("${ns}",l).replace("${title}",i.title||"").replace("${property}",e)}if(n.predicateGenerator)return n.predicateGenerator(i.title||"",e);let a=jl(r);return a.includes("://")?`${a}${e}`:`${a}://${e}`}function Jr(i,e,t,r,n){return t.propertyOptions?.[i]?.[r]!==void 0?t.propertyOptions[i][r]:e["x-ad4m"]?.[r]!==void 0?e["x-ad4m"][r]:t[r]!==void 0?t[r]:n}function Wg(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 Kg(i,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 r=Ju(e,t),n=class extends i{};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={},s={};if(e.properties)for(let[c,l]of Object.entries(e.properties)){let u=Xu(e,c,l,r,t),m=e.required?.includes(c)||!1,y=Ho(l.type);if(Zu(l)){s[c]={through:u,local:Jr(c,l,t,"local")},Object.defineProperty(n.prototype,c,{configurable:!0,writable:!0,value:[]});let f=`add${He(c)}`,h=`remove${He(c)}`,S=`set${He(c)}`;n.prototype[f]=function(){},n.prototype[h]=function(){},n.prototype[S]=function(){}}else{let f=Jr(c,l,t,"resolveLanguage");!f&&t.resolveLanguage&&(f=t.resolveLanguage);let h=Jr(c,l,t,"local"),S=Jr(c,l,t,"readOnly");if(S===void 0){let k=l["x-ad4m"]?.writable;S=k!==void 0?!k:!1}let x=!S,T=Jr(c,l,t,"initial");if(ql(l)&&!f&&(f="literal",console.warn(`Property "${c}" is an object type. It will be stored as JSON. Consider flattening complex objects for better semantic querying.`)),f==null&&Vg(l)&&(f="literal"),f==null&&(f="literal"),m&&!T&&(ql(l)?T="literal:json:{}":T="ad4m://undefined"),a[c]={through:u,required:m,writable:x,...f&&{resolveLanguage:f},...h!==void 0&&{local:h},...T&&{initial:T}},Object.defineProperty(n.prototype,c,{configurable:!0,writable:!0,value:Wg(y)}),x){let k=os(c);n.prototype[k]=function(){}}}}for(let[c,l]of Object.entries(a))xp(n,c,l);for(let[c,l]of Object.entries(s))$p(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,Ep({name:t.name})(n),n}function Qg(i){return!(i.flag||i.resolveLanguage&&i.resolveLanguage!=="literal")}function Gg(i){return i.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}function $v(i){return typeof i=="string"?`"${Gg(i)}"`:`"${String(i)}"`}function ce(i){return`<${i}>`}function Zg(i,e,t,r){let n=[],a=[];if(t.parent){let m=_n(t.parent,r);n.push(`
1447
+ ${ce(t.parent.id)} ${ce(m)} ?source .`)}let s=!1;for(let[,m]of Object.entries(i.properties))if(m.required){if(m.getter)continue;s=!0,m.flag&&m.initial?n.push(`
1448
+ ?source ${ce(m.predicate)} ${ce(m.initial)} .`):n.push(`
1449
+ ?source ${ce(m.predicate)} ?cfTarget_${m.name} .`)}if(!s){for(let[,m]of Object.entries(i.properties))if(m.initial){s=!0,m.flag?n.push(`
1450
+ ?source ${ce(m.predicate)} ${ce(m.initial)} .`):n.push(`
1451
+ ?source ${ce(m.predicate)} ?cfInitTarget_${m.name} .`);break}}if(!s&&n.length===0){let m=[];for(let[,y]of Object.entries(i.properties))y.predicate&&m.push(ce(y.predicate));if(i.relations)for(let[,y]of Object.entries(i.relations))y.predicate&&m.push(ce(y.predicate));m.length>0&&n.push(`
1452
+ { SELECT DISTINCT ?source WHERE { ?source ?cf_structPred ?cf_structTarget . FILTER(?cf_structPred IN (${m.join(", ")})) } }`)}let{joins:o,filters:c}=Yg(i,e,t.where);n.push(...o),a.push(...c);let l=n.join(`
1453
+ `),u=a.length>0?`FILTER(
1454
+ ${a.join(` &&
1455
+ `)}
1456
+ )`:"";return`
1457
+ SELECT ?source ?predicate ?target ?author ?timestamp WHERE {${l}
1458
+ GRAPH ?linkGraph { ?source ?predicate ?target . }
1459
+ FILTER(isIRI(?source) && isIRI(?predicate))
1460
+ ?linkGraph <ad4m://ontology/author> ?author .
1461
+ ?linkGraph <ad4m://ontology/timestamp> ?timestamp .
1462
+ ${u}
1463
+ }
1464
+ ${Jg()}
1465
+ `.trim()}function Jg(i,e){return""}function Xg(i){return`
1466
+ SELECT ?source ?predicate ?target ?author ?timestamp WHERE {
1467
+ GRAPH ?linkGraph { ${ce(i)} ?predicate ?target . }
1468
+ FILTER(isIRI(?predicate))
1469
+ BIND(${ce(i)} AS ?source)
1470
+ ?linkGraph <ad4m://ontology/author> ?author .
1471
+ ?linkGraph <ad4m://ontology/timestamp> ?timestamp .
1472
+ }
1473
+ `.trim()}function xn(i){let e=new Map;for(let t of i){let r=t.source;e.has(r)||e.set(r,[]),e.get(r).push({predicate:t.predicate,target:t.target,author:t.author,timestamp:t.timestamp})}return Array.from(e.entries()).map(([t,r])=>({source_uri:t,links:r}))}function Yg(i,e,t){if(!t)return{joins:[],filters:[]};let r=[],n=[];for(let[a,s]of Object.entries(t)){if(a==="base"||a==="id"){if(Array.isArray(s)){let u=s.map(m=>ce(m)).join(", ");n.push(`?source IN (${u})`)}else if(typeof s=="object"&&s!==null){let u=s;if(u.not!==void 0)if(Array.isArray(u.not)){let m=u.not.map(y=>ce(y)).join(", ");n.push(`!(?source IN (${m}))`)}else n.push(`?source != ${ce(u.not)}`)}else n.push(`?source = ${ce(String(s))}`);continue}if(a==="author"||a==="timestamp")continue;let o=i.properties[a];if(!o)continue;let c=e[a];if(c&&(c.kind==="belongsToOne"||c.kind==="belongsToMany"))continue;if(Qg(o))if(typeof s=="object"&&s!==null&&!Array.isArray(s)){let u=s;(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)&&r.push(`
1474
+ ?source ${ce(o.predicate)} ?wTarget_cmp_${a} .`)}else r.push(`
1475
+ ?source ${ce(o.predicate)} ?wTarget_${a} .`);else if(Array.isArray(s)){let u=s.map(m=>ce(m)).join(", ");r.push(`
1476
+ ?source ${ce(o.predicate)} ?wTarget_${a} .`),n.push(`?wTarget_${a} IN (${u})`)}else if(typeof s=="object"&&s!==null){let u=s;if(u.not!==void 0)if(Array.isArray(u.not)){let y=u.not.map(d=>ce(d)).join(", ");n.push(`
1477
+ NOT EXISTS {
1478
+ ?source ${ce(o.predicate)} ?wTarget_not_${a} .
1479
+ FILTER(?wTarget_not_${a} IN (${y}))
1480
+ }
1481
+ `)}else n.push(`
1482
+ NOT EXISTS {
1483
+ ?source ${ce(o.predicate)} ${ce(u.not)} .
1484
+ }
1485
+ `);(u.gt!==void 0||u.gte!==void 0||u.lt!==void 0||u.lte!==void 0||u.between!==void 0||u.contains!==void 0)&&r.push(`
1486
+ ?source ${ce(o.predicate)} ?wTarget_cmp_${a} .`)}else r.push(`
1487
+ ?source ${ce(o.predicate)} ${ce(String(s))} .`)}return{joins:r,filters:n}}var Xi=new Map;function em(i,e){return`${i}::${e}`}async function tm(i,e,t,r){let n=i.uuid||i.handle?.uuid||"",a=em(n,e),s=Xi.get(a),o={onResult:r,hydrate:t};if(s){s.callbacks.add(o),s.refCount++;let m;return s.latestHydrated!==void 0?m=s.latestHydrated:s.latestRaw!==void 0&&(m=await t(s.latestRaw)),{initialResult:m,dispose:()=>Bl(a,o)}}let c=await i.subscribeQuery(e),l={subscription:c,callbacks:new Set([o]),latestRaw:c.result,latestHydrated:void 0,hydrating:!1,refCount:1};Xi.set(a,l),c.onResult(async m=>{l.latestRaw=m,l.hydrating=!0;try{let y=l.callbacks.values().next().value;if(y){let d=await y.hydrate(m);l.latestHydrated=d;for(let f of l.callbacks)try{f.onResult(d)}catch{}}}finally{l.hydrating=!1}});let u=await t(c.result);return l.latestHydrated=u,{initialResult:u,dispose:()=>Bl(a,o)}}function Bl(i,e){let t=Xi.get(i);!t||(t.callbacks.delete(e),t.refCount--,t.refCount<=0&&(t.subscription?.dispose&&t.subscription.dispose(),Xi.delete(i)))}function Ev(){for(let i of Xi.values())i.subscription?.dispose&&i.subscription.dispose();Xi.clear()}function Av(){return Xi.size}var To=class{constructor(e,t,r){this.queryParams={},this.modelClassName=null,this.engineFlag="sparql",this.perspective=e,this.ctor=t,r&&(this.queryParams=r)}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,r){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 s=e.constructor;return this.queryParams.parent={id:n,model:s,field:t.field},this}let a=r?.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),r=await this.perspective.infer(t);({results:e}=await this.ctor.instancesFromPrologResult(this.perspective,this.queryParams,r))}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:r}=await this.processSparqlResult(t);return r}async processSparqlResult(e,t){let r=xn(Array.isArray(e)?e:[]);return await this.ctor.instancesFromQueryResult(this.perspective,t||this.queryParams,r)}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 r=await t.queryToSPARQL(this.perspective,this.queryParams),n=null,a=l=>{if(l.length===0)return"0:";let u=l.map(y=>y.id||"").sort().join(","),m=l.map(y=>y.updatedAt||y.timestamp||"").join(",");return`${l.length}:${u}:${m}`},s=async l=>{let{results:u}=await this.processSparqlResult(l);return u},o=await tm(this.perspective,r,s,l=>{let u=a(l);u!==n&&(n=u,e(l))});this.currentSubscription={dispose:o.dispose};let c=o.initialResult;return n=a(c),c}else{let r=await t.queryToProlog(this.perspective,this.queryParams,this.modelClassName);this.currentSubscription=await this.perspective.subscribeInfer(r);let n=async s=>{let{results:o}=await t.instancesFromPrologResult(this.perspective,this.queryParams,s);e(o)};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 r=async a=>{let{results:s}=await this.processSparqlResult(a);e(s)};this.currentSubscription.onResult(r);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:r}=await this.processSparqlResult(t);return r}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 r=async a=>{let{totalCount:s}=await this.processSparqlResult(a);e(s)};this.currentSubscription.onResult(r);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 r=async a=>{let s=a?.[0]?.TotalCount||0;e(s)};return this.currentSubscription.onResult(r),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 r=async a=>{let{totalCount:s}=await this.processSparqlResult(a);e(s)};this.currentSubscription.onResult(r);let{totalCount:n}=await this.processSparqlResult(this.currentSubscription.result);return n}async paginate(e,t){let r={...this.queryParams||{},limit:e,offset:e*(t-1),count:!0};if(this.engineFlag==="sparql"){let n=await this.ctor.queryToSPARQL(this.perspective,r),a=await this.perspective.querySparql(n),{results:s,totalCount:o}=await this.processSparqlResult(a,r);return{results:s,totalCount:o,pageSize:e,pageNumber:t}}else{let n=await this.ctor.queryToProlog(this.perspective,r,this.modelClassName),a=await this.perspective.infer(n),{results:s,totalCount:o}=await this.ctor.instancesFromPrologResult(this.perspective,r,a);return{results:s,totalCount:o,pageSize:e,pageNumber:t}}}async paginateSparql(e,t){let r=this.engineFlag;this.engineFlag="sparql";try{return await this.paginate(e,t)}finally{this.engineFlag=r}}async paginateSubscribe(e,t,r){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 s=async u=>{let{results:m,totalCount:y}=await this.processSparqlResult(u,n);r({results:m,totalCount:y,pageSize:e,pageNumber:t})};this.currentSubscription.onResult(s);let{results:o,totalCount:c}=await this.processSparqlResult(this.currentSubscription.result,n);return{results:o,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 s=async u=>{let{results:m,totalCount:y}=await this.ctor.instancesFromPrologResult(this.perspective,this.queryParams,u);r({results:m,totalCount:y,pageSize:e,pageNumber:t})};this.currentSubscription.onResult(s);let{results:o,totalCount:c}=await this.ctor.instancesFromPrologResult(this.perspective,n,this.currentSubscription.result);return{results:o,totalCount:c,pageSize:e,pageNumber:t}}}async paginateSubscribeSparql(e,t,r){let n=this.engineFlag;this.engineFlag="sparql";try{return await this.paginateSubscribe(e,t,r)}finally{this.engineFlag=n}}};function wa(i){return Array.isArray(i)?i.map(e=>e&&typeof e=="object"&&typeof e.id=="string"?e.id:e):i}function to(i,e){if(Array.isArray(e))return e.includes(i);if(typeof e=="object"&&e!==null){let t=e;if(t.not!==void 0)return Array.isArray(t.not)?!t.not.includes(i):i!==t.not;if(t.between!==void 0&&Array.isArray(t.between)&&t.between.length===2)return i>=t.between[0]&&i<=t.between[1];let r=!0;return t.gt!==void 0&&(r=r&&i>t.gt),t.gte!==void 0&&(r=r&&i>=t.gte),t.lt!==void 0&&(r=r&&i<t.lt),t.lte!==void 0&&(r=r&&i<=t.lte),t.contains!==void 0&&(typeof i=="string"?r=r&&i.includes(String(t.contains)):Array.isArray(i)?r=r&&i.includes(t.contains):r=!1),r}return i===e}async function im(i,e,t,r){let n=i;if(i!=null&&i!=="")if(e.resolveLanguage!=null&&e.resolveLanguage!=="literal"&&typeof i=="string"&&!i.startsWith("literal:"))try{let a=await t.getExpression(i);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 i=="string"&&i.startsWith("literal:"))try{let a=le.fromUrl(i).get();n=a.data!==void 0?a.data:a}catch{}else typeof i=="string"&&r&&(r==="number"?n=Number(i):r==="boolean"&&(n=i==="true"||i==="1"));return e.transform&&typeof e.transform=="function"&&(n=e.transform(n)),n}async function Hl(i,e,t,r,n){if(!e||e.length===0)return;let a=null,s=null,o=null,c=n&&n.length>0?new Set(n):null,l=new Map;for(let[f,h]of Object.entries(t.properties))h.getter||c&&!c.has(f)||l.set(h.predicate,[f,h]);let u=new Map,m=[];for(let[f,h]of Object.entries(t.relations))if(!h.getter){if(h.target&&h.filter!==!1){m.push([f,h]);continue}u.set(h.predicate,[f,h])}for(let[f,h]of m)u.has(h.predicate)||u.set(h.predicate,[f,h]);let y=new Map,d=new Map;for(let f=0;f<e.length;f++){let h=e[f],{predicate:S,target:x,author:T,timestamp:k}=h;if(x==="None"||x===void 0||x===null)continue;k!=null&&((a==null||k<a)&&(a=k,o=T??null),(s==null||k>s)&&(s=k));let _=l.get(S);if(_){y.get(_[0]),y.set(_[0],{target:x,timestamp:k});continue}let L=u.get(S);if(L){let[D]=L,P=d.get(D);P||(P=[],d.set(D,P)),P.push({target:x,timestamp:k??"",index:f})}}for(let[f,{target:h}]of y){let[,S]=l.get(t.properties[f].predicate),x=typeof i[f];i[f]=await im(h,S,r,x!=="undefined"?x:void 0)}for(let[f,h]of d)h.sort((S,x)=>{let T=String(S.timestamp).localeCompare(String(x.timestamp));return T!==0?T:S.index-x.index}),i[f]=h.map(S=>S.target).filter(S=>S!=null&&S!==""&&S!=="None");o&&(i.author=o),a!=null&&(i.createdAt=typeof a=="string"&&a.includes("T")?new Date(a).getTime():typeof a=="string"?isNaN(parseInt(a,10))?a:parseInt(a,10):a),s!=null&&(i.updatedAt=typeof s=="string"&&s.includes("T")?new Date(s).getTime():typeof s=="string"?isNaN(parseInt(s,10))?s:parseInt(s,10):s)}async function rm(i,e,t){let r=Object.fromEntries(await Promise.all(t.map(async([a,s,o])=>{let c=s;if(!o&&typeof s=="string"){let m=Array.from(s,f=>f.codePointAt(0)),y=m.every(f=>f<=255),d=m.some(f=>f>=128);if(y&&d)try{let f=Uint8Array.from(m),h=new TextDecoder("utf-8",{fatal:!0}).decode(f);h!==s&&(c=h)}catch(f){console.warn(`UTF-8 byte reconstruction failed for property "${a}"`,{value:s,error:f})}}if(o){let m=await i.getExpression(s);if(m)try{c=JSON.parse(m.data)}catch{c=m.data}}let u=Ki(e.constructor)[a]?.transform;return u&&typeof u=="function"&&(c=u(c)),[a,c]}))),n=Object.fromEntries(Object.entries(r).filter(([a])=>{let s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),a);return s?s.get!==void 0||s.set!==void 0?s.set!==void 0:s.writable!==!1:!0}));Object.assign(e,n)}function nm(i,e){let t=cu(i,e);if(!t){let r=e?.prototype?.className||e?.name||"unknown";console.warn(`[Ad4mModel] buildConformanceGetter: no conditions found for target "${r}".`);return}return t.getter}async function zl(i,e,t,r){`${i.id}`;let a=r?.requestedProperties&&r.requestedProperties.length>0?new Set(r.requestedProperties):null;for(let[s,o]of Object.entries(t.properties))if(!(a&&!a.has(s))&&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}>`),u=l.trim().toUpperCase();if(u.startsWith("SELECT")||u.startsWith("ASK")||u.startsWith("CONSTRUCT")){let m=await e.querySparql(l);if(u.startsWith("ASK"))i[s]=m===!0||m==="true";else if(m&&m.length>0){let y=m[0],d=Object.keys(y)[0],f=y[d]?.value??y[d];f!=null&&f!=="None"&&f!==""&&(i[s]=f)}}else console.warn(`Unsupported legacy getter syntax for property ${s} \u2014 use native SPARQL (SELECT/ASK): ${c.slice(0,100)}`)}catch(c){console.warn(`Failed to evaluate getter for ${s}:`,c)}for(let[s,o]of Object.entries(t.relations)){if(a&&!a.has(s)&&!(r?.include&&s in r.include))continue;let c=o,l=c.getter;if(!l&&c.where&&c.direction!=="reverse")try{let m=c.target?.(),y=m?m.getModelMetadata?.()??null:null,d=!0;if(y)for(let f of Object.keys(c.where)){if(["id","author","timestamp"].includes(f))continue;let h=y.properties[f];if(h&&(!h.resolveLanguage||h.resolveLanguage==="literal")){d=!1;break}}else d=!1;if(d){let f=ou(c.where,y);f.length>0&&(l=`SELECT ?target WHERE { <Base> <${Mt(c.predicate)}> ?target . ${f.join(" ")} }`)}}catch(m){console.warn(`[Ad4mModel] where-clause compilation failed for relation "${s}":`,m)}if(!l&&c.target&&c.filter!==!1&&c.direction!=="reverse")try{let m=c.target();l=nm(c.predicate,m),l||console.warn(`[Ad4mModel] buildConformanceGetter returned undefined for relation "${s}" (predicate: "${c.predicate}")`)}catch(m){console.warn(`[Ad4mModel] auto-generation failed for relation "${s}":`,m)}if(l)try{let m=l.replace(/\?source\b/g,`<${i.id}>`).replace(/<Base>/g,`<${i.id}>`).replace(/\bBase\b/g,`<${i.id}>`),y=m.trim().toUpperCase();if(y.startsWith("SELECT")||y.startsWith("ASK")||y.startsWith("CONSTRUCT")){let d=await e.querySparql(m);if(d&&d.length>0){let f=d.map(h=>{let S=Object.keys(h)[0];return h[S]?.value??h[S]}).filter(h=>h!=null&&h!==""&&h!=="None");i[s]=f}}else console.warn(`Unsupported legacy getter syntax for relation ${s} \u2014 use native SPARQL (SELECT/ASK): ${l.slice(0,100)}`)}catch(m){console.warn(`Failed to evaluate getter for ${s}:`,m)}let u=i[s];if(c.where&&Array.isArray(u)&&u.length>0){let m=c.target?.();if(m){let y=[];for(let d of u)try{let f=new m(e,d);await f.get();let h=!0;for(let[S,x]of Object.entries(c.where))if(f[S]!==x){h=!1;break}h&&y.push(d)}catch{y.push(d)}i[s]=y}}}}async function In(i,e,t,r){if(!r||Object.keys(r).length===0)return;let n=St(i);for(let[a,s]of Object.entries(r)){let o=n[a];if(!o){console.warn(`include: relation "${a}" not found in metadata, skipping`);continue}let c=o.target(),l=typeof s=="object"&&s!==null?s:void 0,u=l?.include;if(o.kind==="belongsToOne"||o.kind==="belongsToMany"){for(let x of e){let k=(await t.get(new B({predicate:o.predicate,target:x.id}))).filter(_=>_.data.target===x.id).map(_=>_.data.source);if(o.kind==="belongsToOne"){if(k.length===0){x[a]=null;continue}let _=k[k.length-1];try{let L=new c(t,_);await L.get(),x[a]=L}catch{x[a]=null}}else{let _=[];if(l&&(l.where||l.order||l.properties)){let L={id:k,...l.where??{}};_=await c.findAll(t,{where:L,...l.order&&{order:l.order},...l.properties&&{properties:l.properties}})}else await Promise.all(k.map(async L=>{try{let D=new c(t,L);await D.get(l?.properties?{properties:l.properties}:void 0),_.push(D)}catch{}}));if(l?.order&&!(l.where||l.properties)){let L=Object.entries(l.order);_=_.sort((D,P)=>{for(let[W,K]of L){let R=String(D[W]??""),G=String(P[W]??""),We=R.localeCompare(G);if(We!==0)return K==="DESC"?-We:We}return 0})}if(l?.offset!=null||l?.limit!=null){let L=l.offset??0,D=l.limit!=null?L+l.limit:void 0;_=_.slice(L,D)}x[a]=_,u&&_.length>0&&await In(c,_,t,u)}}continue}let m=new Set,y=new Map;for(let x of e){let T=x[a];if(y.set(x,Array.isArray(T)?[...T]:T),T!=null)if(Array.isArray(T))for(let k of T)typeof k=="string"?m.add(k):k&&typeof k=="object"&&typeof k.id=="string"&&m.add(k.id);else typeof T=="string"?m.add(T):T&&typeof T=="object"&&typeof T.id=="string"&&m.add(T.id)}if(m.size===0)continue;let d=new Map,h={where:{id:Array.from(m),...l?.where??{}},...l?.order&&{order:l.order},...l?.properties&&{properties:l.properties}},S=await c.findAll(t,h);for(let x of S)d.set(x.id,x);for(let x of e){let T=y.get(x);if(T!=null)if(Array.isArray(T)){let k=T.map(_=>typeof _=="string"?d.has(_)?d.get(_):null:_&&typeof _=="object"&&typeof _.id=="string"?d.has(_.id)?d.get(_.id):_:null).filter(_=>_!==null);if(l?.order){let _=Object.entries(l.order);k=k.sort((L,D)=>{for(let[P,W]of _){let K=String(L[P]??""),R=String(D[P]??""),G=K.localeCompare(R);if(G!==0)return W==="DESC"?-G:G}return 0})}if(l?.offset!=null||l?.limit!=null){let _=l.offset??0,L=l.limit!=null?_+l.limit:void 0;k=k.slice(_,L)}o.maxCount===1?(k.length>1&&console.warn(`include: relation "${a}" has maxCount 1 but ${k.length} values found; keeping the last`),x[a]=k.length>0?k[k.length-1]:null):x[a]=k}else typeof T=="string"&&d.has(T)?x[a]=d.get(T):T&&typeof T=="object"&&typeof T.id=="string"&&(x[a]=d.has(T.id)?d.get(T.id):T)}if(u){let x=Array.from(d.values());await In(c,x,t,u)}}}var Lr=class{static generateSDNA(){return{sdna:"",name:""}}static generateSHACL(){return{shape:null,name:""}}static async getClassName(e){if(this===Lr)return await e.stringOrTemplateObjectToSubjectClassName(this);let r=this.classNamesByClass.get(this);r||(r={},this.classNamesByClass.set(this,r));let n=e.uuid;return r[n]||(r[n]=await e.stringOrTemplateObjectToSubjectClassName(this)),r[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,r={},n=Ki(this);for(let[m,y]of Object.entries(n)){let d=y;r[m]={name:m,predicate:d.through||"",required:d.required||!1,readOnly:!(d.writable??!1),...d.initial!==void 0&&{initial:d.initial},...d.resolveLanguage!==void 0&&{resolveLanguage:d.resolveLanguage},...d.prologGetter!==void 0&&{prologGetter:d.prologGetter},...d.getter!==void 0&&{getter:d.getter},...d.prologSetter!==void 0&&{prologSetter:d.prologSetter},...d.local!==void 0&&{local:d.local},...d.transform!==void 0&&{transform:d.transform},...d.flag!==void 0&&{flag:d.flag}}}let a={},s=St(this),o=Object.fromEntries(Object.entries(s).filter(([,m])=>m.kind==="hasMany"||m.kind==="belongsToMany"));for(let[m,y]of Object.entries(o)){let d=y;a[m]={name:m,predicate:d.predicate||"",...d.local!==void 0&&{local:d.local},...d.getter!==void 0&&{getter:d.getter},direction:d.kind==="belongsToMany"||d.kind==="belongsToOne"?"reverse":"forward",...d.target!==void 0&&{target:d.target},...d.filter!==void 0&&{filter:d.filter},...d.where!==void 0&&{where:d.where}}}let c=Object.keys(r).length>0,l=Object.keys(a).length>0;if(!(c||l)&&e.__jsonSchema){let m=e.__jsonSchema,y=e.__jsonSchemaOptions||{};if(m.properties)for(let[d,f]of Object.entries(m.properties)){let h=Zu(f),S=Xu(m,d,f,Ju(m,y),y);if(h)a[d]={name:d,predicate:S,...f["x-ad4m"]?.local!==void 0&&{local:f["x-ad4m"].local}};else{let x=m.required?.includes(d)||!1;r[d]={name:d,predicate:S,required:x,readOnly:f["x-ad4m"]?.writable===!1,...f["x-ad4m"]?.resolveLanguage&&{resolveLanguage:f["x-ad4m"].resolveLanguage},...f["x-ad4m"]?.initial&&{initial:f["x-ad4m"].initial},...f["x-ad4m"]?.local!==void 0&&{local:f["x-ad4m"].local}}}}}return{className:t,properties:r,relations:a}}constructor(e,t){this._snapshot=null,this._baseExpression=t||le.from(au(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 Ki(t)[e]}getRelationOptions(e){let t=this.constructor;return St(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 r=this.getRelationOptions(e);if(!r)throw new Error(`Relation "${e}" has no metadata defined`);if(!r.predicate)throw new Error(`Relation "${e}" has no predicate defined`);return[{action:{adder:"addLink",remover:"removeLink",setter:"collectionSetter"}[t],source:"this",predicate:r.predicate,target:"value",...r.local&&{local:!0}}]}static async assignValuesToInstance(e,t,r){return rm(e,t,r)}takeSnapshot(e){let r=this.constructor.getModelMetadata(),n={};for(let a of Object.keys(r.properties)){let s=this[a];n[a]=wa(Array.isArray(s)?[...s]:s)}if(e===void 0)for(let a of Object.keys(r.relations)){let s=this[a];n[a]=wa(Array.isArray(s)?[...s]:s)}else if(e&&Object.keys(e).length>0){for(let a of Object.keys(e))if(a in r.relations){let s=this[a];n[a]=wa(Array.isArray(s)?[...s]:s)}}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 r=[],n=[...Object.keys(t.properties),...Object.keys(t.relations)];for(let a of n){if(!(a in this._snapshot))continue;let s=wa(this[a]),o=this._snapshot[a];if(Array.isArray(s)||Array.isArray(o)){let c=Array.isArray(s)?[...s].sort():[],l=Array.isArray(o)?[...o].sort():[];(c.length!==l.length||c.some((u,m)=>u!==l[m]))&&r.push(a)}else s!==o&&r.push(a)}return r}async getData(e){try{let t=this.constructor,r=t.getModelMetadata(),n=Xg(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 Hl(this,a,r,this._perspective,l)}let s=St(t),o=e?.properties&&e.properties.length>0?new Set(e.properties):null;for(let[l,u]of Object.entries(s)){if(u.kind!=="belongsToOne"&&u.kind!=="belongsToMany"||o&&!o.has(l))continue;let y=(await this._perspective.get(new B({predicate:u.predicate,target:this._baseExpression}))).filter(d=>d.data.target===this._baseExpression).map(d=>d.data.source);u.kind==="belongsToOne"?this[l]=y.length>0?y[y.length-1]:null:this[l]=y}let c=e?.properties||e?.include?{requestedProperties:e?.properties,include:e?.include}:void 0;await zl(this,this._perspective,r,c),e?.include&&await In(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,r){let{properties:n,where:a,order:s,offset:o,limit:c,count:l}=t,u=r||await this.getClassName(e),m=t.parent?_n(t.parent,this):void 0,y=[Nl(),Rl(t.parent,m),zg(n),Ol(a)],d=[Ul(l),Dl(s),Ml(o),Fl(c)];return`
1396
1488
  findall([Base, Properties, Collections, Timestamp, Author], (
1397
1489
  subject_class("${u}", SubjectClass),
1398
1490
  instance(SubjectClass, Base),
1399
- ${y.filter(g=>g).join(", ")}
1491
+ ${y.filter(h=>h).join(", ")}
1400
1492
  ), UnsortedInstances),
1401
- ${d.filter(g=>g).join(", ")}
1402
- `}static async queryToSurrealQL(e,t){let r=this.getModelMetadata(),n=$t(this);return Cg(r,n,t,this)}static async instancesFromPrologResult(e,t,r){if(!r?.[0]?.AllInstances)return{results:[],totalCount:0};let n=t?.properties||[],s=(await Promise.all(r[0].AllInstances.map(async([l,c,u,m,y])=>{try{let d=new this(e,l);n.length&&Object.keys(d).forEach(g=>{!n.includes(g)&&g!=="createdAt"&&g!=="updatedAt"&&g!=="author"&&g!=="id"&&g!=="baseExpression"&&delete d[g]});let f=[...c,...u,["createdAt",m],["author",y]];return await $r.assignValuesToInstance(e,d,f),d}catch(d){return console.error(`Failed to process instance ${l}:`,d),null}}))).filter(l=>l!==null);t.include&&s.length>0&&await bn(this,s,e,t.include);let o=t.include;for(let l of s)l.takeSnapshot(o);return{results:s,totalCount:r[0].TotalCount}}static async instancesFromSurrealResult(e,t,r){if(!r||r.length===0)return{results:[],totalCount:0};let n=this.getModelMetadata(),a=t?.properties||[],s=[];for(let g of r){let _;try{if(_=g.source_uri,!_)continue;let E=g.links||[],A=new this(e,_);if(await Cl(A,E,n,e,a.length>0?a:void 0),a.length>0){let k=new Set(a);for(let w of Object.keys(n.properties))k.has(w)||delete A[w];for(let w of Object.keys(n.relations))!k.has(w)&&!(t.include&&w in t.include)&&delete A[w];for(let w of["author","createdAt","updatedAt"])k.has(w)||delete A[w]}s.push(A)}catch(E){console.error(`Failed to process SurrealDB instance ${_}:`,E)}}let o=$t(this),l=Object.entries(o).filter(([g,_])=>(_.kind==="belongsToOne"||_.kind==="belongsToMany")&&(a.length===0||a.includes(g)));l.length>0&&s.length>0&&await Promise.all(s.map(async g=>{for(let[_,E]of l){let k=(await e.get(new ae({predicate:E.predicate,target:g.id}))).filter(w=>w.data.target===g.id).map(w=>w.data.source);E.kind==="belongsToOne"?g[_]=k.length>0?k[k.length-1]:null:g[_]=k}}));let c=a.length>0||t.include?{requestedProperties:a,include:t.include}:void 0;for(let g of s)await Ll(g,e,n,c);let u=s;t.where&&(u=s.filter(g=>{for(let[_,E]of Object.entries(t.where))if(_!=="base"){if(_==="author"||_==="timestamp"){if(!Tl(g[_],E))return!1;continue}if(typeof E=="object"&&E!==null&&!Array.isArray(E)){let A=E;if((A.gt!==void 0||A.gte!==void 0||A.lt!==void 0||A.lte!==void 0||A.between!==void 0||A.contains!==void 0)&&!Tl(g[_],E))return!1}}return!0}));let m=t.order||(t.limit!==void 0||t.offset!==void 0?{timestamp:"ASC"}:null);if(m){let g=Object.entries(m);u.sort((_,E)=>{for(let[A,k]of g){let w=_[A],C=E[A];if(w===void 0&&C===void 0)continue;if(w===void 0)return k==="ASC"?1:-1;if(C===void 0)return k==="ASC"?-1:1;let U=0;if(typeof w=="number"&&typeof C=="number"?U=w-C:typeof w=="string"&&typeof C=="string"?U=w.localeCompare(C):U=String(w).localeCompare(String(C)),U!==0)return k==="DESC"?-U:U}return 0})}let y=u.length,d=u;if(t.offset!==void 0||t.limit!==void 0){let g=t.offset||0,_=t.limit?g+t.limit:void 0;d=u.slice(g,_)}t.include&&d.length>0&&await bn(this,d,e,t.include);let f=t.include;for(let g of d)g.takeSnapshot(f);return{results:d,totalCount:y}}static async findAll(e,t={},r=!0){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(r){let n=await this.queryToSurrealQL(e,t),a=await e.querySurrealDB(n),{results:s}=await this.instancesFromSurrealResult(e,t,a);return s}else{let n=await this.queryToProlog(e,t),a=await e.infer(n),{results:s}=await this.instancesFromPrologResult(e,t,a);return s}}static async findOne(e,t={},r=!0){let n={...t,limit:1};return(await this.findAll(e,n,r))[0]??null}static async findAllAndCount(e,t={},r=!0){if(r){let n=await this.queryToSurrealQL(e,t),a=await e.querySurrealDB(n);return await this.instancesFromSurrealResult(e,t,a)}else{let n=await this.queryToProlog(e,t),a=await e.infer(n);return await this.instancesFromPrologResult(e,t,a)}}static async paginate(e,t,r,n,a=!0){let s={...n||{},limit:t,offset:t*(r-1),count:!0};if(a){let o=await this.queryToSurrealQL(e,s),l=await e.querySurrealDB(o),{results:c,totalCount:u}=await this.instancesFromSurrealResult(e,s,l);return{results:c,totalCount:u,pageSize:t,pageNumber:r}}else{let o=await this.queryToProlog(e,s),l=await e.infer(o),{results:c,totalCount:u}=await this.instancesFromPrologResult(e,s,l);return{results:c,totalCount:u,pageSize:t,pageNumber:r}}}static async countQueryToProlog(e,t={},r){let{where:n}=t,a=r||await this.getClassName(e),s=t.parent?hn(t.parent,this):void 0,o=[Sl(),wl(t.parent,s),_l(n)],l=[xl(!0),El(),$l(),Al()];return`
1493
+ ${d.filter(h=>h).join(", ")}
1494
+ `}static async queryToSPARQL(e,t){let r=this.getModelMetadata(),n=St(this);return Zg(r,n,t,this)}static async instancesFromPrologResult(e,t,r){if(!r?.[0]?.AllInstances)return{results:[],totalCount:0};let n=t?.properties||[],s=(await Promise.all(r[0].AllInstances.map(async([c,l,u,m,y])=>{try{let d=new this(e,c);n.length&&Object.keys(d).forEach(h=>{!n.includes(h)&&h!=="createdAt"&&h!=="updatedAt"&&h!=="author"&&h!=="id"&&h!=="baseExpression"&&delete d[h]});let f=[...l,...u,["createdAt",m],["author",y]];return await Lr.assignValuesToInstance(e,d,f),d}catch(d){return console.error(`Failed to process instance ${c}:`,d),null}}))).filter(c=>c!==null);t.include&&s.length>0&&await In(this,s,e,t.include);let o=t.include;for(let c of s)c.takeSnapshot(o);return{results:s,totalCount:r[0].TotalCount}}static async instancesFromQueryResult(e,t,r){if(!r||r.length===0)return{results:[],totalCount:0};let n=this.getModelMetadata(),a=t?.properties||[],s=[];for(let h of r){let S;try{if(S=h.source_uri,!S)continue;let x=h.links||[],T=new this(e,S),k=a.length>0?[...a]:void 0;if(k&&t.where)for(let _ of Object.keys(t.where))k.includes(_)||k.push(_);await Hl(T,x,n,e,k),s.push(T)}catch(x){console.error(`Failed to process SPARQL instance ${S}:`,x)}}let o=St(this),c=Object.entries(o).filter(([h,S])=>(S.kind==="belongsToOne"||S.kind==="belongsToMany")&&(a.length===0||a.includes(h)));c.length>0&&s.length>0&&await Promise.all(s.map(async h=>{for(let[S,x]of c){let k=(await e.get(new B({predicate:x.predicate,target:h.id}))).filter(_=>_.data.target===h.id).map(_=>_.data.source);x.kind==="belongsToOne"?h[S]=k.length>0?k[k.length-1]:null:h[S]=k}}));let l=a.length>0||t.include?{requestedProperties:a,include:t.include}:void 0;for(let h of s)await zl(h,e,n,l);let u=s;t.where&&(u=s.filter(h=>{for(let[S,x]of Object.entries(t.where)){if(S==="base"||S==="id")continue;if(S==="author"||S==="timestamp"){if(!to(h[S],x))return!1;continue}if(!(S in n.properties)){if(!to(h[S],x))return!1;continue}if(!to(h[S],x))return!1}return!0}));let m=t.order||(t.limit!==void 0||t.offset!==void 0?{timestamp:"ASC"}:null);if(m){let h=Object.entries(m);u.sort((S,x)=>{for(let[T,k]of h){let _=S[T],L=x[T];if(_===void 0&&L===void 0)continue;if(_===void 0)return k==="ASC"?1:-1;if(L===void 0)return k==="ASC"?-1:1;let D=0;if(typeof _=="number"&&typeof L=="number"?D=_-L:typeof _=="string"&&typeof L=="string"?D=_.localeCompare(L):D=String(_).localeCompare(String(L)),D!==0)return k==="DESC"?-D:D}return 0})}let y=u.length,d=u;if(t.offset!==void 0||t.limit!==void 0){let h=t.offset||0,S=t.limit?h+t.limit:void 0;d=u.slice(h,S)}if(a.length>0){let h=new Set(a);for(let S of d){for(let x of Object.keys(n.properties))h.has(x)||delete S[x];for(let x of Object.keys(n.relations))!h.has(x)&&!(t.include&&x in t.include)&&delete S[x];for(let x of["author","createdAt","updatedAt"])h.has(x)||delete S[x]}}t.include&&d.length>0&&await In(this,d,e,t.include);let f=t.include;for(let h of d)h.takeSnapshot(f);return{results:d,totalCount:y}}static async findAll(e,t={},r="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 r=="boolean"?r?"sparql":"prolog":r)==="sparql"){let a=await this.queryToSPARQL(e,t),s=await e.querySparql(a),o=xn(s),{results:c}=await this.instancesFromQueryResult(e,t,o);return c}else{let a=await this.queryToProlog(e,t),s=await e.infer(a),{results:o}=await this.instancesFromPrologResult(e,t,s);return o}}static async findOne(e,t={},r="sparql"){let n={...t,limit:1};return(await this.findAll(e,n,r))[0]??null}static async findAllAndCount(e,t={},r="sparql"){if((typeof r=="boolean"?r?"sparql":"prolog":r)==="sparql"){let a=await this.queryToSPARQL(e,t),s=await e.querySparql(a),o=xn(s);return await this.instancesFromQueryResult(e,t,o)}else{let a=await this.queryToProlog(e,t),s=await e.infer(a);return await this.instancesFromPrologResult(e,t,s)}}static async paginate(e,t,r,n,a="sparql"){let s={...n||{},limit:t,offset:t*(r-1),count:!0};if((typeof a=="boolean"?a?"sparql":"prolog":a)==="sparql"){let c=await this.queryToSPARQL(e,s),l=await e.querySparql(c),u=xn(l),{results:m,totalCount:y}=await this.instancesFromQueryResult(e,s,u);return{results:m,totalCount:y,pageSize:t,pageNumber:r}}else{let c=await this.queryToProlog(e,s),l=await e.infer(c),{results:u,totalCount:m}=await this.instancesFromPrologResult(e,s,l);return{results:u,totalCount:m,pageSize:t,pageNumber:r}}}static async countQueryToProlog(e,t={},r){let{where:n}=t,a=r||await this.getClassName(e),s=t.parent?_n(t.parent,this):void 0,o=[Nl(),Rl(t.parent,s),Ol(n)],c=[Ul(!0),Dl(),Ml(),Fl()];return`
1403
1495
  findall([Base, Properties, Collections, Timestamp, Author], (
1404
1496
  subject_class("${a}", SubjectClass),
1405
1497
  instance(SubjectClass, Base),
1406
1498
  ${o.filter(u=>u).join(", ")}
1407
1499
  ), UnsortedInstances),
1408
- ${l.filter(u=>u).join(", ")}
1409
- `}static async countQueryToSurrealQL(e,t){let r={...t};return delete r.limit,delete r.offset,await this.queryToSurrealQL(e,r)}static async count(e,t={},r=!0){if(r){let n=await this.queryToSurrealQL(e,t),a=await e.querySurrealDB(n),{totalCount:s}=await this.instancesFromSurrealResult(e,t,a);return s}else return(await e.infer(await this.countQueryToProlog(e,t)))?.[0]?.TotalCount||0}async setProperty(e,t,r){let n=this.getPropertyMetadata(e);if(!n){console.warn(`Property "${e}" has no metadata, skipping`);return}let a=this.generatePropertySetterAction(e,n),s=n.resolveLanguage;t==null||t===""||(s&&(t=await this._perspective.createExpression(t,s)),await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:t}],r))}resolveRelationId(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.id=="string"?e.id:String(e)}async setRelationValues(e,t,r){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(s=>({name:"value",value:this.resolveRelationId(s)})),r):await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(t)}],r))}async addRelationValue(e,t,r){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(s=>this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(s)}],r))):await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(t)}],r))}async removeRelationValue(e,t,r){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(s=>this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(s)}],r))):await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(t)}],r))}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 r=this.constructor.getModelMetadata(),n=Object.values(r.properties).some(s=>s.required||s.flag||s.initial!==void 0),a=[];if(n){let s={};for(let[l,c]of Object.entries(this))if(c!=null&&!(Array.isArray(c)&&c.length>0)&&!c?.action){let u=r.properties[l];if(u?.resolveLanguage&&u.resolveLanguage!=="literal"&&typeof c=="object"){a.push(l);continue}s[l]=c}let o=await this.perspective.stringOrTemplateObjectToSubjectClassName(this);await this.perspective.createSubject(o,this._baseExpression,s,e)}await this.innerUpdate(!n,e);for(let s of a){let o=this[s];o!=null&&await this.setProperty(s,o,e)}t?(await this.perspective.commitBatch(e),await this.getData()):this.takeSnapshot()}cleanCopy(){let t=this.constructor.getModelMetadata(),r={},n=new Set([...Object.keys(t.properties),...Object.keys(t.relations)]);for(let a of n){let s=this[a];s!=null&&a!=="author"&&a!=="timestamp"&&(r[a]=s)}return r}async innerUpdate(e=!0,t){let r=this.constructor,n=this._snapshot?new Set(this.changedFields()):null,a=r.getModelMetadata(),s=new Set([...Object.keys(a.properties),...Object.keys(a.relations)]),o=Object.entries(this);for(let[l,c]of o){if(!s.has(l)||n&&!n.has(l))continue;let u=a.relations[l];if(!(u&&(u.getter||u.target&&u.filter!==!1&&Object.entries(a.relations).some(([y,d])=>y!==l&&d.predicate===u.predicate)))&&c!=null){if(c?.action)switch(c.action){case"setter":await this.setRelationValues(l,c.value,t);break;case"adder":await this.addRelationValue(l,c.value,t);break;case"remover":await this.removeRelationValue(l,c.value,t);break;default:await this.setRelationValues(l,c.value,t);break}else if(Array.isArray(c))await this.setRelationValues(l,c,t);else if(c!=null&&c!==""&&e){if(this.getRelationOptions(l)||this.getPropertyMetadata(l)?.flag)continue;await this.setProperty(l,c,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 o of Object.values(t.properties))o.predicate&&n.add(o.predicate);for(let o of Object.values(t.relations))o.predicate&&n.add(o.predicate);let s=(await this._perspective.get(new ae({source:this._baseExpression}))).filter(o=>o.data.predicate&&n.has(o.data.predicate));s.length>0&&await this._perspective.removeLinks(s,e)}catch(n){console.warn(`delete(): failed to remove outgoing links for ${this._baseExpression}:`,n)}try{let n=await this._perspective.get(new ae({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={},r){let n=new this(e);if(Object.assign(n,t),r?.parent&&!r?.batchId){let a=await e.createBatch();await n.save(a);let s=hn(r.parent,this),o=new Je({source:r.parent.id,predicate:s,target:n.id});return await e.add(o,"shared",a),await e.commitBatch(a),await n.get(),n}if(await n.save(r?.batchId),r?.parent){let a=hn(r.parent,this),s=new Je({source:r.parent.id,predicate:a,target:n.id});await e.add(s,"shared",r?.batchId)}return n}static async update(e,t,r){let n=new this(e,t);return await n.get(),Object.assign(n,r),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 r=await e.createBatch(),n=await t({batchId:r});return await e.commitBatch(r),n}static query(e,t){return new bo(e,this,t)}static fromJSONSchema(e,t){return Ig(this,e,t)}};$r.classNamesByClass=new WeakMap;function No(i){return i.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"")}function Ng(i,e){let t=e.properties,r=Object.values(t).filter(s=>s.flag&&s.predicate&&s.initial);if(r.length>0){let s=r.map(o=>`triple(X, '${o.predicate}', '${o.initial}')`).join(`,
1500
+ ${c.filter(u=>u).join(", ")}
1501
+ `}static async countQueryToSPARQL(e,t){let r={...t};return delete r.limit,delete r.offset,await this.queryToSPARQL(e,r)}static async count(e,t={},r="sparql"){if((typeof r=="boolean"?r?"sparql":"prolog":r)==="sparql"){let a=await this.queryToSPARQL(e,t),s=await e.querySparql(a),o=xn(s),{totalCount:c}=await this.instancesFromQueryResult(e,t,o);return c}else return(await e.infer(await this.countQueryToProlog(e,t)))?.[0]?.TotalCount||0}async setProperty(e,t,r){let n=this.getPropertyMetadata(e);if(!n){console.warn(`Property "${e}" has no metadata, skipping`);return}let a=this.generatePropertySetterAction(e,n),s=n.resolveLanguage;t==null||t===""||(s&&(t=await this._perspective.createExpression(t,s)),await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:t}],r))}resolveRelationId(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.id=="string"?e.id:String(e)}async setRelationValues(e,t,r){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(s=>({name:"value",value:this.resolveRelationId(s)})),r):await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(t)}],r))}async addRelationValue(e,t,r){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(s=>this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(s)}],r))):await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(t)}],r))}async removeRelationValue(e,t,r){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(s=>this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(s)}],r))):await this._perspective.executeAction(a,this._baseExpression,[{name:"value",value:this.resolveRelationId(t)}],r))}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 r=this.constructor.getModelMetadata(),n=Object.values(r.properties).some(s=>s.required||s.flag||s.initial!==void 0),a=[];if(n){let s={};for(let[c,l]of Object.entries(this))if(l!=null&&!(Array.isArray(l)&&l.length>0)&&!l?.action){let u=r.properties[c];if(u?.resolveLanguage&&u.resolveLanguage!=="literal"&&typeof l=="object"){a.push(c);continue}s[c]=l}let o=await this.perspective.stringOrTemplateObjectToSubjectClassName(this);await this.perspective.createSubject(o,this._baseExpression,s,e)}await this.innerUpdate(!n,e);for(let s of a){let o=this[s];o!=null&&await this.setProperty(s,o,e)}t?(await this.perspective.commitBatch(e),await this.getData()):this.takeSnapshot()}cleanCopy(){let t=this.constructor.getModelMetadata(),r={},n=new Set([...Object.keys(t.properties),...Object.keys(t.relations)]);for(let a of n){let s=this[a];s!=null&&a!=="author"&&a!=="timestamp"&&(r[a]=s)}return r}async innerUpdate(e=!0,t){let r=this.constructor,n=this._snapshot?new Set(this.changedFields()):null,a=r.getModelMetadata(),s=new Set([...Object.keys(a.properties),...Object.keys(a.relations)]),o=Object.entries(this);for(let[c,l]of o){if(!s.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(([y,d])=>y!==c&&d.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 o of Object.values(t.properties))o.predicate&&n.add(o.predicate);for(let o of Object.values(t.relations))o.predicate&&n.add(o.predicate);let s=(await this._perspective.get(new B({source:this._baseExpression}))).filter(o=>o.data.predicate&&n.has(o.data.predicate));s.length>0&&await this._perspective.removeLinks(s,e)}catch(n){console.warn(`delete(): failed to remove outgoing links for ${this._baseExpression}:`,n)}try{let n=await this._perspective.get(new B({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={},r){let n=new this(e);if(Object.assign(n,t),r?.parent&&!r?.batchId){let a=await e.createBatch();await n.save(a);let s=_n(r.parent,this),o=new Xe({source:r.parent.id,predicate:s,target:n.id});return await e.add(o,"shared",a),await e.commitBatch(a),await n.get(),n}if(await n.save(r?.batchId),r?.parent){let a=_n(r.parent,this),s=new Xe({source:r.parent.id,predicate:a,target:n.id});await e.add(s,"shared",r?.batchId)}return n}static async update(e,t,r){let n=new this(e,t);return await n.get(),Object.assign(n,r),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 r=await e.createBatch(),n=await t({batchId:r});return await e.commitBatch(r),n}static query(e,t){return new To(e,this,t)}static fromJSONSchema(e,t){return Kg(this,e,t)}};Lr.classNamesByClass=new WeakMap;function zo(i){return i.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"")}function am(i,e){let t=e.properties,r=Object.values(t).filter(s=>s.flag&&s.predicate&&s.initial);if(r.length>0){let s=r.map(o=>`triple(X, '${o.predicate}', '${o.initial}')`).join(`,
1410
1502
  `);return`${i}(X) :-
1411
1503
  ${s}.`}let n=Object.values(t).filter(s=>s.required&&s.predicate&&!s.flag);if(n.length>0){let s=n.map(o=>`triple(X, '${o.predicate}', _)`).join(`,
1412
1504
  `);return`${i}(X) :-
1413
1505
  ${s}.`}let a=Object.values(t).filter(s=>s.predicate).map(s=>s.predicate);if(e.relations)for(let s of Object.values(e.relations))s.predicate&&a.push(s.predicate);if(a.length>0){let s=a.map(o=>`triple(X, '${o}', _)`).join(` ;
1414
1506
  `);return`${i}(X) :-
1415
- (${s}).`}return null}function Og(i,e){return e.flag||!e.predicate?null:`${`${i}_${No(e.name)}`}(X, Value) :- triple(X, '${e.predicate}', Value).`}function Dg(i,e){if(!e.predicate)return null;let t=`${i}_${No(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 Q0(i){let e=i.getModelMetadata(),t=No(e.className),r=[];r.push(`% ${e.className} \u2014 generated Prolog facts`);let n=Ng(t,e);n&&(r.push(""),r.push("% Instance recognizer"),r.push(n));let a=Object.values(e.properties).map(o=>Og(t,o)).filter(o=>o!==null);a.length>0&&(r.push(""),r.push("% Field getters"),r.push(...a));let s=Object.values(e.relations).map(o=>Dg(t,o)).filter(o=>o!==null);return s.length>0&&(r.push(""),r.push("% Relation getters"),r.push(...s)),r.join(`
1416
- `)}var G0=`
1507
+ (${s}).`}return null}function sm(i,e){return e.flag||!e.predicate?null:`${`${i}_${zo(e.name)}`}(X, Value) :- triple(X, '${e.predicate}', Value).`}function om(i,e){if(!e.predicate)return null;let t=`${i}_${zo(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 kv(i){let e=i.getModelMetadata(),t=zo(e.className),r=[];r.push(`% ${e.className} \u2014 generated Prolog facts`);let n=am(t,e);n&&(r.push(""),r.push("% Instance recognizer"),r.push(n));let a=Object.values(e.properties).map(o=>sm(t,o)).filter(o=>o!==null);a.length>0&&(r.push(""),r.push("% Field getters"),r.push(...a));let s=Object.values(e.relations).map(o=>om(t,o)).filter(o=>o!==null);return s.length>0&&(r.push(""),r.push("% Relation getters"),r.push(...s)),r.join(`
1508
+ `)}var Iv=`
1417
1509
  type AIModelLoadingStatus {
1418
1510
  downloaded: Boolean!
1419
1511
  loaded: Boolean!
@@ -1504,6 +1596,16 @@ input CapabilityInput {
1504
1596
  with: ResourceInput!
1505
1597
  }
1506
1598
 
1599
+ type ComputeLogEntry {
1600
+ cost: Float!
1601
+ creditsAfter: Float!
1602
+ id: Float!
1603
+ operation: String!
1604
+ summary: String
1605
+ timestamp: String!
1606
+ userEmail: String!
1607
+ }
1608
+
1507
1609
  scalar DateTime
1508
1610
 
1509
1611
  type EntanglementProof {
@@ -1800,6 +1902,7 @@ type Mutation {
1800
1902
  runtimeRequestPayment(amountHOT: String!): PaymentRequestResult!
1801
1903
  runtimeRestartHolochain: Boolean!
1802
1904
  runtimeSendHot(amount: String!, recipient: String!): PaymentRequestResult!
1905
+ runtimeSetFreeHostingEnabled(enabled: Boolean!): Boolean!
1803
1906
  runtimeSetHotWalletAddress(address: String!): Boolean!
1804
1907
  runtimeSetMultiUserEnabled(enabled: Boolean!): Boolean!
1805
1908
  runtimeSetStatus(status: PerspectiveInput!): Boolean!
@@ -1911,9 +2014,10 @@ type Query {
1911
2014
  perspective(uuid: String!): PerspectiveHandle
1912
2015
  perspectiveQueryLinks(query: LinkQuery!, uuid: String!): [LinkExpression!]
1913
2016
  perspectiveQueryProlog(query: String!, uuid: String!): String!
1914
- perspectiveQuerySurrealDB(query: String!, uuid: String!): String!
1915
2017
  perspectiveSnapshot(uuid: String!): Perspective
1916
2018
  perspectives: [PerspectiveHandle!]!
2019
+ runtimeComputeLog(limit: Float, since: String, userEmail: String): [ComputeLogEntry!]!
2020
+ runtimeFreeHostingEnabled: Boolean!
1917
2021
  runtimeFriendStatus(did: String!): PerspectiveExpression
1918
2022
  runtimeFriends: [String!]!
1919
2023
  runtimeGetNetworkMetrics: String!
@@ -1929,6 +2033,7 @@ type Query {
1929
2033
  runtimeMessageOutbox(filter: String): [SentMessage!]!
1930
2034
  runtimeMultiUserEnabled: Boolean!
1931
2035
  runtimeNotifications: [Notification!]!
2036
+ runtimeUnytAgentKey: String!
1932
2037
  runtimeUnytVersionInfo: String!
1933
2038
  runtimeVerifyStringSignedByDid(data: String!, did: String!, didSigningKeyId: String!, signedData: String!): Boolean!
1934
2039
  }
@@ -2026,26 +2131,22 @@ input VoiceActivityParamsInput {
2026
2131
  startWindow: Float
2027
2132
  timeBeforeSpeech: Float
2028
2133
  }
2029
- `,S=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},p=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},j=function(i,e){return function(t,r){e(t,r,i)}},Fn=new si;Fn.author="did:ad4m:test";Fn.timestamp=Date.now();Fn.data={source:"root",target:"neighbourhood://Qm12345"};Fn.proof={signature:"",key:"",valid:!0};var ei=new Bi;ei.author="did:ad4m:test";ei.timestamp=Date.now().toString();ei.proof=new Ht("","");ei.data=new Pt([Fn]);var Za=class{};S([h(),p("design:type",String)],Za.prototype,"recipient",void 0);S([h(),p("design:type",Bi)],Za.prototype,"message",void 0);Za=S([H()],Za);var Ar=class{};S([h(),p("design:type",String)],Ar.prototype,"ad4mExecutorVersion",void 0);S([h(),p("design:type",Boolean)],Ar.prototype,"isInitialized",void 0);S([h(),p("design:type",Boolean)],Ar.prototype,"isUnlocked",void 0);Ar=S([H()],Ar);var Qi=class{};S([h(),p("design:type",String)],Qi.prototype,"title",void 0);S([h(),p("design:type",String)],Qi.prototype,"message",void 0);S([h(),p("design:type",String)],Qi.prototype,"type",void 0);S([h(),p("design:type",String)],Qi.prototype,"addon",void 0);Qi=S([H()],Qi);var ft=class{};S([h(),p("design:type",String)],ft.prototype,"description",void 0);S([h(),p("design:type",String)],ft.prototype,"appName",void 0);S([h(),p("design:type",String)],ft.prototype,"appUrl",void 0);S([h(),p("design:type",String)],ft.prototype,"appIconPath",void 0);S([h(),p("design:type",String)],ft.prototype,"trigger",void 0);S([h(),p("design:type",Array)],ft.prototype,"perspectiveIds",void 0);S([h(),p("design:type",String)],ft.prototype,"webhookUrl",void 0);S([h(),p("design:type",String)],ft.prototype,"webhookAuth",void 0);ft=S([Te()],ft);var nt=class{};S([h(),p("design:type",String)],nt.prototype,"id",void 0);S([h(),p("design:type",Boolean)],nt.prototype,"granted",void 0);S([h(),p("design:type",String)],nt.prototype,"description",void 0);S([h(),p("design:type",String)],nt.prototype,"appName",void 0);S([h(),p("design:type",String)],nt.prototype,"appUrl",void 0);S([h(),p("design:type",String)],nt.prototype,"appIconPath",void 0);S([h(),p("design:type",String)],nt.prototype,"trigger",void 0);S([h(),p("design:type",Array)],nt.prototype,"perspectiveIds",void 0);S([h(),p("design:type",String)],nt.prototype,"webhookUrl",void 0);S([h(),p("design:type",String)],nt.prototype,"webhookAuth",void 0);nt=S([H()],nt);var kr=class{};S([h(),p("design:type",nt)],kr.prototype,"notification",void 0);S([h(),p("design:type",String)],kr.prototype,"perspectiveId",void 0);S([h(),p("design:type",String)],kr.prototype,"triggerMatch",void 0);kr=S([H()],kr);var Ie=class{};S([h(),p("design:type",Number)],Ie.prototype,"total",void 0);S([h(),p("design:type",Number)],Ie.prototype,"imported",void 0);S([h(),p("design:type",Number)],Ie.prototype,"failed",void 0);S([h(),p("design:type",Number)],Ie.prototype,"omitted",void 0);S([h(),p("design:type",Array)],Ie.prototype,"errors",void 0);Ie=S([H()],Ie);var at=class{};S([h(),p("design:type",Ie)],at.prototype,"perspectives",void 0);S([h(),p("design:type",Ie)],at.prototype,"links",void 0);S([h(),p("design:type",Ie)],at.prototype,"expressions",void 0);S([h(),p("design:type",Ie)],at.prototype,"perspectiveDiffs",void 0);S([h(),p("design:type",Ie)],at.prototype,"notifications",void 0);S([h(),p("design:type",Ie)],at.prototype,"models",void 0);S([h(),p("design:type",Ie)],at.prototype,"defaultModels",void 0);S([h(),p("design:type",Ie)],at.prototype,"tasks",void 0);S([h(),p("design:type",Ie)],at.prototype,"friends",void 0);S([h(),p("design:type",Ie)],at.prototype,"trustedAgents",void 0);S([h(),p("design:type",Ie)],at.prototype,"knownLinkLanguages",void 0);at=S([H()],at);var Vt=class{};S([h(),p("design:type",String)],Vt.prototype,"email",void 0);S([h(),p("design:type",String)],Vt.prototype,"did",void 0);S([h(),p("design:type",String)],Vt.prototype,"lastSeen",void 0);S([h(),p("design:type",Number)],Vt.prototype,"perspectiveCount",void 0);S([h(),p("design:type",String)],Vt.prototype,"remainingCredits",void 0);S([h(),p("design:type",Boolean)],Vt.prototype,"freeAccess",void 0);S([h(),p("design:type",String)],Vt.prototype,"hotWalletAddress",void 0);Vt=S([H()],Vt);var Gi=class{};S([h(),p("design:type",Boolean)],Gi.prototype,"success",void 0);S([h(),p("design:type",String)],Gi.prototype,"message",void 0);S([h(),p("design:type",Boolean)],Gi.prototype,"requiresPassword",void 0);S([h(),p("design:type",Boolean)],Gi.prototype,"isExistingUser",void 0);Gi=S([H()],Gi);var pi=class{constructor(e,t,r,n=!1){this.email=e,this.remainingCredits=t,this.hotWalletAddress=r,this.freeAccess=n}};S([h(),p("design:type",String)],pi.prototype,"email",void 0);S([h(),p("design:type",String)],pi.prototype,"remainingCredits",void 0);S([h(),p("design:type",String)],pi.prototype,"hotWalletAddress",void 0);S([h(),p("design:type",Boolean)],pi.prototype,"freeAccess",void 0);pi=S([H(),p("design:paramtypes",[String,String,String,Boolean])],pi);var dt=class{constructor(e,t){this.success=e,this.message=t}};S([h(),p("design:type",Boolean)],dt.prototype,"success",void 0);S([h(),p("design:type",String)],dt.prototype,"message",void 0);dt=S([H(),p("design:paramtypes",[Boolean,String])],dt);var O=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,r,n){return!0}runtimeSetStatus(e){return!0}runtimeFriendStatus(e){return ei}runtimeFriendSendMessage(e,t){return!0}runtimeMessageInbox(e){return[ei]}runtimeMessageOutbox(e){return[{recipient:"did:test:recipient",message:ei}]}runtimeMessageReceived(){return ei}exceptionOccurred(){return{title:"Test title",message:"Test message",type:mo.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}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,r){return"test-jwt-token-from-email-verification"}runtimeTestEmail(e){return!0}runtimeCreateUser(e,t,r){return new qi("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,r){return!0}runtimeHostingUserInfo(){return new pi("test@example.com","100000000",null,!1)}runtimeSetHotWalletAddress(e){return!0}runtimeRequestPayment(e){return new dt(!0,"Mock payment of "+e+" base units credited")}runtimeSetUserCredits(e,t){return!0}runtimeSetUserFreeAccess(e,t){return!0}runtimeReinstallUnytDna(){return new dt(!0,"")}runtimeSendHot(e,t){return new dt(!0,"")}runtimeSetUnytMembraneProof(e){return new dt(!0,"")}runtimeHotWalletBalance(){return""}runtimeHotWalletHistory(e,t){return""}runtimeHotAgentPubkey(){return""}runtimeUnytVersionInfo(){return""}};S([J(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],O.prototype,"runtimeQuit",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],O.prototype,"runtimeOpenLink",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Ar)],O.prototype,"runtimeInfo",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[Array]),p("design:returntype",Array)],O.prototype,"addTrustedAgents",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[Array]),p("design:returntype",Array)],O.prototype,"deleteTrustedAgents",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Array)],O.prototype,"getTrustedAgents",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Array)],O.prototype,"runtimeKnownLinkLanguageTemplates",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[Array]),p("design:returntype",Array)],O.prototype,"runtimeAddKnownLinkLanguageTemplates",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[Array]),p("design:returntype",Array)],O.prototype,"runtimeRemoveKnownLinkLanguageTemplates",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Array)],O.prototype,"runtimeFriends",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[Array]),p("design:returntype",Array)],O.prototype,"runtimeAddFriends",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[Array]),p("design:returntype",Array)],O.prototype,"runtimeRemoveFriends",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",String)],O.prototype,"runtimeHcAgentInfos",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",String)],O.prototype,"runtimeGetNetworkMetrics",null);S([J(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],O.prototype,"runtimeRestartHolochain",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[Object]),p("design:returntype",Boolean)],O.prototype,"runtimeHcAddAgentInfos",null);S([Ce(),j(0,F()),j(1,F()),j(2,F()),j(3,F()),p("design:type",Function),p("design:paramtypes",[String,String,String,String]),p("design:returntype",void 0)],O.prototype,"runtimeVerifyStringSignedByDid",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[Pt]),p("design:returntype",Boolean)],O.prototype,"runtimeSetStatus",null);S([Ce(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Bi)],O.prototype,"runtimeFriendStatus",null);S([J(),j(0,F()),j(1,F()),p("design:type",Function),p("design:paramtypes",[String,Na]),p("design:returntype",Boolean)],O.prototype,"runtimeFriendSendMessage",null);S([Ce(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Array)],O.prototype,"runtimeMessageInbox",null);S([Ce(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Array)],O.prototype,"runtimeMessageOutbox",null);S([wo(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Bi)],O.prototype,"runtimeMessageReceived",null);S([wo(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Qi)],O.prototype,"exceptionOccurred",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[ft]),p("design:returntype",String)],O.prototype,"runtimeRequestInstallNotification",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Array)],O.prototype,"runtimeNotifications",null);S([J(),j(0,F()),j(1,F()),p("design:type",Function),p("design:paramtypes",[String,ft]),p("design:returntype",Boolean)],O.prototype,"runtimeUpdateNotification",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],O.prototype,"runtimeRemoveNotification",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],O.prototype,"runtimeGrantNotification",null);S([wo(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",kr)],O.prototype,"runtimeNotificationTriggered",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],O.prototype,"runtimeExportDb",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],O.prototype,"runtimeImportDb",null);S([J(),j(0,F()),j(1,F()),p("design:type",Function),p("design:paramtypes",[String,String]),p("design:returntype",Boolean)],O.prototype,"runtimeExportPerspective",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],O.prototype,"runtimeImportPerspective",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],O.prototype,"runtimeMultiUserEnabled",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[Boolean]),p("design:returntype",Boolean)],O.prototype,"runtimeSetMultiUserEnabled",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Array)],O.prototype,"runtimeListUsers",null);S([J(),j(0,F()),j(1,F()),p("design:type",Function),p("design:paramtypes",[String,Rt]),p("design:returntype",Gi)],O.prototype,"runtimeRequestLoginVerification",null);S([J(),j(0,F()),j(1,F()),j(2,F()),p("design:type",Function),p("design:paramtypes",[String,String,String]),p("design:returntype",String)],O.prototype,"runtimeVerifyEmailCode",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],O.prototype,"runtimeTestEmail",null);S([J(),j(0,F()),j(1,F()),j(2,F()),p("design:type",Function),p("design:paramtypes",[String,String,Rt]),p("design:returntype",qi)],O.prototype,"runtimeCreateUser",null);S([J(),j(0,F()),j(1,F()),p("design:type",Function),p("design:paramtypes",[String,String]),p("design:returntype",String)],O.prototype,"runtimeLoginUser",null);S([J(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],O.prototype,"runtimeEmailTestModeEnable",null);S([J(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],O.prototype,"runtimeEmailTestModeDisable",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",String)],O.prototype,"runtimeEmailTestGetCode",null);S([J(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],O.prototype,"runtimeEmailTestClearCodes",null);S([J(),j(0,F()),j(1,F()),j(2,F()),p("design:type",Function),p("design:paramtypes",[String,String,Number]),p("design:returntype",Boolean)],O.prototype,"runtimeEmailTestSetExpiry",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",pi)],O.prototype,"runtimeHostingUserInfo",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],O.prototype,"runtimeSetHotWalletAddress",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",dt)],O.prototype,"runtimeRequestPayment",null);S([J(),j(0,F()),j(1,F()),p("design:type",Function),p("design:paramtypes",[String,Number]),p("design:returntype",Boolean)],O.prototype,"runtimeSetUserCredits",null);S([J(),j(0,F()),j(1,F()),p("design:type",Function),p("design:paramtypes",[String,Boolean]),p("design:returntype",Boolean)],O.prototype,"runtimeSetUserFreeAccess",null);S([J(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",dt)],O.prototype,"runtimeReinstallUnytDna",null);S([J(),j(0,F()),j(1,F()),p("design:type",Function),p("design:paramtypes",[String,String]),p("design:returntype",dt)],O.prototype,"runtimeSendHot",null);S([J(),j(0,F()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",dt)],O.prototype,"runtimeSetUnytMembraneProof",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",String)],O.prototype,"runtimeHotWalletBalance",null);S([Ce(),j(0,F()),j(1,F()),p("design:type",Function),p("design:paramtypes",[Number,Number]),p("design:returntype",String)],O.prototype,"runtimeHotWalletHistory",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",String)],O.prototype,"runtimeHotAgentPubkey",null);S([Ce(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",String)],O.prototype,"runtimeUnytVersionInfo",null);O=S([Xd()],O);var bt=class extends ge{constructor(){super(...arguments);this.capabilities=[];this.appname="";this.appiconpath="";this.verificationError=!1;this.requestSent=!1;this.securityCode=""}back(){this.dispatchEvent(new CustomEvent("back",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("clear-verification-error",{bubbles:!0,composed:!0}))}requestCapability(){this.dispatchEvent(new CustomEvent("request-capability",{bubbles:!0,composed:!0})),this.requestSent=!0}verifyCode(){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 r=t.target,n=r.value.replace(/\D/g,"").slice(0,6);r.value=n,this.securityCode=n,this.securityCode.length===6&&this.verifyCode()}render(){return I`
2134
+ `,w=function(i,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,t,r);else for(var o=i.length-1;o>=0;o--)(s=i[o])&&(a=(n<3?s(a):n>3?s(e,t,a):s(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a},p=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},F=function(i,e){return function(t,r){e(t,r,i)}},Qn=new li;Qn.author="did:ad4m:test";Qn.timestamp=Date.now();Qn.data={source:"root",target:"neighbourhood://Qm12345"};Qn.proof={signature:"",key:"",valid:!0};var ri=new Vi;ri.author="did:ad4m:test";ri.timestamp=Date.now().toString();ri.proof=new jt("","");ri.data=new It([Qn]);var as=class{};w([g(),p("design:type",String)],as.prototype,"recipient",void 0);w([g(),p("design:type",Vi)],as.prototype,"message",void 0);as=w([H()],as);var Pr=class{};w([g(),p("design:type",String)],Pr.prototype,"ad4mExecutorVersion",void 0);w([g(),p("design:type",Boolean)],Pr.prototype,"isInitialized",void 0);w([g(),p("design:type",Boolean)],Pr.prototype,"isUnlocked",void 0);Pr=w([H()],Pr);var Yi=class{};w([g(),p("design:type",String)],Yi.prototype,"title",void 0);w([g(),p("design:type",String)],Yi.prototype,"message",void 0);w([g(),p("design:type",String)],Yi.prototype,"type",void 0);w([g(),p("design:type",String)],Yi.prototype,"addon",void 0);Yi=w([H()],Yi);var ht=class{};w([g(),p("design:type",String)],ht.prototype,"description",void 0);w([g(),p("design:type",String)],ht.prototype,"appName",void 0);w([g(),p("design:type",String)],ht.prototype,"appUrl",void 0);w([g(),p("design:type",String)],ht.prototype,"appIconPath",void 0);w([g(),p("design:type",String)],ht.prototype,"trigger",void 0);w([g(),p("design:type",Array)],ht.prototype,"perspectiveIds",void 0);w([g(),p("design:type",String)],ht.prototype,"webhookUrl",void 0);w([g(),p("design:type",String)],ht.prototype,"webhookAuth",void 0);ht=w([Ce()],ht);var at=class{};w([g(),p("design:type",String)],at.prototype,"id",void 0);w([g(),p("design:type",Boolean)],at.prototype,"granted",void 0);w([g(),p("design:type",String)],at.prototype,"description",void 0);w([g(),p("design:type",String)],at.prototype,"appName",void 0);w([g(),p("design:type",String)],at.prototype,"appUrl",void 0);w([g(),p("design:type",String)],at.prototype,"appIconPath",void 0);w([g(),p("design:type",String)],at.prototype,"trigger",void 0);w([g(),p("design:type",Array)],at.prototype,"perspectiveIds",void 0);w([g(),p("design:type",String)],at.prototype,"webhookUrl",void 0);w([g(),p("design:type",String)],at.prototype,"webhookAuth",void 0);at=w([H()],at);var Rr=class{};w([g(),p("design:type",at)],Rr.prototype,"notification",void 0);w([g(),p("design:type",String)],Rr.prototype,"perspectiveId",void 0);w([g(),p("design:type",String)],Rr.prototype,"triggerMatch",void 0);Rr=w([H()],Rr);var Te=class{};w([g(),p("design:type",Number)],Te.prototype,"total",void 0);w([g(),p("design:type",Number)],Te.prototype,"imported",void 0);w([g(),p("design:type",Number)],Te.prototype,"failed",void 0);w([g(),p("design:type",Number)],Te.prototype,"omitted",void 0);w([g(),p("design:type",Array)],Te.prototype,"errors",void 0);Te=w([H()],Te);var st=class{};w([g(),p("design:type",Te)],st.prototype,"perspectives",void 0);w([g(),p("design:type",Te)],st.prototype,"links",void 0);w([g(),p("design:type",Te)],st.prototype,"expressions",void 0);w([g(),p("design:type",Te)],st.prototype,"perspectiveDiffs",void 0);w([g(),p("design:type",Te)],st.prototype,"notifications",void 0);w([g(),p("design:type",Te)],st.prototype,"models",void 0);w([g(),p("design:type",Te)],st.prototype,"defaultModels",void 0);w([g(),p("design:type",Te)],st.prototype,"tasks",void 0);w([g(),p("design:type",Te)],st.prototype,"friends",void 0);w([g(),p("design:type",Te)],st.prototype,"trustedAgents",void 0);w([g(),p("design:type",Te)],st.prototype,"knownLinkLanguages",void 0);st=w([H()],st);var Bt=class{};w([g(),p("design:type",String)],Bt.prototype,"email",void 0);w([g(),p("design:type",String)],Bt.prototype,"did",void 0);w([g(),p("design:type",String)],Bt.prototype,"lastSeen",void 0);w([g(),p("design:type",Number)],Bt.prototype,"perspectiveCount",void 0);w([g(),p("design:type",String)],Bt.prototype,"remainingCredits",void 0);w([g(),p("design:type",Boolean)],Bt.prototype,"freeAccess",void 0);w([g(),p("design:type",String)],Bt.prototype,"hotWalletAddress",void 0);Bt=w([H()],Bt);var er=class{};w([g(),p("design:type",Boolean)],er.prototype,"success",void 0);w([g(),p("design:type",String)],er.prototype,"message",void 0);w([g(),p("design:type",Boolean)],er.prototype,"requiresPassword",void 0);w([g(),p("design:type",Boolean)],er.prototype,"isExistingUser",void 0);er=w([H()],er);var gi=class{constructor(e,t,r,n=!1){this.email=e,this.remainingCredits=t,this.hotWalletAddress=r,this.freeAccess=n}};w([g(),p("design:type",String)],gi.prototype,"email",void 0);w([g(),p("design:type",String)],gi.prototype,"remainingCredits",void 0);w([g(),p("design:type",String)],gi.prototype,"hotWalletAddress",void 0);w([g(),p("design:type",Boolean)],gi.prototype,"freeAccess",void 0);gi=w([H(),p("design:paramtypes",[String,String,String,Boolean])],gi);var pt=class{constructor(e,t){this.success=e,this.message=t}};w([g(),p("design:type",Boolean)],pt.prototype,"success",void 0);w([g(),p("design:type",String)],pt.prototype,"message",void 0);pt=w([H(),p("design:paramtypes",[Boolean,String])],pt);var Ht=class{constructor(e,t,r,n,a,s,o){this.id=e,this.userEmail=t,this.timestamp=r,this.operation=n,this.cost=a,this.creditsAfter=s,this.summary=o}};w([g(),p("design:type",Number)],Ht.prototype,"id",void 0);w([g(),p("design:type",String)],Ht.prototype,"userEmail",void 0);w([g(),p("design:type",String)],Ht.prototype,"timestamp",void 0);w([g(),p("design:type",String)],Ht.prototype,"operation",void 0);w([g(),p("design:type",String)],Ht.prototype,"summary",void 0);w([g(),p("design:type",Number)],Ht.prototype,"cost",void 0);w([g(),p("design:type",Number)],Ht.prototype,"creditsAfter",void 0);Ht=w([H(),p("design:paramtypes",[Number,String,String,String,Number,Number,String])],Ht);var N=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,r,n){return!0}runtimeSetStatus(e){return!0}runtimeFriendStatus(e){return ri}runtimeFriendSendMessage(e,t){return!0}runtimeMessageInbox(e){return[ri]}runtimeMessageOutbox(e){return[{recipient:"did:test:recipient",message:ri}]}runtimeMessageReceived(){return ri}exceptionOccurred(){return{title:"Test title",message:"Test message",type:Ao.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,r){return"test-jwt-token-from-email-verification"}runtimeTestEmail(e){return!0}runtimeCreateUser(e,t,r){return new Wi("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,r){return!0}runtimeHostingUserInfo(){return new gi("test@example.com","100000000",null,!1)}runtimeComputeLog(e,t,r){return[]}runtimeSetHotWalletAddress(e){return!0}runtimeRequestPayment(e){return new pt(!0,"Mock payment of "+e+" base units credited")}runtimeSetUserCredits(e,t){return!0}runtimeSetUserFreeAccess(e,t){return!0}runtimeReinstallUnytDna(){return new pt(!0,"")}runtimeSendHot(e,t){return new pt(!0,"")}runtimeSetUnytMembraneProof(e){return new pt(!0,"")}runtimeHotWalletBalance(){return""}runtimeHotWalletHistory(e,t){return""}runtimeHotAgentPubkey(){return""}runtimeUnytAgentKey(){return""}runtimeUnytVersionInfo(){return""}};w([ee(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],N.prototype,"runtimeQuit",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],N.prototype,"runtimeOpenLink",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Pr)],N.prototype,"runtimeInfo",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[Array]),p("design:returntype",Array)],N.prototype,"addTrustedAgents",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[Array]),p("design:returntype",Array)],N.prototype,"deleteTrustedAgents",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Array)],N.prototype,"getTrustedAgents",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Array)],N.prototype,"runtimeKnownLinkLanguageTemplates",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[Array]),p("design:returntype",Array)],N.prototype,"runtimeAddKnownLinkLanguageTemplates",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[Array]),p("design:returntype",Array)],N.prototype,"runtimeRemoveKnownLinkLanguageTemplates",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Array)],N.prototype,"runtimeFriends",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[Array]),p("design:returntype",Array)],N.prototype,"runtimeAddFriends",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[Array]),p("design:returntype",Array)],N.prototype,"runtimeRemoveFriends",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",String)],N.prototype,"runtimeHcAgentInfos",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",String)],N.prototype,"runtimeGetNetworkMetrics",null);w([ee(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],N.prototype,"runtimeRestartHolochain",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[Object]),p("design:returntype",Boolean)],N.prototype,"runtimeHcAddAgentInfos",null);w([be(),F(0,M()),F(1,M()),F(2,M()),F(3,M()),p("design:type",Function),p("design:paramtypes",[String,String,String,String]),p("design:returntype",void 0)],N.prototype,"runtimeVerifyStringSignedByDid",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[It]),p("design:returntype",Boolean)],N.prototype,"runtimeSetStatus",null);w([be(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Vi)],N.prototype,"runtimeFriendStatus",null);w([ee(),F(0,M()),F(1,M()),p("design:type",Function),p("design:paramtypes",[String,Ha]),p("design:returntype",Boolean)],N.prototype,"runtimeFriendSendMessage",null);w([be(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Array)],N.prototype,"runtimeMessageInbox",null);w([be(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Array)],N.prototype,"runtimeMessageOutbox",null);w([Co(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Vi)],N.prototype,"runtimeMessageReceived",null);w([Co(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Yi)],N.prototype,"exceptionOccurred",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[ht]),p("design:returntype",String)],N.prototype,"runtimeRequestInstallNotification",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Array)],N.prototype,"runtimeNotifications",null);w([ee(),F(0,M()),F(1,M()),p("design:type",Function),p("design:paramtypes",[String,ht]),p("design:returntype",Boolean)],N.prototype,"runtimeUpdateNotification",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],N.prototype,"runtimeRemoveNotification",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],N.prototype,"runtimeGrantNotification",null);w([Co(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Rr)],N.prototype,"runtimeNotificationTriggered",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],N.prototype,"runtimeExportDb",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],N.prototype,"runtimeImportDb",null);w([ee(),F(0,M()),F(1,M()),p("design:type",Function),p("design:paramtypes",[String,String]),p("design:returntype",Boolean)],N.prototype,"runtimeExportPerspective",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],N.prototype,"runtimeImportPerspective",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],N.prototype,"runtimeMultiUserEnabled",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[Boolean]),p("design:returntype",Boolean)],N.prototype,"runtimeSetMultiUserEnabled",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],N.prototype,"runtimeFreeHostingEnabled",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[Boolean]),p("design:returntype",Boolean)],N.prototype,"runtimeSetFreeHostingEnabled",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Array)],N.prototype,"runtimeListUsers",null);w([ee(),F(0,M()),F(1,M()),p("design:type",Function),p("design:paramtypes",[String,Tt]),p("design:returntype",er)],N.prototype,"runtimeRequestLoginVerification",null);w([ee(),F(0,M()),F(1,M()),F(2,M()),p("design:type",Function),p("design:paramtypes",[String,String,String]),p("design:returntype",String)],N.prototype,"runtimeVerifyEmailCode",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],N.prototype,"runtimeTestEmail",null);w([ee(),F(0,M()),F(1,M()),F(2,M()),p("design:type",Function),p("design:paramtypes",[String,String,Tt]),p("design:returntype",Wi)],N.prototype,"runtimeCreateUser",null);w([ee(),F(0,M()),F(1,M()),p("design:type",Function),p("design:paramtypes",[String,String]),p("design:returntype",String)],N.prototype,"runtimeLoginUser",null);w([ee(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],N.prototype,"runtimeEmailTestModeEnable",null);w([ee(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],N.prototype,"runtimeEmailTestModeDisable",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",String)],N.prototype,"runtimeEmailTestGetCode",null);w([ee(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",Boolean)],N.prototype,"runtimeEmailTestClearCodes",null);w([ee(),F(0,M()),F(1,M()),F(2,M()),p("design:type",Function),p("design:paramtypes",[String,String,Number]),p("design:returntype",Boolean)],N.prototype,"runtimeEmailTestSetExpiry",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",gi)],N.prototype,"runtimeHostingUserInfo",null);w([be(),F(0,M()),F(1,M()),F(2,M()),p("design:type",Function),p("design:paramtypes",[String,Number,String]),p("design:returntype",Array)],N.prototype,"runtimeComputeLog",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",Boolean)],N.prototype,"runtimeSetHotWalletAddress",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",pt)],N.prototype,"runtimeRequestPayment",null);w([ee(),F(0,M()),F(1,M()),p("design:type",Function),p("design:paramtypes",[String,Number]),p("design:returntype",Boolean)],N.prototype,"runtimeSetUserCredits",null);w([ee(),F(0,M()),F(1,M()),p("design:type",Function),p("design:paramtypes",[String,Boolean]),p("design:returntype",Boolean)],N.prototype,"runtimeSetUserFreeAccess",null);w([ee(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",pt)],N.prototype,"runtimeReinstallUnytDna",null);w([ee(),F(0,M()),F(1,M()),p("design:type",Function),p("design:paramtypes",[String,String]),p("design:returntype",pt)],N.prototype,"runtimeSendHot",null);w([ee(),F(0,M()),p("design:type",Function),p("design:paramtypes",[String]),p("design:returntype",pt)],N.prototype,"runtimeSetUnytMembraneProof",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",String)],N.prototype,"runtimeHotWalletBalance",null);w([be(),F(0,M()),F(1,M()),p("design:type",Function),p("design:paramtypes",[Number,Number]),p("design:returntype",String)],N.prototype,"runtimeHotWalletHistory",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",String)],N.prototype,"runtimeHotAgentPubkey",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",String)],N.prototype,"runtimeUnytAgentKey",null);w([be(),p("design:type",Function),p("design:paramtypes",[]),p("design:returntype",String)],N.prototype,"runtimeUnytVersionInfo",null);N=w([fp()],N);var gt=class extends he{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 r=t.target,n=r.value.replace(/\D/g,"").slice(0,6);r.value=n,this.securityCode=n,this.securityCode.length===6&&this.verifyCode()}render(){return E`
2030
2135
  <div class="container">
2031
- <div class="back-button" @click=${this.back}>
2032
- ${wt()}
2033
- </div>
2034
-
2035
2136
  <div class="header">
2036
2137
  <h1>${this.appname}</h1>
2037
2138
  <h3>wants to access your AD4M data</h3>
2038
2139
  </div>
2039
2140
 
2040
2141
  <div class="connection-icons">
2041
- ${this.appiconpath?I`<img class="app-image" src=${this.appiconpath} alt="App Logo" />`:I`<div class="app-initial">${this.appname.charAt(0).toUpperCase()}</div>`}
2042
- <div class="arrow-icon">${Gn()}</div>
2043
- <div class="ad4m-logo">${_i()}</div>
2142
+ ${this.appiconpath?E`<img class="app-image" src=${this.appiconpath} alt="App Logo" />`:E`<div class="app-initial">${this.appname.charAt(0).toUpperCase()}</div>`}
2143
+ <div class="arrow-icon">${na()}</div>
2144
+ <div class="ad4m-logo">${Ei()}</div>
2044
2145
  </div>
2045
2146
 
2046
- ${this.requestSent?I`
2147
+ ${this.requestSent?E`
2047
2148
  <div class="state success" style="margin-bottom: -12px">
2048
- ${mt()}
2149
+ ${Ke()}
2049
2150
  <p>Auth request sent to local AD4M node</p>
2050
2151
  </div>
2051
2152
 
@@ -2061,19 +2162,20 @@ input VoiceActivityParamsInput {
2061
2162
  .value=${this.securityCode||""}
2062
2163
  @input=${this.onInputChange}
2063
2164
  />
2165
+ ${this.verifying?E`<div class="spinner"></div>`:""}
2064
2166
  </div>
2065
2167
 
2066
- ${this.verificationError?I`
2168
+ ${this.verificationError?E`
2067
2169
  <div class="state danger" style="margin-top: -32px; margin-bottom: 20px;">
2068
- ${Ue()}
2170
+ ${De()}
2069
2171
  <p>Verification failed. Please try again.</p>
2070
2172
  </div>
2071
2173
  `:""}
2072
- `:I`
2174
+ `:E`
2073
2175
  <p>This will allow ${this.appname} to</p>
2074
2176
 
2075
2177
  <ul class="box">
2076
- ${this.capabilities.map(t=>I`<li>${mt()}<p>${Kl(t)}</p></li>`)}
2178
+ ${this.capabilities.map(t=>E`<li>${Ke()}<p>${su(t)}</p></li>`)}
2077
2179
  </ul>
2078
2180
 
2079
2181
  <div class="row center">
@@ -2083,7 +2185,7 @@ input VoiceActivityParamsInput {
2083
2185
  </div>
2084
2186
  `}
2085
2187
  </div>
2086
- `}};bt.styles=[Ke,Ee`
2188
+ `}};gt.styles=[Qe,$e`
2087
2189
  h1 {
2088
2190
  font-size: 34px;
2089
2191
  }
@@ -2148,7 +2250,9 @@ input VoiceActivityParamsInput {
2148
2250
  .security-code {
2149
2251
  width: 100%;
2150
2252
  display: flex;
2253
+ align-items: center;
2151
2254
  justify-content: center;
2255
+ gap: 12px;
2152
2256
  margin-bottom: 20px;
2153
2257
  }
2154
2258
 
@@ -2165,53 +2269,46 @@ input VoiceActivityParamsInput {
2165
2269
  .state {
2166
2270
  justify-content: center;
2167
2271
  }
2168
- `],L([ie({type:Array})],bt.prototype,"capabilities",2),L([ie({type:String})],bt.prototype,"appname",2),L([ie({type:String})],bt.prototype,"appiconpath",2),L([ie({type:Boolean})],bt.prototype,"verificationError",2),L([Y()],bt.prototype,"requestSent",2),L([Y()],bt.prototype,"securityCode",2),bt=L([Ne("local-authentication")],bt);var Ve=class extends ge{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=""}back(){this.dispatchEvent(new CustomEvent("back",{bubbles:!0,composed:!0})),this.remoteAuthState=null,this.password="",this.confirmPassword="",this.emailSecurityCode=""}emailLogin(){this.dispatchEvent(new CustomEvent("email-login",{detail:{email:this.email.trim()},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 r=t.target,n=r.value.replace(/\D/g,"").slice(0,6);r.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,r=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,s=this.remoteAuthState&&!this.remoteAuthState.success&&!this.remoteAuthState.requiresPassword;return I`
2272
+ `],C([ie({type:Array})],gt.prototype,"capabilities",2),C([ie({type:String})],gt.prototype,"appname",2),C([ie({type:String})],gt.prototype,"appiconpath",2),C([ie({type:Boolean})],gt.prototype,"verificationError",2),C([Z()],gt.prototype,"requestSent",2),C([Z()],gt.prototype,"securityCode",2),C([Z()],gt.prototype,"verifying",2),gt=C([Ne("local-authentication")],gt);var Ve=class extends he{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 r=t.target,n=r.value.replace(/\D/g,"").slice(0,6);r.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,r=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,s=this.remoteAuthState&&!this.remoteAuthState.success&&!this.remoteAuthState.requiresPassword;return E`
2169
2273
  <div class="container">
2170
- <div class="back-button" @click=${this.back}>
2171
- ${wt()}
2172
- </div>
2173
-
2174
2274
  <div class="header">
2175
- <h1>Login or Register</h1>
2176
- ${this.host?I`<p style="font-size: 13px; color: rgba(255,255,255,0.4); margin-top: 4px;">${this.host.url}</p>`:""}
2275
+ <h1 style="font-size: 28px;">${n?"Login":a?"Register":"Login or Register"}</h1>
2276
+ ${this.host?E`<p style="font-size: 15px; color: rgba(255,255,255,0.4); margin-top: 10px;">${this.host.url}</p>`:""}
2177
2277
  </div>
2178
2278
 
2179
- ${t?I`
2180
- <h3>Enter your email to login to ${this.host?I`<strong>${this.host.name}</strong>`:"the remote node"}</h3>
2279
+ ${t?E`
2280
+ <h3>Enter your email to login to ${this.host?E`<strong>${this.host.name}</strong>`:"the remote node"}</h3>
2181
2281
 
2182
2282
  <div class="input-row">
2183
2283
  <input
2184
2284
  type="email"
2185
2285
  placeholder="email@example.com"
2186
2286
  .value=${this.email||""}
2187
- @input=${o=>{let l=o.target;this.email=l.value}}
2287
+ @input=${o=>{let c=o.target;this.email=c.value}}
2188
2288
  @keydown=${o=>{o.key==="Enter"&&!this.remoteAuthLoading&&this.isValidEmail()&&this.emailLogin()}}
2189
2289
  />
2190
2290
  </div>
2191
2291
 
2192
2292
  <div class="login-button" style="margin-top: 10px;">
2193
2293
  <button class="primary" @click=${this.emailLogin} .disabled=${this.remoteAuthLoading||!this.isValidEmail()}>
2194
- ${this.remoteAuthLoading?"Loading...":"Login"}
2294
+ ${this.remoteAuthLoading?"Loading...":"Continue"}
2195
2295
  </button>
2196
2296
  </div>
2197
2297
  `:""}
2198
2298
 
2199
- ${s?I`
2299
+ ${s?E`
2200
2300
  <div class="state danger">
2201
- ${Ue()}
2301
+ ${De()}
2202
2302
  <p>${this.remoteAuthState.message||"Failed to process email. Please try again."}</p>
2203
2303
  </div>
2204
-
2205
- <div class="login-button">
2206
- <button class="primary" @click=${this.back}>
2207
- Back
2208
- </button>
2304
+ <div class="login-button" style="margin-top: 10px;">
2305
+ <button class="primary" @click=${this.tryAgain}>Try again</button>
2209
2306
  </div>
2210
2307
  `:""}
2211
2308
 
2212
- ${r?I`
2309
+ ${r?E`
2213
2310
  <div class="state success" style="margin-bottom: -12px">
2214
- ${mt()}
2311
+ ${Ke()}
2215
2312
  <p>Email verification code sent</p>
2216
2313
  </div>
2217
2314
 
@@ -2227,19 +2324,20 @@ input VoiceActivityParamsInput {
2227
2324
  .value=${this.emailSecurityCode||""}
2228
2325
  @input=${this.onEmailSecurityCodeChange}
2229
2326
  />
2327
+ ${this.remoteAuthLoading?E`<div class="spinner"></div>`:""}
2230
2328
  </div>
2231
2329
 
2232
- ${this.emailCodeError?I`
2330
+ ${this.emailCodeError?E`
2233
2331
  <div class="state danger" style="margin-top: -32px; margin-bottom: 20px;">
2234
- ${Ue()}
2332
+ ${De()}
2235
2333
  <p>Verification failed. Please try again.</p>
2236
2334
  </div>
2237
2335
  `:""}
2238
2336
  `:""}
2239
2337
 
2240
- ${n?I`
2338
+ ${n?E`
2241
2339
  <div class="state success" style="margin-bottom: -12px">
2242
- ${mt()}
2340
+ ${Ke()}
2243
2341
  <p>Account found</p>
2244
2342
  </div>
2245
2343
 
@@ -2250,7 +2348,7 @@ input VoiceActivityParamsInput {
2250
2348
  type="password"
2251
2349
  placeholder="Password..."
2252
2350
  .value=${this.password||""}
2253
- @input=${o=>{let l=o.target;this.password=l.value}}
2351
+ @input=${o=>{let c=o.target;this.password=c.value}}
2254
2352
  @keydown=${o=>{o.key==="Enter"&&!this.remoteAuthLoading&&this.password.length&&this.passwordLogin()}}
2255
2353
  />
2256
2354
  </div>
@@ -2261,17 +2359,17 @@ input VoiceActivityParamsInput {
2261
2359
  </button>
2262
2360
  </div>
2263
2361
 
2264
- ${this.passwordError?I`
2362
+ ${this.passwordError?E`
2265
2363
  <div class="state danger" style="margin-top: -32px; margin-bottom: 20px;">
2266
- ${Ue()}
2364
+ ${De()}
2267
2365
  <p>Incorrect password. Please try again.</p>
2268
2366
  </div>
2269
2367
  `:""}
2270
2368
  `:""}
2271
2369
 
2272
- ${a?I`
2370
+ ${a?E`
2273
2371
  <div class="state success">
2274
- ${mt()}
2372
+ ${Ke()}
2275
2373
  <p>Creating a new account for <strong>${this.email}</strong></p>
2276
2374
  </div>
2277
2375
 
@@ -2282,7 +2380,7 @@ input VoiceActivityParamsInput {
2282
2380
  type="password"
2283
2381
  placeholder="Password..."
2284
2382
  .value=${this.password||""}
2285
- @input=${o=>{let l=o.target;this.password=l.value}}
2383
+ @input=${o=>{let c=o.target;this.password=c.value}}
2286
2384
  />
2287
2385
  </div>
2288
2386
 
@@ -2291,12 +2389,12 @@ input VoiceActivityParamsInput {
2291
2389
  type="password"
2292
2390
  placeholder="Confirm password..."
2293
2391
  .value=${this.confirmPassword||""}
2294
- @input=${o=>{let l=o.target;this.confirmPassword=l.value}}
2392
+ @input=${o=>{let c=o.target;this.confirmPassword=c.value}}
2295
2393
  @keydown=${o=>{o.key==="Enter"&&!this.remoteAuthLoading&&this.passwordsMatch&&this.createAccount()}}
2296
2394
  />
2297
2395
  </div>
2298
2396
 
2299
- ${this.confirmPassword.length>0&&!this.passwordsMatch?I`<p style="font-size: 13px; color: var(--ac-danger-color); text-align: center;">Passwords do not match</p>`:""}
2397
+ ${this.confirmPassword.length>0&&!this.passwordsMatch?E`<p style="font-size: 13px; color: var(--ac-danger-color); text-align: center;">Passwords do not match</p>`:""}
2300
2398
 
2301
2399
  <div class="login-button">
2302
2400
  <button class="primary" @click=${this.createAccount} .disabled=${this.remoteAuthLoading||!this.passwordsMatch}>
@@ -2304,16 +2402,16 @@ input VoiceActivityParamsInput {
2304
2402
  </button>
2305
2403
  </div>
2306
2404
 
2307
- ${this.accountCreationError?I`
2405
+ ${this.accountCreationError?E`
2308
2406
  <div class="state danger" style="margin-top: -32px; margin-bottom: 20px;">
2309
- ${Ue()}
2407
+ ${De()}
2310
2408
  <p>Failed to create account. Please try again.</p>
2311
2409
  </div>
2312
2410
  `:""}
2313
2411
  `:""}
2314
2412
 
2315
2413
  </div>
2316
- `}};Ve.styles=[Ke,Ee`
2414
+ `}};Ve.styles=[Qe,$e`
2317
2415
  .header h1 {
2318
2416
  font-size: 32px;
2319
2417
  margin-bottom: 0;
@@ -2336,7 +2434,9 @@ input VoiceActivityParamsInput {
2336
2434
  .security-code {
2337
2435
  width: 100%;
2338
2436
  display: flex;
2437
+ align-items: center;
2339
2438
  justify-content: center;
2439
+ gap: 12px;
2340
2440
  margin-bottom: 20px;
2341
2441
  }
2342
2442
 
@@ -2359,10 +2459,10 @@ input VoiceActivityParamsInput {
2359
2459
  .state {
2360
2460
  justify-content: center;
2361
2461
  }
2362
- `],L([ie({type:Object})],Ve.prototype,"remoteAuthState",2),L([ie({type:Boolean})],Ve.prototype,"remoteAuthLoading",2),L([ie({type:Boolean})],Ve.prototype,"emailCodeError",2),L([ie({type:Boolean})],Ve.prototype,"passwordError",2),L([ie({type:Boolean})],Ve.prototype,"accountCreationError",2),L([ie({type:Object})],Ve.prototype,"host",2),L([Y()],Ve.prototype,"email",2),L([Y()],Ve.prototype,"password",2),L([Y()],Ve.prototype,"emailSecurityCode",2),L([Y()],Ve.prototype,"confirmPassword",2),Ve=L([Ne("remote-authentication")],Ve);var gi=class extends ge{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 I`
2462
+ `],C([ie({type:Object})],Ve.prototype,"remoteAuthState",2),C([ie({type:Boolean})],Ve.prototype,"remoteAuthLoading",2),C([ie({type:Boolean})],Ve.prototype,"emailCodeError",2),C([ie({type:Boolean})],Ve.prototype,"passwordError",2),C([ie({type:Boolean})],Ve.prototype,"accountCreationError",2),C([ie({type:Object})],Ve.prototype,"host",2),C([Z()],Ve.prototype,"email",2),C([Z()],Ve.prototype,"password",2),C([Z()],Ve.prototype,"emailSecurityCode",2),C([Z()],Ve.prototype,"confirmPassword",2),Ve=C([Ne("remote-authentication")],Ve);var vi=class extends he{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 E`
2363
2463
  <div class="container">
2364
2464
  <div class="close-button" @click=${this.close}>
2365
- ${Ue()}
2465
+ ${De()}
2366
2466
  </div>
2367
2467
 
2368
2468
  <div class="header">
@@ -2372,11 +2472,11 @@ input VoiceActivityParamsInput {
2372
2472
 
2373
2473
  <div class="box">
2374
2474
  <div class="box-header">
2375
- ${t?or():Wn()}
2475
+ ${t?pr():ta()}
2376
2476
  <h3>${t?"Local Node":"Remote Node"}</h3>
2377
2477
  </div>
2378
2478
 
2379
- ${t?I`
2479
+ ${t?E`
2380
2480
  <div class="row">
2381
2481
  <span>Port:</span>
2382
2482
  <span class="detail-value">${this.port}</span>
@@ -2385,7 +2485,7 @@ input VoiceActivityParamsInput {
2385
2485
  <span>URL:</span>
2386
2486
  <span class="detail-value">${this.url}</span>
2387
2487
  </div>
2388
- `:I`
2488
+ `:E`
2389
2489
  <div class="row">
2390
2490
  <span>URL:</span>
2391
2491
  <span class="detail-value">${this.url}</span>
@@ -2404,7 +2504,7 @@ input VoiceActivityParamsInput {
2404
2504
  </button>
2405
2505
  </div>
2406
2506
  </div>
2407
- `}};gi.styles=[Ke,Ee`
2507
+ `}};vi.styles=[Qe,$e`
2408
2508
  .box {
2409
2509
  gap: 15px;
2410
2510
  }
@@ -2439,27 +2539,32 @@ input VoiceActivityParamsInput {
2439
2539
  background: rgba(244, 54, 127, 0.2);
2440
2540
  color: var(--ac-danger-color);
2441
2541
  }
2442
- `],L([ie({type:String})],gi.prototype,"url",2),L([ie({type:Number})],gi.prototype,"port",2),L([ie({type:String})],gi.prototype,"authState",2),gi=L([Ne("current-state")],gi);function os(i,e){let t=cc(i.id||i.name),r=oc(i.name);if(i.profilePicUrl){let n=a=>{let s=a.target,o=document.createElement("div");o.className=`${e} fallback`,o.style.background=`hsl(${t},60%,35%)`,o.textContent=r,s.replaceWith(o)};return I`<img class=${e} src=${i.profilePicUrl} alt="" @error=${n} />`}return I`<div class="${e} fallback" style="background:hsl(${t},60%,35%)">${r}</div>`}var ht=class extends ge{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)}back(){this.dispatchEvent(new CustomEvent("back",{bubbles:!0,composed:!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 r;try{r=new URL(t)}catch(a){this.manualUrlError="Invalid URL format";return}if(r.protocol!=="ws:"&&r.protocol!=="wss:"){this.manualUrlError="URL must use ws:// or wss:// protocol";return}this.manualUrlError=null;let n={id:`manual-${Date.now()}`,name:r.hostname,profilePicUrl:"",location:"Custom URL",url:t,rates:[],aiModels:[]};this.selectHost(n)}renderAvatar(t){return os(t,"host-avatar")}retry(){this.dispatchEvent(new CustomEvent("retry",{bubbles:!0,composed:!0}))}formatPrice(t){return t>=.01?t.toFixed(2):t>=1e-4?t.toFixed(4):t>=1e-6?t.toFixed(6):t.toExponential(2)}getLinkPrice(t){let r=t.find(n=>n.description==="link write");return r?r.priceInHOT:null}getAvgTokenPrice(t){let r=t.filter(n=>n.description.endsWith("per token"));return r.length===0?null:r.reduce((n,a)=>n+a.priceInHOT,0)/r.length}getSortedHosts(){if(!this.lastHostId)return this.hosts;let t=this.hosts.filter(n=>n.id===this.lastHostId),r=this.hosts.filter(n=>n.id!==this.lastHostId);return[...t,...r]}render(){return I`
2542
+ `],C([ie({type:String})],vi.prototype,"url",2),C([ie({type:Number})],vi.prototype,"port",2),C([ie({type:String})],vi.prototype,"authState",2),vi=C([Ne("current-state")],vi);function ms(i,e){let t=vc(i.id||i.name),r=yc(i.name);if(i.profilePicUrl){let n=a=>{let s=a.target,o=document.createElement("div");o.className=`${e} fallback`,o.style.background=`hsl(${t},60%,35%)`,o.textContent=r,s.replaceWith(o)};return E`<img class=${e} src=${i.profilePicUrl} alt="" @error=${n} />`}return E`<div class="${e} fallback" style="background:hsl(${t},60%,35%)">${r}</div>`}var mt=class extends he{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 r;try{r=new URL(t)}catch(a){this.manualUrlError="Invalid URL format";return}if(r.protocol!=="ws:"&&r.protocol!=="wss:"){this.manualUrlError="URL must use ws:// or wss:// protocol";return}this.manualUrlError=null;let n={id:`manual-${Date.now()}`,name:r.hostname,profilePicUrl:"",location:"Custom URL",url:t,rates:[],aiModels:[]};this.selectHost(n)}renderAvatar(t){return ms(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 r=t.find(n=>n.description.trim().toLowerCase()==="link write");return r?r.priceInHOT:null}getAvgTokenPrice(t){let r=t.filter(n=>n.description.trim().toLowerCase()!=="link write");return r.length===0?null:r.reduce((n,a)=>n+a.priceInHOT,0)/r.length}getSortedHosts(){if(!this.lastHostId)return this.hosts;let t=this.hosts.filter(n=>n.id===this.lastHostId),r=this.hosts.filter(n=>n.id!==this.lastHostId);return[...t,...r]}render(){return E`
2443
2543
  <div class="container">
2444
- <button class="back-button" @click=${this.back} aria-label="Go back">
2445
- ${wt()}
2446
- </button>
2447
-
2448
2544
  <div class="header">
2449
2545
  <h1>Remote Node</h1>
2450
2546
  <h3>Choose a host or enter a URL</h3>
2451
2547
  </div>
2452
2548
 
2453
- ${this.loading?I`
2454
- <div class="spinner"></div>
2455
- `:this.error?I`
2549
+ <div class="trust-notice">
2550
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="rgba(255, 200, 50, 0.9)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2551
+ <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>
2552
+ <line x1="12" y1="9" x2="12" y2="13"/>
2553
+ <line x1="12" y1="17" x2="12.01" y2="17"/>
2554
+ </svg>
2555
+ <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>
2556
+ </div>
2557
+
2558
+ ${this.loading?E`
2559
+ <div class="spinner-container"><div class="spinner"></div></div>
2560
+ `:this.error?E`
2456
2561
  <div class="box">
2457
2562
  <p style="color: var(--ac-danger-color)">${this.error}</p>
2458
2563
  <button class="primary" @click=${this.retry}>Retry</button>
2459
2564
  </div>
2460
- `:I`
2565
+ `:E`
2461
2566
  <div class="host-list">
2462
- ${this.getSortedHosts().map(t=>I`
2567
+ ${this.getSortedHosts().map(t=>E`
2463
2568
  <div
2464
2569
  class="host-card ${t.id===this.lastHostId?"pinned":""}"
2465
2570
  tabindex="0"
@@ -2472,17 +2577,17 @@ input VoiceActivityParamsInput {
2472
2577
  <div class="host-info">
2473
2578
  <div style="display:flex;align-items:center;gap:8px;">
2474
2579
  <p class="host-name">${t.name}</p>
2475
- ${t.id===this.lastHostId?I`<span class="pinned-label">Last used</span>`:""}
2580
+ ${t.id===this.lastHostId?E`<span class="pinned-label">Last used</span>`:""}
2476
2581
  </div>
2477
- <p class="host-location">${t.location}</p>
2582
+ <p class="host-location">${Kt()}${t.location}</p>
2478
2583
  <div class="host-meta">
2479
- ${t.aiModels.map(r=>I`<span class="model-chip">${r}</span>`)}
2584
+ ${t.aiModels.map(r=>E`<span class="model-chip">${r}</span>`)}
2480
2585
  </div>
2481
- ${t.rates.length>0?I`
2586
+ ${t.rates.length>0?(()=>{let r=this.getLinkPrice(t.rates),n=this.getAvgTokenPrice(t.rates);return E`
2482
2587
  <p class="rates-preview">
2483
- ${this.getLinkPrice(t.rates)!=null?I`Link: ${this.formatPrice(this.getLinkPrice(t.rates))} HOT`:""}${this.getLinkPrice(t.rates)!=null&&this.getAvgTokenPrice(t.rates)!=null?" \xB7 ":""}${this.getAvgTokenPrice(t.rates)!=null?I`Token: ~${this.formatPrice(this.getAvgTokenPrice(t.rates))} HOT`:""}
2588
+ ${r!=null?E`Link: ${this.formatPrice(r)} wHOT`:""}${r!=null&&n!=null?" \xB7 ":""}${n!=null?E`Token: ~${this.formatPrice(n)} wHOT`:""}
2484
2589
  </p>
2485
- `:""}
2590
+ `})():""}
2486
2591
  </div>
2487
2592
  </div>
2488
2593
  `)}
@@ -2508,9 +2613,9 @@ input VoiceActivityParamsInput {
2508
2613
  Connect
2509
2614
  </button>
2510
2615
  </div>
2511
- ${this.manualUrlError?I`<p class="state danger" style="margin-top: 6px; font-size: 13px;">${this.manualUrlError}</p>`:""}
2616
+ ${this.manualUrlError?E`<p class="state danger" style="margin-top: 6px; font-size: 13px;">${this.manualUrlError}</p>`:""}
2512
2617
  </div>
2513
- `}};ht.styles=[Ke,Ee`
2618
+ `}};mt.styles=[Qe,$e`
2514
2619
  :host {
2515
2620
  display: flex;
2516
2621
  flex-direction: column;
@@ -2536,7 +2641,7 @@ input VoiceActivityParamsInput {
2536
2641
  .host-card {
2537
2642
  display: flex;
2538
2643
  align-items: center;
2539
- gap: 12px;
2644
+ gap: 16px;
2540
2645
  padding: 14px;
2541
2646
  border-radius: 8px;
2542
2647
  background: rgba(128, 178, 201, 0.10);
@@ -2558,8 +2663,8 @@ input VoiceActivityParamsInput {
2558
2663
  }
2559
2664
 
2560
2665
  .host-avatar {
2561
- width: 40px;
2562
- height: 40px;
2666
+ width: 60px;
2667
+ height: 60px;
2563
2668
  border-radius: 50%;
2564
2669
  flex-shrink: 0;
2565
2670
  object-fit: cover;
@@ -2589,12 +2694,19 @@ input VoiceActivityParamsInput {
2589
2694
  }
2590
2695
 
2591
2696
  .host-location {
2697
+ display: inline-flex;
2698
+ align-items: center;
2699
+ gap: 4px;
2592
2700
  font-size: 13px;
2593
2701
  color: rgba(255, 255, 255, 0.6);
2594
2702
  margin: 2px 0 0 0;
2595
2703
  text-align: left;
2596
2704
  }
2597
2705
 
2706
+ .host-location svg {
2707
+ opacity: 0.7;
2708
+ }
2709
+
2598
2710
  .host-meta {
2599
2711
  display: flex;
2600
2712
  flex-wrap: wrap;
@@ -2603,8 +2715,8 @@ input VoiceActivityParamsInput {
2603
2715
  }
2604
2716
 
2605
2717
  .model-chip {
2606
- font-size: 11px;
2607
- padding: 2px 8px;
2718
+ font-size: 12px;
2719
+ padding: 3px 8px;
2608
2720
  border-radius: 10px;
2609
2721
  background: rgba(145, 227, 253, 0.15);
2610
2722
  color: var(--ac-primary-color);
@@ -2614,28 +2726,19 @@ input VoiceActivityParamsInput {
2614
2726
  .rates-preview {
2615
2727
  font-size: 12px;
2616
2728
  color: rgba(255, 255, 255, 0.5);
2617
- margin-top: 4px;
2729
+ margin-top: 6px;
2618
2730
  text-align: left;
2619
2731
  }
2620
2732
 
2621
- .spinner {
2733
+ .spinner-container {
2622
2734
  display: flex;
2623
2735
  justify-content: center;
2624
2736
  padding: 40px 0;
2625
2737
  }
2626
2738
 
2627
- .spinner::after {
2628
- content: "";
2739
+ .spinner-container .spinner {
2629
2740
  width: 32px;
2630
2741
  height: 32px;
2631
- border: 3px solid var(--ac-border-color-light);
2632
- border-top-color: var(--ac-primary-color);
2633
- border-radius: 50%;
2634
- animation: spin 0.8s linear infinite;
2635
- }
2636
-
2637
- @keyframes spin {
2638
- to { transform: rotate(360deg); }
2639
2742
  }
2640
2743
 
2641
2744
  .divider {
@@ -2675,6 +2778,24 @@ input VoiceActivityParamsInput {
2675
2778
  flex-shrink: 0;
2676
2779
  }
2677
2780
 
2781
+ .trust-notice {
2782
+ display: flex;
2783
+ gap: 10px;
2784
+ padding: 12px 14px;
2785
+ border-radius: 8px;
2786
+ background: rgba(255, 200, 50, 0.08);
2787
+ border: 1px solid rgba(255, 200, 50, 0.25);
2788
+ margin-bottom: 12px;
2789
+ font-size: 13px;
2790
+ line-height: 1.45;
2791
+ color: rgba(255, 255, 255, 0.75);
2792
+ }
2793
+
2794
+ .trust-notice svg {
2795
+ flex-shrink: 0;
2796
+ margin-top: 1px;
2797
+ }
2798
+
2678
2799
  .pinned-label {
2679
2800
  font-size: 11px;
2680
2801
  color: var(--ac-primary-color);
@@ -2682,47 +2803,38 @@ input VoiceActivityParamsInput {
2682
2803
  letter-spacing: 0.5px;
2683
2804
  font-weight: 600;
2684
2805
  }
2685
-
2686
- button.back-button {
2687
- all: unset;
2688
- cursor: pointer;
2689
- }
2690
- `],L([ie({type:Array})],ht.prototype,"hosts",2),L([ie({type:Boolean})],ht.prototype,"loading",2),L([ie({type:String})],ht.prototype,"error",2),L([ie({type:String})],ht.prototype,"lastHostId",2),L([ie({type:String})],ht.prototype,"defaultUrl",2),L([Y()],ht.prototype,"manualUrl",2),L([Y()],ht.prototype,"manualUrlError",2),ht=L([Ne("host-browser")],ht);var Nr=class extends ge{back(){this.dispatchEvent(new CustomEvent("back",{bubbles:!0,composed:!0}))}proceedToAuth(){this.dispatchEvent(new CustomEvent("proceed-to-auth",{detail:{host:this.host},bubbles:!0,composed:!0}))}renderAvatar(){return os(this.host,"profile-pic")}rateLabel(t){return t==="link write"?"Link write":t==="embedding per token"?"Embedding (per token)":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?I`
2806
+ `],C([ie({type:Array})],mt.prototype,"hosts",2),C([ie({type:Boolean})],mt.prototype,"loading",2),C([ie({type:String})],mt.prototype,"error",2),C([ie({type:String})],mt.prototype,"lastHostId",2),C([ie({type:String})],mt.prototype,"defaultUrl",2),C([Z()],mt.prototype,"manualUrl",2),C([Z()],mt.prototype,"manualUrlError",2),mt=C([Ne("host-browser")],mt);var zt=class extends he{proceedToAuth(){this.dispatchEvent(new CustomEvent("proceed-to-auth",{detail:{host:this.host},bubbles:!0,composed:!0}))}renderAvatar(){return ms(this.host,"profile-pic")}isOperationRate(t){return zt.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?E`
2691
2807
  <div class="container">
2692
- <button class="back-button" aria-label="Go back" @click=${this.back}>
2693
- ${wt()}
2694
- </button>
2695
-
2696
2808
  <div class="profile">
2697
2809
  ${this.renderAvatar()}
2698
2810
  <p class="profile-name">${this.host.name}</p>
2699
- <p class="profile-location">${this.host.location}</p>
2700
- ${this.host.description?I`<p class="profile-description">${this.host.description}</p>`:""}
2811
+ <p class="profile-location">${Kt()}${this.host.location}</p>
2812
+ ${this.host.description?E`<p class="profile-description">${this.host.description}</p>`:""}
2701
2813
 
2702
- ${this.host.aiModels.length>0?I`
2814
+ ${this.host.aiModels.length>0?E`
2703
2815
  <div class="models">
2704
- ${this.host.aiModels.map(t=>I`<span class="model-chip">${t}</span>`)}
2816
+ ${this.host.aiModels.map(t=>E`<span class="model-chip">${t}</span>`)}
2705
2817
  </div>
2706
2818
  `:""}
2707
2819
  </div>
2708
2820
 
2709
- ${this.host.rates.length>0?I`
2821
+ ${this.host.rates.length>0?E`
2710
2822
  <div class="box">
2711
2823
  <div class="rates-section">
2712
2824
  <h3>Pricing</h3>
2713
2825
  <table class="rates-table">
2714
- ${this.host.rates.filter(t=>!t.description.endsWith("per token")).map(t=>I`
2826
+ ${this.host.rates.filter(t=>this.isOperationRate(t)).map(t=>E`
2715
2827
  <tr>
2716
2828
  <td>${this.rateLabel(t.description)}</td>
2717
- <td>${this.formatPrice(t.priceInHOT)} HOT</td>
2829
+ <td>${this.formatPrice(t.priceInHOT)} wHOT</td>
2718
2830
  </tr>
2719
2831
  `)}
2720
- ${this.host.rates.filter(t=>t.description.endsWith("per token")).length>0?I`
2721
- <tr><td colspan="2" style="padding-top:12px;color:rgba(255,255,255,0.5);font-size:12px;text-transform:uppercase;letter-spacing:0.5px;">AI Models (per token)</td></tr>
2722
- ${this.host.rates.filter(t=>t.description.endsWith("per token")).map(t=>I`
2832
+ ${this.host.rates.filter(t=>!this.isOperationRate(t)).length>0?E`
2833
+ <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>
2834
+ ${this.host.rates.filter(t=>!this.isOperationRate(t)).map(t=>E`
2723
2835
  <tr>
2724
- <td>${t.description.replace(" per token","")}</td>
2725
- <td>${this.formatPrice(t.priceInHOT)} HOT</td>
2836
+ <td>${t.description}</td>
2837
+ <td>${this.formatPrice(t.priceInHOT)} wHOT</td>
2726
2838
  </tr>
2727
2839
  `)}
2728
2840
  `:""}
@@ -2731,7 +2843,7 @@ input VoiceActivityParamsInput {
2731
2843
  </div>
2732
2844
  `:""}
2733
2845
 
2734
- ${this.host.computeSpecs?I`
2846
+ ${this.host.computeSpecs?E`
2735
2847
  <div class="box">
2736
2848
  <div class="rates-section">
2737
2849
  <h3>Compute</h3>
@@ -2744,7 +2856,7 @@ input VoiceActivityParamsInput {
2744
2856
  Connect to ${this.host.name}
2745
2857
  </button>
2746
2858
  </div>
2747
- `:null}};Nr.styles=[Ke,Ee`
2859
+ `:null}};zt.styles=[Qe,$e`
2748
2860
  .profile {
2749
2861
  display: flex;
2750
2862
  flex-direction: column;
@@ -2753,8 +2865,8 @@ input VoiceActivityParamsInput {
2753
2865
  }
2754
2866
 
2755
2867
  .profile-pic {
2756
- width: 72px;
2757
- height: 72px;
2868
+ width: 100px;
2869
+ height: 100px;
2758
2870
  border-radius: 50%;
2759
2871
  object-fit: cover;
2760
2872
  background: rgba(128, 178, 201, 0.2);
@@ -2777,14 +2889,20 @@ input VoiceActivityParamsInput {
2777
2889
  }
2778
2890
 
2779
2891
  .profile-location {
2892
+ display: inline-flex;
2893
+ align-items: center;
2894
+ gap: 6px;
2780
2895
  font-size: 14px;
2781
2896
  color: rgba(255, 255, 255, 0.6);
2782
2897
  margin: 0;
2783
2898
  }
2784
2899
 
2900
+ .profile-location svg {
2901
+ opacity: 0.7;
2902
+ }
2903
+
2785
2904
  .profile-description {
2786
2905
  font-size: 14px;
2787
- color: rgba(255, 255, 255, 0.5);
2788
2906
  margin: 0;
2789
2907
  text-align: center;
2790
2908
  line-height: 1.4;
@@ -2858,61 +2976,68 @@ input VoiceActivityParamsInput {
2858
2976
  button.connect-button {
2859
2977
  width: 100%;
2860
2978
  }
2861
-
2862
- button.back-button {
2863
- all: unset;
2864
- cursor: pointer;
2865
- }
2866
- `],L([ie({type:Object})],Nr.prototype,"host",2),Nr=L([Ne("host-detail")],Nr);var gt=class extends ge{constructor(){super(...arguments);this.connectedHost=null;this.userInfo=null;this.requestingPayment=!1;this.paymentError=null;this.walletInput="";this.editingWallet=!1;this.paymentSuccess=!1}close(){this.dispatchEvent(new CustomEvent("close",{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.dispatchEvent(new CustomEvent("set-wallet-address",{detail:{address:t},bubbles:!0,composed:!0})))}requestTopUp(t){this.paymentSuccess=!1,this.dispatchEvent(new CustomEvent("request-top-up",{detail:{amountHOT:t},bubbles:!0,composed:!0}))}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}updated(t){var r;t.has("requestingPayment")&&!this.requestingPayment&&!this.paymentError&&t.get("requestingPayment")&&(this.paymentSuccess=!0,setTimeout(()=>{this.paymentSuccess=!1},4e3)),t.has("userInfo")&&((r=this.userInfo)==null?void 0:r.hotWalletAddress)&&!this.walletInput&&(this.walletInput=this.userInfo.hotWalletAddress)}render(){var r,n,a;let t=(n=(r=this.userInfo)==null?void 0:r.remainingCredits)!=null?n:0;return I`
2979
+ `],zt.OPERATION_RATES=new Set(["link write"]),C([ie({type:Object})],zt.prototype,"host",2),zt=C([Ne("host-detail")],zt);var Ae=class extends he{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,r=8,n=6){return t.length<=r+n+3?t:`${t.slice(0,r)}\u2026${t.slice(-n)}`}toggleActivityLog(){return oe(this,null,function*(){this.activityLogOpen=!this.activityLogOpen,this.activityLogOpen&&this.activityLog.length===0&&(yield this.loadActivityLog())})}loadActivityLog(){return oe(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 r=Date.now()-new Date(t).getTime(),n=Math.floor(r/1e3);if(n<60)return`${n}s ago`;let a=Math.floor(n/60);if(a<60)return`${a}m ago`;let s=Math.floor(a/60);return s<24?`${s}h ago`:`${Math.floor(s/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 r,n,a,s,o;t.has("requestingPayment")&&!this.requestingPayment&&!this.paymentError&&t.get("requestingPayment")&&(this.awaitingApproval=!0,this.previousCredits=(n=(r=this.userInfo)==null?void 0:r.remainingCredits)!=null?n:null),t.has("userInfo")&&this.awaitingApproval&&this.previousCredits!==null&&((s=(a=this.userInfo)==null?void 0:a.remainingCredits)!=null?s: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")&&((o=this.userInfo)==null?void 0:o.hotWalletAddress)&&!this.walletInput&&(this.walletInput=this.userInfo.hotWalletAddress)}render(){var r,n,a;let t=(n=(r=this.userInfo)==null?void 0:r.remainingCredits)!=null?n:0;return E`
2867
2980
  <div class="container">
2868
- <div class="close-button" @click=${this.close}>
2869
- ${Ue()}
2870
- </div>
2981
+ ${this.forceOpen?"":E`<div class="close-button" @click=${this.close}>${De()}</div>`}
2871
2982
 
2872
2983
  <div class="dashboard-header">
2873
2984
  <h1>Dashboard</h1>
2874
- ${this.connectedHost?I`
2985
+ ${this.connectedHost?E`
2986
+ <div class="host-badge">
2987
+ Connected to <strong>${this.connectedHost.name}</strong>
2988
+ </div>
2875
2989
  <div class="host-badge">
2876
- Connected to <strong>${this.connectedHost.name}</strong> · ${this.connectedHost.location}
2990
+ ${Kt()} ${this.connectedHost.location}
2877
2991
  </div>
2878
2992
  `:""}
2879
- ${(a=this.userInfo)!=null&&a.email?I`
2993
+ ${(a=this.userInfo)!=null&&a.email?E`
2880
2994
  <p class="email-display">${this.userInfo.email}</p>
2881
2995
  `:""}
2882
2996
  </div>
2883
2997
 
2884
2998
  <!-- Credit balance -->
2885
- ${this.isFreeAccess?I`
2999
+ ${this.isFreeAccess?E`
2886
3000
  <div class="credit-display free-access">
2887
- ${Hr()}
3001
+ ${Wt()}
2888
3002
  <span class="credit-amount">Free Access</span>
2889
3003
  </div>
2890
- `:I`
2891
- <div class="credit-display ${this.isDepleted?"depleted":""}">
2892
- ${Hr()}
3004
+ `:E`
3005
+ <div class="credit-display">
3006
+ ${Wt()}
2893
3007
  <span class="credit-amount">${t.toFixed(2)}</span>
2894
- <span class="credit-label">HOT</span>
3008
+ <span class="credit-label">wHOT</span>
2895
3009
  </div>
2896
3010
 
2897
- ${this.isDepleted?I`
3011
+ ${this.isDepleted?E`
2898
3012
  <div class="depleted-banner">Credits depleted — top up to continue using this host</div>
2899
3013
  `:""}
2900
3014
 
3015
+ ${this.hasWallet?"":E`
3016
+ <p style="font-size:15px;color:rgba(255,255,255,0.5);text-align:center;">
3017
+ Set your wallet address to enable top-ups
3018
+ </p>
3019
+ `}
3020
+
2901
3021
  <!-- Wallet address -->
2902
3022
  <div class="wallet-section">
2903
- <label>${Jn()} mHOT Wallet Address</label>
2904
- ${this.hasWallet&&!this.editingWallet?I`
3023
+ <label>${oa()} wHOT Wallet Address</label>
3024
+ ${this.hasWallet&&!this.editingWallet?E`
2905
3025
  <div class="wallet-row">
2906
- <div class="wallet-display">${this.userInfo.hotWalletAddress}</div>
3026
+ <div class="wallet-display" title=${this.userInfo.hotWalletAddress}>${this.truncateMiddle(this.userInfo.hotWalletAddress||"")}</div>
2907
3027
  <button class="secondary" @click=${()=>{this.editingWallet=!0,this.walletInput=this.userInfo.hotWalletAddress||""}}>
2908
3028
  Change
2909
3029
  </button>
2910
3030
  </div>
2911
- `:I`
3031
+ ${this.walletSaveSuccess?E`
3032
+ <div class="success-message" style="display:flex;align-items:center;justify-content:center;gap:6px;">
3033
+ ${Ke()} Wallet saved
3034
+ </div>
3035
+ `:""}
3036
+ `:E`
2912
3037
  <div class="wallet-row">
2913
3038
  <input
2914
3039
  type="text"
2915
- placeholder="Enter your mHOT wallet address"
3040
+ placeholder="Enter your wHOT wallet address"
2916
3041
  .value=${this.walletInput}
2917
3042
  @input=${s=>{this.walletInput=s.target.value}}
2918
3043
  @keydown=${s=>{s.key==="Enter"&&this.setWalletAddress()}}
@@ -2929,39 +3054,92 @@ input VoiceActivityParamsInput {
2929
3054
  `}
2930
3055
  </div>
2931
3056
 
2932
- <!-- Top-up buttons -->
2933
- <div class="topup-buttons">
2934
- ${[10,50,100].map(s=>I`
3057
+ <!-- Top-up -->
3058
+ <div class="topup-section">
3059
+ <label>${Wt()} Top Up Credits</label>
3060
+ <div class="wallet-row">
3061
+ <input
3062
+ type="number"
3063
+ min="1"
3064
+ placeholder="Amount in wHOT"
3065
+ .value=${this.topUpAmount}
3066
+ @input=${s=>{this.topUpAmount=s.target.value}}
3067
+ @keydown=${s=>{s.key==="Enter"&&this.topUpAmount&&Number(this.topUpAmount)>0&&this.requestTopUp(Number(this.topUpAmount))}}
3068
+ style="font-size: 14px;"
3069
+ />
2935
3070
  <button
2936
- class="secondary"
2937
- ?disabled=${!this.hasWallet||this.requestingPayment}
2938
- @click=${()=>this.requestTopUp(s)}
3071
+ class="primary"
3072
+ ?disabled=${this.topUpDisabled||!this.topUpAmount||Number(this.topUpAmount)<=0}
3073
+ @click=${()=>this.requestTopUp(Number(this.topUpAmount))}
2939
3074
  >
2940
- ${this.requestingPayment?"...":`${s} HOT`}
3075
+ ${this.requestingPayment?"...":"Top up"}
2941
3076
  </button>
2942
- `)}
3077
+ </div>
3078
+ <div class="topup-buttons">
3079
+ ${[100,500,1e3].map(s=>E`
3080
+ <button
3081
+ class="secondary"
3082
+ ?disabled=${this.topUpDisabled}
3083
+ @click=${()=>{this.topUpAmount=String(s),this.requestTopUp(s)}}
3084
+ >
3085
+ ${s} wHOT
3086
+ </button>
3087
+ `)}
3088
+ </div>
2943
3089
  </div>
2944
3090
 
2945
- ${this.hasWallet?"":I`
2946
- <p style="font-size:13px;color:rgba(255,255,255,0.4);text-align:center;">
2947
- Set your wallet address above to enable top-ups
2948
- </p>
2949
- `}
3091
+ ${this.awaitingApproval?E`
3092
+ <div class="pending-message">
3093
+ <div class="spinner"></div>
3094
+ Open Unyt app and approve the transaction
3095
+ </div>
3096
+ `:""}
2950
3097
 
2951
- ${this.paymentSuccess?I`
2952
- <div class="success-message">Payment request sent to Unit app</div>
3098
+ ${this.creditsUpdated?E`
3099
+ <div class="success-message" style="display:flex;align-items:center;justify-content:center;gap:6px;">
3100
+ ${Ke()} Credits updated!
3101
+ </div>
2953
3102
  `:""}
2954
3103
 
2955
- ${this.paymentError?I`
3104
+ ${this.paymentError?E`
2956
3105
  <div class="error-message">${this.paymentError}</div>
2957
3106
  `:""}
2958
3107
  `}
2959
3108
 
2960
- <button class="danger full" @click=${this.disconnect}>
2961
- Disconnect
2962
- </button>
3109
+ <!-- Activity Log -->
3110
+ <div class="activity-log-toggle" @click=${this.toggleActivityLog}>
3111
+ <span>Activity Log</span>
3112
+ <span class="chevron ${this.activityLogOpen?"open":""}">&#9654;</span>
3113
+ </div>
3114
+ ${this.activityLogOpen?E`
3115
+ ${this.activityLogLoading?E`
3116
+ <div class="activity-log-empty">Loading...</div>
3117
+ `:this.activityLog.length===0?E`
3118
+ <div class="activity-log-empty">No activity yet</div>
3119
+ `:E`
3120
+ <div class="activity-log-list">
3121
+ ${this.activityLog.map(s=>E`
3122
+ <div class="activity-log-entry">
3123
+ <span class="op-badge ${s.operation}">${this.formatOperation(s.operation)}</span>
3124
+ <span class="summary" title=${s.summary||""}>${s.summary||""}</span>
3125
+ <span class="cost">${s.cost.toFixed(2)}</span>
3126
+ <span class="time">${this.formatTimeAgo(s.timestamp)}</span>
3127
+ </div>
3128
+ `)}
3129
+ </div>
3130
+ `}
3131
+ `:""}
3132
+
3133
+ <div class="footer-actions">
3134
+ <button class="primary" ?disabled=${this.isDepleted&&!this.isFreeAccess} @click=${this._useApp}>
3135
+ Use app
3136
+ </button>
3137
+ <button class="danger-secondary" @click=${this.disconnect}>
3138
+ Disconnect
3139
+ </button>
3140
+ </div>
2963
3141
  </div>
2964
- `}};gt.styles=[Ke,Ee`
3142
+ `}};Ae.styles=[Qe,$e`
2965
3143
  .dashboard-header {
2966
3144
  text-align: center;
2967
3145
  }
@@ -2970,10 +3148,18 @@ input VoiceActivityParamsInput {
2970
3148
  display: flex;
2971
3149
  align-items: center;
2972
3150
  justify-content: center;
2973
- gap: 8px;
3151
+ gap: 5px;
2974
3152
  font-size: 14px;
2975
3153
  color: rgba(255, 255, 255, 0.6);
2976
- margin-top: 4px;
3154
+ margin-bottom: 8px;
3155
+ }
3156
+
3157
+ .host-badge strong {
3158
+ color: #ffffff;
3159
+ }
3160
+
3161
+ .host-badge svg {
3162
+ opacity: 0.7;
2977
3163
  }
2978
3164
 
2979
3165
  .credit-display {
@@ -3010,10 +3196,6 @@ input VoiceActivityParamsInput {
3010
3196
  box-shadow: 0 0 0 1px var(--ac-danger-color);
3011
3197
  }
3012
3198
 
3013
- .credit-display.depleted .credit-amount {
3014
- color: var(--ac-danger-color);
3015
- }
3016
-
3017
3199
  .credit-display.free-access {
3018
3200
  background: rgba(93, 210, 125, 0.14);
3019
3201
  box-shadow: 0 0 0 1px var(--ac-success-color);
@@ -3081,7 +3263,7 @@ input VoiceActivityParamsInput {
3081
3263
  background: #00091e5c;
3082
3264
  box-shadow: 0 0 0 1px var(--ac-border-color-light);
3083
3265
  font-size: 14px;
3084
- color: var(--ac-primary-color);
3266
+ color: var(--ac-primary-color-light);
3085
3267
  font-family: monospace;
3086
3268
  overflow: hidden;
3087
3269
  text-overflow: ellipsis;
@@ -3089,6 +3271,29 @@ input VoiceActivityParamsInput {
3089
3271
  flex: 1;
3090
3272
  }
3091
3273
 
3274
+ .topup-section {
3275
+ display: flex;
3276
+ flex-direction: column;
3277
+ gap: 10px;
3278
+ }
3279
+
3280
+ .topup-section label {
3281
+ display: flex;
3282
+ align-items: center;
3283
+ gap: 6px;
3284
+ font-size: 13px;
3285
+ color: rgba(255, 255, 255, 0.6);
3286
+ text-transform: uppercase;
3287
+ letter-spacing: 0.5px;
3288
+ font-weight: 600;
3289
+ }
3290
+
3291
+ .topup-section label svg {
3292
+ width: 16px;
3293
+ height: 16px;
3294
+ color: var(--ac-primary-color);
3295
+ }
3296
+
3092
3297
  .topup-buttons {
3093
3298
  display: flex;
3094
3299
  gap: 8px;
@@ -3101,6 +3306,26 @@ input VoiceActivityParamsInput {
3101
3306
  height: 42px;
3102
3307
  }
3103
3308
 
3309
+ .pending-message {
3310
+ display: flex;
3311
+ align-items: center;
3312
+ justify-content: center;
3313
+ gap: 8px;
3314
+ text-align: center;
3315
+ padding: 10px;
3316
+ border-radius: 8px;
3317
+ background: rgba(128, 178, 201, 0.14);
3318
+ box-shadow: 0 0 0 1px var(--ac-border-color-light);
3319
+ color: rgba(255, 255, 255, 0.8);
3320
+ font-size: 14px;
3321
+ }
3322
+
3323
+ .pending-message .spinner {
3324
+ width: 16px;
3325
+ height: 16px;
3326
+ flex-shrink: 0;
3327
+ }
3328
+
3104
3329
  .success-message {
3105
3330
  text-align: center;
3106
3331
  padding: 10px;
@@ -3111,6 +3336,12 @@ input VoiceActivityParamsInput {
3111
3336
  font-weight: 600;
3112
3337
  }
3113
3338
 
3339
+ .success-message svg {
3340
+ width: 16px;
3341
+ height: 16px;
3342
+ flex-shrink: 0;
3343
+ }
3344
+
3114
3345
  .error-message {
3115
3346
  text-align: center;
3116
3347
  padding: 10px;
@@ -3126,10 +3357,121 @@ input VoiceActivityParamsInput {
3126
3357
  text-align: center;
3127
3358
  }
3128
3359
 
3360
+ .footer-actions {
3361
+ display: flex;
3362
+ justify-content: center;
3363
+ gap: 8px;
3364
+ }
3365
+
3129
3366
  button.full {
3130
3367
  width: 100%;
3131
3368
  }
3132
- `],L([ie({type:Object})],gt.prototype,"connectedHost",2),L([ie({type:Object})],gt.prototype,"userInfo",2),L([ie({type:Boolean})],gt.prototype,"requestingPayment",2),L([ie({type:String})],gt.prototype,"paymentError",2),L([Y()],gt.prototype,"walletInput",2),L([Y()],gt.prototype,"editingWallet",2),L([Y()],gt.prototype,"paymentSuccess",2),gt=L([Ne("logged-in-dashboard")],gt);var Ug=Ee`
3369
+
3370
+ .activity-log-toggle {
3371
+ display: flex;
3372
+ align-items: center;
3373
+ justify-content: space-between;
3374
+ cursor: pointer;
3375
+ padding: 10px 12px;
3376
+ border-radius: 8px;
3377
+ background: rgba(128, 178, 201, 0.08);
3378
+ box-shadow: 0 0 0 1px var(--ac-border-color-light);
3379
+ font-size: 14px;
3380
+ color: rgba(255, 255, 255, 0.7);
3381
+ user-select: none;
3382
+ }
3383
+
3384
+ .activity-log-toggle:hover {
3385
+ background: rgba(128, 178, 201, 0.14);
3386
+ }
3387
+
3388
+ .activity-log-toggle .chevron {
3389
+ transition: transform 0.2s;
3390
+ font-size: 12px;
3391
+ }
3392
+
3393
+ .activity-log-toggle .chevron.open {
3394
+ transform: rotate(90deg);
3395
+ }
3396
+
3397
+ .activity-log-list {
3398
+ max-height: 200px;
3399
+ overflow-y: auto;
3400
+ display: flex;
3401
+ flex-direction: column;
3402
+ gap: 4px;
3403
+ }
3404
+
3405
+ .activity-log-entry {
3406
+ display: flex;
3407
+ align-items: center;
3408
+ justify-content: space-between;
3409
+ padding: 6px 10px;
3410
+ border-radius: 6px;
3411
+ background: rgba(128, 178, 201, 0.06);
3412
+ font-size: 13px;
3413
+ color: rgba(255, 255, 255, 0.75);
3414
+ }
3415
+
3416
+ .activity-log-entry .op-badge {
3417
+ display: inline-block;
3418
+ padding: 2px 6px;
3419
+ border-radius: 4px;
3420
+ font-size: 11px;
3421
+ font-weight: 600;
3422
+ text-transform: uppercase;
3423
+ letter-spacing: 0.03em;
3424
+ }
3425
+
3426
+ .activity-log-entry .op-badge.ai_prompt {
3427
+ background: rgba(168, 130, 255, 0.2);
3428
+ color: #c4a8ff;
3429
+ }
3430
+
3431
+ .activity-log-entry .op-badge.ai_transcription {
3432
+ background: rgba(168, 130, 255, 0.2);
3433
+ color: #c4a8ff;
3434
+ }
3435
+
3436
+ .activity-log-entry .op-badge.ai_embed {
3437
+ background: rgba(130, 200, 255, 0.2);
3438
+ color: #a8d8ff;
3439
+ }
3440
+
3441
+ .activity-log-entry .op-badge.link_write {
3442
+ background: rgba(255, 200, 100, 0.2);
3443
+ color: #ffd080;
3444
+ }
3445
+
3446
+ .activity-log-entry .cost {
3447
+ font-weight: 600;
3448
+ color: #ffffff;
3449
+ white-space: nowrap;
3450
+ }
3451
+
3452
+ .activity-log-entry .time {
3453
+ font-size: 11px;
3454
+ color: rgba(255, 255, 255, 0.4);
3455
+ white-space: nowrap;
3456
+ }
3457
+
3458
+ .activity-log-entry .summary {
3459
+ flex: 1;
3460
+ margin: 0 8px;
3461
+ overflow: hidden;
3462
+ text-overflow: ellipsis;
3463
+ white-space: nowrap;
3464
+ color: rgba(255, 255, 255, 0.5);
3465
+ font-size: 12px;
3466
+ }
3467
+
3468
+ .activity-log-empty {
3469
+ text-align: center;
3470
+ padding: 12px;
3471
+ color: rgba(255, 255, 255, 0.4);
3472
+ font-size: 13px;
3473
+ }
3474
+ `],C([ie({type:Object})],Ae.prototype,"connectedHost",2),C([ie({type:Object})],Ae.prototype,"userInfo",2),C([ie({type:Boolean})],Ae.prototype,"requestingPayment",2),C([ie({type:String})],Ae.prototype,"paymentError",2),C([ie({type:Boolean})],Ae.prototype,"forceOpen",2),C([Z()],Ae.prototype,"walletInput",2),C([Z()],Ae.prototype,"editingWallet",2),C([Z()],Ae.prototype,"walletSaveSuccess",2),C([Z()],Ae.prototype,"topUpAmount",2),C([Z()],Ae.prototype,"awaitingApproval",2),C([Z()],Ae.prototype,"creditsUpdated",2),C([Z()],Ae.prototype,"activityLogOpen",2),C([Z()],Ae.prototype,"activityLog",2),C([Z()],Ae.prototype,"activityLogLoading",2),Ae=C([Ne("logged-in-dashboard")],Ae);var cm=$e`
3133
3475
  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap');
3134
3476
 
3135
3477
  :host {
@@ -3185,6 +3527,7 @@ input VoiceActivityParamsInput {
3185
3527
  }
3186
3528
 
3187
3529
  .modal-header {
3530
+ position: relative;
3188
3531
  display: flex;
3189
3532
  align-items: center;
3190
3533
  justify-content: center;
@@ -3197,6 +3540,28 @@ input VoiceActivityParamsInput {
3197
3540
  height: 70px;
3198
3541
  }
3199
3542
 
3543
+ .modal-header .back-button {
3544
+ all: unset;
3545
+ display: inline-flex;
3546
+ align-items: center;
3547
+ gap: 8px;
3548
+ cursor: pointer;
3549
+ font-size: 16px;
3550
+ color: rgba(255, 255, 255, 0.5);
3551
+ position: absolute;
3552
+ left: 0;
3553
+ top: 0;
3554
+ }
3555
+
3556
+ .modal-header .back-button svg {
3557
+ width: 20px;
3558
+ height: 20px;
3559
+ }
3560
+
3561
+ .modal-header .back-button:hover {
3562
+ color: rgba(255, 255, 255, 0.8);
3563
+ }
3564
+
3200
3565
  .modal-content {
3201
3566
  display: flex;
3202
3567
  flex-direction: column;
@@ -3205,19 +3570,52 @@ input VoiceActivityParamsInput {
3205
3570
  min-height: 0;
3206
3571
  }
3207
3572
 
3573
+ .settings-bar {
3574
+ position: fixed;
3575
+ bottom: 10px;
3576
+ right: 10px;
3577
+ display: flex;
3578
+ align-items: center;
3579
+ gap: 6px;
3580
+ z-index: 99999;
3581
+ }
3582
+
3583
+ .credit-badge {
3584
+ display: flex;
3585
+ align-items: center;
3586
+ gap: 4px;
3587
+ background: var(--ac-background-color);
3588
+ backdrop-filter: blur(10px);
3589
+ -webkit-backdrop-filter: blur(10px);
3590
+ border: 1px solid var(--ac-border-color-dark);
3591
+ border-radius: 20px;
3592
+ padding: 4px 10px;
3593
+ font-size: 12px;
3594
+ font-weight: 500;
3595
+ color: var(--ac-primary-color);
3596
+ white-space: nowrap;
3597
+ }
3598
+
3599
+ .credit-badge svg {
3600
+ width: 14px;
3601
+ height: 14px;
3602
+ }
3603
+
3604
+ .credit-badge.low-credit {
3605
+ color: var(--ac-danger-color);
3606
+ border-color: var(--ac-danger-color);
3607
+ animation: pulse-danger 2s ease-in-out infinite;
3608
+ }
3609
+
3208
3610
  .settings-button {
3209
3611
  appearance: none;
3210
3612
  border: none;
3211
3613
  background: transparent;
3212
3614
  padding: 0;
3213
3615
  cursor: pointer;
3214
- position: fixed;
3215
- bottom: 10px;
3216
- right: 10px;
3217
3616
  color: var(--ac-primary-color);
3218
3617
  width: 34px;
3219
3618
  height: 34px;
3220
- z-index: 99999;
3221
3619
  }
3222
3620
 
3223
3621
  .settings-button.low-credit {
@@ -3229,7 +3627,7 @@ input VoiceActivityParamsInput {
3229
3627
  0%, 100% { opacity: 1; }
3230
3628
  50% { opacity: 0.4; }
3231
3629
  }
3232
- `,be=class extends ge{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}connectedCallback(){super.connectedCallback(),$s(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 r=t.detail;((n=this.userInfo)==null?void 0:n.hotWalletAddress)&&!r.hotWalletAddress&&(r.hotWalletAddress=this.userInfo.hotWalletAddress),this.userInfo=r,this.lowCredit=this.userInfo.remainingCredits<=10,this.requestUpdate()}),this.core.addEventListener("creditdepleted",()=>{this.lowCredit=!0,this.requestUpdate()}),this.core.token?this.core.connect().then(()=>{this.core.connectedHost&&(this.selectedHost=this.core.connectedHost,this.core.startCreditPolling())}).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 pe(this,null,function*(){this.core.port=t.detail.port,Br("ad4m-port",this.core.port.toString()),this.requestUpdate()})}connectLocalNode(){return pe(this,null,function*(){this.core.url=`ws://localhost:${this.core.port}/graphql`,Br("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 pe(this,null,function*(){let r=yield this.core.verifyLocalAd4mCode(t.detail.code);this.verificationError=!r,r&&(this.modalOpen=!1)})}browseHosts(){return pe(this,null,function*(){this.hostsLoading=!0,this.hostsError=null,this.currentView="host-browser";try{this.hosts=yield As(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 pe(this,null,function*(){this.hostsLoading=!0,this.hostsError=null;try{this.hosts=yield As(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 pe(this,null,function*(){let r=t.detail.host;this.selectedHost=r;let n=r.url;try{yield qr(n),console.log("[Ad4m Connect UI] Host connection successful:",r.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");Br("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 pe(this,null,function*(){this.selectedHost?(this.core.setConnectedHost(this.selectedHost),this.core.startCreditPolling(),this.currentView="logged-in-dashboard"):this.modalOpen=!1})}handleRequestTopUp(t){return pe(this,null,function*(){this.requestingPayment=!0,this.paymentError=null;try{let r=yield this.core.requestTopUp(t.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(t){return pe(this,null,function*(){try{yield this.core.ad4mClient.agent.setHotWalletAddress(t.detail.address),this.userInfo&&(this.userInfo=Fo(Mo({},this.userInfo),{hotWalletAddress:t.detail.address}))}catch(r){console.error("[Ad4m Connect] Failed to set wallet address:",r)}})}connectRemoteNode(t){return pe(this,null,function*(){this.core.url=t.detail.remoteUrl,Br("ad4m-url",this.core.url);try{if(yield qr(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(r){console.error("[Ad4m Connect UI] Remote connection failed:",r)}})}emailLogin(t){return pe(this,null,function*(){try{this.remoteAuthLoading=!0,this.remoteAuthState=yield this.core.submitEmail(t.detail.email)}finally{this.remoteAuthLoading=!1}})}verifyEmailCode(t){return pe(this,null,function*(){try{this.remoteAuthLoading=!0;let r=yield this.core.verifyEmailCode(t.detail.email,t.detail.code);this.emailCodeError=!r,r&&(yield this.handleAuthSuccess())}catch(r){this.emailCodeError=!0}finally{this.remoteAuthLoading=!1}})}passwordLogin(t){return pe(this,null,function*(){try{this.remoteAuthLoading=!0;let r=yield this.core.loginWithPassword(t.detail.email,t.detail.password);this.passwordError=!r,r&&(yield this.handleAuthSuccess())}catch(r){this.passwordError=!0}finally{this.remoteAuthLoading=!1}})}createAccount(t){return pe(this,null,function*(){try{this.remoteAuthLoading=!0;let r=yield this.core.createAccount(t.detail.email,t.detail.password);this.accountCreationError=!r,r&&(yield this.handleAuthSuccess())}catch(r){this.accountCreationError=!0}finally{this.remoteAuthLoading=!1}})}disconnect(){return pe(this,null,function*(){yield this.core.disconnect(),window.location.reload()})}renderViews(){var t,r,n;if(this.currentView==="connection-options")return I`
3630
+ `,ve=class extends he{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(),Ns(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 r=t.detail;((n=this.userInfo)==null?void 0:n.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 t,r;if(this.lowCredit=!0,this.core.connectedHost){this.openedDueToCreditDepletion=!0;try{(r=(t=this.core.options).onCreditsDepleted)==null||r.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 oe(this,null,function*(){this.core.port=t.detail.port,Wr("ad4m-port",this.core.port.toString()),this.requestUpdate()})}connectLocalNode(){return oe(this,null,function*(){this.core.url=`ws://localhost:${this.core.port}/graphql`,Wr("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 oe(this,null,function*(){let r=yield this.core.verifyLocalAd4mCode(t.detail.code);this.verificationError=!r,r&&(this.modalOpen=!1)})}browseHosts(){return oe(this,null,function*(){this.hostsLoading=!0,this.hostsError=null,this.currentView="host-browser";try{this.hosts=yield Os(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 oe(this,null,function*(){this.hostsLoading=!0,this.hostsError=null;try{this.hosts=yield Os(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 oe(this,null,function*(){let r=t.detail.host;this.selectedHost=r;let n=r.url;try{yield Kr(n),console.log("[Ad4m Connect UI] Host connection successful:",r.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");Wr("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 oe(this,null,function*(){this.selectedHost?(this.core.setConnectedHost(this.selectedHost),this.core.startCreditSubscription(),this.currentView="logged-in-dashboard"):this.modalOpen=!1})}handleRequestTopUp(t){return oe(this,null,function*(){this.requestingPayment=!0,this.paymentError=null;try{let r=yield this.core.requestTopUp(t.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(t){return oe(this,null,function*(){try{yield this.core.ad4mClient.agent.setHotWalletAddress(t.detail.address),this.userInfo&&(this.userInfo=Go(Qo({},this.userInfo),{hotWalletAddress:t.detail.address}))}catch(r){console.error("[Ad4m Connect] Failed to set wallet address:",r)}})}connectRemoteNode(t){return oe(this,null,function*(){this.core.url=t.detail.remoteUrl,Wr("ad4m-url",this.core.url);try{if(yield Kr(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(r){console.error("[Ad4m Connect UI] Remote connection failed:",r)}})}emailLogin(t){return oe(this,null,function*(){try{this.remoteAuthLoading=!0,this.remoteAuthState=yield this.core.submitEmail(t.detail.email)}finally{this.remoteAuthLoading=!1}})}verifyEmailCode(t){return oe(this,null,function*(){try{this.remoteAuthLoading=!0;let r=yield this.core.verifyEmailCode(t.detail.email,t.detail.code);this.emailCodeError=!r,r&&(yield this.handleAuthSuccess())}catch(r){this.emailCodeError=!0}finally{this.remoteAuthLoading=!1}})}passwordLogin(t){return oe(this,null,function*(){try{this.remoteAuthLoading=!0;let r=yield this.core.loginWithPassword(t.detail.email,t.detail.password);this.passwordError=!r,r&&(yield this.handleAuthSuccess())}catch(r){this.passwordError=!0}finally{this.remoteAuthLoading=!1}})}createAccount(t){return oe(this,null,function*(){try{this.remoteAuthLoading=!0;let r=yield this.core.createAccount(t.detail.email,t.detail.password);this.accountCreationError=!r,r&&(yield this.handleAuthSuccess())}catch(r){this.accountCreationError=!0}finally{this.remoteAuthLoading=!1}})}disconnect(){return oe(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,r,n;if(this.currentView==="connection-options")return E`
3233
3631
  <connection-options
3234
3632
  .port=${this.core.port}
3235
3633
  .showHosting=${!!this.core.options.hosting}
@@ -3237,7 +3635,7 @@ input VoiceActivityParamsInput {
3237
3635
  @connect-local-node=${this.connectLocalNode}
3238
3636
  @browse-hosts=${this.browseHosts}
3239
3637
  ></connection-options>
3240
- `;if(this.currentView==="local-authentication")return I`
3638
+ `;if(this.currentView==="local-authentication")return E`
3241
3639
  <local-authentication
3242
3640
  .capabilities=${this.core.options.capabilities}
3243
3641
  .appname=${this.core.options.appInfo.name}
@@ -3248,7 +3646,7 @@ input VoiceActivityParamsInput {
3248
3646
  @verify-code=${this.verifyLocalAd4mCode}
3249
3647
  @clear-verification-error=${()=>{this.verificationError=!1}}
3250
3648
  ></local-authentication>
3251
- `;if(this.currentView==="host-browser")return I`
3649
+ `;if(this.currentView==="host-browser")return E`
3252
3650
  <host-browser
3253
3651
  .hosts=${this.hosts}
3254
3652
  .loading=${this.hostsLoading}
@@ -3259,13 +3657,13 @@ input VoiceActivityParamsInput {
3259
3657
  @back=${()=>{this.currentView="connection-options"}}
3260
3658
  @retry=${this.retryFetchHosts}
3261
3659
  ></host-browser>
3262
- `;if(this.currentView==="host-detail")return I`
3660
+ `;if(this.currentView==="host-detail")return E`
3263
3661
  <host-detail
3264
3662
  .host=${this.selectedHost}
3265
3663
  @proceed-to-auth=${this.proceedToAuth}
3266
3664
  @back=${()=>{this.currentView="host-browser"}}
3267
3665
  ></host-detail>
3268
- `;if(this.currentView==="remote-authentication")return I`
3666
+ `;if(this.currentView==="remote-authentication")return E`
3269
3667
  <remote-authentication
3270
3668
  .host=${this.selectedHost}
3271
3669
  .remoteAuthLoading=${this.remoteAuthLoading}
@@ -3279,19 +3677,23 @@ input VoiceActivityParamsInput {
3279
3677
  @password-login=${this.passwordLogin}
3280
3678
  @create-account=${this.createAccount}
3281
3679
  @clear-email-code-error=${()=>{this.emailCodeError=!1}}
3680
+ @reset-auth-state=${()=>{this.resetRemoteAuthState()}}
3282
3681
  ></remote-authentication>
3283
- `;if(this.currentView==="logged-in-dashboard")return I`
3682
+ `;if(this.currentView==="logged-in-dashboard")return E`
3284
3683
  <logged-in-dashboard
3285
3684
  .connectedHost=${this.core.connectedHost}
3286
3685
  .userInfo=${this.userInfo}
3287
3686
  .requestingPayment=${this.requestingPayment}
3288
3687
  .paymentError=${this.paymentError}
3289
- @close=${()=>{this.modalOpen=!1}}
3688
+ .forceOpen=${this.openedDueToCreditDepletion}
3689
+ @close=${()=>{this.openedDueToCreditDepletion=!1,this.modalOpen=!1}}
3690
+ @use-app=${()=>{var a,s;this.openedDueToCreditDepletion=!1;try{(s=(a=this.core.options).onUseApp)==null||s.call(a)}catch(o){console.error("[Ad4m Connect] onUseApp callback error:",o)}this.modalOpen=!1}}
3290
3691
  @disconnect=${this.disconnect}
3291
3692
  @request-top-up=${this.handleRequestTopUp}
3292
3693
  @set-wallet-address=${this.handleSetWalletAddress}
3694
+ @fetch-compute-log=${a=>{var o;let s=(o=a==null?void 0:a.detail)==null?void 0:o.callback;typeof s=="function"&&this.core.fetchComputeLog().then(s).catch(c=>{console.error("[Ad4m Connect] Failed to fetch compute log:",c),s([])})}}
3293
3695
  ></logged-in-dashboard>
3294
- `;if(this.currentView==="current-state")return I`
3696
+ `;if(this.currentView==="current-state")return E`
3295
3697
  <current-state
3296
3698
  .url=${this.core.url}
3297
3699
  .port=${this.core.port}
@@ -3299,11 +3701,16 @@ input VoiceActivityParamsInput {
3299
3701
  @close=${()=>{this.modalOpen=!1}}
3300
3702
  @disconnect=${this.disconnect}
3301
3703
  ></current-state>
3302
- `}render(){return this.modalOpen?I`
3704
+ `}render(){var t;if(this.modalOpen)return E`
3303
3705
  <div class="wrapper">
3304
3706
  <div class="modal">
3305
3707
  <header class="modal-header">
3306
- ${_i()}
3708
+ ${this.backTarget?E`
3709
+ <button class="back-button" aria-label="Go back" @click=${this.handleBack}>
3710
+ ${aa()} Back
3711
+ </button>
3712
+ `:""}
3713
+ ${Ei()}
3307
3714
  </header>
3308
3715
  <main class="modal-content">
3309
3716
  ${this.renderViews()}
@@ -3311,16 +3718,23 @@ input VoiceActivityParamsInput {
3311
3718
  </div>
3312
3719
  <div class="backdrop" />
3313
3720
  </div>
3314
- `:this.core.authState==="authenticated"?I`
3315
- <button
3316
- type="button"
3317
- class="settings-button ${this.lowCredit?"low-credit":""}"
3318
- aria-label="Open settings"
3319
- @click=${()=>{this.currentView=this.core.connectedHost?"logged-in-dashboard":"current-state",this.modalOpen=!0}}
3320
- >
3321
- ${_i()}
3322
- </button>
3323
- `:null}};be.styles=[Ug],L([Y()],be.prototype,"modalOpen",2),L([Y()],be.prototype,"currentView",2),L([Y()],be.prototype,"verificationError",2),L([Y()],be.prototype,"remoteAuthLoading",2),L([Y()],be.prototype,"remoteAuthState",2),L([Y()],be.prototype,"emailCodeError",2),L([Y()],be.prototype,"passwordError",2),L([Y()],be.prototype,"accountCreationError",2),L([Y()],be.prototype,"hosts",2),L([Y()],be.prototype,"hostsLoading",2),L([Y()],be.prototype,"hostsError",2),L([Y()],be.prototype,"selectedHost",2),L([Y()],be.prototype,"userInfo",2),L([Y()],be.prototype,"lowCredit",2),L([Y()],be.prototype,"requestingPayment",2),L([Y()],be.prototype,"paymentError",2),be=L([Ne("ad4m-connect")],be);function Mg(i){let e=new be;return e.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(e)),e}export{be as Ad4mConnectElement,Mg as default};
3721
+ `;if(this.core.authState==="authenticated"){let r=(t=this.userInfo)==null?void 0:t.remainingCredits;return E`
3722
+ <div class="settings-bar">
3723
+ ${r!=null?E`
3724
+ <span class="credit-badge ${this.lowCredit?"low-credit":""}">
3725
+ ${Wt()} ${r.toFixed(2)} wHOT
3726
+ </span>
3727
+ `:""}
3728
+ <button
3729
+ type="button"
3730
+ class="settings-button ${this.lowCredit?"low-credit":""}"
3731
+ aria-label="Open settings"
3732
+ @click=${()=>{this.currentView=this.core.connectedHost?"logged-in-dashboard":"current-state",this.modalOpen=!0}}
3733
+ >
3734
+ ${Ei()}
3735
+ </button>
3736
+ </div>
3737
+ `}return null}};ve.styles=[cm],C([Z()],ve.prototype,"modalOpen",2),C([Z()],ve.prototype,"currentView",2),C([Z()],ve.prototype,"verificationError",2),C([Z()],ve.prototype,"remoteAuthLoading",2),C([Z()],ve.prototype,"remoteAuthState",2),C([Z()],ve.prototype,"emailCodeError",2),C([Z()],ve.prototype,"passwordError",2),C([Z()],ve.prototype,"accountCreationError",2),C([Z()],ve.prototype,"hosts",2),C([Z()],ve.prototype,"hostsLoading",2),C([Z()],ve.prototype,"hostsError",2),C([Z()],ve.prototype,"selectedHost",2),C([Z()],ve.prototype,"userInfo",2),C([Z()],ve.prototype,"lowCredit",2),C([Z()],ve.prototype,"requestingPayment",2),C([Z()],ve.prototype,"paymentError",2),ve=C([Ne("ad4m-connect")],ve);function lm(i){let e=new ve;return e.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(e)),e}export{ve as Ad4mConnectElement,lm as default};
3324
3738
  /*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */
3325
3739
  /**
3326
3740
  * @license