diff --git a/packages/http-client/core.js b/packages/http-client/core.js index 1c48dc995dd9a773197159bc14b1fd84fc337314..f352e269fa16a270d83d0ebae5bc6e35fbbd3b20 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=["POST","PUT"],n={desc:"y"},o=Array.isArray,i="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},a="object"==typeof i&&i&&i.Object===Object&&i,u="object"==typeof self&&self&&self.Object===Object&&self,c=a||u||Function("return this")(),s=c.Symbol,l=Object.prototype,f=l.hasOwnProperty,p=l.toString,h=s?s.toStringTag:void 0;var d=Object.prototype.toString;var v=s?s.toStringTag:void 0;function g(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":v&&v in Object(t)?function(t){var e=f.call(t,h),r=t[h];try{t[h]=void 0;var n=!0}catch(t){}var o=p.call(t);return n&&(e?t[h]=r:delete t[h]),o}(t):function(t){return d.call(t)}(t)}function y(t,e){return function(r){return t(e(r))}}var b=y(Object.getPrototypeOf,Object);function _(t){return null!=t&&"object"==typeof t}var m=Function.prototype,w=Object.prototype,j=m.toString,S=w.hasOwnProperty,O=j.call(Object);function k(t){if(!_(t)||"[object Object]"!=g(t))return!1;var e=b(t);if(null===e)return!0;var r=S.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&j.call(r)==O}function A(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--&&$(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var W=function(t){return o(t)?t:[t]},Y=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},Q=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),X=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),Z=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),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"JsonqlAuthorisationError"},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 401},r.name.get=function(){return"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),rt=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),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={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),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"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),it=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),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"JsonqlCheckerError"},Object.defineProperties(e,r),e}(Error),ut=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),st=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),lt=Object.freeze({__proto__:null,Jsonql406Error:Q,Jsonql500Error:X,JsonqlForbiddenError:Z,JsonqlAuthorisationError:tt,JsonqlContractAuthError:et,JsonqlResolverAppError:rt,JsonqlResolverNotFoundError:nt,JsonqlEnumError:ot,JsonqlTypeError:it,JsonqlCheckerError:at,JsonqlValidationError:ut,JsonqlError:ct,JsonqlServerError:st}),ft=ct;function pt(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&<[o])throw new lt[r](i,a);throw new ft(i,a)}return t}function ht(t){if(Array.isArray(t))throw new ut("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof Q:throw new Q(e,r);case t instanceof X:throw new X(e,r);case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof et:throw new et(e,r);case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof st:throw new st(e,r);default:throw new ct(e,r)}}function dt(t){return!!function(t){return k(t)&&(Y(t,"query")||Y(t,"mutation")||Y(t,"socket"))}(t)&&t}function vt(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function gt(t){this.message=t}gt.prototype=new Error,gt.prototype.name="InvalidCharacterError";var yt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new gt("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".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(yt(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 yt(e)}};function _t(t){this.message=t}_t.prototype=new Error,_t.prototype.name="InvalidTokenError";var mt=function(t,e){if("string"!=typeof t)throw new _t("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(bt(t.split(".")[r]))}catch(t){throw new _t("Invalid token specified: "+t.message)}};mt.InvalidTokenError=_t;function wt(t){return"string"==typeof t||!o(t)&&_(t)&&"[object String]"==g(t)}var jt=function(t){return""!==G(t)&&wt(t)};function St(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!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}function Ot(t){if(jt(t))return St(mt(t));throw new ct("Token must be a string!")}var kt=function(t){return!!o(t)||null!=t&&""!==G(t)};function At(t){return function(t){return"number"==typeof t||_(t)&&"[object Number]"==g(t)}(t)&&t!=+t}var Et=function(t){return!wt(t)&&!At(parseFloat(t))},Tt=function(t){return null!=t&&"boolean"==typeof t},xt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==G(t)&&(!1===e||!0===e&&null!==t)},Pt=function(t){switch(t){case"number":return Et;case"string":return jt;case"boolean":return Tt;default:return xt}},qt=function(t,e){return void 0===e&&(e=""),!!o(t)&&(""===e||""===G(e)||!(t.filter((function(t){return!Pt(e)(t)})).length>0))},Ct=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},$t=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Pt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!qt(r,t)})).length};var zt,Nt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[zt?a:++n];if(!1===e(o[u],u,o))break}return t};function Mt(t){return _(t)&&"[object Arguments]"==g(t)}var Rt=Object.prototype,It=Rt.hasOwnProperty,Ft=Rt.propertyIsEnumerable,Jt=Mt(function(){return arguments}())?Mt:function(t){return _(t)&&It.call(t,"callee")&&!Ft.call(t,"callee")};var Ut="object"==typeof exports&&exports&&!exports.nodeType&&exports,Lt=Ut&&"object"==typeof module&&module&&!module.nodeType&&module,Ht=Lt&&Lt.exports===Ut?c.Buffer:void 0,Dt=(Ht?Ht.isBuffer:void 0)||function(){return!1},Kt=/^(?:0|[1-9]\d*)$/;function Bt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Kt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Gt={};Gt["[object Float32Array]"]=Gt["[object Float64Array]"]=Gt["[object Int8Array]"]=Gt["[object Int16Array]"]=Gt["[object Int32Array]"]=Gt["[object Uint8Array]"]=Gt["[object Uint8ClampedArray]"]=Gt["[object Uint16Array]"]=Gt["[object Uint32Array]"]=!0,Gt["[object Arguments]"]=Gt["[object Array]"]=Gt["[object ArrayBuffer]"]=Gt["[object Boolean]"]=Gt["[object DataView]"]=Gt["[object Date]"]=Gt["[object Error]"]=Gt["[object Function]"]=Gt["[object Map]"]=Gt["[object Number]"]=Gt["[object Object]"]=Gt["[object RegExp]"]=Gt["[object Set]"]=Gt["[object String]"]=Gt["[object WeakMap]"]=!1;var Wt,Yt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Qt=Yt&&"object"==typeof module&&module&&!module.nodeType&&module,Xt=Qt&&Qt.exports===Yt&&a.process,Zt=function(){try{var t=Qt&&Qt.require&&Qt.require("util").types;return t||Xt&&Xt.binding&&Xt.binding("util")}catch(t){}}(),te=Zt&&Zt.isTypedArray,ee=te?(Wt=te,function(t){return Wt(t)}):function(t){return _(t)&&Vt(t.length)&&!!Gt[g(t)]},re=Object.prototype.hasOwnProperty;function ne(t,e){var r=o(t),n=!r&&Jt(t),i=!r&&!n&&Dt(t),a=!r&&!n&&!i&&ee(t),u=r||n||i||a,c=u?function(t,e){for(var r=-1,n=Array(t);++r-1},ge.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 ye,be=c["__core-js_shared__"],_e=(ye=/[^.]+$/.exec(be&&be.keys&&be.keys.IE_PROTO||""))?"Symbol(src)_1."+ye:"";var me=Function.prototype.toString;function we(t){if(null!=t){try{return me.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var je=/^\[object .+?Constructor\]$/,Se=Function.prototype,Oe=Object.prototype,ke=Se.toString,Ae=Oe.hasOwnProperty,Ee=RegExp("^"+ke.call(Ae).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Te(t){return!(!ce(t)||function(t){return!!_e&&_e in t}(t))&&(se(t)?Ee:je).test(we(t))}function xe(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Te(r)?r:void 0}var Pe=xe(c,"Map"),qe=xe(Object,"create");var Ce=Object.prototype.hasOwnProperty;var $e=Object.prototype.hasOwnProperty;function ze(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 l=-1,f=!0,p=2&r?new Ie:void 0;for(i.set(t,e),i.set(e,t);++le.type.filter((function(t){var e;return void 0===r||(!1!==(e=Ct(t))?!$t({arg:r},e):!Pt(t)(r))})).length)})).length}return!1},zr=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($r,null,a);case"array"===t:return!qt(e.arg);case!1!==(r=Ct(t)):return!$t(e,r);default:return!Pt(t)(e.arg)}},Nr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Mr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!qt(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(!qt(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?Nr(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!!kt(e)&&!(r.type.length>r.type.filter((function(e){return zr(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return zr(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Rr=function(){try{var t=xe(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Ir(t,e,r){"__proto__"==e&&Rr?Rr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Fr(t,e,r){(void 0===r||he(t[e],r))&&(void 0!==r||e in t)||Ir(t,e,r)}var Jr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ur=Jr&&"object"==typeof module&&module&&!module.nodeType&&module,Lr=Ur&&Ur.exports===Jr?c.Buffer:void 0,Hr=Lr?Lr.allocUnsafe:void 0;function Dr(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Ue(n).set(new Ue(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Kr=Object.create,Br=function(){function t(){}return function(e){if(!ce(e))return{};if(Kr)return Kr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Vr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Gr=Object.prototype.hasOwnProperty;function Wr(t,e,r){var n=t[e];Gr.call(t,e)&&he(n,r)&&(void 0!==r||e in t)||Ir(t,e,r)}var Yr=Object.prototype.hasOwnProperty;function Qr(t){if(!ce(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=ie(t),r=[];for(var n in t)("constructor"!=n||!e&&Yr.call(t,n))&&r.push(n);return r}function Xr(t){return le(t)?ne(t,!0):Qr(t)}function Zr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(on);function cn(t,e){return un(function(t,e,r){return e=nn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=nn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=sn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ce(r))return!1;var n=typeof e;return!!("number"==n?le(r)&&Bt(e,r.length):"string"==n&&e in r)&&he(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r=0;e--){var r=uo().key(e);t(co(r),r)}},remove:function(t){return uo().removeItem(t)},clearAll:function(){return uo().clear()}};function uo(){return io.localStorage}function co(t){return uo().getItem(t)}var so=Hn.trim,lo={name:"cookieStorage",read:function(t){if(!t||!vo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(fo.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;fo.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:po,remove:ho,clearAll:function(){po((function(t,e){ho(e)}))}},fo=Hn.Global.document;function po(t){for(var e=fo.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(so(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function ho(t){t&&vo(t)&&(fo.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function vo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(fo.cookie)}var go=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 yo=Hn.bind,bo=Hn.each,_o=Hn.create,mo=Hn.slice,wo=function(){var t=_o(jo,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,yo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,yo(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(),bo(r,(function(e,r){t.fire(r,void 0,e)}))}}};var jo={_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,yo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=mo(arguments,1);bo(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},So=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==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++),a[s]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(u,l)){if(l.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=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,l,f=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)f[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;l=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;l=t(a);break;case 2:return""}for(f[3]=l,i=l,g.push(l);;){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(l=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[h++]=t(a),l=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;f[h++]=t(a),l=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),f[l])v=f[l];else{if(l!==h)return null;v=i+i.charAt(0)}g.push(v),f[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Oo=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=So.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=So.compress(this._serialize(r));t(e,n)}}};var ko=[ao,lo],Ao=[go,wo,Oo],Eo=ro.createStore(ko,Ao),To=Hn.Global;function xo(){return To.sessionStorage}function Po(t){return xo().getItem(t)}var qo=[{name:"sessionStorage",read:Po,write:function(t,e){return xo().setItem(t,e)},each:function(t){for(var e=xo().length-1;e>=0;e--){var r=xo().key(e);t(Po(r),r)}},remove:function(t){return xo().removeItem(t)},clearAll:function(){return xo().clear()}},lo],Co=[go,Oo],$o=ro.createStore(qo,Co),zo=Eo,No=$o;function Mo(t,e){var r;return(r={})[t]=e,r.TS=[Rn()],r}var Ro=function(t){return Y(t,"data")&&!Y(t,"error")?t.data:t},Io=function(t){this.opts=t,this.instanceKey=vt(this.opts.hostname),this.localStore=zo,this.sessionStore=No},Fo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Io.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?ln({},o,e):e,r))},Io.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Io.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)}},Io.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)}},Fo.lset.set=function(t){return this.__setMethod("localStore",t)},Fo.lget.get=function(){return this.__getMethod("localStore")},Io.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Io.prototype.lclear=function(){return this.__clearMethod("localStore")},Fo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Fo.sget.get=function(){return this.__getMethod("sessionStore")},Io.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Io.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Io.prototype,Fo);var Jo=r[0],Uo=r[1],Lo=function(t){function e(e,r){t.call(this,r),console.log("fly",e),this.fly=e,this.reqInterceptor(),this.resInterceptor()}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=Ot),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($n(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new ut("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&&$n(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(!dt(t))throw new ut("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=dt(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={}}t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r;var i={headers:{configurable:!0}};return i.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=ln({},{_cb:Rn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=ln({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=ln({},{method:Jo,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 Ro(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=Cn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Ro(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new st("Server side error",r)}))},r.prototype.getHeaders=function(){return this.opts.enableAuth?ln({},e,this.getAuthHeader(),this.extraHeader):ln({},e,this.extraHeader)},r.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},r.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=ln({},this.extraParams,n)),this.request({},{method:"GET"},this.contractHeader).then(pt).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 st("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),wt(t)&&o(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Mo(t,n)}throw new ut("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(pt)},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.payload=e,o.condition=r,!0===n)return o;if(wt(t))return Mo(t,o);throw new ut("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Uo}).then(pt)},Object.defineProperties(r.prototype,i),r}(Io)))),Ho=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,W(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 zn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(ht)}},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 zn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(ht)}))};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 zn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(ht)}))};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,r,n){var o=function(t,e,r,n){var o=[Vo,Go,Wo];return Reflect.apply(Ho,null,o)({},t,e,r,n)}(t,n,e,r);return e.exposeStore,o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.5.16",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.userdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)},Qo={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:t,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Xo={hostname:Nn(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Nn("jsonql",["string"]),loginHandlerName:Nn("login",["string"]),logoutHandlerName:Nn("logout",["string"]),enableJsonp:Nn(!1,["boolean"]),enableAuth:Nn(!1,["boolean"]),useJwt:Nn(!0,["boolean"]),persistToken:Nn(!1,["boolean","number"]),useLocalstorage:Nn(!0,["boolean"]),storageKey:Nn("jsonqlstore",["string"]),authKey:Nn("jsonqlauthkey",["string"]),contractExpired:Nn(0,["number"]),keepContract:Nn(!0,["boolean"]),exposeContract:Nn(!1,["boolean"]),exposeStore:Nn(!1,["boolean"]),showContractDesc:Nn(!1,["boolean"]),contractKey:Nn(!1,["boolean"]),contractKeyName:Nn("X-JSONQL-CV-KEY",["string"]),enableTimeout:Nn(!1,["boolean"]),timeout:Nn(5e3,["number"]),returnInstance:Nn(!1,["boolean"]),allowReturnRawToken:Nn(!1,["boolean"]),debugOn:Nn(!1,["boolean"])};function Zo(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];var o=function(t){return Ko(t,"__checked__",Rn())};r.push(o);var i=Reflect.apply(Ho,null,r);return function(r){return void 0===r&&(r={}),i(r,t,e)}}function ti(t){var e=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return function(n){var o;if(void 0===n&&(n={}),Do(n,"__checked__")){var i=1;return n.__passed__&&(i=++n.__passed__,delete n.__passed__),Promise.resolve(Object.assign(((o={}).__passed__=i,o),n,e))}var a=Reflect.apply(Zo,null,[t,e].concat(r));return Promise.resolve(a(n))}}(Xo,Qo,Mn),r=t.contract;return e(t).then((function(t){return t.contract=r,t}))}function ei(t,e,r){return void 0===e&&(e={}),ti(e).then((function(t){return{baseClient:new Lo(r,t),opts:t}})).then((function(e){var r,n,o=e.baseClient,i=e.opts;return(r=o,n=i.contract,void 0===n&&(n={}),dt(n)?Promise.resolve(n):r.getContract()).then((function(e){return Yo(o,i,e,t)}))}))}var ri=new WeakMap,ni=new WeakMap,oi=function(){this.__suspend__=null,this.queueStore=new Set},ii={$suspend:{configurable:!0},$queues:{configurable:!0}};ii.$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)},oi.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__},ii.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},oi.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(oi.prototype,ii);var ai=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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,l=0;l0;)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){ri.set(this,t)},r.normalStore.get=function(){return ri.get(this)},r.lazyStore.set=function(t){ni.set(this,t)},r.lazyStore.get=function(){return ni.get(this)},e.prototype.hashFnToKey=function(t){return vt(t.toString())},Object.defineProperties(e.prototype,r),e}(oi)));return function(t,e){var r;return ei((r=e.debugOn,new ai({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=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),e=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),r=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),n=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),o=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),i=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),a=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),u=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),c=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),s=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),l=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),f="application/vnd.api+json",p={Accept:f,"Content-Type":[f,"charset=utf-8"].join(";")},h=["POST","PUT"],d={desc:"y"},v=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),g=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),y=Object.freeze({__proto__:null,Jsonql406Error:t,Jsonql500Error:e,JsonqlForbiddenError:r,JsonqlAuthorisationError:n,JsonqlContractAuthError:o,JsonqlResolverAppError:i,JsonqlResolverNotFoundError:a,JsonqlEnumError:u,JsonqlTypeError:c,JsonqlCheckerError:s,JsonqlValidationError:l,JsonqlError:v,JsonqlServerError:g}),b=v;function _(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&y[o])throw new y[r](i,a);throw new b(i,a)}return t}function m(f){if(Array.isArray(f))throw new l("",f);var p=f.message||"No message",h=f.detail||f;switch(!0){case f instanceof t:throw new t(p,h);case f instanceof e:throw new e(p,h);case f instanceof r:throw new r(p,h);case f instanceof n:throw new n(p,h);case f instanceof o:throw new o(p,h);case f instanceof i:throw new i(p,h);case f instanceof a:throw new a(p,h);case f instanceof u:throw new u(p,h);case f instanceof c:throw new c(p,h);case f instanceof s:throw new s(p,h);case f instanceof l:throw new l(p,h);case f instanceof g:throw new g(p,h);default:throw new v(p,h)}}var 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;function A(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--&&L(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var ot=function(t){return!!E(t)||null!=t&&""!==nt(t)};function it(t){return function(t){return"number"==typeof t||N(t)&&"[object Number]"==z(t)}(t)&&t!=+t}function at(t){return"string"==typeof t||!E(t)&&N(t)&&"[object String]"==z(t)}var ut=function(t){return!at(t)&&!it(parseFloat(t))},ct=function(t){return""!==nt(t)&&at(t)},st=function(t){return null!=t&&"boolean"==typeof t},lt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==nt(t)&&(!1===e||!0===e&&null!==t)},ft=function(t){switch(t){case"number":return ut;case"string":return ct;case"boolean":return st;default:return lt}},pt=function(t,e){return void 0===e&&(e=""),!!E(t)&&(""===e||""===nt(e)||!(t.filter((function(t){return!ft(e)(t)})).length>0))},ht=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},dt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!ft(e)(t)})).length)})).length:e.length>e.filter((function(t){return!pt(r,t)})).length};function vt(t,e){return function(r){return t(e(r))}}var gt=vt(Object.getPrototypeOf,Object),yt=Function.prototype,bt=Object.prototype,_t=yt.toString,mt=bt.hasOwnProperty,wt=_t.call(Object);function jt(t){if(!N(t)||"[object Object]"!=z(t))return!1;var e=gt(t);if(null===e)return!0;var r=mt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&_t.call(r)==wt}var St,Ot=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[St?a:++n];if(!1===e(o[u],u,o))break}return t};function kt(t){return N(t)&&"[object Arguments]"==z(t)}var At=Object.prototype,Et=At.hasOwnProperty,Tt=At.propertyIsEnumerable,xt=kt(function(){return arguments}())?kt:function(t){return N(t)&&Et.call(t,"callee")&&!Tt.call(t,"callee")};var Pt="object"==typeof exports&&exports&&!exports.nodeType&&exports,qt=Pt&&"object"==typeof module&&module&&!module.nodeType&&module,Ct=qt&&qt.exports===Pt?O.Buffer:void 0,$t=(Ct?Ct.isBuffer:void 0)||function(){return!1},zt=/^(?:0|[1-9]\d*)$/;function Nt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&zt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var It={};It["[object Float32Array]"]=It["[object Float64Array]"]=It["[object Int8Array]"]=It["[object Int16Array]"]=It["[object Int32Array]"]=It["[object Uint8Array]"]=It["[object Uint8ClampedArray]"]=It["[object Uint16Array]"]=It["[object Uint32Array]"]=!0,It["[object Arguments]"]=It["[object Array]"]=It["[object ArrayBuffer]"]=It["[object Boolean]"]=It["[object DataView]"]=It["[object Date]"]=It["[object Error]"]=It["[object Function]"]=It["[object Map]"]=It["[object Number]"]=It["[object Object]"]=It["[object RegExp]"]=It["[object Set]"]=It["[object String]"]=It["[object WeakMap]"]=!1;var Rt,Ft="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=Ft&&"object"==typeof module&&module&&!module.nodeType&&module,Ut=Jt&&Jt.exports===Ft&&j.process,Lt=function(){try{var t=Jt&&Jt.require&&Jt.require("util").types;return t||Ut&&Ut.binding&&Ut.binding("util")}catch(t){}}(),Ht=Lt&&Lt.isTypedArray,Dt=Ht?(Rt=Ht,function(t){return Rt(t)}):function(t){return N(t)&&Mt(t.length)&&!!It[z(t)]},Kt=Object.prototype.hasOwnProperty;function Bt(t,e){var r=E(t),n=!r&&xt(t),o=!r&&!n&&$t(t),i=!r&&!n&&!o&&Dt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},ie.prototype.set=function(t,e){var r=this.__data__,n=ne(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var ae,ue=O["__core-js_shared__"],ce=(ae=/[^.]+$/.exec(ue&&ue.keys&&ue.keys.IE_PROTO||""))?"Symbol(src)_1."+ae:"";var se=Function.prototype.toString;function le(t){if(null!=t){try{return se.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var fe=/^\[object .+?Constructor\]$/,pe=Function.prototype,he=Object.prototype,de=pe.toString,ve=he.hasOwnProperty,ge=RegExp("^"+de.call(ve).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ye(t){return!(!Qt(t)||function(t){return!!ce&&ce in t}(t))&&(Xt(t)?ge:fe).test(le(t))}function be(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ye(r)?r:void 0}var _e=be(O,"Map"),me=be(Object,"create");var we=Object.prototype.hasOwnProperty;var je=Object.prototype.hasOwnProperty;function Se(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 l=-1,f=!0,p=2&r?new Ee:void 0;for(i.set(t,e),i.set(e,t);++le.type.filter((function(t){var e;return void 0===r||(!1!==(e=ht(t))?!dt({arg:r},e):!ft(t)(r))})).length)})).length}return!1},Sr=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(jr,null,a);case"array"===t:return!pt(e.arg);case!1!==(r=ht(t)):return!dt(e,r);default:return!ft(t)(e.arg)}},Or=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},kr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!pt(e))throw new v("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!pt(t))throw new v("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?Or(t,a):t,index:r,param:a,optional:i}}));default:throw new v("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!!ot(e)&&!(r.type.length>r.type.filter((function(e){return Sr(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Sr(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Ar=function(){try{var t=be(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Er(t,e,r){"__proto__"==e&&Ar?Ar(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Tr(t,e,r){(void 0===r||re(t[e],r))&&(void 0!==r||e in t)||Er(t,e,r)}var xr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Pr=xr&&"object"==typeof module&&module&&!module.nodeType&&module,qr=Pr&&Pr.exports===xr?O.Buffer:void 0,Cr=qr?qr.allocUnsafe:void 0;function $r(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Pe(n).set(new Pe(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var zr=Object.create,Nr=function(){function t(){}return function(e){if(!Qt(e))return{};if(zr)return zr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Mr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ir=Object.prototype.hasOwnProperty;function Rr(t,e,r){var n=t[e];Ir.call(t,e)&&re(n,r)&&(void 0!==r||e in t)||Er(t,e,r)}var Fr=Object.prototype.hasOwnProperty;function Jr(t){if(!Qt(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Gt(t),r=[];for(var n in t)("constructor"!=n||!e&&Fr.call(t,n))&&r.push(n);return r}function Ur(t){return Zt(t)?Bt(t,!0):Jr(t)}function Lr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Vr);function Yr(t,e){return Wr(function(t,e,r){return e=Br(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Br(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=Qr.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!Qt(r))return!1;var n=typeof e;return!!("number"==n?Zt(r)&&Nt(e,r.length):"string"==n&&e in r)&&re(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,yn(t))}),Reflect.apply(t,null,r))}};function mn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function wn(t,e,r,n){void 0===n&&(n=!1);var o=mn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var jn=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 dn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(m)}},Sn=function(t,e,r,n,o){var i={},a=function(t){i=wn(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 dn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(m)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},On=function(t,e,r,n,o){var i={},a=function(t){i=wn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return dn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(m)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},kn=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=jn(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=jn(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 An=function(t,e,r,n){var o=function(t,e,r,n){var o=[Sn,On,kn];return Reflect.apply(_n,null,o)({},t,e,r,n)}(t,n,e,r);return e.exposeStore,o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.5.17",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.userdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)};function En(t){return!!function(t){return jt(t)&&(bn(t,"query")||bn(t,"mutation")||bn(t,"socket"))}(t)&&t}function Tn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function xn(t){this.message=t}xn.prototype=new Error,xn.prototype.name="InvalidCharacterError";var Pn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new xn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var qn=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(Pn(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 Pn(e)}};function Cn(t){this.message=t}Cn.prototype=new Error,Cn.prototype.name="InvalidTokenError";var $n=function(t,e){if("string"!=typeof t)throw new Cn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(qn(t.split(".")[r]))}catch(t){throw new Cn("Invalid token specified: "+t.message)}};$n.InvalidTokenError=Cn;var zn,Nn,Mn,In,Rn,Fn,Jn,Un,Ln;function Hn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new v("Token has expired on "+r,t)}return t}function Dn(t){if(ct(t))return Hn($n(t));throw new v("Token must be a string!")}vn("HS256",["string"]),vn(!1,["boolean","number","string"],((zn={}).alias="exp",zn.optional=!0,zn)),vn(!1,["boolean","number","string"],((Nn={}).alias="nbf",Nn.optional=!0,Nn)),vn(!1,["boolean","string"],((Mn={}).alias="iss",Mn.optional=!0,Mn)),vn(!1,["boolean","string"],((In={}).alias="sub",In.optional=!0,In)),vn(!1,["boolean","string"],((Rn={}).alias="iss",Rn.optional=!0,Rn)),vn(!1,["boolean"],((Fn={}).optional=!0,Fn)),vn(!1,["boolean","string"],((Jn={}).optional=!0,Jn)),vn(!1,["boolean","string"],((Un={}).optional=!0,Un)),vn(!1,["boolean"],((Ln={}).optional=!0,Ln));var Kn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Bn(t,e){var r;return(r={})[t]=e,r.TS=[Kn()],r}var Vn=function(t){return bn(t,"data")&&!bn(t,"error")?t.data:t},Gn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Wn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=bo().key(e);t(_o(r),r)}},remove:function(t){return bo().removeItem(t)},clearAll:function(){return bo().clear()}};function bo(){return go.localStorage}function _o(t){return bo().getItem(t)}var mo=Zn.trim,wo={name:"cookieStorage",read:function(t){if(!t||!ko(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(jo.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;jo.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:So,remove:Oo,clearAll:function(){So((function(t,e){Oo(e)}))}},jo=Zn.Global.document;function So(t){for(var e=jo.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(mo(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Oo(t){t&&ko(t)&&(jo.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function ko(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(jo.cookie)}var Ao=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 Eo=Zn.bind,To=Zn.each,xo=Zn.create,Po=Zn.slice,qo=function(){var t=xo(Co,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,Eo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,Eo(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(),To(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Co={_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,Eo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Po(arguments,1);To(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},$o=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==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++),a[s]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(u,l)){if(l.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=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,l,f=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)f[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;l=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;l=t(a);break;case 2:return""}for(f[3]=l,i=l,g.push(l);;){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(l=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[h++]=t(a),l=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;f[h++]=t(a),l=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),f[l])v=f[l];else{if(l!==h)return null;v=i+i.charAt(0)}g.push(v),f[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),zo=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=$o.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=$o.compress(this._serialize(r));t(e,n)}}};var No=[yo,wo],Mo=[Ao,qo,zo],Io=po.createStore(No,Mo),Ro=Zn.Global;function Fo(){return Ro.sessionStorage}function Jo(t){return Fo().getItem(t)}var Uo=[{name:"sessionStorage",read:Jo,write:function(t,e){return Fo().setItem(t,e)},each:function(t){for(var e=Fo().length-1;e>=0;e--){var r=Fo().key(e);t(Jo(r),r)}},remove:function(t){return Fo().removeItem(t)},clearAll:function(){return Fo().clear()}},wo],Lo=[Ao,zo],Ho=po.createStore(Uo,Lo),Do=Io,Ko=Ho,Bo=function(t){this.opts=t,this.instanceKey=Tn(this.opts.hostname),this.localStore=Do,this.sessionStore=Ko},Vo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Bo.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?Xr({},o,e):e,r))},Bo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Bo.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)}},Bo.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)}},Vo.lset.set=function(t){return this.__setMethod("localStore",t)},Vo.lget.get=function(){return this.__getMethod("localStore")},Bo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Bo.prototype.lclear=function(){return this.__clearMethod("localStore")},Vo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Vo.sget.get=function(){return this.__getMethod("sessionStore")},Bo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Bo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Bo.prototype,Vo);var Go=h[0],Wo=h[1],Yo=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}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=Dn),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(hn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new l("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&&hn(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(!En(t))throw new l("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=En(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={}}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=Xr({},{_cb:Kn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=Xr({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=Xr({},{method:Go,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.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 Vn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=pn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Vn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new g("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?Xr({},p,this.getAuthHeader(),this.extraHeader):Xr({},p,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=Xr({},this.extraParams,d)),this.request({},{method:"GET"},this.contractHeader).then(_).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 g("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),at(t)&&E(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Bn(t,n)}throw new l("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(_)},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.payload=e,o.condition=r,!0===n)return o;if(at(t))return Bn(t,o);throw new l("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Wo}).then(_)},Object.defineProperties(e.prototype,r),e}(Bo)))),Qo={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:f,BEARER:"Bearer",AUTH_HEADER:"Authorization"},Xo={hostname:vn(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:vn("jsonql",["string"]),loginHandlerName:vn("login",["string"]),logoutHandlerName:vn("logout",["string"]),enableJsonp:vn(!1,["boolean"]),enableAuth:vn(!1,["boolean"]),useJwt:vn(!0,["boolean"]),persistToken:vn(!1,["boolean","number"]),useLocalstorage:vn(!0,["boolean"]),storageKey:vn("jsonqlstore",["string"]),authKey:vn("jsonqlauthkey",["string"]),contractExpired:vn(0,["number"]),keepContract:vn(!0,["boolean"]),exposeContract:vn(!1,["boolean"]),exposeStore:vn(!1,["boolean"]),showContractDesc:vn(!1,["boolean"]),contractKey:vn(!1,["boolean"]),contractKeyName:vn("X-JSONQL-CV-KEY",["string"]),enableTimeout:vn(!1,["boolean"]),timeout:vn(5e3,["number"]),returnInstance:vn(!1,["boolean"]),allowReturnRawToken:vn(!1,["boolean"]),debugOn:vn(!1,["boolean"])};function Zo(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];var o=function(t){return wn(t,"__checked__",Kn())};r.push(o);var i=Reflect.apply(_n,null,r);return function(r){return void 0===r&&(r={}),i(r,t,e)}}function ti(t){var e=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return function(n){var o;if(void 0===n&&(n={}),mn(n,"__checked__")){var i=1;return n.__passed__&&(i=++n.__passed__,delete n.__passed__),Promise.resolve(Object.assign(((o={}).__passed__=i,o),n,e))}var a=Reflect.apply(Zo,null,[t,e].concat(r));return Promise.resolve(a(n))}}(Xo,Qo,gn),r=t.contract;return e(t).then((function(t){return t.contract=r,t}))}function ei(t,e,r){return void 0===r&&(r={}),ti(r).then((function(t){return{baseClient:new Yo(e,t),opts:t}})).then((function(e){var r,n,o=e.baseClient,i=e.opts;return(r=o,n=i.contract,void 0===n&&(n={}),En(n)?Promise.resolve(n):r.getContract()).then((function(e){return An(o,i,e,t)}))}))}var ri=new WeakMap,ni=new WeakMap,oi=function(){this.__suspend__=null,this.queueStore=new Set},ii={$suspend:{configurable:!0},$queues:{configurable:!0}};ii.$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)},oi.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__},ii.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},oi.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(oi.prototype,ii);var ai=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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,l=0;l0;)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){ri.set(this,t)},r.normalStore.get=function(){return ri.get(this)},r.lazyStore.set=function(t){ni.set(this,t)},r.lazyStore.get=function(){return ni.get(this)},e.prototype.hashFnToKey=function(t){return Tn(t.toString())},Object.defineProperties(e.prototype,r),e}(oi)));return function(t,e){var r;return ei((r=e.debugOn,new ai({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),t,e)}})); //# sourceMappingURL=core.js.map diff --git a/packages/http-client/core.js.map b/packages/http-client/core.js.map index 9e09209f9db00732470761147fe78688a69e6da4..0a97fb6f095856855867d7422a5fab7c75369246 100644 --- a/packages/http-client/core.js.map +++ b/packages/http-client/core.js.map @@ -1 +1 @@ -{"version":3,"file":"core.js","sources":["node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"q2vCAAA"} \ No newline at end of file +{"version":3,"file":"core.js","sources":["node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"wl1CAAA"} \ No newline at end of file diff --git a/packages/http-client/dist/jsonql-client.static-full.js b/packages/http-client/dist/jsonql-client.static-full.js index 6e166c730d049d646a7187bf79acc857f98ccca9..5962ad003421001c1e8f61f1fa6f1ee299d833ad 100644 --- a/packages/http-client/dist/jsonql-client.static-full.js +++ b/packages/http-client/dist/jsonql-client.static-full.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("?")?"?":"&")+_.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==g&&(a.responseType=g)}catch(t){}var w=r.headers["Content-Type"]||r.headers[u],j="application/x-www-form-urlencoded";for(var O in o.trim((w||"").toLowerCase())===j?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(j="application/json;charset=utf-8",e=JSON.stringify(e)),w||y||(r.headers["Content-Type"]=j),r.headers)if("Content-Type"===O&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function S(t,e,n){d(f.p,(function(){if(t){n&&(e.request=r);var o=t.call(f,e,Promise);e=void 0===o?e:o}h(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){c(t)})).catch((function(t){p(t)}))}))}function k(t){t.engine=a,S(f.onerror,t,-1)}function E(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader("Content-Type")||"").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,u=a.statusText,c={data:t,headers:e,status:i,statusText:u};if(o.merge(c,a._response),i>=200&&i<300||304===i)c.engine=a,c.request=r,S(f.handler,c,0);else{var s=new E(u,i);s.response=c,k(s)}}catch(s){k(new E(s.msg,a.status))}},a.onerror=function(t){k(new E(t.msg||"Network Error",0))},a.ontimeout=function(){k(new E("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(y?null:e)}),0)}(n):c(n)}),(function(t){p(t)}))}))}));return p.engine=a,p}},{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=["POST","PUT"],c={desc:"y"},s=Array.isArray,f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},l="object"==typeof f&&f&&f.Object===Object&&f,p="object"==typeof self&&self&&self.Object===Object&&self,h=l||p||Function("return this")(),d=h.Symbol,v=Object.prototype,g=v.hasOwnProperty,y=v.toString,b=d?d.toStringTag:void 0;var m=Object.prototype.toString;var _=d?d.toStringTag:void 0;function w(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":_&&_ in Object(t)?function(t){var e=g.call(t,b),r=t[b];try{t[b]=void 0;var n=!0}catch(t){}var o=y.call(t);return n&&(e?t[b]=r:delete t[b]),o}(t):function(t){return m.call(t)}(t)}function j(t,e){return function(r){return t(e(r))}}var O=j(Object.getPrototypeOf,Object);function S(t){return null!=t&&"object"==typeof t}var k=Function.prototype,E=Object.prototype,T=k.toString,A=E.hasOwnProperty,x=T.call(Object);function P(t){if(!S(t)||"[object Object]"!=w(t))return!1;var e=O(t);if(null===e)return!0;var r=A.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&T.call(r)==x}function q(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--&&F(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var tt=function(t){return s(t)?t:[t]},et=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},rt=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},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={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),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"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),it=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),ut=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),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={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),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 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),ft=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),lt=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),ht=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),dt=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),vt=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),gt=Object.freeze({__proto__:null,Jsonql406Error:nt,Jsonql500Error:ot,JsonqlForbiddenError:it,JsonqlAuthorisationError:at,JsonqlContractAuthError:ut,JsonqlResolverAppError:ct,JsonqlResolverNotFoundError:st,JsonqlEnumError:ft,JsonqlTypeError:lt,JsonqlCheckerError:pt,JsonqlValidationError:ht,JsonqlError:dt,JsonqlServerError:vt}),yt=dt;function bt(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&>[o])throw new gt[r](i,a);throw new yt(i,a)}return t}function mt(t){if(Array.isArray(t))throw new ht("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof st:throw new st(e,r);case t instanceof ft:throw new ft(e,r);case t instanceof lt:throw new lt(e,r);case t instanceof pt:throw new pt(e,r);case t instanceof ht:throw new ht(e,r);case t instanceof vt:throw new vt(e,r);default:throw new dt(e,r)}}var _t=function(t){return!!s(t)||null!=t&&""!==Z(t)};function wt(t){return function(t){return"number"==typeof t||S(t)&&"[object Number]"==w(t)}(t)&&t!=+t}function jt(t){return"string"==typeof t||!s(t)&&S(t)&&"[object String]"==w(t)}var Ot=function(t){return!jt(t)&&!wt(parseFloat(t))},St=function(t){return""!==Z(t)&&jt(t)},kt=function(t){return null!=t&&"boolean"==typeof t},Et=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==Z(t)&&(!1===e||!0===e&&null!==t)},Tt=function(t){switch(t){case"number":return Ot;case"string":return St;case"boolean":return kt;default:return Et}},At=function(t,e){return void 0===e&&(e=""),!!s(t)&&(""===e||""===Z(e)||!(t.filter((function(t){return!Tt(e)(t)})).length>0))},xt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Pt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Tt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!At(r,t)})).length};var qt,Ct=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[qt?a:++n];if(!1===e(o[u],u,o))break}return t};function $t(t){return S(t)&&"[object Arguments]"==w(t)}var zt=Object.prototype,Nt=zt.hasOwnProperty,Rt=zt.propertyIsEnumerable,Mt=$t(function(){return arguments}())?$t:function(t){return S(t)&&Nt.call(t,"callee")&&!Rt.call(t,"callee")};var Ft="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=Ft&&"object"==typeof module&&module&&!module.nodeType&&module,It=Jt&&Jt.exports===Ft?h.Buffer:void 0,Ut=(It?It.isBuffer:void 0)||function(){return!1},Dt=/^(?:0|[1-9]\d*)$/;function Ht(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Dt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Bt={};Bt["[object Float32Array]"]=Bt["[object Float64Array]"]=Bt["[object Int8Array]"]=Bt["[object Int16Array]"]=Bt["[object Int32Array]"]=Bt["[object Uint8Array]"]=Bt["[object Uint8ClampedArray]"]=Bt["[object Uint16Array]"]=Bt["[object Uint32Array]"]=!0,Bt["[object Arguments]"]=Bt["[object Array]"]=Bt["[object ArrayBuffer]"]=Bt["[object Boolean]"]=Bt["[object DataView]"]=Bt["[object Date]"]=Bt["[object Error]"]=Bt["[object Function]"]=Bt["[object Map]"]=Bt["[object Number]"]=Bt["[object Object]"]=Bt["[object RegExp]"]=Bt["[object Set]"]=Bt["[object String]"]=Bt["[object WeakMap]"]=!1;var Kt,Gt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Vt=Gt&&"object"==typeof module&&module&&!module.nodeType&&module,Wt=Vt&&Vt.exports===Gt&&l.process,Yt=function(){try{var t=Vt&&Vt.require&&Vt.require("util").types;return t||Wt&&Wt.binding&&Wt.binding("util")}catch(t){}}(),Qt=Yt&&Yt.isTypedArray,Xt=Qt?(Kt=Qt,function(t){return Kt(t)}):function(t){return S(t)&&Lt(t.length)&&!!Bt[w(t)]},Zt=Object.prototype.hasOwnProperty;function te(t,e){var r=s(t),n=!r&&Mt(t),o=!r&&!n&&Ut(t),i=!r&&!n&&!o&&Xt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},he.prototype.set=function(t,e){var r=this.__data__,n=le(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var de,ve=h["__core-js_shared__"],ge=(de=/[^.]+$/.exec(ve&&ve.keys&&ve.keys.IE_PROTO||""))?"Symbol(src)_1."+de:"";var ye=Function.prototype.toString;function be(t){if(null!=t){try{return ye.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var me=/^\[object .+?Constructor\]$/,_e=Function.prototype,we=Object.prototype,je=_e.toString,Oe=we.hasOwnProperty,Se=RegExp("^"+je.call(Oe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ke(t){return!(!ie(t)||function(t){return!!ge&&ge in t}(t))&&(ae(t)?Se:me).test(be(t))}function Ee(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ke(r)?r:void 0}var Te=Ee(h,"Map"),Ae=Ee(Object,"create");var xe=Object.prototype.hasOwnProperty;var Pe=Object.prototype.hasOwnProperty;function qe(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=2&r?new Ne:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=xt(t))?!Pt({arg:r},e):!Tt(t)(r))})).length)})).length}return!1},qr=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(Pr,null,a);case"array"===t:return!At(e.arg);case!1!==(r=xt(t)):return!Pt(e,r);default:return!Tt(t)(e.arg)}},Cr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},$r=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!At(e))throw new dt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!At(t))throw new dt("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?Cr(t,a):t,index:r,param:a,optional:i}}));default:throw new dt("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!!_t(e)&&!(r.type.length>r.type.filter((function(e){return qr(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return qr(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},zr=function(){try{var t=Ee(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Nr(t,e,r){"__proto__"==e&&zr?zr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Rr(t,e,r){(void 0===r||fe(t[e],r))&&(void 0!==r||e in t)||Nr(t,e,r)}var Mr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Fr=Mr&&"object"==typeof module&&module&&!module.nodeType&&module,Jr=Fr&&Fr.exports===Mr?h.Buffer:void 0,Ir=Jr?Jr.allocUnsafe:void 0;function Ur(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Fe(n).set(new Fe(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Dr=Object.create,Hr=function(){function t(){}return function(e){if(!ie(e))return{};if(Dr)return Dr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Lr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Br=Object.prototype.hasOwnProperty;function Kr(t,e,r){var n=t[e];Br.call(t,e)&&fe(n,r)&&(void 0!==r||e in t)||Nr(t,e,r)}var Gr=Object.prototype.hasOwnProperty;function Vr(t){if(!ie(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&&Gr.call(t,n))&&r.push(n);return r}function Wr(t){return ue(t)?te(t,!0):Vr(t)}function Yr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(en);function on(t,e){return nn(function(t,e,r){return e=tn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=tn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=an.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ie(r))return!1;var n=typeof e;return!!("number"==n?ue(r)&&Ht(e,r.length):"string"==n&&e in r)&&fe(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,tt(t))}),Reflect.apply(t,null,r))}};function En(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Tn(t,e,r,n){void 0===n&&(n=!1);var o=En(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var An=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 jn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(mt)}},xn=function(t,e,r,n,o){var i={},a=function(t){i=Tn(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 jn(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]},Pn=function(t,e,r,n,o){var i={},a=function(t){i=Tn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return jn(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]},qn=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=An(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=An(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 Cn=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(rt(e,r,"onResult"),o),t.$only(rt(e,r,"onError"),i),t.$trigger(e,{resolverName:r,args:n})}))}};function $n(t,e,r,n){var o=function(t,e,r,n){var o=[xn,Pn,qn];return Reflect.apply(kn,null,o)({},t,e,r,n)}(t,e,r,n);!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!")}))}(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(rt(t,n,"onResult"),r)})).catch((function(r){e.$trigger(rt(t,n,"onError"),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}function zn(t){return!!function(t){return P(t)&&(et(t,"query")||et(t,"mutation")||et(t,"socket"))}(t)&&t}function Nn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Rn(t){this.message=t}Rn.prototype=new Error,Rn.prototype.name="InvalidCharacterError";var Mn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Rn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var Fn=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(Mn(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 Mn(e)}};function Jn(t){this.message=t}Jn.prototype=new Error,Jn.prototype.name="InvalidTokenError";var In=function(t,e){if("string"!=typeof t)throw new Jn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Fn(t.split(".")[r]))}catch(t){throw new Jn("Invalid token specified: "+t.message)}};In.InvalidTokenError=Jn;var Un,Dn,Hn,Ln,Bn,Kn,Gn,Vn,Wn;function Yn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new dt("Token has expired on "+r,t)}return t}function Qn(t){if(St(t))return Yn(In(t));throw new dt("Token must be a string!")}On("HS256",["string"]),On(!1,["boolean","number","string"],((Un={}).alias="exp",Un.optional=!0,Un)),On(!1,["boolean","number","string"],((Dn={}).alias="nbf",Dn.optional=!0,Dn)),On(!1,["boolean","string"],((Hn={}).alias="iss",Hn.optional=!0,Hn)),On(!1,["boolean","string"],((Ln={}).alias="sub",Ln.optional=!0,Ln)),On(!1,["boolean","string"],((Bn={}).alias="iss",Bn.optional=!0,Bn)),On(!1,["boolean"],((Kn={}).optional=!0,Kn)),On(!1,["boolean","string"],((Gn={}).optional=!0,Gn)),On(!1,["boolean","string"],((Vn={}).optional=!0,Vn)),On(!1,["boolean"],((Wn={}).optional=!0,Wn));var Xn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},Zn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=jo().key(e);t(Oo(r),r)}},remove:function(t){return jo().removeItem(t)},clearAll:function(){return jo().clear()}};function jo(){return _o.localStorage}function Oo(t){return jo().getItem(t)}var So=no.trim,ko={name:"cookieStorage",read:function(t){if(!t||!xo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Eo.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Eo.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:To,remove:Ao,clearAll:function(){To((function(t,e){Ao(e)}))}},Eo=no.Global.document;function To(t){for(var e=Eo.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(So(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ao(t){t&&xo(t)&&(Eo.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function xo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Eo.cookie)}var Po=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 qo=no.bind,Co=no.each,$o=no.create,zo=no.slice,No=function(){var t=$o(Ro,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,qo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,qo(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(),Co(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Ro={_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,qo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=zo(arguments,1);Co(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Mo=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)})),Fo=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Mo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Mo.compress(this._serialize(r));t(e,n)}}};var Jo=[wo,ko],Io=[Po,No,Fo],Uo=yo.createStore(Jo,Io),Do=no.Global;function Ho(){return Do.sessionStorage}function Lo(t){return Ho().getItem(t)}var Bo=[{name:"sessionStorage",read:Lo,write:function(t,e){return Ho().setItem(t,e)},each:function(t){for(var e=Ho().length-1;e>=0;e--){var r=Ho().key(e);t(Lo(r),r)}},remove:function(t){return Ho().removeItem(t)},clearAll:function(){return Ho().clear()}},ko],Ko=[Po,Fo],Go=yo.createStore(Bo,Ko),Vo=Uo,Wo=Go;function Yo(t,e){var r;return(r={})[t]=e,r.TS=[Xn()],r}var Qo=function(t){return et(t,"data")&&!et(t,"error")?t.data:t},Xo=function(t){this.opts=t,this.instanceKey=Nn(this.opts.hostname),this.localStore=Vo,this.sessionStore=Wo},Zo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Xo.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?un({},o,e):e,r))},Xo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Xo.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)}},Xo.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)}},Zo.lset.set=function(t){return this.__setMethod("localStore",t)},Zo.lget.get=function(){return this.__getMethod("localStore")},Xo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Xo.prototype.lclear=function(){return this.__clearMethod("localStore")},Zo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Zo.sget.get=function(){return this.__getMethod("sessionStore")},Xo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Xo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Xo.prototype,Zo);var ti=u[0],ei=u[1],ri=function(t){function e(e,r){t.call(this,r),console.log("fly",e),this.fly=e,this.reqInterceptor(),this.resInterceptor()}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=Qn),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(wn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new ht("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&&wn(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(!zn(t))throw new ht("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=zn(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={}}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=un({},{_cb:Xn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=un({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=un({},{method:ti,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 Qo(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=_n(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Qo(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new vt("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?un({},a,this.getAuthHeader(),this.extraHeader):un({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=un({},this.extraParams,c)),this.request({},{method:"GET"},this.contractHeader).then(bt).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 vt("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),jt(t)&&s(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Yo(t,n)}throw new ht("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(bt)},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.payload=e,o.condition=r,!0===n)return o;if(jt(t))return Yo(t,o);throw new ht("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ei}).then(bt)},Object.defineProperties(e.prototype,r),e}(Xo)))),ni={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},oi={hostname:On(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:On("jsonql",["string"]),loginHandlerName:On("login",["string"]),logoutHandlerName:On("logout",["string"]),enableJsonp:On(!1,["boolean"]),enableAuth:On(!1,["boolean"]),useJwt:On(!0,["boolean"]),persistToken:On(!1,["boolean","number"]),useLocalstorage:On(!0,["boolean"]),storageKey:On("jsonqlstore",["string"]),authKey:On("jsonqlauthkey",["string"]),contractExpired:On(0,["number"]),keepContract:On(!0,["boolean"]),exposeContract:On(!1,["boolean"]),exposeStore:On(!1,["boolean"]),showContractDesc:On(!1,["boolean"]),contractKey:On(!1,["boolean"]),contractKeyName:On("X-JSONQL-CV-KEY",["string"]),enableTimeout:On(!1,["boolean"]),timeout:On(5e3,["number"]),returnInstance:On(!1,["boolean"]),allowReturnRawToken:On(!1,["boolean"]),debugOn:On(!1,["boolean"])};var ii=new WeakMap,ai=new WeakMap,ui=function(){this.__suspend__=null,this.queueStore=new Set},ci={$suspend:{configurable:!0},$queues:{configurable:!0}};ci.$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)},ui.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__},ci.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ui.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(ui.prototype,ci);var si=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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){ii.set(this,t)},r.normalStore.get=function(){return ii.get(this)},r.lazyStore.set=function(t){ai.set(this,t)},r.lazyStore.get=function(){return ai.get(this)},e.prototype.hashFnToKey=function(t){return Nn(t.toString())},Object.defineProperties(e.prototype,r),e}(ui)));function fi(t,e){var r,n=e.contract,o=function(t){return En(t,"__checked__")?Object.assign(t,ni):Sn(t,oi,ni)}(e),i=new ri(t,o),a=function(t,e){return void 0===e&&(e={}),zn(e)?Promise.resolve(e):t.getContract()}(i,n),u=(r=o.debugOn,new si({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=function(t,e,r,n){return n.$suspend=!0,r.then((function(r){$n(t,n,e,r)})),{query:Cn(n,"query"),mutation:Cn(n,"mutation"),auth:Cn(n,"auth")}}(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),fi(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("?")?"?":"&")+_.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==g&&(a.responseType=g)}catch(t){}var w=r.headers["Content-Type"]||r.headers[u],j="application/x-www-form-urlencoded";for(var O in o.trim((w||"").toLowerCase())===j?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(j="application/json;charset=utf-8",e=JSON.stringify(e)),w||y||(r.headers["Content-Type"]=j),r.headers)if("Content-Type"===O&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function S(t,e,n){d(f.p,(function(){if(t){n&&(e.request=r);var o=t.call(f,e,Promise);e=void 0===o?e:o}h(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){c(t)})).catch((function(t){p(t)}))}))}function k(t){t.engine=a,S(f.onerror,t,-1)}function E(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader("Content-Type")||"").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,u=a.statusText,c={data:t,headers:e,status:i,statusText:u};if(o.merge(c,a._response),i>=200&&i<300||304===i)c.engine=a,c.request=r,S(f.handler,c,0);else{var s=new E(u,i);s.response=c,k(s)}}catch(s){k(new E(s.msg,a.status))}},a.onerror=function(t){k(new E(t.msg||"Network Error",0))},a.ontimeout=function(){k(new E("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(y?null:e)}),0)}(n):c(n)}),(function(t){p(t)}))}))}));return p.engine=a,p}},{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=["POST","PUT"],c={desc:"y"},s=Array.isArray,f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},l="object"==typeof f&&f&&f.Object===Object&&f,p="object"==typeof self&&self&&self.Object===Object&&self,h=l||p||Function("return this")(),d=h.Symbol,v=Object.prototype,g=v.hasOwnProperty,y=v.toString,b=d?d.toStringTag:void 0;var m=Object.prototype.toString;var _=d?d.toStringTag:void 0;function w(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":_&&_ in Object(t)?function(t){var e=g.call(t,b),r=t[b];try{t[b]=void 0;var n=!0}catch(t){}var o=y.call(t);return n&&(e?t[b]=r:delete t[b]),o}(t):function(t){return m.call(t)}(t)}function j(t,e){return function(r){return t(e(r))}}var O=j(Object.getPrototypeOf,Object);function S(t){return null!=t&&"object"==typeof t}var k=Function.prototype,E=Object.prototype,T=k.toString,A=E.hasOwnProperty,x=T.call(Object);function P(t){if(!S(t)||"[object Object]"!=w(t))return!1;var e=O(t);if(null===e)return!0;var r=A.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&T.call(r)==x}function q(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--&&F(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var tt=function(t){return s(t)?t:[t]},et=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},rt=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},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={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),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"Jsonql500Error"},Object.defineProperties(e,r),e}(Error),it=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),ut=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),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={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),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 404},r.name.get=function(){return"JsonqlResolverNotFoundError"},Object.defineProperties(e,r),e}(Error),ft=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),lt=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),ht=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),dt=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),vt=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),gt=Object.freeze({__proto__:null,Jsonql406Error:nt,Jsonql500Error:ot,JsonqlForbiddenError:it,JsonqlAuthorisationError:at,JsonqlContractAuthError:ut,JsonqlResolverAppError:ct,JsonqlResolverNotFoundError:st,JsonqlEnumError:ft,JsonqlTypeError:lt,JsonqlCheckerError:pt,JsonqlValidationError:ht,JsonqlError:dt,JsonqlServerError:vt}),yt=dt;function bt(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&>[o])throw new gt[r](i,a);throw new yt(i,a)}return t}function mt(t){if(Array.isArray(t))throw new ht("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof st:throw new st(e,r);case t instanceof ft:throw new ft(e,r);case t instanceof lt:throw new lt(e,r);case t instanceof pt:throw new pt(e,r);case t instanceof ht:throw new ht(e,r);case t instanceof vt:throw new vt(e,r);default:throw new dt(e,r)}}var _t=function(t){return!!s(t)||null!=t&&""!==Z(t)};function wt(t){return function(t){return"number"==typeof t||S(t)&&"[object Number]"==w(t)}(t)&&t!=+t}function jt(t){return"string"==typeof t||!s(t)&&S(t)&&"[object String]"==w(t)}var Ot=function(t){return!jt(t)&&!wt(parseFloat(t))},St=function(t){return""!==Z(t)&&jt(t)},kt=function(t){return null!=t&&"boolean"==typeof t},Et=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==Z(t)&&(!1===e||!0===e&&null!==t)},Tt=function(t){switch(t){case"number":return Ot;case"string":return St;case"boolean":return kt;default:return Et}},At=function(t,e){return void 0===e&&(e=""),!!s(t)&&(""===e||""===Z(e)||!(t.filter((function(t){return!Tt(e)(t)})).length>0))},xt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Pt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Tt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!At(r,t)})).length};var qt,Ct=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[qt?a:++n];if(!1===e(o[u],u,o))break}return t};function $t(t){return S(t)&&"[object Arguments]"==w(t)}var zt=Object.prototype,Nt=zt.hasOwnProperty,Rt=zt.propertyIsEnumerable,Mt=$t(function(){return arguments}())?$t:function(t){return S(t)&&Nt.call(t,"callee")&&!Rt.call(t,"callee")};var Ft="object"==typeof exports&&exports&&!exports.nodeType&&exports,Jt=Ft&&"object"==typeof module&&module&&!module.nodeType&&module,It=Jt&&Jt.exports===Ft?h.Buffer:void 0,Ut=(It?It.isBuffer:void 0)||function(){return!1},Dt=/^(?:0|[1-9]\d*)$/;function Lt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Dt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Bt={};Bt["[object Float32Array]"]=Bt["[object Float64Array]"]=Bt["[object Int8Array]"]=Bt["[object Int16Array]"]=Bt["[object Int32Array]"]=Bt["[object Uint8Array]"]=Bt["[object Uint8ClampedArray]"]=Bt["[object Uint16Array]"]=Bt["[object Uint32Array]"]=!0,Bt["[object Arguments]"]=Bt["[object Array]"]=Bt["[object ArrayBuffer]"]=Bt["[object Boolean]"]=Bt["[object DataView]"]=Bt["[object Date]"]=Bt["[object Error]"]=Bt["[object Function]"]=Bt["[object Map]"]=Bt["[object Number]"]=Bt["[object Object]"]=Bt["[object RegExp]"]=Bt["[object Set]"]=Bt["[object String]"]=Bt["[object WeakMap]"]=!1;var Kt,Gt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Vt=Gt&&"object"==typeof module&&module&&!module.nodeType&&module,Wt=Vt&&Vt.exports===Gt&&l.process,Yt=function(){try{var t=Vt&&Vt.require&&Vt.require("util").types;return t||Wt&&Wt.binding&&Wt.binding("util")}catch(t){}}(),Qt=Yt&&Yt.isTypedArray,Xt=Qt?(Kt=Qt,function(t){return Kt(t)}):function(t){return S(t)&&Ht(t.length)&&!!Bt[w(t)]},Zt=Object.prototype.hasOwnProperty;function te(t,e){var r=s(t),n=!r&&Mt(t),o=!r&&!n&&Ut(t),i=!r&&!n&&!o&&Xt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},he.prototype.set=function(t,e){var r=this.__data__,n=le(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var de,ve=h["__core-js_shared__"],ge=(de=/[^.]+$/.exec(ve&&ve.keys&&ve.keys.IE_PROTO||""))?"Symbol(src)_1."+de:"";var ye=Function.prototype.toString;function be(t){if(null!=t){try{return ye.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var me=/^\[object .+?Constructor\]$/,_e=Function.prototype,we=Object.prototype,je=_e.toString,Oe=we.hasOwnProperty,Se=RegExp("^"+je.call(Oe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ke(t){return!(!ie(t)||function(t){return!!ge&&ge in t}(t))&&(ae(t)?Se:me).test(be(t))}function Ee(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return ke(r)?r:void 0}var Te=Ee(h,"Map"),Ae=Ee(Object,"create");var xe=Object.prototype.hasOwnProperty;var Pe=Object.prototype.hasOwnProperty;function qe(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=2&r?new Ne:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=xt(t))?!Pt({arg:r},e):!Tt(t)(r))})).length)})).length}return!1},qr=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(Pr,null,a);case"array"===t:return!At(e.arg);case!1!==(r=xt(t)):return!Pt(e,r);default:return!Tt(t)(e.arg)}},Cr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},$r=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!At(e))throw new dt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!At(t))throw new dt("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?Cr(t,a):t,index:r,param:a,optional:i}}));default:throw new dt("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!!_t(e)&&!(r.type.length>r.type.filter((function(e){return qr(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return qr(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},zr=function(){try{var t=Ee(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Nr(t,e,r){"__proto__"==e&&zr?zr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Rr(t,e,r){(void 0===r||fe(t[e],r))&&(void 0!==r||e in t)||Nr(t,e,r)}var Mr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Fr=Mr&&"object"==typeof module&&module&&!module.nodeType&&module,Jr=Fr&&Fr.exports===Mr?h.Buffer:void 0,Ir=Jr?Jr.allocUnsafe:void 0;function Ur(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Fe(n).set(new Fe(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Dr=Object.create,Lr=function(){function t(){}return function(e){if(!ie(e))return{};if(Dr)return Dr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Hr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Br=Object.prototype.hasOwnProperty;function Kr(t,e,r){var n=t[e];Br.call(t,e)&&fe(n,r)&&(void 0!==r||e in t)||Nr(t,e,r)}var Gr=Object.prototype.hasOwnProperty;function Vr(t){if(!ie(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&&Gr.call(t,n))&&r.push(n);return r}function Wr(t){return ue(t)?te(t,!0):Vr(t)}function Yr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(en);function on(t,e){return nn(function(t,e,r){return e=tn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=tn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=an.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ie(r))return!1;var n=typeof e;return!!("number"==n?ue(r)&&Lt(e,r.length):"string"==n&&e in r)&&fe(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,tt(t))}),Reflect.apply(t,null,r))}};function En(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Tn(t,e,r,n){void 0===n&&(n=!1);var o=En(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var An=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 jn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(mt)}},xn=function(t,e,r,n,o){var i={},a=function(t){i=Tn(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 jn(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]},Pn=function(t,e,r,n,o){var i={},a=function(t){i=Tn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return jn(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]},qn=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=An(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=An(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 Cn=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(rt(e,r,"onResult"),o),t.$only(rt(e,r,"onError"),i),t.$trigger(e,{resolverName:r,args:n})}))}};function $n(t,e,r,n){var o=function(t,e,r,n){var o=[xn,Pn,qn];return Reflect.apply(kn,null,o)({},t,e,r,n)}(t,e,r,n);!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!")}))}(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(rt(t,n,"onResult"),r)})).catch((function(r){e.$trigger(rt(t,n,"onError"),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}function zn(t){return!!function(t){return P(t)&&(et(t,"query")||et(t,"mutation")||et(t,"socket"))}(t)&&t}function Nn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Rn(t){this.message=t}Rn.prototype=new Error,Rn.prototype.name="InvalidCharacterError";var Mn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Rn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var Fn=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(Mn(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 Mn(e)}};function Jn(t){this.message=t}Jn.prototype=new Error,Jn.prototype.name="InvalidTokenError";var In=function(t,e){if("string"!=typeof t)throw new Jn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Fn(t.split(".")[r]))}catch(t){throw new Jn("Invalid token specified: "+t.message)}};In.InvalidTokenError=Jn;var Un,Dn,Ln,Hn,Bn,Kn,Gn,Vn,Wn;function Yn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new dt("Token has expired on "+r,t)}return t}function Qn(t){if(St(t))return Yn(In(t));throw new dt("Token must be a string!")}On("HS256",["string"]),On(!1,["boolean","number","string"],((Un={}).alias="exp",Un.optional=!0,Un)),On(!1,["boolean","number","string"],((Dn={}).alias="nbf",Dn.optional=!0,Dn)),On(!1,["boolean","string"],((Ln={}).alias="iss",Ln.optional=!0,Ln)),On(!1,["boolean","string"],((Hn={}).alias="sub",Hn.optional=!0,Hn)),On(!1,["boolean","string"],((Bn={}).alias="iss",Bn.optional=!0,Bn)),On(!1,["boolean"],((Kn={}).optional=!0,Kn)),On(!1,["boolean","string"],((Gn={}).optional=!0,Gn)),On(!1,["boolean","string"],((Vn={}).optional=!0,Vn)),On(!1,["boolean"],((Wn={}).optional=!0,Wn));var Xn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Zn(t,e){var r;return(r={})[t]=e,r.TS=[Xn()],r}var to=function(t){return et(t,"data")&&!et(t,"error")?t.data:t},eo=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=So().key(e);t(ko(r),r)}},remove:function(t){return So().removeItem(t)},clearAll:function(){return So().clear()}};function So(){return jo.localStorage}function ko(t){return So().getItem(t)}var Eo=io.trim,To={name:"cookieStorage",read:function(t){if(!t||!qo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Ao.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Ao.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:xo,remove:Po,clearAll:function(){xo((function(t,e){Po(e)}))}},Ao=io.Global.document;function xo(t){for(var e=Ao.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(Eo(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Po(t){t&&qo(t)&&(Ao.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function qo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Ao.cookie)}var Co=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 $o=io.bind,zo=io.each,No=io.create,Ro=io.slice,Mo=function(){var t=No(Fo,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,$o(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,$o(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(),zo(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Fo={_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,$o(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=Ro(arguments,1);zo(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Jo=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)})),Io=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Jo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Jo.compress(this._serialize(r));t(e,n)}}};var Uo=[Oo,To],Do=[Co,Mo,Io],Lo=mo.createStore(Uo,Do),Ho=io.Global;function Bo(){return Ho.sessionStorage}function Ko(t){return Bo().getItem(t)}var Go=[{name:"sessionStorage",read:Ko,write:function(t,e){return Bo().setItem(t,e)},each:function(t){for(var e=Bo().length-1;e>=0;e--){var r=Bo().key(e);t(Ko(r),r)}},remove:function(t){return Bo().removeItem(t)},clearAll:function(){return Bo().clear()}},To],Vo=[Co,Io],Wo=mo.createStore(Go,Vo),Yo=Lo,Qo=Wo,Xo=function(t){this.opts=t,this.instanceKey=Nn(this.opts.hostname),this.localStore=Yo,this.sessionStore=Qo},Zo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Xo.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?un({},o,e):e,r))},Xo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Xo.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)}},Xo.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)}},Zo.lset.set=function(t){return this.__setMethod("localStore",t)},Zo.lget.get=function(){return this.__getMethod("localStore")},Xo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Xo.prototype.lclear=function(){return this.__clearMethod("localStore")},Zo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Zo.sget.get=function(){return this.__getMethod("sessionStore")},Xo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Xo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Xo.prototype,Zo);var ti=u[0],ei=u[1],ri=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}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=Qn),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(wn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new ht("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&&wn(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(!zn(t))throw new ht("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=zn(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={}}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=un({},{_cb:Xn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=un({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=un({},{method:ti,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.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 to(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=_n(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):to(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new vt("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?un({},a,this.getAuthHeader(),this.extraHeader):un({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=un({},this.extraParams,c)),this.request({},{method:"GET"},this.contractHeader).then(bt).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 vt("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),jt(t)&&s(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Zn(t,n)}throw new ht("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(bt)},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.payload=e,o.condition=r,!0===n)return o;if(jt(t))return Zn(t,o);throw new ht("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:ei}).then(bt)},Object.defineProperties(e.prototype,r),e}(Xo)))),ni={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},oi={hostname:On(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:On("jsonql",["string"]),loginHandlerName:On("login",["string"]),logoutHandlerName:On("logout",["string"]),enableJsonp:On(!1,["boolean"]),enableAuth:On(!1,["boolean"]),useJwt:On(!0,["boolean"]),persistToken:On(!1,["boolean","number"]),useLocalstorage:On(!0,["boolean"]),storageKey:On("jsonqlstore",["string"]),authKey:On("jsonqlauthkey",["string"]),contractExpired:On(0,["number"]),keepContract:On(!0,["boolean"]),exposeContract:On(!1,["boolean"]),exposeStore:On(!1,["boolean"]),showContractDesc:On(!1,["boolean"]),contractKey:On(!1,["boolean"]),contractKeyName:On("X-JSONQL-CV-KEY",["string"]),enableTimeout:On(!1,["boolean"]),timeout:On(5e3,["number"]),returnInstance:On(!1,["boolean"]),allowReturnRawToken:On(!1,["boolean"]),debugOn:On(!1,["boolean"])};var ii=new WeakMap,ai=new WeakMap,ui=function(){this.__suspend__=null,this.queueStore=new Set},ci={$suspend:{configurable:!0},$queues:{configurable:!0}};ci.$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)},ui.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__},ci.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ui.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(ui.prototype,ci);var si=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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){ii.set(this,t)},r.normalStore.get=function(){return ii.get(this)},r.lazyStore.set=function(t){ai.set(this,t)},r.lazyStore.get=function(){return ai.get(this)},e.prototype.hashFnToKey=function(t){return Nn(t.toString())},Object.defineProperties(e.prototype,r),e}(ui)));function fi(t,e){var r,n=e.contract,o=function(t){return En(t,"__checked__")?Object.assign(t,ni):Sn(t,oi,ni)}(e),i=new ri(t,o),a=function(t,e){return void 0===e&&(e={}),zn(e)?Promise.resolve(e):t.getContract()}(i,n),u=(r=o.debugOn,new si({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),c=function(t,e,r,n){return n.$suspend=!0,r.then((function(r){$n(t,n,e,r)})),{query:Cn(n,"query"),mutation:Cn(n,"mutation"),auth:Cn(n,"auth")}}(i,o,a,u);return c.eventEmitter=u,c}return function(t){return void 0===t&&(t={}),fi(new o,t)}})); //# sourceMappingURL=jsonql-client.static-full.js.map diff --git a/packages/http-client/dist/jsonql-client.static-full.js.map b/packages/http-client/dist/jsonql-client.static-full.js.map index 823b4a896e9442506852b3c63dc3049726c18707..3c08a4e16d61d10272adb7f868c817f0ec4a989c 100644 --- a/packages/http-client/dist/jsonql-client.static-full.js.map +++ b/packages/http-client/dist/jsonql-client.static-full.js.map @@ -1 +1 @@ -{"version":3,"file":"jsonql-client.static-full.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"mgiDAAA"} \ No newline at end of file +{"version":3,"file":"jsonql-client.static-full.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"2niDAAA"} \ No newline at end of file diff --git a/packages/http-client/dist/jsonql-client.static.js b/packages/http-client/dist/jsonql-client.static.js index a48d2a7736c1878235816200d5df3fe4e4632414..ee54261e0ac8f03c55586a7846cd48e5abd935cc 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?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).jsonqlClientStatic={})}(this,(function(t){"use strict";var e="application/vnd.api+json",r={Accept:e,"Content-Type":[e,"charset=utf-8"].join(";")},n=["POST","PUT"],o={desc:"y"},i=Array.isArray,a="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},u="object"==typeof a&&a&&a.Object===Object&&a,c="object"==typeof self&&self&&self.Object===Object&&self,s=u||c||Function("return this")(),l=s.Symbol,f=Object.prototype,p=f.hasOwnProperty,h=f.toString,d=l?l.toStringTag:void 0;var v=Object.prototype.toString;var g=l?l.toStringTag:void 0;function y(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":g&&g in Object(t)?function(t){var e=p.call(t,d),r=t[d];try{t[d]=void 0;var n=!0}catch(t){}var o=h.call(t);return n&&(e?t[d]=r:delete t[d]),o}(t):function(t){return v.call(t)}(t)}function b(t,e){return function(r){return t(e(r))}}var _=b(Object.getPrototypeOf,Object);function m(t){return null!=t&&"object"==typeof t}var w=Function.prototype,j=Object.prototype,S=w.toString,O=j.hasOwnProperty,k=S.call(Object);function E(t){if(!m(t)||"[object Object]"!=y(t))return!1;var e=_(t);if(null===e)return!0;var r=O.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&S.call(r)==k}function A(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--&&z(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Y=function(t){return i(t)?t:[t]},Q=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},X=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},Z=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),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 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),rt=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),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={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),it=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),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"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),ut=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),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"JsonqlCheckerError"},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"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),lt=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),ft=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),pt=Object.freeze({__proto__:null,Jsonql406Error:Z,Jsonql500Error:tt,JsonqlForbiddenError:et,JsonqlAuthorisationError:rt,JsonqlContractAuthError:nt,JsonqlResolverAppError:ot,JsonqlResolverNotFoundError:it,JsonqlEnumError:at,JsonqlTypeError:ut,JsonqlCheckerError:ct,JsonqlValidationError:st,JsonqlError:lt,JsonqlServerError:ft}),ht=lt;function dt(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&pt[o])throw new pt[r](i,a);throw new ht(i,a)}return t}function vt(t){if(Array.isArray(t))throw new st("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof et:throw new et(e,r);case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof st:throw new st(e,r);case t instanceof ft:throw new ft(e,r);default:throw new lt(e,r)}}var gt=function(t){return!!i(t)||null!=t&&""!==W(t)};function yt(t){return function(t){return"number"==typeof t||m(t)&&"[object Number]"==y(t)}(t)&&t!=+t}function bt(t){return"string"==typeof t||!i(t)&&m(t)&&"[object String]"==y(t)}var _t=function(t){return!bt(t)&&!yt(parseFloat(t))},mt=function(t){return""!==W(t)&&bt(t)},wt=function(t){return null!=t&&"boolean"==typeof t},jt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==W(t)&&(!1===e||!0===e&&null!==t)},St=function(t){switch(t){case"number":return _t;case"string":return mt;case"boolean":return wt;default:return jt}},Ot=function(t,e){return void 0===e&&(e=""),!!i(t)&&(""===e||""===W(e)||!(t.filter((function(t){return!St(e)(t)})).length>0))},kt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Et=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!St(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Ot(r,t)})).length};var At,Tt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[At?a:++n];if(!1===e(o[u],u,o))break}return t};function Pt(t){return m(t)&&"[object Arguments]"==y(t)}var qt=Object.prototype,xt=qt.hasOwnProperty,Ct=qt.propertyIsEnumerable,$t=Pt(function(){return arguments}())?Pt:function(t){return m(t)&&xt.call(t,"callee")&&!Ct.call(t,"callee")};var zt="object"==typeof t&&t&&!t.nodeType&&t,Nt=zt&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Nt&&Nt.exports===zt?s.Buffer:void 0,Rt=(Mt?Mt.isBuffer:void 0)||function(){return!1},Ft=/^(?:0|[1-9]\d*)$/;function It(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Ft.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Ut={};Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=!0,Ut["[object Arguments]"]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object Boolean]"]=Ut["[object DataView]"]=Ut["[object Date]"]=Ut["[object Error]"]=Ut["[object Function]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut["[object Object]"]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object WeakMap]"]=!1;var Ht,Lt="object"==typeof t&&t&&!t.nodeType&&t,Dt=Lt&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Dt&&Dt.exports===Lt&&u.process,Bt=function(){try{var t=Dt&&Dt.require&&Dt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Vt=Bt&&Bt.isTypedArray,Gt=Vt?(Ht=Vt,function(t){return Ht(t)}):function(t){return m(t)&&Jt(t.length)&&!!Ut[y(t)]},Wt=Object.prototype.hasOwnProperty;function Yt(t,e){var r=i(t),n=!r&&$t(t),o=!r&&!n&&Rt(t),a=!r&&!n&&!o&&Gt(t),u=r||n||o||a,c=u?function(t,e){for(var r=-1,n=Array(t);++r-1},se.prototype.set=function(t,e){var r=this.__data__,n=ue(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var le,fe=s["__core-js_shared__"],pe=(le=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||""))?"Symbol(src)_1."+le:"";var he=Function.prototype.toString;function de(t){if(null!=t){try{return he.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ve=/^\[object .+?Constructor\]$/,ge=Function.prototype,ye=Object.prototype,be=ge.toString,_e=ye.hasOwnProperty,me=RegExp("^"+be.call(_e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function we(t){return!(!ee(t)||function(t){return!!pe&&pe in t}(t))&&(re(t)?me:ve).test(de(t))}function je(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return we(r)?r:void 0}var Se=je(s,"Map"),Oe=je(Object,"create");var ke=Object.prototype.hasOwnProperty;var Ee=Object.prototype.hasOwnProperty;function Ae(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 l=-1,f=!0,p=2&r?new xe:void 0;for(i.set(t,e),i.set(e,t);++le.type.filter((function(t){var e;return void 0===r||(!1!==(e=kt(t))?!Et({arg:r},e):!St(t)(r))})).length)})).length}return!1},Ar=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(Er,null,a);case"array"===t:return!Ot(e.arg);case!1!==(r=kt(t)):return!Et(e,r);default:return!St(t)(e.arg)}},Tr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Pr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Ot(e))throw new lt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Ot(t))throw new lt("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?Tr(t,a):t,index:r,param:a,optional:i}}));default:throw new lt("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!!gt(e)&&!(r.type.length>r.type.filter((function(e){return Ar(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Ar(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},qr=function(){try{var t=je(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function xr(t,e,r){"__proto__"==e&&qr?qr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Cr(t,e,r){(void 0===r||ae(t[e],r))&&(void 0!==r||e in t)||xr(t,e,r)}var $r="object"==typeof t&&t&&!t.nodeType&&t,zr=$r&&"object"==typeof module&&module&&!module.nodeType&&module,Nr=zr&&zr.exports===$r?s.Buffer:void 0,Mr=Nr?Nr.allocUnsafe:void 0;function Rr(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new ze(n).set(new ze(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Fr=Object.create,Ir=function(){function t(){}return function(e){if(!ee(e))return{};if(Fr)return Fr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Jr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ur=Object.prototype.hasOwnProperty;function Hr(t,e,r){var n=t[e];Ur.call(t,e)&&ae(n,r)&&(void 0!==r||e in t)||xr(t,e,r)}var Lr=Object.prototype.hasOwnProperty;function Dr(t){if(!ee(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Xt(t),r=[];for(var n in t)("constructor"!=n||!e&&Lr.call(t,n))&&r.push(n);return r}function Kr(t){return ne(t)?Yt(t,!0):Dr(t)}function Br(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Qr);function tn(t,e){return Zr(function(t,e,r){return e=Yr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Yr(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=en.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ee(r))return!1;var n=typeof e;return!!("number"==n?ne(r)&&It(e,r.length):"string"==n&&e in r)&&ae(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,Y(t))}),Reflect.apply(t,null,r))}};function jn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Sn(t,e,r,n){void 0===n&&(n=!1);var o=jn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var On=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 bn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(vt)}},kn=function(t,e,r,n,o){var i={},a=function(t){i=Sn(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 bn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(vt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},En=function(t,e,r,n,o){var i={},a=function(t){i=Sn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return bn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(vt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},An=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=On(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=On(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 Tn=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(X(e,r,"onResult"),o),t.$only(X(e,r,"onError"),i),t.$trigger(e,{resolverName:r,args:n})}))}};function Pn(t,e,r,n){var o=function(t,e,r,n){var o=[kn,En,An];return Reflect.apply(wn,null,o)({},t,e,r,n)}(t,e,r,n);!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!")}))}(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(X(t,n,"onResult"),r)})).catch((function(r){e.$trigger(X(t,n,"onError"),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}function qn(t){return!!function(t){return E(t)&&(Q(t,"query")||Q(t,"mutation")||Q(t,"socket"))}(t)&&t}function xn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Cn(t){this.message=t}Cn.prototype=new Error,Cn.prototype.name="InvalidCharacterError";var $n="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Cn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var zn=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($n(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 $n(e)}};function Nn(t){this.message=t}Nn.prototype=new Error,Nn.prototype.name="InvalidTokenError";var Mn=function(t,e){if("string"!=typeof t)throw new Nn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(zn(t.split(".")[r]))}catch(t){throw new Nn("Invalid token specified: "+t.message)}};Mn.InvalidTokenError=Nn;var Rn,Fn,In,Jn,Un,Hn,Ln,Dn,Kn;function Bn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new lt("Token has expired on "+r,t)}return t}function Vn(t){if(mt(t))return Bn(Mn(t));throw new lt("Token must be a string!")}_n("HS256",["string"]),_n(!1,["boolean","number","string"],((Rn={}).alias="exp",Rn.optional=!0,Rn)),_n(!1,["boolean","number","string"],((Fn={}).alias="nbf",Fn.optional=!0,Fn)),_n(!1,["boolean","string"],((In={}).alias="iss",In.optional=!0,In)),_n(!1,["boolean","string"],((Jn={}).alias="sub",Jn.optional=!0,Jn)),_n(!1,["boolean","string"],((Un={}).alias="iss",Un.optional=!0,Un)),_n(!1,["boolean"],((Hn={}).optional=!0,Hn)),_n(!1,["boolean","string"],((Ln={}).optional=!0,Ln)),_n(!1,["boolean","string"],((Dn={}).optional=!0,Dn)),_n(!1,["boolean"],((Kn={}).optional=!0,Kn));var Gn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e},Wn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Yn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=_o().key(e);t(mo(r),r)}},remove:function(t){return _o().removeItem(t)},clearAll:function(){return _o().clear()}};function _o(){return yo.localStorage}function mo(t){return _o().getItem(t)}var wo=to.trim,jo={name:"cookieStorage",read:function(t){if(!t||!Eo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(So.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;So.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Oo,remove:ko,clearAll:function(){Oo((function(t,e){ko(e)}))}},So=to.Global.document;function Oo(t){for(var e=So.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(wo(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function ko(t){t&&Eo(t)&&(So.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function Eo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(So.cookie)}var Ao=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 To=to.bind,Po=to.each,qo=to.create,xo=to.slice,Co=function(){var t=qo($o,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,To(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,To(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(),Po(r,(function(e,r){t.fire(r,void 0,e)}))}}};var $o={_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,To(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=xo(arguments,1);Po(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},zo=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==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++),a[s]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(u,l)){if(l.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=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,l,f=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)f[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;l=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;l=t(a);break;case 2:return""}for(f[3]=l,i=l,g.push(l);;){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(l=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[h++]=t(a),l=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;f[h++]=t(a),l=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),f[l])v=f[l];else{if(l!==h)return null;v=i+i.charAt(0)}g.push(v),f[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),No=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=zo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=zo.compress(this._serialize(r));t(e,n)}}};var Mo=[bo,jo],Ro=[Ao,Co,No],Fo=ho.createStore(Mo,Ro),Io=to.Global;function Jo(){return Io.sessionStorage}function Uo(t){return Jo().getItem(t)}var Ho=[{name:"sessionStorage",read:Uo,write:function(t,e){return Jo().setItem(t,e)},each:function(t){for(var e=Jo().length-1;e>=0;e--){var r=Jo().key(e);t(Uo(r),r)}},remove:function(t){return Jo().removeItem(t)},clearAll:function(){return Jo().clear()}},jo],Lo=[Ao,No],Do=ho.createStore(Ho,Lo),Ko=Fo,Bo=Do;function Vo(t,e){var r;return(r={})[t]=e,r.TS=[Gn()],r}var Go=function(t){return Q(t,"data")&&!Q(t,"error")?t.data:t},Wo=function(t){this.opts=t,this.instanceKey=xn(this.opts.hostname),this.localStore=Ko,this.sessionStore=Bo},Yo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Wo.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?rn({},o,e):e,r))},Wo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Wo.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)}},Wo.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)}},Yo.lset.set=function(t){return this.__setMethod("localStore",t)},Yo.lget.get=function(){return this.__getMethod("localStore")},Wo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Wo.prototype.lclear=function(){return this.__clearMethod("localStore")},Yo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Yo.sget.get=function(){return this.__getMethod("sessionStore")},Wo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Wo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Wo.prototype,Yo);var Qo=n[0],Xo=n[1],Zo=function(t){function e(e,r){t.call(this,r),console.log("fly",e),this.fly=e,this.reqInterceptor(),this.resInterceptor()}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=Vn),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(yn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new st("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&&yn(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(!qn(t))throw new st("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=qn(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={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={headers:{configurable:!0}};return n.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=rn({},{_cb:Gn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=rn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=rn({},{method:Qo,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 Go(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=gn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Go(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new ft("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?rn({},r,this.getAuthHeader(),this.extraHeader):rn({},r,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=rn({},this.extraParams,o)),this.request({},{method:"GET"},this.contractHeader).then(dt).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 ft("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),bt(t)&&i(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Vo(t,n)}throw new st("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(dt)},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.payload=e,o.condition=r,!0===n)return o;if(bt(t))return Vo(t,o);throw new st("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Xo}).then(dt)},Object.defineProperties(e.prototype,n),e}(Wo)))),ti={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:e,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ei={hostname:_n(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:_n("jsonql",["string"]),loginHandlerName:_n("login",["string"]),logoutHandlerName:_n("logout",["string"]),enableJsonp:_n(!1,["boolean"]),enableAuth:_n(!1,["boolean"]),useJwt:_n(!0,["boolean"]),persistToken:_n(!1,["boolean","number"]),useLocalstorage:_n(!0,["boolean"]),storageKey:_n("jsonqlstore",["string"]),authKey:_n("jsonqlauthkey",["string"]),contractExpired:_n(0,["number"]),keepContract:_n(!0,["boolean"]),exposeContract:_n(!1,["boolean"]),exposeStore:_n(!1,["boolean"]),showContractDesc:_n(!1,["boolean"]),contractKey:_n(!1,["boolean"]),contractKeyName:_n("X-JSONQL-CV-KEY",["string"]),enableTimeout:_n(!1,["boolean"]),timeout:_n(5e3,["number"]),returnInstance:_n(!1,["boolean"]),allowReturnRawToken:_n(!1,["boolean"]),debugOn:_n(!1,["boolean"])};var ri=new WeakMap,ni=new WeakMap,oi=function(){this.__suspend__=null,this.queueStore=new Set},ii={$suspend:{configurable:!0},$queues:{configurable:!0}};ii.$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)},oi.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__},ii.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},oi.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(oi.prototype,ii);var ai=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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,l=0;l0;)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){ri.set(this,t)},r.normalStore.get=function(){return ri.get(this)},r.lazyStore.set=function(t){ni.set(this,t)},r.lazyStore.get=function(){return ni.get(this)},e.prototype.hashFnToKey=function(t){return xn(t.toString())},Object.defineProperties(e.prototype,r),e}(oi)));t.jsonqlStaticClient=function(t,e){var r,n=e.contract,o=function(t){return jn(t,"__checked__")?Object.assign(t,ti):mn(t,ei,ti)}(e),i=new Zo(t,o),a=function(t,e){return void 0===e&&(e={}),qn(e)?Promise.resolve(e):t.getContract()}(i,n),u=(r=o.debugOn,new ai({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=function(t,e,r,n){return n.$suspend=!0,r.then((function(r){Pn(t,n,e,r)})),{query:Tn(n,"query"),mutation:Tn(n,"mutation"),auth:Tn(n,"auth")}}(i,o,a,u);return c.eventEmitter=u,c},Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).jsonqlClientStatic={})}(this,(function(t){"use strict";var e="application/vnd.api+json",r={Accept:e,"Content-Type":[e,"charset=utf-8"].join(";")},n=["POST","PUT"],o={desc:"y"},i=Array.isArray,a="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},u="object"==typeof a&&a&&a.Object===Object&&a,c="object"==typeof self&&self&&self.Object===Object&&self,s=u||c||Function("return this")(),l=s.Symbol,f=Object.prototype,p=f.hasOwnProperty,h=f.toString,d=l?l.toStringTag:void 0;var v=Object.prototype.toString;var g=l?l.toStringTag:void 0;function y(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":g&&g in Object(t)?function(t){var e=p.call(t,d),r=t[d];try{t[d]=void 0;var n=!0}catch(t){}var o=h.call(t);return n&&(e?t[d]=r:delete t[d]),o}(t):function(t){return v.call(t)}(t)}function b(t,e){return function(r){return t(e(r))}}var _=b(Object.getPrototypeOf,Object);function m(t){return null!=t&&"object"==typeof t}var w=Function.prototype,j=Object.prototype,S=w.toString,O=j.hasOwnProperty,k=S.call(Object);function E(t){if(!m(t)||"[object Object]"!=y(t))return!1;var e=_(t);if(null===e)return!0;var r=O.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&S.call(r)==k}function A(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--&&z(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var Y=function(t){return i(t)?t:[t]},Q=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},X=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return t.join("_")},Z=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),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 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),rt=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),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={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),it=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),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"JsonqlEnumError"},Object.defineProperties(e,r),e}(Error),ut=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),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"JsonqlCheckerError"},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"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),lt=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),ft=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),pt=Object.freeze({__proto__:null,Jsonql406Error:Z,Jsonql500Error:tt,JsonqlForbiddenError:et,JsonqlAuthorisationError:rt,JsonqlContractAuthError:nt,JsonqlResolverAppError:ot,JsonqlResolverNotFoundError:it,JsonqlEnumError:at,JsonqlTypeError:ut,JsonqlCheckerError:ct,JsonqlValidationError:st,JsonqlError:lt,JsonqlServerError:ft}),ht=lt;function dt(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&pt[o])throw new pt[r](i,a);throw new ht(i,a)}return t}function vt(t){if(Array.isArray(t))throw new st("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof Z:throw new Z(e,r);case t instanceof tt:throw new tt(e,r);case t instanceof et:throw new et(e,r);case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof st:throw new st(e,r);case t instanceof ft:throw new ft(e,r);default:throw new lt(e,r)}}var gt=function(t){return!!i(t)||null!=t&&""!==W(t)};function yt(t){return function(t){return"number"==typeof t||m(t)&&"[object Number]"==y(t)}(t)&&t!=+t}function bt(t){return"string"==typeof t||!i(t)&&m(t)&&"[object String]"==y(t)}var _t=function(t){return!bt(t)&&!yt(parseFloat(t))},mt=function(t){return""!==W(t)&&bt(t)},wt=function(t){return null!=t&&"boolean"==typeof t},jt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==W(t)&&(!1===e||!0===e&&null!==t)},St=function(t){switch(t){case"number":return _t;case"string":return mt;case"boolean":return wt;default:return jt}},Ot=function(t,e){return void 0===e&&(e=""),!!i(t)&&(""===e||""===W(e)||!(t.filter((function(t){return!St(e)(t)})).length>0))},kt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Et=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!St(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Ot(r,t)})).length};var At,Tt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[At?a:++n];if(!1===e(o[u],u,o))break}return t};function Pt(t){return m(t)&&"[object Arguments]"==y(t)}var qt=Object.prototype,xt=qt.hasOwnProperty,Ct=qt.propertyIsEnumerable,$t=Pt(function(){return arguments}())?Pt:function(t){return m(t)&&xt.call(t,"callee")&&!Ct.call(t,"callee")};var zt="object"==typeof t&&t&&!t.nodeType&&t,Nt=zt&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Nt&&Nt.exports===zt?s.Buffer:void 0,Rt=(Mt?Mt.isBuffer:void 0)||function(){return!1},It=/^(?:0|[1-9]\d*)$/;function Ft(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&It.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Ut={};Ut["[object Float32Array]"]=Ut["[object Float64Array]"]=Ut["[object Int8Array]"]=Ut["[object Int16Array]"]=Ut["[object Int32Array]"]=Ut["[object Uint8Array]"]=Ut["[object Uint8ClampedArray]"]=Ut["[object Uint16Array]"]=Ut["[object Uint32Array]"]=!0,Ut["[object Arguments]"]=Ut["[object Array]"]=Ut["[object ArrayBuffer]"]=Ut["[object Boolean]"]=Ut["[object DataView]"]=Ut["[object Date]"]=Ut["[object Error]"]=Ut["[object Function]"]=Ut["[object Map]"]=Ut["[object Number]"]=Ut["[object Object]"]=Ut["[object RegExp]"]=Ut["[object Set]"]=Ut["[object String]"]=Ut["[object WeakMap]"]=!1;var Lt,Ht="object"==typeof t&&t&&!t.nodeType&&t,Dt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Dt&&Dt.exports===Ht&&u.process,Bt=function(){try{var t=Dt&&Dt.require&&Dt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Vt=Bt&&Bt.isTypedArray,Gt=Vt?(Lt=Vt,function(t){return Lt(t)}):function(t){return m(t)&&Jt(t.length)&&!!Ut[y(t)]},Wt=Object.prototype.hasOwnProperty;function Yt(t,e){var r=i(t),n=!r&&$t(t),o=!r&&!n&&Rt(t),a=!r&&!n&&!o&&Gt(t),u=r||n||o||a,c=u?function(t,e){for(var r=-1,n=Array(t);++r-1},se.prototype.set=function(t,e){var r=this.__data__,n=ue(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var le,fe=s["__core-js_shared__"],pe=(le=/[^.]+$/.exec(fe&&fe.keys&&fe.keys.IE_PROTO||""))?"Symbol(src)_1."+le:"";var he=Function.prototype.toString;function de(t){if(null!=t){try{return he.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ve=/^\[object .+?Constructor\]$/,ge=Function.prototype,ye=Object.prototype,be=ge.toString,_e=ye.hasOwnProperty,me=RegExp("^"+be.call(_e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function we(t){return!(!ee(t)||function(t){return!!pe&&pe in t}(t))&&(re(t)?me:ve).test(de(t))}function je(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return we(r)?r:void 0}var Se=je(s,"Map"),Oe=je(Object,"create");var ke=Object.prototype.hasOwnProperty;var Ee=Object.prototype.hasOwnProperty;function Ae(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 l=-1,f=!0,p=2&r?new xe:void 0;for(i.set(t,e),i.set(e,t);++le.type.filter((function(t){var e;return void 0===r||(!1!==(e=kt(t))?!Et({arg:r},e):!St(t)(r))})).length)})).length}return!1},Ar=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(Er,null,a);case"array"===t:return!Ot(e.arg);case!1!==(r=kt(t)):return!Et(e,r);default:return!St(t)(e.arg)}},Tr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Pr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Ot(e))throw new lt("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Ot(t))throw new lt("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?Tr(t,a):t,index:r,param:a,optional:i}}));default:throw new lt("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!!gt(e)&&!(r.type.length>r.type.filter((function(e){return Ar(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Ar(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},qr=function(){try{var t=je(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function xr(t,e,r){"__proto__"==e&&qr?qr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Cr(t,e,r){(void 0===r||ae(t[e],r))&&(void 0!==r||e in t)||xr(t,e,r)}var $r="object"==typeof t&&t&&!t.nodeType&&t,zr=$r&&"object"==typeof module&&module&&!module.nodeType&&module,Nr=zr&&zr.exports===$r?s.Buffer:void 0,Mr=Nr?Nr.allocUnsafe:void 0;function Rr(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new ze(n).set(new ze(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Ir=Object.create,Fr=function(){function t(){}return function(e){if(!ee(e))return{};if(Ir)return Ir(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Jr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ur=Object.prototype.hasOwnProperty;function Lr(t,e,r){var n=t[e];Ur.call(t,e)&&ae(n,r)&&(void 0!==r||e in t)||xr(t,e,r)}var Hr=Object.prototype.hasOwnProperty;function Dr(t){if(!ee(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Xt(t),r=[];for(var n in t)("constructor"!=n||!e&&Hr.call(t,n))&&r.push(n);return r}function Kr(t){return ne(t)?Yt(t,!0):Dr(t)}function Br(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Qr);function tn(t,e){return Zr(function(t,e,r){return e=Yr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Yr(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=en.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!ee(r))return!1;var n=typeof e;return!!("number"==n?ne(r)&&Ft(e,r.length):"string"==n&&e in r)&&ae(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,Y(t))}),Reflect.apply(t,null,r))}};function jn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Sn(t,e,r,n){void 0===n&&(n=!1);var o=jn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var On=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 bn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(vt)}},kn=function(t,e,r,n,o){var i={},a=function(t){i=Sn(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 bn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(vt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},En=function(t,e,r,n,o){var i={},a=function(t){i=Sn(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return bn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(vt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},An=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=On(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=On(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 Tn=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(X(e,r,"onResult"),o),t.$only(X(e,r,"onError"),i),t.$trigger(e,{resolverName:r,args:n})}))}};function Pn(t,e,r,n){var o=function(t,e,r,n){var o=[kn,En,An];return Reflect.apply(wn,null,o)({},t,e,r,n)}(t,e,r,n);!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!")}))}(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(X(t,n,"onResult"),r)})).catch((function(r){e.$trigger(X(t,n,"onError"),r)})):console.error(n+" is not defined in the contract!")}))};for(var a in o)i(a);setTimeout((function(){e.$suspend=!1}),1)}function qn(t){return!!function(t){return E(t)&&(Q(t,"query")||Q(t,"mutation")||Q(t,"socket"))}(t)&&t}function xn(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function Cn(t){this.message=t}Cn.prototype=new Error,Cn.prototype.name="InvalidCharacterError";var $n="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Cn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var zn=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($n(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 $n(e)}};function Nn(t){this.message=t}Nn.prototype=new Error,Nn.prototype.name="InvalidTokenError";var Mn=function(t,e){if("string"!=typeof t)throw new Nn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(zn(t.split(".")[r]))}catch(t){throw new Nn("Invalid token specified: "+t.message)}};Mn.InvalidTokenError=Nn;var Rn,In,Fn,Jn,Un,Ln,Hn,Dn,Kn;function Bn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new lt("Token has expired on "+r,t)}return t}function Vn(t){if(mt(t))return Bn(Mn(t));throw new lt("Token must be a string!")}_n("HS256",["string"]),_n(!1,["boolean","number","string"],((Rn={}).alias="exp",Rn.optional=!0,Rn)),_n(!1,["boolean","number","string"],((In={}).alias="nbf",In.optional=!0,In)),_n(!1,["boolean","string"],((Fn={}).alias="iss",Fn.optional=!0,Fn)),_n(!1,["boolean","string"],((Jn={}).alias="sub",Jn.optional=!0,Jn)),_n(!1,["boolean","string"],((Un={}).alias="iss",Un.optional=!0,Un)),_n(!1,["boolean"],((Ln={}).optional=!0,Ln)),_n(!1,["boolean","string"],((Hn={}).optional=!0,Hn)),_n(!1,["boolean","string"],((Dn={}).optional=!0,Dn)),_n(!1,["boolean"],((Kn={}).optional=!0,Kn));var Gn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Wn(t,e){var r;return(r={})[t]=e,r.TS=[Gn()],r}var Yn=function(t){return Q(t,"data")&&!Q(t,"error")?t.data:t},Qn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var Xn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=wo().key(e);t(jo(r),r)}},remove:function(t){return wo().removeItem(t)},clearAll:function(){return wo().clear()}};function wo(){return _o.localStorage}function jo(t){return wo().getItem(t)}var So=ro.trim,Oo={name:"cookieStorage",read:function(t){if(!t||!To(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(ko.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;ko.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:Eo,remove:Ao,clearAll:function(){Eo((function(t,e){Ao(e)}))}},ko=ro.Global.document;function Eo(t){for(var e=ko.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(So(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ao(t){t&&To(t)&&(ko.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function To(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(ko.cookie)}var Po=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 qo=ro.bind,xo=ro.each,Co=ro.create,$o=ro.slice,zo=function(){var t=Co(No,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,qo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,qo(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(),xo(r,(function(e,r){t.fire(r,void 0,e)}))}}};var No={_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,qo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=$o(arguments,1);xo(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Mo=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==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=Math.pow(2,h),h++),a[s]=p++,l=String(c)}if(""!==l){if(Object.prototype.hasOwnProperty.call(u,l)){if(l.charCodeAt(0)<256){for(n=0;n>=1}else{for(o=1,n=0;n>=1}0==--f&&(f=Math.pow(2,h),h++),delete u[l]}else for(o=a[l],n=0;n>=1;0==--f&&(f=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,l,f=[],p=4,h=4,d=3,v="",g=[],y={val:n(0),position:r,index:1};for(o=0;o<3;o+=1)f[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;l=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;l=t(a);break;case 2:return""}for(f[3]=l,i=l,g.push(l);;){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(l=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[h++]=t(a),l=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;f[h++]=t(a),l=h-1,p--;break;case 2:return g.join("")}if(0==p&&(p=Math.pow(2,d),d++),f[l])v=f[l];else{if(l!==h)return null;v=i+i.charAt(0)}g.push(v),f[h++]=i+v.charAt(0),i=v,0==--p&&(p=Math.pow(2,d),d++)}}};return i}();null!=t&&(t.exports=e)})),Ro=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Mo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Mo.compress(this._serialize(r));t(e,n)}}};var Io=[mo,Oo],Fo=[Po,zo,Ro],Jo=go.createStore(Io,Fo),Uo=ro.Global;function Lo(){return Uo.sessionStorage}function Ho(t){return Lo().getItem(t)}var Do=[{name:"sessionStorage",read:Ho,write:function(t,e){return Lo().setItem(t,e)},each:function(t){for(var e=Lo().length-1;e>=0;e--){var r=Lo().key(e);t(Ho(r),r)}},remove:function(t){return Lo().removeItem(t)},clearAll:function(){return Lo().clear()}},Oo],Ko=[Po,Ro],Bo=go.createStore(Do,Ko),Vo=Jo,Go=Bo,Wo=function(t){this.opts=t,this.instanceKey=xn(this.opts.hostname),this.localStore=Vo,this.sessionStore=Go},Yo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Wo.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?rn({},o,e):e,r))},Wo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Wo.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)}},Wo.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)}},Yo.lset.set=function(t){return this.__setMethod("localStore",t)},Yo.lget.get=function(){return this.__getMethod("localStore")},Wo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Wo.prototype.lclear=function(){return this.__clearMethod("localStore")},Yo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Yo.sget.get=function(){return this.__getMethod("sessionStore")},Wo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Wo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Wo.prototype,Yo);var Qo=n[0],Xo=n[1],Zo=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}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=Vn),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(yn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new st("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&&yn(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(!qn(t))throw new st("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=qn(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={}}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={headers:{configurable:!0}};return n.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=rn({},{_cb:Gn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=rn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=rn({},{method:Qo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.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 Yn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=gn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Yn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new ft("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?rn({},r,this.getAuthHeader(),this.extraHeader):rn({},r,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=rn({},this.extraParams,o)),this.request({},{method:"GET"},this.contractHeader).then(dt).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 ft("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),bt(t)&&i(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Wn(t,n)}throw new st("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(dt)},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.payload=e,o.condition=r,!0===n)return o;if(bt(t))return Wn(t,o);throw new st("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Xo}).then(dt)},Object.defineProperties(e.prototype,n),e}(Wo)))),ti={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:e,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ei={hostname:_n(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:_n("jsonql",["string"]),loginHandlerName:_n("login",["string"]),logoutHandlerName:_n("logout",["string"]),enableJsonp:_n(!1,["boolean"]),enableAuth:_n(!1,["boolean"]),useJwt:_n(!0,["boolean"]),persistToken:_n(!1,["boolean","number"]),useLocalstorage:_n(!0,["boolean"]),storageKey:_n("jsonqlstore",["string"]),authKey:_n("jsonqlauthkey",["string"]),contractExpired:_n(0,["number"]),keepContract:_n(!0,["boolean"]),exposeContract:_n(!1,["boolean"]),exposeStore:_n(!1,["boolean"]),showContractDesc:_n(!1,["boolean"]),contractKey:_n(!1,["boolean"]),contractKeyName:_n("X-JSONQL-CV-KEY",["string"]),enableTimeout:_n(!1,["boolean"]),timeout:_n(5e3,["number"]),returnInstance:_n(!1,["boolean"]),allowReturnRawToken:_n(!1,["boolean"]),debugOn:_n(!1,["boolean"])};var ri=new WeakMap,ni=new WeakMap,oi=function(){this.__suspend__=null,this.queueStore=new Set},ii={$suspend:{configurable:!0},$queues:{configurable:!0}};ii.$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)},oi.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__},ii.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},oi.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(oi.prototype,ii);var ai=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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,l=0;l0;)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){ri.set(this,t)},r.normalStore.get=function(){return ri.get(this)},r.lazyStore.set=function(t){ni.set(this,t)},r.lazyStore.get=function(){return ni.get(this)},e.prototype.hashFnToKey=function(t){return xn(t.toString())},Object.defineProperties(e.prototype,r),e}(oi)));t.jsonqlStaticClient=function(t,e){var r,n=e.contract,o=function(t){return jn(t,"__checked__")?Object.assign(t,ti):mn(t,ei,ti)}(e),i=new Zo(t,o),a=function(t,e){return void 0===e&&(e={}),qn(e)?Promise.resolve(e):t.getContract()}(i,n),u=(r=o.debugOn,new ai({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),c=function(t,e,r,n){return n.$suspend=!0,r.then((function(r){Pn(t,n,e,r)})),{query:Tn(n,"query"),mutation:Tn(n,"mutation"),auth:Tn(n,"auth")}}(i,o,a,u);return c.eventEmitter=u,c},Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=jsonql-client.static.js.map diff --git a/packages/http-client/dist/jsonql-client.static.js.map b/packages/http-client/dist/jsonql-client.static.js.map index 164b5e4a2b76f97c2896a4858d607a1bdfdb739d..29f492ffc1d5eaa05df5d451d090a599656c725f 100644 --- a/packages/http-client/dist/jsonql-client.static.js.map +++ b/packages/http-client/dist/jsonql-client.static.js.map @@ -1 +1 @@ -{"version":3,"file":"jsonql-client.static.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"+z1CAAA"} \ No newline at end of file +{"version":3,"file":"jsonql-client.static.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"q71CAAA"} \ No newline at end of file diff --git a/packages/http-client/dist/jsonql-client.umd.js b/packages/http-client/dist/jsonql-client.umd.js index 7afc9471c011378c70b277a861cab6bdbc10f0c0..64382c5f430ff1cf12cba7bf066235f8dba4138c 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("?")?"?":"&")+_.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==g&&(a.responseType=g)}catch(t){}var w=r.headers["Content-Type"]||r.headers[u],j="application/x-www-form-urlencoded";for(var O in o.trim((w||"").toLowerCase())===j?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(j="application/json;charset=utf-8",e=JSON.stringify(e)),w||y||(r.headers["Content-Type"]=j),r.headers)if("Content-Type"===O&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function S(t,e,n){d(f.p,(function(){if(t){n&&(e.request=r);var o=t.call(f,e,Promise);e=void 0===o?e:o}h(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){c(t)})).catch((function(t){p(t)}))}))}function k(t){t.engine=a,S(f.onerror,t,-1)}function E(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader("Content-Type")||"").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,u=a.statusText,c={data:t,headers:e,status:i,statusText:u};if(o.merge(c,a._response),i>=200&&i<300||304===i)c.engine=a,c.request=r,S(f.handler,c,0);else{var s=new E(u,i);s.response=c,k(s)}}catch(s){k(new E(s.msg,a.status))}},a.onerror=function(t){k(new E(t.msg||"Network Error",0))},a.ontimeout=function(){k(new E("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(y?null:e)}),0)}(n):c(n)}),(function(t){p(t)}))}))}));return p.engine=a,p}},{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=["POST","PUT"],c={desc:"y"},s=Array.isArray,f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},l="object"==typeof f&&f&&f.Object===Object&&f,p="object"==typeof self&&self&&self.Object===Object&&self,h=l||p||Function("return this")(),d=h.Symbol,v=Object.prototype,g=v.hasOwnProperty,y=v.toString,b=d?d.toStringTag:void 0;var m=Object.prototype.toString;var _=d?d.toStringTag:void 0;function w(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":_&&_ in Object(t)?function(t){var e=g.call(t,b),r=t[b];try{t[b]=void 0;var n=!0}catch(t){}var o=y.call(t);return n&&(e?t[b]=r:delete t[b]),o}(t):function(t){return m.call(t)}(t)}function j(t,e){return function(r){return t(e(r))}}var O=j(Object.getPrototypeOf,Object);function S(t){return null!=t&&"object"==typeof t}var k=Function.prototype,E=Object.prototype,A=k.toString,T=E.hasOwnProperty,x=A.call(Object);function P(t){if(!S(t)||"[object Object]"!=w(t))return!1;var e=O(t);if(null===e)return!0;var r=T.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&A.call(r)==x}function q(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--&&F(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var tt=function(t){return s(t)?t:[t]},et=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},rt=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),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={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),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 403},r.name.get=function(){return"JsonqlForbiddenError"},Object.defineProperties(e,r),e}(Error),it=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),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"JsonqlContractAuthError"},Object.defineProperties(e,r),e}(Error),ut=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),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={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),ft=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),lt=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),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"JsonqlValidationError"},Object.defineProperties(e,r),e}(Error),ht=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),dt=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),vt=Object.freeze({__proto__:null,Jsonql406Error:rt,Jsonql500Error:nt,JsonqlForbiddenError:ot,JsonqlAuthorisationError:it,JsonqlContractAuthError:at,JsonqlResolverAppError:ut,JsonqlResolverNotFoundError:ct,JsonqlEnumError:st,JsonqlTypeError:ft,JsonqlCheckerError:lt,JsonqlValidationError:pt,JsonqlError:ht,JsonqlServerError:dt}),gt=ht;function yt(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&vt[o])throw new vt[r](i,a);throw new gt(i,a)}return t}function bt(t){if(Array.isArray(t))throw new pt("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof rt:throw new rt(e,r);case t instanceof nt:throw new nt(e,r);case t instanceof ot:throw new ot(e,r);case t instanceof it:throw new it(e,r);case t instanceof at:throw new at(e,r);case t instanceof ut:throw new ut(e,r);case t instanceof ct:throw new ct(e,r);case t instanceof st:throw new st(e,r);case t instanceof ft:throw new ft(e,r);case t instanceof lt:throw new lt(e,r);case t instanceof pt:throw new pt(e,r);case t instanceof dt:throw new dt(e,r);default:throw new ht(e,r)}}function mt(t){return!!function(t){return P(t)&&(et(t,"query")||et(t,"mutation")||et(t,"socket"))}(t)&&t}function _t(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function wt(t){this.message=t}wt.prototype=new Error,wt.prototype.name="InvalidCharacterError";var jt="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new wt("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var Ot=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(jt(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 jt(e)}};function St(t){this.message=t}St.prototype=new Error,St.prototype.name="InvalidTokenError";var kt=function(t,e){if("string"!=typeof t)throw new St("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Ot(t.split(".")[r]))}catch(t){throw new St("Invalid token specified: "+t.message)}};kt.InvalidTokenError=St;function Et(t){return"string"==typeof t||!s(t)&&S(t)&&"[object String]"==w(t)}var At=function(t){return""!==Z(t)&&Et(t)};function Tt(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new ht("Token has expired on "+r,t)}return t}function xt(t){if(At(t))return Tt(kt(t));throw new ht("Token must be a string!")}var Pt=function(t){return!!s(t)||null!=t&&""!==Z(t)};function qt(t){return function(t){return"number"==typeof t||S(t)&&"[object Number]"==w(t)}(t)&&t!=+t}var Ct=function(t){return!Et(t)&&!qt(parseFloat(t))},$t=function(t){return null!=t&&"boolean"==typeof t},zt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==Z(t)&&(!1===e||!0===e&&null!==t)},Nt=function(t){switch(t){case"number":return Ct;case"string":return At;case"boolean":return $t;default:return zt}},Rt=function(t,e){return void 0===e&&(e=""),!!s(t)&&(""===e||""===Z(e)||!(t.filter((function(t){return!Nt(e)(t)})).length>0))},Mt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},Ft=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!Nt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!Rt(r,t)})).length};var It,Jt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[It?a:++n];if(!1===e(o[u],u,o))break}return t};function Ut(t){return S(t)&&"[object Arguments]"==w(t)}var Dt=Object.prototype,Lt=Dt.hasOwnProperty,Ht=Dt.propertyIsEnumerable,Bt=Ut(function(){return arguments}())?Ut:function(t){return S(t)&&Lt.call(t,"callee")&&!Ht.call(t,"callee")};var Kt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Gt=Kt&&"object"==typeof module&&module&&!module.nodeType&&module,Vt=Gt&&Gt.exports===Kt?h.Buffer:void 0,Wt=(Vt?Vt.isBuffer:void 0)||function(){return!1},Yt=/^(?:0|[1-9]\d*)$/;function Qt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Yt.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Zt={};Zt["[object Float32Array]"]=Zt["[object Float64Array]"]=Zt["[object Int8Array]"]=Zt["[object Int16Array]"]=Zt["[object Int32Array]"]=Zt["[object Uint8Array]"]=Zt["[object Uint8ClampedArray]"]=Zt["[object Uint16Array]"]=Zt["[object Uint32Array]"]=!0,Zt["[object Arguments]"]=Zt["[object Array]"]=Zt["[object ArrayBuffer]"]=Zt["[object Boolean]"]=Zt["[object DataView]"]=Zt["[object Date]"]=Zt["[object Error]"]=Zt["[object Function]"]=Zt["[object Map]"]=Zt["[object Number]"]=Zt["[object Object]"]=Zt["[object RegExp]"]=Zt["[object Set]"]=Zt["[object String]"]=Zt["[object WeakMap]"]=!1;var te,ee="object"==typeof exports&&exports&&!exports.nodeType&&exports,re=ee&&"object"==typeof module&&module&&!module.nodeType&&module,ne=re&&re.exports===ee&&l.process,oe=function(){try{var t=re&&re.require&&re.require("util").types;return t||ne&&ne.binding&&ne.binding("util")}catch(t){}}(),ie=oe&&oe.isTypedArray,ae=ie?(te=ie,function(t){return te(t)}):function(t){return S(t)&&Xt(t.length)&&!!Zt[w(t)]},ue=Object.prototype.hasOwnProperty;function ce(t,e){var r=s(t),n=!r&&Bt(t),o=!r&&!n&&Wt(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},we.prototype.set=function(t,e){var r=this.__data__,n=me(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var je,Oe=h["__core-js_shared__"],Se=(je=/[^.]+$/.exec(Oe&&Oe.keys&&Oe.keys.IE_PROTO||""))?"Symbol(src)_1."+je:"";var ke=Function.prototype.toString;function Ee(t){if(null!=t){try{return ke.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var Ae=/^\[object .+?Constructor\]$/,Te=Function.prototype,xe=Object.prototype,Pe=Te.toString,qe=xe.hasOwnProperty,Ce=RegExp("^"+Pe.call(qe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function $e(t){return!(!he(t)||function(t){return!!Se&&Se in t}(t))&&(de(t)?Ce:Ae).test(Ee(t))}function ze(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return $e(r)?r:void 0}var Ne=ze(h,"Map"),Re=ze(Object,"create");var Me=Object.prototype.hasOwnProperty;var Fe=Object.prototype.hasOwnProperty;function Ie(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=2&r?new Le:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=Mt(t))?!Ft({arg:r},e):!Nt(t)(r))})).length)})).length}return!1},Ir=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(Fr,null,a);case"array"===t:return!Rt(e.arg);case!1!==(r=Mt(t)):return!Ft(e,r);default:return!Nt(t)(e.arg)}},Jr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Ur=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!Rt(e))throw new ht("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!Rt(t))throw new ht("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?Jr(t,a):t,index:r,param:a,optional:i}}));default:throw new ht("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!!Pt(e)&&!(r.type.length>r.type.filter((function(e){return Ir(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Ir(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},Dr=function(){try{var t=ze(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Lr(t,e,r){"__proto__"==e&&Dr?Dr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function Hr(t,e,r){(void 0===r||be(t[e],r))&&(void 0!==r||e in t)||Lr(t,e,r)}var Br="object"==typeof exports&&exports&&!exports.nodeType&&exports,Kr=Br&&"object"==typeof module&&module&&!module.nodeType&&module,Gr=Kr&&Kr.exports===Br?h.Buffer:void 0,Vr=Gr?Gr.allocUnsafe:void 0;function Wr(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Ke(n).set(new Ke(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Yr=Object.create,Qr=function(){function t(){}return function(e){if(!he(e))return{};if(Yr)return Yr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Xr(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Zr=Object.prototype.hasOwnProperty;function tn(t,e,r){var n=t[e];Zr.call(t,e)&&be(n,r)&&(void 0!==r||e in t)||Lr(t,e,r)}var en=Object.prototype.hasOwnProperty;function rn(t){if(!he(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=fe(t),r=[];for(var n in t)("constructor"!=n||!e&&en.call(t,n))&&r.push(n);return r}function nn(t){return ve(t)?ce(t,!0):rn(t)}function on(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(fn);function hn(t,e){return pn(function(t,e,r){return e=sn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=sn(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=dn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!he(r))return!1;var n=typeof e;return!!("number"==n?ve(r)&&Qt(e,r.length):"string"==n&&e in r)&&be(r[e],t)}(e[0],e[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r=0;e--){var r=lo().key(e);t(po(r),r)}},remove:function(t){return lo().removeItem(t)},clearAll:function(){return lo().clear()}};function lo(){return so.localStorage}function po(t){return lo().getItem(t)}var ho=Gn.trim,vo={name:"cookieStorage",read:function(t){if(!t||!mo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(go.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;go.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:yo,remove:bo,clearAll:function(){yo((function(t,e){bo(e)}))}},go=Gn.Global.document;function yo(t){for(var e=go.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(ho(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function bo(t){t&&mo(t)&&(go.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function mo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(go.cookie)}var _o=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 wo=Gn.bind,jo=Gn.each,Oo=Gn.create,So=Gn.slice,ko=function(){var t=Oo(Eo,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,wo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,wo(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(),jo(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Eo={_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,wo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=So(arguments,1);jo(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Ao=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)})),To=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Ao.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Ao.compress(this._serialize(r));t(e,n)}}};var xo=[fo,vo],Po=[_o,ko,To],qo=ao.createStore(xo,Po),Co=Gn.Global;function $o(){return Co.sessionStorage}function zo(t){return $o().getItem(t)}var No=[{name:"sessionStorage",read:zo,write:function(t,e){return $o().setItem(t,e)},each:function(t){for(var e=$o().length-1;e>=0;e--){var r=$o().key(e);t(zo(r),r)}},remove:function(t){return $o().removeItem(t)},clearAll:function(){return $o().clear()}},vo],Ro=[_o,To],Mo=ao.createStore(No,Ro),Fo=qo,Io=Mo;function Jo(t,e){var r;return(r={})[t]=e,r.TS=[Dn()],r}var Uo=function(t){return et(t,"data")&&!et(t,"error")?t.data:t},Do=function(t){this.opts=t,this.instanceKey=_t(this.opts.hostname),this.localStore=Fo,this.sessionStore=Io},Lo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Do.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?vn({},o,e):e,r))},Do.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Do.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)}},Do.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)}},Lo.lset.set=function(t){return this.__setMethod("localStore",t)},Lo.lget.get=function(){return this.__getMethod("localStore")},Do.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Do.prototype.lclear=function(){return this.__clearMethod("localStore")},Lo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Lo.sget.get=function(){return this.__getMethod("sessionStore")},Do.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Do.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Do.prototype,Lo);var Ho=u[0],Bo=u[1],Ko=function(t){function e(e,r){t.call(this,r),console.log("fly",e),this.fly=e,this.reqInterceptor(),this.resInterceptor()}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=xt),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(Fn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new pt("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&&Fn(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(!mt(t))throw new pt("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=mt(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={}}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=vn({},{_cb:Dn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=vn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=vn({},{method:Ho,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 Uo(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=Mn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Uo(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new dt("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?vn({},a,this.getAuthHeader(),this.extraHeader):vn({},a,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=vn({},this.extraParams,c)),this.request({},{method:"GET"},this.contractHeader).then(yt).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 dt("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),Et(t)&&s(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Jo(t,n)}throw new pt("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(yt)},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.payload=e,o.condition=r,!0===n)return o;if(Et(t))return Jo(t,o);throw new pt("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Bo}).then(yt)},Object.defineProperties(e.prototype,r),e}(Do)))),Go=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,tt(t))}),Reflect.apply(t,null,r))}};function Vo(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function Wo(t,e,r,n){void 0===n&&(n=!1);var o=Vo(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Yo=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 In(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(bt)}},Qo=function(t,e,r,n,o){var i={},a=function(t){i=Wo(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 In(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(bt)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},Xo=function(t,e,r,n,o){var i={},a=function(t){i=Wo(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return In(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(bt)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Zo=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=Yo(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=Yo(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 ti=function(t,e,r,n){var o=function(t,e,r,n){var o=[Qo,Xo,Zo];return Reflect.apply(Go,null,o)({},t,e,r,n)}(t,n,e,r);return e.exposeStore,o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.5.16",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.userdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)},ei={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:i,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ri={hostname:Jn(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:Jn("jsonql",["string"]),loginHandlerName:Jn("login",["string"]),logoutHandlerName:Jn("logout",["string"]),enableJsonp:Jn(!1,["boolean"]),enableAuth:Jn(!1,["boolean"]),useJwt:Jn(!0,["boolean"]),persistToken:Jn(!1,["boolean","number"]),useLocalstorage:Jn(!0,["boolean"]),storageKey:Jn("jsonqlstore",["string"]),authKey:Jn("jsonqlauthkey",["string"]),contractExpired:Jn(0,["number"]),keepContract:Jn(!0,["boolean"]),exposeContract:Jn(!1,["boolean"]),exposeStore:Jn(!1,["boolean"]),showContractDesc:Jn(!1,["boolean"]),contractKey:Jn(!1,["boolean"]),contractKeyName:Jn("X-JSONQL-CV-KEY",["string"]),enableTimeout:Jn(!1,["boolean"]),timeout:Jn(5e3,["number"]),returnInstance:Jn(!1,["boolean"]),allowReturnRawToken:Jn(!1,["boolean"]),debugOn:Jn(!1,["boolean"])};function ni(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];var o=function(t){return Wo(t,"__checked__",Dn())};r.push(o);var i=Reflect.apply(Go,null,r);return function(r){return void 0===r&&(r={}),i(r,t,e)}}function oi(t){var e=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return function(n){var o;if(void 0===n&&(n={}),Vo(n,"__checked__")){var i=1;return n.__passed__&&(i=++n.__passed__,delete n.__passed__),Promise.resolve(Object.assign(((o={}).__passed__=i,o),n,e))}var a=Reflect.apply(ni,null,[t,e].concat(r));return Promise.resolve(a(n))}}(ri,ei,Un),r=t.contract;return e(t).then((function(t){return t.contract=r,t}))}function ii(t,e,r){return void 0===e&&(e={}),oi(e).then((function(t){return{baseClient:new Ko(r,t),opts:t}})).then((function(e){var r,n,o=e.baseClient,i=e.opts;return(r=o,n=i.contract,void 0===n&&(n={}),mt(n)?Promise.resolve(n):r.getContract()).then((function(e){return ti(o,i,e,t)}))}))}var ai=new WeakMap,ui=new WeakMap,ci=function(){this.__suspend__=null,this.queueStore=new Set},si={$suspend:{configurable:!0},$queues:{configurable:!0}};si.$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)},ci.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__},si.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ci.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(ci.prototype,si);var fi=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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){ai.set(this,t)},r.normalStore.get=function(){return ai.get(this)},r.lazyStore.set=function(t){ui.set(this,t)},r.lazyStore.get=function(){return ui.get(this)},e.prototype.hashFnToKey=function(t){return _t(t.toString())},Object.defineProperties(e.prototype,r),e}(ci)));function li(t,e){var r;return ii((r=e.debugOn,new fi({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={}),li(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("?")?"?":"&")+_.join("&")),a.open(r.method,t);try{a.withCredentials=!!r.withCredentials,a.timeout=r.timeout||0,"stream"!==g&&(a.responseType=g)}catch(t){}var w=r.headers["Content-Type"]||r.headers[u],j="application/x-www-form-urlencoded";for(var O in o.trim((w||"").toLowerCase())===j?e=o.formatParams(e):o.isFormData(e)||-1===["object","array"].indexOf(o.type(e))||(j="application/json;charset=utf-8",e=JSON.stringify(e)),w||y||(r.headers["Content-Type"]=j),r.headers)if("Content-Type"===O&&o.isFormData(e))delete r.headers[O];else try{a.setRequestHeader(O,r.headers[O])}catch(t){}function S(t,e,n){d(f.p,(function(){if(t){n&&(e.request=r);var o=t.call(f,e,Promise);e=void 0===o?e:o}h(e)||(e=Promise[0===n?"resolve":"reject"](e)),e.then((function(t){c(t)})).catch((function(t){p(t)}))}))}function k(t){t.engine=a,S(f.onerror,t,-1)}function E(t,e){this.message=t,this.status=e}a.onload=function(){try{var t=a.response||a.responseText;t&&r.parseJson&&-1!==(a.getResponseHeader("Content-Type")||"").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,u=a.statusText,c={data:t,headers:e,status:i,statusText:u};if(o.merge(c,a._response),i>=200&&i<300||304===i)c.engine=a,c.request=r,S(f.handler,c,0);else{var s=new E(u,i);s.response=c,k(s)}}catch(s){k(new E(s.msg,a.status))}},a.onerror=function(t){k(new E(t.msg||"Network Error",0))},a.ontimeout=function(){k(new E("timeout [ "+a.timeout+"ms ]",1))},a._options=r,setTimeout((function(){a.send(y?null:e)}),0)}(n):c(n)}),(function(t){p(t)}))}))}));return p.engine=a,p}},{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=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),a=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),u=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),c=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),s=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),f=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),l=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),p=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),h=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),d=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),v=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),g="application/vnd.api+json",y={Accept:g,"Content-Type":[g,"charset=utf-8"].join(";")},b=["POST","PUT"],m={desc:"y"},_=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),w=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),j=Object.freeze({__proto__:null,Jsonql406Error:i,Jsonql500Error:a,JsonqlForbiddenError:u,JsonqlAuthorisationError:c,JsonqlContractAuthError:s,JsonqlResolverAppError:f,JsonqlResolverNotFoundError:l,JsonqlEnumError:p,JsonqlTypeError:h,JsonqlCheckerError:d,JsonqlValidationError:v,JsonqlError:_,JsonqlServerError:w}),O=_;function S(t){if(function(t,e){return!!Object.keys(t).filter((function(t){return e===t})).length}(t,"error")){var e=t.error,r=e.className,n=e.name,o=r||n,i=e.message||"No message",a=e.detail||e;if(o&&j[o])throw new j[r](i,a);throw new O(i,a)}return t}function k(t){if(Array.isArray(t))throw new v("",t);var e=t.message||"No message",r=t.detail||t;switch(!0){case t instanceof i:throw new i(e,r);case t instanceof a:throw new a(e,r);case t instanceof u:throw new u(e,r);case t instanceof c:throw new c(e,r);case t instanceof s:throw new s(e,r);case t instanceof f:throw new f(e,r);case t instanceof l:throw new l(e,r);case t instanceof p:throw new p(e,r);case t instanceof h:throw new h(e,r);case t instanceof d:throw new d(e,r);case t instanceof v:throw new v(e,r);case t instanceof w:throw new w(e,r);default:throw new _(e,r)}}var E="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},T="object"==typeof E&&E&&E.Object===Object&&E,A="object"==typeof self&&self&&self.Object===Object&&self,x=T||A||Function("return this")(),P=x.Symbol;function q(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--&&G(e,t[r],0)>-1;);return r}(n,o)+1).join("")}var st=function(t){return!!C(t)||null!=t&&""!==ct(t)};function ft(t){return function(t){return"number"==typeof t||J(t)&&"[object Number]"==F(t)}(t)&&t!=+t}function lt(t){return"string"==typeof t||!C(t)&&J(t)&&"[object String]"==F(t)}var pt=function(t){return!lt(t)&&!ft(parseFloat(t))},ht=function(t){return""!==ct(t)&<(t)},dt=function(t){return null!=t&&"boolean"==typeof t},vt=function(t,e){return void 0===e&&(e=!0),void 0!==t&&""!==t&&""!==ct(t)&&(!1===e||!0===e&&null!==t)},gt=function(t){switch(t){case"number":return pt;case"string":return ht;case"boolean":return dt;default:return vt}},yt=function(t,e){return void 0===e&&(e=""),!!C(t)&&(""===e||""===ct(e)||!(t.filter((function(t){return!gt(e)(t)})).length>0))},bt=function(t){if(t.indexOf("array.<")>-1&&t.indexOf(">")>-1){var e=t.replace("array.<","").replace(">","");return e.indexOf("|")?e.split("|"):[e]}return!1},mt=function(t,e){var r=t.arg;return e.length>1?!r.filter((function(t){return!(e.length>e.filter((function(e){return!gt(e)(t)})).length)})).length:e.length>e.filter((function(t){return!yt(r,t)})).length};function _t(t,e){return function(r){return t(e(r))}}var wt=_t(Object.getPrototypeOf,Object),jt=Function.prototype,Ot=Object.prototype,St=jt.toString,kt=Ot.hasOwnProperty,Et=St.call(Object);function Tt(t){if(!J(t)||"[object Object]"!=F(t))return!1;var e=wt(t);if(null===e)return!0;var r=kt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&St.call(r)==Et}var At,xt=function(t,e,r){for(var n=-1,o=Object(t),i=r(t),a=i.length;a--;){var u=i[At?a:++n];if(!1===e(o[u],u,o))break}return t};function Pt(t){return J(t)&&"[object Arguments]"==F(t)}var qt=Object.prototype,Ct=qt.hasOwnProperty,$t=qt.propertyIsEnumerable,zt=Pt(function(){return arguments}())?Pt:function(t){return J(t)&&Ct.call(t,"callee")&&!$t.call(t,"callee")};var Nt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Rt=Nt&&"object"==typeof module&&module&&!module.nodeType&&module,Mt=Rt&&Rt.exports===Nt?x.Buffer:void 0,It=(Mt?Mt.isBuffer:void 0)||function(){return!1},Ft=/^(?:0|[1-9]\d*)$/;function Jt(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&Ft.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=9007199254740991}var Dt={};Dt["[object Float32Array]"]=Dt["[object Float64Array]"]=Dt["[object Int8Array]"]=Dt["[object Int16Array]"]=Dt["[object Int32Array]"]=Dt["[object Uint8Array]"]=Dt["[object Uint8ClampedArray]"]=Dt["[object Uint16Array]"]=Dt["[object Uint32Array]"]=!0,Dt["[object Arguments]"]=Dt["[object Array]"]=Dt["[object ArrayBuffer]"]=Dt["[object Boolean]"]=Dt["[object DataView]"]=Dt["[object Date]"]=Dt["[object Error]"]=Dt["[object Function]"]=Dt["[object Map]"]=Dt["[object Number]"]=Dt["[object Object]"]=Dt["[object RegExp]"]=Dt["[object Set]"]=Dt["[object String]"]=Dt["[object WeakMap]"]=!1;var Lt,Ht="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bt=Ht&&"object"==typeof module&&module&&!module.nodeType&&module,Kt=Bt&&Bt.exports===Ht&&T.process,Gt=function(){try{var t=Bt&&Bt.require&&Bt.require("util").types;return t||Kt&&Kt.binding&&Kt.binding("util")}catch(t){}}(),Vt=Gt&&Gt.isTypedArray,Wt=Vt?(Lt=Vt,function(t){return Lt(t)}):function(t){return J(t)&&Ut(t.length)&&!!Dt[F(t)]},Yt=Object.prototype.hasOwnProperty;function Qt(t,e){var r=C(t),n=!r&&zt(t),o=!r&&!n&&It(t),i=!r&&!n&&!o&&Wt(t),a=r||n||o||i,u=a?function(t,e){for(var r=-1,n=Array(t);++r-1},fe.prototype.set=function(t,e){var r=this.__data__,n=ce(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var le,pe=x["__core-js_shared__"],he=(le=/[^.]+$/.exec(pe&&pe.keys&&pe.keys.IE_PROTO||""))?"Symbol(src)_1."+le:"";var de=Function.prototype.toString;function ve(t){if(null!=t){try{return de.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ge=/^\[object .+?Constructor\]$/,ye=Function.prototype,be=Object.prototype,me=ye.toString,_e=be.hasOwnProperty,we=RegExp("^"+me.call(_e).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function je(t){return!(!re(t)||function(t){return!!he&&he in t}(t))&&(ne(t)?we:ge).test(ve(t))}function Oe(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return je(r)?r:void 0}var Se=Oe(x,"Map"),ke=Oe(Object,"create");var Ee=Object.prototype.hasOwnProperty;var Te=Object.prototype.hasOwnProperty;function Ae(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=2&r?new Ce:void 0;for(i.set(t,e),i.set(e,t);++fe.type.filter((function(t){var e;return void 0===r||(!1!==(e=bt(t))?!mt({arg:r},e):!gt(t)(r))})).length)})).length}return!1},Ar=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(Tr,null,a);case"array"===t:return!yt(e.arg);case!1!==(r=bt(t)):return!mt(e,r);default:return!gt(t)(e.arg)}},xr=function(t,e){return void 0!==t?t:!0===e.optional&&void 0!==e.defaultvalue?e.defaultvalue:null},Pr=function(t,e,r){var n;void 0===r&&(r=!1);var o=function(t,e){if(!yt(e))throw new _("params is not an array! Did something gone wrong when you generate the contract.json?");if(0===e.length)return[];if(!yt(t))throw new _("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?xr(t,a):t,index:r,param:a,optional:i}}));default:throw new _("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!!st(e)&&!(r.type.length>r.type.filter((function(e){return Ar(e,t)})).length)}(t):!(t.param.type.length>t.param.type.filter((function(e){return Ar(e,t)})).length)}));return r?((n={}).error=i,n.data=o.map((function(t){return t.arg})),n):i},qr=function(){try{var t=Oe(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();function Cr(t,e,r){"__proto__"==e&&qr?qr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function $r(t,e,r){(void 0===r||ue(t[e],r))&&(void 0!==r||e in t)||Cr(t,e,r)}var zr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Nr=zr&&"object"==typeof module&&module&&!module.nodeType&&module,Rr=Nr&&Nr.exports===zr?x.Buffer:void 0,Mr=Rr?Rr.allocUnsafe:void 0;function Ir(t,e){var r,n,o=e?(r=t.buffer,n=new r.constructor(r.byteLength),new Ne(n).set(new Ne(r)),n):t.buffer;return new t.constructor(o,t.byteOffset,t.length)}var Fr=Object.create,Jr=function(){function t(){}return function(e){if(!re(e))return{};if(Fr)return Fr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}();function Ur(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Dr=Object.prototype.hasOwnProperty;function Lr(t,e,r){var n=t[e];Dr.call(t,e)&&ue(n,r)&&(void 0!==r||e in t)||Cr(t,e,r)}var Hr=Object.prototype.hasOwnProperty;function Br(t){if(!re(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Zt(t),r=[];for(var n in t)("constructor"!=n||!e&&Hr.call(t,n))&&r.push(n);return r}function Kr(t){return oe(t)?Qt(t,!0):Br(t)}function Gr(t){return function(t,e,r,n){var o=!r;r||(r={});for(var i=-1,a=e.length;++i0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Xr);function en(t,e){return tn(function(t,e,r){return e=Qr(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=Qr(n.length-e,0),a=Array(i);++o1?e[n-1]:void 0,i=n>2?e[2]:void 0;for(o=rn.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(t,e,r){if(!re(r))return!1;var n=typeof e;return!!("number"==n?oe(r)&&Jt(e,r.length):"string"==n&&e in r)&&ue(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,jn(t))}),Reflect.apply(t,null,r))}};function kn(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return void 0!==r&&r.value?r.value:r}function En(t,e,r,n){void 0===n&&(n=!1);var o=kn(t,e);return!1===n&&void 0!==o?t:(Object.defineProperty(t,e,{value:r,writable:n}),t)}var Tn=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 mn(r,i).then((function(){return t.query.apply(t,[e,a,u])})).catch(k)}},An=function(t,e,r,n,o){var i={},a=function(t){i=En(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 mn(a,i).then((function(){return e.query.apply(e,[t,a,u])})).catch(k)}))};for(var u in o.query)a(u);return t.query=i,t.helloWorld=i.helloWorld,[t,e,r,n,o]},xn=function(t,e,r,n,o){var i={},a=function(t){i=En(i,t,(function(r,n,i){void 0===i&&(i={});var a=[r,n],u=o.mutation[t].params;return mn(a,u).then((function(){return e.mutation.apply(e,[t,r,n,i])})).catch(k)}))};for(var u in o.mutation)a(u);return t.mutation=i,[t,e,r,n,o]},Pn=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=Tn(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=Tn(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 qn=function(t,e,r,n){var o=function(t,e,r,n){var o=[An,xn,Pn];return Reflect.apply(Sn,null,o)({},t,e,r,n)}(t,n,e,r);return e.exposeStore,o=function(t,e,r,n,o){return t.eventEmitter=r,t.contract=o,t.version="1.5.17",t.getLogger=function(t){return function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return Reflect.apply(e.log,e,[t].concat(r))}},n.enableAuth&&(t.userdata=function(){return e.jsonqlUserdata},t.getToken=function(t){return void 0===t&&(t=!1),e.rawAuthToken(t)},t.profileIndex=function(t){if(void 0===t&&(t=!1),!1===t)return e.profileIndex;e.profileIndex=t},t.getProfiles=function(t){return void 0===t&&(t=!1),e.getProfiles(t)}),t}(o,t,n,e,r)};function Cn(t){return!!function(t){return Tt(t)&&(On(t,"query")||On(t,"mutation")||On(t,"socket"))}(t)&&t}function $n(t){return function(t){return t.split("").reduce((function(t,e){return(t=(t<<5)-t+e.charCodeAt(0))&t}),0)}(t)+""}function zn(t){this.message=t}zn.prototype=new Error,zn.prototype.name="InvalidCharacterError";var Nn="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new zn("'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="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return a};var Rn=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(Nn(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 Nn(e)}};function Mn(t){this.message=t}Mn.prototype=new Error,Mn.prototype.name="InvalidTokenError";var In=function(t,e){if("string"!=typeof t)throw new Mn("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Rn(t.split(".")[r]))}catch(t){throw new Mn("Invalid token specified: "+t.message)}};In.InvalidTokenError=Mn;var Fn,Jn,Un,Dn,Ln,Hn,Bn,Kn,Gn;function Vn(t){var e=t.iat||function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e}(!0);if(t.exp&&e>=t.exp){var r=new Date(t.exp).toISOString();throw new _("Token has expired on "+r,t)}return t}function Wn(t){if(ht(t))return Vn(In(t));throw new _("Token must be a string!")}_n("HS256",["string"]),_n(!1,["boolean","number","string"],((Fn={}).alias="exp",Fn.optional=!0,Fn)),_n(!1,["boolean","number","string"],((Jn={}).alias="nbf",Jn.optional=!0,Jn)),_n(!1,["boolean","string"],((Un={}).alias="iss",Un.optional=!0,Un)),_n(!1,["boolean","string"],((Dn={}).alias="sub",Dn.optional=!0,Dn)),_n(!1,["boolean","string"],((Ln={}).alias="iss",Ln.optional=!0,Ln)),_n(!1,["boolean"],((Hn={}).optional=!0,Hn)),_n(!1,["boolean","string"],((Bn={}).optional=!0,Bn)),_n(!1,["boolean","string"],((Kn={}).optional=!0,Kn)),_n(!1,["boolean"],((Gn={}).optional=!0,Gn));var Yn=function(t){void 0===t&&(t=!1);var e=Date.now();return t?Math.floor(e/1e3):e};function Qn(t,e){var r;return(r={})[t]=e,r.TS=[Yn()],r}var Xn=function(t){return On(t,"data")&&!On(t,"error")?t.data:t},Zn=Object.assign?Object.assign:function(t,e,r,n){for(var o=arguments,i=1;i=0;e--){var r=jo().key(e);t(Oo(r),r)}},remove:function(t){return jo().removeItem(t)},clearAll:function(){return jo().clear()}};function jo(){return _o.localStorage}function Oo(t){return jo().getItem(t)}var So=no.trim,ko={name:"cookieStorage",read:function(t){if(!t||!xo(t))return null;var e="(?:^|.*;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*";return unescape(Eo.cookie.replace(new RegExp(e),"$1"))},write:function(t,e){if(!t)return;Eo.cookie=escape(t)+"="+escape(e)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"},each:To,remove:Ao,clearAll:function(){To((function(t,e){Ao(e)}))}},Eo=no.Global.document;function To(t){for(var e=Eo.cookie.split(/; ?/g),r=e.length-1;r>=0;r--)if(So(e[r])){var n=e[r].split("="),o=unescape(n[0]);t(unescape(n[1]),o)}}function Ao(t){t&&xo(t)&&(Eo.cookie=escape(t)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/")}function xo(t){return new RegExp("(?:^|;\\s*)"+escape(t).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(Eo.cookie)}var Po=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 qo=no.bind,Co=no.each,$o=no.create,zo=no.slice,No=function(){var t=$o(Ro,{_id:0,_subSignals:{},_subCallbacks:{}});return{watch:function(e,r,n){return t.on(r,qo(this,n))},unwatch:function(e,r){t.off(r)},once:function(e,r,n){t.once(r,qo(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(),Co(r,(function(e,r){t.fire(r,void 0,e)}))}}};var Ro={_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,qo(this,(function(){e.apply(this,arguments),this.off(r)})))},fire:function(t){var e=zo(arguments,1);Co(this._subCallbacks[t],(function(t){t.apply(this,e)}))}},Mo=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)})),Io=function(){return{get:function(t,e){var r=t(e);if(!r)return r;var n=Mo.decompress(r);return null==n?r:this._deserialize(n)},set:function(t,e,r){var n=Mo.compress(this._serialize(r));t(e,n)}}};var Fo=[wo,ko],Jo=[Po,No,Io],Uo=yo.createStore(Fo,Jo),Do=no.Global;function Lo(){return Do.sessionStorage}function Ho(t){return Lo().getItem(t)}var Bo=[{name:"sessionStorage",read:Ho,write:function(t,e){return Lo().setItem(t,e)},each:function(t){for(var e=Lo().length-1;e>=0;e--){var r=Lo().key(e);t(Ho(r),r)}},remove:function(t){return Lo().removeItem(t)},clearAll:function(){return Lo().clear()}},ko],Ko=[Po,Io],Go=yo.createStore(Bo,Ko),Vo=Uo,Wo=Go,Yo=function(t){this.opts=t,this.instanceKey=$n(this.opts.hostname),this.localStore=Vo,this.sessionStore=Wo},Qo={lset:{configurable:!0},lget:{configurable:!0},sset:{configurable:!0},sget:{configurable:!0}};Yo.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?nn({},o,e):e,r))},Yo.prototype.__getMethod=function(t){var e=this[t].get(this.opts.storageKey);return!!e&&e[this.instanceKey]},Yo.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)}},Yo.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)}},Qo.lset.set=function(t){return this.__setMethod("localStore",t)},Qo.lget.get=function(){return this.__getMethod("localStore")},Yo.prototype.ldel=function(t){return this.__delMethod("localStore",t)},Yo.prototype.lclear=function(){return this.__clearMethod("localStore")},Qo.sset.set=function(t){return this.__setMethod("sessionStore",t)},Qo.sget.get=function(){return this.__getMethod("sessionStore")},Yo.prototype.sdel=function(t){return this.__delMethod("sessionStore",t)},Yo.prototype.sclear=function(){return this.__clearMethod("sessionStore")},Object.defineProperties(Yo.prototype,Qo);var Xo=b[0],Zo=b[1],ti=function(t){function e(e,r){t.call(this,r),this.httpEngine=e,this.reqInterceptor(),this.resInterceptor()}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=Wn),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(bn(t))return this.prof_idx=t,void(this.opts.persistToken&&(this.lset=((e={}).prof_idx=t,e)));throw new v("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&&bn(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(!Cn(t))throw new v("Contract is malformed!");return this.lset=((e={}).contract=t,e),this.log("storeContract return result",t),t},e.prototype.readContract=function(){var t=Cn(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={}}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=nn({},{_cb:Yn()},this.extraParams);if(this.opts.enableJsonp){var i=function(t){return Object.keys(t)[0]}(t);o=nn({},o,((n={}).jsonqlJsonpCallback=i,n)),t=t[i]}var a=nn({},{method:Xo,params:o},e);return this.log("request params",a,this.jsonqlEndpoint),this.httpEngine.request(this.jsonqlEndpoint,t,a)},e.prototype.reqInterceptor=function(){var t=this;this.httpEngine.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 Xn(t)},e.prototype.resInterceptor=function(){var t=this,e=this,r=e.opts.enableJsonp;this.httpEngine.interceptors.response.use((function(n){t.log("response interceptor call",n),e.cleanUp();var o=yn(n.data)?JSON.parse(n.data):n.data;return r?e.processJsonp(o):Xn(o)}),(function(r){throw e.cleanUp(),t.log("__error__",r),new w("Server side error",r)}))},e.prototype.getHeaders=function(){return this.opts.enableAuth?nn({},y,this.getAuthHeader(),this.extraHeader):nn({},y,this.extraHeader)},e.prototype.cleanUp=function(){this.extraHeader={},this.extraParams={}},e.prototype.getRemoteContract=function(){var t=this;return this.opts.showContractDesc&&(this.extraParams=nn({},this.extraParams,m)),this.request({},{method:"GET"},this.contractHeader).then(S).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 w("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),lt(t)&&C(e)){var n=function(t){var e;return(e={}).args=t,e}(e);return!0===r?n:Qn(t,n)}throw new v("[createQuery] expect resolverName to be string and args to be array!",{resolverName:t,args:e})}(t,e)).then(S)},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.payload=e,o.condition=r,!0===n)return o;if(lt(t))return Qn(t,o);throw new v("[createMutation] expect resolverName to be string!",{resolverName:t,payload:e,condition:r})}(t,e,r),{method:Zo}).then(S)},Object.defineProperties(e.prototype,r),e}(Yo)))),ei={contract:!1,MUTATION_ARGS:["name","payload","conditions"],CONTENT_TYPE:g,BEARER:"Bearer",AUTH_HEADER:"Authorization"},ri={hostname:_n(function(){try{return[window.location.protocol,window.location.host].join("//")}catch(t){return null}}(),["string"]),jsonqlPath:_n("jsonql",["string"]),loginHandlerName:_n("login",["string"]),logoutHandlerName:_n("logout",["string"]),enableJsonp:_n(!1,["boolean"]),enableAuth:_n(!1,["boolean"]),useJwt:_n(!0,["boolean"]),persistToken:_n(!1,["boolean","number"]),useLocalstorage:_n(!0,["boolean"]),storageKey:_n("jsonqlstore",["string"]),authKey:_n("jsonqlauthkey",["string"]),contractExpired:_n(0,["number"]),keepContract:_n(!0,["boolean"]),exposeContract:_n(!1,["boolean"]),exposeStore:_n(!1,["boolean"]),showContractDesc:_n(!1,["boolean"]),contractKey:_n(!1,["boolean"]),contractKeyName:_n("X-JSONQL-CV-KEY",["string"]),enableTimeout:_n(!1,["boolean"]),timeout:_n(5e3,["number"]),returnInstance:_n(!1,["boolean"]),allowReturnRawToken:_n(!1,["boolean"]),debugOn:_n(!1,["boolean"])};function ni(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];var o=function(t){return En(t,"__checked__",Yn())};r.push(o);var i=Reflect.apply(Sn,null,r);return function(r){return void 0===r&&(r={}),i(r,t,e)}}function oi(t){var e=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return function(n){var o;if(void 0===n&&(n={}),kn(n,"__checked__")){var i=1;return n.__passed__&&(i=++n.__passed__,delete n.__passed__),Promise.resolve(Object.assign(((o={}).__passed__=i,o),n,e))}var a=Reflect.apply(ni,null,[t,e].concat(r));return Promise.resolve(a(n))}}(ri,ei,wn),r=t.contract;return e(t).then((function(t){return t.contract=r,t}))}function ii(t,e,r){return void 0===r&&(r={}),oi(r).then((function(t){return{baseClient:new ti(e,t),opts:t}})).then((function(e){var r,n,o=e.baseClient,i=e.opts;return(r=o,n=i.contract,void 0===n&&(n={}),Cn(n)?Promise.resolve(n):r.getContract()).then((function(e){return qn(o,i,e,t)}))}))}var ai=new WeakMap,ui=new WeakMap,ci=function(){this.__suspend__=null,this.queueStore=new Set},si={$suspend:{configurable:!0},$queues:{configurable:!0}};si.$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)},ci.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__},si.$queues.get=function(){var t=this.queueStore.size;return this.logger("($queues)","size: "+t),t>0?Array.from(this.queueStore):[]},ci.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(ci.prototype,si);var fi=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={name:{configurable:!0}};return r.name.get=function(){return"jsonql-event-emitter"},Object.defineProperties(e.prototype,r),e}(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){ai.set(this,t)},r.normalStore.get=function(){return ai.get(this)},r.lazyStore.set=function(t){ui.set(this,t)},r.lazyStore.get=function(){return ui.get(this)},e.prototype.hashFnToKey=function(t){return $n(t.toString())},Object.defineProperties(e.prototype,r),e}(ci)));function li(t,e){var r;return ii((r=e.debugOn,new fi({logger:r?function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];t.unshift("[BUILTIN]"),console.log.apply(null,t)}:void 0})),t,e)}return function(t){return void 0===t&&(t={}),li(new o,t)}})); //# sourceMappingURL=jsonql-client.umd.js.map diff --git a/packages/http-client/dist/jsonql-client.umd.js.map b/packages/http-client/dist/jsonql-client.umd.js.map index 658d3fca099d03ce37cffe2fd2f1550930d23686..53788d4b37d0840085996f5a3f0c84a2513edf1f 100644 --- a/packages/http-client/dist/jsonql-client.umd.js.map +++ b/packages/http-client/dist/jsonql-client.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"jsonql-client.umd.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"0+7CAAA"} \ No newline at end of file +{"version":3,"file":"jsonql-client.umd.js","sources":["../node_modules/store/plugins/defaults.js"],"sourcesContent":["module.exports = defaultsPlugin\n\nfunction defaultsPlugin() {\n\tvar defaultValues = {}\n\t\n\treturn {\n\t\tdefaults: defaults,\n\t\tget: get\n\t}\n\t\n\tfunction defaults(_, values) {\n\t\tdefaultValues = values\n\t}\n\t\n\tfunction get(super_fn, key) {\n\t\tvar val = super_fn()\n\t\treturn (val !== undefined ? val : defaultValues[key])\n\t}\n}\n"],"names":[],"mappings":"wthDAAA"} \ No newline at end of file diff --git a/packages/http-client/index.js b/packages/http-client/index.js index 2db2d579b8d428585ab446b8820888e089202cac..e551515fcbe087cd3f0e6fb468d07938e5a4bb4f 100644 --- a/packages/http-client/index.js +++ b/packages/http-client/index.js @@ -1,8 +1,5 @@ // main export interface -import { - jsonqlAsync, - ee as getEventEmitter -} from './src' +import { jsonqlAsync, getEventEmitter } from './src' /** * When pass a static contract then it return a static interface @@ -13,5 +10,5 @@ import { */ export default function jsonqlClient(fly, config) { const ee = getEventEmitter(config.debugOn) - return jsonqlAsync(ee, config, fly) + return jsonqlAsync(ee, fly, config) } diff --git a/packages/http-client/module.js b/packages/http-client/module.js index 07d86a9acd5ae9d9a28f24e3e6f1ec13702a6c91..a4ea0c881c769526bd084c35001d2c95ba0c35ed 100644 --- a/packages/http-client/module.js +++ b/packages/http-client/module.js @@ -1,9 +1,9 @@ // new module interface for @jsonql/client // this will be use with the @jsonql/ws, @jsonql/socketio // 1.5.8 we move the implmentation out and they should be in the @jsonql/client -import JsonqlBaseClient from './src/base' -import getEventEmitter from './src/ee' import generator from './src/core/jsonql-api-generator' +import { JsonqlBaseEngine } from './src/base' +import { getEventEmitter } from './src' import { checkOptionsAsync } from './src/options' import { getContractFromConfig } from './src/utils' // merge from opt.js not point of having two @@ -29,14 +29,18 @@ function getPreConfigCheck(extraProps = {}, extraConstProps = {}) { // rename for export const jsonqlHttpClientAppProps = appProps const jsonqlHttpClientConstProps = constProps +// just duplicate it and export to avoid the crash out +// and take down those name later on +const JsonqlBase = JsonqlBaseEngine // export export { + generator, jsonqlHttpClientAppProps, jsonqlHttpClientConstProps, - JsonqlBaseClient, + JsonqlBase, + JsonqlBaseEngine, // this will affect a lot of the deps later getEventEmitter, - generator, checkOptionsAsync, getContractFromConfig, getPreConfigCheck diff --git a/packages/http-client/package.json b/packages/http-client/package.json index aaa490066b1ecaef5985f47226bd2d48720e5cfa..267f4a00e5ca3b3b5dcb15154786119386055797 100755 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -1,6 +1,6 @@ { "name": "jsonql-client", - "version": "1.5.16", + "version": "1.5.17", "description": "jsonql http browser client using Fly.js with full user profile management with jwt and more", "main": "core.js", "module": "index.js", diff --git a/packages/http-client/src/base/auth-cls.js b/packages/http-client/src/base/auth-cls.js index 7ef4f975979def6242d29e5beb8386e5dd699d5b..03e71da0a04eb0f7f6b1e76a2d02af9de868769c 100644 --- a/packages/http-client/src/base/auth-cls.js +++ b/packages/http-client/src/base/auth-cls.js @@ -3,7 +3,7 @@ import { decodeToken } from 'jsonql-jwt/src/client' import { isNumber } from 'jsonql-params-validator' import { JsonqlValidationError } from 'jsonql-errors' -import { CREDENTIAL_STORAGE_KEY, AUTH_HEADER, BEARER } from 'jsonql-constants' +import { CREDENTIAL_STORAGE_KEY, BEARER } from 'jsonql-constants' import { CLS_PROFILE_IDX, ZERO_IDX, USERDATA_TABLE } from '../utils' import ContractClass from './contract-cls' // export diff --git a/packages/http-client/src/base/base-cls.js b/packages/http-client/src/base/base-cls.js index 47f89c7b234a13147f1b8863fecd6ebbed4d260f..153fc5770ccc9ecbcd32d948beb588b82efcbef3 100644 --- a/packages/http-client/src/base/base-cls.js +++ b/packages/http-client/src/base/base-cls.js @@ -1,20 +1,19 @@ // this the core of the internal storage management -import { CREDENTIAL_STORAGE_KEY } from 'jsonql-constants' +// import { CREDENTIAL_STORAGE_KEY } from 'jsonql-constants' // import { isObject, isArray } from 'jsonql-params-validator' // import { JsonqlValidationError } from 'jsonql-errors' // import { timestamp } from 'jsonql-utils/src/timestamp' // import { inArray } from 'jsonql-utils/src/generic' -import { USERDATA_TABLE, LOG_ERROR_SWITCH } from '../utils' +import { LOG_ERROR_SWITCH } from '../utils' import AuthCls from './auth-cls' // This class will only focus on the storage system -export default class JsonqlBaseClient extends AuthCls { +export default class JsonqlBaseEngine extends AuthCls { // change the order of the interface in 1.4.10 to match up the top level - constructor(fly, opts) { + constructor(httpEngine, opts) { super(opts) // change at 1.4.10 pass it directly without init it - console.log('fly', fly) - this.fly = fly + this.httpEngine = httpEngine // fly.js // this two methods defined in http-cls, and execute the create interceptors this.reqInterceptor() this.resInterceptor() diff --git a/packages/http-client/src/base/contract-cls.js b/packages/http-client/src/base/contract-cls.js index 70595062598870f0593e4e6c8bfcbba7f922bf0f..378ea5e90bac717cdbb20e1a299bf6a01f33a4a5 100644 --- a/packages/http-client/src/base/contract-cls.js +++ b/packages/http-client/src/base/contract-cls.js @@ -1,9 +1,9 @@ // all the contract related methods will be here import { JsonqlValidationError } from 'jsonql-errors' -import { timestamp } from 'jsonql-utils/src/timestamp' +// import { timestamp } from 'jsonql-utils/src/timestamp' import { isContract } from 'jsonql-utils/src/contract' -import { ENDPOINT_TABLE, CLS_CONTRACT_NAME } from '../utils' -import { localStore } from '../stores' +import { CLS_CONTRACT_NAME } from '../utils' +// import { localStore } from '../stores' import HttpClass from './http-cls' // export diff --git a/packages/http-client/src/base/http-cls.js b/packages/http-client/src/base/http-cls.js index 59c78983be1fae66a3107b05e7986e492e51126f..7692685d359d0732952a85957448e22a6900eba7 100644 --- a/packages/http-client/src/base/http-cls.js +++ b/packages/http-client/src/base/http-cls.js @@ -5,13 +5,13 @@ import { createMutation, getNameFromPayload } from 'jsonql-utils/src/params-api' -import { cacheBurst, urlParams } from 'jsonql-utils/src/urls' +import { cacheBurst } from 'jsonql-utils/src/urls' import { resultHandler } from 'jsonql-utils/src/results' -import { isObject, isString } from 'jsonql-params-validator' +import { isString } from 'jsonql-params-validator' import { - JsonqlValidationError, + // JsonqlValidationError, JsonqlServerError, - JsonqlError, + // JsonqlError, clientErrorsHandler } from 'jsonql-errors' import { @@ -34,22 +34,15 @@ export default class HttpClass extends StoreClass { */ constructor(opts) { super(opts) - // change the way how we init Fly - // flyio now become external depedencies and it makes it easier to switch - // @BUG should we run test to check if we have the windows object? - // this.log(opts) - // this.fly = opts.Fly ? new opts.Fly() : new Fly() - // to a different environment like WeChat mini app - - this.extraHeader = {}; // @1.2.1 for adding query to the call on the fly - this.extraParams = {}; + this.extraHeader = {} + this.extraParams = {} // this.log('start up opts', opts); } // set headers for that one call set headers(header) { - this.extraHeader = header; + this.extraHeader = header } /** @@ -72,7 +65,7 @@ export default class HttpClass extends StoreClass { const reqParams = merge({}, { method: POST, params }, options) this.log('request params', reqParams, this.jsonqlEndpoint) - return this.fly.request(this.jsonqlEndpoint, payload, reqParams) + return this.httpEngine.request(this.jsonqlEndpoint, payload, reqParams) } /** @@ -80,7 +73,7 @@ export default class HttpClass extends StoreClass { * */ reqInterceptor() { - this.fly.interceptors.request.use( + this.httpEngine.interceptors.request.use( req => { const headers = this.getHeaders() this.log('request interceptor call', headers) @@ -88,7 +81,7 @@ export default class HttpClass extends StoreClass { for (let key in headers) { req.headers[key] = headers[key] } - return req; + return req } ) } @@ -103,9 +96,9 @@ export default class HttpClass extends StoreClass { * */ resInterceptor() { - const self = this; - const jsonp = self.opts.enableJsonp; - this.fly.interceptors.response.use( + const self = this + const jsonp = self.opts.enableJsonp + this.httpEngine.interceptors.response.use( res => { this.log('response interceptor call', res) self.cleanUp() diff --git a/packages/http-client/src/base/index.js b/packages/http-client/src/base/index.js index 703a14a8be2dab9d3b9ce226eaddc43346d714a8..5dc122cc08ba2925c6b29a4871da4562fee93537 100644 --- a/packages/http-client/src/base/index.js +++ b/packages/http-client/src/base/index.js @@ -1,5 +1,5 @@ // export interface // @public -import JsonqlBaseClient from './base-cls' - -export default JsonqlBaseClient +import JsonqlBaseEngine from './base-cls' +// change to named export in 1.5.17 +export { JsonqlBaseEngine } diff --git a/packages/http-client/src/core/jsonql-api-generator.js b/packages/http-client/src/core/jsonql-api-generator.js index e56e16687eabff768e9a74c1b23303b927dd20da..4bba0195d4cd72063d27e77006eca410d472ac1b 100644 --- a/packages/http-client/src/core/jsonql-api-generator.js +++ b/packages/http-client/src/core/jsonql-api-generator.js @@ -6,6 +6,7 @@ // is calling a private method without logging in // then we should throw the JsonqlForbiddenError at this point // instead of making a round trip to the server +/* import { LOGOUT_NAME, ISSUER_NAME, KEY_WORD } from 'jsonql-constants' import { validateAsync } from 'jsonql-params-validator' import { @@ -14,7 +15,7 @@ import { clientErrorsHandler, finalCatch } from 'jsonql-errors' - +*/ import { methodsGenerator, addPropsToClient } from './methods-generator' /** diff --git a/packages/http-client/src/core/methods-generator.js b/packages/http-client/src/core/methods-generator.js index 2f5dfc0c977f5bafe679a485e7da916e71e16a98..74ada6ec9921ba3ebb9a927dfb17b5be8444925c 100644 --- a/packages/http-client/src/core/methods-generator.js +++ b/packages/http-client/src/core/methods-generator.js @@ -1,8 +1,8 @@ // breaking out the inner methods generator in here import { - JsonqlValidationError, - JsonqlError, - clientErrorsHandler, + // JsonqlValidationError, + // JsonqlError, + // clientErrorsHandler, finalCatch } from 'jsonql-errors' import { validateAsync } from 'jsonql-params-validator' diff --git a/packages/http-client/src/ee.js b/packages/http-client/src/ee.js index 23fa63a6d9f504dbcb135bf16c5e407f5ee968a1..aadc65f9db468ca1914b4b00ee219069f7e7e382 100644 --- a/packages/http-client/src/ee.js +++ b/packages/http-client/src/ee.js @@ -11,10 +11,10 @@ class JsonqlEventEmitter extends NBEventService { } } -// output -export default function(debugOn) { +// export +export function getEventEmitter(debugOn) { let logger = debugOn ? (...args) => { - args.unshift('[NBS]') + args.unshift('[BUILTIN]') // rename here to id where this come from console.log.apply(null, args) }: undefined; return new JsonqlEventEmitter({ logger }) diff --git a/packages/http-client/src/index.js b/packages/http-client/src/index.js index 2653e67438d451e3a73e001b6b451d534787621c..8398d0fba1e57e3fc880e656a64f3bc771d0d6c4 100644 --- a/packages/http-client/src/index.js +++ b/packages/http-client/src/index.js @@ -1,11 +1,10 @@ - -import jsonqlAsync from './jsonql-async' -import jsonqlSync from './jsonql-sync' - -import ee from './ee' +// re-export for use later +import { jsonqlAsync } from './jsonql-async' +import { jsonqlSync } from './jsonql-sync' +import { getEventEmitter } from './ee' export { jsonqlAsync, jsonqlSync, - ee + getEventEmitter } diff --git a/packages/http-client/src/jsonql-async.js b/packages/http-client/src/jsonql-async.js index 9cf61050091065733299ed4bbb6e383080c0d818..2006ddd3e1680cccafd4f431fc742ee8aefa23f2 100644 --- a/packages/http-client/src/jsonql-async.js +++ b/packages/http-client/src/jsonql-async.js @@ -1,21 +1,21 @@ // this is new for the flyio and normalize the name from now on -import JsonqlBaseClient from './base' import generator from './core/jsonql-api-generator' +import { JsonqlBaseEngine } from './base' import { checkOptionsAsync } from './options' import { getContractFromConfig } from './utils' /** * Main interface for jsonql fetch api * @param {object} ee EventEmitter - * @param {object} config * @param {object} fly this is really pain in the backside ... long story + * @param {object} [config={}] configuration options * @return {object} jsonql client */ -export default function(ee, config = {}, fly) { +export function jsonqlAsync(ee, fly, config = {}) { return checkOptionsAsync(config) .then(opts => ( { - baseClient: new JsonqlBaseClient(fly, opts), + baseClient: new JsonqlBaseEngine(fly, opts), opts: opts } )) diff --git a/packages/http-client/src/jsonql-sync.js b/packages/http-client/src/jsonql-sync.js index d691259e72ec78c7694f89d2eb58c6c2a98882b8..186909515a89ef4055b1dd0ba7caf88aa7292eb5 100644 --- a/packages/http-client/src/jsonql-sync.js +++ b/packages/http-client/src/jsonql-sync.js @@ -1,21 +1,20 @@ // this will be the sync version -import JsonqlBaseClient from './base' import generator from './core/jsonql-api-generator' +import { JsonqlBaseEngine } from './base' import { checkOptions } from './options' -import ee from './ee' /** * when the client contains a valid contract * @param {object} ee EventEmitter - * @param {object} config configuration * @param {object} fly the fly client + * @param {object} [config={}] configuration * @return {object} the client */ -export default function jsonqlSync(ee, config, fly) { +export function jsonqlSync(ee, fly, config = {}) { const { contract } = config; const opts = checkOptions(config) - const jsonqlBase = new JsonqlBaseClient(fly, opts) + const jsonqlBaseCls = new JsonqlBaseEngine(fly, opts) - return generator(jsonqlBase, opts, contract, ee) + return generator(jsonqlBaseCls, opts, contract, ee) } diff --git a/packages/http-client/static.js b/packages/http-client/static.js index a0c72aa9e910b6dceae0bd4339b7e7b505f71531..ff7529064a25067c3ffbeab376b34a9ba3303385 100644 --- a/packages/http-client/static.js +++ b/packages/http-client/static.js @@ -4,10 +4,10 @@ // the export will be different and purposely design for framework that // is very hard to use Promise such as Vue import jsonqlStaticGenerator from './src/core/jsonql-static-generator' -import JsonqlBaseClient from './src/base' +import { JsonqlBaseEngine } from './src/base' import { checkOptions } from './src/options' import { getContractFromConfig } from './src/utils' -import getEventEmitter from './src/ee' +import { getEventEmitter } from './src' /** * this is the slim client without Fly, you pick the version of Fly to use @@ -19,11 +19,11 @@ import getEventEmitter from './src/ee' export function jsonqlStaticClient(fly, config) { const { contract } = config; const opts = checkOptions(config) - const jsonqlBase = new JsonqlBaseClient(fly, opts) - const contractPromise = getContractFromConfig(jsonqlBase, contract) + const jsonqlBaseCls = new JsonqlBaseEngine(fly, opts) + const contractPromise = getContractFromConfig(jsonqlBaseCls, contract) const ee = getEventEmitter(opts.debugOn) // finally - let methods = jsonqlStaticGenerator(jsonqlBase, opts, contractPromise, ee) + let methods = jsonqlStaticGenerator(jsonqlBaseCls, opts, contractPromise, ee) methods.eventEmitter = ee; return methods; } diff --git a/packages/http-client/sync.js b/packages/http-client/sync.js index 3fd6c83ead70ece5a1fd423e7b19b8198be9171a..2e536748c391eebdc6248178c0d2c6c889d4d2d8 100644 --- a/packages/http-client/sync.js +++ b/packages/http-client/sync.js @@ -2,7 +2,7 @@ // because that will cause a lot of confusion about the api // new module interface for @jsonql/client // this will be use with the @jsonql/ws, @jsonql/socketio -import { jsonqlAsync, jsonqlSync, ee as getEventEmitter } from './src' +import { jsonqlSync, getEventEmitter } from './src' import { isContract } from './src/utils' import { JsonqlError } from 'jsonql-errors' @@ -16,7 +16,7 @@ import { JsonqlError } from 'jsonql-errors' export function jsonqlSyncClient(Fly, config) { const ee = getEventEmitter(config.debugOn) if (config.contract && isContract(config.contract)) { - return jsonqlSync(ee, config, Fly) + return jsonqlSync(ee, Fly, config) } throw new JsonqlError('jsonqlSyncClient', `Expect to pass the contract via configuration!`) }