From d132dd4bd2fd8611d146ca3658d60474113db5bd Mon Sep 17 00:00:00 2001 From: joelchu Date: Fri, 13 Dec 2019 15:43:12 +0800 Subject: [PATCH] jsonql-client 1.5.9 --- packages/http-client/core.js | 2 +- packages/http-client/dist/jsonql-client.static.js | 2 +- packages/http-client/dist/jsonql-client.umd.js | 2 +- packages/http-client/package.json | 6 +++--- packages/http-client/static.js | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/http-client/core.js b/packages/http-client/core.js index a277147c..a1c2765b 100644 --- a/packages/http-client/core.js +++ b/packages/http-client/core.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r="query",n="mutation",o="socket",i="payload",a="condition",u="TS",c=["POST","PUT"],s="type",f="optional",l="enumv",p="args",h="checker",d="alias",v="__checked__",g={desc:"y"},y="No message",b=Array.isArray,_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},m="object"==typeof _&&_&&_.Object===Object&&_,w="object"==typeof self&&self&&self.Object===Object&&self,j=m||w||Function("return this")(),S=j.Symbol,O=Object.prototype,k=O.hasOwnProperty,A=O.toString,E=S?S.toStringTag:void 0;var T=Object.prototype.toString;var x="[object Null]",P="[object Undefined]",q=S?S.toStringTag:void 0;function C(t){return null==t?void 0===t?P:x:q&&q in Object(t)?function(t){var e=k.call(t,E),r=t[E];try{t[E]=void 0;var n=!0}catch(t){}var o=A.call(t);return n&&(e?t[E]=r:delete t[E]),o}(t):function(t){return T.call(t)}(t)}function $(t,e){return function(r){return t(e(r))}}var z=$(Object.getPrototypeOf,Object);function N(t){return null!=t&&"object"==typeof t}var M="[object Object]",I=Function.prototype,R=Object.prototype,F=I.toString,J=R.hasOwnProperty,U=F.call(Object);function D(t){if(!N(t)||C(t)!=M)return!1;var e=z(t);if(null===e)return!0;var r=J.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&F.call(r)==U}function L(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&X(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var dt=function(t){return b(t)?t:[t]},vt=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},gt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),yt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),bt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),_t=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),mt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),wt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),jt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),St=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),Ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),kt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),At=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),Et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),Tt=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),xt=Object.freeze({__proto__:null,Jsonql406Error:gt,Jsonql500Error:yt,JsonqlForbiddenError:bt,JsonqlAuthorisationError:_t,JsonqlContractAuthError:mt,JsonqlResolverAppError:wt,JsonqlResolverNotFoundError:jt,JsonqlEnumError:St,JsonqlTypeError:Ot,JsonqlCheckerError:kt,JsonqlValidationError:At,JsonqlError:Et,JsonqlServerError:Tt}),Pt=Et,qt=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function Ct(t){if(qt(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||y,a=e.detail||e;if(o&&xt[o])throw new xt[r](i,a);throw new Pt(i,a)}return t}function $t(t){if(Array.isArray(t))throw new At("",t);var e=t.message||y,r=t.detail||t;switch(!0){case t instanceof gt:throw new gt(e,r);case t instanceof yt:throw new yt(e,r);case t instanceof bt:throw new bt(e,r);case t instanceof _t:throw new _t(e,r);case t instanceof mt:throw new mt(e,r);case t instanceof wt:throw new wt(e,r);case t instanceof jt:throw new jt(e,r);case t instanceof St:throw new St(e,r);case t instanceof Ot:throw new Ot(e,r);case t instanceof kt:throw new kt(e,r);case t instanceof At:throw new At(e,r);case t instanceof Tt:throw new Tt(e,r);default:throw new Et(e,r)}}function zt(t){return!!function(t){return D(t)&&(vt(t,r)||vt(t,n)||vt(t,o))}(t)&&t}function Nt(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}var Mt=function(t,e){return void 0===e&&(e={}),zt(e)?Promise.resolve(e):t.getContract()},It="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Rt(t){this.message=t}Rt.prototype=new Error,Rt.prototype.name="InvalidCharacterError";var Ft="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Rt("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=It.indexOf(n);return a};var Jt=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Ft(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return Ft(e)}};function Ut(t){this.message=t}Ut.prototype=new Error,Ut.prototype.name="InvalidTokenError";var Dt=function(t,e){if("string"!=typeof t)throw new Ut("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Jt(t.split(".")[r]))}catch(t){throw new Ut("Invalid token specified: "+t.message)}},Lt=Ut;Dt.InvalidTokenError=Lt;var Ht="[object String]";function Kt(t){return"string"==typeof t||!b(t)&&N(t)&&C(t)==Ht}var Bt=function(t){return""!==ht(t)&&Kt(t)},Gt=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Vt(t){if(Bt(t))return function(t){var e=t.iat||Gt(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new Et("Token has expired on "+r,t)}return t}(Dt(t));throw new Et("Token must be a string!")}var Wt=function(t){return!!b(t)||null!=t&&""!==ht(t)},Yt="[object Number]";function Qt(t){return function(t){return"number"==typeof t||N(t)&&C(t)==Yt}(t)&&t!=+t}var Xt=function(t){return!Kt(t)&&!Qt(parseFloat(t))},Zt=function(t){return null!=t&&"boolean"==typeof t},te=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==ht(t)&&(!1===e||!0===e&&null!==t)},ee=s,re=f,ne=l,oe=p,ie=h,ae=d,ue="continue",ce=function(t){switch(t){case"number":return Xt;case"string":return Bt;case"boolean":return Zt;default:return te}},se=function(t,e){return void 0===e&&(e=""),!!b(t)&&(""===e||""===ht(e)||!(t.filter((function(t){return!ce(e)(t)})).length>0))},fe=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},le=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!ce(e)(t)})).length)})).length:e.length>e.filter((function(t){return!se(r,t)})).length};var pe,he=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[pe?a:++n];if(!1===e(o[u],u,o))break}return t};var de="[object Arguments]";function ve(t){return N(t)&&C(t)==de}var ge=Object.prototype,ye=ge.hasOwnProperty,be=ge.propertyIsEnumerable,_e=ve(function(){return arguments}())?ve:function(t){return N(t)&&ye.call(t,"callee")&&!be.call(t,"callee")};var me="object"==typeof exports&&exports&&!exports.nodeType&&exports,we=me&&"object"==typeof module&&module&&!module.nodeType&&module,je=we&&we.exports===me?j.Buffer:void 0,Se=(je?je.isBuffer:void 0)||function(){return!1},Oe=9007199254740991,ke=/^(?:0|[1-9]\d*)$/;function Ae(t,e){var r=typeof t;return!!(e=null==e?Oe:e)&&("number"==r||"symbol"!=r&&ke.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Ee}var xe={};xe["[object Float32Array]"]=xe["[object Float64Array]"]=xe["[object Int8Array]"]=xe["[object Int16Array]"]=xe["[object Int32Array]"]=xe["[object Uint8Array]"]=xe["[object Uint8ClampedArray]"]=xe["[object Uint16Array]"]=xe["[object Uint32Array]"]=!0,xe["[object Arguments]"]=xe["[object Array]"]=xe["[object ArrayBuffer]"]=xe["[object Boolean]"]=xe["[object DataView]"]=xe["[object Date]"]=xe["[object Error]"]=xe["[object Function]"]=xe["[object Map]"]=xe["[object Number]"]=xe["[object Object]"]=xe["[object RegExp]"]=xe["[object Set]"]=xe["[object String]"]=xe["[object WeakMap]"]=!1;var Pe,qe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ce=qe&&"object"==typeof module&&module&&!module.nodeType&&module,$e=Ce&&Ce.exports===qe&&m.process,ze=function(){try{var t=Ce&&Ce.require&&Ce.require("util").types;return t||$e&&$e.binding&&$e.binding("util")}catch(t){}}(),Ne=ze&&ze.isTypedArray,Me=Ne?(Pe=Ne,function(t){return Pe(t)}):function(t){return N(t)&&Te(t.length)&&!!xe[C(t)]},Ie=Object.prototype.hasOwnProperty;function Re(t,e){var r=b(t),n=!r&&_e(t),o=!r&&!n&&Se(t),i=!r&&!n&&!o&&Me(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},er.prototype.set=function(t,e){var r=this.__data__,n=Ze(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var rr,nr=j["__core-js_shared__"],or=(rr=/[^.]+$/.exec(nr&&nr.keys&&nr.keys.IE_PROTO||""))?"Symbol(src)_1."+rr:"";var ir=Function.prototype.toString;function ar(t){if(null!=t){try{return ir.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ur=/^\[object .+?Constructor\]$/,cr=Function.prototype,sr=Object.prototype,fr=cr.toString,lr=sr.hasOwnProperty,pr=RegExp("^"+fr.call(lr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function hr(t){return!(!Le(t)||function(t){return!!or&&or in t}(t))&&(Ve(t)?pr:ur).test(ar(t))}function dr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return hr(r)?r:void 0}var vr=dr(j,"Map"),gr=dr(Object,"create");var yr="__lodash_hash_undefined__",br=Object.prototype.hasOwnProperty;var _r=Object.prototype.hasOwnProperty;var mr="__lodash_hash_undefined__";function wr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Pr?new Er:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=fe(t))?!le({arg:r},e):!ce(t)(r))})).length)})).length}return!1},Qn=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Yn,null,a);case"array"===t:return!se(e.arg);case!1!==(r=fe(t)):return!le(e,r);default:return!ce(t)(e.arg)}},Xn=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Zn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!se(e))throw new Et("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!se(t))throw new Et("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Xn(t,a):t,index:r,param:a,optional:i}}));default:throw new Et("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Wt(e)&&!(r.type.length>r.type.filter((function(e){return Qn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Qn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},to=function(){try{var t=dr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function eo(t,e,r){"__proto__"==e&&to?to(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function ro(t,e,r){(void 0===r||Xe(t[e],r))&&(void 0!==r||e in t)||eo(t,e,r)}var no="object"==typeof exports&&exports&&!exports.nodeType&&exports,oo=no&&"object"==typeof module&&module&&!module.nodeType&&module,io=oo&&oo.exports===no?j.Buffer:void 0,ao=io?io.allocUnsafe:void 0;function uo(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Cr(n).set(new Cr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var co=Object.create,so=function(){function t(){}return function(e){if(!Le(e))return{};if(co)return co(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function fo(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var lo=Object.prototype.hasOwnProperty;function po(t,e,r){var n=t[e];lo.call(t,e)&&Xe(n,r)&&(void 0!==r||e in t)||eo(t,e,r)}var ho=Object.prototype.hasOwnProperty;function vo(t){if(!Le(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Je(t),r=[];for(var n in t)("constructor"!=n||!e&&ho.call(t,n))&&r.push(n);return r}function go(t){return We(t)?Re(t,!0):vo(t)}function yo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=So)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(jo);function Eo(t,e){return Ao(function(t,e,r){return e=wo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=wo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=To.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Le(r))return!1;var n=typeof e;return!!("number"==n?We(r)&&Ae(e,r.length):"string"==n&&e in r)&&Xe(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r=0;e--){var r=Ci().key(e);t($i(r),r)}},remove:function(t){return Ci().removeItem(t)},clearAll:function(){return Ci().clear()}};function Ci(){return Pi.localStorage}function $i(t){return Ci().getItem(t)}var zi=di.trim,Ni={name:"cookieStorage",read:function(t){if(!t||!Fi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Mi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Mi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Ii,remove:Ri,clearAll:function(){Ii((function(t,e){Ri(e)}))}},Mi=di.Global.document;function Ii(t){for(var e=Mi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(zi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ri(t){t&&Fi(t)&&(Mi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Fi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Mi.cookie)}var Ji=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var Ui=di.bind,Di=di.each,Li=di.create,Hi=di.slice,Ki=function(){var t=Li(Bi,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Ui(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Ui(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),Di(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Bi={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Ui(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Hi(arguments,1);Di(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Gi=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Vi=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Gi.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Gi.compress(this._serialize(r));t(e,n)}}};var Wi=[qi,Ni],Yi=[Ji,Ki,Vi],Qi=Ei.createStore(Wi,Yi),Xi=di.Global;function Zi(){return Xi.sessionStorage}function ta(t){return Zi().getItem(t)}var ea=[{name:"sessionStorage",read:ta,write:function(t,e){return Zi().setItem(t,e)},each:function(t){for(var e=Zi().length-1;e>=0;e--){var r=Zi().key(e);t(ta(r),r)}},remove:function(t){return Zi().removeItem(t)},clearAll:function(){return Zi().clear()}},Ni],ra=[Ji,Vi],na=Ei.createStore(ea,ra),oa=Qi,ia=na,aa=function(t){var e;return(e={}).args=t,e};function ua(t,e){var r;return(r={})[t]=e,r[u]=[ci()],r}var ca=function(t){return vt(t,"data")&&!vt(t,"error")?t.data:t},sa=function(t){this.opts=t,this.instanceKey=Nt(this.opts.hostname),this.localStore=oa,this.sessionStore=ia},fa={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};sa.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?xo({},o,e):e,r))},sa.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},sa.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},sa.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},fa.lset.set=function(t){return this.__setMethod("localStore",t)},fa.lget.get=function(){return this.__getMethod("localStore")},sa.prototype.ldel=function(t){return this.__delMethod("localStore",t)},sa.prototype.lclear=function(){return this.__clearMethod("localStore")},fa.sset.set=function(t){return this.__setMethod("sessionStore",t)},fa.sget.get=function(){return this.__getMethod("sessionStore")},sa.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},sa.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(sa.prototype,fa);var la=c[0],pa=c[1],ha=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,t)}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Vt),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(oi(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new At("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&oi(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!zt(t))throw new At("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=zt(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function r(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var n={headers:{configurable:!0}};return n.headers.set=function(t){this.extraHeader=t},r.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=xo({},{_cb:ci()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=xo({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=xo({},{method:la,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},r.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},r.prototype.processJsonp=function(t){return ca(t)},r.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=ni(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ca(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new Tt("Server side error",r)}))},r.prototype.getHeaders=function(){return this.opts.enableAuth?xo({},e,this.getAuthHeader(),this.extraHeader):xo({},e,this.extraHeader)},r.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},r.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=xo({},this.extraParams,g)),this.request({},{method:"GET"},this.contractHeader).then(Ct).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new Tt("getRemoteContract",e)}))},r.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Kt(t)&&b(e)){var n=aa(e);return!0===r?n:ua(t,n)}throw new At("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(Ct)},r.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[i]=e,o[a]=r,!0===n)return o;if(Kt(t))return ua(t,o);throw new At("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:pa}).then(Ct)},Object.defineProperties(r.prototype,n),r}(sa)))),da=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,dt(t))}),Reflect.apply(t,null,r))}};function va(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function ga(t,e,r,n){void 0===n&&(n=!1);var o=va(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var ya=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return ii(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch($t)}},ba=function(t,e,r,n,o){var i={},a=function(t){i=ga(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return ii(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch($t)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},_a=function(t,e,r,n,o){var i={},a=function(t){i=ga(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return ii(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch($t)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},ma=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=ya(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=ya(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var wa=function(t,e,r,n){var o=function(t,e,r,n){return da(ba,_a,ma)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.jsonqlUserdata},o.getToken=function(e){return void 0===e&&(e=!1),t.rawAuthToken(e)},o.profileIndex=function(e){if(void 0===e&&(e=!1),!1===e)return t.profileIndex;t.profileIndex=e},o.getProfiles=function(e){return void 0===e&&(e=!1),t.getProfiles(e)}),e.exposeContract&&(o.getContract=function(){return t.getContract()}),e.exposeStore&&(o.tmpSave=function(t){},o.tmpGet=function(t){},o.tmpDel=function(t){},o.persistSave=function(t){},o.persistGet=function(t){},o.persistDel=function(t){}),o.eventEmitter=n,o.version="1.5.8",o.getLogger=function(e){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(t.log,t,[e].concat(r))}},o},ja={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Sa={hostname:ai(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:ai("jsonql",["string"]),loginHandlerName:ai("login",["string"]),logoutHandlerName:ai("logout",["string"]),enableJsonp:ai(!1,["boolean"]),enableAuth:ai(!1,["boolean"]),useJwt:ai(!0,["boolean"]),persistToken:ai(!1,["boolean","number"]),useLocalstorage:ai(!0,["boolean"]),storageKey:ai("jsonqlstore",["string"]),authKey:ai("jsonqlauthkey",["string"]),contractExpired:ai(0,["number"]),keepContract:ai(!0,["boolean"]),exposeContract:ai(!1,["boolean"]),exposeStore:ai(!1,["boolean"]),showContractDesc:ai(!1,["boolean"]),contractKey:ai(!1,["boolean"]),contractKeyName:ai("X-JSONQL-CV-KEY",["string"]),enableTimeout:ai(!1,["boolean"]),timeout:ai(5e3,["number"]),returnInstance:ai(!1,["boolean"]),allowReturnRawToken:ai(!1,["boolean"]),debugOn:ai(!1,["boolean"])};function Oa(t){return va(t,v)?Promise.resolve(t):function(t){var e=t.contract;return ui(t,Sa,ja).then((function(t){return t.contract=e,t}))}(t)}var ka=new WeakMap,Aa=new WeakMap,Ea=function(){this.__suspend__=null,this.queueStore=new Set},Ta={$suspend:{configurable:!0},$queues:{configurable:!0}};Ta.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},Ea.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},Ta.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Ea.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(Ea.prototype,Ta);var xa=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ka.set(this,t)},r.normalStore.get=function(){return ka.get(this)},r.lazyStore.set=function(t){Aa.set(this,t)},r.lazyStore.get=function(){return Aa.get(this)},e.prototype.hashFnToKey=function(t){return Nt(t.toString())},Object.defineProperties(e.prototype,r),e}(Ea));return function(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),Oa(e).then((function(t){return{baseClient:new ha(r,t),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return Mt(r,n.contract).then((function(e){return wa(r,n,e,t)}))}))}((r=e.debugOn,new xa({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r="query",n="mutation",o="socket",i="payload",a="condition",u="TS",c=["POST","PUT"],s="type",f="optional",l="enumv",p="args",h="checker",d="alias",v="__checked__",g={desc:"y"},y="No message",b=Array.isArray,_="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},m="object"==typeof _&&_&&_.Object===Object&&_,w="object"==typeof self&&self&&self.Object===Object&&self,j=m||w||Function("return this")(),S=j.Symbol,O=Object.prototype,k=O.hasOwnProperty,A=O.toString,E=S?S.toStringTag:void 0;var T=Object.prototype.toString;var x="[object Null]",P="[object Undefined]",q=S?S.toStringTag:void 0;function C(t){return null==t?void 0===t?P:x:q&&q in Object(t)?function(t){var e=k.call(t,E),r=t[E];try{t[E]=void 0;var n=!0}catch(t){}var o=A.call(t);return n&&(e?t[E]=r:delete t[E]),o}(t):function(t){return T.call(t)}(t)}function $(t,e){return function(r){return t(e(r))}}var z=$(Object.getPrototypeOf,Object);function N(t){return null!=t&&"object"==typeof t}var M="[object Object]",I=Function.prototype,R=Object.prototype,F=I.toString,J=R.hasOwnProperty,U=F.call(Object);function D(t){if(!N(t)||C(t)!=M)return!1;var e=z(t);if(null===e)return!0;var r=J.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&F.call(r)==U}function L(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&X(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var dt=function(t){return b(t)?t:[t]},vt=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},gt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),yt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),bt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),_t=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),mt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),wt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),jt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),St=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),Ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),kt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),At=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),Et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),Tt=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),xt=Object.freeze({__proto__:null,Jsonql406Error:gt,Jsonql500Error:yt,JsonqlForbiddenError:bt,JsonqlAuthorisationError:_t,JsonqlContractAuthError:mt,JsonqlResolverAppError:wt,JsonqlResolverNotFoundError:jt,JsonqlEnumError:St,JsonqlTypeError:Ot,JsonqlCheckerError:kt,JsonqlValidationError:At,JsonqlError:Et,JsonqlServerError:Tt}),Pt=Et,qt=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function Ct(t){if(qt(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||y,a=e.detail||e;if(o&&xt[o])throw new xt[r](i,a);throw new Pt(i,a)}return t}function $t(t){if(Array.isArray(t))throw new At("",t);var e=t.message||y,r=t.detail||t;switch(!0){case t instanceof gt:throw new gt(e,r);case t instanceof yt:throw new yt(e,r);case t instanceof bt:throw new bt(e,r);case t instanceof _t:throw new _t(e,r);case t instanceof mt:throw new mt(e,r);case t instanceof wt:throw new wt(e,r);case t instanceof jt:throw new jt(e,r);case t instanceof St:throw new St(e,r);case t instanceof Ot:throw new Ot(e,r);case t instanceof kt:throw new kt(e,r);case t instanceof At:throw new At(e,r);case t instanceof Tt:throw new Tt(e,r);default:throw new Et(e,r)}}function zt(t){return!!function(t){return D(t)&&(vt(t,r)||vt(t,n)||vt(t,o))}(t)&&t}function Nt(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}var Mt=function(t,e){return void 0===e&&(e={}),zt(e)?Promise.resolve(e):t.getContract()},It="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Rt(t){this.message=t}Rt.prototype=new Error,Rt.prototype.name="InvalidCharacterError";var Ft="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Rt("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=It.indexOf(n);return a};var Jt=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Ft(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return Ft(e)}};function Ut(t){this.message=t}Ut.prototype=new Error,Ut.prototype.name="InvalidTokenError";var Dt=function(t,e){if("string"!=typeof t)throw new Ut("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Jt(t.split(".")[r]))}catch(t){throw new Ut("Invalid token specified: "+t.message)}},Lt=Ut;Dt.InvalidTokenError=Lt;var Ht="[object String]";function Kt(t){return"string"==typeof t||!b(t)&&N(t)&&C(t)==Ht}var Bt=function(t){return""!==ht(t)&&Kt(t)},Gt=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Vt(t){if(Bt(t))return function(t){var e=t.iat||Gt(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new Et("Token has expired on "+r,t)}return t}(Dt(t));throw new Et("Token must be a string!")}var Wt=function(t){return!!b(t)||null!=t&&""!==ht(t)},Yt="[object Number]";function Qt(t){return function(t){return"number"==typeof t||N(t)&&C(t)==Yt}(t)&&t!=+t}var Xt=function(t){return!Kt(t)&&!Qt(parseFloat(t))},Zt=function(t){return null!=t&&"boolean"==typeof t},te=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==ht(t)&&(!1===e||!0===e&&null!==t)},ee=s,re=f,ne=l,oe=p,ie=h,ae=d,ue="continue",ce=function(t){switch(t){case"number":return Xt;case"string":return Bt;case"boolean":return Zt;default:return te}},se=function(t,e){return void 0===e&&(e=""),!!b(t)&&(""===e||""===ht(e)||!(t.filter((function(t){return!ce(e)(t)})).length>0))},fe=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},le=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!ce(e)(t)})).length)})).length:e.length>e.filter((function(t){return!se(r,t)})).length};var pe,he=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[pe?a:++n];if(!1===e(o[u],u,o))break}return t};var de="[object Arguments]";function ve(t){return N(t)&&C(t)==de}var ge=Object.prototype,ye=ge.hasOwnProperty,be=ge.propertyIsEnumerable,_e=ve(function(){return arguments}())?ve:function(t){return N(t)&&ye.call(t,"callee")&&!be.call(t,"callee")};var me="object"==typeof exports&&exports&&!exports.nodeType&&exports,we=me&&"object"==typeof module&&module&&!module.nodeType&&module,je=we&&we.exports===me?j.Buffer:void 0,Se=(je?je.isBuffer:void 0)||function(){return!1},Oe=9007199254740991,ke=/^(?:0|[1-9]\d*)$/;function Ae(t,e){var r=typeof t;return!!(e=null==e?Oe:e)&&("number"==r||"symbol"!=r&&ke.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Ee}var xe={};xe["[object Float32Array]"]=xe["[object Float64Array]"]=xe["[object Int8Array]"]=xe["[object Int16Array]"]=xe["[object Int32Array]"]=xe["[object Uint8Array]"]=xe["[object Uint8ClampedArray]"]=xe["[object Uint16Array]"]=xe["[object Uint32Array]"]=!0,xe["[object Arguments]"]=xe["[object Array]"]=xe["[object ArrayBuffer]"]=xe["[object Boolean]"]=xe["[object DataView]"]=xe["[object Date]"]=xe["[object Error]"]=xe["[object Function]"]=xe["[object Map]"]=xe["[object Number]"]=xe["[object Object]"]=xe["[object RegExp]"]=xe["[object Set]"]=xe["[object String]"]=xe["[object WeakMap]"]=!1;var Pe,qe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ce=qe&&"object"==typeof module&&module&&!module.nodeType&&module,$e=Ce&&Ce.exports===qe&&m.process,ze=function(){try{var t=Ce&&Ce.require&&Ce.require("util").types;return t||$e&&$e.binding&&$e.binding("util")}catch(t){}}(),Ne=ze&&ze.isTypedArray,Me=Ne?(Pe=Ne,function(t){return Pe(t)}):function(t){return N(t)&&Te(t.length)&&!!xe[C(t)]},Ie=Object.prototype.hasOwnProperty;function Re(t,e){var r=b(t),n=!r&&_e(t),o=!r&&!n&&Se(t),i=!r&&!n&&!o&&Me(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},er.prototype.set=function(t,e){var r=this.__data__,n=Ze(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var rr,nr=j["__core-js_shared__"],or=(rr=/[^.]+$/.exec(nr&&nr.keys&&nr.keys.IE_PROTO||""))?"Symbol(src)_1."+rr:"";var ir=Function.prototype.toString;function ar(t){if(null!=t){try{return ir.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ur=/^\[object .+?Constructor\]$/,cr=Function.prototype,sr=Object.prototype,fr=cr.toString,lr=sr.hasOwnProperty,pr=RegExp("^"+fr.call(lr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function hr(t){return!(!Le(t)||function(t){return!!or&&or in t}(t))&&(Ve(t)?pr:ur).test(ar(t))}function dr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return hr(r)?r:void 0}var vr=dr(j,"Map"),gr=dr(Object,"create");var yr="__lodash_hash_undefined__",br=Object.prototype.hasOwnProperty;var _r=Object.prototype.hasOwnProperty;var mr="__lodash_hash_undefined__";function wr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Pr?new Er:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=fe(t))?!le({arg:r},e):!ce(t)(r))})).length)})).length}return!1},Qn=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Yn,null,a);case"array"===t:return!se(e.arg);case!1!==(r=fe(t)):return!le(e,r);default:return!ce(t)(e.arg)}},Xn=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Zn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!se(e))throw new Et("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!se(t))throw new Et("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Xn(t,a):t,index:r,param:a,optional:i}}));default:throw new Et("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Wt(e)&&!(r.type.length>r.type.filter((function(e){return Qn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Qn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},to=function(){try{var t=dr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function eo(t,e,r){"__proto__"==e&&to?to(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function ro(t,e,r){(void 0===r||Xe(t[e],r))&&(void 0!==r||e in t)||eo(t,e,r)}var no="object"==typeof exports&&exports&&!exports.nodeType&&exports,oo=no&&"object"==typeof module&&module&&!module.nodeType&&module,io=oo&&oo.exports===no?j.Buffer:void 0,ao=io?io.allocUnsafe:void 0;function uo(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Cr(n).set(new Cr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var co=Object.create,so=function(){function t(){}return function(e){if(!Le(e))return{};if(co)return co(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function fo(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var lo=Object.prototype.hasOwnProperty;function po(t,e,r){var n=t[e];lo.call(t,e)&&Xe(n,r)&&(void 0!==r||e in t)||eo(t,e,r)}var ho=Object.prototype.hasOwnProperty;function vo(t){if(!Le(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Je(t),r=[];for(var n in t)("constructor"!=n||!e&&ho.call(t,n))&&r.push(n);return r}function go(t){return We(t)?Re(t,!0):vo(t)}function yo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=So)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(jo);function Eo(t,e){return Ao(function(t,e,r){return e=wo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=wo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=To.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Le(r))return!1;var n=typeof e;return!!("number"==n?We(r)&&Ae(e,r.length):"string"==n&&e in r)&&Xe(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r=0;e--){var r=Ci().key(e);t($i(r),r)}},remove:function(t){return Ci().removeItem(t)},clearAll:function(){return Ci().clear()}};function Ci(){return Pi.localStorage}function $i(t){return Ci().getItem(t)}var zi=di.trim,Ni={name:"cookieStorage",read:function(t){if(!t||!Fi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Mi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Mi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Ii,remove:Ri,clearAll:function(){Ii((function(t,e){Ri(e)}))}},Mi=di.Global.document;function Ii(t){for(var e=Mi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(zi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ri(t){t&&Fi(t)&&(Mi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Fi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Mi.cookie)}var Ji=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var Ui=di.bind,Di=di.each,Li=di.create,Hi=di.slice,Ki=function(){var t=Li(Bi,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Ui(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Ui(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),Di(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Bi={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Ui(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Hi(arguments,1);Di(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Gi=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Vi=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Gi.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Gi.compress(this._serialize(r));t(e,n)}}};var Wi=[qi,Ni],Yi=[Ji,Ki,Vi],Qi=Ei.createStore(Wi,Yi),Xi=di.Global;function Zi(){return Xi.sessionStorage}function ta(t){return Zi().getItem(t)}var ea=[{name:"sessionStorage",read:ta,write:function(t,e){return Zi().setItem(t,e)},each:function(t){for(var e=Zi().length-1;e>=0;e--){var r=Zi().key(e);t(ta(r),r)}},remove:function(t){return Zi().removeItem(t)},clearAll:function(){return Zi().clear()}},Ni],ra=[Ji,Vi],na=Ei.createStore(ea,ra),oa=Qi,ia=na,aa=function(t){var e;return(e={}).args=t,e};function ua(t,e){var r;return(r={})[t]=e,r[u]=[ci()],r}var ca=function(t){return vt(t,"data")&&!vt(t,"error")?t.data:t},sa=function(t){this.opts=t,this.instanceKey=Nt(this.opts.hostname),this.localStore=oa,this.sessionStore=ia},fa={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};sa.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?xo({},o,e):e,r))},sa.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},sa.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},sa.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},fa.lset.set=function(t){return this.__setMethod("localStore",t)},fa.lget.get=function(){return this.__getMethod("localStore")},sa.prototype.ldel=function(t){return this.__delMethod("localStore",t)},sa.prototype.lclear=function(){return this.__clearMethod("localStore")},fa.sset.set=function(t){return this.__setMethod("sessionStore",t)},fa.sget.get=function(){return this.__getMethod("sessionStore")},sa.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},sa.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(sa.prototype,fa);var la=c[0],pa=c[1],ha=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,t)}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Vt),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(oi(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new At("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&oi(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!zt(t))throw new At("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=zt(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function r(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var n={headers:{configurable:!0}};return n.headers.set=function(t){this.extraHeader=t},r.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=xo({},{_cb:ci()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=xo({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=xo({},{method:la,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},r.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},r.prototype.processJsonp=function(t){return ca(t)},r.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=ni(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ca(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new Tt("Server side error",r)}))},r.prototype.getHeaders=function(){return this.opts.enableAuth?xo({},e,this.getAuthHeader(),this.extraHeader):xo({},e,this.extraHeader)},r.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},r.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=xo({},this.extraParams,g)),this.request({},{method:"GET"},this.contractHeader).then(Ct).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new Tt("getRemoteContract",e)}))},r.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Kt(t)&&b(e)){var n=aa(e);return!0===r?n:ua(t,n)}throw new At("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(Ct)},r.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[i]=e,o[a]=r,!0===n)return o;if(Kt(t))return ua(t,o);throw new At("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:pa}).then(Ct)},Object.defineProperties(r.prototype,n),r}(sa)))),da=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,dt(t))}),Reflect.apply(t,null,r))}};function va(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function ga(t,e,r,n){void 0===n&&(n=!1);var o=va(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var ya=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return ii(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch($t)}},ba=function(t,e,r,n,o){var i={},a=function(t){i=ga(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return ii(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch($t)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},_a=function(t,e,r,n,o){var i={},a=function(t){i=ga(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return ii(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch($t)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},ma=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=ya(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=ya(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var wa=function(t,e,r,n){var o=function(t,e,r,n){return da(ba,_a,ma)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.jsonqlUserdata},o.getToken=function(e){return void 0===e&&(e=!1),t.rawAuthToken(e)},o.profileIndex=function(e){if(void 0===e&&(e=!1),!1===e)return t.profileIndex;t.profileIndex=e},o.getProfiles=function(e){return void 0===e&&(e=!1),t.getProfiles(e)}),e.exposeContract&&(o.getContract=function(){return t.getContract()}),e.exposeStore&&(o.tmpSave=function(t){},o.tmpGet=function(t){},o.tmpDel=function(t){},o.persistSave=function(t){},o.persistGet=function(t){},o.persistDel=function(t){}),o.eventEmitter=n,o.version="1.5.9",o.getLogger=function(e){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(t.log,t,[e].concat(r))}},o},ja={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Sa={hostname:ai(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:ai("jsonql",["string"]),loginHandlerName:ai("login",["string"]),logoutHandlerName:ai("logout",["string"]),enableJsonp:ai(!1,["boolean"]),enableAuth:ai(!1,["boolean"]),useJwt:ai(!0,["boolean"]),persistToken:ai(!1,["boolean","number"]),useLocalstorage:ai(!0,["boolean"]),storageKey:ai("jsonqlstore",["string"]),authKey:ai("jsonqlauthkey",["string"]),contractExpired:ai(0,["number"]),keepContract:ai(!0,["boolean"]),exposeContract:ai(!1,["boolean"]),exposeStore:ai(!1,["boolean"]),showContractDesc:ai(!1,["boolean"]),contractKey:ai(!1,["boolean"]),contractKeyName:ai("X-JSONQL-CV-KEY",["string"]),enableTimeout:ai(!1,["boolean"]),timeout:ai(5e3,["number"]),returnInstance:ai(!1,["boolean"]),allowReturnRawToken:ai(!1,["boolean"]),debugOn:ai(!1,["boolean"])};function Oa(t){return va(t,v)?Promise.resolve(t):function(t){var e=t.contract;return ui(t,Sa,ja).then((function(t){return t.contract=e,t}))}(t)}var ka=new WeakMap,Aa=new WeakMap,Ea=function(){this.__suspend__=null,this.queueStore=new Set},Ta={$suspend:{configurable:!0},$queues:{configurable:!0}};Ta.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},Ea.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},Ta.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Ea.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(Ea.prototype,Ta);var xa=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){ka.set(this,t)},r.normalStore.get=function(){return ka.get(this)},r.lazyStore.set=function(t){Aa.set(this,t)},r.lazyStore.get=function(){return Aa.get(this)},e.prototype.hashFnToKey=function(t){return Nt(t.toString())},Object.defineProperties(e.prototype,r),e}(Ea));return function(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),Oa(e).then((function(t){return{baseClient:new ha(r,t),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return Mt(r,n.contract).then((function(e){return wa(r,n,e,t)}))}))}((r=e.debugOn,new xa({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}})); //# sourceMappingURL=core.js.map diff --git a/packages/http-client/dist/jsonql-client.static.js b/packages/http-client/dist/jsonql-client.static.js index 3edba92f..af9daec6 100644 --- a/packages/http-client/dist/jsonql-client.static.js +++ b/packages/http-client/dist/jsonql-client.static.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function k(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function E(t){t.engine=a,k(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,k(l.handler,s,0);else{var f=new A(c,i);f.response=s,E(f)}}catch(f){E(new A(f.msg,a.status))}},a.onerror=function(t){E(new A(t.msg||"Network Error",0))},a.ontimeout=function(){E(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u="query",c="mutation",s="socket",f="payload",l="condition",p="TS",h=["POST","PUT"],d="type",v="optional",g="enumv",y="args",b="checker",m="alias",_="__checked__",w={desc:"y"},j="No message",O="onResult",S="onError",k=Array.isArray,E="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A="object"==typeof E&&E&&E.Object===Object&&E,T="object"==typeof self&&self&&self.Object===Object&&self,x=A||T||Function("return this")(),P=x.Symbol,q=Object.prototype,C=q.hasOwnProperty,$=q.toString,z=P?P.toStringTag:void 0;var N=Object.prototype.toString;var R="[object Null]",M="[object Undefined]",F=P?P.toStringTag:void 0;function J(t){return null==t?void 0===t?M:R:F&&F in Object(t)?function(t){var e=C.call(t,z),r=t[z];try{t[z]=void 0;var n=!0}catch(t){}var o=$.call(t);return n&&(e?t[z]=r:delete t[z]),o}(t):function(t){return N.call(t)}(t)}function I(t,e){return function(r){return t(e(r))}}var U=I(Object.getPrototypeOf,Object);function D(t){return null!=t&&"object"==typeof t}var H="[object Object]",L=Function.prototype,B=Object.prototype,K=L.toString,G=B.hasOwnProperty,V=K.call(Object);function W(t){if(!D(t)||J(t)!=H)return!1;var e=U(t);if(null===e)return!0;var r=G.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&K.call(r)==V}function Y(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&it(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var wt=function(t){return k(t)?t:[t]},jt=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},Ot=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},St=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),kt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),Et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),At=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),Tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),xt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),Pt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),qt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),Ct=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),$t=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),zt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),Nt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),Rt=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),Mt=Object.freeze({__proto__:null,Jsonql406Error:St,Jsonql500Error:kt,JsonqlForbiddenError:Et,JsonqlAuthorisationError:At,JsonqlContractAuthError:Tt,JsonqlResolverAppError:xt,JsonqlResolverNotFoundError:Pt,JsonqlEnumError:qt,JsonqlTypeError:Ct,JsonqlCheckerError:$t,JsonqlValidationError:zt,JsonqlError:Nt,JsonqlServerError:Rt}),Ft=Nt,Jt=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function It(t){if(Jt(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||j,a=e.detail||e;if(o&&Mt[o])throw new Mt[r](i,a);throw new Ft(i,a)}return t}function Ut(t){if(Array.isArray(t))throw new zt("",t);var e=t.message||j,r=t.detail||t;switch(!0){case t instanceof St:throw new St(e,r);case t instanceof kt:throw new kt(e,r);case t instanceof Et:throw new Et(e,r);case t instanceof At:throw new At(e,r);case t instanceof Tt:throw new Tt(e,r);case t instanceof xt:throw new xt(e,r);case t instanceof Pt:throw new Pt(e,r);case t instanceof qt:throw new qt(e,r);case t instanceof Ct:throw new Ct(e,r);case t instanceof $t:throw new $t(e,r);case t instanceof zt:throw new zt(e,r);case t instanceof Rt:throw new Rt(e,r);default:throw new Nt(e,r)}}var Dt=function(t){return!!k(t)||null!=t&&""!==_t(t)},Ht="[object Number]";function Lt(t){return function(t){return"number"==typeof t||D(t)&&J(t)==Ht}(t)&&t!=+t}var Bt="[object String]";function Kt(t){return"string"==typeof t||!k(t)&&D(t)&&J(t)==Bt}var Gt=function(t){return!Kt(t)&&!Lt(parseFloat(t))},Vt=function(t){return""!==_t(t)&&Kt(t)},Wt=function(t){return null!=t&&"boolean"==typeof t},Yt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==_t(t)&&(!1===e||!0===e&&null!==t)},Qt=d,Xt=v,Zt=g,te=y,ee=b,re=m,ne="continue",oe=function(t){switch(t){case"number":return Gt;case"string":return Vt;case"boolean":return Wt;default:return Yt}},ie=function(t,e){return void 0===e&&(e=""),!!k(t)&&(""===e||""===_t(e)||!(t.filter((function(t){return!oe(e)(t)})).length>0))},ae=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ue=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!oe(e)(t)})).length)})).length:e.length>e.filter((function(t){return!ie(r,t)})).length};var ce,se=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ce?a:++n];if(!1===e(o[u],u,o))break}return t};var fe="[object Arguments]";function le(t){return D(t)&&J(t)==fe}var pe=Object.prototype,he=pe.hasOwnProperty,de=pe.propertyIsEnumerable,ve=le(function(){return arguments}())?le:function(t){return D(t)&&he.call(t,"callee")&&!de.call(t,"callee")};var ge="object"==typeof exports&&exports&&!exports.nodeType&&exports,ye=ge&&"object"==typeof module&&module&&!module.nodeType&&module,be=ye&&ye.exports===ge?x.Buffer:void 0,me=(be?be.isBuffer:void 0)||function(){return!1},_e=9007199254740991,we=/^(?:0|[1-9]\d*)$/;function je(t,e){var r=typeof t;return!!(e=null==e?_e:e)&&("number"==r||"symbol"!=r&&we.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Oe}var ke={};ke["[object Float32Array]"]=ke["[object Float64Array]"]=ke["[object Int8Array]"]=ke["[object Int16Array]"]=ke["[object Int32Array]"]=ke["[object Uint8Array]"]=ke["[object Uint8ClampedArray]"]=ke["[object Uint16Array]"]=ke["[object Uint32Array]"]=!0,ke["[object Arguments]"]=ke["[object Array]"]=ke["[object ArrayBuffer]"]=ke["[object Boolean]"]=ke["[object DataView]"]=ke["[object Date]"]=ke["[object Error]"]=ke["[object Function]"]=ke["[object Map]"]=ke["[object Number]"]=ke["[object Object]"]=ke["[object RegExp]"]=ke["[object Set]"]=ke["[object String]"]=ke["[object WeakMap]"]=!1;var Ee,Ae="object"==typeof exports&&exports&&!exports.nodeType&&exports,Te=Ae&&"object"==typeof module&&module&&!module.nodeType&&module,xe=Te&&Te.exports===Ae&&A.process,Pe=function(){try{var t=Te&&Te.require&&Te.require("util").types;return t||xe&&xe.binding&&xe.binding("util")}catch(t){}}(),qe=Pe&&Pe.isTypedArray,Ce=qe?(Ee=qe,function(t){return Ee(t)}):function(t){return D(t)&&Se(t.length)&&!!ke[J(t)]},$e=Object.prototype.hasOwnProperty;function ze(t,e){var r=k(t),n=!r&&ve(t),o=!r&&!n&&me(t),i=!r&&!n&&!o&&Ce(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Qe.prototype.set=function(t,e){var r=this.__data__,n=We(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Xe,Ze=x["__core-js_shared__"],tr=(Xe=/[^.]+$/.exec(Ze&&Ze.keys&&Ze.keys.IE_PROTO||""))?"Symbol(src)_1."+Xe:"";var er=Function.prototype.toString;function rr(t){if(null!=t){try{return er.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var nr=/^\[object .+?Constructor\]$/,or=Function.prototype,ir=Object.prototype,ar=or.toString,ur=ir.hasOwnProperty,cr=RegExp("^"+ar.call(ur).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function sr(t){return!(!Je(t)||function(t){return!!tr&&tr in t}(t))&&(Le(t)?cr:nr).test(rr(t))}function fr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return sr(r)?r:void 0}var lr=fr(x,"Map"),pr=fr(Object,"create");var hr="__lodash_hash_undefined__",dr=Object.prototype.hasOwnProperty;var vr=Object.prototype.hasOwnProperty;var gr="__lodash_hash_undefined__";function yr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Er?new Or:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=ae(t))?!ue({arg:r},e):!oe(t)(r))})).length)})).length}return!1},Gn=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Kn,null,a);case"array"===t:return!ie(e.arg);case!1!==(r=ae(t)):return!ue(e,r);default:return!oe(t)(e.arg)}},Vn=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Wn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!ie(e))throw new Nt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!ie(t))throw new Nt("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Vn(t,a):t,index:r,param:a,optional:i}}));default:throw new Nt("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Dt(e)&&!(r.type.length>r.type.filter((function(e){return Gn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Gn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Yn=function(){try{var t=fr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Qn(t,e,r){"__proto__"==e&&Yn?Yn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Xn(t,e,r){(void 0===r||Ve(t[e],r))&&(void 0!==r||e in t)||Qn(t,e,r)}var Zn="object"==typeof exports&&exports&&!exports.nodeType&&exports,to=Zn&&"object"==typeof module&&module&&!module.nodeType&&module,eo=to&&to.exports===Zn?x.Buffer:void 0,ro=eo?eo.allocUnsafe:void 0;function no(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Tr(n).set(new Tr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var oo=Object.create,io=function(){function t(){}return function(e){if(!Je(e))return{};if(oo)return oo(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function ao(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var uo=Object.prototype.hasOwnProperty;function co(t,e,r){var n=t[e];uo.call(t,e)&&Ve(n,r)&&(void 0!==r||e in t)||Qn(t,e,r)}var so=Object.prototype.hasOwnProperty;function fo(t){if(!Je(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Re(t),r=[];for(var n in t)("constructor"!=n||!e&&so.call(t,n))&&r.push(n);return r}function lo(t){return Be(t)?ze(t,!0):fo(t)}function po(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=mo)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(bo);function Oo(t,e){return jo(function(t,e,r){return e=yo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=yo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=So.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Je(r))return!1;var n=typeof e;return!!("number"==n?Be(r)&&je(e,r.length):"string"==n&&e in r)&&Ve(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,wt(t))}),Reflect.apply(t,null,r))}};function Wo(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Yo(t,e,r,n){void 0===n&&(n=!1);var o=Wo(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Qo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Bo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(Ut)}},Xo=function(t,e,r,n,o){var i={},a=function(t){i=Yo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return Bo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(Ut)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Zo=function(t,e,r,n,o){var i={},a=function(t){i=Yo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Bo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(Ut)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},ti=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Qo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Qo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var ei=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(Ot(e,r,O),o),t.$only(Ot(e,r,S),i),t.$trigger(e,{resolverName:r,args:n})}))}},ri=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function ni(t,e,r,n){var o=function(t,e,r,n){return Vo(Xo,Zo,ti)({},t,e,r,n)}(t,e,r,n);ri(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(Ot(t,n,O),r)})).catch((function(r){e.$trigger(Ot(t,n,S),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var oi=function(t,e,r,n){n.$suspend=!0,r.then((function(r){ni(t,n,e,r)}));var o={query:ei(n,"query"),mutation:ei(n,"mutation"),auth:ei(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.5.8",o};function ii(t){return!!function(t){return W(t)&&(jt(t,u)||jt(t,c)||jt(t,s))}(t)&&t}function ai(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}var ui=function(t,e){return void 0===e&&(e={}),ii(e)?Promise.resolve(e):t.getContract()},ci="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function si(t){this.message=t}si.prototype=new Error,si.prototype.name="InvalidCharacterError";var fi="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new si("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=ci.indexOf(n);return a};var li=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(fi(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return fi(e)}};function pi(t){this.message=t}pi.prototype=new Error,pi.prototype.name="InvalidTokenError";var hi=function(t,e){if("string"!=typeof t)throw new pi("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(li(t.split(".")[r]))}catch(t){throw new pi("Invalid token specified: "+t.message)}},di=pi;hi.InvalidTokenError=di;var vi,gi,yi,bi,mi,_i,wi,ji,Oi,Si=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function ki(t){if(Vt(t))return function(t){var e=t.iat||Si(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new Nt("Token has expired on "+r,t)}return t}(hi(t));throw new Nt("Token must be a string!")}Ko("HS256",["string"]),Ko(!1,["boolean","number","string"],((vi={})[m]="exp",vi[v]=!0,vi)),Ko(!1,["boolean","number","string"],((gi={})[m]="nbf",gi[v]=!0,gi)),Ko(!1,["boolean","string"],((yi={})[m]="iss",yi[v]=!0,yi)),Ko(!1,["boolean","string"],((bi={})[m]="sub",bi[v]=!0,bi)),Ko(!1,["boolean","string"],((mi={})[m]="iss",mi[v]=!0,mi)),Ko(!1,["boolean"],((_i={})[v]=!0,_i)),Ko(!1,["boolean","string"],((wi={})[v]=!0,wi)),Ko(!1,["boolean","string"],((ji={})[v]=!0,ji)),Ko(!1,["boolean"],((Oi={})[v]=!0,Oi));var Ei=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},Ai=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=Wi().key(e);t(Yi(r),r)}},remove:function(t){return Wi().removeItem(t)},clearAll:function(){return Wi().clear()}};function Wi(){return Gi.localStorage}function Yi(t){return Wi().getItem(t)}var Qi=qi.trim,Xi={name:"cookieStorage",read:function(t){if(!t||!ra(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Zi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Zi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:ta,remove:ea,clearAll:function(){ta((function(t,e){ea(e)}))}},Zi=qi.Global.document;function ta(t){for(var e=Zi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Qi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function ea(t){t&&ra(t)&&(Zi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ra(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Zi.cookie)}var na=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var oa=qi.bind,ia=qi.each,aa=qi.create,ua=qi.slice,ca=function(){var t=aa(sa,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,oa(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,oa(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),ia(r,(function(e,r){t.fire(r,void 0,e)}))}}};var sa={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,oa(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=ua(arguments,1);ia(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},fa=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),la=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=fa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=fa.compress(this._serialize(r));t(e,n)}}};var pa=[Vi,Xi],ha=[na,ca,la],da=Li.createStore(pa,ha),va=qi.Global;function ga(){return va.sessionStorage}function ya(t){return ga().getItem(t)}var ba=[{name:"sessionStorage",read:ya,write:function(t,e){return ga().setItem(t,e)},each:function(t){for(var e=ga().length-1;e>=0;e--){var r=ga().key(e);t(ya(r),r)}},remove:function(t){return ga().removeItem(t)},clearAll:function(){return ga().clear()}},Xi],ma=[na,la],_a=Li.createStore(ba,ma),wa=da,ja=_a,Oa=function(t){var e;return(e={}).args=t,e};function Sa(t,e){var r;return(r={})[t]=e,r[p]=[Ei()],r}var ka=function(t){return jt(t,"data")&&!jt(t,"error")?t.data:t},Ea=function(t){this.opts=t,this.instanceKey=ai(this.opts.hostname),this.localStore=wa,this.sessionStore=ja},Aa={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Ea.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?ko({},o,e):e,r))},Ea.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Ea.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Ea.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Aa.lset.set=function(t){return this.__setMethod("localStore",t)},Aa.lget.get=function(){return this.__getMethod("localStore")},Ea.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Ea.prototype.lclear=function(){return this.__clearMethod("localStore")},Aa.sset.set=function(t){return this.__setMethod("sessionStore",t)},Aa.sget.get=function(){return this.__getMethod("sessionStore")},Ea.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Ea.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Ea.prototype,Aa);var Ta=h[0],xa=h[1],Pa=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,t)}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=ki),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(Lo(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new zt("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&Lo(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!ii(t))throw new zt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=ii(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=ko({},{_cb:Ei()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=ko({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=ko({},{method:Ta,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return ka(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=Ho(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ka(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new Rt("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?ko({},a,this.getAuthHeader(),this.extraHeader):ko({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=ko({},this.extraParams,w)),this.request({},{method:"GET"},this.contractHeader).then(It).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new Rt("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Kt(t)&&k(e)){var n=Oa(e);return!0===r?n:Sa(t,n)}throw new zt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(It)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[f]=e,o[l]=r,!0===n)return o;if(Kt(t))return Sa(t,o);throw new zt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:xa}).then(It)},Object.defineProperties(e.prototype,r),e}(Ea)))),qa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Ca={hostname:Ko(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Ko("jsonql",["string"]),loginHandlerName:Ko("login",["string"]),logoutHandlerName:Ko("logout",["string"]),enableJsonp:Ko(!1,["boolean"]),enableAuth:Ko(!1,["boolean"]),useJwt:Ko(!0,["boolean"]),persistToken:Ko(!1,["boolean","number"]),useLocalstorage:Ko(!0,["boolean"]),storageKey:Ko("jsonqlstore",["string"]),authKey:Ko("jsonqlauthkey",["string"]),contractExpired:Ko(0,["number"]),keepContract:Ko(!0,["boolean"]),exposeContract:Ko(!1,["boolean"]),exposeStore:Ko(!1,["boolean"]),showContractDesc:Ko(!1,["boolean"]),contractKey:Ko(!1,["boolean"]),contractKeyName:Ko("X-JSONQL-CV-KEY",["string"]),enableTimeout:Ko(!1,["boolean"]),timeout:Ko(5e3,["number"]),returnInstance:Ko(!1,["boolean"]),allowReturnRawToken:Ko(!1,["boolean"]),debugOn:Ko(!1,["boolean"])};function $a(t){return Wo(t,_)?t:function(t){return Go(t,Ca,qa)}(t)}var za=new WeakMap,Na=new WeakMap,Ra=function(){this.__suspend__=null,this.queueStore=new Set},Ma={$suspend:{configurable:!0},$queues:{configurable:!0}};Ma.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},Ra.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},Ma.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Ra.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(Ra.prototype,Ma);var Fa=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){za.set(this,t)},r.normalStore.get=function(){return za.get(this)},r.lazyStore.set=function(t){Na.set(this,t)},r.lazyStore.get=function(){return Na.get(this)},e.prototype.hashFnToKey=function(t){return ai(t.toString())},Object.defineProperties(e.prototype,r),e}(Ra));function Ja(t,e){void 0===e&&(e={});var r,n=e.contract,o=$a(e),i=new Pa(t,o),a=ui(i,n),u=(r=o.debugOn,new Fa({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=oi(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),Ja(new o,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],O="application/x-www-form-urlencoded";for(var S in o.trim((j||"").toLowerCase())===O?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(O="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=O),r.headers)if(S===u&&o.isFormData(e))delete r.headers[S];else try{a.setRequestHeader(S,r.headers[S])}catch(t){}function k(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function E(t){t.engine=a,k(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,k(l.handler,s,0);else{var f=new A(c,i);f.response=s,E(f)}}catch(f){E(new A(f.msg,a.status))}},a.onerror=function(t){E(new A(t.msg||"Network Error",0))},a.ontimeout=function(){E(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u="query",c="mutation",s="socket",f="payload",l="condition",p="TS",h=["POST","PUT"],d="type",v="optional",g="enumv",y="args",b="checker",m="alias",_="__checked__",w={desc:"y"},j="No message",O="onResult",S="onError",k=Array.isArray,E="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},A="object"==typeof E&&E&&E.Object===Object&&E,T="object"==typeof self&&self&&self.Object===Object&&self,x=A||T||Function("return this")(),P=x.Symbol,q=Object.prototype,C=q.hasOwnProperty,$=q.toString,z=P?P.toStringTag:void 0;var N=Object.prototype.toString;var R="[object Null]",M="[object Undefined]",F=P?P.toStringTag:void 0;function J(t){return null==t?void 0===t?M:R:F&&F in Object(t)?function(t){var e=C.call(t,z),r=t[z];try{t[z]=void 0;var n=!0}catch(t){}var o=$.call(t);return n&&(e?t[z]=r:delete t[z]),o}(t):function(t){return N.call(t)}(t)}function I(t,e){return function(r){return t(e(r))}}var U=I(Object.getPrototypeOf,Object);function D(t){return null!=t&&"object"==typeof t}var H="[object Object]",L=Function.prototype,B=Object.prototype,K=L.toString,G=B.hasOwnProperty,V=K.call(Object);function W(t){if(!D(t)||J(t)!=H)return!1;var e=U(t);if(null===e)return!0;var r=G.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&K.call(r)==V}function Y(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&it(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var wt=function(t){return k(t)?t:[t]},jt=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},Ot=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},St=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),kt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),Et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),At=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),Tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),xt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),Pt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),qt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),Ct=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),$t=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),zt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),Nt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),Rt=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),Mt=Object.freeze({__proto__:null,Jsonql406Error:St,Jsonql500Error:kt,JsonqlForbiddenError:Et,JsonqlAuthorisationError:At,JsonqlContractAuthError:Tt,JsonqlResolverAppError:xt,JsonqlResolverNotFoundError:Pt,JsonqlEnumError:qt,JsonqlTypeError:Ct,JsonqlCheckerError:$t,JsonqlValidationError:zt,JsonqlError:Nt,JsonqlServerError:Rt}),Ft=Nt,Jt=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function It(t){if(Jt(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||j,a=e.detail||e;if(o&&Mt[o])throw new Mt[r](i,a);throw new Ft(i,a)}return t}function Ut(t){if(Array.isArray(t))throw new zt("",t);var e=t.message||j,r=t.detail||t;switch(!0){case t instanceof St:throw new St(e,r);case t instanceof kt:throw new kt(e,r);case t instanceof Et:throw new Et(e,r);case t instanceof At:throw new At(e,r);case t instanceof Tt:throw new Tt(e,r);case t instanceof xt:throw new xt(e,r);case t instanceof Pt:throw new Pt(e,r);case t instanceof qt:throw new qt(e,r);case t instanceof Ct:throw new Ct(e,r);case t instanceof $t:throw new $t(e,r);case t instanceof zt:throw new zt(e,r);case t instanceof Rt:throw new Rt(e,r);default:throw new Nt(e,r)}}var Dt=function(t){return!!k(t)||null!=t&&""!==_t(t)},Ht="[object Number]";function Lt(t){return function(t){return"number"==typeof t||D(t)&&J(t)==Ht}(t)&&t!=+t}var Bt="[object String]";function Kt(t){return"string"==typeof t||!k(t)&&D(t)&&J(t)==Bt}var Gt=function(t){return!Kt(t)&&!Lt(parseFloat(t))},Vt=function(t){return""!==_t(t)&&Kt(t)},Wt=function(t){return null!=t&&"boolean"==typeof t},Yt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==_t(t)&&(!1===e||!0===e&&null!==t)},Qt=d,Xt=v,Zt=g,te=y,ee=b,re=m,ne="continue",oe=function(t){switch(t){case"number":return Gt;case"string":return Vt;case"boolean":return Wt;default:return Yt}},ie=function(t,e){return void 0===e&&(e=""),!!k(t)&&(""===e||""===_t(e)||!(t.filter((function(t){return!oe(e)(t)})).length>0))},ae=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ue=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!oe(e)(t)})).length)})).length:e.length>e.filter((function(t){return!ie(r,t)})).length};var ce,se=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ce?a:++n];if(!1===e(o[u],u,o))break}return t};var fe="[object Arguments]";function le(t){return D(t)&&J(t)==fe}var pe=Object.prototype,he=pe.hasOwnProperty,de=pe.propertyIsEnumerable,ve=le(function(){return arguments}())?le:function(t){return D(t)&&he.call(t,"callee")&&!de.call(t,"callee")};var ge="object"==typeof exports&&exports&&!exports.nodeType&&exports,ye=ge&&"object"==typeof module&&module&&!module.nodeType&&module,be=ye&&ye.exports===ge?x.Buffer:void 0,me=(be?be.isBuffer:void 0)||function(){return!1},_e=9007199254740991,we=/^(?:0|[1-9]\d*)$/;function je(t,e){var r=typeof t;return!!(e=null==e?_e:e)&&("number"==r||"symbol"!=r&&we.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Oe}var ke={};ke["[object Float32Array]"]=ke["[object Float64Array]"]=ke["[object Int8Array]"]=ke["[object Int16Array]"]=ke["[object Int32Array]"]=ke["[object Uint8Array]"]=ke["[object Uint8ClampedArray]"]=ke["[object Uint16Array]"]=ke["[object Uint32Array]"]=!0,ke["[object Arguments]"]=ke["[object Array]"]=ke["[object ArrayBuffer]"]=ke["[object Boolean]"]=ke["[object DataView]"]=ke["[object Date]"]=ke["[object Error]"]=ke["[object Function]"]=ke["[object Map]"]=ke["[object Number]"]=ke["[object Object]"]=ke["[object RegExp]"]=ke["[object Set]"]=ke["[object String]"]=ke["[object WeakMap]"]=!1;var Ee,Ae="object"==typeof exports&&exports&&!exports.nodeType&&exports,Te=Ae&&"object"==typeof module&&module&&!module.nodeType&&module,xe=Te&&Te.exports===Ae&&A.process,Pe=function(){try{var t=Te&&Te.require&&Te.require("util").types;return t||xe&&xe.binding&&xe.binding("util")}catch(t){}}(),qe=Pe&&Pe.isTypedArray,Ce=qe?(Ee=qe,function(t){return Ee(t)}):function(t){return D(t)&&Se(t.length)&&!!ke[J(t)]},$e=Object.prototype.hasOwnProperty;function ze(t,e){var r=k(t),n=!r&&ve(t),o=!r&&!n&&me(t),i=!r&&!n&&!o&&Ce(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Qe.prototype.set=function(t,e){var r=this.__data__,n=We(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Xe,Ze=x["__core-js_shared__"],tr=(Xe=/[^.]+$/.exec(Ze&&Ze.keys&&Ze.keys.IE_PROTO||""))?"Symbol(src)_1."+Xe:"";var er=Function.prototype.toString;function rr(t){if(null!=t){try{return er.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var nr=/^\[object .+?Constructor\]$/,or=Function.prototype,ir=Object.prototype,ar=or.toString,ur=ir.hasOwnProperty,cr=RegExp("^"+ar.call(ur).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function sr(t){return!(!Je(t)||function(t){return!!tr&&tr in t}(t))&&(Le(t)?cr:nr).test(rr(t))}function fr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return sr(r)?r:void 0}var lr=fr(x,"Map"),pr=fr(Object,"create");var hr="__lodash_hash_undefined__",dr=Object.prototype.hasOwnProperty;var vr=Object.prototype.hasOwnProperty;var gr="__lodash_hash_undefined__";function yr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Er?new Or:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=ae(t))?!ue({arg:r},e):!oe(t)(r))})).length)})).length}return!1},Gn=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Kn,null,a);case"array"===t:return!ie(e.arg);case!1!==(r=ae(t)):return!ue(e,r);default:return!oe(t)(e.arg)}},Vn=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Wn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!ie(e))throw new Nt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!ie(t))throw new Nt("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Vn(t,a):t,index:r,param:a,optional:i}}));default:throw new Nt("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Dt(e)&&!(r.type.length>r.type.filter((function(e){return Gn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Gn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Yn=function(){try{var t=fr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Qn(t,e,r){"__proto__"==e&&Yn?Yn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Xn(t,e,r){(void 0===r||Ve(t[e],r))&&(void 0!==r||e in t)||Qn(t,e,r)}var Zn="object"==typeof exports&&exports&&!exports.nodeType&&exports,to=Zn&&"object"==typeof module&&module&&!module.nodeType&&module,eo=to&&to.exports===Zn?x.Buffer:void 0,ro=eo?eo.allocUnsafe:void 0;function no(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Tr(n).set(new Tr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var oo=Object.create,io=function(){function t(){}return function(e){if(!Je(e))return{};if(oo)return oo(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function ao(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var uo=Object.prototype.hasOwnProperty;function co(t,e,r){var n=t[e];uo.call(t,e)&&Ve(n,r)&&(void 0!==r||e in t)||Qn(t,e,r)}var so=Object.prototype.hasOwnProperty;function fo(t){if(!Je(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Re(t),r=[];for(var n in t)("constructor"!=n||!e&&so.call(t,n))&&r.push(n);return r}function lo(t){return Be(t)?ze(t,!0):fo(t)}function po(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=mo)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(bo);function Oo(t,e){return jo(function(t,e,r){return e=yo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=yo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=So.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Je(r))return!1;var n=typeof e;return!!("number"==n?Be(r)&&je(e,r.length):"string"==n&&e in r)&&Ve(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,wt(t))}),Reflect.apply(t,null,r))}};function Wo(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Yo(t,e,r,n){void 0===n&&(n=!1);var o=Wo(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Qo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Bo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(Ut)}},Xo=function(t,e,r,n,o){var i={},a=function(t){i=Yo(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return Bo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(Ut)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Zo=function(t,e,r,n,o){var i={},a=function(t){i=Yo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Bo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(Ut)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},ti=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Qo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Qo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var ei=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(Ot(e,r,O),o),t.$only(Ot(e,r,S),i),t.$trigger(e,{resolverName:r,args:n})}))}},ri=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function ni(t,e,r,n){var o=function(t,e,r,n){return Vo(Xo,Zo,ti)({},t,e,r,n)}(t,e,r,n);ri(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(Ot(t,n,O),r)})).catch((function(r){e.$trigger(Ot(t,n,S),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var oi=function(t,e,r,n){n.$suspend=!0,r.then((function(r){ni(t,n,e,r)}));var o={query:ei(n,"query"),mutation:ei(n,"mutation"),auth:ei(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.5.9",o};function ii(t){return!!function(t){return W(t)&&(jt(t,u)||jt(t,c)||jt(t,s))}(t)&&t}function ai(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}var ui=function(t,e){return void 0===e&&(e={}),ii(e)?Promise.resolve(e):t.getContract()},ci="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function si(t){this.message=t}si.prototype=new Error,si.prototype.name="InvalidCharacterError";var fi="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new si("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=ci.indexOf(n);return a};var li=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(fi(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return fi(e)}};function pi(t){this.message=t}pi.prototype=new Error,pi.prototype.name="InvalidTokenError";var hi=function(t,e){if("string"!=typeof t)throw new pi("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(li(t.split(".")[r]))}catch(t){throw new pi("Invalid token specified: "+t.message)}},di=pi;hi.InvalidTokenError=di;var vi,gi,yi,bi,mi,_i,wi,ji,Oi,Si=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function ki(t){if(Vt(t))return function(t){var e=t.iat||Si(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new Nt("Token has expired on "+r,t)}return t}(hi(t));throw new Nt("Token must be a string!")}Ko("HS256",["string"]),Ko(!1,["boolean","number","string"],((vi={})[m]="exp",vi[v]=!0,vi)),Ko(!1,["boolean","number","string"],((gi={})[m]="nbf",gi[v]=!0,gi)),Ko(!1,["boolean","string"],((yi={})[m]="iss",yi[v]=!0,yi)),Ko(!1,["boolean","string"],((bi={})[m]="sub",bi[v]=!0,bi)),Ko(!1,["boolean","string"],((mi={})[m]="iss",mi[v]=!0,mi)),Ko(!1,["boolean"],((_i={})[v]=!0,_i)),Ko(!1,["boolean","string"],((wi={})[v]=!0,wi)),Ko(!1,["boolean","string"],((ji={})[v]=!0,ji)),Ko(!1,["boolean"],((Oi={})[v]=!0,Oi));var Ei=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},Ai=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=Wi().key(e);t(Yi(r),r)}},remove:function(t){return Wi().removeItem(t)},clearAll:function(){return Wi().clear()}};function Wi(){return Gi.localStorage}function Yi(t){return Wi().getItem(t)}var Qi=qi.trim,Xi={name:"cookieStorage",read:function(t){if(!t||!ra(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Zi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Zi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:ta,remove:ea,clearAll:function(){ta((function(t,e){ea(e)}))}},Zi=qi.Global.document;function ta(t){for(var e=Zi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Qi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function ea(t){t&&ra(t)&&(Zi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ra(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Zi.cookie)}var na=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var oa=qi.bind,ia=qi.each,aa=qi.create,ua=qi.slice,ca=function(){var t=aa(sa,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,oa(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,oa(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),ia(r,(function(e,r){t.fire(r,void 0,e)}))}}};var sa={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,oa(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=ua(arguments,1);ia(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},fa=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),la=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=fa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=fa.compress(this._serialize(r));t(e,n)}}};var pa=[Vi,Xi],ha=[na,ca,la],da=Li.createStore(pa,ha),va=qi.Global;function ga(){return va.sessionStorage}function ya(t){return ga().getItem(t)}var ba=[{name:"sessionStorage",read:ya,write:function(t,e){return ga().setItem(t,e)},each:function(t){for(var e=ga().length-1;e>=0;e--){var r=ga().key(e);t(ya(r),r)}},remove:function(t){return ga().removeItem(t)},clearAll:function(){return ga().clear()}},Xi],ma=[na,la],_a=Li.createStore(ba,ma),wa=da,ja=_a,Oa=function(t){var e;return(e={}).args=t,e};function Sa(t,e){var r;return(r={})[t]=e,r[p]=[Ei()],r}var ka=function(t){return jt(t,"data")&&!jt(t,"error")?t.data:t},Ea=function(t){this.opts=t,this.instanceKey=ai(this.opts.hostname),this.localStore=wa,this.sessionStore=ja},Aa={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Ea.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?ko({},o,e):e,r))},Ea.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Ea.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},Ea.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Aa.lset.set=function(t){return this.__setMethod("localStore",t)},Aa.lget.get=function(){return this.__getMethod("localStore")},Ea.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Ea.prototype.lclear=function(){return this.__clearMethod("localStore")},Aa.sset.set=function(t){return this.__setMethod("sessionStore",t)},Aa.sget.get=function(){return this.__getMethod("sessionStore")},Ea.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Ea.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Ea.prototype,Aa);var Ta=h[0],xa=h[1],Pa=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,t)}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=ki),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(Lo(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new zt("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&Lo(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!ii(t))throw new zt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=ii(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=ko({},{_cb:Ei()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=ko({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=ko({},{method:Ta,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return ka(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=Ho(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):ka(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new Rt("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?ko({},a,this.getAuthHeader(),this.extraHeader):ko({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=ko({},this.extraParams,w)),this.request({},{method:"GET"},this.contractHeader).then(It).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new Rt("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Kt(t)&&k(e)){var n=Oa(e);return!0===r?n:Sa(t,n)}throw new zt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(It)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[f]=e,o[l]=r,!0===n)return o;if(Kt(t))return Sa(t,o);throw new zt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:xa}).then(It)},Object.defineProperties(e.prototype,r),e}(Ea)))),qa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Ca={hostname:Ko(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Ko("jsonql",["string"]),loginHandlerName:Ko("login",["string"]),logoutHandlerName:Ko("logout",["string"]),enableJsonp:Ko(!1,["boolean"]),enableAuth:Ko(!1,["boolean"]),useJwt:Ko(!0,["boolean"]),persistToken:Ko(!1,["boolean","number"]),useLocalstorage:Ko(!0,["boolean"]),storageKey:Ko("jsonqlstore",["string"]),authKey:Ko("jsonqlauthkey",["string"]),contractExpired:Ko(0,["number"]),keepContract:Ko(!0,["boolean"]),exposeContract:Ko(!1,["boolean"]),exposeStore:Ko(!1,["boolean"]),showContractDesc:Ko(!1,["boolean"]),contractKey:Ko(!1,["boolean"]),contractKeyName:Ko("X-JSONQL-CV-KEY",["string"]),enableTimeout:Ko(!1,["boolean"]),timeout:Ko(5e3,["number"]),returnInstance:Ko(!1,["boolean"]),allowReturnRawToken:Ko(!1,["boolean"]),debugOn:Ko(!1,["boolean"])};function $a(t){return Wo(t,_)?t:function(t){return Go(t,Ca,qa)}(t)}var za=new WeakMap,Na=new WeakMap,Ra=function(){this.__suspend__=null,this.queueStore=new Set},Ma={$suspend:{configurable:!0},$queues:{configurable:!0}};Ma.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},Ra.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},Ma.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Ra.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(Ra.prototype,Ma);var Fa=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){za.set(this,t)},r.normalStore.get=function(){return za.get(this)},r.lazyStore.set=function(t){Na.set(this,t)},r.lazyStore.get=function(){return Na.get(this)},e.prototype.hashFnToKey=function(t){return ai(t.toString())},Object.defineProperties(e.prototype,r),e}(Ra));function Ja(t,e){void 0===e&&(e={});var r,n=e.contract,o=$a(e),i=new Pa(t,o),a=ui(i,n),u=(r=o.debugOn,new Fa({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=oi(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),Ja(new o,t)}})); //# sourceMappingURL=jsonql-client.static.js.map diff --git a/packages/http-client/dist/jsonql-client.umd.js b/packages/http-client/dist/jsonql-client.umd.js index de1bef94..3afa5a89 100644 --- a/packages/http-client/dist/jsonql-client.umd.js +++ b/packages/http-client/dist/jsonql-client.umd.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],S="application/x-www-form-urlencoded";for(var O in o.trim((j||"").toLowerCase())===S?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(S="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=S),r.headers)if(O===u&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function k(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function E(t){t.engine=a,k(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,k(l.handler,s,0);else{var f=new A(c,i);f.response=s,E(f)}}catch(f){E(new A(f.msg,a.status))}},a.onerror=function(t){E(new A(t.msg||"Network Error",0))},a.ontimeout=function(){E(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u="query",c="mutation",s="socket",f="payload",l="condition",p="TS",h=["POST","PUT"],d="type",v="optional",g="enumv",y="args",b="checker",m="alias",_="__checked__",w={desc:"y"},j="No message",S=Array.isArray,O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},k="object"==typeof O&&O&&O.Object===Object&&O,E="object"==typeof self&&self&&self.Object===Object&&self,A=k||E||Function("return this")(),x=A.Symbol,T=Object.prototype,P=T.hasOwnProperty,q=T.toString,C=x?x.toStringTag:void 0;var $=Object.prototype.toString;var z="[object Null]",N="[object Undefined]",R=x?x.toStringTag:void 0;function M(t){return null==t?void 0===t?N:z:R&&R in Object(t)?function(t){var e=P.call(t,C),r=t[C];try{t[C]=void 0;var n=!0}catch(t){}var o=q.call(t);return n&&(e?t[C]=r:delete t[C]),o}(t):function(t){return $.call(t)}(t)}function F(t,e){return function(r){return t(e(r))}}var I=F(Object.getPrototypeOf,Object);function J(t){return null!=t&&"object"==typeof t}var U="[object Object]",D=Function.prototype,L=Object.prototype,H=D.toString,B=L.hasOwnProperty,K=H.call(Object);function G(t){if(!J(t)||M(t)!=U)return!1;var e=I(t);if(null===e)return!0;var r=B.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&H.call(r)==K}function V(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&nt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var mt=function(t){return S(t)?t:[t]},_t=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},wt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),jt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),St=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),Ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),kt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),Et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),At=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),xt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),Tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),Pt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),qt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),Ct=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),$t=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),zt=Object.freeze({__proto__:null,Jsonql406Error:wt,Jsonql500Error:jt,JsonqlForbiddenError:St,JsonqlAuthorisationError:Ot,JsonqlContractAuthError:kt,JsonqlResolverAppError:Et,JsonqlResolverNotFoundError:At,JsonqlEnumError:xt,JsonqlTypeError:Tt,JsonqlCheckerError:Pt,JsonqlValidationError:qt,JsonqlError:Ct,JsonqlServerError:$t}),Nt=Ct,Rt=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function Mt(t){if(Rt(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||j,a=e.detail||e;if(o&&zt[o])throw new zt[r](i,a);throw new Nt(i,a)}return t}function Ft(t){if(Array.isArray(t))throw new qt("",t);var e=t.message||j,r=t.detail||t;switch(!0){case t instanceof wt:throw new wt(e,r);case t instanceof jt:throw new jt(e,r);case t instanceof St:throw new St(e,r);case t instanceof Ot:throw new Ot(e,r);case t instanceof kt:throw new kt(e,r);case t instanceof Et:throw new Et(e,r);case t instanceof At:throw new At(e,r);case t instanceof xt:throw new xt(e,r);case t instanceof Tt:throw new Tt(e,r);case t instanceof Pt:throw new Pt(e,r);case t instanceof qt:throw new qt(e,r);case t instanceof $t:throw new $t(e,r);default:throw new Ct(e,r)}}function It(t){return!!function(t){return G(t)&&(_t(t,u)||_t(t,c)||_t(t,s))}(t)&&t}function Jt(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}var Ut=function(t,e){return void 0===e&&(e={}),It(e)?Promise.resolve(e):t.getContract()},Dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Lt(t){this.message=t}Lt.prototype=new Error,Lt.prototype.name="InvalidCharacterError";var Ht="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Lt("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=Dt.indexOf(n);return a};var Bt=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Ht(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return Ht(e)}};function Kt(t){this.message=t}Kt.prototype=new Error,Kt.prototype.name="InvalidTokenError";var Gt=function(t,e){if("string"!=typeof t)throw new Kt("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Bt(t.split(".")[r]))}catch(t){throw new Kt("Invalid token specified: "+t.message)}},Vt=Kt;Gt.InvalidTokenError=Vt;var Wt="[object String]";function Yt(t){return"string"==typeof t||!S(t)&&J(t)&&M(t)==Wt}var Qt=function(t){return""!==bt(t)&&Yt(t)},Xt=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Zt(t){if(Qt(t))return function(t){var e=t.iat||Xt(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new Ct("Token has expired on "+r,t)}return t}(Gt(t));throw new Ct("Token must be a string!")}var te=function(t){return!!S(t)||null!=t&&""!==bt(t)},ee="[object Number]";function re(t){return function(t){return"number"==typeof t||J(t)&&M(t)==ee}(t)&&t!=+t}var ne=function(t){return!Yt(t)&&!re(parseFloat(t))},oe=function(t){return null!=t&&"boolean"==typeof t},ie=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==bt(t)&&(!1===e||!0===e&&null!==t)},ae=d,ue=v,ce=g,se=y,fe=b,le=m,pe="continue",he=function(t){switch(t){case"number":return ne;case"string":return Qt;case"boolean":return oe;default:return ie}},de=function(t,e){return void 0===e&&(e=""),!!S(t)&&(""===e||""===bt(e)||!(t.filter((function(t){return!he(e)(t)})).length>0))},ve=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ge=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!he(e)(t)})).length)})).length:e.length>e.filter((function(t){return!de(r,t)})).length};var ye,be=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ye?a:++n];if(!1===e(o[u],u,o))break}return t};var me="[object Arguments]";function _e(t){return J(t)&&M(t)==me}var we=Object.prototype,je=we.hasOwnProperty,Se=we.propertyIsEnumerable,Oe=_e(function(){return arguments}())?_e:function(t){return J(t)&&je.call(t,"callee")&&!Se.call(t,"callee")};var ke="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ee=ke&&"object"==typeof module&&module&&!module.nodeType&&module,Ae=Ee&&Ee.exports===ke?A.Buffer:void 0,xe=(Ae?Ae.isBuffer:void 0)||function(){return!1},Te=9007199254740991,Pe=/^(?:0|[1-9]\d*)$/;function qe(t,e){var r=typeof t;return!!(e=null==e?Te:e)&&("number"==r||"symbol"!=r&&Pe.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Ce}var ze={};ze["[object Float32Array]"]=ze["[object Float64Array]"]=ze["[object Int8Array]"]=ze["[object Int16Array]"]=ze["[object Int32Array]"]=ze["[object Uint8Array]"]=ze["[object Uint8ClampedArray]"]=ze["[object Uint16Array]"]=ze["[object Uint32Array]"]=!0,ze["[object Arguments]"]=ze["[object Array]"]=ze["[object ArrayBuffer]"]=ze["[object Boolean]"]=ze["[object DataView]"]=ze["[object Date]"]=ze["[object Error]"]=ze["[object Function]"]=ze["[object Map]"]=ze["[object Number]"]=ze["[object Object]"]=ze["[object RegExp]"]=ze["[object Set]"]=ze["[object String]"]=ze["[object WeakMap]"]=!1;var Ne,Re="object"==typeof exports&&exports&&!exports.nodeType&&exports,Me=Re&&"object"==typeof module&&module&&!module.nodeType&&module,Fe=Me&&Me.exports===Re&&k.process,Ie=function(){try{var t=Me&&Me.require&&Me.require("util").types;return t||Fe&&Fe.binding&&Fe.binding("util")}catch(t){}}(),Je=Ie&&Ie.isTypedArray,Ue=Je?(Ne=Je,function(t){return Ne(t)}):function(t){return J(t)&&$e(t.length)&&!!ze[M(t)]},De=Object.prototype.hasOwnProperty;function Le(t,e){var r=S(t),n=!r&&Oe(t),o=!r&&!n&&xe(t),i=!r&&!n&&!o&&Ue(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ar.prototype.set=function(t,e){var r=this.__data__,n=or(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ur,cr=A["__core-js_shared__"],sr=(ur=/[^.]+$/.exec(cr&&cr.keys&&cr.keys.IE_PROTO||""))?"Symbol(src)_1."+ur:"";var fr=Function.prototype.toString;function lr(t){if(null!=t){try{return fr.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var pr=/^\[object .+?Constructor\]$/,hr=Function.prototype,dr=Object.prototype,vr=hr.toString,gr=dr.hasOwnProperty,yr=RegExp("^"+vr.call(gr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function br(t){return!(!Ve(t)||function(t){return!!sr&&sr in t}(t))&&(Ze(t)?yr:pr).test(lr(t))}function mr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return br(r)?r:void 0}var _r=mr(A,"Map"),wr=mr(Object,"create");var jr="__lodash_hash_undefined__",Sr=Object.prototype.hasOwnProperty;var Or=Object.prototype.hasOwnProperty;var kr="__lodash_hash_undefined__";function Er(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Nr?new Cr:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=ve(t))?!ge({arg:r},e):!he(t)(r))})).length)})).length}return!1},ro=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(eo,null,a);case"array"===t:return!de(e.arg);case!1!==(r=ve(t)):return!ge(e,r);default:return!he(t)(e.arg)}},no=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},oo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!de(e))throw new Ct("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!de(t))throw new Ct("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?no(t,a):t,index:r,param:a,optional:i}}));default:throw new Ct("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!te(e)&&!(r.type.length>r.type.filter((function(e){return ro(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return ro(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},io=function(){try{var t=mr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function ao(t,e,r){"__proto__"==e&&io?io(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function uo(t,e,r){(void 0===r||nr(t[e],r))&&(void 0!==r||e in t)||ao(t,e,r)}var co="object"==typeof exports&&exports&&!exports.nodeType&&exports,so=co&&"object"==typeof module&&module&&!module.nodeType&&module,fo=so&&so.exports===co?A.Buffer:void 0,lo=fo?fo.allocUnsafe:void 0;function po(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Mr(n).set(new Mr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var ho=Object.create,vo=function(){function t(){}return function(e){if(!Ve(e))return{};if(ho)return ho(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function go(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var yo=Object.prototype.hasOwnProperty;function bo(t,e,r){var n=t[e];yo.call(t,e)&&nr(n,r)&&(void 0!==r||e in t)||ao(t,e,r)}var mo=Object.prototype.hasOwnProperty;function _o(t){if(!Ve(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Be(t),r=[];for(var n in t)("constructor"!=n||!e&&mo.call(t,n))&&r.push(n);return r}function wo(t){return tr(t)?Le(t,!0):_o(t)}function jo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=xo)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Ao);function Co(t,e){return qo(function(t,e,r){return e=Eo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Eo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=$o.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Ve(r))return!1;var n=typeof e;return!!("number"==n?tr(r)&&qe(e,r.length):"string"==n&&e in r)&&nr(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r=0;e--){var r=Ri().key(e);t(Mi(r),r)}},remove:function(t){return Ri().removeItem(t)},clearAll:function(){return Ri().clear()}};function Ri(){return zi.localStorage}function Mi(t){return Ri().getItem(t)}var Fi=bi.trim,Ii={name:"cookieStorage",read:function(t){if(!t||!Li(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Ji.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Ji.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Ui,remove:Di,clearAll:function(){Ui((function(t,e){Di(e)}))}},Ji=bi.Global.document;function Ui(t){for(var e=Ji.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Fi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Di(t){t&&Li(t)&&(Ji.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Li(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Ji.cookie)}var Hi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var Bi=bi.bind,Ki=bi.each,Gi=bi.create,Vi=bi.slice,Wi=function(){var t=Gi(Yi,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Bi(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Bi(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),Ki(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Yi={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Bi(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Vi(arguments,1);Ki(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Qi=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Xi=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Qi.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Qi.compress(this._serialize(r));t(e,n)}}};var Zi=[Ni,Ii],ta=[Hi,Wi,Xi],ea=qi.createStore(Zi,ta),ra=bi.Global;function na(){return ra.sessionStorage}function oa(t){return na().getItem(t)}var ia=[{name:"sessionStorage",read:oa,write:function(t,e){return na().setItem(t,e)},each:function(t){for(var e=na().length-1;e>=0;e--){var r=na().key(e);t(oa(r),r)}},remove:function(t){return na().removeItem(t)},clearAll:function(){return na().clear()}},Ii],aa=[Hi,Xi],ua=qi.createStore(ia,aa),ca=ea,sa=ua,fa=function(t){var e;return(e={}).args=t,e};function la(t,e){var r;return(r={})[t]=e,r[p]=[hi()],r}var pa=function(t){return _t(t,"data")&&!_t(t,"error")?t.data:t},ha=function(t){this.opts=t,this.instanceKey=Jt(this.opts.hostname),this.localStore=ca,this.sessionStore=sa},da={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};ha.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?zo({},o,e):e,r))},ha.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},ha.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},ha.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},da.lset.set=function(t){return this.__setMethod("localStore",t)},da.lget.get=function(){return this.__getMethod("localStore")},ha.prototype.ldel=function(t){return this.__delMethod("localStore",t)},ha.prototype.lclear=function(){return this.__clearMethod("localStore")},da.sset.set=function(t){return this.__setMethod("sessionStore",t)},da.sget.get=function(){return this.__getMethod("sessionStore")},ha.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},ha.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(ha.prototype,da);var va=h[0],ga=h[1],ya=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,t)}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Zt),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(si(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new qt("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&si(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!It(t))throw new qt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=It(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=zo({},{_cb:hi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=zo({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=zo({},{method:va,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return pa(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=ci(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):pa(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new $t("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?zo({},a,this.getAuthHeader(),this.extraHeader):zo({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=zo({},this.extraParams,w)),this.request({},{method:"GET"},this.contractHeader).then(Mt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new $t("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Yt(t)&&S(e)){var n=fa(e);return!0===r?n:la(t,n)}throw new qt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(Mt)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[f]=e,o[l]=r,!0===n)return o;if(Yt(t))return la(t,o);throw new qt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ga}).then(Mt)},Object.defineProperties(e.prototype,r),e}(ha)))),ba=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,mt(t))}),Reflect.apply(t,null,r))}};function ma(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function _a(t,e,r,n){void 0===n&&(n=!1);var o=ma(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var wa=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return fi(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(Ft)}},ja=function(t,e,r,n,o){var i={},a=function(t){i=_a(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return fi(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(Ft)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Sa=function(t,e,r,n,o){var i={},a=function(t){i=_a(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return fi(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(Ft)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Oa=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=wa(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=wa(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var ka=function(t,e,r,n){var o=function(t,e,r,n){return ba(ja,Sa,Oa)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.jsonqlUserdata},o.getToken=function(e){return void 0===e&&(e=!1),t.rawAuthToken(e)},o.profileIndex=function(e){if(void 0===e&&(e=!1),!1===e)return t.profileIndex;t.profileIndex=e},o.getProfiles=function(e){return void 0===e&&(e=!1),t.getProfiles(e)}),e.exposeContract&&(o.getContract=function(){return t.getContract()}),e.exposeStore&&(o.tmpSave=function(t){},o.tmpGet=function(t){},o.tmpDel=function(t){},o.persistSave=function(t){},o.persistGet=function(t){},o.persistDel=function(t){}),o.eventEmitter=n,o.version="1.5.8",o.getLogger=function(e){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(t.log,t,[e].concat(r))}},o},Ea={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Aa={hostname:li(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:li("jsonql",["string"]),loginHandlerName:li("login",["string"]),logoutHandlerName:li("logout",["string"]),enableJsonp:li(!1,["boolean"]),enableAuth:li(!1,["boolean"]),useJwt:li(!0,["boolean"]),persistToken:li(!1,["boolean","number"]),useLocalstorage:li(!0,["boolean"]),storageKey:li("jsonqlstore",["string"]),authKey:li("jsonqlauthkey",["string"]),contractExpired:li(0,["number"]),keepContract:li(!0,["boolean"]),exposeContract:li(!1,["boolean"]),exposeStore:li(!1,["boolean"]),showContractDesc:li(!1,["boolean"]),contractKey:li(!1,["boolean"]),contractKeyName:li("X-JSONQL-CV-KEY",["string"]),enableTimeout:li(!1,["boolean"]),timeout:li(5e3,["number"]),returnInstance:li(!1,["boolean"]),allowReturnRawToken:li(!1,["boolean"]),debugOn:li(!1,["boolean"])};function xa(t){return ma(t,_)?Promise.resolve(t):function(t){var e=t.contract;return pi(t,Aa,Ea).then((function(t){return t.contract=e,t}))}(t)}var Ta=new WeakMap,Pa=new WeakMap,qa=function(){this.__suspend__=null,this.queueStore=new Set},Ca={$suspend:{configurable:!0},$queues:{configurable:!0}};Ca.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},qa.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},Ca.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},qa.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(qa.prototype,Ca);var $a=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){Ta.set(this,t)},r.normalStore.get=function(){return Ta.get(this)},r.lazyStore.set=function(t){Pa.set(this,t)},r.lazyStore.get=function(){return Pa.get(this)},e.prototype.hashFnToKey=function(t){return Jt(t.toString())},Object.defineProperties(e.prototype,r),e}(qa));function za(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),xa(e).then((function(t){return{baseClient:new ya(r,t),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return Ut(r,n.contract).then((function(e){return ka(r,n,e,t)}))}))}((r=e.debugOn,new $a({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}return function(t){return void 0===t&&(t={}),za(new o,t)}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClient=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,e){return t(e={exports:{}},e.exports),e.exports}var r,n=e((function(t,e){var r;r=function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports={type:function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},isObject:function(t,e){return e?"object"===this.type(t):t&&"object"===(void 0===t?"undefined":n(t))},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},encode:function(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")},formatParams:function(t){var e="",r=!0,n=this;return this.isObject(t)?(function t(o,i){var a=n.encode,u=n.type(o);if("array"==u)o.forEach((function(e,r){n.isObject(e)||(r=""),t(e,i+"%5B"+r+"%5D")}));else if("object"==u)for(var c in o)t(o[c],i?i+"%5B"+a(c)+"%5D":a(c));else r||(e+="&"),r=!1,e+=i+"="+a(o)}(t,""),e):t},merge:function(t,e){for(var r in e)t.hasOwnProperty(r)?this.isObject(e[r],1)&&this.isObject(t[r],1)&&this.merge(t[r],e[r]):t[r]=e[r];return t}}},,function(t,e,r){var n=function(){function t(t,e){for(var r=0;r0&&(t+=(-1===t.indexOf("?")?"?":"&")+w.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==y&&(a.responseType=y)}catch(t){}var j=r.headers[u]||r.headers[c],S="application/x-www-form-urlencoded";for(var O in o.trim((j||"").toLowerCase())===S?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(S="application/json;charset=utf-8",e=JSON.stringify(e)),j||b||(r.headers[u]=S),r.headers)if(O===u&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function k(t,e,n){v(l.p,(function(){if(t){n&&(e.request=r);var o=t.call(l,e,Promise);e=void 0===o?e:o}d(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){s(t)})).catch((function(t){h(t)}))}))}function E(t){t.engine=a,k(l.onerror,t,-1)}function A(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader(u)||"").indexOf("json")&&!o.isObject(t)&&(t=JSON.parse(t));var e=a.responseHeaders;if(!e){e={};var n=(a.getAllResponseHeaders()||"").split("\r\n");n.pop(),n.forEach((function(t){if(t){var r=t.split(":")[0];e[r]=a.getResponseHeader(r)}}))}var i=a.status,c=a.statusText,s={data:t,headers:e,status:i,statusText:c};if(o.merge(s,a._response),i>=200&&i<300||304===i)s.engine=a,s.request=r,k(l.handler,s,0);else{var f=new A(c,i);f.response=s,E(f)}}catch(f){E(new A(f.msg,a.status))}},a.onerror=function(t){E(new A(t.msg||"Network Error",0))},a.ontimeout=function(){E(new A("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(b?null:e)}),0)}(n):s(n)}),(function(t){h(t)}))}))}));return h.engine=a,h}},{key:"all",value:function(t){return Promise.all(t)}},{key:"spread",value:function(t){return function(e){return t.apply(null,e)}}}]),t}();a.default=a,["get","post","put","patch","head","delete"].forEach((function(t){a.prototype[t]=function(e,r,n){return this.request(e,r,o.merge({method:t},n))}})),["lock","unlock","clear"].forEach((function(t){a.prototype[t]=function(){this.interceptors.request[t]()}})),t.exports=a}])},t.exports=r()})),o=(r=n)&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,i="application/vnd.api+json",a={Accept:i,"Content-Type":[i,"charset=utf-8"].join(";")},u="query",c="mutation",s="socket",f="payload",l="condition",p="TS",h=["POST","PUT"],d="type",v="optional",g="enumv",y="args",b="checker",m="alias",_="__checked__",w={desc:"y"},j="No message",S=Array.isArray,O="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},k="object"==typeof O&&O&&O.Object===Object&&O,E="object"==typeof self&&self&&self.Object===Object&&self,A=k||E||Function("return this")(),x=A.Symbol,T=Object.prototype,P=T.hasOwnProperty,q=T.toString,C=x?x.toStringTag:void 0;var $=Object.prototype.toString;var z="[object Null]",N="[object Undefined]",R=x?x.toStringTag:void 0;function M(t){return null==t?void 0===t?N:z:R&&R in Object(t)?function(t){var e=P.call(t,C),r=t[C];try{t[C]=void 0;var n=!0}catch(t){}var o=q.call(t);return n&&(e?t[C]=r:delete t[C]),o}(t):function(t){return $.call(t)}(t)}function F(t,e){return function(r){return t(e(r))}}var I=F(Object.getPrototypeOf,Object);function J(t){return null!=t&&"object"==typeof t}var U="[object Object]",D=Function.prototype,L=Object.prototype,H=D.toString,B=L.hasOwnProperty,K=H.call(Object);function G(t){if(!J(t)||M(t)!=U)return!1;var e=I(t);if(null===e)return!0;var r=B.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&H.call(r)==K}function V(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&nt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var mt=function(t){return S(t)?t:[t]},_t=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},wt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),jt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),St=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),Ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),kt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),Et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),At=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),xt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),Tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),Pt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),qt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),Ct=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),$t=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),zt=Object.freeze({__proto__:null,Jsonql406Error:wt,Jsonql500Error:jt,JsonqlForbiddenError:St,JsonqlAuthorisationError:Ot,JsonqlContractAuthError:kt,JsonqlResolverAppError:Et,JsonqlResolverNotFoundError:At,JsonqlEnumError:xt,JsonqlTypeError:Tt,JsonqlCheckerError:Pt,JsonqlValidationError:qt,JsonqlError:Ct,JsonqlServerError:$t}),Nt=Ct,Rt=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function Mt(t){if(Rt(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||j,a=e.detail||e;if(o&&zt[o])throw new zt[r](i,a);throw new Nt(i,a)}return t}function Ft(t){if(Array.isArray(t))throw new qt("",t);var e=t.message||j,r=t.detail||t;switch(!0){case t instanceof wt:throw new wt(e,r);case t instanceof jt:throw new jt(e,r);case t instanceof St:throw new St(e,r);case t instanceof Ot:throw new Ot(e,r);case t instanceof kt:throw new kt(e,r);case t instanceof Et:throw new Et(e,r);case t instanceof At:throw new At(e,r);case t instanceof xt:throw new xt(e,r);case t instanceof Tt:throw new Tt(e,r);case t instanceof Pt:throw new Pt(e,r);case t instanceof qt:throw new qt(e,r);case t instanceof $t:throw new $t(e,r);default:throw new Ct(e,r)}}function It(t){return!!function(t){return G(t)&&(_t(t,u)||_t(t,c)||_t(t,s))}(t)&&t}function Jt(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}var Ut=function(t,e){return void 0===e&&(e={}),It(e)?Promise.resolve(e):t.getContract()},Dt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function Lt(t){this.message=t}Lt.prototype=new Error,Lt.prototype.name="InvalidCharacterError";var Ht="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Lt("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=Dt.indexOf(n);return a};var Bt=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(Ht(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return Ht(e)}};function Kt(t){this.message=t}Kt.prototype=new Error,Kt.prototype.name="InvalidTokenError";var Gt=function(t,e){if("string"!=typeof t)throw new Kt("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Bt(t.split(".")[r]))}catch(t){throw new Kt("Invalid token specified: "+t.message)}},Vt=Kt;Gt.InvalidTokenError=Vt;var Wt="[object String]";function Yt(t){return"string"==typeof t||!S(t)&&J(t)&&M(t)==Wt}var Qt=function(t){return""!==bt(t)&&Yt(t)},Xt=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Zt(t){if(Qt(t))return function(t){var e=t.iat||Xt(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new Ct("Token has expired on "+r,t)}return t}(Gt(t));throw new Ct("Token must be a string!")}var te=function(t){return!!S(t)||null!=t&&""!==bt(t)},ee="[object Number]";function re(t){return function(t){return"number"==typeof t||J(t)&&M(t)==ee}(t)&&t!=+t}var ne=function(t){return!Yt(t)&&!re(parseFloat(t))},oe=function(t){return null!=t&&"boolean"==typeof t},ie=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==bt(t)&&(!1===e||!0===e&&null!==t)},ae=d,ue=v,ce=g,se=y,fe=b,le=m,pe="continue",he=function(t){switch(t){case"number":return ne;case"string":return Qt;case"boolean":return oe;default:return ie}},de=function(t,e){return void 0===e&&(e=""),!!S(t)&&(""===e||""===bt(e)||!(t.filter((function(t){return!he(e)(t)})).length>0))},ve=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},ge=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!he(e)(t)})).length)})).length:e.length>e.filter((function(t){return!de(r,t)})).length};var ye,be=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ye?a:++n];if(!1===e(o[u],u,o))break}return t};var me="[object Arguments]";function _e(t){return J(t)&&M(t)==me}var we=Object.prototype,je=we.hasOwnProperty,Se=we.propertyIsEnumerable,Oe=_e(function(){return arguments}())?_e:function(t){return J(t)&&je.call(t,"callee")&&!Se.call(t,"callee")};var ke="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ee=ke&&"object"==typeof module&&module&&!module.nodeType&&module,Ae=Ee&&Ee.exports===ke?A.Buffer:void 0,xe=(Ae?Ae.isBuffer:void 0)||function(){return!1},Te=9007199254740991,Pe=/^(?:0|[1-9]\d*)$/;function qe(t,e){var r=typeof t;return!!(e=null==e?Te:e)&&("number"==r||"symbol"!=r&&Pe.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=Ce}var ze={};ze["[object Float32Array]"]=ze["[object Float64Array]"]=ze["[object Int8Array]"]=ze["[object Int16Array]"]=ze["[object Int32Array]"]=ze["[object Uint8Array]"]=ze["[object Uint8ClampedArray]"]=ze["[object Uint16Array]"]=ze["[object Uint32Array]"]=!0,ze["[object Arguments]"]=ze["[object Array]"]=ze["[object ArrayBuffer]"]=ze["[object Boolean]"]=ze["[object DataView]"]=ze["[object Date]"]=ze["[object Error]"]=ze["[object Function]"]=ze["[object Map]"]=ze["[object Number]"]=ze["[object Object]"]=ze["[object RegExp]"]=ze["[object Set]"]=ze["[object String]"]=ze["[object WeakMap]"]=!1;var Ne,Re="object"==typeof exports&&exports&&!exports.nodeType&&exports,Me=Re&&"object"==typeof module&&module&&!module.nodeType&&module,Fe=Me&&Me.exports===Re&&k.process,Ie=function(){try{var t=Me&&Me.require&&Me.require("util").types;return t||Fe&&Fe.binding&&Fe.binding("util")}catch(t){}}(),Je=Ie&&Ie.isTypedArray,Ue=Je?(Ne=Je,function(t){return Ne(t)}):function(t){return J(t)&&$e(t.length)&&!!ze[M(t)]},De=Object.prototype.hasOwnProperty;function Le(t,e){var r=S(t),n=!r&&Oe(t),o=!r&&!n&&xe(t),i=!r&&!n&&!o&&Ue(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ar.prototype.set=function(t,e){var r=this.__data__,n=or(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ur,cr=A["__core-js_shared__"],sr=(ur=/[^.]+$/.exec(cr&&cr.keys&&cr.keys.IE_PROTO||""))?"Symbol(src)_1."+ur:"";var fr=Function.prototype.toString;function lr(t){if(null!=t){try{return fr.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var pr=/^\[object .+?Constructor\]$/,hr=Function.prototype,dr=Object.prototype,vr=hr.toString,gr=dr.hasOwnProperty,yr=RegExp("^"+vr.call(gr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function br(t){return!(!Ve(t)||function(t){return!!sr&&sr in t}(t))&&(Ze(t)?yr:pr).test(lr(t))}function mr(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return br(r)?r:void 0}var _r=mr(A,"Map"),wr=mr(Object,"create");var jr="__lodash_hash_undefined__",Sr=Object.prototype.hasOwnProperty;var Or=Object.prototype.hasOwnProperty;var kr="__lodash_hash_undefined__";function Er(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&Nr?new Cr:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=ve(t))?!ge({arg:r},e):!he(t)(r))})).length)})).length}return!1},ro=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(eo,null,a);case"array"===t:return!de(e.arg);case!1!==(r=ve(t)):return!ge(e,r);default:return!he(t)(e.arg)}},no=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},oo=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!de(e))throw new Ct("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!de(t))throw new Ct("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?no(t,a):t,index:r,param:a,optional:i}}));default:throw new Ct("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!te(e)&&!(r.type.length>r.type.filter((function(e){return ro(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return ro(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},io=function(){try{var t=mr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function ao(t,e,r){"__proto__"==e&&io?io(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function uo(t,e,r){(void 0===r||nr(t[e],r))&&(void 0!==r||e in t)||ao(t,e,r)}var co="object"==typeof exports&&exports&&!exports.nodeType&&exports,so=co&&"object"==typeof module&&module&&!module.nodeType&&module,fo=so&&so.exports===co?A.Buffer:void 0,lo=fo?fo.allocUnsafe:void 0;function po(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Mr(n).set(new Mr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var ho=Object.create,vo=function(){function t(){}return function(e){if(!Ve(e))return{};if(ho)return ho(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function go(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var yo=Object.prototype.hasOwnProperty;function bo(t,e,r){var n=t[e];yo.call(t,e)&&nr(n,r)&&(void 0!==r||e in t)||ao(t,e,r)}var mo=Object.prototype.hasOwnProperty;function _o(t){if(!Ve(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Be(t),r=[];for(var n in t)("constructor"!=n||!e&&mo.call(t,n))&&r.push(n);return r}function wo(t){return tr(t)?Le(t,!0):_o(t)}function jo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=xo)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Ao);function Co(t,e){return qo(function(t,e,r){return e=Eo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Eo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=$o.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Ve(r))return!1;var n=typeof e;return!!("number"==n?tr(r)&&qe(e,r.length):"string"==n&&e in r)&&nr(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r=0;e--){var r=Ri().key(e);t(Mi(r),r)}},remove:function(t){return Ri().removeItem(t)},clearAll:function(){return Ri().clear()}};function Ri(){return zi.localStorage}function Mi(t){return Ri().getItem(t)}var Fi=bi.trim,Ii={name:"cookieStorage",read:function(t){if(!t||!Li(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Ji.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Ji.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Ui,remove:Di,clearAll:function(){Ui((function(t,e){Di(e)}))}},Ji=bi.Global.document;function Ui(t){for(var e=Ji.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Fi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Di(t){t&&Li(t)&&(Ji.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Li(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Ji.cookie)}var Hi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var Bi=bi.bind,Ki=bi.each,Gi=bi.create,Vi=bi.slice,Wi=function(){var t=Gi(Yi,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Bi(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Bi(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),Ki(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Yi={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,Bi(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Vi(arguments,1);Ki(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Qi=e((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Xi=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Qi.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Qi.compress(this._serialize(r));t(e,n)}}};var Zi=[Ni,Ii],ta=[Hi,Wi,Xi],ea=qi.createStore(Zi,ta),ra=bi.Global;function na(){return ra.sessionStorage}function oa(t){return na().getItem(t)}var ia=[{name:"sessionStorage",read:oa,write:function(t,e){return na().setItem(t,e)},each:function(t){for(var e=na().length-1;e>=0;e--){var r=na().key(e);t(oa(r),r)}},remove:function(t){return na().removeItem(t)},clearAll:function(){return na().clear()}},Ii],aa=[Hi,Xi],ua=qi.createStore(ia,aa),ca=ea,sa=ua,fa=function(t){var e;return(e={}).args=t,e};function la(t,e){var r;return(r={})[t]=e,r[p]=[hi()],r}var pa=function(t){return _t(t,"data")&&!_t(t,"error")?t.data:t},ha=function(t){this.opts=t,this.instanceKey=Jt(this.opts.hostname),this.localStore=ca,this.sessionStore=sa},da={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};ha.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?zo({},o,e):e,r))},ha.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},ha.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},ha.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},da.lset.set=function(t){return this.__setMethod("localStore",t)},da.lget.get=function(){return this.__getMethod("localStore")},ha.prototype.ldel=function(t){return this.__delMethod("localStore",t)},ha.prototype.lclear=function(){return this.__clearMethod("localStore")},da.sset.set=function(t){return this.__setMethod("sessionStore",t)},da.sget.get=function(){return this.__getMethod("sessionStore")},ha.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},ha.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(ha.prototype,da);var va=h[0],ga=h[1],ya=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,t)}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=Zt),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(si(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new qt("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&si(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!It(t))throw new qt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=It(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={headers:{configurable:!0}};return r.headers.set=function(t){this.extraHeader=t},e.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=zo({},{_cb:hi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=zo({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=zo({},{method:va,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},e.prototype.processJsonp=function(t){return pa(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=ci(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):pa(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new $t("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?zo({},a,this.getAuthHeader(),this.extraHeader):zo({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=zo({},this.extraParams,w)),this.request({},{method:"GET"},this.contractHeader).then(Mt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new $t("getRemoteContract",e)}))},e.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Yt(t)&&S(e)){var n=fa(e);return!0===r?n:la(t,n)}throw new qt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(Mt)},e.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[f]=e,o[l]=r,!0===n)return o;if(Yt(t))return la(t,o);throw new qt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ga}).then(Mt)},Object.defineProperties(e.prototype,r),e}(ha)))),ba=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,mt(t))}),Reflect.apply(t,null,r))}};function ma(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function _a(t,e,r,n){void 0===n&&(n=!1);var o=ma(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var wa=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return fi(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(Ft)}},ja=function(t,e,r,n,o){var i={},a=function(t){i=_a(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return fi(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(Ft)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Sa=function(t,e,r,n,o){var i={},a=function(t){i=_a(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return fi(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(Ft)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Oa=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=wa(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=wa(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var ka=function(t,e,r,n){var o=function(t,e,r,n){return ba(ja,Sa,Oa)({},t,e,r,n)}(t,n,e,r);return e.enableAuth&&(o.userdata=function(){return t.jsonqlUserdata},o.getToken=function(e){return void 0===e&&(e=!1),t.rawAuthToken(e)},o.profileIndex=function(e){if(void 0===e&&(e=!1),!1===e)return t.profileIndex;t.profileIndex=e},o.getProfiles=function(e){return void 0===e&&(e=!1),t.getProfiles(e)}),e.exposeContract&&(o.getContract=function(){return t.getContract()}),e.exposeStore&&(o.tmpSave=function(t){},o.tmpGet=function(t){},o.tmpDel=function(t){},o.persistSave=function(t){},o.persistGet=function(t){},o.persistDel=function(t){}),o.eventEmitter=n,o.version="1.5.9",o.getLogger=function(e){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(t.log,t,[e].concat(r))}},o},Ea={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Aa={hostname:li(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:li("jsonql",["string"]),loginHandlerName:li("login",["string"]),logoutHandlerName:li("logout",["string"]),enableJsonp:li(!1,["boolean"]),enableAuth:li(!1,["boolean"]),useJwt:li(!0,["boolean"]),persistToken:li(!1,["boolean","number"]),useLocalstorage:li(!0,["boolean"]),storageKey:li("jsonqlstore",["string"]),authKey:li("jsonqlauthkey",["string"]),contractExpired:li(0,["number"]),keepContract:li(!0,["boolean"]),exposeContract:li(!1,["boolean"]),exposeStore:li(!1,["boolean"]),showContractDesc:li(!1,["boolean"]),contractKey:li(!1,["boolean"]),contractKeyName:li("X-JSONQL-CV-KEY",["string"]),enableTimeout:li(!1,["boolean"]),timeout:li(5e3,["number"]),returnInstance:li(!1,["boolean"]),allowReturnRawToken:li(!1,["boolean"]),debugOn:li(!1,["boolean"])};function xa(t){return ma(t,_)?Promise.resolve(t):function(t){var e=t.contract;return pi(t,Aa,Ea).then((function(t){return t.contract=e,t}))}(t)}var Ta=new WeakMap,Pa=new WeakMap,qa=function(){this.__suspend__=null,this.queueStore=new Set},Ca={$suspend:{configurable:!0},$queues:{configurable:!0}};Ca.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},qa.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},Ca.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},qa.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(qa.prototype,Ca);var $a=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){Ta.set(this,t)},r.normalStore.get=function(){return Ta.get(this)},r.lazyStore.set=function(t){Pa.set(this,t)},r.lazyStore.get=function(){return Pa.get(this)},e.prototype.hashFnToKey=function(t){return Jt(t.toString())},Object.defineProperties(e.prototype,r),e}(qa));function za(t,e){var r;return function(t,e,r){return void 0===e&&(e={}),xa(e).then((function(t){return{baseClient:new ya(r,t),opts:t}})).then((function(e){var r=e.baseClient,n=e.opts;return Ut(r,n.contract).then((function(e){return ka(r,n,e,t)}))}))}((r=e.debugOn,new $a({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),e,t)}return function(t){return void 0===t&&(t={}),za(new o,t)}})); //# sourceMappingURL=jsonql-client.umd.js.map diff --git a/packages/http-client/package.json b/packages/http-client/package.json index 2f3d2ae5..f1a446ff 100755 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -68,7 +68,7 @@ "jsonql-errors": "^1.1.10", "jsonql-jwt": "^1.3.8", "jsonql-params-validator": "^1.5.2", - "jsonql-utils": "^0.9.3", + "jsonql-utils": "^0.9.4", "lodash-es": "^4.17.15", "nb-event-service": "^1.9.0", "store": "^2.0.12" @@ -79,12 +79,12 @@ "debug": "^4.1.1", "esm": "^3.2.25", "glob": "^7.1.6", - "jsonql-koa": "^1.5.3", + "jsonql-koa": "^1.5.5", "koa-favicon": "^2.0.1", "nyc": "^14.1.1", "promise-polyfill": "8.1.3", "qunit": "^2.9.3", - "rollup": "^1.27.10", + "rollup": "^1.27.12", "rollup-plugin-alias": "^2.2.0", "rollup-plugin-analyzer": "^3.2.2", "rollup-plugin-async": "^1.2.0", diff --git a/packages/http-client/static.js b/packages/http-client/static.js index 3a17611a..39eeec20 100644 --- a/packages/http-client/static.js +++ b/packages/http-client/static.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r="query",n="mutation",o="socket",i="payload",a="condition",u="TS",c=["POST","PUT"],s="type",f="optional",l="enumv",p="args",h="checker",d="alias",v="__checked__",g={desc:"y"},y="No message",b="onResult",_="onError",m=Array.isArray,w="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},j="object"==typeof w&&w&&w.Object===Object&&w,S="object"==typeof self&&self&&self.Object===Object&&self,O=j||S||Function("return this")(),k=O.Symbol,E=Object.prototype,A=E.hasOwnProperty,T=E.toString,x=k?k.toStringTag:void 0;var P=Object.prototype.toString;var q="[object Null]",C="[object Undefined]",$=k?k.toStringTag:void 0;function z(t){return null==t?void 0===t?C:q:$&&$ in Object(t)?function(t){var e=A.call(t,x),r=t[x];try{t[x]=void 0;var n=!0}catch(t){}var o=T.call(t);return n&&(e?t[x]=r:delete t[x]),o}(t):function(t){return P.call(t)}(t)}function N(t,e){return function(r){return t(e(r))}}var M=N(Object.getPrototypeOf,Object);function R(t){return null!=t&&"object"==typeof t}var F="[object Object]",I=Function.prototype,J=Object.prototype,U=I.toString,H=J.hasOwnProperty,L=U.call(Object);function D(t){if(!R(t)||z(t)!=F)return!1;var e=M(t);if(null===e)return!0;var r=H.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&U.call(r)==L}function K(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&tt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var gt=function(t){return m(t)?t:[t]},yt=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},bt=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},_t=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),mt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),wt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),jt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),St=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),Ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),kt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),Et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),At=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),Tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),xt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),Pt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),qt=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),Ct=Object.freeze({__proto__:null,Jsonql406Error:_t,Jsonql500Error:mt,JsonqlForbiddenError:wt,JsonqlAuthorisationError:jt,JsonqlContractAuthError:St,JsonqlResolverAppError:Ot,JsonqlResolverNotFoundError:kt,JsonqlEnumError:Et,JsonqlTypeError:At,JsonqlCheckerError:Tt,JsonqlValidationError:xt,JsonqlError:Pt,JsonqlServerError:qt}),$t=Pt,zt=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function Nt(t){if(zt(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||y,a=e.detail||e;if(o&&Ct[o])throw new Ct[r](i,a);throw new $t(i,a)}return t}function Mt(t){if(Array.isArray(t))throw new xt("",t);var e=t.message||y,r=t.detail||t;switch(!0){case t instanceof _t:throw new _t(e,r);case t instanceof mt:throw new mt(e,r);case t instanceof wt:throw new wt(e,r);case t instanceof jt:throw new jt(e,r);case t instanceof St:throw new St(e,r);case t instanceof Ot:throw new Ot(e,r);case t instanceof kt:throw new kt(e,r);case t instanceof Et:throw new Et(e,r);case t instanceof At:throw new At(e,r);case t instanceof Tt:throw new Tt(e,r);case t instanceof xt:throw new xt(e,r);case t instanceof qt:throw new qt(e,r);default:throw new Pt(e,r)}}var Rt=function(t){return!!m(t)||null!=t&&""!==vt(t)},Ft="[object Number]";function It(t){return function(t){return"number"==typeof t||R(t)&&z(t)==Ft}(t)&&t!=+t}var Jt="[object String]";function Ut(t){return"string"==typeof t||!m(t)&&R(t)&&z(t)==Jt}var Ht=function(t){return!Ut(t)&&!It(parseFloat(t))},Lt=function(t){return""!==vt(t)&&Ut(t)},Dt=function(t){return null!=t&&"boolean"==typeof t},Kt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==vt(t)&&(!1===e||!0===e&&null!==t)},Bt=s,Vt=f,Gt=l,Wt=p,Yt=h,Qt=d,Xt="continue",Zt=function(t){switch(t){case"number":return Ht;case"string":return Lt;case"boolean":return Dt;default:return Kt}},te=function(t,e){return void 0===e&&(e=""),!!m(t)&&(""===e||""===vt(e)||!(t.filter((function(t){return!Zt(e)(t)})).length>0))},ee=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},re=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Zt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!te(r,t)})).length};var ne,oe=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ne?a:++n];if(!1===e(o[u],u,o))break}return t};var ie="[object Arguments]";function ae(t){return R(t)&&z(t)==ie}var ue=Object.prototype,ce=ue.hasOwnProperty,se=ue.propertyIsEnumerable,fe=ae(function(){return arguments}())?ae:function(t){return R(t)&&ce.call(t,"callee")&&!se.call(t,"callee")};var le="object"==typeof exports&&exports&&!exports.nodeType&&exports,pe=le&&"object"==typeof module&&module&&!module.nodeType&&module,he=pe&&pe.exports===le?O.Buffer:void 0,de=(he?he.isBuffer:void 0)||function(){return!1},ve=9007199254740991,ge=/^(?:0|[1-9]\d*)$/;function ye(t,e){var r=typeof t;return!!(e=null==e?ve:e)&&("number"==r||"symbol"!=r&&ge.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=be}var me={};me["[object Float32Array]"]=me["[object Float64Array]"]=me["[object Int8Array]"]=me["[object Int16Array]"]=me["[object Int32Array]"]=me["[object Uint8Array]"]=me["[object Uint8ClampedArray]"]=me["[object Uint16Array]"]=me["[object Uint32Array]"]=!0,me["[object Arguments]"]=me["[object Array]"]=me["[object ArrayBuffer]"]=me["[object Boolean]"]=me["[object DataView]"]=me["[object Date]"]=me["[object Error]"]=me["[object Function]"]=me["[object Map]"]=me["[object Number]"]=me["[object Object]"]=me["[object RegExp]"]=me["[object Set]"]=me["[object String]"]=me["[object WeakMap]"]=!1;var we,je="object"==typeof exports&&exports&&!exports.nodeType&&exports,Se=je&&"object"==typeof module&&module&&!module.nodeType&&module,Oe=Se&&Se.exports===je&&j.process,ke=function(){try{var t=Se&&Se.require&&Se.require("util").types;return t||Oe&&Oe.binding&&Oe.binding("util")}catch(t){}}(),Ee=ke&&ke.isTypedArray,Ae=Ee?(we=Ee,function(t){return we(t)}):function(t){return R(t)&&_e(t.length)&&!!me[z(t)]},Te=Object.prototype.hasOwnProperty;function xe(t,e){var r=m(t),n=!r&&fe(t),o=!r&&!n&&de(t),i=!r&&!n&&!o&&Ae(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Be.prototype.set=function(t,e){var r=this.__data__,n=De(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Ve,Ge=O["__core-js_shared__"],We=(Ve=/[^.]+$/.exec(Ge&&Ge.keys&&Ge.keys.IE_PROTO||""))?"Symbol(src)_1."+Ve:"";var Ye=Function.prototype.toString;function Qe(t){if(null!=t){try{return Ye.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Xe=/^\[object .+?Constructor\]$/,Ze=Function.prototype,tr=Object.prototype,er=Ze.toString,rr=tr.hasOwnProperty,nr=RegExp("^"+er.call(rr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function or(t){return!(!ze(t)||function(t){return!!We&&We in t}(t))&&(Ie(t)?nr:Xe).test(Qe(t))}function ir(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return or(r)?r:void 0}var ar=ir(O,"Map"),ur=ir(Object,"create");var cr="__lodash_hash_undefined__",sr=Object.prototype.hasOwnProperty;var fr=Object.prototype.hasOwnProperty;var lr="__lodash_hash_undefined__";function pr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&wr?new br:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=ee(t))?!re({arg:r},e):!Zt(t)(r))})).length)})).length}return!1},Hn=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Un,null,a);case"array"===t:return!te(e.arg);case!1!==(r=ee(t)):return!re(e,r);default:return!Zt(t)(e.arg)}},Ln=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Dn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!te(e))throw new Pt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!te(t))throw new Pt("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Ln(t,a):t,index:r,param:a,optional:i}}));default:throw new Pt("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Rt(e)&&!(r.type.length>r.type.filter((function(e){return Hn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Hn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Kn=function(){try{var t=ir(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Bn(t,e,r){"__proto__"==e&&Kn?Kn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Vn(t,e,r){(void 0===r||Le(t[e],r))&&(void 0!==r||e in t)||Bn(t,e,r)}var Gn="object"==typeof exports&&exports&&!exports.nodeType&&exports,Wn=Gn&&"object"==typeof module&&module&&!module.nodeType&&module,Yn=Wn&&Wn.exports===Gn?O.Buffer:void 0,Qn=Yn?Yn.allocUnsafe:void 0;function Xn(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Sr(n).set(new Sr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Zn=Object.create,to=function(){function t(){}return function(e){if(!ze(e))return{};if(Zn)return Zn(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function eo(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var ro=Object.prototype.hasOwnProperty;function no(t,e,r){var n=t[e];ro.call(t,e)&&Le(n,r)&&(void 0!==r||e in t)||Bn(t,e,r)}var oo=Object.prototype.hasOwnProperty;function io(t){if(!ze(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=qe(t),r=[];for(var n in t)("constructor"!=n||!e&&oo.call(t,n))&&r.push(n);return r}function ao(t){return Je(t)?xe(t,!0):io(t)}function uo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=ho)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(po);function bo(t,e){return yo(function(t,e,r){return e=lo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=lo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=_o.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ze(r))return!1;var n=typeof e;return!!("number"==n?Je(r)&&ye(e,r.length):"string"==n&&e in r)&&Le(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,gt(t))}),Reflect.apply(t,null,r))}};function Do(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Ko(t,e,r,n){void 0===n&&(n=!1);var o=Do(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Bo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Jo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(Mt)}},Vo=function(t,e,r,n,o){var i={},a=function(t){i=Ko(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return Jo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(Mt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Go=function(t,e,r,n,o){var i={},a=function(t){i=Ko(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Jo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(Mt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Wo=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Bo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Bo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var Yo=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(bt(e,r,b),o),t.$only(bt(e,r,_),i),t.$trigger(e,{resolverName:r,args:n})}))}},Qo=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function Xo(t,e,r,n){var o=function(t,e,r,n){return Lo(Vo,Go,Wo)({},t,e,r,n)}(t,e,r,n);Qo(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(bt(t,n,b),r)})).catch((function(r){e.$trigger(bt(t,n,_),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Zo=function(t,e,r,n){n.$suspend=!0,r.then((function(r){Xo(t,n,e,r)}));var o={query:Yo(n,"query"),mutation:Yo(n,"mutation"),auth:Yo(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.5.8",o};function ti(t){return!!function(t){return D(t)&&(yt(t,r)||yt(t,n)||yt(t,o))}(t)&&t}function ei(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}var ri=function(t,e){return void 0===e&&(e={}),ti(e)?Promise.resolve(e):t.getContract()},ni="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function oi(t){this.message=t}oi.prototype=new Error,oi.prototype.name="InvalidCharacterError";var ii="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new oi("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=ni.indexOf(n);return a};var ai=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ii(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ii(e)}};function ui(t){this.message=t}ui.prototype=new Error,ui.prototype.name="InvalidTokenError";var ci=function(t,e){if("string"!=typeof t)throw new ui("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(ai(t.split(".")[r]))}catch(t){throw new ui("Invalid token specified: "+t.message)}},si=ui;ci.InvalidTokenError=si;var fi,li,pi,hi,di,vi,gi,yi,bi,_i=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function mi(t){if(Lt(t))return function(t){var e=t.iat||_i(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new Pt("Token has expired on "+r,t)}return t}(ci(t));throw new Pt("Token must be a string!")}Uo("HS256",["string"]),Uo(!1,["boolean","number","string"],((fi={})[d]="exp",fi[f]=!0,fi)),Uo(!1,["boolean","number","string"],((li={})[d]="nbf",li[f]=!0,li)),Uo(!1,["boolean","string"],((pi={})[d]="iss",pi[f]=!0,pi)),Uo(!1,["boolean","string"],((hi={})[d]="sub",hi[f]=!0,hi)),Uo(!1,["boolean","string"],((di={})[d]="iss",di[f]=!0,di)),Uo(!1,["boolean"],((vi={})[f]=!0,vi)),Uo(!1,["boolean","string"],((gi={})[f]=!0,gi)),Uo(!1,["boolean","string"],((yi={})[f]=!0,yi)),Uo(!1,["boolean"],((bi={})[f]=!0,bi));var wi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},ji="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Si=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=Ki().key(e);t(Bi(r),r)}},remove:function(t){return Ki().removeItem(t)},clearAll:function(){return Ki().clear()}};function Ki(){return Li.localStorage}function Bi(t){return Ki().getItem(t)}var Vi=Ai.trim,Gi={name:"cookieStorage",read:function(t){if(!t||!Xi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Wi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Wi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Yi,remove:Qi,clearAll:function(){Yi((function(t,e){Qi(e)}))}},Wi=Ai.Global.document;function Yi(t){for(var e=Wi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Vi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Qi(t){t&&Xi(t)&&(Wi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Xi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Wi.cookie)}var Zi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var ta=Ai.bind,ea=Ai.each,ra=Ai.create,na=Ai.slice,oa=function(){var t=ra(ia,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,ta(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,ta(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),ea(r,(function(e,r){t.fire(r,void 0,e)}))}}};var ia={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,ta(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=na(arguments,1);ea(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},aa=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),ua=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=aa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=aa.compress(this._serialize(r));t(e,n)}}};var ca=[Di,Gi],sa=[Zi,oa,ua],fa=Ji.createStore(ca,sa),la=Ai.Global;function pa(){return la.sessionStorage}function ha(t){return pa().getItem(t)}var da=[{name:"sessionStorage",read:ha,write:function(t,e){return pa().setItem(t,e)},each:function(t){for(var e=pa().length-1;e>=0;e--){var r=pa().key(e);t(ha(r),r)}},remove:function(t){return pa().removeItem(t)},clearAll:function(){return pa().clear()}},Gi],va=[Zi,ua],ga=Ji.createStore(da,va),ya=fa,ba=ga,_a=function(t){var e;return(e={}).args=t,e};function ma(t,e){var r;return(r={})[t]=e,r[u]=[wi()],r}var wa=function(t){return yt(t,"data")&&!yt(t,"error")?t.data:t},ja=function(t){this.opts=t,this.instanceKey=ei(this.opts.hostname),this.localStore=ya,this.sessionStore=ba},Sa={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};ja.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?mo({},o,e):e,r))},ja.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},ja.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},ja.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Sa.lset.set=function(t){return this.__setMethod("localStore",t)},Sa.lget.get=function(){return this.__getMethod("localStore")},ja.prototype.ldel=function(t){return this.__delMethod("localStore",t)},ja.prototype.lclear=function(){return this.__clearMethod("localStore")},Sa.sset.set=function(t){return this.__setMethod("sessionStore",t)},Sa.sget.get=function(){return this.__getMethod("sessionStore")},ja.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},ja.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(ja.prototype,Sa);var Oa=c[0],ka=c[1],Ea=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,t)}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=mi),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(Io(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new xt("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&Io(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!ti(t))throw new xt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=ti(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function r(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var n={headers:{configurable:!0}};return n.headers.set=function(t){this.extraHeader=t},r.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=mo({},{_cb:wi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=mo({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=mo({},{method:Oa,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},r.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},r.prototype.processJsonp=function(t){return wa(t)},r.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=Fo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):wa(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new qt("Server side error",r)}))},r.prototype.getHeaders=function(){return this.opts.enableAuth?mo({},e,this.getAuthHeader(),this.extraHeader):mo({},e,this.extraHeader)},r.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},r.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=mo({},this.extraParams,g)),this.request({},{method:"GET"},this.contractHeader).then(Nt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new qt("getRemoteContract",e)}))},r.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Ut(t)&&m(e)){var n=_a(e);return!0===r?n:ma(t,n)}throw new xt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(Nt)},r.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[i]=e,o[a]=r,!0===n)return o;if(Ut(t))return ma(t,o);throw new xt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ka}).then(Nt)},Object.defineProperties(r.prototype,n),r}(ja)))),Aa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Ta={hostname:Uo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Uo("jsonql",["string"]),loginHandlerName:Uo("login",["string"]),logoutHandlerName:Uo("logout",["string"]),enableJsonp:Uo(!1,["boolean"]),enableAuth:Uo(!1,["boolean"]),useJwt:Uo(!0,["boolean"]),persistToken:Uo(!1,["boolean","number"]),useLocalstorage:Uo(!0,["boolean"]),storageKey:Uo("jsonqlstore",["string"]),authKey:Uo("jsonqlauthkey",["string"]),contractExpired:Uo(0,["number"]),keepContract:Uo(!0,["boolean"]),exposeContract:Uo(!1,["boolean"]),exposeStore:Uo(!1,["boolean"]),showContractDesc:Uo(!1,["boolean"]),contractKey:Uo(!1,["boolean"]),contractKeyName:Uo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Uo(!1,["boolean"]),timeout:Uo(5e3,["number"]),returnInstance:Uo(!1,["boolean"]),allowReturnRawToken:Uo(!1,["boolean"]),debugOn:Uo(!1,["boolean"])};function xa(t){return Do(t,v)?t:function(t){return Ho(t,Ta,Aa)}(t)}var Pa=new WeakMap,qa=new WeakMap,Ca=function(){this.__suspend__=null,this.queueStore=new Set},$a={$suspend:{configurable:!0},$queues:{configurable:!0}};$a.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},Ca.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},$a.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Ca.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(Ca.prototype,$a);var za=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){Pa.set(this,t)},r.normalStore.get=function(){return Pa.get(this)},r.lazyStore.set=function(t){qa.set(this,t)},r.lazyStore.get=function(){return qa.get(this)},e.prototype.hashFnToKey=function(t){return ei(t.toString())},Object.defineProperties(e.prototype,r),e}(Ca));return function(t,e){void 0===e&&(e={});var r,n=e.contract,o=xa(e),i=new Ea(t,o),a=ri(i,n),u=(r=o.debugOn,new za({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Zo(i,o,a,u);return c.eventEmitter=u,c}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).jsonqlClientStatic=e()}(this,(function(){"use strict";var t="application/vnd.api+json",e={Accept:t,"Content-Type":[t,"charset=utf-8"].join(";")},r="query",n="mutation",o="socket",i="payload",a="condition",u="TS",c=["POST","PUT"],s="type",f="optional",l="enumv",p="args",h="checker",d="alias",v="__checked__",g={desc:"y"},y="No message",b="onResult",_="onError",m=Array.isArray,w="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},j="object"==typeof w&&w&&w.Object===Object&&w,S="object"==typeof self&&self&&self.Object===Object&&self,O=j||S||Function("return this")(),k=O.Symbol,E=Object.prototype,A=E.hasOwnProperty,T=E.toString,x=k?k.toStringTag:void 0;var P=Object.prototype.toString;var q="[object Null]",C="[object Undefined]",$=k?k.toStringTag:void 0;function z(t){return null==t?void 0===t?C:q:$&&$ in Object(t)?function(t){var e=A.call(t,x),r=t[x];try{t[x]=void 0;var n=!0}catch(t){}var o=T.call(t);return n&&(e?t[x]=r:delete t[x]),o}(t):function(t){return P.call(t)}(t)}function N(t,e){return function(r){return t(e(r))}}var M=N(Object.getPrototypeOf,Object);function R(t){return null!=t&&"object"==typeof t}var F="[object Object]",I=Function.prototype,J=Object.prototype,U=I.toString,H=J.hasOwnProperty,L=U.call(Object);function D(t){if(!R(t)||z(t)!=F)return!1;var e=M(t);if(null===e)return!0;var r=H.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&U.call(r)==L}function K(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r=n?t:function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n-1;);return r}(n,o),function(t,e){for(var r=t.length;r--&&tt(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var gt=function(t){return m(t)?t:[t]},yt=function(t,e){try{var r=Object.keys(t);return n=e,!!r.filter((function(t){return t===n})).length}catch(t){return!1}var n},bt=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},_t=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 406},r.name.get=function(){return"Jsonql406Error"},Object.defineProperties(e,r),e}(Error),mt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),wt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),jt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlAuthorisationError"},Object.defineProperties(e,r),e}(Error),St=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),Ot=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 500},r.name.get=function(){return"JsonqlResolverAppError"},Object.defineProperties(e,r),e}(Error),kt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={statusCode:{configurable:!0},name:{configurable:!0}};return r.statusCode.get=function(){return 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),Et=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),At=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlTypeError"},Object.defineProperties(e,r),e}(Error),Tt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),xt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),Pt=function(t){function e(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];t.apply(this,r),this.message=r[0],this.detail=r[1],this.className=e.name,t.captureStackTrace&&t.captureStackTrace(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0},statusCode:{configurable:!0}};return r.name.get=function(){return"JsonqlError"},r.statusCode.get=function(){return-1},Object.defineProperties(e,r),e}(Error),qt=function(t){function e(r,n){t.call(this,n),this.statusCode=r,this.className=e.name}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={name:{configurable:!0}};return r.name.get=function(){return"JsonqlServerError"},Object.defineProperties(e,r),e}(Error),Ct=Object.freeze({__proto__:null,Jsonql406Error:_t,Jsonql500Error:mt,JsonqlForbiddenError:wt,JsonqlAuthorisationError:jt,JsonqlContractAuthError:St,JsonqlResolverAppError:Ot,JsonqlResolverNotFoundError:kt,JsonqlEnumError:Et,JsonqlTypeError:At,JsonqlCheckerError:Tt,JsonqlValidationError:xt,JsonqlError:Pt,JsonqlServerError:qt}),$t=Pt,zt=function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length};function Nt(t){if(zt(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||y,a=e.detail||e;if(o&&Ct[o])throw new Ct[r](i,a);throw new $t(i,a)}return t}function Mt(t){if(Array.isArray(t))throw new xt("",t);var e=t.message||y,r=t.detail||t;switch(!0){case t instanceof _t:throw new _t(e,r);case t instanceof mt:throw new mt(e,r);case t instanceof wt:throw new wt(e,r);case t instanceof jt:throw new jt(e,r);case t instanceof St:throw new St(e,r);case t instanceof Ot:throw new Ot(e,r);case t instanceof kt:throw new kt(e,r);case t instanceof Et:throw new Et(e,r);case t instanceof At:throw new At(e,r);case t instanceof Tt:throw new Tt(e,r);case t instanceof xt:throw new xt(e,r);case t instanceof qt:throw new qt(e,r);default:throw new Pt(e,r)}}var Rt=function(t){return!!m(t)||null!=t&&""!==vt(t)},Ft="[object Number]";function It(t){return function(t){return"number"==typeof t||R(t)&&z(t)==Ft}(t)&&t!=+t}var Jt="[object String]";function Ut(t){return"string"==typeof t||!m(t)&&R(t)&&z(t)==Jt}var Ht=function(t){return!Ut(t)&&!It(parseFloat(t))},Lt=function(t){return""!==vt(t)&&Ut(t)},Dt=function(t){return null!=t&&"boolean"==typeof t},Kt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==vt(t)&&(!1===e||!0===e&&null!==t)},Bt=s,Vt=f,Gt=l,Wt=p,Yt=h,Qt=d,Xt="continue",Zt=function(t){switch(t){case"number":return Ht;case"string":return Lt;case"boolean":return Dt;default:return Kt}},te=function(t,e){return void 0===e&&(e=""),!!m(t)&&(""===e||""===vt(e)||!(t.filter((function(t){return!Zt(e)(t)})).length>0))},ee=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},re=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Zt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!te(r,t)})).length};var ne,oe=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[ne?a:++n];if(!1===e(o[u],u,o))break}return t};var ie="[object Arguments]";function ae(t){return R(t)&&z(t)==ie}var ue=Object.prototype,ce=ue.hasOwnProperty,se=ue.propertyIsEnumerable,fe=ae(function(){return arguments}())?ae:function(t){return R(t)&&ce.call(t,"callee")&&!se.call(t,"callee")};var le="object"==typeof exports&&exports&&!exports.nodeType&&exports,pe=le&&"object"==typeof module&&module&&!module.nodeType&&module,he=pe&&pe.exports===le?O.Buffer:void 0,de=(he?he.isBuffer:void 0)||function(){return!1},ve=9007199254740991,ge=/^(?:0|[1-9]\d*)$/;function ye(t,e){var r=typeof t;return!!(e=null==e?ve:e)&&("number"==r||"symbol"!=r&&ge.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=be}var me={};me["[object Float32Array]"]=me["[object Float64Array]"]=me["[object Int8Array]"]=me["[object Int16Array]"]=me["[object Int32Array]"]=me["[object Uint8Array]"]=me["[object Uint8ClampedArray]"]=me["[object Uint16Array]"]=me["[object Uint32Array]"]=!0,me["[object Arguments]"]=me["[object Array]"]=me["[object ArrayBuffer]"]=me["[object Boolean]"]=me["[object DataView]"]=me["[object Date]"]=me["[object Error]"]=me["[object Function]"]=me["[object Map]"]=me["[object Number]"]=me["[object Object]"]=me["[object RegExp]"]=me["[object Set]"]=me["[object String]"]=me["[object WeakMap]"]=!1;var we,je="object"==typeof exports&&exports&&!exports.nodeType&&exports,Se=je&&"object"==typeof module&&module&&!module.nodeType&&module,Oe=Se&&Se.exports===je&&j.process,ke=function(){try{var t=Se&&Se.require&&Se.require("util").types;return t||Oe&&Oe.binding&&Oe.binding("util")}catch(t){}}(),Ee=ke&&ke.isTypedArray,Ae=Ee?(we=Ee,function(t){return we(t)}):function(t){return R(t)&&_e(t.length)&&!!me[z(t)]},Te=Object.prototype.hasOwnProperty;function xe(t,e){var r=m(t),n=!r&&fe(t),o=!r&&!n&&de(t),i=!r&&!n&&!o&&Ae(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},Be.prototype.set=function(t,e){var r=this.__data__,n=De(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Ve,Ge=O["__core-js_shared__"],We=(Ve=/[^.]+$/.exec(Ge&&Ge.keys&&Ge.keys.IE_PROTO||""))?"Symbol(src)_1."+Ve:"";var Ye=Function.prototype.toString;function Qe(t){if(null!=t){try{return Ye.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Xe=/^\[object .+?Constructor\]$/,Ze=Function.prototype,tr=Object.prototype,er=Ze.toString,rr=tr.hasOwnProperty,nr=RegExp("^"+er.call(rr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function or(t){return!(!ze(t)||function(t){return!!We&&We in t}(t))&&(Ie(t)?nr:Xe).test(Qe(t))}function ir(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return or(r)?r:void 0}var ar=ir(O,"Map"),ur=ir(Object,"create");var cr="__lodash_hash_undefined__",sr=Object.prototype.hasOwnProperty;var fr=Object.prototype.hasOwnProperty;var lr="__lodash_hash_undefined__";function pr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++eu))return!1;var s=i.get(t);if(s&&i.get(e))return s==e;var f=-1,l=!0,p=r&wr?new br:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=ee(t))?!re({arg:r},e):!Zt(t)(r))})).length)})).length}return!1},Hn=function(t,e){var r,n,o,i,a;switch(!0){case"object"===t:return o=(n=e).arg,i=n.param,a=[o],Array.isArray(i.keys)&&i.keys.length&&a.push(i.keys),!Reflect.apply(Un,null,a);case"array"===t:return!te(e.arg);case!1!==(r=ee(t)):return!re(e,r);default:return!Zt(t)(e.arg)}},Ln=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Dn=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!te(e))throw new Pt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!te(t))throw new Pt("args is not an array! You might want to do: ES6 Array.from(arguments) or ES5 Array.prototype.slice.call(arguments)");switch(!0){case t.length==e.length:return t.map((function(t,r){return{arg:t,index:r,param:e[r]}}));case!0===e[0].variable:var r=e[0].type;return t.map((function(t,n){return{arg:t,index:n,param:e[n]||{type:r,name:"_"}}}));case t.lengthe.length:var n=e.length,o=["any"];return t.map((function(t,r){var i=r>=n||!!e[r].optional,a=e[r]||{type:o,name:"_"+r};return{arg:i?Ln(t,a):t,index:r,param:a,optional:i}}));default:throw new Pt("Could not understand your arguments and parameter structure!",{args:t,params:e})}}(t,e),i=o.filter((function(t){return!0===t.optional||!0===t.param.optional?function(t){var e=t.arg,r=t.param;return!!Rt(e)&&!(r.type.length>r.type.filter((function(e){return Hn(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Hn(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Kn=function(){try{var t=ir(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Bn(t,e,r){"__proto__"==e&&Kn?Kn(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Vn(t,e,r){(void 0===r||Le(t[e],r))&&(void 0!==r||e in t)||Bn(t,e,r)}var Gn="object"==typeof exports&&exports&&!exports.nodeType&&exports,Wn=Gn&&"object"==typeof module&&module&&!module.nodeType&&module,Yn=Wn&&Wn.exports===Gn?O.Buffer:void 0,Qn=Yn?Yn.allocUnsafe:void 0;function Xn(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Sr(n).set(new Sr(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Zn=Object.create,to=function(){function t(){}return function(e){if(!ze(e))return{};if(Zn)return Zn(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function eo(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var ro=Object.prototype.hasOwnProperty;function no(t,e,r){var n=t[e];ro.call(t,e)&&Le(n,r)&&(void 0!==r||e in t)||Bn(t,e,r)}var oo=Object.prototype.hasOwnProperty;function io(t){if(!ze(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=qe(t),r=[];for(var n in t)("constructor"!=n||!e&&oo.call(t,n))&&r.push(n);return r}function ao(t){return Je(t)?xe(t,!0):io(t)}function uo(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=ho)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(po);function bo(t,e){return yo(function(t,e,r){return e=lo(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=lo(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=_o.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ze(r))return!1;var n=typeof e;return!!("number"==n?Je(r)&&ye(e,r.length):"string"==n&&e in r)&&Le(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r0;)e[r]=arguments[r+1];return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return e.reduce((function(t,e){return Reflect.apply(e,null,gt(t))}),Reflect.apply(t,null,r))}};function Do(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Ko(t,e,r,n){void 0===n&&(n=!1);var o=Do(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Bo=function(t,e,r,n){return function(){for(var r=[],o=arguments.length;o--;)r[o]=arguments[o];var i=n.auth[e].params,a=i.map((function(t,e){return r[e]})),u=r[i.length]||{};return Jo(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(Mt)}},Vo=function(t,e,r,n,o){var i={},a=function(t){i=Ko(i,t,(function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var i=o.query[t].params,a=i.map((function(t,e){return r[e]})),u={};return Jo(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(Mt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Go=function(t,e,r,n,o){var i={},a=function(t){i=Ko(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return Jo(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(Mt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Wo=function(t,e,r,n,o){if(n.enableAuth&&o.auth){var i={},a=n.loginHandlerName,u=n.logoutHandlerName;o.auth[a]&&(i[a]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Bo(e,a,0,o);return i.apply(null,t).then(e.postLoginAction.bind(e)).then((function(t){var e=t.token,n=t.userdata;return r.$trigger("login",e),n}))}),o.auth[u]?i[u]=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var i=Bo(e,u,0,o);return i.apply(null,t).then(e.postLogoutAction.bind(e)).then((function(t){return r.$trigger("logout",t),t}))}:i[u]=function(t){void 0===t&&(t=null),e.postLogoutAction("continue",t),r.$trigger("logout","continue")},t.auth=i}return t};var Yo=function(t,e){return function(r){for(var n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return new Promise((function(o,i){t.$only(bt(e,r,b),o),t.$only(bt(e,r,_),i),t.$trigger(e,{resolverName:r,args:n})}))}},Qo=function(t,e,r){var n=t.$queues,o=r.debugOn;o&&console.info("(validateRegisteredEvents)","storedEvt",n),n.forEach((function(t){var r=t[0],n=t[1].resolverName;if(o&&console.info("(validateRegisteredEvents)",r,n),!e[r][n])throw new Error(r+"."+n+" not existed in contract!")}))};function Xo(t,e,r,n){var o=function(t,e,r,n){return Lo(Vo,Go,Wo)({},t,e,r,n)}(t,e,r,n);Qo(e,n,r);var i=function(t){e.$only(t,(function(r){var n=r.resolverName,i=r.args;o[t][n]?Reflect.apply(o[t][n],null,i).then((function(r){e.$trigger(bt(t,n,b),r)})).catch((function(r){e.$trigger(bt(t,n,_),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}var Zo=function(t,e,r,n){n.$suspend=!0,r.then((function(r){Xo(t,n,e,r)}));var o={query:Yo(n,"query"),mutation:Yo(n,"mutation"),auth:Yo(n,"auth"),getToken:function(){return t.rawAuthToken}};return e.exposeContract&&(o.getContract=function(){return t.get()}),e.enableAuth&&(o.userdata=function(){return t.userdata}),o.version="1.5.9",o};function ti(t){return!!function(t){return D(t)&&(yt(t,r)||yt(t,n)||yt(t,o))}(t)&&t}function ei(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}var ri=function(t,e){return void 0===e&&(e={}),ti(e)?Promise.resolve(e):t.getContract()},ni="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function oi(t){this.message=t}oi.prototype=new Error,oi.prototype.name="InvalidCharacterError";var ii="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new oi("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,a="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?a+=String.fromCharCode(255&r>>(-2*o&6)):0)n=ni.indexOf(n);return a};var ai=function(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(ii(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return ii(e)}};function ui(t){this.message=t}ui.prototype=new Error,ui.prototype.name="InvalidTokenError";var ci=function(t,e){if("string"!=typeof t)throw new ui("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(ai(t.split(".")[r]))}catch(t){throw new ui("Invalid token specified: "+t.message)}},si=ui;ci.InvalidTokenError=si;var fi,li,pi,hi,di,vi,gi,yi,bi,_i=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function mi(t){if(Lt(t))return function(t){var e=t.iat||_i(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new Pt("Token has expired on "+r,t)}return t}(ci(t));throw new Pt("Token must be a string!")}Uo("HS256",["string"]),Uo(!1,["boolean","number","string"],((fi={})[d]="exp",fi[f]=!0,fi)),Uo(!1,["boolean","number","string"],((li={})[d]="nbf",li[f]=!0,li)),Uo(!1,["boolean","string"],((pi={})[d]="iss",pi[f]=!0,pi)),Uo(!1,["boolean","string"],((hi={})[d]="sub",hi[f]=!0,hi)),Uo(!1,["boolean","string"],((di={})[d]="iss",di[f]=!0,di)),Uo(!1,["boolean"],((vi={})[f]=!0,vi)),Uo(!1,["boolean","string"],((gi={})[f]=!0,gi)),Uo(!1,["boolean","string"],((yi={})[f]=!0,yi)),Uo(!1,["boolean"],((bi={})[f]=!0,bi));var wi=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},ji="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Si=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=Ki().key(e);t(Bi(r),r)}},remove:function(t){return Ki().removeItem(t)},clearAll:function(){return Ki().clear()}};function Ki(){return Li.localStorage}function Bi(t){return Ki().getItem(t)}var Vi=Ai.trim,Gi={name:"cookieStorage",read:function(t){if(!t||!Xi(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Wi.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Wi.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Yi,remove:Qi,clearAll:function(){Yi((function(t,e){Qi(e)}))}},Wi=Ai.Global.document;function Yi(t){for(var e=Wi.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Vi(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Qi(t){t&&Xi(t)&&(Wi.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Xi(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Wi.cookie)}var Zi=function(){var t={};return{defaults:function(e,r){t=r},get:function(e,r){var n=e();return void 0!==n?n:t[r]}}};var ta=Ai.bind,ea=Ai.each,ra=Ai.create,na=Ai.slice,oa=function(){var t=ra(ia,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,ta(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,ta(this,n))},set:function(e,r,n){var o=this.get(r);e(),t.fire(r,n,o)},remove:function(e,r){var n=this.get(r);e(),t.fire(r,void 0,n)},clearAll:function(e){var r={};this.each((function(t,e){r[e]=t})),e(),ea(r,(function(e,r){t.fire(r,void 0,e)}))}}};var ia={_id:null,_subCallbacks:null,_subSignals:null,on:function(t,e){return this._subCallbacks[t]||(this._subCallbacks[t]={}),this._id+=1,this._subCallbacks[t][this._id]=e,this._subSignals[this._id]=t,this._id},off:function(t){var e=this._subSignals[t];delete this._subCallbacks[e][t],delete this._subSignals[t]},once:function(t,e){var r=this.on(t,ta(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=na(arguments,1);ea(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},aa=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(){var t=String.fromCharCode,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",n={};function o(t,e){if(!n[t]){n[t]={};for(var r=0;r>>8,r[2*n+1]=a%256}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++),a[s]=p++,f=String(c)}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[f]}else for(o=a[f],n=0;n>=1;0==--l&&(l=Math.pow(2,h),h++)}for(o=2,n=0;n>=1;for(;;){if(v<<=1,g==e-1){d.push(r(v));break}g++}return d.join("")},decompress:function(t){return null==t?"":""==t?null:i._decompress(t.length,32768,(function(e){return t.charCodeAt(e)}))},_decompress:function(e,r,n){var o,i,a,u,c,s,f,l=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)l[o]=o;for(a=0,c=Math.pow(2,2),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;f=t(a);break;case 2:return""}for(l[3]=f,i=f,g.push(f);;){if(y.index>e)return"";for(a=0,c=Math.pow(2,d),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;switch(f=a){case 0:for(a=0,c=Math.pow(2,8),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 1:for(a=0,c=Math.pow(2,16),s=1;s!=c;)u=y.val&y.position,y.position>>=1,0==y.position&&(y.position=r,y.val=n(y.index++)),a|=(u>0?1:0)*s,s<<=1;l[h++]=t(a),f=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),l[f])v=l[f];else{if(f!==h)return null;v=i+i.charAt(0)}g.push(v),l[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),ua=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=aa.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=aa.compress(this._serialize(r));t(e,n)}}};var ca=[Di,Gi],sa=[Zi,oa,ua],fa=Ji.createStore(ca,sa),la=Ai.Global;function pa(){return la.sessionStorage}function ha(t){return pa().getItem(t)}var da=[{name:"sessionStorage",read:ha,write:function(t,e){return pa().setItem(t,e)},each:function(t){for(var e=pa().length-1;e>=0;e--){var r=pa().key(e);t(ha(r),r)}},remove:function(t){return pa().removeItem(t)},clearAll:function(){return pa().clear()}},Gi],va=[Zi,ua],ga=Ji.createStore(da,va),ya=fa,ba=ga,_a=function(t){var e;return(e={}).args=t,e};function ma(t,e){var r;return(r={})[t]=e,r[u]=[wi()],r}var wa=function(t){return yt(t,"data")&&!yt(t,"error")?t.data:t},ja=function(t){this.opts=t,this.instanceKey=ei(this.opts.hostname),this.localStore=ya,this.sessionStore=ba},Sa={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};ja.prototype.__setMethod=function(t,e){var r,n=this[t],o=this.__getMethod(t),i=this.opts.storageKey,a=this.instanceKey;n.set(i,((r={})[a]=o?mo({},o,e):e,r))},ja.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},ja.prototype.__delMethod=function(t,e){var r=this.__getMethod(t);if(r){var n={};for(var o in r)o!==e&&(n[o]=r[o]);this.__setMethod(t,n)}},ja.prototype.__clearMethod=function(t){var e=this.opts.storageKey,r=this[t],n=r.get(e);if(n){var o={};for(var i in n)i!==this.instanceKey&&(o[i]=n[i]);r.set(e,o)}},Sa.lset.set=function(t){return this.__setMethod("localStore",t)},Sa.lget.get=function(){return this.__getMethod("localStore")},ja.prototype.ldel=function(t){return this.__delMethod("localStore",t)},ja.prototype.lclear=function(){return this.__clearMethod("localStore")},Sa.sset.set=function(t){return this.__setMethod("sessionStore",t)},Sa.sget.get=function(){return this.__getMethod("sessionStore")},ja.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},ja.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(ja.prototype,Sa);var Oa=c[0],ka=c[1],Ea=function(t){function e(e,r){this.fly=e,t.call(this,r)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={jsonqlEndpoint:{configurable:!0}};return r.jsonqlEndpoint.get=function(){return[this.opts.hostname||"",this.opts.jsonqlPath].join("/")},e.prototype.log=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!0===this.opts.debugOn){var r=["info","error"],n="__error__"===t[0]?1:0;t.splice(0,n),Reflect.apply(console[r[n]],console,t)}},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e),e.enableAuth&&(this.setDecoder=mi),this.__userdata__=null}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={profileIndex:{configurable:!0},setDecoder:{configurable:!0},saveProfile:{configurable:!0},readProfile:{configurable:!0},jsonqlToken:{configurable:!0},jsonqlUserdata:{configurable:!0}};return e.prototype.decoder=function(t){return t},r.profileIndex.set=function(t){var e;if(Io(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new xt("profileIndex","Expect idx to be number but got "+typeof t)},r.profileIndex.get=function(){var t="prof_idx";if(this.opts.persistToken){var e=this.lget;if(e[t])return e[t]}return this[t]?this[t]:0},e.prototype.rawAuthToken=function(t){return void 0===t&&(t=!1),!1!==t&&(this.profileIndex=t),this.jsonqlToken},r.setDecoder.set=function(t){"function"==typeof t&&(this.decoder=t)},r.saveProfile.set=function(t){this.opts.persistToken?this.lset=t:this.sset=t},r.readProfile.get=function(){return this.opts.persistToken?this.lget:this.sget},r.jsonqlToken.set=function(t){var e,r=this.readProfile,n="jsonqlcredential",o=r&&r[n]?r[n]:[];o.push(t),this.saveProfile=((e={})[n]=o,e),this.__userdata__=this.decoder(t),this.jsonqlUserdata=this.__userdata__},r.jsonqlToken.get=function(){var t=this.readProfile,e="jsonqlcredential";return!(!t||!t[e])&&(this.log("-- jsonqlToken --",t[e],this.profileIndex,t[e][this.profileIndex]),t[e][this.profileIndex])},r.jsonqlUserdata.set=function(t){var e;this.sset=((e={}).userdata=t,e)},r.jsonqlUserdata.get=function(){var t=this.sget;return!!t&&t.userdata},e.prototype.getAuthHeader=function(){var t,e=this.jsonqlToken;return e?((t={})[this.opts.AUTH_HEADER]="Bearer "+e,t):{}},e.prototype.getProfiles=function(t){void 0===t&&(t=!1);var e=this.readProfile,r="jsonqlcredential";return!(!e||!e[r])&&(!1!==t&&Io(t)?e[r][t]||!1:e[r].map(this.decoder.bind(this)))},e.prototype.postLoginAction=function(t){return this.jsonqlToken=t,{token:t,userdata:this.__userdata__}},e.prototype.postLogoutAction=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];console.info("postLogoutAction",t)},Object.defineProperties(e.prototype,r),e}(function(t){function e(e){t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={contractHeader:{configurable:!0}};return e.prototype.getContract=function(){var t=this.readContract();return this.log("getContract first call",t),t?Promise.resolve(t):this.getRemoteContract().then(this.storeContract.bind(this))},r.contractHeader.get=function(){var t={};return!1!==this.opts.contractKey&&(t[this.opts.contractKeyName]=this.opts.contractKey),t},e.prototype.storeContract=function(t){var e;if(!ti(t))throw new xt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=ti(this.opts.contract);if(!1!==t)return t;var e=this.lget;return!!e&&e.contract},Object.defineProperties(e.prototype,r),e}(function(t){function r(e){t.call(this,e),this.extraHeader={},this.extraParams={},this.reqInterceptor(),this.resInterceptor()}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var n={headers:{configurable:!0}};return n.headers.set=function(t){this.extraHeader=t},r.prototype.request=function(t,e,r){var n;void 0===e&&(e={}),void 0===r&&(r={}),this.headers=r;var o=mo({},{_cb:wi()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=mo({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=mo({},{method:Oa,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.fly.request(this.jsonqlEndpoint,t,a)},r.prototype.reqInterceptor=function(){var t=this;this.fly.interceptors.request.use((function(e){var r=t.getHeaders();for(var n in t.log("request interceptor call",r),r)e.headers[n]=r[n];return e}))},r.prototype.processJsonp=function(t){return wa(t)},r.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.fly.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=Fo(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):wa(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new qt("Server side error",r)}))},r.prototype.getHeaders=function(){return this.opts.enableAuth?mo({},e,this.getAuthHeader(),this.extraHeader):mo({},e,this.extraHeader)},r.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},r.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=mo({},this.extraParams,g)),this.request({},{method:"GET"},this.contractHeader).then(Nt).then((function(e){return t.log("get contract result",e),e.cache&&e.contract?e.contract:e})).catch((function(e){throw t.log("__error__","getRemoteContract err",e),new qt("getRemoteContract",e)}))},r.prototype.query=function(t,e){return void 0===e&&(e=[]),this.request(function(t,e,r){if(void 0===e&&(e=[]),void 0===r&&(r=!1),Ut(t)&&m(e)){var n=_a(e);return!0===r?n:ma(t,n)}throw new xt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(Nt)},r.prototype.mutation=function(t,e,r){return void 0===e&&(e={}),void 0===r&&(r={}),this.request(function(t,e,r,n){void 0===r&&(r={}),void 0===n&&(n=!1);var o={};if(o[i]=e,o[a]=r,!0===n)return o;if(Ut(t))return ma(t,o);throw new xt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ka}).then(Nt)},Object.defineProperties(r.prototype,n),r}(ja)))),Aa={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Ta={hostname:Uo(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Uo("jsonql",["string"]),loginHandlerName:Uo("login",["string"]),logoutHandlerName:Uo("logout",["string"]),enableJsonp:Uo(!1,["boolean"]),enableAuth:Uo(!1,["boolean"]),useJwt:Uo(!0,["boolean"]),persistToken:Uo(!1,["boolean","number"]),useLocalstorage:Uo(!0,["boolean"]),storageKey:Uo("jsonqlstore",["string"]),authKey:Uo("jsonqlauthkey",["string"]),contractExpired:Uo(0,["number"]),keepContract:Uo(!0,["boolean"]),exposeContract:Uo(!1,["boolean"]),exposeStore:Uo(!1,["boolean"]),showContractDesc:Uo(!1,["boolean"]),contractKey:Uo(!1,["boolean"]),contractKeyName:Uo("X-JSONQL-CV-KEY",["string"]),enableTimeout:Uo(!1,["boolean"]),timeout:Uo(5e3,["number"]),returnInstance:Uo(!1,["boolean"]),allowReturnRawToken:Uo(!1,["boolean"]),debugOn:Uo(!1,["boolean"])};function xa(t){return Do(t,v)?t:function(t){return Ho(t,Ta,Aa)}(t)}var Pa=new WeakMap,qa=new WeakMap,Ca=function(){this.__suspend__=null,this.queueStore=new Set},$a={$suspend:{configurable:!0},$queues:{configurable:!0}};$a.$suspend.set=function(t){var e=this;if("boolean"!=typeof t)throw new Error("$suspend only accept Boolean value!");var r=this.__suspend__;this.__suspend__=t,this.logger("($suspend)","Change from "+r+" --\x3e "+t),!0===r&&!1===t&&setTimeout((function(){e.release()}),1)},Ca.prototype.$queue=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return!0===this.__suspend__&&(this.logger("($queue)","added to $queue",t),this.queueStore.add(t)),this.__suspend__},$a.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},Ca.prototype.release=function(){var t=this,e=this.queueStore.size;if(this.logger("(release)","Release was called "+e),e>0){var r=Array.from(this.queueStore);this.queueStore.clear(),this.logger("queue",r),r.forEach((function(e){t.logger(e),Reflect.apply(t.$trigger,t,e)})),this.logger("Release size "+this.queueStore.size)}},Object.defineProperties(Ca.prototype,$a);var za=function(t){function e(e){void 0===e&&(e={}),t.call(this,e)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={$done:{configurable:!0}};return e.prototype.logger=function(){},e.prototype.$on=function(t,e,r){var n=this;void 0===r&&(r=null);this.validate(t,e);var o=this.takeFromStore(t);if(!1===o)return this.logger("($on)",t+" callback is not in lazy store"),this.addToNormalStore(t,"on",e,r);this.logger("($on)",t+" found in lazy store");var i=0;return o.forEach((function(o){var a=o[0],u=o[1],c=o[2];if(c&&"on"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);n.logger("($on)","call run on "+t),n.run(e,a,r||u),i+=n.addToNormalStore(t,"on",e,r||u)})),i},e.prototype.$once=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=this.takeFromStore(t);this.normalStore;if(!1===n)return this.logger("($once)",t+" not in the lazy store"),this.addToNormalStore(t,"once",e,r);this.logger("($once)",n);var o=Array.from(n)[0],i=o[0],a=o[1],u=o[2];if(u&&"once"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);this.logger("($once)","call run for "+t),this.run(e,i,r||a),this.$off(t)},e.prototype.$only=function(t,e,r){var n=this;void 0===r&&(r=null),this.validate(t,e);var o=!1,i=this.takeFromStore(t);(this.normalStore.has(t)||(this.logger("($only)",t+" add to store"),o=this.addToNormalStore(t,"only",e,r)),!1!==i)&&(this.logger("($only)",t+" found data in lazy store to execute"),Array.from(i).forEach((function(o){var i=o[0],a=o[1],u=o[2];if(u&&"only"!==u)throw new Error("You are trying to register an event already been taken by other type: "+u);n.logger("($only)","call run for "+t),n.run(e,i,r||a)})));return o},e.prototype.$onlyOnce=function(t,e,r){void 0===r&&(r=null),this.validate(t,e);var n=!1,o=this.takeFromStore(t);if(this.normalStore.has(t)||(this.logger("($onlyOnce)",t+" add to store"),n=this.addToNormalStore(t,"onlyOnce",e,r)),!1!==o){this.logger("($onlyOnce)",o);var i=Array.from(o)[0],a=i[0],u=i[1],c=i[2];if(c&&"onlyOnce"!==c)throw new Error("You are trying to register an event already been taken by other type: "+c);this.logger("($onlyOnce)","call run for "+t),this.run(e,a,r||u),this.$off(t)}return n},e.prototype.$replace=function(t,e,r,n){if(void 0===r&&(r=null),void 0===n&&(n="on"),this.validateType(n)){this.$off(t);var o=this["$"+n];return this.logger("($replace)",t,e),Reflect.apply(o,this,[t,e,r])}throw new Error(n+" is not supported!")},e.prototype.$trigger=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1),this.validateEvt(t);var o=0,i=this.normalStore;if(this.logger("($trigger)","normalStore",i),i.has(t)){var a=this.$queue(t,e,r,n);if(this.logger("($trigger)",t,"found; add to queue: ",a),!0===a)return this.logger("($trigger)",t,"not executed. Exit now."),!1;for(var u=Array.from(i.get(t)),c=u.length,s=!1,f=0;f0;)n[o]=arguments[o+2];if(t.has(e)?(this.logger("(addToStore)",e+" existed"),r=t.get(e)):(this.logger("(addToStore)","create new Set for "+e),r=new Set),n.length>2)if(Array.isArray(n[0])){var i=n[2];this.checkTypeInLazyStore(e,i)||r.add(n)}else this.checkContentExist(n,r)||(this.logger("(addToStore)","insert new",n),r.add(n));else r.add(n);return t.set(e,r),[t,r.size]},e.prototype.checkContentExist=function(t,e){return!!Array.from(e).filter((function(e){return e[0]===t[0]})).length},e.prototype.checkTypeInStore=function(t,e){this.validateEvt(t,e);var r=this.$get(t,!0);return!1===r||!r.filter((function(t){var r=t[3];return e!==r})).length},e.prototype.checkTypeInLazyStore=function(t,e){this.validateEvt(t,e);var r=this.lazyStore.get(t);return this.logger("(checkTypeInLazyStore)",r),!!r&&!!Array.from(r).filter((function(t){return t[2]!==e})).length},e.prototype.addToNormalStore=function(t,e,r,n){if(void 0===n&&(n=null),this.logger("(addToNormalStore)",t,e,"try to add to normal store"),this.checkTypeInStore(t,e)){this.logger("(addToNormalStore)",e+" can add to "+t+" normal store");var o=this.hashFnToKey(r),i=[this.normalStore,t,o,r,n,e],a=Reflect.apply(this.addToStore,this,i),u=a[0],c=a[1];return this.normalStore=u,c}return!1},e.prototype.addToLazyStore=function(t,e,r,n){void 0===e&&(e=[]),void 0===r&&(r=null),void 0===n&&(n=!1);var o=[this.lazyStore,t,this.toArray(e),r];n&&o.push(n);var i=Reflect.apply(this.addToStore,this,o),a=i[0],u=i[1];return this.lazyStore=a,u},e.prototype.toArray=function(t){return Array.isArray(t)?t:[t]},r.normalStore.set=function(t){Pa.set(this,t)},r.normalStore.get=function(){return Pa.get(this)},r.lazyStore.set=function(t){qa.set(this,t)},r.lazyStore.get=function(){return qa.get(this)},e.prototype.hashFnToKey=function(t){return ei(t.toString())},Object.defineProperties(e.prototype,r),e}(Ca));return function(t,e){void 0===e&&(e={});var r,n=e.contract,o=xa(e),i=new Ea(t,o),a=ri(i,n),u=(r=o.debugOn,new za({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[NBS]"),console.log.apply(null,t)}:void 0})),c=Zo(i,o,a,u);return c.eventEmitter=u,c}})); //# sourceMappingURL=static.js.map -- Gitee