import r from"@babel/runtime/helpers/slicedToArray";import e from"@babel/runtime/helpers/createClass";import t from"@babel/runtime/helpers/classCallCheck";import n from"@babel/runtime/helpers/defineProperty";function i(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function s(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?i(Object(t),!0).forEach((function(e){n(r,e,t[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}))}return r}var o=e((function e(){var i=this;t(this,e),n(this,"getConfiguration",(function(e){var t=null,n=null,s=null,o=!1;e.forEach((function(e){if(e.toLowerCase().startsWith("~version"))o=!0;else if(e.toLowerCase().startsWith("~"))o=!1;else{if(o){var a=e.split(" ").filter(Boolean),l=r(a,3),u=l[0],c=l[1],f=l[2];switch(u){case"VERS.":t=c;break;case"WRAP.":n=c;break;case"DLM":s=f}}i.config={version:t,wrap:n,delimiter:s}}}))})),n(this,"parseHeaders",(function(r){var e=r.split("\n");i.getConfiguration(e);var t=!1;return e.reduce((function(r,e){if(e.toLowerCase().startsWith("~curve"))return t=!0,r;if(e.startsWith("~")&&(t=!1),t&&!e.startsWith("#")&&!e.startsWith("\r")){var n=e.split(" ").filter(Boolean);return n?r.push(n[0]):r}return r}),[])})),n(this,"parseData",(function(r,e,t){var i=r.split("\n"),o=!1;return i.reduce((function(r,i){if(i.toLowerCase().startsWith("~a"))return o=!0,r;if(i.startsWith("~")&&(o=!1),o){var a=i.split(/[\t\s,]/).filter(Boolean).reduce((function(r,i,o){var a=e[o],l=t.find((function(r){return r.parsingKey===a}));if(l){var u=l.innerKey;return s(s({},r),{},n({},u,parseFloat(i,2)))}return r}),{});return a.isEmpty()?r:r.push(a)}return r}),[])})),this.config={version:null,wrap:null,delimiter:null}}));export{o as default};
