needle-cloud 1.3.0 → 1.3.1
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.
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/needle-share-cli/src/web/auth.config.d.ts +6 -0
- package/dist/needle-share-cli/src/web/auth.d.ts +6 -6
- package/dist/needle-share-cli/src/web/index.d.ts +1 -0
- package/dist/web/auth.config.d.ts +6 -0
- package/dist/web/auth.d.ts +6 -6
- package/dist/web/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{Buffer as t}from"buffer";import n,{UserScope as r}from"@logto/browser";globalThis.Buffer=t;var o,i=void 0,s=null,a=null,u=null,l=null,c=new Array;function f(){c.forEach(function(e){try{e()}catch(e){console.error(e)}})}var d={debug:!1,baseUrl:window.location.origin,redirectUri:window.location.origin,postSignOutRedirectUri:window.location.origin,onChanged:function(e){return c.includes(e)||c.push(e),function(){for(;;){var t=c.indexOf(e);if(!(t>=0))break;c.splice(t,1)}}},ready:function(){return a?a.then(function(){return!0}):Promise.reject(new Error("Auth not initialized"))},init:function(e){return a||(a=function(e){try{var t,n=function(){var e=p(!0);if(!e)return d.checkIsAuthenticated().then(function(e){return!e||d.requestUserInfo().then(function(){return!0})});var t=new URL(window.location.href);return t.search=e,window.history.replaceState({},"",t.href),Promise.resolve(!0)};d.debug=(null==e?void 0:e.debug)||!1,d.debug&&console.debug("Auth.init",e),null!=e&&e.appId?(null==(t=l)?void 0:t.logtoConfig.appId)!==(i=e.appId)&&(d.debug&&console.debug("Auth.init","App ID changed, resetting client"),l=null):i="2x82zzh5xuudmiotdy2ux";var r=function(){var e,t=new URL(window.location.href);if(t.searchParams.has("code")&&t.searchParams.has("state")&&null!=(e=t.searchParams.get("iss"))&&e.includes("https://auth.needle.tools/"))return m().handleSignInCallback(t.href).then(function(){var e=new URL(window.location.href);e.pathname=e.pathname.replace("callback",""),e.searchParams.delete("code"),e.searchParams.delete("state"),e.searchParams.delete("iss");var t=p();t&&(console.log("Restore query before login",t,"Current:",e.search),e.search=t),window.history.replaceState({},"",e.href)}).catch(function(e){console.error(e)})}(),o=function(){if(r instanceof Promise)return Promise.resolve(r.then(function(e){return!0})).then(function(){})}();return Promise.resolve(o&&o.then?o.then(n):n())}catch(e){return Promise.reject(e)}}(e))},isAuthenticated:function(){return o},checkIsAuthenticated:function(){return m().isAuthenticated().then(function(e){return o=e,e})},getUserInfo:function(){return s},getUserId:function(){return s?s.sub:null},getName:function(){return s?s.username?s.username:s.name?s.name:s.email?s.email.split("@")[0]:null:null},requestUserInfo:function(){return u||(u=d.checkIsAuthenticated().then(function(e){return e?m().fetchUserInfo().then(function(e){var t;return d.debug&&(null==e?void 0:e.sub)!=(null==(t=s)?void 0:t.sub)&&console.debug("UserInfo",e),s=e,f(),e}).catch(function(e){return console.error(e),s=null,f(),null}):(s=null,f(),null)}))},requestAccessToken:function(e){return d.debug&&console.debug("requestAccessToken",{org_id:e}),e?m().getOrganizationToken(e):m().getAccessToken("https://cloud.needle.tools/api",e||void 0)},signIn:function(){return d.checkIsAuthenticated().then(function(e){if(0==e){var t;if(null==(t=i)||!t.length)throw new Error("App ID is not set: Make sure to call 'init' first");h(),m().signIn(d.redirectUri)}})},signOut:function(){return u=null,d.checkIsAuthenticated().then(function(e){if(1==e){var t;if(null==(t=i)||!t.length)throw new Error("App ID is not set: Make sure to call 'init' first");h(),m().signOut(d.postSignOutRedirectUri)}})}};function h(){sessionStorage.setItem("needle-auth:query",window.location.search)}function p(e){void 0===e&&(e=!0);var t=sessionStorage.getItem("needle-auth:query");return t?(e&&sessionStorage.removeItem("needle-auth:query"),t):""}function m(){if(!l){if(!i)throw new Error("App ID is not set: Make sure to call 'init' first");var e={endpoint:"https://auth.needle.tools/",appId:i,scopes:[r.Profile,r.Email,r.Roles,r.CustomData,r.Organizations,r.OrganizationRoles].concat(["all","read","write","delete","invite","download","create:org","write:org","delete:org","read:accounting","write:accounting","read:usage"]),resources:["https://cloud.needle.tools/api"]};d.debug&&console.debug("Auth client instance not found, creating a new one with scopes:",e.scopes),l=new n(e)}return l}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function v(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return g(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function y(){return y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},y.apply(null,arguments)}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function w(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(w=function(){return!!e})()}function S(e,t){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},S(e,t)}function E(e){var t="function"==typeof Map?new Map:void 0;return E=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(w())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var o=new(e.bind.apply(e,r));return n&&S(o,n.prototype),o}(e,arguments,b(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),S(n,e)},E(e)}function _(){_=function(e,t){return new n(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function n(e,r,o){var i=RegExp(e,r);return t.set(i,o||t.get(e)),S(i,n.prototype)}function r(e,n){var r=t.get(n);return Object.keys(r).reduce(function(t,n){var o=r[n];if("number"==typeof o)t[n]=e[o];else{for(var i=0;void 0===e[o[i]]&&i+1<o.length;)i++;t[n]=e[o[i]]}return t},Object.create(null))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&S(e,t)}(n,RegExp),n.prototype.exec=function(t){var n=e.exec.call(this,t);if(n){n.groups=r(n,this);var o=n.indices;o&&(o.groups=r(o,this))}return n},n.prototype[Symbol.replace]=function(n,o){if("string"==typeof o){var i=t.get(this);return e[Symbol.replace].call(this,n,o.replace(/\$<([^>]+)>/g,function(e,t){var n=i[t];return"$"+(Array.isArray(n)?n.join("$"):n)}))}if("function"==typeof o){var s=this;return e[Symbol.replace].call(this,n,function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(r(e,s)),o.apply(this,e)})}return e[Symbol.replace].call(this,n,o)},_.apply(this,arguments)}var x=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this).addEventListener("click",function(){d.isAuthenticated()?d.signOut():d.signIn()}),t}var n,r;r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,S(n,r);var o=t.prototype;return o.connectedCallback=function(){var e=this;d.init(),this.__update(),this.__unsubscribeOnChange=d.onChanged(function(){e.__update()})},o.disconnectedCallback=function(){var e;null==(e=this.__unsubscribeOnChange)||e.call(this)},o.__update=function(){this.innerHTML=d.isAuthenticated()?"Logout":"Login"},t}(/*#__PURE__*/E(HTMLButtonElement));function T(e){var t={authorization:"Bearer "+e.authToken};return e.org&&(t["x-needle-cloud-org"]=e.org),e.roles&&(t.roles=e.roles.join(",")),e.roles_org&&(t.roles_org=e.roles_org.join(",")),t}customElements.define("needle-login-button",x,{extends:"button"});var O={credentials:"omit"};function P(e,t){return function(){return e.apply(t,arguments)}}const{toString:R}=Object.prototype,{getPrototypeOf:j}=Object,A=(C=Object.create(null),e=>{const t=R.call(e);return C[t]||(C[t]=t.slice(8,-1).toLowerCase())});var C;const U=e=>(e=e.toLowerCase(),t=>A(t)===e),W=e=>t=>typeof t===e,{isArray:k}=Array,z=W("undefined"),F=U("ArrayBuffer"),L=W("string"),N=W("function"),B=W("number"),D=e=>null!==e&&"object"==typeof e,M=e=>{if("object"!==A(e))return!1;const t=j(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},I=U("Date"),q=U("File"),J=U("Blob"),H=U("FileList"),K=U("URLSearchParams"),[V,G,$,X]=["ReadableStream","Request","Response","Headers"].map(U);function Z(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),k(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let s;for(r=0;r<i;r++)s=o[r],t.call(null,e[s],s,e)}}function Q(e,t){t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const Y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,ee=e=>!z(e)&&e!==Y,te=(ne="undefined"!=typeof Uint8Array&&j(Uint8Array),e=>ne&&e instanceof ne);var ne;const re=U("HTMLFormElement"),oe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ie=U("RegExp"),se=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Z(n,(n,o)=>{let i;!1!==(i=t(n,o,e))&&(r[o]=i||n)}),Object.defineProperties(e,r)},ae="abcdefghijklmnopqrstuvwxyz",ue="0123456789",le={DIGIT:ue,ALPHA:ae,ALPHA_DIGIT:ae+ae.toUpperCase()+ue},ce=U("AsyncFunction"),fe=(de="function"==typeof setImmediate,he=N(Y.postMessage),de?setImmediate:he?(pe=`axios@${Math.random()}`,me=[],Y.addEventListener("message",({source:e,data:t})=>{e===Y&&t===pe&&me.length&&me.shift()()},!1),e=>{me.push(e),Y.postMessage(pe,"*")}):e=>setTimeout(e));var de,he,pe,me;const ge="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Y):"undefined"!=typeof process&&process.nextTick||fe;var ve={isArray:k,isArrayBuffer:F,isBuffer:function(e){return null!==e&&!z(e)&&null!==e.constructor&&!z(e.constructor)&&N(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||N(e.append)&&("formdata"===(t=A(e))||"object"===t&&N(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&F(e.buffer),t},isString:L,isNumber:B,isBoolean:e=>!0===e||!1===e,isObject:D,isPlainObject:M,isReadableStream:V,isRequest:G,isResponse:$,isHeaders:X,isUndefined:z,isDate:I,isFile:q,isBlob:J,isRegExp:ie,isFunction:N,isStream:e=>D(e)&&N(e.pipe),isURLSearchParams:K,isTypedArray:te,isFileList:H,forEach:Z,merge:function e(){const{caseless:t}=ee(this)&&this||{},n={},r=(r,o)=>{const i=t&&Q(n,o)||o;n[i]=M(n[i])&&M(r)?e(n[i],r):M(r)?e({},r):k(r)?r.slice():r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&Z(arguments[e],r);return n},extend:(e,t,n,{allOwnKeys:r}={})=>(Z(t,(t,r)=>{e[r]=n&&N(t)?P(t,n):t},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(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)},toFlatObject:(e,t,n,r)=>{let o,i,s;const a={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],r&&!r(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==n&&j(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:A,kindOfTest:U,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length);const r=e.indexOf(t,n-=t.length);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(k(e))return e;let t=e.length;if(!B(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:re,hasOwnProperty:oe,hasOwnProp:oe,reduceDescriptors:se,freezeMethods:e=>{se(e,(t,n)=>{if(N(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;N(e[n])&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return k(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:Q,global:Y,isContextDefined:ee,ALPHABET:le,generateString:(e=16,t=le.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&N(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(D(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const o=k(e)?[]:{};return Z(e,(e,t)=>{const i=n(e,r+1);!z(i)&&(o[t]=i)}),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:ce,isThenable:e=>e&&(D(e)||N(e))&&N(e.then)&&N(e.catch),setImmediate:fe,asap:ge};function ye(e,t,n,r,o){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),o&&(this.response=o)}ve.inherits(ye,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:ve.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const be=ye.prototype,we={};function Se(e){return ve.isPlainObject(e)||ve.isArray(e)}function Ee(e){return ve.endsWith(e,"[]")?e.slice(0,-2):e}function _e(e,t,n){return e?e.concat(t).map(function(e,t){return e=Ee(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}["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=>{we[e]={value:e}}),Object.defineProperties(ye,we),Object.defineProperty(be,"isAxiosError",{value:!0}),ye.from=(e,t,n,r,o,i)=>{const s=Object.create(be);return ve.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e),ye.call(s,e.message,t,n,r,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};const xe=ve.toFlatObject(ve,{},null,function(e){return/^is[A-Z]/.test(e)});function Te(e,t,n){if(!ve.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=ve.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!ve.isUndefined(t[e])})).metaTokens,o=n.visitor||l,i=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&ve.isSpecCompliantForm(t);if(!ve.isFunction(o))throw new TypeError("visitor must be a function");function u(e){if(null===e)return"";if(ve.isDate(e))return e.toISOString();if(!a&&ve.isBlob(e))throw new ye("Blob is not supported. Use a Buffer instead.");return ve.isArrayBuffer(e)||ve.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(ve.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(ve.isArray(e)&&function(e){return ve.isArray(e)&&!e.some(Se)}(e)||(ve.isFileList(e)||ve.endsWith(n,"[]"))&&(a=ve.toArray(e)))return n=Ee(n),a.forEach(function(e,r){!ve.isUndefined(e)&&null!==e&&t.append(!0===s?_e([n],r,i):null===s?n:n+"[]",u(e))}),!1;return!!Se(e)||(t.append(_e(o,n,i),u(e)),!1)}const c=[],f=Object.assign(xe,{defaultVisitor:l,convertValue:u,isVisitable:Se});if(!ve.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!ve.isUndefined(n)){if(-1!==c.indexOf(n))throw Error("Circular reference detected in "+r.join("."));c.push(n),ve.forEach(n,function(n,i){!0===(!(ve.isUndefined(n)||null===n)&&o.call(t,n,ve.isString(i)?i.trim():i,r,f))&&e(n,r?r.concat(i):[i])}),c.pop()}}(e),t}function Oe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Pe(e,t){this._pairs=[],e&&Te(e,this,t)}const Re=Pe.prototype;function je(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Ae(e,t,n){if(!t)return e;const r=n&&n.encode||je,o=n&&n.serialize;let i;if(i=o?o(t,n):ve.isURLSearchParams(t)?t.toString():new Pe(t,n).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}Re.append=function(e,t){this._pairs.push([e,t])},Re.toString=function(e){const t=e?function(t){return e.call(this,t,Oe)}:Oe;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var Ce=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ve.forEach(this.handlers,function(t){null!==t&&e(t)})}},Ue={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},We={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Pe,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ke="undefined"!=typeof window&&"undefined"!=typeof document,ze=(Fe="undefined"!=typeof navigator&&navigator.product,ke&&["ReactNative","NativeScript","NS"].indexOf(Fe)<0);var Fe,Le={__proto__:null,hasBrowserEnv:ke,hasStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,hasStandardBrowserEnv:ze,origin:ke&&window.location.href||"http://localhost",...We};function Ne(e){function t(e,n,r,o){let i=e[o++];if("__proto__"===i)return!0;const s=Number.isFinite(+i),a=o>=e.length;return i=!i&&ve.isArray(r)?r.length:i,a?(r[i]=ve.hasOwnProp(r,i)?[r[i],n]:n,!s):(r[i]&&ve.isObject(r[i])||(r[i]=[]),t(e,n,r[i],o)&&ve.isArray(r[i])&&(r[i]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}(r[i])),!s)}if(ve.isFormData(e)&&ve.isFunction(e.entries)){const n={};return ve.forEachEntry(e,(e,r)=>{t(function(e){return ve.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const Be={transitional:Ue,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=ve.isObject(e);if(o&&ve.isHTMLForm(e)&&(e=new FormData(e)),ve.isFormData(e))return r?JSON.stringify(Ne(e)):e;if(ve.isArrayBuffer(e)||ve.isBuffer(e)||ve.isStream(e)||ve.isFile(e)||ve.isBlob(e)||ve.isReadableStream(e))return e;if(ve.isArrayBufferView(e))return e.buffer;if(ve.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Te(e,new Le.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return Le.isNode&&ve.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((i=ve.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Te(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(ve.isString(e))try{return(0,JSON.parse)(e),ve.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Be.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(ve.isResponse(e)||ve.isReadableStream(e))return e;if(e&&ve.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw ye.from(e,ye.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Le.classes.FormData,Blob:Le.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ve.forEach(["delete","get","head","post","put","patch"],e=>{Be.headers[e]={}});var De=Be;const Me=ve.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"]),Ie=Symbol("internals");function qe(e){return e&&String(e).trim().toLowerCase()}function Je(e){return!1===e||null==e?e:ve.isArray(e)?e.map(Je):String(e)}function He(e,t,n,r,o){return ve.isFunction(r)?r.call(this,t,n):(o&&(t=n),ve.isString(t)?ve.isString(r)?-1!==t.indexOf(r):ve.isRegExp(r)?r.test(t):void 0:void 0)}class Ke{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=qe(t);if(!o)throw new Error("header name must be a non-empty string");const i=ve.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=Je(e))}const i=(e,t)=>ve.forEach(e,(e,n)=>o(e,n,t));if(ve.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(ve.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&Me[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(ve.isHeaders(e))for(const[t,r]of e.entries())o(r,t,n);else null!=e&&o(t,e,n);return this}get(e,t){if(e=qe(e)){const n=ve.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(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}(e);if(ve.isFunction(t))return t.call(this,e,n);if(ve.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=qe(e)){const n=ve.findKey(this,e);return!(!n||void 0===this[n]||t&&!He(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=qe(e)){const o=ve.findKey(n,e);!o||t&&!He(0,n[o],o,t)||(delete n[o],r=!0)}}return ve.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!He(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return ve.forEach(this,(r,o)=>{const i=ve.findKey(n,o);if(i)return t[i]=Je(r),void delete t[o];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();s!==o&&delete t[o],t[s]=Je(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return ve.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&ve.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[Ie]=this[Ie]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=qe(e);t[r]||(function(e,t){const n=ve.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})})}(n,e),t[r]=!0)}return ve.isArray(e)?e.forEach(r):r(e),this}}Ke.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ve.reduceDescriptors(Ke.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),ve.freezeMethods(Ke);var Ve=Ke;function Ge(e,t){const n=this||De,r=t||n,o=Ve.from(r.headers);let i=r.data;return ve.forEach(e,function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function $e(e){return!(!e||!e.__CANCEL__)}function Xe(e,t,n){ye.call(this,null==e?"canceled":e,ye.ERR_CANCELED,t,n),this.name="CanceledError"}function Ze(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new ye("Request failed with status code "+n.status,[ye.ERR_BAD_REQUEST,ye.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}ve.inherits(Xe,ye,{__CANCEL__:!0});const Qe=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,i=0,s=0;return t=void 0!==t?t:1e3,function(a){const u=Date.now(),l=r[s];o||(o=u),n[i]=a,r[i]=u;let c=s,f=0;for(;c!==i;)f+=n[c++],c%=e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),u-o<t)return;const d=l&&u-l;return d?Math.round(1e3*f/d):void 0}}(50,250);return function(e,t){let n,r,o=0,i=1e3/t;const s=(t,i=Date.now())=>{o=i,n=null,r&&(clearTimeout(r),r=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=i?s(e,t):(n=e,r||(r=setTimeout(()=>{r=null,s(n)},i-a)))},()=>n&&s(n)]}(n=>{const i=n.loaded,s=n.lengthComputable?n.total:void 0,a=i-r,u=o(a);r=i,e({loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:u||void 0,estimated:u&&s&&i<=s?(s-i)/u:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})},n)},Ye=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},et=e=>(...t)=>ve.asap(()=>e(...t));var tt=Le.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let n;function r(n){let r=n;return e&&(t.setAttribute("href",r),r=t.href),t.setAttribute("href",r),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return n=r(window.location.href),function(e){const t=ve.isString(e)?r(e):e;return t.protocol===n.protocol&&t.host===n.host}}():function(){return!0},nt=Le.hasStandardBrowserEnv?{write(e,t,n,r,o,i){const s=[e+"="+encodeURIComponent(t)];ve.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),ve.isString(r)&&s.push("path="+r),ve.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.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:()=>null,remove(){}};function rt(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const ot=e=>e instanceof Ve?{...e}:e;function it(e,t){t=t||{};const n={};function r(e,t,n){return ve.isPlainObject(e)&&ve.isPlainObject(t)?ve.merge.call({caseless:n},e,t):ve.isPlainObject(t)?ve.merge({},t):ve.isArray(t)?t.slice():t}function o(e,t,n){return ve.isUndefined(t)?ve.isUndefined(e)?void 0:r(void 0,e,n):r(e,t,n)}function i(e,t){if(!ve.isUndefined(t))return r(void 0,t)}function s(e,t){return ve.isUndefined(t)?ve.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,i){return i in t?r(n,o):i in e?r(void 0,n):void 0}const u={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t)=>o(ot(e),ot(t),!0)};return ve.forEach(Object.keys(Object.assign({},e,t)),function(r){const i=u[r]||o,s=i(e[r],t[r],r);ve.isUndefined(s)&&i!==a||(n[r]=s)}),n}var st=e=>{const t=it({},e);let n,{data:r,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:s,headers:a,auth:u}=t;if(t.headers=a=Ve.from(a),t.url=Ae(rt(t.baseURL,t.url),e.params,e.paramsSerializer),u&&a.set("Authorization","Basic "+btoa((u.username||"")+":"+(u.password?unescape(encodeURIComponent(u.password)):""))),ve.isFormData(r))if(Le.hasStandardBrowserEnv||Le.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(n=a.getContentType())){const[e,...t]=n?n.split(";").map(e=>e.trim()).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(Le.hasStandardBrowserEnv&&(o&&ve.isFunction(o)&&(o=o(t)),o||!1!==o&&tt(t.url))){const e=i&&s&&nt.read(s);e&&a.set(i,e)}return t},at="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=st(e);let o=r.data;const i=Ve.from(r.headers).normalize();let s,a,u,l,c,{responseType:f,onUploadProgress:d,onDownloadProgress:h}=r;function p(){l&&l(),c&&c(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=Ve.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());Ze(function(e){t(e),p()},function(e){n(e),p()},{data:f&&"text"!==f&&"json"!==f?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new ye("Request aborted",ye.ECONNABORTED,e,m)),m=null)},m.onerror=function(){n(new ye("Network Error",ye.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new ye(t,(r.transitional||Ue).clarifyTimeoutError?ye.ETIMEDOUT:ye.ECONNABORTED,e,m)),m=null},void 0===o&&i.setContentType(null),"setRequestHeader"in m&&ve.forEach(i.toJSON(),function(e,t){m.setRequestHeader(t,e)}),ve.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),f&&"json"!==f&&(m.responseType=r.responseType),h&&([u,c]=Qe(h,!0),m.addEventListener("progress",u)),d&&m.upload&&([a,l]=Qe(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",l)),(r.cancelToken||r.signal)&&(s=t=>{m&&(n(!t||t.type?new Xe(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const v=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);v&&-1===Le.protocols.indexOf(v)?n(new ye("Unsupported protocol "+v+":",ye.ERR_BAD_REQUEST,e)):m.send(o||null)})},ut=(e,t)=>{let n,r=new AbortController;const o=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof ye?t:new Xe(t instanceof Error?t.message:t))}};let i=t&&setTimeout(()=>{o(new ye(`timeout ${t} of ms exceeded`,ye.ETIMEDOUT))},t);const s=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(e=>{e&&(e.removeEventListener?e.removeEventListener("abort",o):e.unsubscribe(o))}),e=null)};e.forEach(e=>e&&e.addEventListener&&e.addEventListener("abort",o));const{signal:a}=r;return a.unsubscribe=s,[a,()=>{i&&clearTimeout(i),i=null}]};const lt=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},ct=(e,t,n,r,o)=>{const i=async function*(e,t,n){for await(const r of e)yield*lt(ArrayBuffer.isView(r)?r:await n(String(r)),t)}(e,t,o);let s,a=0,u=e=>{s||(s=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await i.next();if(t)return u(),void e.close();if(n){let e=a+=r.byteLength;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw u(e),e}},cancel:e=>(u(e),i.return())},{highWaterMark:2})},ft="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,dt=ft&&"function"==typeof ReadableStream,ht=ft&&("function"==typeof TextEncoder?(pt=new TextEncoder,e=>pt.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var pt;const mt=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},gt=dt&&mt(()=>{let e=!1;const t=new Request(Le.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),vt=dt&&mt(()=>ve.isReadableStream(new Response("").body)),yt={stream:vt&&(e=>e.body)};var bt;ft&&(bt=new Response,["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!yt[e]&&(yt[e]=ve.isFunction(bt[e])?t=>t[e]():(t,n)=>{throw new ye(`Response type '${e}' is not supported`,ye.ERR_NOT_SUPPORT,n)})}));const wt={http:null,xhr:at,fetch:ft&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:i,timeout:s,onDownloadProgress:a,onUploadProgress:u,responseType:l,headers:c,withCredentials:f="same-origin",fetchOptions:d}=st(e);l=l?(l+"").toLowerCase():"text";let h,p,[m,g]=o||i||s?ut([o,i],s):[];const v=()=>{!h&&setTimeout(()=>{m&&m.unsubscribe()}),h=!0};let y;try{if(u&>&&"get"!==n&&"head"!==n&&0!==(y=await(async(e,t)=>{const n=ve.toFiniteNumber(e.getContentLength());return null==n?(async e=>null==e?0:ve.isBlob(e)?e.size:ve.isSpecCompliantForm(e)?(await new Request(e).arrayBuffer()).byteLength:ve.isArrayBufferView(e)||ve.isArrayBuffer(e)?e.byteLength:(ve.isURLSearchParams(e)&&(e+=""),ve.isString(e)?(await ht(e)).byteLength:void 0))(t):n})(c,r))){let e,n=new Request(t,{method:"POST",body:r,duplex:"half"});if(ve.isFormData(r)&&(e=n.headers.get("content-type"))&&c.setContentType(e),n.body){const[e,t]=Ye(y,Qe(et(u)));r=ct(n.body,65536,e,t,ht)}}ve.isString(f)||(f=f?"include":"omit"),p=new Request(t,{...d,signal:m,method:n.toUpperCase(),headers:c.normalize().toJSON(),body:r,duplex:"half",credentials:f});let o=await fetch(p);const i=vt&&("stream"===l||"response"===l);if(vt&&(a||i)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=o[t]});const t=ve.toFiniteNumber(o.headers.get("content-length")),[n,r]=a&&Ye(t,Qe(et(a),!0))||[];o=new Response(ct(o.body,65536,n,()=>{r&&r(),i&&v()},ht),e)}l=l||"text";let s=await yt[ve.findKey(yt,l)||"text"](o,e);return!i&&v(),g&&g(),await new Promise((t,n)=>{Ze(t,n,{data:s,headers:Ve.from(o.headers),status:o.status,statusText:o.statusText,config:e,request:p})})}catch(t){if(v(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new ye("Network Error",ye.ERR_NETWORK,e,p),{cause:t.cause||t});throw ye.from(t,t&&t.code,e,p)}})};ve.forEach(wt,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const St=e=>`- ${e}`,Et=e=>ve.isFunction(e)||null===e||!1===e;var _t=e=>{e=ve.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let i=0;i<t;i++){let t;if(n=e[i],r=n,!Et(n)&&(r=wt[(t=String(n)).toLowerCase()],void 0===r))throw new ye(`Unknown adapter '${t}'`);if(r)break;o[t||"#"+i]=r}if(!r){const e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new ye("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(St).join("\n"):" "+St(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function xt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Xe(null,e)}function Tt(e){return xt(e),e.headers=Ve.from(e.headers),e.data=Ge.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),_t(e.adapter||De.adapter)(e).then(function(t){return xt(e),t.data=Ge.call(e,e.transformResponse,t),t.headers=Ve.from(t.headers),t},function(t){return $e(t)||(xt(e),t&&t.response&&(t.response.data=Ge.call(e,e.transformResponse,t.response),t.response.headers=Ve.from(t.response.headers))),Promise.reject(t)})}const Ot={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ot[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Pt={};Ot.transitional=function(e,t,n){function r(e,t){return"[Axios v1.7.4] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,i)=>{if(!1===e)throw new ye(r(o," has been removed"+(t?" in "+t:"")),ye.ERR_DEPRECATED);return t&&!Pt[o]&&(Pt[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}};var Rt={assertOptions:function(e,t,n){if("object"!=typeof e)throw new ye("options must be an object",ye.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],s=t[i];if(s){const t=e[i],n=void 0===t||s(t,i,e);if(!0!==n)throw new ye("option "+i+" must be "+n,ye.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new ye("Unknown option "+i,ye.ERR_BAD_OPTION)}},validators:Ot};const jt=Rt.validators;class At{constructor(e){this.defaults=e,this.interceptors={request:new Ce,response:new Ce}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t;Error.captureStackTrace?Error.captureStackTrace(t={}):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=it(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&Rt.assertOptions(n,{silentJSONParsing:jt.transitional(jt.boolean),forcedJSONParsing:jt.transitional(jt.boolean),clarifyTimeoutError:jt.transitional(jt.boolean)},!1),null!=r&&(ve.isFunction(r)?t.paramsSerializer={serialize:r}:Rt.assertOptions(r,{encode:jt.function,serialize:jt.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&ve.merge(o.common,o[t.method]);o&&ve.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=Ve.concat(i,o);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const u=[];let l;this.interceptors.response.forEach(function(e){u.push(e.fulfilled,e.rejected)});let c,f=0;if(!a){const e=[Tt.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,u),c=e.length,l=Promise.resolve(t);f<c;)l=l.then(e[f++],e[f++]);return l}c=s.length;let d=t;for(f=0;f<c;){const e=s[f++],t=s[f++];try{d=e(d)}catch(e){t.call(this,e);break}}try{l=Tt.call(this,d)}catch(e){return Promise.reject(e)}for(f=0,c=u.length;f<c;)l=l.then(u[f++],u[f++]);return l}getUri(e){return Ae(rt((e=it(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}ve.forEach(["delete","get","head","options"],function(e){At.prototype[e]=function(t,n){return this.request(it(n||{},{method:e,url:t,data:(n||{}).data}))}}),ve.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,o){return this.request(it(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}At.prototype[e]=t(),At.prototype[e+"Form"]=t(!0)});var Ct=At;class Ut{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,o){n.reason||(n.reason=new Xe(e,r,o),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;return{token:new Ut(function(t){e=t}),cancel:e}}}var Wt=Ut;const kt={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(kt).forEach(([e,t])=>{kt[t]=e});var zt=kt;const Ft=function e(t){const n=new Ct(t),r=P(Ct.prototype.request,n);return ve.extend(r,Ct.prototype,n,{allOwnKeys:!0}),ve.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(it(t,n))},r}(De);Ft.Axios=Ct,Ft.CanceledError=Xe,Ft.CancelToken=Wt,Ft.isCancel=$e,Ft.VERSION="1.7.4",Ft.toFormData=Te,Ft.AxiosError=ye,Ft.Cancel=Ft.CanceledError,Ft.all=function(e){return Promise.all(e)},Ft.spread=function(e){return function(t){return e.apply(null,t)}},Ft.isAxiosError=function(e){return ve.isObject(e)&&!0===e.isAxiosError},Ft.mergeConfig=it,Ft.AxiosHeaders=Ve,Ft.formToJSON=e=>Ne(ve.isHTMLForm(e)?new FormData(e):e),Ft.getAdapter=_t,Ft.HttpStatusCode=zt,Ft.default=Ft;var Lt=Ft;const{CanceledError:Nt}=Lt;var Bt,Dt,Mt=function(e,t){try{var n=t.baseUrl+"/v1/jobs/update",r=y({},T(t),{job_id:e.identifier,status:e.status});return Promise.resolve(fetch(n,y({},O,{method:"POST",headers:r,body:JSON.stringify({status_message:e.status_message,error:e.error,progress:e.progress})})).catch(function(e){return console.error(e),null})).then(function(e){return!!e&&e.ok})}catch(e){return Promise.reject(e)}},It="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},qt={__proto__:null,default:{}},Jt=(Bt=function(t){!function(){var n="input is invalid type",r="object"==typeof window,o=r?window:{};o.JS_MD5_NO_WINDOW&&(r=!1);var i=!r&&"object"==typeof self,s=!o.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;s?o=It:i&&(o=self);var a,u=!o.JS_MD5_NO_COMMON_JS&&t.exports,l=!o.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,c="0123456789abcdef".split(""),f=[128,32768,8388608,-2147483648],d=[0,8,16,24],h=["hex","array","digest","buffer","arrayBuffer","base64"],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),m=[];if(l){var g=new ArrayBuffer(68);a=new Uint8Array(g),m=new Uint32Array(g)}var v=Array.isArray;!o.JS_MD5_NO_NODE_JS&&v||(v=function(e){return"[object Array]"===Object.prototype.toString.call(e)});var y=ArrayBuffer.isView;!l||!o.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&y||(y=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var b=function(e){var t=typeof e;if("string"===t)return[e,!0];if("object"!==t||null===e)throw new Error(n);if(l&&e.constructor===ArrayBuffer)return[new Uint8Array(e),!1];if(!v(e)&&!y(e))throw new Error(n);return[e,!1]},w=function(e){return function(t){return new E(!0).update(t)[e]()}},S=function(e){return function(t,n){return new _(t,!0).update(n)[e]()}};function E(e){if(e)m[0]=m[16]=m[1]=m[2]=m[3]=m[4]=m[5]=m[6]=m[7]=m[8]=m[9]=m[10]=m[11]=m[12]=m[13]=m[14]=m[15]=0,this.blocks=m,this.buffer8=a;else if(l){var t=new ArrayBuffer(68);this.buffer8=new Uint8Array(t),this.blocks=new Uint32Array(t)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function _(e,t){var n,r=b(e);if(e=r[0],r[1]){var o,i=[],s=e.length,a=0;for(n=0;n<s;++n)(o=e.charCodeAt(n))<128?i[a++]=o:o<2048?(i[a++]=192|o>>>6,i[a++]=128|63&o):o<55296||o>=57344?(i[a++]=224|o>>>12,i[a++]=128|o>>>6&63,i[a++]=128|63&o):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++n)),i[a++]=240|o>>>18,i[a++]=128|o>>>12&63,i[a++]=128|o>>>6&63,i[a++]=128|63&o);e=i}e.length>64&&(e=new E(!0).update(e).array());var u=[],l=[];for(n=0;n<64;++n){var c=e[n]||0;u[n]=92^c,l[n]=54^c}E.call(this,t),this.update(l),this.oKeyPad=u,this.inner=!0,this.sharedMemory=t}E.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");for(var t,n,r=b(e),o=r[1],i=0,s=(e=r[0]).length,a=this.blocks,u=this.buffer8;i<s;){if(this.hashed&&(this.hashed=!1,a[0]=a[16],a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0),o)if(l)for(n=this.start;i<s&&n<64;++i)(t=e.charCodeAt(i))<128?u[n++]=t:t<2048?(u[n++]=192|t>>>6,u[n++]=128|63&t):t<55296||t>=57344?(u[n++]=224|t>>>12,u[n++]=128|t>>>6&63,u[n++]=128|63&t):(t=65536+((1023&t)<<10|1023&e.charCodeAt(++i)),u[n++]=240|t>>>18,u[n++]=128|t>>>12&63,u[n++]=128|t>>>6&63,u[n++]=128|63&t);else for(n=this.start;i<s&&n<64;++i)(t=e.charCodeAt(i))<128?a[n>>>2]|=t<<d[3&n++]:t<2048?(a[n>>>2]|=(192|t>>>6)<<d[3&n++],a[n>>>2]|=(128|63&t)<<d[3&n++]):t<55296||t>=57344?(a[n>>>2]|=(224|t>>>12)<<d[3&n++],a[n>>>2]|=(128|t>>>6&63)<<d[3&n++],a[n>>>2]|=(128|63&t)<<d[3&n++]):(t=65536+((1023&t)<<10|1023&e.charCodeAt(++i)),a[n>>>2]|=(240|t>>>18)<<d[3&n++],a[n>>>2]|=(128|t>>>12&63)<<d[3&n++],a[n>>>2]|=(128|t>>>6&63)<<d[3&n++],a[n>>>2]|=(128|63&t)<<d[3&n++]);else if(l)for(n=this.start;i<s&&n<64;++i)u[n++]=e[i];else for(n=this.start;i<s&&n<64;++i)a[n>>>2]|=e[i]<<d[3&n++];this.lastByteIndex=n,this.bytes+=n-this.start,n>=64?(this.start=n-64,this.hash(),this.hashed=!0):this.start=n}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},E.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[t>>>2]|=f[3&t],t>=56&&(this.hashed||this.hash(),e[0]=e[16],e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.bytes<<3,e[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},E.prototype.hash=function(){var e,t,n,r,o,i,s=this.blocks;this.first?t=((t=((e=((e=s[0]-680876937)<<7|e>>>25)-271733879|0)^(n=((n=(-271733879^(r=((r=(-1732584194^2004318071&e)+s[1]-117830708)<<12|r>>>20)+e|0)&(-271733879^e))+s[2]-1126478375)<<17|n>>>15)+r|0)&(r^e))+s[3]-1316259209)<<22|t>>>10)+n|0:(e=this.h0,t=this.h1,t=((t+=((e=((e+=((r=this.h3)^t&((n=this.h2)^r))+s[0]-680876936)<<7|e>>>25)+t|0)^(n=((n+=(t^(r=((r+=(n^e&(t^n))+s[1]-389564586)<<12|r>>>20)+e|0)&(e^t))+s[2]+606105819)<<17|n>>>15)+r|0)&(r^e))+s[3]-1044525330)<<22|t>>>10)+n|0),t=((t+=((e=((e+=(r^t&(n^r))+s[4]-176418897)<<7|e>>>25)+t|0)^(n=((n+=(t^(r=((r+=(n^e&(t^n))+s[5]+1200080426)<<12|r>>>20)+e|0)&(e^t))+s[6]-1473231341)<<17|n>>>15)+r|0)&(r^e))+s[7]-45705983)<<22|t>>>10)+n|0,t=((t+=((e=((e+=(r^t&(n^r))+s[8]+1770035416)<<7|e>>>25)+t|0)^(n=((n+=(t^(r=((r+=(n^e&(t^n))+s[9]-1958414417)<<12|r>>>20)+e|0)&(e^t))+s[10]-42063)<<17|n>>>15)+r|0)&(r^e))+s[11]-1990404162)<<22|t>>>10)+n|0,t=((t+=((e=((e+=(r^t&(n^r))+s[12]+1804603682)<<7|e>>>25)+t|0)^(n=((n+=(t^(r=((r+=(n^e&(t^n))+s[13]-40341101)<<12|r>>>20)+e|0)&(e^t))+s[14]-1502002290)<<17|n>>>15)+r|0)&(r^e))+s[15]+1236535329)<<22|t>>>10)+n|0,t=((t+=((r=((r+=(t^n&((e=((e+=(n^r&(t^n))+s[1]-165796510)<<5|e>>>27)+t|0)^t))+s[6]-1069501632)<<9|r>>>23)+e|0)^e&((n=((n+=(e^t&(r^e))+s[11]+643717713)<<14|n>>>18)+r|0)^r))+s[0]-373897302)<<20|t>>>12)+n|0,t=((t+=((r=((r+=(t^n&((e=((e+=(n^r&(t^n))+s[5]-701558691)<<5|e>>>27)+t|0)^t))+s[10]+38016083)<<9|r>>>23)+e|0)^e&((n=((n+=(e^t&(r^e))+s[15]-660478335)<<14|n>>>18)+r|0)^r))+s[4]-405537848)<<20|t>>>12)+n|0,t=((t+=((r=((r+=(t^n&((e=((e+=(n^r&(t^n))+s[9]+568446438)<<5|e>>>27)+t|0)^t))+s[14]-1019803690)<<9|r>>>23)+e|0)^e&((n=((n+=(e^t&(r^e))+s[3]-187363961)<<14|n>>>18)+r|0)^r))+s[8]+1163531501)<<20|t>>>12)+n|0,t=((t+=((r=((r+=(t^n&((e=((e+=(n^r&(t^n))+s[13]-1444681467)<<5|e>>>27)+t|0)^t))+s[2]-51403784)<<9|r>>>23)+e|0)^e&((n=((n+=(e^t&(r^e))+s[7]+1735328473)<<14|n>>>18)+r|0)^r))+s[12]-1926607734)<<20|t>>>12)+n|0,t=((t+=((i=(r=((r+=((o=t^n)^(e=((e+=(o^r)+s[5]-378558)<<4|e>>>28)+t|0))+s[8]-2022574463)<<11|r>>>21)+e|0)^e)^(n=((n+=(i^t)+s[11]+1839030562)<<16|n>>>16)+r|0))+s[14]-35309556)<<23|t>>>9)+n|0,t=((t+=((i=(r=((r+=((o=t^n)^(e=((e+=(o^r)+s[1]-1530992060)<<4|e>>>28)+t|0))+s[4]+1272893353)<<11|r>>>21)+e|0)^e)^(n=((n+=(i^t)+s[7]-155497632)<<16|n>>>16)+r|0))+s[10]-1094730640)<<23|t>>>9)+n|0,t=((t+=((i=(r=((r+=((o=t^n)^(e=((e+=(o^r)+s[13]+681279174)<<4|e>>>28)+t|0))+s[0]-358537222)<<11|r>>>21)+e|0)^e)^(n=((n+=(i^t)+s[3]-722521979)<<16|n>>>16)+r|0))+s[6]+76029189)<<23|t>>>9)+n|0,t=((t+=((i=(r=((r+=((o=t^n)^(e=((e+=(o^r)+s[9]-640364487)<<4|e>>>28)+t|0))+s[12]-421815835)<<11|r>>>21)+e|0)^e)^(n=((n+=(i^t)+s[15]+530742520)<<16|n>>>16)+r|0))+s[2]-995338651)<<23|t>>>9)+n|0,t=((t+=((r=((r+=(t^((e=((e+=(n^(t|~r))+s[0]-198630844)<<6|e>>>26)+t|0)|~n))+s[7]+1126891415)<<10|r>>>22)+e|0)^((n=((n+=(e^(r|~t))+s[14]-1416354905)<<15|n>>>17)+r|0)|~e))+s[5]-57434055)<<21|t>>>11)+n|0,t=((t+=((r=((r+=(t^((e=((e+=(n^(t|~r))+s[12]+1700485571)<<6|e>>>26)+t|0)|~n))+s[3]-1894986606)<<10|r>>>22)+e|0)^((n=((n+=(e^(r|~t))+s[10]-1051523)<<15|n>>>17)+r|0)|~e))+s[1]-2054922799)<<21|t>>>11)+n|0,t=((t+=((r=((r+=(t^((e=((e+=(n^(t|~r))+s[8]+1873313359)<<6|e>>>26)+t|0)|~n))+s[15]-30611744)<<10|r>>>22)+e|0)^((n=((n+=(e^(r|~t))+s[6]-1560198380)<<15|n>>>17)+r|0)|~e))+s[13]+1309151649)<<21|t>>>11)+n|0,t=((t+=((r=((r+=(t^((e=((e+=(n^(t|~r))+s[4]-145523070)<<6|e>>>26)+t|0)|~n))+s[11]-1120210379)<<10|r>>>22)+e|0)^((n=((n+=(e^(r|~t))+s[2]+718787259)<<15|n>>>17)+r|0)|~e))+s[9]-343485551)<<21|t>>>11)+n|0,this.first?(this.h0=e+1732584193|0,this.h1=t-271733879|0,this.h2=n-1732584194|0,this.h3=r+271733878|0,this.first=!1):(this.h0=this.h0+e|0,this.h1=this.h1+t|0,this.h2=this.h2+n|0,this.h3=this.h3+r|0)},E.prototype.toString=E.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3;return c[e>>>4&15]+c[15&e]+c[e>>>12&15]+c[e>>>8&15]+c[e>>>20&15]+c[e>>>16&15]+c[e>>>28&15]+c[e>>>24&15]+c[t>>>4&15]+c[15&t]+c[t>>>12&15]+c[t>>>8&15]+c[t>>>20&15]+c[t>>>16&15]+c[t>>>28&15]+c[t>>>24&15]+c[n>>>4&15]+c[15&n]+c[n>>>12&15]+c[n>>>8&15]+c[n>>>20&15]+c[n>>>16&15]+c[n>>>28&15]+c[n>>>24&15]+c[r>>>4&15]+c[15&r]+c[r>>>12&15]+c[r>>>8&15]+c[r>>>20&15]+c[r>>>16&15]+c[r>>>28&15]+c[r>>>24&15]},E.prototype.array=E.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3;return[255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&n,n>>>8&255,n>>>16&255,n>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255]},E.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(16),t=new Uint32Array(e);return t[0]=this.h0,t[1]=this.h1,t[2]=this.h2,t[3]=this.h3,e},E.prototype.buffer=E.prototype.arrayBuffer,E.prototype.base64=function(){for(var e,t,n,r="",o=this.array(),i=0;i<15;)e=o[i++],t=o[i++],n=o[i++],r+=p[e>>>2]+p[63&(e<<4|t>>>4)]+p[63&(t<<2|n>>>6)]+p[63&n];return r+(p[(e=o[i])>>>2]+p[e<<4&63]+"==")},(_.prototype=new E).finalize=function(){if(E.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();E.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(e),E.prototype.finalize.call(this)}};var x=function(){var t=w("hex");s&&(t=function(t){var r,i=qt,s=e.Buffer;return r=s.from&&!o.JS_MD5_NO_BUFFER_FROM?s.from:function(e){return new s(e)},function(e){if("string"==typeof e)return i.createHash("md5").update(e,"utf8").digest("hex");if(null==e)throw new Error(n);return e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),v(e)||y(e)||e.constructor===s?i.createHash("md5").update(r(e)).digest("hex"):t(e)}}(t)),t.create=function(){return new E},t.update=function(e){return t.create().update(e)};for(var r=0;r<h.length;++r){var i=h[r];t[i]=w(i)}return t}();x.md5=x,x.md5.hmac=function(){var e=S("hex");e.create=function(e){return new _(e)},e.update=function(t,n){return e.create(t).update(n)};for(var t=0;t<h.length;++t){var n=h[t];e[n]=S(n)}return e}(),u?t.exports=x:o.md5=x}()},Bt(Dt={exports:{}}),Dt.exports);function Ht(e,t=0){return $t(e,t,2).getUint16(0,!0)}function Kt(e,t=0){return $t(e,t,4).getUint32(0,!0)}function Vt(e,t=0,n=e.byteLength){const r=e.slice(t,t+n);return Xt.decode(new Uint8Array(r))}function Gt(e,t,n=0){if(e.length<t.length+n)return!1;for(const[r,o]of t.entries())if(null!==o&&o!==e[r+n])return!1;return!0}function $t(e,t,n){const r=e.slice(t,t+n);return new DataView(new Uint8Array(r).buffer)}const Xt=new TextDecoder("utf8"),Zt=[["db","application/vnd.sqlite3",[83,81,76,105,116,101,32,102,111,114,109,97,116,32,51,0]],["woff","font/woff",[119,79,70,70]],["woff2","font/woff2",[119,79,70,50]],["bmp","image/bmp",[66,77]],["gif","image/gif",[71,73,70,56,55,97]],["gif","image/gif",[71,73,70,56,57,97]],["heic","image/heic",[102,116,121,112,104,101,105],{offset:4}],["heic","image/heic",[102,116,121,112,109],{offset:4}],["ico","image/x-icon",[0,0,1,0]],["jpg","image/jpeg",[255,216,255]],["pdf","application/pdf",[37,80,68,70,45]],["png","image/png",[137,80,78,71,13,10,26,10]],["7z","application/x-7z-compressed",[55,122,188,175,39,28]],["rar","application/x-rar-compressed",[82,97,114,33,26,7,0]],["rar","application/x-rar-compressed",[82,97,114,33,26,7,1,0]],["rtf","application/rtf",[123,92,114,116,102,49]],["bz2","application/x-bzip2",[66,90,104]],["gz","application/gzip",[31,139]],["tar","application/x-tar",[117,115,116,97,114,0,48,48],{offset:257}],["tar","application/x-tar",[117,115,116,97,114,32,32,0],{offset:257}],["tif","image/tiff",[73,73,42,0]],["tiff","image/tiff",[77,77,0,42]],["zip","application/zip",[80,75,3,4],{exact:!1}],["zip","application/zip",[80,75,5,6]],["mp3","audio/mp3",[255,251]],["mp3","audio/mp3",[255,243]],["mp3","audio/mp3",[255,242]],["mp3","audio/mp3",[73,68,51]],["mp4","video/mp4",[102,116,121,112,105,115,111,109],{offset:4}],["avi","video/x-msvideo",[82,73,70,70,null,null,null,null,65,86,73,32]],["wav","audio/wav",[82,73,70,70,null,null,null,null,87,65,86,69]],["ogx","application/ogg",[79,103,103,83],{exact:!1},[["oga","audio/ogg",[127,70,76,65,67],{offset:28}],["ogg","audio/ogg",[1,118,111,114,98,105,115],{offset:28}],["ogm","video/ogg",[1,118,105,100,101,111,0],{offset:28}],["ogv","video/ogg",[128,116,104,101,111,114,97],{offset:28}]]],["webp","image/webp",[82,73,70,70,null,null,null,null,87,69,66,80]],["psd","image/vnd.adobe.photoshop",[56,66,80,83]],["flac","audio/x-flac",[102,76,97,67]],["wasm","application/wasm",[0,97,115,109]],["deb","application/x-deb",[33,60,97,114,99,104,62,10]],["exe","application/x-msdownload",[77,90]],["exe","application/x-msdownload",[90,77]],["class","application/java-vm",[202,254,186,190]]];function Qt(e){return e.flatMap(([e,t,n,r={},o=[]])=>[[e,t,n,r],...o])}function Yt(e,t){const n=Ht(e,26),r=Vt(e,30,n),[o]=r.split("/"),i=r.endsWith(".xml");return"META-INF"===o?{ext:"jar",mime:"application/java-archive"}:"ppt"===o&&i?{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}:"word"===o&&i?{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}:"xl"===o&&i?{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}:"mimetype"===o?function(e,t){const n=Kt(e,18),r=Kt(e,22),o=Ht(e,28);if(n===r){const r=Vt(e,30+t+o,n);if("application/vnd.oasis.opendocument.presentation"===r)return{ext:"odp",mime:r};if("application/vnd.oasis.opendocument.spreadsheet"===r)return{ext:"ods",mime:r};if("application/vnd.oasis.opendocument.text"===r)return{ext:"odt",mime:r};if("application/epub+zip"===r)return{ext:"epub",mime:r}}}(e,n)??t:t}const en=function(e){return Qt(e).map(([e,t,n,{offset:r=0}={}])=>n.length+r).reduce((e,t)=>t>e?t:e,0)}(Zt);function tn(e,t){for(const[n,r,o,{exact:i=!0,offset:s=0}={},a=[]]of t)if(Gt(e,o,s)){if("zip"===n&&!i)return Yt(e.buffer,{ext:n,mime:r});if(!i&&a.length)for(const[t,n,r,{offset:o=0}={}]of a)if(Gt(e,r,o))return{ext:t,mime:n};return{ext:n,mime:r}}}function nn(e){var t=Jt.md5.create();return t.update(e),t.base64()}function rn(e,t){void 0===t&&(t=void 0);var n=function(e,{extra:t=!1,hint:n}={}){const r=new Uint8Array(e.slice(0,en));if(n){const e=function(e,{ext:t,mime:n}){return t||n?Qt(e).filter(e=>e[0]===t||e[1]===n):[]}(Zt,n);if(e.length>0){const t=tn(r,e);if(void 0!==t)return t}}return tn(r,Zt)||(t?function(e){return function(e){try{const t=Vt(e);if(!function(e){for(let t=0;t<e.length;t++)try{const n=e.charCodeAt(t);if(65533===n||n<=8)return!1}catch{return!1}return!0}(t))return;try{return JSON.parse(t),{ext:"json",mime:"application/json"}}catch{return{ext:"txt",mime:"text/plain"}}}catch{return}}(e)}(e):void 0)}(e);if(n)return n.mime;for(var r=new Uint8Array(e).subarray(0,4),o="",i=0;i<r.length;i++)o+=r[i].toString(16);var s="unknown";switch(o){case"676c5446":s="model/gltf-binary";break;case"89504e47":s="image/png";break;case"ffd8ffe0":case"ffd8ffe1":case"ffd8ffe2":case"ffd8ffe3":case"ffd8ffe8":s="image/jpeg";break;default:s="unknown"}return"unknown"===s&&"string"==typeof t&&(s=on(t)),s}function on(e){var t=e.toLowerCase(),n="";return t.endsWith(".html")||t.endsWith(".html.gz")?n="text/html":t.endsWith(".js")||t.endsWith(".js.gz")?n="application/javascript":t.endsWith(".wasm")?n="application/wasm":t.endsWith(".css")?n="text/css":t.endsWith(".json")?n="application/json":t.endsWith(".txt")?n="text/plain":t.endsWith(".bin")?n="application/octet-stream":t.endsWith(".png")?n="image/png":t.endsWith(".jpg")||t.endsWith(".jpeg")?n="image/jpeg":t.endsWith(".gif")?n="image/gif":t.endsWith(".webp")?n="image/webp":t.endsWith(".svg")?n="image/svg+xml":t.endsWith(".glb")?n="model/gltf-binary":t.endsWith(".gltf")?n="model/gltf+json":t.endsWith(".vrm")?n="model/gltf-binary":t.endsWith(".usdz")?n="model/vnd.usdz+zip":t.endsWith(".usda")?n="model/vnd.usd-usda":t.endsWith(".usdc")?n="model/vnd.usd-usdc":t.endsWith(".usd")?n="model/vnd.usd-usd":t.endsWith(".mtl")?n="model/mtl":t.endsWith(".obj")?n="model/obj":t.endsWith(".fbx")?n="model/vnd.autodesk.fbx":t.endsWith(".stl")&&(n="model/stl"),n}function sn(e,t,n){void 0===t&&(t=void 0),void 0===n&&(n=!0);var r=Math.abs(e);if(r>=1099511627776){var o=n?" TB":"";return(e/1099511627776).toFixed(void 0===t?2:t)+o}if(r>=1073741824){var i=n?" GB":"";return(e/1073741824).toFixed(void 0===t?2:t)+i}if(r>=1048576){var s=n?" MB":"";return(e/1048576).toFixed(void 0===t?1:t)+s}if(r>=1024){var a=n?" KB":"";return(e/1024).toFixed(void 0===t?0:t)+a}var u=n?" B":"";return e.toFixed(0)+u}"undefined"==typeof Symbol||Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"));var an=function(e){try{return Promise.resolve(new Promise(function(t){return setTimeout(t,e)}))}catch(e){return Promise.reject(e)}},un=/*#__PURE__*/_(/^image_(\d+)_|^mesh_lod_(\d+)_/,{image_lod:1,mesh_lod:2});function ln(e,t,n){if(!e.s){if(n instanceof cn){if(!n.s)return void(n.o=ln.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(ln.bind(null,e,t),ln.bind(null,e,2));e.s=t,e.v=n;const r=e.o;r&&r(e)}}var cn=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var i=1&o?t:n;if(i){try{ln(r,1,i(this.v))}catch(e){ln(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?ln(r,1,t?t(o):o):n?ln(r,1,n(o)):ln(r,2,o)}catch(e){ln(r,2,e)}},r},e}();function fn(e){return e instanceof cn&&1&e.s}function dn(e){return e.includes("\\u")?JSON.parse('"'+e+'"'):decodeURIComponent(e)}function hn(e){for(var t=-1,n=Infinity,r=0;r<e.length;r++){var o=e[r];o.path.split("/").length<n&&(n=o.path.split("/").length,t=r)}return t<0?null:e[t]}var pn=/*#__PURE__*/function(){function e(e,t){this.totalFiles=e,this.estimatedTotalSize=t,this.uploadedSize=0,this.startTime=Date.now(),this.lastUpdateTime=this.startTime,this.lastUploadedSize=0,this.speedEMA=null,this.emaFactor=.1,this.smoothedRemainingTime=null,this.recentSpeeds=new Array,this.maxRecentSpeeds=20,this.initialEstimateThreshold=.05}var t=e.prototype;return t.updateProgress=function(e){var t=Date.now(),n=(t-this.lastUpdateTime)/1e3,r=e-this.lastUploadedSize;if(this.uploadedSize=e,n>0&&r>0){this.recentSpeeds.push(r/n),this.recentSpeeds.length>this.maxRecentSpeeds&&this.recentSpeeds.shift();var o=this.recentSpeeds.reduce(function(e,t){return e+t},0)/this.recentSpeeds.length;this.speedEMA=null===this.speedEMA?o:this.emaFactor*o+(1-this.emaFactor)*this.speedEMA}this.lastUpdateTime=t,this.lastUploadedSize=e;var i,s=this.uploadedSize/this.estimatedTotalSize,a=(t-this.startTime)/1e3,u=this.speedEMA&&this.speedEMA>0?this.speedEMA:this.uploadedSize/a;return i=u>0?(this.estimatedTotalSize-this.uploadedSize)/u:Infinity,this.smoothedRemainingTime=s>=this.initialEstimateThreshold?null===this.smoothedRemainingTime?i:.9*this.smoothedRemainingTime+.1*i:a/s-a,this.smoothedRemainingTime=Math.max(this.smoothedRemainingTime,(this.estimatedTotalSize-this.uploadedSize)/u),{progress:100*s,estimatedTimeRemaining:Math.round(this.smoothedRemainingTime),estimatedTimeRemainingString:this.smoothedRemainingTime>3?this.__formatTime(this.smoothedRemainingTime):"few seconds"}},t.__formatTime=function(e){if(!isFinite(e)||e>86400)return"Calculating...";if(e<60)return Math.round(e)+"sec";var t=Math.floor(e/60);return t<60?t+"min":Math.floor(t/60)+"h "+t%60+"min"},e}();function mn(e,t,n){if(!e.s){if(n instanceof gn){if(!n.s)return void(n.o=mn.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(mn.bind(null,e,t),mn.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}"undefined"==typeof Symbol||Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"));var gn=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var i=1&o?t:n;if(i){try{mn(r,1,i(this.v))}catch(e){mn(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?mn(r,1,t?t(o):o):n?mn(r,1,n(o)):mn(r,2,o)}catch(e){mn(r,2,e)}},r},e}();function vn(e){return e instanceof gn&&1&e.s}function yn(e,t,n){var r,o,i=-1;return function s(a){try{for(;++i<e.length&&(!n||!n());)if((a=t(i))&&a.then){if(!vn(a))return void a.then(s,o||(o=mn.bind(null,r=new gn,2)));a=a.v}r?mn(r,1,a):r=a}catch(e){mn(r||(r=new gn),2,e)}}(),r}function bn(e,t,n){for(var r;;){var o=e();if(vn(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!vn(i)){r=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!vn(s)){r=2;break}}}var a=new gn,u=mn.bind(null,a,2);return(0===r?o.then(c):1===r?i.then(l):s.then(f)).then(void 0,u),a;function l(r){i=r;do{if(t&&(s=t())&&s.then&&!vn(s))return void s.then(f).then(void 0,u);if(!(o=e())||vn(o)&&!o.v)return void mn(a,1,i);if(o.then)return void o.then(c).then(void 0,u);vn(i=n())&&(i=i.v)}while(!i||!i.then);i.then(l).then(void 0,u)}function c(e){e?(i=n())&&i.then?i.then(l).then(void 0,u):l(i):mn(a,1,i)}function f(){(o=e())?o.then?o.then(c).then(void 0,u):c(o):mn(a,1,i)}}var wn=[];new Array;var Sn=function(e){try{return Promise.resolve(d.requestAccessToken(e).then(function(t){return{authToken:t,org:e||void 0}}))}catch(e){return Promise.reject(e)}},En=function(e,t){try{return Promise.resolve(Sn(t.org)).then(function(n){if(!n)throw new Error("Not authenticated");var r=e.map(function(e){return function(e,t){if(void 0===t&&(t=null),"object"==typeof(r=e)&&"string"==typeof r.name&&"string"==typeof r.mimetype){var n=e.mimetype||on(e.name);e=new File([e.buffer],e.name,{type:n})}else e.type||(e=new File([e],e.name,{type:on(e.name)}));var r,o=e;return null==t&&(t=e.webkitRelativePath||""),o.path=t+e.name,o}(e)});return function(e,t,n){void 0===n&&(n=void 0);try{var r=function(e,t,n){void 0===n&&(n=void 0);try{var r,o=t.files,i=(null==(r=n)?void 0:r.loglevel)||"none";if(!o.length)return"none"!=i&&console.error("No files to upload"),Promise.resolve({success:!1,error:"No files to upload"});if(!t.entrypoint){var s=function(e){var t=null,n="",r=e.filter(function(e){return"index.html"===e.name.toLowerCase()||"index.html.gz"===e.name.toLowerCase()||"index.html.br"===e.name.toLowerCase()});if(1===r.length)return r[0];var o=e.filter(function(e){return e.name.toLowerCase().endsWith(".html")||e.name.toLowerCase().endsWith(".htm")||e.name.toLowerCase().endsWith(".html.gz")||e.name.toLowerCase().endsWith(".html.br")});if(1===o.length)return o[0];if(o.length>1){for(var i,s=new Map,a=v(o);!(i=a()).done;){var u=i.value,l=u.path.split("/"),c=s.get(l.length);c||s.set(l.length,c=[]),c.push(u)}var f=Array.from(s.keys()).sort(function(e,t){return e-t});if(f.length>0)for(var d,h=v(f);!(d=h()).done;){var p=s.get(d.value);if(p)return p.find(function(e){return"index.html"===e.name.toLowerCase()||"index.html.gz"===e.name.toLowerCase()||"index.html.br"===e.name.toLowerCase()})||p[0]}return n="Invalid upload: Multiple HTML files found but could not determine root.",console.error(n,o.map(function(e){return e.path||e.name})),{error:n}}var m=e.filter(function(e){return e.name.toLowerCase().endsWith(".glb")||e.name.toLowerCase().endsWith(".gltf")||e.name.toLowerCase().endsWith(".vrm")});if(m.length>1){var g=function(e){for(var t,n=new Array,r=/(mesh_lod|image)_\d_(.{1,50})/,o=v(e);!(t=o()).done;){var i=t.value;if(!r.test(i.name)){var s=i.name.toLowerCase();(s.endsWith(".gltf")||s.endsWith(".vrm")||s.endsWith(".glb"))&&n.push(i)}}return 1==n.length?n[0]:hn(n)}(m);return g?t=g:(n="Invalid upload: Multiple glb/glTF/vrm files found. This is currently not supported.",console.error(n,m.map(function(e){return e.path||e.name})),{error:n})}if(1===m.length)return m[0];var y=e.filter(function(e){return e.name.toLowerCase().endsWith(".usdz")||e.name.toLowerCase().endsWith(".usd")||e.name.toLowerCase().endsWith(".usda")||e.name.toLowerCase().endsWith(".usdc")});y.length>=1&&(t=hn(y));var b=e.filter(function(e){return e.name.toLowerCase().endsWith(".fbx")});if(b.length>1)return n="Invalid upload: Multiple fbx files found. This is currently not supported.",console.error(n,b),{error:n};if(1===b.length)return b[0];var w=e.filter(function(e){return e.name.toLowerCase().endsWith(".obj")});if(w.length>1)return n="Invalid upload: Multiple obj files found. This is currently not supported.",console.error(n,w),{error:n};if(1===w.length)return w[0];var S=e.filter(function(e){return e.name.toLowerCase().endsWith(".stl")});if(S.length>1)return n="Invalid upload: Multiple stl files found. This is currently not supported.",console.error(n,S),{error:n};if(1===S.length)return S[0];if(1===e.length&&!e[0].arrayBuffer&&e[0].path.toLowerCase().startsWith("http"))return e[0];var E=e.filter(function(e){return e.name.toLowerCase().endsWith("package.json")});return 1===E.length?t=E[0]:E.length>1?(n="Invalid upload: Multiple package.json files found. This is currently not supported.",console.error(n,E),{error:n}):t||{error:"No supported file to upload found..."}}(o);if(null==s)return Promise.resolve({success:!1,error:"No entrypoint file found"});if("object"==typeof s&&"error"in s)return Promise.resolve({success:!1,error:s.error});"info"===i&&console.log("Entrypoint: "+s.name),t.entrypoint=s}return t.entrypoint&&!o.includes(t.entrypoint)&&o.push(t.entrypoint),Promise.resolve(function(e){try{var t,n=function(e){return t?e:{success:!0,vrm_count:o,gltf_count:i,glb_count:s}};if(e.length>5e3)return Promise.resolve({success:!1,error:"Too many files. Maximum filecount is 5000"});var r=0,o=0,i=0,s=0,a=e.length-1,u=function(e,t,n){for(var r;;){var o=e();if(fn(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!fn(i)){r=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!fn(s)){r=2;break}}}var a=new cn,u=ln.bind(null,a,2);return(0===r?o.then(c):1===r?i.then(l):s.then(f)).then(void 0,u),a;function l(r){i=r;do{if(t&&(s=t())&&s.then&&!fn(s))return void s.then(f).then(void 0,u);if(!(o=e())||fn(o)&&!o.v)return void ln(a,1,i);if(o.then)return void o.then(c).then(void 0,u);fn(i=n())&&(i=i.v)}while(!i||!i.then);i.then(l).then(void 0,u)}function c(e){e?(i=n())&&i.then?i.then(l).then(void 0,u):l(i):ln(a,1,i)}function f(){(o=e())?o.then?o.then(c).then(void 0,u):c(o):ln(a,1,i)}}(function(){return!t&&a>=0},function(){return a--},function(){var n=e[a];if((r+=n.size)>1073741824){var u={success:!1,error:"Total file size exceeds limit of "+1024..toFixed(0)+" MB. Please reduce the size of your upload."};return t=1,u}var l,c=n.name.toLocaleLowerCase();if(".ds_store"!==c)return c.endsWith(".gltf")?i++:c.endsWith(".glb")?(l=c)&&un.test(l)||s++:c.endsWith(".vrm")&&o++,function(){if(c.endsWith(".gltf"))return i+=1,console.log("Found glTF file "+n.name+". Will check if all dependencies are available\n",e),Promise.resolve(n.text()).then(function(r){var o,i=r.matchAll(/*#__PURE__*/_(/"uri"\s*:\s*"(.*?)"/g,{value:1}));if(i){var s=JSON.parse(r);if("2.0"!==s.asset.version)return console.warn("⚠ glTF version is not 2.0. This is currently not supported."),t=1,{success:!1,error:"glTF version "+s.asset.version+" is unsupported.Please use glTF 2.0."};for(var a,u=null==(o=n.path)?void 0:o.split("/"),l=u.splice(0,u.length-1).join("/"),c=v(i);!(a=c()).done;){var f,d=null==(f=a.value.groups)?void 0:f.value;if(d){var h=!1;if(d.startsWith("http://")||d.startsWith("https://")||d.startsWith("www.")){console.log("✅ Found remote dependency "+d+" ");break}if(d.startsWith("data:")){console.log("✅ Found embedded dependency "+d+" ");break}var p=(l+"/"+dn(d)).split("/").reduce(function(e,t){return"."===t||(".."===t?e.pop():null!=t&&t.length&&e.push(t)),e},[]).join("/");console.log('❓ Check if local dependency exists "'+p+'"');for(var m,g=v(e);!(m=g()).done;){var y=m.value;if(y.webkitRelativePath===p||y.name==p){h=!0,console.log("✅ Found dependency in name or webkit: "+y.name+" || "+y.webkitRelativePath+" ");break}if(y.path===p){h=!0,console.log("✅ Found dependency in path: "+y.path+" ");break}}if(!h)return console.warn("⚠ Missing dependency "+d,l),t=1,{success:!1,error:"Missing resource: "+d}}}}})}();e.splice(a,1)});return Promise.resolve(u&&u.then?u.then(n):n(u))}catch(e){return Promise.reject(e)}}(o)).then(function(r){var s,a,u,l,c;function f(r){var s,a,u,l,f,d;if(c)return r;function h(r){return Promise.resolve(fetch(p+"/v1/upload/request",y({},O,{method:"POST",headers:g,body:JSON.stringify(v)})).catch(function(e){return"fetch failed"==e.message||"Failed to fetch"==e.message?"Network error. Make sure you are connected to the internet and "+p+" is reachable.":(console.error("Failed to begin upload\n",e),null)})).then(function(r){var s;function a(a){return s?a:Promise.resolve(r.json()).then(function(r){var s,a,u;function l(){return Promise.resolve(Promise.all(_).catch(function(e){var t;null!=(t=n)&&null!=(t=t.abort)&&t.aborted?console.warn("Upload aborted"):(console.error(e.message),x=!0)})).then(function(){var t;function s(s){var a;if(t)return s;function u(t){var n;if(a)return t;function s(){var e;function t(t){return e?t:("none"!=i&&console.log("Upload complete"),Promise.resolve(l.json()).then(function(e){return{success:!0,type:e.type,uploadSkipped:!1,id:e.id,view_id:e.view_id,url:e.url,filesUploaded:o.length,totalSize:c}}))}if(!l)return console.error("Failed to complete upload"),{success:!1,error:"Failed to complete upload"};var n=function(){if(!l.ok)return 524===l.status?(console.error("Failed to complete upload: Gateway Timeout"),e=1,{success:!1,error:"Failed to complete upload: Gateway Timeout"}):Promise.resolve(l.text()).then(function(t){return console.error("Failed to complete upload ("+l.status+"): "+t),e=1,{success:!1,error:"Failed to complete upload"}})}();return n&&n.then?n.then(t):t(n)}h=!0,console.log("Upload Done: All files uploaded to "+r.id);var u=y({},T(e),{id:r.id});"none"!=i&&console.log("Completing upload - notify server");var l=null,f=0,d=bn(function(){return!n&&f<5},function(){return f++},function(){return Promise.resolve(an(1e3*f)).then(function(){var e=AbortSignal.timeout(2e4+1e3*f);return Promise.resolve(fetch(p+"/v1/upload/done",y({},O,{method:"POST",headers:u,signal:e})).catch(function(e){return console.error("Failed to complete upload ("+(f+1)+" / 5)",e.message),null})).then(function(e){var t,r;!0!==(null==(t=l=e)?void 0:t.ok)?"none"!=i&&f<4&&console.warn("Failed to complete upload ("+((null==(r=l)?void 0:r.status)||"no status")+"): will retry in 1 second"):n=1})})});return d&&d.then?d.then(s):s()}var l=function(t){if(null!=(t=n)&&null!=(t=t.abort)&&t.aborted)return Promise.resolve(Mt({identifier:r.id,status:"canceled",status_message:"Upload aborted",error:"Upload aborted"},e)).then(function(){return a=1,{success:!1,error:"Upload aborted"}})}();return l&&l.then?l.then(u):u(l)}var a=function(){if(x)return Promise.resolve(Mt({identifier:r.id,status:"failed",error:"Failed to upload files"},e)).then(function(){return t=1,{success:!1,error:"Failed to upload files"}})}();return a&&a.then?a.then(s):s(a)})}"debug"===i&&console.debug("BeginResponse",r);var c=o.reduce(function(e,t){return e+t.size},0);if("exists"===r.type)return"none"!=i&&console.log("Upload already exists",r.id),{success:!0,uploadSkipped:!0,id:r.id,type:r.job_type,view_id:r.view_id,filesUploaded:o.length,totalSize:c,url:r.url};var f=t.entrypoint.webkitRelativePath||t.entrypoint.name,d=0;null==(s=n)||null==(s=s.abort)||s.addEventListener("abort",function(){try{return console.log("Upload aborted: Cancelling upload"),Promise.resolve(fetch(p+"/v1/upload/cancel",y({},O,{method:"POST",headers:{authorization:m,id:r.id}}))).then(function(){})}catch(e){return Promise.reject(e)}});var h=!1;function g(t,n,o){if(void 0===o&&(o=!1),!o&&Date.now()-w<1e3)return!1;if(!h||"completed"===n){w=Date.now();var s=Math.floor(d/c*100);return"debug"===i&&console.log("SET STATUS: "+n,t,s),Mt({identifier:r.id,status:n,status_message:t,progress:s},e),!0}"none"!=i&&console.warn("Invalid status update...")}var w=Date.now();null!=(a=n)&&a.onStart&&n.onStart(r.id,r.view_id);var S=Date.now(),E=new pn(o.length,c/1024/1024),_=new Array,x=!1,P=[].concat(o),R=o.length,j=yn(P,function(s){var a;if(null!=(a=n)&&null!=(a=a.abort)&&a.aborted)return console.debug("Upload aborted"),void(u=1);if(x)return console.debug("Upload failed"),void(u=1);if(_.length<10){console.debug("Uploading file "+s+"/"+o.length+": "+o[s].name);var l=0,h=0,p=v.results.files[s],m=p.filename,w=b[s],P=p.content_length,j=p.content_type,A=o[s],C=A.name.endsWith(".gz")?"gzip":A.name.endsWith(".br")?"br":void 0,U=function(e){try{var t,n=function(t){var n;function o(e){var t=function(){if(!h)return console.error("Failed to upload file "+a),Promise.resolve(Mt({identifier:r,status:"failed",status_message:"Failed to upload file "+a,error:"Failed to upload file "+a},v)).then(function(){throw new Error("Failed to upload file "+a)})}();return!t||!t.then||t.then(function(e){return!0})}if(null==x)throw new Error('Failed to get presigned url for "'+a+'" "'+f+'" \n'+P);var i=x.presigned_url,h=!1,S=0,E=bn(function(){return!n&&S<5},function(){return S++},function(){function t(){var t;if(null!=b&&null!=(t=b.abort)&&t.aborted)throw new Nt("Upload aborted");var r={"Content-Type":f,"Content-MD5":l};return w&&(r["Content-Length"]=c.toString()),d&&(r["Content-Encoding"]=d),0===S&&"none"!=g&&console.log("Uploading file "+p+"/"+m+": "+a),"debug"===g&&console.debug("PUT with headers",r),Promise.resolve(Lt.put(i,u,y({},O,{withCredentials:!1,signal:null==b?void 0:b.abort,headers:r,onUploadProgress:function(t){e.onProgress(t)}})).catch(function(e){return e instanceof Nt||("none"!==g&&console.error("Failed to upload file (PUT) ("+p+", "+a+') "'+e.message+'"'),"debug"===g&&(console.log(r,{fileSize:c}),e.response?console.debug(e.response):console.debug(e))),null})).then(function(e){if(e)return 200!==e.status?void console.debug("Failed ("+e.status+" "+e.status+") to upload file "+s.name+' to "'+x.path+'". Retrying...'):(h=!0,"info"===g&&console.log("Uploaded file "+p+"/"+m+' "'+a+'" ('+f+", "+sn(c)+")"),void(n=1))})}var r=function(){if(S>0)return"none"!==g&&console.log("Retry PUT #"+S+" for file "+a),Promise.resolve(an(1e3*S)).then(function(){})}();return r&&r.then?r.then(t):t()});return E&&E.then?E.then(o):o()},r=e.uploadId,o=e.uploadRequestPUTUrl,i=e.entrypointPath,s=e.file,a=e.fileName,u=e.fileBuffer,l=e.fileMd5,c=e.fileSize,f=e.fileType,d=e.content_encoding,h=e.fileIndex,p=e.fileNumber,m=e.fileCount,g=e.loglevel,v=e.args,b=e.options,w=e.experimental;"info"===g&&console.log('Uploading file "'+s.name+'" type='+f+" ("+c+") "+s.type+" with hash "+l);var S=y({},T(v),{"Content-Type":"application/json",org:v.org,job_id:r,filesize:c.toString(),progress:(h/m*100).toFixed(0)}),E={filename:a,entrypoint:i,"content-type":f,"content-md5":l,"content-encoding":d};"debug"===g&&console.debug("Requesting presigned URL with headers",S);var _=JSON.stringify(E),x=null,P="",R=0,j=bn(function(){return!t&&R<5},function(){return R++},function(){var e;if(null==x){if(null!=b&&null!=(e=b.abort)&&e.aborted)throw new Error("Upload aborted");return Promise.resolve(an(200*R)).then(function(){return Promise.resolve(fetch(o,y({},O,{method:"POST",headers:S,body:_})).then(function(e){try{var t,n=function(n){return t?n:Promise.resolve(e.json())},r=function(){if(!e.ok)return Promise.resolve(e.text()).then(function(n){return P=n,console.log(o),console.warn('Failed to get presigned url for "'+a+'" "'+f+'" ('+e.status+").\n→ Retrying..."),t=1,null})}();return Promise.resolve(r&&r.then?r.then(n):n(r))}catch(e){return Promise.reject(e)}}).catch(function(e){return P=e.message,console.warn("Failed to get presigned url "+e.message+", retrying..."),null})).then(function(e){x=e})})}t=1});return Promise.resolve(j&&j.then?j.then(n):n())}catch(e){return Promise.reject(e)}}({uploadId:r.id,uploadRequestPUTUrl:r.request_put_url,entrypointPath:f,file:o[s],fileName:m,fileMd5:p.content_md5,fileBuffer:w,fileType:j,content_encoding:C,fileSize:P,fileIndex:s,fileNumber:s+1,fileCount:R,loglevel:i,experimental:t.experimental,args:e,options:n,onProgress:function(e){var t,r=e.progress||0,i=(l=o[s].size*r)-h;if(h=l,d+=i,null!=(t=n)&&t.progress){var a=d/c,u=o.length,f=o[s].size,p=(Date.now()-S)/1e3,v=E.updateProgress(d/1024/1024);n.progress({uploadedBytes:d,totalBytes:c,progress01:a,fileName:o[s].name,fileSize:f,fileProgress01:r,fileIndex:s,totalFiles:u,estimatedTimeLeftDisplay:v.estimatedTimeRemainingString,estimatedTimeLeft:v.estimatedTimeRemaining,elapsedTime:p}),g("Uploading file "+(s+1)+"/"+u+" ("+m+"): "+(100*r).toFixed(0)+"% of "+sn(c)+". Finished in approx. "+v.estimatedTimeRemainingString,"running",!1)}}}).then(function(e){if(!0!==e)return e;for(var t=_.length-1;t>=0;t--)_[t]===U&&_.splice(t,1);g("Uploaded "+sn(d)+" of "+sn(c)+" for "+o[s].name,"running")}).catch(function(e){var t;null!=(t=n)&&null!=(t=t.abort)&&t.aborted?console.warn("Upload aborted"):(console.error(e.message),x=!0)});_.push(U)}var W=function(){if(_.length>=10)return Promise.resolve(Promise.race(_)).then(function(){})}();return W&&W.then?W.then(function(){}):void 0},function(){return u});return j&&j.then?j.then(l):l()})}if(null===r||"string"==typeof r)return{success:!1,error:r||"Failed to begin upload"};var u=function(){if(!r.ok)return Promise.resolve(r.text()).then(function(e){if(e.startsWith("{")){var t=JSON.parse(e);if("error"in t)return s=1,{success:!1,status:r.status,error:t.error}}return"none"!=i&&console.error("Failed to begin upload\n",r.status,e),s=1,{success:!1,status:r.status,error:""+e}})}();return u&&u.then?u.then(a):a(u)})}o.sort(function(e,t){return e.name.includes(".needle")&&!t.name.includes(".needle")?-1:!e.name.includes(".needle")&&t.name.includes(".needle")?1:0});var p=e.baseUrl,m="Bearer "+e.authToken,g=y({},T(e),{triggered_by:t.triggered_by,filename:""+encodeURIComponent(t.entrypoint.name),"total-files":o.length.toString(),"total-files-size":o.reduce(function(e,t){return e+t.size},0).toString()});null!=(s=n)&&s.view_id&&(g.view_id=n.view_id),null!=(a=n)&&a.type&&(g.type=n.type),null!=(u=n)&&u.name&&(g.name=encodeURIComponent(n.name)),null!=(l=n)&&l.parent_job_id&&(g.parent_job_id=n.parent_job_id);var v={results:{entrypoint:(null==(f=t.entrypoint)?void 0:f.path)||(null==(d=t.entrypoint)?void 0:d.name),files:[]}},b=[],w=yn(o,function(e){var t,r=o[e],i=r.path||r.webkitRelativePath||r.name;if(null!=(t=i)&&t.includes(":"))throw new Error("Invalid filename: "+i);return Promise.resolve(r.arrayBuffer()).then(function(t){var o,s,a,u,l,c=r.size,f=r.type;if(null!=(o=f)&&o.length&&"unknown"!==f.toLowerCase()||(f=rn(t,i)),"deployment"===(null==(s=n)?void 0:s.type)){var d=(u=f,l=(a=i).toLowerCase(),"application/gzip"===u||"application/brotli"===u?(l.endsWith(".html.gz")||l.endsWith(".html.br")?(u="text/html",a=a.substring(0,a.length-3)):l.endsWith(".js.gz")||l.endsWith(".js.br")||l.endsWith(".mjs.gz")||l.endsWith(".mjs.br")||l.endsWith(".cjs.gz")||l.endsWith(".cjs.br")?(u="application/javascript",a=a.substring(0,a.length-3)):l.endsWith(".css.gz")||l.endsWith(".css.br")?(u="text/css",a=a.substring(0,a.length-3)):l.endsWith(".json.gz")||l.endsWith(".json.br")?(u="text/json",a=a.substring(0,a.length-3)):l.endsWith(".txt.gz")||l.endsWith(".txt.br")?(u="text/plain",a=a.substring(0,a.length-3)):l.endsWith(".wasm.gz")||l.endsWith(".wasm.br")?(u="application/wasm",a=a.substring(0,a.length-3)):l.endsWith(".bin.gz")||l.endsWith(".bin.br")?(u="application/octet-stream",a=a.substring(0,a.length-3)):l.endsWith(".png.gz")||l.endsWith(".png.br")?(u="image/png",a=a.substring(0,a.length-3)):l.endsWith(".jpg.gz")||l.endsWith(".jpg.br")||l.endsWith(".jpeg.gz")||l.endsWith(".jpeg.br")?(u="image/jpeg",a=a.substring(0,a.length-3)):l.endsWith(".gif.gz")||l.endsWith(".gif.br")?(u="image/gif",a=a.substring(0,a.length-3)):l.endsWith(".webp.gz")||l.endsWith(".webp.br")?(u="image/webp",a=a.substring(0,a.length-3)):l.endsWith(".svg.gz")||l.endsWith(".svg.br")?(u="image/svg+xml",a=a.substring(0,a.length-3)):l.endsWith(".ico.gz")||l.endsWith(".ico.br")?(u="image/x-icon",a=a.substring(0,a.length-3)):l.endsWith(".webm.gz")||l.endsWith(".webm.br")?(u="video/webm",a=a.substring(0,a.length-3)):l.endsWith(".mp4.gz")||l.endsWith(".mp4.br")?(u="video/mp4",a=a.substring(0,a.length-3)):l.endsWith(".mov.gz")||l.endsWith(".mov.br")?(u="video/quicktime",a=a.substring(0,a.length-3)):l.endsWith(".mp3.gz")||l.endsWith(".mp3.br")?(u="audio/mpeg",a=a.substring(0,a.length-3)):l.endsWith(".wav.gz")||l.endsWith(".wav.br")?(u="audio/wave",a=a.substring(0,a.length-3)):l.endsWith(".ogg.gz")||l.endsWith(".ogg.br")?(u="audio/ogg",a=a.substring(0,a.length-3)):l.endsWith(".flac.gz")||l.endsWith(".flac.br")?(u="audio/flac",a=a.substring(0,a.length-3)):l.endsWith(".glb.gz")||l.endsWith(".glb.br")?(u="model/gltf-binary",a=a.substring(0,a.length-3)):l.endsWith(".gltf.gz")||l.endsWith(".gltf.br")?(u="model/gltf+json",a=a.substring(0,a.length-3)):l.endsWith(".vrm.gz")||l.endsWith(".vrm.br")?(u="model/gltf-binary",a=a.substring(0,a.length-3)):l.endsWith(".usdz.gz")||l.endsWith(".usdz.br")?(u="model/vnd.usdz+zip",a=a.substring(0,a.length-3)):l.endsWith(".obj.gz")||l.endsWith(".obj.br")?(u="model/obj",a=a.substring(0,a.length-3)):(l.endsWith(".mtl.gz")||l.endsWith(".mtl.br"))&&(u="model/mtl",a=a.substring(0,a.length-3)),{filename:a,mimetype:u}):null);d&&(i=d.filename,f=d.mimetype)}var h=nn(t);b[e]=t,v.results.files[e]={filename:i,content_type:f,content_length:c,content_md5:h}})},function(){});return w&&w.then?w.then(h):h()}if("error"in r)return{success:!1,error:r.error||"Failed to validate files"};if(null!=(s=t.entrypoint)&&s.name.endsWith(".htm")||null!=(a=t.entrypoint)&&a.name.endsWith(".html")||null!=(u=t.entrypoint)&&u.name.endsWith(".html.gz")||null!=(l=t.entrypoint)&&l.name.endsWith(".html.br"))n||(n={}),n.type="deployment";else if(r.vrm_count>10)return{success:!1,error:"Multiple model files found - this is not supported for asset uploads. Please upload a single model file only."};var d=function(){if(!t.raw)return yn(o,function(e){var r=o[e],i=r.name.toLowerCase();return function(){var s;if(i.endsWith(".html")||i.endsWith(".js")||i.endsWith(".css"))return"none"!==(null==(s=n)?void 0:s.loglevel)&&console.log("gZip compressing file: "+r.name),Promise.resolve(function(e){try{return Promise.resolve(import("./pako.esm-01431bd2.js")).then(function(t){return Promise.resolve(e.arrayBuffer()).then(function(n){var r=t.gzip(new Uint8Array(n)).buffer.slice(0);if(r.byteLength>51200&&r.byteLength>=n.byteLength){if(n.byteLength>0)return null}else if(!(r instanceof ArrayBuffer))return console.error("gzipCompress: Invalid ArrayBuffer"),{error:'Gzip compressing failed for "'+e.name+'" (unexpected result)'};return function(e,t,n){var r;void 0===n&&(n=void 0);var o=function(e,t,n){for(var r=0;;){var o=e.indexOf("\\",r);if(-1===o)break;r=o+1,e=e.replace("\\","/")}return e}(e).split("/").pop()||e,i=(null==(r=n)?void 0:r.type)||rn(t,e),s=new File([t],o,{type:i});return s.path=e,s}(("path"in e?e.path:e.name)+".gz",r,{type:"application/gzip"})})})}catch(e){return Promise.reject(e)}}(r).catch(function(e){return{error:"Error compressing "+r.name+": "+e.message}})).then(function(i){var s;if(null!==i){if("error"in i)return c=1,{success:!1,error:i.error,status:500};if(!i)return c=1,{success:!1,error:"Failed to compress "+r.name,status:500};var a=t.entrypoint===r;o[e]=i,a&&(t.entrypoint=i),"none"!==(null==(s=n)?void 0:s.loglevel)&&console.log("gZip compressed file: "+r.name+" "+(a?"(entrypoint)":""))}else{var u;"none"!==(null==(u=n)?void 0:u.loglevel)&&console.error("Did not compress file: "+r.name)}})}()},function(){return c});"none"!=i&&console.warn("Raw upload - skipping gzip compression of files")}();return d&&d.then?d.then(f):f(d)})}catch(e){return Promise.reject(e)}}(e,t,n);return wn.push(r),Promise.resolve(r.finally(function(){var e=wn.indexOf(r);e>=0&&wn.splice(e,1)}))}catch(e){return Promise.reject(e)}}(y({baseUrl:"https://cloud.needle.tools/api"},n,t),{triggered_by:"web",entrypoint:void 0,files:r},{name:t.name,abort:t.abort}).then(function(e){return"error"in e?{error:e.error}:{job_id:e.id,view_id:e.view_id,url:e.url,skipped:e.uploadSkipped}})})}catch(e){return Promise.reject(e)}},_n=function(e){try{return Promise.resolve(Sn()).then(function(t){if(!t)return null;console.log({auth:t});var n=function(e,t){try{var n=e.baseUrl+"/v1/account/get/licenses",r=y({},t),o=y({},r,T(e));return Promise.resolve(fetch(n,y({},O,{method:"GET",headers:o})).catch(function(e){return console.error(e),null})).then(function(e){var t;function n(n){return t?n:Promise.resolve(e.json()).then(function(e){return e.licenses})}if(!e)return[];var r=function(){if(!e.ok){var n=e.statusText;return Promise.resolve(e.text()).then(function(e){return console.error(n,e),t=1,[]})}}();return r&&r.then?r.then(n):n(r)})}catch(e){return Promise.reject(e)}}(y({baseUrl:"https://cloud.needle.tools/api"},t),{type:"user","x-needle-product":Array.isArray(e.product)?e.product.join(","):e.product});return n})}catch(e){return Promise.reject(e)}},xn=function(e){try{return Promise.resolve(Sn(e.org)).then(function(t){if(!t)throw new Error("Not authenticated");return Promise.resolve(function(e){try{var t=new URL((e.endpoint||"https://cloud.needle.tools/api")+"/v1/list/deployments");return t.searchParams.append("offset",e.offset.toString()),t.searchParams.append("limit",e.limit.toString()),e.names&&t.searchParams.append("name",e.names.map(function(e){return e.trim()}).join(",")),Promise.resolve(fetch(t,{method:"GET",headers:y({},T({authToken:e.authToken,org:e.org}))})).then(function(e){var t;function n(n){return t?n:Promise.resolve(e.json())}var r=function(){if(!e.ok){var n=e.status;return Promise.resolve(e.text()).then(function(e){return t=1,{status:n,error:e}})}}();return r&&r.then?r.then(n):n(r)})}catch(e){return Promise.reject(e)}}(y({endpoint:"https://cloud.needle.tools/api"},t,{offset:e.offset||0,limit:e.limit||10})).catch(function(e){return e})).then(function(e){return!e||e instanceof Error?[]:e.deployments.map(function(e){return{name:e.name,url:e.url}})})})}catch(e){return Promise.reject(e)}},Tn=function(e){try{return Promise.resolve(Sn(e.org)).then(function(t){if(!t)throw new Error("Not authenticated");"limit"in e&&(e.limit=Math.min(100,e.limit));var n="page"in e||"limit"in e;return function(e,t){void 0===t&&(t={sort_by_upload:!0,page:1,limit:20,view_id:void 0,type:"upload"});try{var n;if(t.page<=0)throw new Error("Invalid page. Must be greater than 0");var r=new URL(e.baseUrl+"/v1/list/uploads");null!=(n=t.search)&&null!=(n=n.trim())&&n.length&&r.searchParams.set("search",t.search.trim());var o=y({type:t.type||"upload",max:(t.limit||0).toString(),page:(t.page||1).toString()},T(e));return null!=t.view_id&&(o.view_id=t.view_id),null!=t.view_name&&(o.view_name=t.view_name),Promise.resolve(fetch(r,y({},O,{method:"GET",headers:o})).then(function(e){try{var n=function(n){return void 0===t.sort_by_upload&&(t.sort_by_upload=!0),Promise.resolve(e.json()).then(function(e){return t.sort_by_upload&&e.uploads.sort(function(e,t){return new Date(t.updated_time).getTime()-new Date(e.updated_time).getTime()}),e})},r=function(){if(!e.ok)return Promise.resolve(e.text()).then(function(t){throw new Error("Failed to list uploads ("+e.status+"): "+t)})}();return Promise.resolve(r&&r.then?r.then(n):n())}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}}(y({baseUrl:"https://cloud.needle.tools/api"},t,e),{view_name:"name"in e?e.name:void 0,view_id:"view_id"in e?e.view_id:void 0,type:"upload",page:n?e.page:1,limit:n?e.limit:100}).then(function(e){return e.uploads.map(function(e){return{name:e.name,created_at:e.created_time,updated_at:e.updated_time,thumbnail_url:e.thumbnail_url,files:e.jobs.map(function(e){return{created_at:e.created_at,updated_at:e.updated_at||e.created_at,type:e.type,status:e.status,name:e.name,url:e.url,size:e.size}})}})})})}catch(e){return Promise.reject(e)}},On=function(e){try{var t=new URL("https://cloud.needle.tools/api/v1/account/buy_licenses");return Promise.resolve(Sn()).then(function(n){var r={mode:"payment",price_id:e.price_id,return_url:window.location.href,cancel_url:window.location.href};return Promise.resolve(fetch(t,{method:"POST",headers:y({"Content-Type":"application/json"},T(n)),body:JSON.stringify(r)})).then(function(e){return e.ok?Promise.resolve(e.json()).then(function(e){return"session_url"in e?(window.location.href=e.session_url,{ok:!0,status:200}):{ok:!1,status:400}}):{ok:!1,status:e.status}})})}catch(e){return Promise.reject(e)}};export{d as Auth,x as NeedleLoginButton,xn as getDeployments,Tn as getUploads,_n as getUserLicenses,On as startCheckoutSession,En as uploadFiles};
|
|
1
|
+
import e,{Buffer as t}from"buffer";import n,{UserScope as r}from"@logto/browser";globalThis.Buffer=t;var o,i={Basic:[r.Profile,r.Email],Payment:["read:accounting","write:accounting"],All:[r.Profile,r.Email,r.Roles,r.CustomData,r.Organizations,r.OrganizationRoles].concat(["all","read","write","delete","invite","download","create:org","write:org","delete:org","read:accounting","write:accounting","read:usage"])},s=void 0,a=[],u=null,l=null,c=null,f=null,d=new Array;function h(){d.forEach(function(e){try{e()}catch(e){console.error(e)}})}var p=!1,m={setDebug:function(e){p=e},baseUrl:window.location.origin,redirectUri:window.location.origin,postSignOutRedirectUri:window.location.origin,onChanged:function(e){return d.includes(e)||d.push(e),function(){for(;;){var t=d.indexOf(e);if(!(t>=0))break;d.splice(t,1)}}},ready:function(){return l?l.then(function(){return!0}):Promise.reject(new Error("Auth not initialized"))},init:function(e){return l||(l=function(e){try{var t,n=function(){var e=v(!0);if(!e)return m.checkIsAuthenticated().then(function(e){return!e||m.requestUserInfo().then(function(){return!0})});var t=new URL(window.location.href);return t.search=e,window.history.replaceState({},"",t.href),Promise.resolve(!0)};if((p=(null==e?void 0:e.debug)||!1)&&console.debug("Auth.init",e),null!=e&&e.scopes){switch(e.scopes){case"all":e.scopes=i.All;break;case"payment":e.scopes=i.Payment}var r;(a=e.scopes).length<=0&&(r=a).push.apply(r,i.Basic.concat(i.Payment)),p&&console.debug("Auth.init","Use scopes",a)}null!=e&&e.appId?(null==(t=f)?void 0:t.logtoConfig.appId)!==(s=e.appId)&&(p&&console.debug("Auth.init","App ID changed, resetting client"),f=null):(s="2x82zzh5xuudmiotdy2ux",p&&console.debug("Auth.init","Use default app ID",s));var o=function(){var e,t=new URL(window.location.href);if(t.searchParams.has("code")&&t.searchParams.has("state")&&null!=(e=t.searchParams.get("iss"))&&e.includes("https://auth.needle.tools/"))return y().handleSignInCallback(t.href).then(function(){var e=new URL(window.location.href);e.pathname=e.pathname.replace("callback",""),e.searchParams.delete("code"),e.searchParams.delete("state"),e.searchParams.delete("iss");var t=v();t&&(console.log("Restore query before login",t,"Current:",e.search),e.search=t),window.history.replaceState({},"",e.href)}).catch(function(e){console.error(e)})}(),u=function(){if(o instanceof Promise)return Promise.resolve(o.then(function(e){return!0})).then(function(){})}();return Promise.resolve(u&&u.then?u.then(n):n())}catch(e){return Promise.reject(e)}}(e))},isAuthenticated:function(){return o},checkIsAuthenticated:function(){return y().isAuthenticated().then(function(e){return o=e,e})},getUserInfo:function(){return u},getUserId:function(){return u?u.sub:null},getName:function(){return u?u.username?u.username:u.name?u.name:u.email?u.email.split("@")[0]:null:null},requestUserInfo:function(){return c||(c=m.checkIsAuthenticated().then(function(e){return e?y().fetchUserInfo().then(function(e){var t;return p&&(null==e?void 0:e.sub)!=(null==(t=u)?void 0:t.sub)&&console.debug("UserInfo",e),u=e,h(),e}).catch(function(e){return console.error(e),u=null,h(),null}):(u=null,h(),null)}))},requestAccessToken:function(e){return p&&console.debug("requestAccessToken",{org_id:e}),e?y().getOrganizationToken(e):y().getAccessToken("https://cloud.needle.tools/api",e||void 0)},signIn:function(){return m.checkIsAuthenticated().then(function(e){if(0==e){var t;if(null==(t=s)||!t.length)throw new Error("App ID is not set: Make sure to call 'init' first");g(),y().signIn(m.redirectUri)}})},signOut:function(){return c=null,m.checkIsAuthenticated().then(function(e){if(1==e){var t;if(null==(t=s)||!t.length)throw new Error("App ID is not set: Make sure to call 'init' first");g(),y().signOut(m.postSignOutRedirectUri)}})}};function g(){sessionStorage.setItem("needle-auth:query",window.location.search)}function v(e){void 0===e&&(e=!0);var t=sessionStorage.getItem("needle-auth:query");return t?(e&&sessionStorage.removeItem("needle-auth:query"),t):""}function y(){if(!f){if(!s)throw new Error("App ID is not set: Make sure to call 'init' first");var e={endpoint:"https://auth.needle.tools/",appId:s,scopes:a,resources:["https://cloud.needle.tools/api"]};p&&console.debug("Auth client instance not found, creating a new one with scopes:",e.scopes),f=new n(e)}return f}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function w(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return b(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?b(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function S(){return S=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},S.apply(null,arguments)}function E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_=function(){return!!e})()}function x(e,t){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},x(e,t)}function T(e){var t="function"==typeof Map?new Map:void 0;return T=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(_())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var o=new(e.bind.apply(e,r));return n&&x(o,n.prototype),o}(e,arguments,E(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),x(n,e)},T(e)}function O(){O=function(e,t){return new n(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function n(e,r,o){var i=RegExp(e,r);return t.set(i,o||t.get(e)),x(i,n.prototype)}function r(e,n){var r=t.get(n);return Object.keys(r).reduce(function(t,n){var o=r[n];if("number"==typeof o)t[n]=e[o];else{for(var i=0;void 0===e[o[i]]&&i+1<o.length;)i++;t[n]=e[o[i]]}return t},Object.create(null))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&x(e,t)}(n,RegExp),n.prototype.exec=function(t){var n=e.exec.call(this,t);if(n){n.groups=r(n,this);var o=n.indices;o&&(o.groups=r(o,this))}return n},n.prototype[Symbol.replace]=function(n,o){if("string"==typeof o){var i=t.get(this);return e[Symbol.replace].call(this,n,o.replace(/\$<([^>]+)>/g,function(e,t){var n=i[t];return"$"+(Array.isArray(n)?n.join("$"):n)}))}if("function"==typeof o){var s=this;return e[Symbol.replace].call(this,n,function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(r(e,s)),o.apply(this,e)})}return e[Symbol.replace].call(this,n,o)},O.apply(this,arguments)}var P=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this).addEventListener("click",function(){m.isAuthenticated()?m.signOut():m.signIn()}),t}var n,r;r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,x(n,r);var o=t.prototype;return o.connectedCallback=function(){var e=this;console.debug("Login button connected..."),this.__update(),this.__unsubscribeOnChange=m.onChanged(function(){e.__update()})},o.disconnectedCallback=function(){var e;null==(e=this.__unsubscribeOnChange)||e.call(this)},o.__update=function(){this.innerHTML=m.isAuthenticated()?"Logout":"Login"},t}(/*#__PURE__*/T(HTMLButtonElement));function R(e){var t={authorization:"Bearer "+e.authToken};return e.org&&(t["x-needle-cloud-org"]=e.org),e.roles&&(t.roles=e.roles.join(",")),e.roles_org&&(t.roles_org=e.roles_org.join(",")),t}customElements.define("needle-login-button",P,{extends:"button"});var A={credentials:"omit"};function j(e,t){return function(){return e.apply(t,arguments)}}const{toString:C}=Object.prototype,{getPrototypeOf:U}=Object,k=(W=Object.create(null),e=>{const t=C.call(e);return W[t]||(W[t]=t.slice(8,-1).toLowerCase())});var W;const z=e=>(e=e.toLowerCase(),t=>k(t)===e),F=e=>t=>typeof t===e,{isArray:L}=Array,N=F("undefined"),B=z("ArrayBuffer"),D=F("string"),I=F("function"),M=F("number"),q=e=>null!==e&&"object"==typeof e,J=e=>{if("object"!==k(e))return!1;const t=U(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},H=z("Date"),K=z("File"),V=z("Blob"),G=z("FileList"),$=z("URLSearchParams"),[X,Z,Q,Y]=["ReadableStream","Request","Response","Headers"].map(z);function ee(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,o;if("object"!=typeof e&&(e=[e]),L(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let s;for(r=0;r<i;r++)s=o[r],t.call(null,e[s],s,e)}}function te(e,t){t=t.toLowerCase();const n=Object.keys(e);let r,o=n.length;for(;o-- >0;)if(r=n[o],t===r.toLowerCase())return r;return null}const ne="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,re=e=>!N(e)&&e!==ne,oe=(ie="undefined"!=typeof Uint8Array&&U(Uint8Array),e=>ie&&e instanceof ie);var ie;const se=z("HTMLFormElement"),ae=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),ue=z("RegExp"),le=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};ee(n,(n,o)=>{let i;!1!==(i=t(n,o,e))&&(r[o]=i||n)}),Object.defineProperties(e,r)},ce="abcdefghijklmnopqrstuvwxyz",fe="0123456789",de={DIGIT:fe,ALPHA:ce,ALPHA_DIGIT:ce+ce.toUpperCase()+fe},he=z("AsyncFunction"),pe=(me="function"==typeof setImmediate,ge=I(ne.postMessage),me?setImmediate:ge?(ve=`axios@${Math.random()}`,ye=[],ne.addEventListener("message",({source:e,data:t})=>{e===ne&&t===ve&&ye.length&&ye.shift()()},!1),e=>{ye.push(e),ne.postMessage(ve,"*")}):e=>setTimeout(e));var me,ge,ve,ye;const be="undefined"!=typeof queueMicrotask?queueMicrotask.bind(ne):"undefined"!=typeof process&&process.nextTick||pe;var we={isArray:L,isArrayBuffer:B,isBuffer:function(e){return null!==e&&!N(e)&&null!==e.constructor&&!N(e.constructor)&&I(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||I(e.append)&&("formdata"===(t=k(e))||"object"===t&&I(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&B(e.buffer),t},isString:D,isNumber:M,isBoolean:e=>!0===e||!1===e,isObject:q,isPlainObject:J,isReadableStream:X,isRequest:Z,isResponse:Q,isHeaders:Y,isUndefined:N,isDate:H,isFile:K,isBlob:V,isRegExp:ue,isFunction:I,isStream:e=>q(e)&&I(e.pipe),isURLSearchParams:$,isTypedArray:oe,isFileList:G,forEach:ee,merge:function e(){const{caseless:t}=re(this)&&this||{},n={},r=(r,o)=>{const i=t&&te(n,o)||o;n[i]=J(n[i])&&J(r)?e(n[i],r):J(r)?e({},r):L(r)?r.slice():r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&ee(arguments[e],r);return n},extend:(e,t,n,{allOwnKeys:r}={})=>(ee(t,(t,r)=>{e[r]=n&&I(t)?j(t,n):t},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(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)},toFlatObject:(e,t,n,r)=>{let o,i,s;const a={};if(t=t||{},null==e)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],r&&!r(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0);e=!1!==n&&U(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:k,kindOfTest:z,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length);const r=e.indexOf(t,n-=t.length);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(L(e))return e;let t=e.length;if(!M(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:se,hasOwnProperty:ae,hasOwnProp:ae,reduceDescriptors:le,freezeMethods:e=>{le(e,(t,n)=>{if(I(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;I(e[n])&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return L(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:te,global:ne,isContextDefined:re,ALPHABET:de,generateString:(e=16,t=de.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&I(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(q(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const o=L(e)?[]:{};return ee(e,(e,t)=>{const i=n(e,r+1);!N(i)&&(o[t]=i)}),t[r]=void 0,o}}return e};return n(e,0)},isAsyncFn:he,isThenable:e=>e&&(q(e)||I(e))&&I(e.then)&&I(e.catch),setImmediate:pe,asap:be};function Se(e,t,n,r,o){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),o&&(this.response=o)}we.inherits(Se,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:we.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Ee=Se.prototype,_e={};function xe(e){return we.isPlainObject(e)||we.isArray(e)}function Te(e){return we.endsWith(e,"[]")?e.slice(0,-2):e}function Oe(e,t,n){return e?e.concat(t).map(function(e,t){return e=Te(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}["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=>{_e[e]={value:e}}),Object.defineProperties(Se,_e),Object.defineProperty(Ee,"isAxiosError",{value:!0}),Se.from=(e,t,n,r,o,i)=>{const s=Object.create(Ee);return we.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e),Se.call(s,e.message,t,n,r,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};const Pe=we.toFlatObject(we,{},null,function(e){return/^is[A-Z]/.test(e)});function Re(e,t,n){if(!we.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=we.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!we.isUndefined(t[e])})).metaTokens,o=n.visitor||l,i=n.dots,s=n.indexes,a=(n.Blob||"undefined"!=typeof Blob&&Blob)&&we.isSpecCompliantForm(t);if(!we.isFunction(o))throw new TypeError("visitor must be a function");function u(e){if(null===e)return"";if(we.isDate(e))return e.toISOString();if(!a&&we.isBlob(e))throw new Se("Blob is not supported. Use a Buffer instead.");return we.isArrayBuffer(e)||we.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,n,o){let a=e;if(e&&!o&&"object"==typeof e)if(we.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(we.isArray(e)&&function(e){return we.isArray(e)&&!e.some(xe)}(e)||(we.isFileList(e)||we.endsWith(n,"[]"))&&(a=we.toArray(e)))return n=Te(n),a.forEach(function(e,r){!we.isUndefined(e)&&null!==e&&t.append(!0===s?Oe([n],r,i):null===s?n:n+"[]",u(e))}),!1;return!!xe(e)||(t.append(Oe(o,n,i),u(e)),!1)}const c=[],f=Object.assign(Pe,{defaultVisitor:l,convertValue:u,isVisitable:xe});if(!we.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!we.isUndefined(n)){if(-1!==c.indexOf(n))throw Error("Circular reference detected in "+r.join("."));c.push(n),we.forEach(n,function(n,i){!0===(!(we.isUndefined(n)||null===n)&&o.call(t,n,we.isString(i)?i.trim():i,r,f))&&e(n,r?r.concat(i):[i])}),c.pop()}}(e),t}function Ae(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function je(e,t){this._pairs=[],e&&Re(e,this,t)}const Ce=je.prototype;function Ue(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ke(e,t,n){if(!t)return e;const r=n&&n.encode||Ue,o=n&&n.serialize;let i;if(i=o?o(t,n):we.isURLSearchParams(t)?t.toString():new je(t,n).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}Ce.append=function(e,t){this._pairs.push([e,t])},Ce.toString=function(e){const t=e?function(t){return e.call(this,t,Ae)}:Ae;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};var We=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){we.forEach(this.handlers,function(t){null!==t&&e(t)})}},ze={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Fe={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:je,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const Le="undefined"!=typeof window&&"undefined"!=typeof document,Ne=(Be="undefined"!=typeof navigator&&navigator.product,Le&&["ReactNative","NativeScript","NS"].indexOf(Be)<0);var Be,De={__proto__:null,hasBrowserEnv:Le,hasStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,hasStandardBrowserEnv:Ne,origin:Le&&window.location.href||"http://localhost",...Fe};function Ie(e){function t(e,n,r,o){let i=e[o++];if("__proto__"===i)return!0;const s=Number.isFinite(+i),a=o>=e.length;return i=!i&&we.isArray(r)?r.length:i,a?(r[i]=we.hasOwnProp(r,i)?[r[i],n]:n,!s):(r[i]&&we.isObject(r[i])||(r[i]=[]),t(e,n,r[i],o)&&we.isArray(r[i])&&(r[i]=function(e){const t={},n=Object.keys(e);let r;const o=n.length;let i;for(r=0;r<o;r++)i=n[r],t[i]=e[i];return t}(r[i])),!s)}if(we.isFormData(e)&&we.isFunction(e.entries)){const n={};return we.forEachEntry(e,(e,r)=>{t(function(e){return we.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null}const Me={transitional:ze,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=we.isObject(e);if(o&&we.isHTMLForm(e)&&(e=new FormData(e)),we.isFormData(e))return r?JSON.stringify(Ie(e)):e;if(we.isArrayBuffer(e)||we.isBuffer(e)||we.isStream(e)||we.isFile(e)||we.isBlob(e)||we.isReadableStream(e))return e;if(we.isArrayBufferView(e))return e.buffer;if(we.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Re(e,new De.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return De.isNode&&we.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((i=we.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Re(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(we.isString(e))try{return(0,JSON.parse)(e),we.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Me.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(we.isResponse(e)||we.isReadableStream(e))return e;if(e&&we.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw Se.from(e,Se.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:De.classes.FormData,Blob:De.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};we.forEach(["delete","get","head","post","put","patch"],e=>{Me.headers[e]={}});var qe=Me;const Je=we.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"]),He=Symbol("internals");function Ke(e){return e&&String(e).trim().toLowerCase()}function Ve(e){return!1===e||null==e?e:we.isArray(e)?e.map(Ve):String(e)}function Ge(e,t,n,r,o){return we.isFunction(r)?r.call(this,t,n):(o&&(t=n),we.isString(t)?we.isString(r)?-1!==t.indexOf(r):we.isRegExp(r)?r.test(t):void 0:void 0)}class $e{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=Ke(t);if(!o)throw new Error("header name must be a non-empty string");const i=we.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=Ve(e))}const i=(e,t)=>we.forEach(e,(e,n)=>o(e,n,t));if(we.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(we.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let n,r,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),n=e.substring(0,o).trim().toLowerCase(),r=e.substring(o+1).trim(),!n||t[n]&&Je[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t})(e),t);else if(we.isHeaders(e))for(const[t,r]of e.entries())o(r,t,n);else null!=e&&o(t,e,n);return this}get(e,t){if(e=Ke(e)){const n=we.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(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}(e);if(we.isFunction(t))return t.call(this,e,n);if(we.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Ke(e)){const n=we.findKey(this,e);return!(!n||void 0===this[n]||t&&!Ge(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=Ke(e)){const o=we.findKey(n,e);!o||t&&!Ge(0,n[o],o,t)||(delete n[o],r=!0)}}return we.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const o=t[n];e&&!Ge(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}normalize(e){const t=this,n={};return we.forEach(this,(r,o)=>{const i=we.findKey(n,o);if(i)return t[i]=Ve(r),void delete t[o];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();s!==o&&delete t[o],t[s]=Ve(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return we.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&we.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[He]=this[He]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=Ke(e);t[r]||(function(e,t){const n=we.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})})}(n,e),t[r]=!0)}return we.isArray(e)?e.forEach(r):r(e),this}}$e.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),we.reduceDescriptors($e.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),we.freezeMethods($e);var Xe=$e;function Ze(e,t){const n=this||qe,r=t||n,o=Xe.from(r.headers);let i=r.data;return we.forEach(e,function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function Qe(e){return!(!e||!e.__CANCEL__)}function Ye(e,t,n){Se.call(this,null==e?"canceled":e,Se.ERR_CANCELED,t,n),this.name="CanceledError"}function et(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new Se("Request failed with status code "+n.status,[Se.ERR_BAD_REQUEST,Se.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}we.inherits(Ye,Se,{__CANCEL__:!0});const tt=(e,t,n=3)=>{let r=0;const o=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o,i=0,s=0;return t=void 0!==t?t:1e3,function(a){const u=Date.now(),l=r[s];o||(o=u),n[i]=a,r[i]=u;let c=s,f=0;for(;c!==i;)f+=n[c++],c%=e;if(i=(i+1)%e,i===s&&(s=(s+1)%e),u-o<t)return;const d=l&&u-l;return d?Math.round(1e3*f/d):void 0}}(50,250);return function(e,t){let n,r,o=0,i=1e3/t;const s=(t,i=Date.now())=>{o=i,n=null,r&&(clearTimeout(r),r=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),a=t-o;a>=i?s(e,t):(n=e,r||(r=setTimeout(()=>{r=null,s(n)},i-a)))},()=>n&&s(n)]}(n=>{const i=n.loaded,s=n.lengthComputable?n.total:void 0,a=i-r,u=o(a);r=i,e({loaded:i,total:s,progress:s?i/s:void 0,bytes:a,rate:u||void 0,estimated:u&&s&&i<=s?(s-i)/u:void 0,event:n,lengthComputable:null!=s,[t?"download":"upload"]:!0})},n)},nt=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},rt=e=>(...t)=>we.asap(()=>e(...t));var ot=De.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let n;function r(n){let r=n;return e&&(t.setAttribute("href",r),r=t.href),t.setAttribute("href",r),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return n=r(window.location.href),function(e){const t=we.isString(e)?r(e):e;return t.protocol===n.protocol&&t.host===n.host}}():function(){return!0},it=De.hasStandardBrowserEnv?{write(e,t,n,r,o,i){const s=[e+"="+encodeURIComponent(t)];we.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),we.isString(r)&&s.push("path="+r),we.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.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:()=>null,remove(){}};function st(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const at=e=>e instanceof Xe?{...e}:e;function ut(e,t){t=t||{};const n={};function r(e,t,n){return we.isPlainObject(e)&&we.isPlainObject(t)?we.merge.call({caseless:n},e,t):we.isPlainObject(t)?we.merge({},t):we.isArray(t)?t.slice():t}function o(e,t,n){return we.isUndefined(t)?we.isUndefined(e)?void 0:r(void 0,e,n):r(e,t,n)}function i(e,t){if(!we.isUndefined(t))return r(void 0,t)}function s(e,t){return we.isUndefined(t)?we.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(n,o,i){return i in t?r(n,o):i in e?r(void 0,n):void 0}const u={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t)=>o(at(e),at(t),!0)};return we.forEach(Object.keys(Object.assign({},e,t)),function(r){const i=u[r]||o,s=i(e[r],t[r],r);we.isUndefined(s)&&i!==a||(n[r]=s)}),n}var lt=e=>{const t=ut({},e);let n,{data:r,withXSRFToken:o,xsrfHeaderName:i,xsrfCookieName:s,headers:a,auth:u}=t;if(t.headers=a=Xe.from(a),t.url=ke(st(t.baseURL,t.url),e.params,e.paramsSerializer),u&&a.set("Authorization","Basic "+btoa((u.username||"")+":"+(u.password?unescape(encodeURIComponent(u.password)):""))),we.isFormData(r))if(De.hasStandardBrowserEnv||De.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(n=a.getContentType())){const[e,...t]=n?n.split(";").map(e=>e.trim()).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(De.hasStandardBrowserEnv&&(o&&we.isFunction(o)&&(o=o(t)),o||!1!==o&&ot(t.url))){const e=i&&s&&it.read(s);e&&a.set(i,e)}return t},ct="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,n){const r=lt(e);let o=r.data;const i=Xe.from(r.headers).normalize();let s,a,u,l,c,{responseType:f,onUploadProgress:d,onDownloadProgress:h}=r;function p(){l&&l(),c&&c(),r.cancelToken&&r.cancelToken.unsubscribe(s),r.signal&&r.signal.removeEventListener("abort",s)}let m=new XMLHttpRequest;function g(){if(!m)return;const r=Xe.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders());et(function(e){t(e),p()},function(e){n(e),p()},{data:f&&"text"!==f&&"json"!==f?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:r,config:e,request:m}),m=null}m.open(r.method.toUpperCase(),r.url,!0),m.timeout=r.timeout,"onloadend"in m?m.onloadend=g:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(g)},m.onabort=function(){m&&(n(new Se("Request aborted",Se.ECONNABORTED,e,m)),m=null)},m.onerror=function(){n(new Se("Network Error",Se.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new Se(t,(r.transitional||ze).clarifyTimeoutError?Se.ETIMEDOUT:Se.ECONNABORTED,e,m)),m=null},void 0===o&&i.setContentType(null),"setRequestHeader"in m&&we.forEach(i.toJSON(),function(e,t){m.setRequestHeader(t,e)}),we.isUndefined(r.withCredentials)||(m.withCredentials=!!r.withCredentials),f&&"json"!==f&&(m.responseType=r.responseType),h&&([u,c]=tt(h,!0),m.addEventListener("progress",u)),d&&m.upload&&([a,l]=tt(d),m.upload.addEventListener("progress",a),m.upload.addEventListener("loadend",l)),(r.cancelToken||r.signal)&&(s=t=>{m&&(n(!t||t.type?new Ye(null,e,m):t),m.abort(),m=null)},r.cancelToken&&r.cancelToken.subscribe(s),r.signal&&(r.signal.aborted?s():r.signal.addEventListener("abort",s)));const v=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);v&&-1===De.protocols.indexOf(v)?n(new Se("Unsupported protocol "+v+":",Se.ERR_BAD_REQUEST,e)):m.send(o||null)})},ft=(e,t)=>{let n,r=new AbortController;const o=function(e){if(!n){n=!0,s();const t=e instanceof Error?e:this.reason;r.abort(t instanceof Se?t:new Ye(t instanceof Error?t.message:t))}};let i=t&&setTimeout(()=>{o(new Se(`timeout ${t} of ms exceeded`,Se.ETIMEDOUT))},t);const s=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(e=>{e&&(e.removeEventListener?e.removeEventListener("abort",o):e.unsubscribe(o))}),e=null)};e.forEach(e=>e&&e.addEventListener&&e.addEventListener("abort",o));const{signal:a}=r;return a.unsubscribe=s,[a,()=>{i&&clearTimeout(i),i=null}]};const dt=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,o=0;for(;o<n;)r=o+t,yield e.slice(o,r),o=r},ht=(e,t,n,r,o)=>{const i=async function*(e,t,n){for await(const r of e)yield*dt(ArrayBuffer.isView(r)?r:await n(String(r)),t)}(e,t,o);let s,a=0,u=e=>{s||(s=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await i.next();if(t)return u(),void e.close();if(n){let e=a+=r.byteLength;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw u(e),e}},cancel:e=>(u(e),i.return())},{highWaterMark:2})},pt="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,mt=pt&&"function"==typeof ReadableStream,gt=pt&&("function"==typeof TextEncoder?(vt=new TextEncoder,e=>vt.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var vt;const yt=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},bt=mt&&yt(()=>{let e=!1;const t=new Request(De.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),wt=mt&&yt(()=>we.isReadableStream(new Response("").body)),St={stream:wt&&(e=>e.body)};var Et;pt&&(Et=new Response,["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!St[e]&&(St[e]=we.isFunction(Et[e])?t=>t[e]():(t,n)=>{throw new Se(`Response type '${e}' is not supported`,Se.ERR_NOT_SUPPORT,n)})}));const _t={http:null,xhr:ct,fetch:pt&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:i,timeout:s,onDownloadProgress:a,onUploadProgress:u,responseType:l,headers:c,withCredentials:f="same-origin",fetchOptions:d}=lt(e);l=l?(l+"").toLowerCase():"text";let h,p,[m,g]=o||i||s?ft([o,i],s):[];const v=()=>{!h&&setTimeout(()=>{m&&m.unsubscribe()}),h=!0};let y;try{if(u&&bt&&"get"!==n&&"head"!==n&&0!==(y=await(async(e,t)=>{const n=we.toFiniteNumber(e.getContentLength());return null==n?(async e=>null==e?0:we.isBlob(e)?e.size:we.isSpecCompliantForm(e)?(await new Request(e).arrayBuffer()).byteLength:we.isArrayBufferView(e)||we.isArrayBuffer(e)?e.byteLength:(we.isURLSearchParams(e)&&(e+=""),we.isString(e)?(await gt(e)).byteLength:void 0))(t):n})(c,r))){let e,n=new Request(t,{method:"POST",body:r,duplex:"half"});if(we.isFormData(r)&&(e=n.headers.get("content-type"))&&c.setContentType(e),n.body){const[e,t]=nt(y,tt(rt(u)));r=ht(n.body,65536,e,t,gt)}}we.isString(f)||(f=f?"include":"omit"),p=new Request(t,{...d,signal:m,method:n.toUpperCase(),headers:c.normalize().toJSON(),body:r,duplex:"half",credentials:f});let o=await fetch(p);const i=wt&&("stream"===l||"response"===l);if(wt&&(a||i)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=o[t]});const t=we.toFiniteNumber(o.headers.get("content-length")),[n,r]=a&&nt(t,tt(rt(a),!0))||[];o=new Response(ht(o.body,65536,n,()=>{r&&r(),i&&v()},gt),e)}l=l||"text";let s=await St[we.findKey(St,l)||"text"](o,e);return!i&&v(),g&&g(),await new Promise((t,n)=>{et(t,n,{data:s,headers:Xe.from(o.headers),status:o.status,statusText:o.statusText,config:e,request:p})})}catch(t){if(v(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new Se("Network Error",Se.ERR_NETWORK,e,p),{cause:t.cause||t});throw Se.from(t,t&&t.code,e,p)}})};we.forEach(_t,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const xt=e=>`- ${e}`,Tt=e=>we.isFunction(e)||null===e||!1===e;var Ot=e=>{e=we.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let i=0;i<t;i++){let t;if(n=e[i],r=n,!Tt(n)&&(r=_t[(t=String(n)).toLowerCase()],void 0===r))throw new Se(`Unknown adapter '${t}'`);if(r)break;o[t||"#"+i]=r}if(!r){const e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new Se("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(xt).join("\n"):" "+xt(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function Pt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ye(null,e)}function Rt(e){return Pt(e),e.headers=Xe.from(e.headers),e.data=Ze.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ot(e.adapter||qe.adapter)(e).then(function(t){return Pt(e),t.data=Ze.call(e,e.transformResponse,t),t.headers=Xe.from(t.headers),t},function(t){return Qe(t)||(Pt(e),t&&t.response&&(t.response.data=Ze.call(e,e.transformResponse,t.response),t.response.headers=Xe.from(t.response.headers))),Promise.reject(t)})}const At={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{At[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const jt={};At.transitional=function(e,t,n){function r(e,t){return"[Axios v1.7.4] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,o,i)=>{if(!1===e)throw new Se(r(o," has been removed"+(t?" in "+t:"")),Se.ERR_DEPRECATED);return t&&!jt[o]&&(jt[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}};var Ct={assertOptions:function(e,t,n){if("object"!=typeof e)throw new Se("options must be an object",Se.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],s=t[i];if(s){const t=e[i],n=void 0===t||s(t,i,e);if(!0!==n)throw new Se("option "+i+" must be "+n,Se.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new Se("Unknown option "+i,Se.ERR_BAD_OPTION)}},validators:At};const Ut=Ct.validators;class kt{constructor(e){this.defaults=e,this.interceptors={request:new We,response:new We}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t;Error.captureStackTrace?Error.captureStackTrace(t={}):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=ut(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&Ct.assertOptions(n,{silentJSONParsing:Ut.transitional(Ut.boolean),forcedJSONParsing:Ut.transitional(Ut.boolean),clarifyTimeoutError:Ut.transitional(Ut.boolean)},!1),null!=r&&(we.isFunction(r)?t.paramsSerializer={serialize:r}:Ct.assertOptions(r,{encode:Ut.function,serialize:Ut.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=o&&we.merge(o.common,o[t.method]);o&&we.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=Xe.concat(i,o);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const u=[];let l;this.interceptors.response.forEach(function(e){u.push(e.fulfilled,e.rejected)});let c,f=0;if(!a){const e=[Rt.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,u),c=e.length,l=Promise.resolve(t);f<c;)l=l.then(e[f++],e[f++]);return l}c=s.length;let d=t;for(f=0;f<c;){const e=s[f++],t=s[f++];try{d=e(d)}catch(e){t.call(this,e);break}}try{l=Rt.call(this,d)}catch(e){return Promise.reject(e)}for(f=0,c=u.length;f<c;)l=l.then(u[f++],u[f++]);return l}getUri(e){return ke(st((e=ut(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}we.forEach(["delete","get","head","options"],function(e){kt.prototype[e]=function(t,n){return this.request(ut(n||{},{method:e,url:t,data:(n||{}).data}))}}),we.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,o){return this.request(ut(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}kt.prototype[e]=t(),kt.prototype[e+"Form"]=t(!0)});var Wt=kt;class zt{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const n=this;this.promise.then(e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,o){n.reason||(n.reason=new Ye(e,r,o),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;return{token:new zt(function(t){e=t}),cancel:e}}}var Ft=zt;const Lt={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(Lt).forEach(([e,t])=>{Lt[t]=e});var Nt=Lt;const Bt=function e(t){const n=new Wt(t),r=j(Wt.prototype.request,n);return we.extend(r,Wt.prototype,n,{allOwnKeys:!0}),we.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(ut(t,n))},r}(qe);Bt.Axios=Wt,Bt.CanceledError=Ye,Bt.CancelToken=Ft,Bt.isCancel=Qe,Bt.VERSION="1.7.4",Bt.toFormData=Re,Bt.AxiosError=Se,Bt.Cancel=Bt.CanceledError,Bt.all=function(e){return Promise.all(e)},Bt.spread=function(e){return function(t){return e.apply(null,t)}},Bt.isAxiosError=function(e){return we.isObject(e)&&!0===e.isAxiosError},Bt.mergeConfig=ut,Bt.AxiosHeaders=Xe,Bt.formToJSON=e=>Ie(we.isHTMLForm(e)?new FormData(e):e),Bt.getAdapter=Ot,Bt.HttpStatusCode=Nt,Bt.default=Bt;var Dt=Bt;const{CanceledError:It}=Dt;var Mt,qt,Jt=function(e,t){try{var n=t.baseUrl+"/v1/jobs/update",r=S({},R(t),{job_id:e.identifier,status:e.status});return Promise.resolve(fetch(n,S({},A,{method:"POST",headers:r,body:JSON.stringify({status_message:e.status_message,error:e.error,progress:e.progress})})).catch(function(e){return console.error(e),null})).then(function(e){return!!e&&e.ok})}catch(e){return Promise.reject(e)}},Ht="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},Kt={__proto__:null,default:{}},Vt=(Mt=function(t){!function(){var n="input is invalid type",r="object"==typeof window,o=r?window:{};o.JS_MD5_NO_WINDOW&&(r=!1);var i=!r&&"object"==typeof self,s=!o.JS_MD5_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;s?o=Ht:i&&(o=self);var a,u=!o.JS_MD5_NO_COMMON_JS&&t.exports,l=!o.JS_MD5_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,c="0123456789abcdef".split(""),f=[128,32768,8388608,-2147483648],d=[0,8,16,24],h=["hex","array","digest","buffer","arrayBuffer","base64"],p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),m=[];if(l){var g=new ArrayBuffer(68);a=new Uint8Array(g),m=new Uint32Array(g)}var v=Array.isArray;!o.JS_MD5_NO_NODE_JS&&v||(v=function(e){return"[object Array]"===Object.prototype.toString.call(e)});var y=ArrayBuffer.isView;!l||!o.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW&&y||(y=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});var b=function(e){var t=typeof e;if("string"===t)return[e,!0];if("object"!==t||null===e)throw new Error(n);if(l&&e.constructor===ArrayBuffer)return[new Uint8Array(e),!1];if(!v(e)&&!y(e))throw new Error(n);return[e,!1]},w=function(e){return function(t){return new E(!0).update(t)[e]()}},S=function(e){return function(t,n){return new _(t,!0).update(n)[e]()}};function E(e){if(e)m[0]=m[16]=m[1]=m[2]=m[3]=m[4]=m[5]=m[6]=m[7]=m[8]=m[9]=m[10]=m[11]=m[12]=m[13]=m[14]=m[15]=0,this.blocks=m,this.buffer8=a;else if(l){var t=new ArrayBuffer(68);this.buffer8=new Uint8Array(t),this.blocks=new Uint32Array(t)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}function _(e,t){var n,r=b(e);if(e=r[0],r[1]){var o,i=[],s=e.length,a=0;for(n=0;n<s;++n)(o=e.charCodeAt(n))<128?i[a++]=o:o<2048?(i[a++]=192|o>>>6,i[a++]=128|63&o):o<55296||o>=57344?(i[a++]=224|o>>>12,i[a++]=128|o>>>6&63,i[a++]=128|63&o):(o=65536+((1023&o)<<10|1023&e.charCodeAt(++n)),i[a++]=240|o>>>18,i[a++]=128|o>>>12&63,i[a++]=128|o>>>6&63,i[a++]=128|63&o);e=i}e.length>64&&(e=new E(!0).update(e).array());var u=[],l=[];for(n=0;n<64;++n){var c=e[n]||0;u[n]=92^c,l[n]=54^c}E.call(this,t),this.update(l),this.oKeyPad=u,this.inner=!0,this.sharedMemory=t}E.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");for(var t,n,r=b(e),o=r[1],i=0,s=(e=r[0]).length,a=this.blocks,u=this.buffer8;i<s;){if(this.hashed&&(this.hashed=!1,a[0]=a[16],a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0),o)if(l)for(n=this.start;i<s&&n<64;++i)(t=e.charCodeAt(i))<128?u[n++]=t:t<2048?(u[n++]=192|t>>>6,u[n++]=128|63&t):t<55296||t>=57344?(u[n++]=224|t>>>12,u[n++]=128|t>>>6&63,u[n++]=128|63&t):(t=65536+((1023&t)<<10|1023&e.charCodeAt(++i)),u[n++]=240|t>>>18,u[n++]=128|t>>>12&63,u[n++]=128|t>>>6&63,u[n++]=128|63&t);else for(n=this.start;i<s&&n<64;++i)(t=e.charCodeAt(i))<128?a[n>>>2]|=t<<d[3&n++]:t<2048?(a[n>>>2]|=(192|t>>>6)<<d[3&n++],a[n>>>2]|=(128|63&t)<<d[3&n++]):t<55296||t>=57344?(a[n>>>2]|=(224|t>>>12)<<d[3&n++],a[n>>>2]|=(128|t>>>6&63)<<d[3&n++],a[n>>>2]|=(128|63&t)<<d[3&n++]):(t=65536+((1023&t)<<10|1023&e.charCodeAt(++i)),a[n>>>2]|=(240|t>>>18)<<d[3&n++],a[n>>>2]|=(128|t>>>12&63)<<d[3&n++],a[n>>>2]|=(128|t>>>6&63)<<d[3&n++],a[n>>>2]|=(128|63&t)<<d[3&n++]);else if(l)for(n=this.start;i<s&&n<64;++i)u[n++]=e[i];else for(n=this.start;i<s&&n<64;++i)a[n>>>2]|=e[i]<<d[3&n++];this.lastByteIndex=n,this.bytes+=n-this.start,n>=64?(this.start=n-64,this.hash(),this.hashed=!0):this.start=n}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},E.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[t>>>2]|=f[3&t],t>=56&&(this.hashed||this.hash(),e[0]=e[16],e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.bytes<<3,e[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},E.prototype.hash=function(){var e,t,n,r,o,i,s=this.blocks;this.first?t=((t=((e=((e=s[0]-680876937)<<7|e>>>25)-271733879|0)^(n=((n=(-271733879^(r=((r=(-1732584194^2004318071&e)+s[1]-117830708)<<12|r>>>20)+e|0)&(-271733879^e))+s[2]-1126478375)<<17|n>>>15)+r|0)&(r^e))+s[3]-1316259209)<<22|t>>>10)+n|0:(e=this.h0,t=this.h1,t=((t+=((e=((e+=((r=this.h3)^t&((n=this.h2)^r))+s[0]-680876936)<<7|e>>>25)+t|0)^(n=((n+=(t^(r=((r+=(n^e&(t^n))+s[1]-389564586)<<12|r>>>20)+e|0)&(e^t))+s[2]+606105819)<<17|n>>>15)+r|0)&(r^e))+s[3]-1044525330)<<22|t>>>10)+n|0),t=((t+=((e=((e+=(r^t&(n^r))+s[4]-176418897)<<7|e>>>25)+t|0)^(n=((n+=(t^(r=((r+=(n^e&(t^n))+s[5]+1200080426)<<12|r>>>20)+e|0)&(e^t))+s[6]-1473231341)<<17|n>>>15)+r|0)&(r^e))+s[7]-45705983)<<22|t>>>10)+n|0,t=((t+=((e=((e+=(r^t&(n^r))+s[8]+1770035416)<<7|e>>>25)+t|0)^(n=((n+=(t^(r=((r+=(n^e&(t^n))+s[9]-1958414417)<<12|r>>>20)+e|0)&(e^t))+s[10]-42063)<<17|n>>>15)+r|0)&(r^e))+s[11]-1990404162)<<22|t>>>10)+n|0,t=((t+=((e=((e+=(r^t&(n^r))+s[12]+1804603682)<<7|e>>>25)+t|0)^(n=((n+=(t^(r=((r+=(n^e&(t^n))+s[13]-40341101)<<12|r>>>20)+e|0)&(e^t))+s[14]-1502002290)<<17|n>>>15)+r|0)&(r^e))+s[15]+1236535329)<<22|t>>>10)+n|0,t=((t+=((r=((r+=(t^n&((e=((e+=(n^r&(t^n))+s[1]-165796510)<<5|e>>>27)+t|0)^t))+s[6]-1069501632)<<9|r>>>23)+e|0)^e&((n=((n+=(e^t&(r^e))+s[11]+643717713)<<14|n>>>18)+r|0)^r))+s[0]-373897302)<<20|t>>>12)+n|0,t=((t+=((r=((r+=(t^n&((e=((e+=(n^r&(t^n))+s[5]-701558691)<<5|e>>>27)+t|0)^t))+s[10]+38016083)<<9|r>>>23)+e|0)^e&((n=((n+=(e^t&(r^e))+s[15]-660478335)<<14|n>>>18)+r|0)^r))+s[4]-405537848)<<20|t>>>12)+n|0,t=((t+=((r=((r+=(t^n&((e=((e+=(n^r&(t^n))+s[9]+568446438)<<5|e>>>27)+t|0)^t))+s[14]-1019803690)<<9|r>>>23)+e|0)^e&((n=((n+=(e^t&(r^e))+s[3]-187363961)<<14|n>>>18)+r|0)^r))+s[8]+1163531501)<<20|t>>>12)+n|0,t=((t+=((r=((r+=(t^n&((e=((e+=(n^r&(t^n))+s[13]-1444681467)<<5|e>>>27)+t|0)^t))+s[2]-51403784)<<9|r>>>23)+e|0)^e&((n=((n+=(e^t&(r^e))+s[7]+1735328473)<<14|n>>>18)+r|0)^r))+s[12]-1926607734)<<20|t>>>12)+n|0,t=((t+=((i=(r=((r+=((o=t^n)^(e=((e+=(o^r)+s[5]-378558)<<4|e>>>28)+t|0))+s[8]-2022574463)<<11|r>>>21)+e|0)^e)^(n=((n+=(i^t)+s[11]+1839030562)<<16|n>>>16)+r|0))+s[14]-35309556)<<23|t>>>9)+n|0,t=((t+=((i=(r=((r+=((o=t^n)^(e=((e+=(o^r)+s[1]-1530992060)<<4|e>>>28)+t|0))+s[4]+1272893353)<<11|r>>>21)+e|0)^e)^(n=((n+=(i^t)+s[7]-155497632)<<16|n>>>16)+r|0))+s[10]-1094730640)<<23|t>>>9)+n|0,t=((t+=((i=(r=((r+=((o=t^n)^(e=((e+=(o^r)+s[13]+681279174)<<4|e>>>28)+t|0))+s[0]-358537222)<<11|r>>>21)+e|0)^e)^(n=((n+=(i^t)+s[3]-722521979)<<16|n>>>16)+r|0))+s[6]+76029189)<<23|t>>>9)+n|0,t=((t+=((i=(r=((r+=((o=t^n)^(e=((e+=(o^r)+s[9]-640364487)<<4|e>>>28)+t|0))+s[12]-421815835)<<11|r>>>21)+e|0)^e)^(n=((n+=(i^t)+s[15]+530742520)<<16|n>>>16)+r|0))+s[2]-995338651)<<23|t>>>9)+n|0,t=((t+=((r=((r+=(t^((e=((e+=(n^(t|~r))+s[0]-198630844)<<6|e>>>26)+t|0)|~n))+s[7]+1126891415)<<10|r>>>22)+e|0)^((n=((n+=(e^(r|~t))+s[14]-1416354905)<<15|n>>>17)+r|0)|~e))+s[5]-57434055)<<21|t>>>11)+n|0,t=((t+=((r=((r+=(t^((e=((e+=(n^(t|~r))+s[12]+1700485571)<<6|e>>>26)+t|0)|~n))+s[3]-1894986606)<<10|r>>>22)+e|0)^((n=((n+=(e^(r|~t))+s[10]-1051523)<<15|n>>>17)+r|0)|~e))+s[1]-2054922799)<<21|t>>>11)+n|0,t=((t+=((r=((r+=(t^((e=((e+=(n^(t|~r))+s[8]+1873313359)<<6|e>>>26)+t|0)|~n))+s[15]-30611744)<<10|r>>>22)+e|0)^((n=((n+=(e^(r|~t))+s[6]-1560198380)<<15|n>>>17)+r|0)|~e))+s[13]+1309151649)<<21|t>>>11)+n|0,t=((t+=((r=((r+=(t^((e=((e+=(n^(t|~r))+s[4]-145523070)<<6|e>>>26)+t|0)|~n))+s[11]-1120210379)<<10|r>>>22)+e|0)^((n=((n+=(e^(r|~t))+s[2]+718787259)<<15|n>>>17)+r|0)|~e))+s[9]-343485551)<<21|t>>>11)+n|0,this.first?(this.h0=e+1732584193|0,this.h1=t-271733879|0,this.h2=n-1732584194|0,this.h3=r+271733878|0,this.first=!1):(this.h0=this.h0+e|0,this.h1=this.h1+t|0,this.h2=this.h2+n|0,this.h3=this.h3+r|0)},E.prototype.toString=E.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3;return c[e>>>4&15]+c[15&e]+c[e>>>12&15]+c[e>>>8&15]+c[e>>>20&15]+c[e>>>16&15]+c[e>>>28&15]+c[e>>>24&15]+c[t>>>4&15]+c[15&t]+c[t>>>12&15]+c[t>>>8&15]+c[t>>>20&15]+c[t>>>16&15]+c[t>>>28&15]+c[t>>>24&15]+c[n>>>4&15]+c[15&n]+c[n>>>12&15]+c[n>>>8&15]+c[n>>>20&15]+c[n>>>16&15]+c[n>>>28&15]+c[n>>>24&15]+c[r>>>4&15]+c[15&r]+c[r>>>12&15]+c[r>>>8&15]+c[r>>>20&15]+c[r>>>16&15]+c[r>>>28&15]+c[r>>>24&15]},E.prototype.array=E.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3;return[255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&t,t>>>8&255,t>>>16&255,t>>>24&255,255&n,n>>>8&255,n>>>16&255,n>>>24&255,255&r,r>>>8&255,r>>>16&255,r>>>24&255]},E.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(16),t=new Uint32Array(e);return t[0]=this.h0,t[1]=this.h1,t[2]=this.h2,t[3]=this.h3,e},E.prototype.buffer=E.prototype.arrayBuffer,E.prototype.base64=function(){for(var e,t,n,r="",o=this.array(),i=0;i<15;)e=o[i++],t=o[i++],n=o[i++],r+=p[e>>>2]+p[63&(e<<4|t>>>4)]+p[63&(t<<2|n>>>6)]+p[63&n];return r+(p[(e=o[i])>>>2]+p[e<<4&63]+"==")},(_.prototype=new E).finalize=function(){if(E.prototype.finalize.call(this),this.inner){this.inner=!1;var e=this.array();E.call(this,this.sharedMemory),this.update(this.oKeyPad),this.update(e),E.prototype.finalize.call(this)}};var x=function(){var t=w("hex");s&&(t=function(t){var r,i=Kt,s=e.Buffer;return r=s.from&&!o.JS_MD5_NO_BUFFER_FROM?s.from:function(e){return new s(e)},function(e){if("string"==typeof e)return i.createHash("md5").update(e,"utf8").digest("hex");if(null==e)throw new Error(n);return e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),v(e)||y(e)||e.constructor===s?i.createHash("md5").update(r(e)).digest("hex"):t(e)}}(t)),t.create=function(){return new E},t.update=function(e){return t.create().update(e)};for(var r=0;r<h.length;++r){var i=h[r];t[i]=w(i)}return t}();x.md5=x,x.md5.hmac=function(){var e=S("hex");e.create=function(e){return new _(e)},e.update=function(t,n){return e.create(t).update(n)};for(var t=0;t<h.length;++t){var n=h[t];e[n]=S(n)}return e}(),u?t.exports=x:o.md5=x}()},Mt(qt={exports:{}}),qt.exports);function Gt(e,t=0){return Qt(e,t,2).getUint16(0,!0)}function $t(e,t=0){return Qt(e,t,4).getUint32(0,!0)}function Xt(e,t=0,n=e.byteLength){const r=e.slice(t,t+n);return Yt.decode(new Uint8Array(r))}function Zt(e,t,n=0){if(e.length<t.length+n)return!1;for(const[r,o]of t.entries())if(null!==o&&o!==e[r+n])return!1;return!0}function Qt(e,t,n){const r=e.slice(t,t+n);return new DataView(new Uint8Array(r).buffer)}const Yt=new TextDecoder("utf8"),en=[["db","application/vnd.sqlite3",[83,81,76,105,116,101,32,102,111,114,109,97,116,32,51,0]],["woff","font/woff",[119,79,70,70]],["woff2","font/woff2",[119,79,70,50]],["bmp","image/bmp",[66,77]],["gif","image/gif",[71,73,70,56,55,97]],["gif","image/gif",[71,73,70,56,57,97]],["heic","image/heic",[102,116,121,112,104,101,105],{offset:4}],["heic","image/heic",[102,116,121,112,109],{offset:4}],["ico","image/x-icon",[0,0,1,0]],["jpg","image/jpeg",[255,216,255]],["pdf","application/pdf",[37,80,68,70,45]],["png","image/png",[137,80,78,71,13,10,26,10]],["7z","application/x-7z-compressed",[55,122,188,175,39,28]],["rar","application/x-rar-compressed",[82,97,114,33,26,7,0]],["rar","application/x-rar-compressed",[82,97,114,33,26,7,1,0]],["rtf","application/rtf",[123,92,114,116,102,49]],["bz2","application/x-bzip2",[66,90,104]],["gz","application/gzip",[31,139]],["tar","application/x-tar",[117,115,116,97,114,0,48,48],{offset:257}],["tar","application/x-tar",[117,115,116,97,114,32,32,0],{offset:257}],["tif","image/tiff",[73,73,42,0]],["tiff","image/tiff",[77,77,0,42]],["zip","application/zip",[80,75,3,4],{exact:!1}],["zip","application/zip",[80,75,5,6]],["mp3","audio/mp3",[255,251]],["mp3","audio/mp3",[255,243]],["mp3","audio/mp3",[255,242]],["mp3","audio/mp3",[73,68,51]],["mp4","video/mp4",[102,116,121,112,105,115,111,109],{offset:4}],["avi","video/x-msvideo",[82,73,70,70,null,null,null,null,65,86,73,32]],["wav","audio/wav",[82,73,70,70,null,null,null,null,87,65,86,69]],["ogx","application/ogg",[79,103,103,83],{exact:!1},[["oga","audio/ogg",[127,70,76,65,67],{offset:28}],["ogg","audio/ogg",[1,118,111,114,98,105,115],{offset:28}],["ogm","video/ogg",[1,118,105,100,101,111,0],{offset:28}],["ogv","video/ogg",[128,116,104,101,111,114,97],{offset:28}]]],["webp","image/webp",[82,73,70,70,null,null,null,null,87,69,66,80]],["psd","image/vnd.adobe.photoshop",[56,66,80,83]],["flac","audio/x-flac",[102,76,97,67]],["wasm","application/wasm",[0,97,115,109]],["deb","application/x-deb",[33,60,97,114,99,104,62,10]],["exe","application/x-msdownload",[77,90]],["exe","application/x-msdownload",[90,77]],["class","application/java-vm",[202,254,186,190]]];function tn(e){return e.flatMap(([e,t,n,r={},o=[]])=>[[e,t,n,r],...o])}function nn(e,t){const n=Gt(e,26),r=Xt(e,30,n),[o]=r.split("/"),i=r.endsWith(".xml");return"META-INF"===o?{ext:"jar",mime:"application/java-archive"}:"ppt"===o&&i?{ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}:"word"===o&&i?{ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}:"xl"===o&&i?{ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}:"mimetype"===o?function(e,t){const n=$t(e,18),r=$t(e,22),o=Gt(e,28);if(n===r){const r=Xt(e,30+t+o,n);if("application/vnd.oasis.opendocument.presentation"===r)return{ext:"odp",mime:r};if("application/vnd.oasis.opendocument.spreadsheet"===r)return{ext:"ods",mime:r};if("application/vnd.oasis.opendocument.text"===r)return{ext:"odt",mime:r};if("application/epub+zip"===r)return{ext:"epub",mime:r}}}(e,n)??t:t}const rn=function(e){return tn(e).map(([e,t,n,{offset:r=0}={}])=>n.length+r).reduce((e,t)=>t>e?t:e,0)}(en);function on(e,t){for(const[n,r,o,{exact:i=!0,offset:s=0}={},a=[]]of t)if(Zt(e,o,s)){if("zip"===n&&!i)return nn(e.buffer,{ext:n,mime:r});if(!i&&a.length)for(const[t,n,r,{offset:o=0}={}]of a)if(Zt(e,r,o))return{ext:t,mime:n};return{ext:n,mime:r}}}function sn(e){var t=Vt.md5.create();return t.update(e),t.base64()}function an(e,t){void 0===t&&(t=void 0);var n=function(e,{extra:t=!1,hint:n}={}){const r=new Uint8Array(e.slice(0,rn));if(n){const e=function(e,{ext:t,mime:n}){return t||n?tn(e).filter(e=>e[0]===t||e[1]===n):[]}(en,n);if(e.length>0){const t=on(r,e);if(void 0!==t)return t}}return on(r,en)||(t?function(e){return function(e){try{const t=Xt(e);if(!function(e){for(let t=0;t<e.length;t++)try{const n=e.charCodeAt(t);if(65533===n||n<=8)return!1}catch{return!1}return!0}(t))return;try{return JSON.parse(t),{ext:"json",mime:"application/json"}}catch{return{ext:"txt",mime:"text/plain"}}}catch{return}}(e)}(e):void 0)}(e);if(n)return n.mime;for(var r=new Uint8Array(e).subarray(0,4),o="",i=0;i<r.length;i++)o+=r[i].toString(16);var s="unknown";switch(o){case"676c5446":s="model/gltf-binary";break;case"89504e47":s="image/png";break;case"ffd8ffe0":case"ffd8ffe1":case"ffd8ffe2":case"ffd8ffe3":case"ffd8ffe8":s="image/jpeg";break;default:s="unknown"}return"unknown"===s&&"string"==typeof t&&(s=un(t)),s}function un(e){var t=e.toLowerCase(),n="";return t.endsWith(".html")||t.endsWith(".html.gz")?n="text/html":t.endsWith(".js")||t.endsWith(".js.gz")?n="application/javascript":t.endsWith(".wasm")?n="application/wasm":t.endsWith(".css")?n="text/css":t.endsWith(".json")?n="application/json":t.endsWith(".txt")?n="text/plain":t.endsWith(".bin")?n="application/octet-stream":t.endsWith(".png")?n="image/png":t.endsWith(".jpg")||t.endsWith(".jpeg")?n="image/jpeg":t.endsWith(".gif")?n="image/gif":t.endsWith(".webp")?n="image/webp":t.endsWith(".svg")?n="image/svg+xml":t.endsWith(".glb")?n="model/gltf-binary":t.endsWith(".gltf")?n="model/gltf+json":t.endsWith(".vrm")?n="model/gltf-binary":t.endsWith(".usdz")?n="model/vnd.usdz+zip":t.endsWith(".usda")?n="model/vnd.usd-usda":t.endsWith(".usdc")?n="model/vnd.usd-usdc":t.endsWith(".usd")?n="model/vnd.usd-usd":t.endsWith(".mtl")?n="model/mtl":t.endsWith(".obj")?n="model/obj":t.endsWith(".fbx")?n="model/vnd.autodesk.fbx":t.endsWith(".stl")&&(n="model/stl"),n}function ln(e,t,n){void 0===t&&(t=void 0),void 0===n&&(n=!0);var r=Math.abs(e);if(r>=1099511627776){var o=n?" TB":"";return(e/1099511627776).toFixed(void 0===t?2:t)+o}if(r>=1073741824){var i=n?" GB":"";return(e/1073741824).toFixed(void 0===t?2:t)+i}if(r>=1048576){var s=n?" MB":"";return(e/1048576).toFixed(void 0===t?1:t)+s}if(r>=1024){var a=n?" KB":"";return(e/1024).toFixed(void 0===t?0:t)+a}var u=n?" B":"";return e.toFixed(0)+u}"undefined"==typeof Symbol||Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"));var cn=function(e){try{return Promise.resolve(new Promise(function(t){return setTimeout(t,e)}))}catch(e){return Promise.reject(e)}},fn=/*#__PURE__*/O(/^image_(\d+)_|^mesh_lod_(\d+)_/,{image_lod:1,mesh_lod:2});function dn(e,t,n){if(!e.s){if(n instanceof hn){if(!n.s)return void(n.o=dn.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(dn.bind(null,e,t),dn.bind(null,e,2));e.s=t,e.v=n;const r=e.o;r&&r(e)}}var hn=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var i=1&o?t:n;if(i){try{dn(r,1,i(this.v))}catch(e){dn(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?dn(r,1,t?t(o):o):n?dn(r,1,n(o)):dn(r,2,o)}catch(e){dn(r,2,e)}},r},e}();function pn(e){return e instanceof hn&&1&e.s}function mn(e){return e.includes("\\u")?JSON.parse('"'+e+'"'):decodeURIComponent(e)}function gn(e){for(var t=-1,n=Infinity,r=0;r<e.length;r++){var o=e[r];o.path.split("/").length<n&&(n=o.path.split("/").length,t=r)}return t<0?null:e[t]}var vn=/*#__PURE__*/function(){function e(e,t){this.totalFiles=e,this.estimatedTotalSize=t,this.uploadedSize=0,this.startTime=Date.now(),this.lastUpdateTime=this.startTime,this.lastUploadedSize=0,this.speedEMA=null,this.emaFactor=.1,this.smoothedRemainingTime=null,this.recentSpeeds=new Array,this.maxRecentSpeeds=20,this.initialEstimateThreshold=.05}var t=e.prototype;return t.updateProgress=function(e){var t=Date.now(),n=(t-this.lastUpdateTime)/1e3,r=e-this.lastUploadedSize;if(this.uploadedSize=e,n>0&&r>0){this.recentSpeeds.push(r/n),this.recentSpeeds.length>this.maxRecentSpeeds&&this.recentSpeeds.shift();var o=this.recentSpeeds.reduce(function(e,t){return e+t},0)/this.recentSpeeds.length;this.speedEMA=null===this.speedEMA?o:this.emaFactor*o+(1-this.emaFactor)*this.speedEMA}this.lastUpdateTime=t,this.lastUploadedSize=e;var i,s=this.uploadedSize/this.estimatedTotalSize,a=(t-this.startTime)/1e3,u=this.speedEMA&&this.speedEMA>0?this.speedEMA:this.uploadedSize/a;return i=u>0?(this.estimatedTotalSize-this.uploadedSize)/u:Infinity,this.smoothedRemainingTime=s>=this.initialEstimateThreshold?null===this.smoothedRemainingTime?i:.9*this.smoothedRemainingTime+.1*i:a/s-a,this.smoothedRemainingTime=Math.max(this.smoothedRemainingTime,(this.estimatedTotalSize-this.uploadedSize)/u),{progress:100*s,estimatedTimeRemaining:Math.round(this.smoothedRemainingTime),estimatedTimeRemainingString:this.smoothedRemainingTime>3?this.__formatTime(this.smoothedRemainingTime):"few seconds"}},t.__formatTime=function(e){if(!isFinite(e)||e>86400)return"Calculating...";if(e<60)return Math.round(e)+"sec";var t=Math.floor(e/60);return t<60?t+"min":Math.floor(t/60)+"h "+t%60+"min"},e}();function yn(e,t,n){if(!e.s){if(n instanceof bn){if(!n.s)return void(n.o=yn.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(yn.bind(null,e,t),yn.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}"undefined"==typeof Symbol||Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"));var bn=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var i=1&o?t:n;if(i){try{yn(r,1,i(this.v))}catch(e){yn(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?yn(r,1,t?t(o):o):n?yn(r,1,n(o)):yn(r,2,o)}catch(e){yn(r,2,e)}},r},e}();function wn(e){return e instanceof bn&&1&e.s}function Sn(e,t,n){var r,o,i=-1;return function s(a){try{for(;++i<e.length&&(!n||!n());)if((a=t(i))&&a.then){if(!wn(a))return void a.then(s,o||(o=yn.bind(null,r=new bn,2)));a=a.v}r?yn(r,1,a):r=a}catch(e){yn(r||(r=new bn),2,e)}}(),r}function En(e,t,n){for(var r;;){var o=e();if(wn(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!wn(i)){r=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!wn(s)){r=2;break}}}var a=new bn,u=yn.bind(null,a,2);return(0===r?o.then(c):1===r?i.then(l):s.then(f)).then(void 0,u),a;function l(r){i=r;do{if(t&&(s=t())&&s.then&&!wn(s))return void s.then(f).then(void 0,u);if(!(o=e())||wn(o)&&!o.v)return void yn(a,1,i);if(o.then)return void o.then(c).then(void 0,u);wn(i=n())&&(i=i.v)}while(!i||!i.then);i.then(l).then(void 0,u)}function c(e){e?(i=n())&&i.then?i.then(l).then(void 0,u):l(i):yn(a,1,i)}function f(){(o=e())?o.then?o.then(c).then(void 0,u):c(o):yn(a,1,i)}}var _n=[];new Array;var xn=function(e){try{return Promise.resolve(m.requestAccessToken(e).then(function(t){return{authToken:t,org:e||void 0}}))}catch(e){return Promise.reject(e)}},Tn=function(e,t){try{return Promise.resolve(xn(t.org)).then(function(n){if(!n)throw new Error("Not authenticated");var r=e.map(function(e){return function(e,t){if(void 0===t&&(t=null),"object"==typeof(r=e)&&"string"==typeof r.name&&"string"==typeof r.mimetype){var n=e.mimetype||un(e.name);e=new File([e.buffer],e.name,{type:n})}else e.type||(e=new File([e],e.name,{type:un(e.name)}));var r,o=e;return null==t&&(t=e.webkitRelativePath||""),o.path=t+e.name,o}(e)});return function(e,t,n){void 0===n&&(n=void 0);try{var r=function(e,t,n){void 0===n&&(n=void 0);try{var r,o=t.files,i=(null==(r=n)?void 0:r.loglevel)||"none";if(!o.length)return"none"!=i&&console.error("No files to upload"),Promise.resolve({success:!1,error:"No files to upload"});if(!t.entrypoint){var s=function(e){var t=null,n="",r=e.filter(function(e){return"index.html"===e.name.toLowerCase()||"index.html.gz"===e.name.toLowerCase()||"index.html.br"===e.name.toLowerCase()});if(1===r.length)return r[0];var o=e.filter(function(e){return e.name.toLowerCase().endsWith(".html")||e.name.toLowerCase().endsWith(".htm")||e.name.toLowerCase().endsWith(".html.gz")||e.name.toLowerCase().endsWith(".html.br")});if(1===o.length)return o[0];if(o.length>1){for(var i,s=new Map,a=w(o);!(i=a()).done;){var u=i.value,l=u.path.split("/"),c=s.get(l.length);c||s.set(l.length,c=[]),c.push(u)}var f=Array.from(s.keys()).sort(function(e,t){return e-t});if(f.length>0)for(var d,h=w(f);!(d=h()).done;){var p=s.get(d.value);if(p)return p.find(function(e){return"index.html"===e.name.toLowerCase()||"index.html.gz"===e.name.toLowerCase()||"index.html.br"===e.name.toLowerCase()})||p[0]}return n="Invalid upload: Multiple HTML files found but could not determine root.",console.error(n,o.map(function(e){return e.path||e.name})),{error:n}}var m=e.filter(function(e){return e.name.toLowerCase().endsWith(".glb")||e.name.toLowerCase().endsWith(".gltf")||e.name.toLowerCase().endsWith(".vrm")});if(m.length>1){var g=function(e){for(var t,n=new Array,r=/(mesh_lod|image)_\d_(.{1,50})/,o=w(e);!(t=o()).done;){var i=t.value;if(!r.test(i.name)){var s=i.name.toLowerCase();(s.endsWith(".gltf")||s.endsWith(".vrm")||s.endsWith(".glb"))&&n.push(i)}}return 1==n.length?n[0]:gn(n)}(m);return g?t=g:(n="Invalid upload: Multiple glb/glTF/vrm files found. This is currently not supported.",console.error(n,m.map(function(e){return e.path||e.name})),{error:n})}if(1===m.length)return m[0];var v=e.filter(function(e){return e.name.toLowerCase().endsWith(".usdz")||e.name.toLowerCase().endsWith(".usd")||e.name.toLowerCase().endsWith(".usda")||e.name.toLowerCase().endsWith(".usdc")});v.length>=1&&(t=gn(v));var y=e.filter(function(e){return e.name.toLowerCase().endsWith(".fbx")});if(y.length>1)return n="Invalid upload: Multiple fbx files found. This is currently not supported.",console.error(n,y),{error:n};if(1===y.length)return y[0];var b=e.filter(function(e){return e.name.toLowerCase().endsWith(".obj")});if(b.length>1)return n="Invalid upload: Multiple obj files found. This is currently not supported.",console.error(n,b),{error:n};if(1===b.length)return b[0];var S=e.filter(function(e){return e.name.toLowerCase().endsWith(".stl")});if(S.length>1)return n="Invalid upload: Multiple stl files found. This is currently not supported.",console.error(n,S),{error:n};if(1===S.length)return S[0];if(1===e.length&&!e[0].arrayBuffer&&e[0].path.toLowerCase().startsWith("http"))return e[0];var E=e.filter(function(e){return e.name.toLowerCase().endsWith("package.json")});return 1===E.length?t=E[0]:E.length>1?(n="Invalid upload: Multiple package.json files found. This is currently not supported.",console.error(n,E),{error:n}):t||{error:"No supported file to upload found..."}}(o);if(null==s)return Promise.resolve({success:!1,error:"No entrypoint file found"});if("object"==typeof s&&"error"in s)return Promise.resolve({success:!1,error:s.error});"info"===i&&console.log("Entrypoint: "+s.name),t.entrypoint=s}return t.entrypoint&&!o.includes(t.entrypoint)&&o.push(t.entrypoint),Promise.resolve(function(e){try{var t,n=function(e){return t?e:{success:!0,vrm_count:o,gltf_count:i,glb_count:s}};if(e.length>5e3)return Promise.resolve({success:!1,error:"Too many files. Maximum filecount is 5000"});var r=0,o=0,i=0,s=0,a=e.length-1,u=function(e,t,n){for(var r;;){var o=e();if(pn(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!pn(i)){r=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!pn(s)){r=2;break}}}var a=new hn,u=dn.bind(null,a,2);return(0===r?o.then(c):1===r?i.then(l):s.then(f)).then(void 0,u),a;function l(r){i=r;do{if(t&&(s=t())&&s.then&&!pn(s))return void s.then(f).then(void 0,u);if(!(o=e())||pn(o)&&!o.v)return void dn(a,1,i);if(o.then)return void o.then(c).then(void 0,u);pn(i=n())&&(i=i.v)}while(!i||!i.then);i.then(l).then(void 0,u)}function c(e){e?(i=n())&&i.then?i.then(l).then(void 0,u):l(i):dn(a,1,i)}function f(){(o=e())?o.then?o.then(c).then(void 0,u):c(o):dn(a,1,i)}}(function(){return!t&&a>=0},function(){return a--},function(){var n=e[a];if((r+=n.size)>1073741824){var u={success:!1,error:"Total file size exceeds limit of "+1024..toFixed(0)+" MB. Please reduce the size of your upload."};return t=1,u}var l,c=n.name.toLocaleLowerCase();if(".ds_store"!==c)return c.endsWith(".gltf")?i++:c.endsWith(".glb")?(l=c)&&fn.test(l)||s++:c.endsWith(".vrm")&&o++,function(){if(c.endsWith(".gltf"))return i+=1,console.log("Found glTF file "+n.name+". Will check if all dependencies are available\n",e),Promise.resolve(n.text()).then(function(r){var o,i=r.matchAll(/*#__PURE__*/O(/"uri"\s*:\s*"(.*?)"/g,{value:1}));if(i){var s=JSON.parse(r);if("2.0"!==s.asset.version)return console.warn("⚠ glTF version is not 2.0. This is currently not supported."),t=1,{success:!1,error:"glTF version "+s.asset.version+" is unsupported.Please use glTF 2.0."};for(var a,u=null==(o=n.path)?void 0:o.split("/"),l=u.splice(0,u.length-1).join("/"),c=w(i);!(a=c()).done;){var f,d=null==(f=a.value.groups)?void 0:f.value;if(d){var h=!1;if(d.startsWith("http://")||d.startsWith("https://")||d.startsWith("www.")){console.log("✅ Found remote dependency "+d+" ");break}if(d.startsWith("data:")){console.log("✅ Found embedded dependency "+d+" ");break}var p=(l+"/"+mn(d)).split("/").reduce(function(e,t){return"."===t||(".."===t?e.pop():null!=t&&t.length&&e.push(t)),e},[]).join("/");console.log('❓ Check if local dependency exists "'+p+'"');for(var m,g=w(e);!(m=g()).done;){var v=m.value;if(v.webkitRelativePath===p||v.name==p){h=!0,console.log("✅ Found dependency in name or webkit: "+v.name+" || "+v.webkitRelativePath+" ");break}if(v.path===p){h=!0,console.log("✅ Found dependency in path: "+v.path+" ");break}}if(!h)return console.warn("⚠ Missing dependency "+d,l),t=1,{success:!1,error:"Missing resource: "+d}}}}})}();e.splice(a,1)});return Promise.resolve(u&&u.then?u.then(n):n(u))}catch(e){return Promise.reject(e)}}(o)).then(function(r){var s,a,u,l,c;function f(r){var s,a,u,l,f,d;if(c)return r;function h(r){return Promise.resolve(fetch(p+"/v1/upload/request",S({},A,{method:"POST",headers:g,body:JSON.stringify(v)})).catch(function(e){return"fetch failed"==e.message||"Failed to fetch"==e.message?"Network error. Make sure you are connected to the internet and "+p+" is reachable.":(console.error("Failed to begin upload\n",e),null)})).then(function(r){var s;function a(a){return s?a:Promise.resolve(r.json()).then(function(r){var s,a,u;function l(){return Promise.resolve(Promise.all(_).catch(function(e){var t;null!=(t=n)&&null!=(t=t.abort)&&t.aborted?console.warn("Upload aborted"):(console.error(e.message),x=!0)})).then(function(){var t;function s(s){var a;if(t)return s;function u(t){var n;if(a)return t;function s(){var e;function t(t){return e?t:("none"!=i&&console.log("Upload complete"),Promise.resolve(l.json()).then(function(e){return{success:!0,type:e.type,uploadSkipped:!1,id:e.id,view_id:e.view_id,url:e.url,filesUploaded:o.length,totalSize:c}}))}if(!l)return console.error("Failed to complete upload"),{success:!1,error:"Failed to complete upload"};var n=function(){if(!l.ok)return 524===l.status?(console.error("Failed to complete upload: Gateway Timeout"),e=1,{success:!1,error:"Failed to complete upload: Gateway Timeout"}):Promise.resolve(l.text()).then(function(t){return console.error("Failed to complete upload ("+l.status+"): "+t),e=1,{success:!1,error:"Failed to complete upload"}})}();return n&&n.then?n.then(t):t(n)}h=!0,console.log("Upload Done: All files uploaded to "+r.id);var u=S({},R(e),{id:r.id});"none"!=i&&console.log("Completing upload - notify server");var l=null,f=0,d=En(function(){return!n&&f<5},function(){return f++},function(){return Promise.resolve(cn(1e3*f)).then(function(){var e=AbortSignal.timeout(2e4+1e3*f);return Promise.resolve(fetch(p+"/v1/upload/done",S({},A,{method:"POST",headers:u,signal:e})).catch(function(e){return console.error("Failed to complete upload ("+(f+1)+" / 5)",e.message),null})).then(function(e){var t,r;!0!==(null==(t=l=e)?void 0:t.ok)?"none"!=i&&f<4&&console.warn("Failed to complete upload ("+((null==(r=l)?void 0:r.status)||"no status")+"): will retry in 1 second"):n=1})})});return d&&d.then?d.then(s):s()}var l=function(t){if(null!=(t=n)&&null!=(t=t.abort)&&t.aborted)return Promise.resolve(Jt({identifier:r.id,status:"canceled",status_message:"Upload aborted",error:"Upload aborted"},e)).then(function(){return a=1,{success:!1,error:"Upload aborted"}})}();return l&&l.then?l.then(u):u(l)}var a=function(){if(x)return Promise.resolve(Jt({identifier:r.id,status:"failed",error:"Failed to upload files"},e)).then(function(){return t=1,{success:!1,error:"Failed to upload files"}})}();return a&&a.then?a.then(s):s(a)})}"debug"===i&&console.debug("BeginResponse",r);var c=o.reduce(function(e,t){return e+t.size},0);if("exists"===r.type)return"none"!=i&&console.log("Upload already exists",r.id),{success:!0,uploadSkipped:!0,id:r.id,type:r.job_type,view_id:r.view_id,filesUploaded:o.length,totalSize:c,url:r.url};var f=t.entrypoint.webkitRelativePath||t.entrypoint.name,d=0;null==(s=n)||null==(s=s.abort)||s.addEventListener("abort",function(){try{return console.log("Upload aborted: Cancelling upload"),Promise.resolve(fetch(p+"/v1/upload/cancel",S({},A,{method:"POST",headers:{authorization:m,id:r.id}}))).then(function(){})}catch(e){return Promise.reject(e)}});var h=!1;function g(t,n,o){if(void 0===o&&(o=!1),!o&&Date.now()-b<1e3)return!1;if(!h||"completed"===n){b=Date.now();var s=Math.floor(d/c*100);return"debug"===i&&console.log("SET STATUS: "+n,t,s),Jt({identifier:r.id,status:n,status_message:t,progress:s},e),!0}"none"!=i&&console.warn("Invalid status update...")}var b=Date.now();null!=(a=n)&&a.onStart&&n.onStart(r.id,r.view_id);var w=Date.now(),E=new vn(o.length,c/1024/1024),_=new Array,x=!1,T=[].concat(o),O=o.length,P=Sn(T,function(s){var a;if(null!=(a=n)&&null!=(a=a.abort)&&a.aborted)return console.debug("Upload aborted"),void(u=1);if(x)return console.debug("Upload failed"),void(u=1);if(_.length<10){console.debug("Uploading file "+s+"/"+o.length+": "+o[s].name);var l=0,h=0,p=v.results.files[s],m=p.filename,b=y[s],T=p.content_length,P=p.content_type,j=o[s],C=j.name.endsWith(".gz")?"gzip":j.name.endsWith(".br")?"br":void 0,U=function(e){try{var t,n=function(t){var n;function o(e){var t=function(){if(!h)return console.error("Failed to upload file "+a),Promise.resolve(Jt({identifier:r,status:"failed",status_message:"Failed to upload file "+a,error:"Failed to upload file "+a},v)).then(function(){throw new Error("Failed to upload file "+a)})}();return!t||!t.then||t.then(function(e){return!0})}if(null==x)throw new Error('Failed to get presigned url for "'+a+'" "'+f+'" \n'+T);var i=x.presigned_url,h=!1,w=0,E=En(function(){return!n&&w<5},function(){return w++},function(){function t(){var t;if(null!=y&&null!=(t=y.abort)&&t.aborted)throw new It("Upload aborted");var r={"Content-Type":f,"Content-MD5":l};return b&&(r["Content-Length"]=c.toString()),d&&(r["Content-Encoding"]=d),0===w&&"none"!=g&&console.log("Uploading file "+p+"/"+m+": "+a),"debug"===g&&console.debug("PUT with headers",r),Promise.resolve(Dt.put(i,u,S({},A,{withCredentials:!1,signal:null==y?void 0:y.abort,headers:r,onUploadProgress:function(t){e.onProgress(t)}})).catch(function(e){return e instanceof It||("none"!==g&&console.error("Failed to upload file (PUT) ("+p+", "+a+') "'+e.message+'"'),"debug"===g&&(console.log(r,{fileSize:c}),e.response?console.debug(e.response):console.debug(e))),null})).then(function(e){if(e)return 200!==e.status?void console.debug("Failed ("+e.status+" "+e.status+") to upload file "+s.name+' to "'+x.path+'". Retrying...'):(h=!0,"info"===g&&console.log("Uploaded file "+p+"/"+m+' "'+a+'" ('+f+", "+ln(c)+")"),void(n=1))})}var r=function(){if(w>0)return"none"!==g&&console.log("Retry PUT #"+w+" for file "+a),Promise.resolve(cn(1e3*w)).then(function(){})}();return r&&r.then?r.then(t):t()});return E&&E.then?E.then(o):o()},r=e.uploadId,o=e.uploadRequestPUTUrl,i=e.entrypointPath,s=e.file,a=e.fileName,u=e.fileBuffer,l=e.fileMd5,c=e.fileSize,f=e.fileType,d=e.content_encoding,h=e.fileIndex,p=e.fileNumber,m=e.fileCount,g=e.loglevel,v=e.args,y=e.options,b=e.experimental;"info"===g&&console.log('Uploading file "'+s.name+'" type='+f+" ("+c+") "+s.type+" with hash "+l);var w=S({},R(v),{"Content-Type":"application/json",org:v.org,job_id:r,filesize:c.toString(),progress:(h/m*100).toFixed(0)}),E={filename:a,entrypoint:i,"content-type":f,"content-md5":l,"content-encoding":d};"debug"===g&&console.debug("Requesting presigned URL with headers",w);var _=JSON.stringify(E),x=null,T="",O=0,P=En(function(){return!t&&O<5},function(){return O++},function(){var e;if(null==x){if(null!=y&&null!=(e=y.abort)&&e.aborted)throw new Error("Upload aborted");return Promise.resolve(cn(200*O)).then(function(){return Promise.resolve(fetch(o,S({},A,{method:"POST",headers:w,body:_})).then(function(e){try{var t,n=function(n){return t?n:Promise.resolve(e.json())},r=function(){if(!e.ok)return Promise.resolve(e.text()).then(function(n){return T=n,console.log(o),console.warn('Failed to get presigned url for "'+a+'" "'+f+'" ('+e.status+").\n→ Retrying..."),t=1,null})}();return Promise.resolve(r&&r.then?r.then(n):n(r))}catch(e){return Promise.reject(e)}}).catch(function(e){return T=e.message,console.warn("Failed to get presigned url "+e.message+", retrying..."),null})).then(function(e){x=e})})}t=1});return Promise.resolve(P&&P.then?P.then(n):n())}catch(e){return Promise.reject(e)}}({uploadId:r.id,uploadRequestPUTUrl:r.request_put_url,entrypointPath:f,file:o[s],fileName:m,fileMd5:p.content_md5,fileBuffer:b,fileType:P,content_encoding:C,fileSize:T,fileIndex:s,fileNumber:s+1,fileCount:O,loglevel:i,experimental:t.experimental,args:e,options:n,onProgress:function(e){var t,r=e.progress||0,i=(l=o[s].size*r)-h;if(h=l,d+=i,null!=(t=n)&&t.progress){var a=d/c,u=o.length,f=o[s].size,p=(Date.now()-w)/1e3,v=E.updateProgress(d/1024/1024);n.progress({uploadedBytes:d,totalBytes:c,progress01:a,fileName:o[s].name,fileSize:f,fileProgress01:r,fileIndex:s,totalFiles:u,estimatedTimeLeftDisplay:v.estimatedTimeRemainingString,estimatedTimeLeft:v.estimatedTimeRemaining,elapsedTime:p}),g("Uploading file "+(s+1)+"/"+u+" ("+m+"): "+(100*r).toFixed(0)+"% of "+ln(c)+". Finished in approx. "+v.estimatedTimeRemainingString,"running",!1)}}}).then(function(e){if(!0!==e)return e;for(var t=_.length-1;t>=0;t--)_[t]===U&&_.splice(t,1);g("Uploaded "+ln(d)+" of "+ln(c)+" for "+o[s].name,"running")}).catch(function(e){var t;null!=(t=n)&&null!=(t=t.abort)&&t.aborted?console.warn("Upload aborted"):(console.error(e.message),x=!0)});_.push(U)}var k=function(){if(_.length>=10)return Promise.resolve(Promise.race(_)).then(function(){})}();return k&&k.then?k.then(function(){}):void 0},function(){return u});return P&&P.then?P.then(l):l()})}if(null===r||"string"==typeof r)return{success:!1,error:r||"Failed to begin upload"};var u=function(){if(!r.ok)return Promise.resolve(r.text()).then(function(e){if(e.startsWith("{")){var t=JSON.parse(e);if("error"in t)return s=1,{success:!1,status:r.status,error:t.error}}return"none"!=i&&console.error("Failed to begin upload\n",r.status,e),s=1,{success:!1,status:r.status,error:""+e}})}();return u&&u.then?u.then(a):a(u)})}o.sort(function(e,t){return e.name.includes(".needle")&&!t.name.includes(".needle")?-1:!e.name.includes(".needle")&&t.name.includes(".needle")?1:0});var p=e.baseUrl,m="Bearer "+e.authToken,g=S({},R(e),{triggered_by:t.triggered_by,filename:""+encodeURIComponent(t.entrypoint.name),"total-files":o.length.toString(),"total-files-size":o.reduce(function(e,t){return e+t.size},0).toString()});null!=(s=n)&&s.view_id&&(g.view_id=n.view_id),null!=(a=n)&&a.type&&(g.type=n.type),null!=(u=n)&&u.name&&(g.name=encodeURIComponent(n.name)),null!=(l=n)&&l.parent_job_id&&(g.parent_job_id=n.parent_job_id);var v={results:{entrypoint:(null==(f=t.entrypoint)?void 0:f.path)||(null==(d=t.entrypoint)?void 0:d.name),files:[]}},y=[],b=Sn(o,function(e){var t,r=o[e],i=r.path||r.webkitRelativePath||r.name;if(null!=(t=i)&&t.includes(":"))throw new Error("Invalid filename: "+i);return Promise.resolve(r.arrayBuffer()).then(function(t){var o,s,a,u,l,c=r.size,f=r.type;if(null!=(o=f)&&o.length&&"unknown"!==f.toLowerCase()||(f=an(t,i)),"deployment"===(null==(s=n)?void 0:s.type)){var d=(u=f,l=(a=i).toLowerCase(),"application/gzip"===u||"application/brotli"===u?(l.endsWith(".html.gz")||l.endsWith(".html.br")?(u="text/html",a=a.substring(0,a.length-3)):l.endsWith(".js.gz")||l.endsWith(".js.br")||l.endsWith(".mjs.gz")||l.endsWith(".mjs.br")||l.endsWith(".cjs.gz")||l.endsWith(".cjs.br")?(u="application/javascript",a=a.substring(0,a.length-3)):l.endsWith(".css.gz")||l.endsWith(".css.br")?(u="text/css",a=a.substring(0,a.length-3)):l.endsWith(".json.gz")||l.endsWith(".json.br")?(u="text/json",a=a.substring(0,a.length-3)):l.endsWith(".txt.gz")||l.endsWith(".txt.br")?(u="text/plain",a=a.substring(0,a.length-3)):l.endsWith(".wasm.gz")||l.endsWith(".wasm.br")?(u="application/wasm",a=a.substring(0,a.length-3)):l.endsWith(".bin.gz")||l.endsWith(".bin.br")?(u="application/octet-stream",a=a.substring(0,a.length-3)):l.endsWith(".png.gz")||l.endsWith(".png.br")?(u="image/png",a=a.substring(0,a.length-3)):l.endsWith(".jpg.gz")||l.endsWith(".jpg.br")||l.endsWith(".jpeg.gz")||l.endsWith(".jpeg.br")?(u="image/jpeg",a=a.substring(0,a.length-3)):l.endsWith(".gif.gz")||l.endsWith(".gif.br")?(u="image/gif",a=a.substring(0,a.length-3)):l.endsWith(".webp.gz")||l.endsWith(".webp.br")?(u="image/webp",a=a.substring(0,a.length-3)):l.endsWith(".svg.gz")||l.endsWith(".svg.br")?(u="image/svg+xml",a=a.substring(0,a.length-3)):l.endsWith(".ico.gz")||l.endsWith(".ico.br")?(u="image/x-icon",a=a.substring(0,a.length-3)):l.endsWith(".webm.gz")||l.endsWith(".webm.br")?(u="video/webm",a=a.substring(0,a.length-3)):l.endsWith(".mp4.gz")||l.endsWith(".mp4.br")?(u="video/mp4",a=a.substring(0,a.length-3)):l.endsWith(".mov.gz")||l.endsWith(".mov.br")?(u="video/quicktime",a=a.substring(0,a.length-3)):l.endsWith(".mp3.gz")||l.endsWith(".mp3.br")?(u="audio/mpeg",a=a.substring(0,a.length-3)):l.endsWith(".wav.gz")||l.endsWith(".wav.br")?(u="audio/wave",a=a.substring(0,a.length-3)):l.endsWith(".ogg.gz")||l.endsWith(".ogg.br")?(u="audio/ogg",a=a.substring(0,a.length-3)):l.endsWith(".flac.gz")||l.endsWith(".flac.br")?(u="audio/flac",a=a.substring(0,a.length-3)):l.endsWith(".glb.gz")||l.endsWith(".glb.br")?(u="model/gltf-binary",a=a.substring(0,a.length-3)):l.endsWith(".gltf.gz")||l.endsWith(".gltf.br")?(u="model/gltf+json",a=a.substring(0,a.length-3)):l.endsWith(".vrm.gz")||l.endsWith(".vrm.br")?(u="model/gltf-binary",a=a.substring(0,a.length-3)):l.endsWith(".usdz.gz")||l.endsWith(".usdz.br")?(u="model/vnd.usdz+zip",a=a.substring(0,a.length-3)):l.endsWith(".obj.gz")||l.endsWith(".obj.br")?(u="model/obj",a=a.substring(0,a.length-3)):(l.endsWith(".mtl.gz")||l.endsWith(".mtl.br"))&&(u="model/mtl",a=a.substring(0,a.length-3)),{filename:a,mimetype:u}):null);d&&(i=d.filename,f=d.mimetype)}var h=sn(t);y[e]=t,v.results.files[e]={filename:i,content_type:f,content_length:c,content_md5:h}})},function(){});return b&&b.then?b.then(h):h()}if("error"in r)return{success:!1,error:r.error||"Failed to validate files"};if(null!=(s=t.entrypoint)&&s.name.endsWith(".htm")||null!=(a=t.entrypoint)&&a.name.endsWith(".html")||null!=(u=t.entrypoint)&&u.name.endsWith(".html.gz")||null!=(l=t.entrypoint)&&l.name.endsWith(".html.br"))n||(n={}),n.type="deployment";else if(r.vrm_count>10)return{success:!1,error:"Multiple model files found - this is not supported for asset uploads. Please upload a single model file only."};var d=function(){if(!t.raw)return Sn(o,function(e){var r=o[e],i=r.name.toLowerCase();return function(){var s;if(i.endsWith(".html")||i.endsWith(".js")||i.endsWith(".css"))return"none"!==(null==(s=n)?void 0:s.loglevel)&&console.log("gZip compressing file: "+r.name),Promise.resolve(function(e){try{return Promise.resolve(import("./pako.esm-01431bd2.js")).then(function(t){return Promise.resolve(e.arrayBuffer()).then(function(n){var r=t.gzip(new Uint8Array(n)).buffer.slice(0);if(r.byteLength>51200&&r.byteLength>=n.byteLength){if(n.byteLength>0)return null}else if(!(r instanceof ArrayBuffer))return console.error("gzipCompress: Invalid ArrayBuffer"),{error:'Gzip compressing failed for "'+e.name+'" (unexpected result)'};return function(e,t,n){var r;void 0===n&&(n=void 0);var o=function(e,t,n){for(var r=0;;){var o=e.indexOf("\\",r);if(-1===o)break;r=o+1,e=e.replace("\\","/")}return e}(e).split("/").pop()||e,i=(null==(r=n)?void 0:r.type)||an(t,e),s=new File([t],o,{type:i});return s.path=e,s}(("path"in e?e.path:e.name)+".gz",r,{type:"application/gzip"})})})}catch(e){return Promise.reject(e)}}(r).catch(function(e){return{error:"Error compressing "+r.name+": "+e.message}})).then(function(i){var s;if(null!==i){if("error"in i)return c=1,{success:!1,error:i.error,status:500};if(!i)return c=1,{success:!1,error:"Failed to compress "+r.name,status:500};var a=t.entrypoint===r;o[e]=i,a&&(t.entrypoint=i),"none"!==(null==(s=n)?void 0:s.loglevel)&&console.log("gZip compressed file: "+r.name+" "+(a?"(entrypoint)":""))}else{var u;"none"!==(null==(u=n)?void 0:u.loglevel)&&console.error("Did not compress file: "+r.name)}})}()},function(){return c});"none"!=i&&console.warn("Raw upload - skipping gzip compression of files")}();return d&&d.then?d.then(f):f(d)})}catch(e){return Promise.reject(e)}}(e,t,n);return _n.push(r),Promise.resolve(r.finally(function(){var e=_n.indexOf(r);e>=0&&_n.splice(e,1)}))}catch(e){return Promise.reject(e)}}(S({baseUrl:"https://cloud.needle.tools/api"},n,t),{triggered_by:"web",entrypoint:void 0,files:r},{name:t.name,abort:t.abort}).then(function(e){return"error"in e?{error:e.error}:{job_id:e.id,view_id:e.view_id,url:e.url,skipped:e.uploadSkipped}})})}catch(e){return Promise.reject(e)}},On=function(e){try{return Promise.resolve(xn()).then(function(t){if(!t)return null;console.log({auth:t});var n=function(e,t){try{var n=e.baseUrl+"/v1/account/get/licenses",r=S({},t),o=S({},r,R(e));return Promise.resolve(fetch(n,S({},A,{method:"GET",headers:o})).catch(function(e){return console.error(e),null})).then(function(e){var t;function n(n){return t?n:Promise.resolve(e.json()).then(function(e){return e.licenses})}if(!e)return[];var r=function(){if(!e.ok){var n=e.statusText;return Promise.resolve(e.text()).then(function(e){return console.error(n,e),t=1,[]})}}();return r&&r.then?r.then(n):n(r)})}catch(e){return Promise.reject(e)}}(S({baseUrl:"https://cloud.needle.tools/api"},t),{type:"user","x-needle-product":Array.isArray(e.product)?e.product.join(","):e.product});return n})}catch(e){return Promise.reject(e)}},Pn=function(e){try{return Promise.resolve(xn(e.org)).then(function(t){if(!t)throw new Error("Not authenticated");return Promise.resolve(function(e){try{var t=new URL((e.endpoint||"https://cloud.needle.tools/api")+"/v1/list/deployments");return t.searchParams.append("offset",e.offset.toString()),t.searchParams.append("limit",e.limit.toString()),e.names&&t.searchParams.append("name",e.names.map(function(e){return e.trim()}).join(",")),Promise.resolve(fetch(t,{method:"GET",headers:S({},R({authToken:e.authToken,org:e.org}))})).then(function(e){var t;function n(n){return t?n:Promise.resolve(e.json())}var r=function(){if(!e.ok){var n=e.status;return Promise.resolve(e.text()).then(function(e){return t=1,{status:n,error:e}})}}();return r&&r.then?r.then(n):n(r)})}catch(e){return Promise.reject(e)}}(S({endpoint:"https://cloud.needle.tools/api"},t,{offset:e.offset||0,limit:e.limit||10})).catch(function(e){return e})).then(function(e){return!e||e instanceof Error?[]:e.deployments.map(function(e){return{name:e.name,url:e.url}})})})}catch(e){return Promise.reject(e)}},Rn=function(e){try{return Promise.resolve(xn(e.org)).then(function(t){if(!t)throw new Error("Not authenticated");"limit"in e&&(e.limit=Math.min(100,e.limit));var n="page"in e||"limit"in e;return function(e,t){void 0===t&&(t={sort_by_upload:!0,page:1,limit:20,view_id:void 0,type:"upload"});try{var n;if(t.page<=0)throw new Error("Invalid page. Must be greater than 0");var r=new URL(e.baseUrl+"/v1/list/uploads");null!=(n=t.search)&&null!=(n=n.trim())&&n.length&&r.searchParams.set("search",t.search.trim());var o=S({type:t.type||"upload",max:(t.limit||0).toString(),page:(t.page||1).toString()},R(e));return null!=t.view_id&&(o.view_id=t.view_id),null!=t.view_name&&(o.view_name=t.view_name),Promise.resolve(fetch(r,S({},A,{method:"GET",headers:o})).then(function(e){try{var n=function(n){return void 0===t.sort_by_upload&&(t.sort_by_upload=!0),Promise.resolve(e.json()).then(function(e){return t.sort_by_upload&&e.uploads.sort(function(e,t){return new Date(t.updated_time).getTime()-new Date(e.updated_time).getTime()}),e})},r=function(){if(!e.ok)return Promise.resolve(e.text()).then(function(t){throw new Error("Failed to list uploads ("+e.status+"): "+t)})}();return Promise.resolve(r&&r.then?r.then(n):n())}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}}(S({baseUrl:"https://cloud.needle.tools/api"},t,e),{view_name:"name"in e?e.name:void 0,view_id:"view_id"in e?e.view_id:void 0,type:"upload",page:n?e.page:1,limit:n?e.limit:100}).then(function(e){return e.uploads.map(function(e){return{name:e.name,created_at:e.created_time,updated_at:e.updated_time,thumbnail_url:e.thumbnail_url,files:e.jobs.map(function(e){return{created_at:e.created_at,updated_at:e.updated_at||e.created_at,type:e.type,status:e.status,name:e.name,url:e.url,size:e.size}})}})})})}catch(e){return Promise.reject(e)}},An=function(e){try{var t=new URL("https://cloud.needle.tools/api/v1/account/buy_licenses");return Promise.resolve(xn()).then(function(n){var r={mode:"payment",price_id:e.price_id,return_url:window.location.href,cancel_url:window.location.href};return Promise.resolve(fetch(t,{method:"POST",headers:S({"Content-Type":"application/json"},R(n)),body:JSON.stringify(r)})).then(function(e){return e.ok?Promise.resolve(e.json()).then(function(e){return"session_url"in e?(window.location.href=e.session_url,{ok:!0,status:200}):{ok:!1,status:400}}):{ok:!1,status:e.status}})})}catch(e){return Promise.reject(e)}};export{m as Auth,i as AuthScopes,P as NeedleLoginButton,Pn as getDeployments,Rn as getUploads,On as getUserLicenses,An as startCheckoutSession,Tn as uploadFiles};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|