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