"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("uuid"),n=require("lodash"),r=require("./clientStorage/index.js"),o=require("./jsonApi/index.js"),i=require("./subscriptions.js"),c=require("./api/apiCore.js"),s=require("./constants.js"),u=require("./corvaUrls.js"),a=require("./subscriptions/constants.js"),p=require("./subscriptions/socket-client.v2.js"),d=require("./sso/index.js"),l=require("./utils.js"),v=require("./api/rateLimiter.js");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=f(e);function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function A(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?h(Object(n),!0).forEach((function(t){g.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var b={get:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c.get(e,t,n)},getWithHeaders:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c.getWithHeaders(e,t,n)},put:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return c.put(e,t,n,r)},patch:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return c.patch(e,t,n,r)},post:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c.post(e,t,n)},del:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c.del(e,t,n)}},j={get:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c.get(e,t,A({apiUrl:s.CORVA_API_URLS.DATA_API},n))},put:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return c.put(e,t,n,A({apiUrl:s.CORVA_API_URLS.DATA_API},r))},patch:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return c.patch(e,t,n,A({apiUrl:s.CORVA_API_URLS.DATA_API},r))},post:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c.post(e,t,A({apiUrl:s.CORVA_API_URLS.DATA_API},n))},del:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return c.del(e,t,A({apiUrl:s.CORVA_API_URLS.DATA_API},n))}};function P(){if(window.xprops){var e,n,r,o,i,c=(null===(e=window.xprops)||void 0===e||null===(n=e.app)||void 0===n||null===(r=n.app)||void 0===r?void 0:r.id)||"unknown-app-id",s=(null===(o=window.xprops)||void 0===o||null===(i=o.app)||void 0===i?void 0:i.id)||"unknown-instance-id";return"".concat(c,":").concat(s,":").concat(t.v4())}return"non-dc-app:".concat(t.v4())}var O={subscribe:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.onDataReceive,o=window[Symbol.for("socket")]||{},i=o.subscribe,c=o.unsubscribe,s=o.socket;if(!s)return console.error("Socket is not initialized!"),n.noop;var u=P(),a=A(A({},e),{},{collection:e.collection||e.dataset,appInstanceId:u}),p=r&&function(e){return e.appInstanceId===u&&r(e)};return i(a),p&&s.on("data",p),function(){p&&s.off("data",p),c(a)}},onConnectionChange:function(e){var t=(window[Symbol.for("socket")]||{}).socket;if(!t)return function(){};var n=function(){return e({status:"connected"})},r=function(t){return e({status:"disconnected",reason:t})},o=function(){return e({status:"reconnecting"})},i=function(t){return e({status:"error",reason:(null==t?void 0:t.message)||String(t)})};return t.on("connect",n),t.on("disconnect",r),t.on("reconnect",o),t.on("connect_error",i),function(){t.off("connect",n),t.off("disconnect",r),t.off("reconnect",o),t.off("connect_error",i)}}},x=a.handleSubscriptionsVersion(O,p.socketClientV2);exports.clientStorage=r,exports.jsonApi=o,exports.subscriptions=i,exports.corvaUrls=u,exports.sso=d,exports.attachHTTPHeaders=l.attachHTTPHeaders,exports.getAppKeyAndId=l.getAppKeyAndId,exports.getAuthorizationHeaders=l.getAuthorizationHeaders,exports.getAuthorizationToken=l.getAuthorizationToken,exports.apiRequestsRateLimiter=v.apiRequestsRateLimiter,exports.corvaAPI=b,exports.corvaDataAPI=j,exports.socketClient=x;
//# sourceMappingURL=index.js.map
