nervoscan-js-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ (function(N,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(N=typeof globalThis<"u"?globalThis:N||self,O(N.NervoscanSDK={}))})(this,function(N){"use strict";var On=Object.defineProperty;var An=(N,O,q)=>O in N?On(N,O,{enumerable:!0,configurable:!0,writable:!0,value:q}):N[O]=q;var M=(N,O,q)=>An(N,typeof O!="symbol"?O+"":O,q);function O(e,t){return function(){return e.apply(t,arguments)}}const{toString:q}=Object.prototype,{getPrototypeOf:oe}=Object,v=(e=>t=>{const n=q.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),P=e=>(e=e.toLowerCase(),t=>v(t)===e),W=e=>t=>typeof t===e,{isArray:H}=Array,z=W("undefined");function tt(e){return e!==null&&!z(e)&&e.constructor!==null&&!z(e.constructor)&&C(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const be=P("ArrayBuffer");function nt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&be(e.buffer),t}const rt=W("string"),C=W("function"),Ee=W("number"),X=e=>e!==null&&typeof e=="object",st=e=>e===!0||e===!1,G=e=>{if(v(e)!=="object")return!1;const t=oe(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},ot=P("Date"),it=P("File"),at=P("Blob"),ct=P("FileList"),lt=e=>X(e)&&C(e.pipe),ut=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||C(e.append)&&((t=v(e))==="formdata"||t==="object"&&C(e.toString)&&e.toString()==="[object FormData]"))},ft=P("URLSearchParams"),[dt,pt,ht,mt]=["ReadableStream","Request","Response","Headers"].map(P),yt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function $(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),H(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let c;for(r=0;r<i;r++)c=o[r],t.call(null,e[c],c,e)}}function ge(e,t){t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const U=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Se=e=>!z(e)&&e!==U;function ie(){const{caseless:e}=Se(this)&&this||{},t={},n=(r,s)=>{const o=e&&ge(t,s)||s;G(t[o])&&G(r)?t[o]=ie(t[o],r):G(r)?t[o]=ie({},r):H(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&$(arguments[r],n);return t}const wt=(e,t,n,{allOwnKeys:r}={})=>($(t,(s,o)=>{n&&C(s)?e[o]=O(s,n):e[o]=s},{allOwnKeys:r}),e),bt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Et=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},gt=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&oe(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},St=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},Rt=e=>{if(!e)return null;if(H(e))return e;let t=e.length;if(!Ee(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Tt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&oe(Uint8Array)),Ot=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},At=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},xt=P("HTMLFormElement"),Ct=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Re=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Nt=P("RegExp"),Te=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};$(n,(s,o)=>{let i;(i=t(s,o,e))!==!1&&(r[o]=i||s)}),Object.defineProperties(e,r)},Pt=e=>{Te(e,(t,n)=>{if(C(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(C(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},kt=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return H(e)?r(e):r(String(e).split(t)),n},Ft=()=>{},_t=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Ut(e){return!!(e&&C(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const Bt=e=>{const t=new Array(10),n=(r,s)=>{if(X(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=H(r)?[]:{};return $(r,(i,c)=>{const f=n(i,s+1);!z(f)&&(o[c]=f)}),t[s]=void 0,o}}return r};return n(e,0)},Lt=P("AsyncFunction"),Dt=e=>e&&(X(e)||C(e))&&C(e.then)&&C(e.catch),Oe=((e,t)=>e?setImmediate:t?((n,r)=>(U.addEventListener("message",({source:s,data:o})=>{s===U&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),U.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",C(U.postMessage)),jt=typeof queueMicrotask<"u"?queueMicrotask.bind(U):typeof process<"u"&&process.nextTick||Oe,a={isArray:H,isArrayBuffer:be,isBuffer:tt,isFormData:ut,isArrayBufferView:nt,isString:rt,isNumber:Ee,isBoolean:st,isObject:X,isPlainObject:G,isReadableStream:dt,isRequest:pt,isResponse:ht,isHeaders:mt,isUndefined:z,isDate:ot,isFile:it,isBlob:at,isRegExp:Nt,isFunction:C,isStream:lt,isURLSearchParams:ft,isTypedArray:Tt,isFileList:ct,forEach:$,merge:ie,extend:wt,trim:yt,stripBOM:bt,inherits:Et,toFlatObject:gt,kindOf:v,kindOfTest:P,endsWith:St,toArray:Rt,forEachEntry:Ot,matchAll:At,isHTMLForm:xt,hasOwnProperty:Re,hasOwnProp:Re,reduceDescriptors:Te,freezeMethods:Pt,toObjectSet:kt,toCamelCase:Ct,noop:Ft,toFiniteNumber:_t,findKey:ge,global:U,isContextDefined:Se,isSpecCompliantForm:Ut,toJSONObject:Bt,isAsyncFn:Lt,isThenable:Dt,setImmediate:Oe,asap:jt};function m(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(m,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const Ae=m.prototype,xe={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{xe[e]={value:e}}),Object.defineProperties(m,xe),Object.defineProperty(Ae,"isAxiosError",{value:!0}),m.from=(e,t,n,r,s,o)=>{const i=Object.create(Ae);return a.toFlatObject(e,i,function(f){return f!==Error.prototype},c=>c!=="isAxiosError"),m.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};const qt=null;function ae(e){return a.isPlainObject(e)||a.isArray(e)}function Ce(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Ne(e,t,n){return e?e.concat(t).map(function(s,o){return s=Ce(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Ht(e){return a.isArray(e)&&!e.some(ae)}const It=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function Q(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,h){return!a.isUndefined(h[y])});const r=n.metaTokens,s=n.visitor||u,o=n.dots,i=n.indexes,f=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function l(p){if(p===null)return"";if(a.isDate(p))return p.toISOString();if(!f&&a.isBlob(p))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(p)||a.isTypedArray(p)?f&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function u(p,y,h){let E=p;if(p&&!h&&typeof p=="object"){if(a.endsWith(y,"{}"))y=r?y:y.slice(0,-2),p=JSON.stringify(p);else if(a.isArray(p)&&Ht(p)||(a.isFileList(p)||a.endsWith(y,"[]"))&&(E=a.toArray(p)))return y=Ce(y),E.forEach(function(R,F){!(a.isUndefined(R)||R===null)&&t.append(i===!0?Ne([y],F,o):i===null?y:y+"[]",l(R))}),!1}return ae(p)?!0:(t.append(Ne(h,y,o),l(p)),!1)}const d=[],w=Object.assign(It,{defaultVisitor:u,convertValue:l,isVisitable:ae});function g(p,y){if(!a.isUndefined(p)){if(d.indexOf(p)!==-1)throw Error("Circular reference detected in "+y.join("."));d.push(p),a.forEach(p,function(E,S){(!(a.isUndefined(E)||E===null)&&s.call(t,E,a.isString(S)?S.trim():S,y,w))===!0&&g(E,y?y.concat(S):[S])}),d.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return g(e),t}function Pe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ce(e,t){this._pairs=[],e&&Q(e,this,t)}const ke=ce.prototype;ke.append=function(t,n){this._pairs.push([t,n])},ke.toString=function(t){const n=t?function(r){return t.call(this,r,Pe)}:Pe;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function Mt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Fe(e,t,n){if(!t)return e;const r=n&&n.encode||Mt;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new ce(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class _e{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ue={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},zt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ce,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},le=typeof window<"u"&&typeof document<"u",ue=typeof navigator=="object"&&navigator||void 0,$t=le&&(!ue||["ReactNative","NativeScript","NS"].indexOf(ue.product)<0),Jt=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Vt=le&&window.location.href||"http://localhost",T={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:le,hasStandardBrowserEnv:$t,hasStandardBrowserWebWorkerEnv:Jt,navigator:ue,origin:Vt},Symbol.toStringTag,{value:"Module"})),...zt};function Kt(e,t){return Q(e,new T.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return T.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function vt(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Wt(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function Be(e){function t(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),f=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,f?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=Wt(s[i])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(vt(r),s,n,0)}),n}return null}function Xt(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const J={transitional:Ue,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s?JSON.stringify(Be(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t)||a.isReadableStream(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Kt(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return Q(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),Xt(t)):t}],transformResponse:[function(t){const n=this.transitional||J.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(t)||a.isReadableStream(t))return t;if(t&&a.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?m.from(c,m.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:T.classes.FormData,Blob:T.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{J.headers[e]={}});const Gt=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Qt=e=>{const t={};let n,r,s;return e&&e.split(`
2
+ `).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&Gt[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Le=Symbol("internals");function V(e){return e&&String(e).trim().toLowerCase()}function Z(e){return e===!1||e==null?e:a.isArray(e)?e.map(Z):String(e)}function Zt(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const Yt=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function fe(e,t,n,r,s){if(a.isFunction(r))return r.call(this,t,n);if(s&&(t=n),!!a.isString(t)){if(a.isString(r))return t.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(t)}}function en(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function tn(e,t){const n=a.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}let A=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,f,l){const u=V(f);if(!u)throw new Error("header name must be a non-empty string");const d=a.findKey(s,u);(!d||s[d]===void 0||l===!0||l===void 0&&s[d]!==!1)&&(s[d||f]=Z(c))}const i=(c,f)=>a.forEach(c,(l,u)=>o(l,u,f));if(a.isPlainObject(t)||t instanceof this.constructor)i(t,n);else if(a.isString(t)&&(t=t.trim())&&!Yt(t))i(Qt(t),n);else if(a.isHeaders(t))for(const[c,f]of t.entries())o(f,c,r);else t!=null&&o(n,t,r);return this}get(t,n){if(t=V(t),t){const r=a.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Zt(s);if(a.isFunction(n))return n.call(this,s,r);if(a.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=V(t),t){const r=a.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||fe(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=V(i),i){const c=a.findKey(r,i);c&&(!n||fe(r,r[c],c,n))&&(delete r[c],s=!0)}}return a.isArray(t)?t.forEach(o):o(t),s}clear(t){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const o=n[r];(!t||fe(this,this[o],o,t,!0))&&(delete this[o],s=!0)}return s}normalize(t){const n=this,r={};return a.forEach(this,(s,o)=>{const i=a.findKey(r,o);if(i){n[i]=Z(s),delete n[o];return}const c=t?en(o):String(o).trim();c!==o&&delete n[o],n[c]=Z(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return a.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
3
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[Le]=this[Le]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=V(i);r[c]||(tn(s,i),r[c]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};A.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(A.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),a.freezeMethods(A);function de(e,t){const n=this||J,r=t||n,s=A.from(r.headers);let o=r.data;return a.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function De(e){return!!(e&&e.__CANCEL__)}function I(e,t,n){m.call(this,e??"canceled",m.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(I,m,{__CANCEL__:!0});function je(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new m("Request failed with status code "+n.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function nn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function rn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(f){const l=Date.now(),u=r[o];i||(i=l),n[s]=f,r[s]=l;let d=o,w=0;for(;d!==s;)w+=n[d++],d=d%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),l-i<t)return;const g=u&&l-u;return g?Math.round(w*1e3/g):void 0}}function sn(e,t){let n=0,r=1e3/t,s,o;const i=(l,u=Date.now())=>{n=u,s=null,o&&(clearTimeout(o),o=null),e.apply(null,l)};return[(...l)=>{const u=Date.now(),d=u-n;d>=r?i(l,u):(s=l,o||(o=setTimeout(()=>{o=null,i(s)},r-d)))},()=>s&&i(s)]}const Y=(e,t,n=3)=>{let r=0;const s=rn(50,250);return sn(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,f=i-r,l=s(f),u=i<=c;r=i;const d={loaded:i,total:c,progress:c?i/c:void 0,bytes:f,rate:l||void 0,estimated:l&&c&&u?(c-i)/l:void 0,event:o,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(d)},n)},qe=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},He=e=>(...t)=>a.asap(()=>e(...t)),on=T.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,T.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(T.origin),T.navigator&&/(msie|trident)/i.test(T.navigator.userAgent)):()=>!0,an=T.hasStandardBrowserEnv?{write(e,t,n,r,s,o){const i=[e+"="+encodeURIComponent(t)];a.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),a.isString(r)&&i.push("path="+r),a.isString(s)&&i.push("domain="+s),o===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function cn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function ln(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ie(e,t,n){let r=!cn(t);return e&&(r||n==!1)?ln(e,t):t}const Me=e=>e instanceof A?{...e}:e;function B(e,t){t=t||{};const n={};function r(l,u,d,w){return a.isPlainObject(l)&&a.isPlainObject(u)?a.merge.call({caseless:w},l,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function s(l,u,d,w){if(a.isUndefined(u)){if(!a.isUndefined(l))return r(void 0,l,d,w)}else return r(l,u,d,w)}function o(l,u){if(!a.isUndefined(u))return r(void 0,u)}function i(l,u){if(a.isUndefined(u)){if(!a.isUndefined(l))return r(void 0,l)}else return r(void 0,u)}function c(l,u,d){if(d in t)return r(l,u);if(d in e)return r(void 0,l)}const f={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(l,u,d)=>s(Me(l),Me(u),d,!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(u){const d=f[u]||s,w=d(e[u],t[u],u);a.isUndefined(w)&&d!==c||(n[u]=w)}),n}const ze=e=>{const t=B({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=t;t.headers=i=A.from(i),t.url=Fe(Ie(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let f;if(a.isFormData(n)){if(T.hasStandardBrowserEnv||T.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((f=i.getContentType())!==!1){const[l,...u]=f?f.split(";").map(d=>d.trim()).filter(Boolean):[];i.setContentType([l||"multipart/form-data",...u].join("; "))}}if(T.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(t)),r||r!==!1&&on(t.url))){const l=s&&o&&an.read(o);l&&i.set(s,l)}return t},un=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const s=ze(e);let o=s.data;const i=A.from(s.headers).normalize();let{responseType:c,onUploadProgress:f,onDownloadProgress:l}=s,u,d,w,g,p;function y(){g&&g(),p&&p(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function E(){if(!h)return;const R=A.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),x={data:!c||c==="text"||c==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:R,config:e,request:h};je(function(j){n(j),y()},function(j){r(j),y()},x),h=null}"onloadend"in h?h.onloadend=E:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(E)},h.onabort=function(){h&&(r(new m("Request aborted",m.ECONNABORTED,e,h)),h=null)},h.onerror=function(){r(new m("Network Error",m.ERR_NETWORK,e,h)),h=null},h.ontimeout=function(){let F=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const x=s.transitional||Ue;s.timeoutErrorMessage&&(F=s.timeoutErrorMessage),r(new m(F,x.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,h)),h=null},o===void 0&&i.setContentType(null),"setRequestHeader"in h&&a.forEach(i.toJSON(),function(F,x){h.setRequestHeader(x,F)}),a.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),c&&c!=="json"&&(h.responseType=s.responseType),l&&([w,p]=Y(l,!0),h.addEventListener("progress",w)),f&&h.upload&&([d,g]=Y(f),h.upload.addEventListener("progress",d),h.upload.addEventListener("loadend",g)),(s.cancelToken||s.signal)&&(u=R=>{h&&(r(!R||R.type?new I(null,e,h):R),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const S=nn(s.url);if(S&&T.protocols.indexOf(S)===-1){r(new m("Unsupported protocol "+S+":",m.ERR_BAD_REQUEST,e));return}h.send(o||null)})},fn=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,s;const o=function(l){if(!s){s=!0,c();const u=l instanceof Error?l:this.reason;r.abort(u instanceof m?u:new I(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,o(new m(`timeout ${t} of ms exceeded`,m.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(l=>{l.unsubscribe?l.unsubscribe(o):l.removeEventListener("abort",o)}),e=null)};e.forEach(l=>l.addEventListener("abort",o));const{signal:f}=r;return f.unsubscribe=()=>a.asap(c),f}},dn=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,s;for(;r<n;)s=r+t,yield e.slice(r,s),r=s},pn=async function*(e,t){for await(const n of hn(e))yield*dn(n,t)},hn=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},$e=(e,t,n,r)=>{const s=pn(e,t);let o=0,i,c=f=>{i||(i=!0,r&&r(f))};return new ReadableStream({async pull(f){try{const{done:l,value:u}=await s.next();if(l){c(),f.close();return}let d=u.byteLength;if(n){let w=o+=d;n(w)}f.enqueue(new Uint8Array(u))}catch(l){throw c(l),l}},cancel(f){return c(f),s.return()}},{highWaterMark:2})},ee=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Je=ee&&typeof ReadableStream=="function",mn=ee&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Ve=(e,...t)=>{try{return!!e(...t)}catch{return!1}},yn=Je&&Ve(()=>{let e=!1;const t=new Request(T.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Ke=64*1024,pe=Je&&Ve(()=>a.isReadableStream(new Response("").body)),te={stream:pe&&(e=>e.body)};ee&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!te[t]&&(te[t]=a.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new m(`Response type '${t}' is not supported`,m.ERR_NOT_SUPPORT,r)})})})(new Response);const wn=async e=>{if(e==null)return 0;if(a.isBlob(e))return e.size;if(a.isSpecCompliantForm(e))return(await new Request(T.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(a.isArrayBufferView(e)||a.isArrayBuffer(e))return e.byteLength;if(a.isURLSearchParams(e)&&(e=e+""),a.isString(e))return(await mn(e)).byteLength},bn=async(e,t)=>{const n=a.toFiniteNumber(e.getContentLength());return n??wn(t)},he={http:qt,xhr:un,fetch:ee&&(async e=>{let{url:t,method:n,data:r,signal:s,cancelToken:o,timeout:i,onDownloadProgress:c,onUploadProgress:f,responseType:l,headers:u,withCredentials:d="same-origin",fetchOptions:w}=ze(e);l=l?(l+"").toLowerCase():"text";let g=fn([s,o&&o.toAbortSignal()],i),p;const y=g&&g.unsubscribe&&(()=>{g.unsubscribe()});let h;try{if(f&&yn&&n!=="get"&&n!=="head"&&(h=await bn(u,r))!==0){let x=new Request(t,{method:"POST",body:r,duplex:"half"}),_;if(a.isFormData(r)&&(_=x.headers.get("content-type"))&&u.setContentType(_),x.body){const[j,se]=qe(h,Y(He(f)));r=$e(x.body,Ke,j,se)}}a.isString(d)||(d=d?"include":"omit");const E="credentials"in Request.prototype;p=new Request(t,{...w,signal:g,method:n.toUpperCase(),headers:u.normalize().toJSON(),body:r,duplex:"half",credentials:E?d:void 0});let S=await fetch(p);const R=pe&&(l==="stream"||l==="response");if(pe&&(c||R&&y)){const x={};["status","statusText","headers"].forEach(Ye=>{x[Ye]=S[Ye]});const _=a.toFiniteNumber(S.headers.get("content-length")),[j,se]=c&&qe(_,Y(He(c),!0))||[];S=new Response($e(S.body,Ke,j,()=>{se&&se(),y&&y()}),x)}l=l||"text";let F=await te[a.findKey(te,l)||"text"](S,e);return!R&&y&&y(),await new Promise((x,_)=>{je(x,_,{data:F,headers:A.from(S.headers),status:S.status,statusText:S.statusText,config:e,request:p})})}catch(E){throw y&&y(),E&&E.name==="TypeError"&&/fetch/i.test(E.message)?Object.assign(new m("Network Error",m.ERR_NETWORK,e,p),{cause:E.cause||E}):m.from(E,E&&E.code,e,p)}})};a.forEach(he,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const ve=e=>`- ${e}`,En=e=>a.isFunction(e)||e===null||e===!1,We={getAdapter:e=>{e=a.isArray(e)?e:[e];const{length:t}=e;let n,r;const s={};for(let o=0;o<t;o++){n=e[o];let i;if(r=n,!En(n)&&(r=he[(i=String(n)).toLowerCase()],r===void 0))throw new m(`Unknown adapter '${i}'`);if(r)break;s[i||"#"+o]=r}if(!r){const o=Object.entries(s).map(([c,f])=>`adapter ${c} `+(f===!1?"is not supported by the environment":"is not available in the build"));let i=t?o.length>1?`since :
4
+ `+o.map(ve).join(`
5
+ `):" "+ve(o[0]):"as no adapter specified";throw new m("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return r},adapters:he};function me(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new I(null,e)}function Xe(e){return me(e),e.headers=A.from(e.headers),e.data=de.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),We.getAdapter(e.adapter||J.adapter)(e).then(function(r){return me(e),r.data=de.call(e,e.transformResponse,r),r.headers=A.from(r.headers),r},function(r){return De(r)||(me(e),r&&r.response&&(r.response.data=de.call(e,e.transformResponse,r.response),r.response.headers=A.from(r.response.headers))),Promise.reject(r)})}const Ge="1.8.4",ne={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ne[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Qe={};ne.transitional=function(t,n,r){function s(o,i){return"[Axios v"+Ge+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new m(s(i," has been removed"+(n?" in "+n:"")),m.ERR_DEPRECATED);return n&&!Qe[i]&&(Qe[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}},ne.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function gn(e,t,n){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],f=c===void 0||i(c,o,e);if(f!==!0)throw new m("option "+o+" must be "+f,m.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new m("Unknown option "+o,m.ERR_BAD_OPTION)}}const re={assertOptions:gn,validators:ne},k=re.validators;let L=class{constructor(t){this.defaults=t,this.interceptors={request:new _e,response:new _e}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
+ `+o):r.stack=o}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=B(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&re.assertOptions(r,{silentJSONParsing:k.transitional(k.boolean),forcedJSONParsing:k.transitional(k.boolean),clarifyTimeoutError:k.transitional(k.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:re.assertOptions(s,{encode:k.function,serialize:k.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),re.assertOptions(n,{baseUrl:k.spelling("baseURL"),withXsrfToken:k.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=A.concat(i,o);const c=[];let f=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(n)===!1||(f=f&&y.synchronous,c.unshift(y.fulfilled,y.rejected))});const l=[];this.interceptors.response.forEach(function(y){l.push(y.fulfilled,y.rejected)});let u,d=0,w;if(!f){const p=[Xe.bind(this),void 0];for(p.unshift.apply(p,c),p.push.apply(p,l),w=p.length,u=Promise.resolve(n);d<w;)u=u.then(p[d++],p[d++]);return u}w=c.length;let g=n;for(d=0;d<w;){const p=c[d++],y=c[d++];try{g=p(g)}catch(h){y.call(this,h);break}}try{u=Xe.call(this,g)}catch(p){return Promise.reject(p)}for(d=0,w=l.length;d<w;)u=u.then(l[d++],l[d++]);return u}getUri(t){t=B(this.defaults,t);const n=Ie(t.baseURL,t.url,t.allowAbsoluteUrls);return Fe(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){L.prototype[t]=function(n,r){return this.request(B(r||{},{method:t,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,c){return this.request(B(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}L.prototype[t]=n(),L.prototype[t+"Form"]=n(!0)});let Sn=class et{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new I(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new et(function(s){t=s}),cancel:t}}};function Rn(e){return function(n){return e.apply(null,n)}}function Tn(e){return a.isObject(e)&&e.isAxiosError===!0}const ye={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ye).forEach(([e,t])=>{ye[t]=e});function Ze(e){const t=new L(e),n=O(L.prototype.request,t);return a.extend(n,L.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Ze(B(e,s))},n}const b=Ze(J);b.Axios=L,b.CanceledError=I,b.CancelToken=Sn,b.isCancel=De,b.VERSION=Ge,b.toFormData=Q,b.AxiosError=m,b.Cancel=b.CanceledError,b.all=function(t){return Promise.all(t)},b.spread=Rn,b.isAxiosError=Tn,b.mergeConfig=B,b.AxiosHeaders=A,b.formToJSON=e=>Be(a.isHTMLForm(e)?new FormData(e):e),b.getAdapter=We.getAdapter,b.HttpStatusCode=ye,b.default=b;const{Axios:_n,AxiosError:Un,CanceledError:Bn,isCancel:Ln,CancelToken:Dn,VERSION:jn,all:qn,Cancel:Hn,isAxiosError:In,spread:Mn,toFormData:zn,AxiosHeaders:$n,HttpStatusCode:Jn,formToJSON:Vn,getAdapter:Kn,mergeConfig:vn}=b,K="https://backend.nervoscan.com",D=class D{constructor(){M(this,"username");M(this,"password");M(this,"initialized",!1);M(this,"accessToken")}static getInstance(){return D.instance||(D.instance=new D),D.instance}initialize(t,n){this.initialized=!0,this.username=t,this.password=n}async getStatus(){return"ok"}async getToken(){const n=(await b.post(K.concat("/clientlogin"),{username:this.username,password:this.password})).data.access_token;return localStorage.setItem("accessToken",n),n}async getAPIKey(t){return(await b.post(K.concat("/clientgeturl"),{host_name:"www.nervoscan.com"},{headers:{Authorization:`Bearer ${t}`}})).data.url.split("?api_key=")[1]}async uploadVideoToServer(t,n,r){try{const s=new FormData;return s.append("file",t,"recording.webm"),s.append("data",JSON.stringify({uuid:r,meta_data:{}})),(await b.post(K.concat("/submitscan"),s,{headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${n}`}})).data}catch(s){throw console.error("Error uploading video:",s),s.response?(console.error("Error response:",s.response.data),console.error("Error status:",s.response.status),console.error("Error headers:",s.response.headers)):s.request?console.error("Error request:",s.request):console.error("Error message:",s.message),s}}async uploadVideo(t){if(!this.initialized)throw new Error("Client not initialized!");const n=await this.getToken(),r=await this.getAPIKey(n);return this.uploadVideoToServer(t,n,r),r}async checkResults(t){try{this.accessToken||(this.accessToken=await this.getToken());const s=(await b.post(K.concat("/check"),{api_key:t},{headers:{Authorization:`Bearer ${this.accessToken}`}})).data.job_status;return s==="Completed"||s==="Failed"?s:"Pending"}catch(n){return console.error("Error fetching results:",n),"Error"}}async getResults(t){return this.accessToken||(this.accessToken=await this.getToken()),(await b.post(K.concat("/getcustomerinfo"),{mode:"selection",api_keys:[t]},{headers:{Authorization:`Bearer ${this.accessToken}`}})).data}};M(D,"instance");let we=D;N.Client=we,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "nervoscan-js-sdk",
3
+ "version": "1.0.0",
4
+ "main": "dist/nervoscan-js-sdk.umd.js",
5
+ "module": "dist/nervoscan-js-sdk.mjs",
6
+ "types": "dist/types/index.d.ts",
7
+ "scripts": {
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "build": "vite build",
10
+ "watch": "chokidar 'src/**/*' -c 'npm run build'"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/nervotec/nervoscan-js.git"
15
+ },
16
+ "keywords": [],
17
+ "author": "Nervotec",
18
+ "license": "ISC",
19
+ "bugs": {
20
+ "url": "https://github.com/nervotec/nervoscan-js/issues"
21
+ },
22
+ "homepage": "https://github.com/nervotec/nervoscan-js#readme",
23
+ "description": "",
24
+ "dependencies": {
25
+ "@types/axios": "^0.9.36",
26
+ "axios": "^1.8.4",
27
+ "react": "^19.1.0",
28
+ "react-dom": "^19.1.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^22.14.1",
32
+ "@vitejs/plugin-react": "^4.4.1",
33
+ "typescript": "^5.8.3",
34
+ "vite": "^6.3.2"
35
+ },
36
+ "exports": {
37
+ ".": {
38
+ "import": "./dist/nervoscan-js-sdk.mjs",
39
+ "require": "./dist/nervoscan-js-sdk.umd.js"
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,135 @@
1
+ /// <reference types="vite/client" />
2
+ import axios from 'axios'
3
+
4
+ const backendUrl = import.meta.env.VITE_BACKEND_URL
5
+
6
+ export class Client {
7
+ private static instance: Client;
8
+ private username: string | undefined
9
+ private password: string | undefined
10
+ private initialized: boolean = false
11
+ private accessToken: string | undefined
12
+
13
+ private constructor() {}
14
+
15
+ public static getInstance(): Client {
16
+ if (!Client.instance) {
17
+ Client.instance = new Client();
18
+ }
19
+ return Client.instance;
20
+ }
21
+
22
+ public initialize(username: string, password: string) {
23
+ this.initialized = true
24
+ this.username = username
25
+ this.password = password
26
+ }
27
+
28
+ async getStatus() {
29
+ return 'ok'
30
+ }
31
+
32
+ private async getToken() {
33
+ const response = await axios.post<{ access_token: string }>(backendUrl.concat('/clientlogin'),{username: this.username, password: this.password});
34
+ const accessToken = response.data.access_token;
35
+ localStorage.setItem('accessToken', accessToken);
36
+ return accessToken;
37
+ }
38
+
39
+ private async getAPIKey(accessToken: string) {
40
+ const response = await axios.post<{ url: string }>(backendUrl.concat('/clientgeturl'),{
41
+ "host_name": "www.nervoscan.com"
42
+ },{
43
+ headers: {
44
+ 'Authorization': `Bearer ${accessToken}`,
45
+ },
46
+ });
47
+ const url = response.data.url;
48
+ const apiKey = url.split('?api_key=')[1];
49
+ return apiKey;
50
+ };
51
+
52
+ private async uploadVideoToServer(videoBlob: Blob, accessToken: string, apiKey: string) {
53
+ try {
54
+ const formData = new FormData();
55
+
56
+ formData.append('file', videoBlob, 'recording.webm');
57
+ formData.append(
58
+ 'data',
59
+ JSON.stringify({
60
+ uuid: apiKey,
61
+ meta_data: {},
62
+ })
63
+ );
64
+
65
+ const response = await axios.post(backendUrl.concat('/submitscan'), formData, {
66
+ headers: {
67
+ 'Content-Type': 'multipart/form-data',
68
+ 'Authorization': `Bearer ${accessToken}`,
69
+ },
70
+ });
71
+
72
+ return response.data;
73
+ } catch (error) {
74
+ console.error('Error uploading video:', error);
75
+ if ((error as any).response) {
76
+ console.error('Error response:', (error as any).response.data);
77
+ console.error('Error status:', (error as any).response.status);
78
+ console.error('Error headers:', (error as any).response.headers);
79
+ } else if ((error as any).request) {
80
+ console.error('Error request:', (error as any).request);
81
+ } else {
82
+ console.error('Error message:', (error as Error).message);
83
+ }
84
+ throw error;
85
+ }
86
+ };
87
+
88
+ public async uploadVideo(videoBlob: Blob) {
89
+ if (!this.initialized) {
90
+ throw new Error('Client not initialized!');
91
+ }
92
+ const accessToken = await this.getToken();
93
+ const apiKey = await this.getAPIKey(accessToken);
94
+ const response = this.uploadVideoToServer(videoBlob, accessToken, apiKey);
95
+ return apiKey;
96
+ }
97
+ public async checkResults(jobID: string) {
98
+ try {
99
+ if (!this.accessToken) {
100
+ this.accessToken = await this.getToken();
101
+ }
102
+ const response = await axios.post<{ job_status: string }>(backendUrl.concat('/check'), {api_key: jobID},{
103
+ headers: {
104
+ 'Authorization': `Bearer ${this.accessToken}`,
105
+ },
106
+ });
107
+ const data = response.data;
108
+ const jobStatus = data.job_status;
109
+ if (jobStatus === "Completed" || jobStatus === "Failed") {
110
+ return jobStatus;
111
+ } else {
112
+ return "Pending";
113
+ }
114
+ } catch (error) {
115
+ console.error("Error fetching results:", error);
116
+ return "Error";
117
+ }
118
+ };
119
+
120
+ public async getResults(jobID: string) {
121
+ if (!this.accessToken) {
122
+ this.accessToken = await this.getToken();
123
+ }
124
+ const response = await axios.post(backendUrl.concat('/getcustomerinfo'), {
125
+ "mode": "selection",
126
+ "api_keys": [jobID]
127
+ },{
128
+ headers: {
129
+ 'Authorization': `Bearer ${this.accessToken}`,
130
+ },
131
+ });
132
+ return response.data;
133
+ };
134
+ }
135
+
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { Client } from './api/Client'
package/tsconfig.json ADDED
@@ -0,0 +1,114 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ "jsx": "react-jsx", /* Specify what JSX code is generated. */
17
+ // "libReplacement": true, /* Enable lib replacement. */
18
+ // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
19
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
20
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
21
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
22
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
23
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
24
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
25
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
26
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
27
+
28
+ /* Modules */
29
+ "module": "ESNext", /* Specify what module code is generated. */
30
+ // "rootDir": "./", /* Specify the root folder within your source files. */
31
+ "moduleResolution": "Node", /* Specify how TypeScript looks up a file from a given module specifier. */
32
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
34
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
36
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
37
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
38
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
39
+ // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
40
+ // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
41
+ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
42
+ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
43
+ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
44
+ // "noUncheckedSideEffectImports": true, /* Check side effect imports. */
45
+ // "resolveJsonModule": true, /* Enable importing .json files. */
46
+ // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
47
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
48
+
49
+ /* JavaScript Support */
50
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
51
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
52
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
53
+
54
+ /* Emit */
55
+ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
56
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
57
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
58
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
59
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
60
+ // "noEmit": true, /* Disable emitting files from a compilation. */
61
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
62
+ "outDir": "dist", /* Specify an output folder for all emitted files. */
63
+ // "removeComments": true, /* Disable emitting comments. */
64
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
65
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
66
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
67
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
68
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
69
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
70
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
71
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
72
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
73
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
74
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
75
+ "declarationDir": "dist/types", /* Specify the output directory for generated declaration files. */
76
+
77
+ /* Interop Constraints */
78
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
79
+ // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
80
+ // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
81
+ // "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
82
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
83
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
84
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
85
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
86
+
87
+ /* Type Checking */
88
+ "strict": true, /* Enable all strict type-checking options. */
89
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
90
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
91
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
92
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
93
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
94
+ // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
95
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
96
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
97
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
98
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
99
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
100
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
101
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
102
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
103
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
104
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
105
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
106
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
107
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
108
+
109
+ /* Completeness */
110
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
111
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
112
+ },
113
+ "include": ["src"]
114
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+ import path from 'path'
4
+
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ build: {
8
+ lib: {
9
+ entry: path.resolve(__dirname, 'src/index.ts'),
10
+ name: 'NervoscanSDK',
11
+ fileName: 'nervoscan-js-sdk',
12
+ formats: ['es', 'cjs', 'umd']
13
+ },
14
+ rollupOptions: {
15
+ external: ['react', 'react-dom'],
16
+ output: {
17
+ globals: {
18
+ react: 'React',
19
+ 'react-dom': 'ReactDOM'
20
+ }
21
+ }
22
+ }
23
+ }
24
+ })