import t from"@babel/runtime/helpers/defineProperty";import{v4 as r}from"uuid";import{noop as n}from"lodash";import*as o from"./clientStorage/index.js";export{o 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 a,getWithHeaders as p,put as c,patch as s,post as u,del as l}from"./api/apiCore.js";import{CORVA_API_URLS as d}from"./constants.js";import*as v from"./corvaUrls.js";export{v as corvaUrls};import*as f from"./sso/index.js";export{f as sso};function g(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),n.push.apply(n,o)}return n}function h(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?g(Object(o),!0).forEach((function(n){t(r,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):g(Object(o)).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(o,t))}))}return r}var m={get:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(t,r,n)},getWithHeaders:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return p(t,r,n)},put:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return c(t,r,n,o)},patch:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return s(t,r,n,o)},post:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(t,r,n)},del:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return l(t,r,n)}},b={get:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a(t,r,h({apiUrl:d.DATA_API},n))},put:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return c(t,r,n,h({apiUrl:d.DATA_API},o))},patch:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return s(t,r,n,h({apiUrl:d.DATA_API},o))},post:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return u(t,r,h({apiUrl:d.DATA_API},n))},del:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return l(t,r,h({apiUrl:d.DATA_API},n))}};function j(){if(window.xprops){var t,n,o,e,i,a=(null===(t=window.xprops)||void 0===t||null===(n=t.app)||void 0===n||null===(o=n.app)||void 0===o?void 0:o.id)||"unknown-app-id",p=(null===(e=window.xprops)||void 0===e||null===(i=e.app)||void 0===i?void 0:i.id)||"unknown-instance-id";return"".concat(a,":").concat(p,":").concat(r())}return"non-dc-app:".concat(r())}var A={subscribe:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r.onDataReceive,e=void 0===o?n:o,i=window[Symbol.for("socket")]||{},a=i.subscribe,p=i.unsubscribe,c=i.socket;if(!c)return console.error("Socket is not initialized!"),n;var s=j(),u=h(h({},t),{},{collection:t.collection||t.dataset,appInstanceId:s});return a(u),c.on("data",(function(t){return t.appInstanceId===s&&e(t)})),function(){return p(u)}}};export{m as corvaAPI,b as corvaDataAPI,A as socketClient};
