7 lines
54 KiB
JavaScript
7 lines
54 KiB
JavaScript
(function(){"use strict";function Se(t,e){return function(){return t.apply(e,arguments)}}const{toString:at}=Object.prototype,{getPrototypeOf:le}=Object,{iterator:G,toStringTag:Te}=Symbol,Q=(t=>e=>{const n=at.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),x=t=>(t=t.toLowerCase(),e=>Q(e)===t),Y=t=>e=>typeof e===t,{isArray:j}=Array,J=Y("undefined");function V(t){return t!==null&&!J(t)&&t.constructor!==null&&!J(t.constructor)&&P(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Re=x("ArrayBuffer");function ct(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Re(t.buffer),e}const lt=Y("string"),P=Y("function"),ke=Y("number"),K=t=>t!==null&&typeof t=="object",ut=t=>t===!0||t===!1,ee=t=>{if(Q(t)!=="object")return!1;const e=le(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Te in t)&&!(G in t)},dt=t=>{if(!K(t)||V(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},ft=x("Date"),ht=x("File"),pt=x("Blob"),mt=x("FileList"),wt=t=>K(t)&&P(t.pipe),yt=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||P(t.append)&&((e=Q(t))==="formdata"||e==="object"&&P(t.toString)&&t.toString()==="[object FormData]"))},bt=x("URLSearchParams"),[gt,Et,vt,St]=["ReadableStream","Request","Response","Headers"].map(x),Tt=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function X(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,s;if(typeof t!="object"&&(t=[t]),j(t))for(r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else{if(V(t))return;const o=n?Object.getOwnPropertyNames(t):Object.keys(t),i=o.length;let c;for(r=0;r<i;r++)c=o[r],e.call(null,t[c],c,t)}}function Oe(t,e){if(V(t))return null;e=e.toLowerCase();const n=Object.keys(t);let r=n.length,s;for(;r-- >0;)if(s=n[r],e===s.toLowerCase())return s;return null}const U=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Pe=t=>!J(t)&&t!==U;function ue(){const{caseless:t}=Pe(this)&&this||{},e={},n=(r,s)=>{const o=t&&Oe(e,s)||s;ee(e[o])&&ee(r)?e[o]=ue(e[o],r):ee(r)?e[o]=ue({},r):j(r)?e[o]=r.slice():e[o]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&X(arguments[r],n);return e}const Rt=(t,e,n,{allOwnKeys:r}={})=>(X(e,(s,o)=>{n&&P(s)?t[o]=Se(s,n):t[o]=s},{allOwnKeys:r}),t),kt=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Ot=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},Pt=(t,e,n,r)=>{let s,o,i;const c={};if(e=e||{},t==null)return e;do{for(s=Object.getOwnPropertyNames(t),o=s.length;o-- >0;)i=s[o],(!r||r(i,t,e))&&!c[i]&&(e[i]=t[i],c[i]=!0);t=n!==!1&&le(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},At=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const r=t.indexOf(e,n);return r!==-1&&r===n},Ct=t=>{if(!t)return null;if(j(t))return t;let e=t.length;if(!ke(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},_t=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&le(Uint8Array)),xt=(t,e)=>{const r=(t&&t[G]).call(t);let s;for(;(s=r.next())&&!s.done;){const o=s.value;e.call(t,o[0],o[1])}},Nt=(t,e)=>{let n;const r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},It=x("HTMLFormElement"),Lt=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ae=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),Bt=x("RegExp"),Ce=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};X(n,(s,o)=>{let i;(i=e(s,o,t))!==!1&&(r[o]=i||s)}),Object.defineProperties(t,r)},Ft=t=>{Ce(t,(e,n)=>{if(P(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(P(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Ut=(t,e)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return j(t)?r(t):r(String(t).split(e)),n},Dt=()=>{},Mt=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function qt(t){return!!(t&&P(t.append)&&t[Te]==="FormData"&&t[G])}const jt=t=>{const e=new Array(10),n=(r,s)=>{if(K(r)){if(e.indexOf(r)>=0)return;if(V(r))return r;if(!("toJSON"in r)){e[s]=r;const o=j(r)?[]:{};return X(r,(i,c)=>{const d=n(i,s+1);!J(d)&&(o[c]=d)}),e[s]=void 0,o}}return r};return n(t,0)},Ht=x("AsyncFunction"),$t=t=>t&&(K(t)||P(t))&&P(t.then)&&P(t.catch),_e=((t,e)=>t?setImmediate:e?((n,r)=>(U.addEventListener("message",({source:s,data:o})=>{s===U&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),U.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",P(U.postMessage)),zt=typeof queueMicrotask<"u"?queueMicrotask.bind(U):typeof process<"u"&&process.nextTick||_e,a={isArray:j,isArrayBuffer:Re,isBuffer:V,isFormData:yt,isArrayBufferView:ct,isString:lt,isNumber:ke,isBoolean:ut,isObject:K,isPlainObject:ee,isEmptyObject:dt,isReadableStream:gt,isRequest:Et,isResponse:vt,isHeaders:St,isUndefined:J,isDate:ft,isFile:ht,isBlob:pt,isRegExp:Bt,isFunction:P,isStream:wt,isURLSearchParams:bt,isTypedArray:_t,isFileList:mt,forEach:X,merge:ue,extend:Rt,trim:Tt,stripBOM:kt,inherits:Ot,toFlatObject:Pt,kindOf:Q,kindOfTest:x,endsWith:At,toArray:Ct,forEachEntry:xt,matchAll:Nt,isHTMLForm:It,hasOwnProperty:Ae,hasOwnProp:Ae,reduceDescriptors:Ce,freezeMethods:Ft,toObjectSet:Ut,toCamelCase:Lt,noop:Dt,toFiniteNumber:Mt,findKey:Oe,global:U,isContextDefined:Pe,isSpecCompliantForm:qt,toJSONObject:jt,isAsyncFn:Ht,isThenable:$t,setImmediate:_e,asap:zt,isIterable:t=>t!=null&&P(t[G])};function m(t,e,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status?s.status:null)}a.inherits(m,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.status}}});const xe=m.prototype,Ne={};["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(t=>{Ne[t]={value:t}}),Object.defineProperties(m,Ne),Object.defineProperty(xe,"isAxiosError",{value:!0}),m.from=(t,e,n,r,s,o)=>{const i=Object.create(xe);return a.toFlatObject(t,i,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),m.call(i,t.message,e,n,r,s),i.cause=t,i.name=t.name,o&&Object.assign(i,o),i};const Jt=null;function de(t){return a.isPlainObject(t)||a.isArray(t)}function Ie(t){return a.endsWith(t,"[]")?t.slice(0,-2):t}function Le(t,e,n){return t?t.concat(e).map(function(s,o){return s=Ie(s),!n&&o?"["+s+"]":s}).join(n?".":""):e}function Vt(t){return a.isArray(t)&&!t.some(de)}const Kt=a.toFlatObject(a,{},null,function(e){return/^is[A-Z]/.test(e)});function te(t,e,n){if(!a.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,p){return!a.isUndefined(p[w])});const r=n.metaTokens,s=n.visitor||u,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(e);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function l(h){if(h===null)return"";if(a.isDate(h))return h.toISOString();if(a.isBoolean(h))return h.toString();if(!d&&a.isBlob(h))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(h)||a.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function u(h,w,p){let v=h;if(h&&!p&&typeof h=="object"){if(a.endsWith(w,"{}"))w=r?w:w.slice(0,-2),h=JSON.stringify(h);else if(a.isArray(h)&&Vt(h)||(a.isFileList(h)||a.endsWith(w,"[]"))&&(v=a.toArray(h)))return w=Ie(w),v.forEach(function(k,I){!(a.isUndefined(k)||k===null)&&e.append(i===!0?Le([w],I,o):i===null?w:w+"[]",l(k))}),!1}return de(h)?!0:(e.append(Le(p,w,o),l(h)),!1)}const f=[],g=Object.assign(Kt,{defaultVisitor:u,convertValue:l,isVisitable:de});function S(h,w){if(!a.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+w.join("."));f.push(h),a.forEach(h,function(v,T){(!(a.isUndefined(v)||v===null)&&s.call(e,v,a.isString(T)?T.trim():T,w,g))===!0&&S(v,w?w.concat(T):[T])}),f.pop()}}if(!a.isObject(t))throw new TypeError("data must be an object");return S(t),e}function Be(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function fe(t,e){this._pairs=[],t&&te(t,this,e)}const Fe=fe.prototype;Fe.append=function(e,n){this._pairs.push([e,n])},Fe.toString=function(e){const n=e?function(r){return e.call(this,r,Be)}:Be;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function Xt(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Ue(t,e,n){if(!e)return t;const r=n&&n.encode||Xt;a.isFunction(n)&&(n={serialize:n});const s=n&&n.serialize;let o;if(s?o=s(e,n):o=a.isURLSearchParams(e)?e.toString():new fe(e,n).toString(r),o){const i=t.indexOf("#");i!==-1&&(t=t.slice(0,i)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class De{constructor(){this.handlers=[]}use(e,n,r){return this.handlers.push({fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){a.forEach(this.handlers,function(r){r!==null&&e(r)})}}const Me={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Wt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:fe,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},he=typeof window<"u"&&typeof document<"u",pe=typeof navigator=="object"&&navigator||void 0,Zt=he&&(!pe||["ReactNative","NativeScript","NS"].indexOf(pe.product)<0),Gt=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Qt=he&&window.location.href||"http://localhost",O={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:he,hasStandardBrowserEnv:Zt,hasStandardBrowserWebWorkerEnv:Gt,navigator:pe,origin:Qt},Symbol.toStringTag,{value:"Module"})),...Wt};function Yt(t,e){return te(t,new O.classes.URLSearchParams,{visitor:function(n,r,s,o){return O.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}function en(t){return a.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function tn(t){const e={},n=Object.keys(t);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],e[o]=t[o];return e}function qe(t){function e(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const c=Number.isFinite(+i),d=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,d?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),e(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=tn(s[i])),!c)}if(a.isFormData(t)&&a.isFunction(t.entries)){const n={};return a.forEachEntry(t,(r,s)=>{e(en(r),s,n,0)}),n}return null}function nn(t,e,n){if(a.isString(t))try{return(e||JSON.parse)(t),a.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const W={transitional:Me,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(e);if(o&&a.isHTMLForm(e)&&(e=new FormData(e)),a.isFormData(e))return s?JSON.stringify(qe(e)):e;if(a.isArrayBuffer(e)||a.isBuffer(e)||a.isStream(e)||a.isFile(e)||a.isBlob(e)||a.isReadableStream(e))return e;if(a.isArrayBufferView(e))return e.buffer;if(a.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Yt(e,this.formSerializer).toString();if((c=a.isFileList(e))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return te(c?{"files[]":e}:e,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),nn(e)):e}],transformResponse:[function(e){const n=this.transitional||W.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(a.isResponse(e)||a.isReadableStream(e))return e;if(e&&a.isString(e)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(e)}catch(c){if(i)throw c.name==="SyntaxError"?m.from(c,m.ERR_BAD_RESPONSE,this,null,this.response):c}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:O.classes.FormData,Blob:O.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],t=>{W.headers[t]={}});const rn=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),sn=t=>{const e={};let n,r,s;return t&&t.split(`
|
|
`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||e[n]&&rn[n])&&(n==="set-cookie"?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e},je=Symbol("internals");function Z(t){return t&&String(t).trim().toLowerCase()}function ne(t){return t===!1||t==null?t:a.isArray(t)?t.map(ne):String(t)}function on(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(t);)e[r[1]]=r[2];return e}const an=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function me(t,e,n,r,s){if(a.isFunction(r))return r.call(this,e,n);if(s&&(e=n),!!a.isString(e)){if(a.isString(r))return e.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(e)}}function cn(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function ln(t,e){const n=a.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(s,o,i){return this[r].call(this,e,s,o,i)},configurable:!0})})}let A=class{constructor(e){e&&this.set(e)}set(e,n,r){const s=this;function o(c,d,l){const u=Z(d);if(!u)throw new Error("header name must be a non-empty string");const f=a.findKey(s,u);(!f||s[f]===void 0||l===!0||l===void 0&&s[f]!==!1)&&(s[f||d]=ne(c))}const i=(c,d)=>a.forEach(c,(l,u)=>o(l,u,d));if(a.isPlainObject(e)||e instanceof this.constructor)i(e,n);else if(a.isString(e)&&(e=e.trim())&&!an(e))i(sn(e),n);else if(a.isObject(e)&&a.isIterable(e)){let c={},d,l;for(const u of e){if(!a.isArray(u))throw TypeError("Object iterator must return a key-value pair");c[l=u[0]]=(d=c[l])?a.isArray(d)?[...d,u[1]]:[d,u[1]]:u[1]}i(c,n)}else e!=null&&o(n,e,r);return this}get(e,n){if(e=Z(e),e){const r=a.findKey(this,e);if(r){const s=this[r];if(!n)return s;if(n===!0)return on(s);if(a.isFunction(n))return n.call(this,s,r);if(a.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=Z(e),e){const r=a.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||me(this,this[r],r,n)))}return!1}delete(e,n){const r=this;let s=!1;function o(i){if(i=Z(i),i){const c=a.findKey(r,i);c&&(!n||me(r,r[c],c,n))&&(delete r[c],s=!0)}}return a.isArray(e)?e.forEach(o):o(e),s}clear(e){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const o=n[r];(!e||me(this,this[o],o,e,!0))&&(delete this[o],s=!0)}return s}normalize(e){const n=this,r={};return a.forEach(this,(s,o)=>{const i=a.findKey(r,o);if(i){n[i]=ne(s),delete n[o];return}const c=e?cn(o):String(o).trim();c!==o&&delete n[o],n[c]=ne(s),r[c]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return a.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=e&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(`
|
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const r=new this(e);return n.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[je]=this[je]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=Z(i);r[c]||(ln(s,i),r[c]=!0)}return a.isArray(e)?e.forEach(o):o(e),this}};A.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(A.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}}),a.freezeMethods(A);function we(t,e){const n=this||W,r=e||n,s=A.from(r.headers);let o=r.data;return a.forEach(t,function(c){o=c.call(n,o,s.normalize(),e?e.status:void 0)}),s.normalize(),o}function He(t){return!!(t&&t.__CANCEL__)}function H(t,e,n){m.call(this,t??"canceled",m.ERR_CANCELED,e,n),this.name="CanceledError"}a.inherits(H,m,{__CANCEL__:!0});function $e(t,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new m("Request failed with status code "+n.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function un(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function dn(t,e){t=t||10;const n=new Array(t),r=new Array(t);let s=0,o=0,i;return e=e!==void 0?e:1e3,function(d){const l=Date.now(),u=r[o];i||(i=l),n[s]=d,r[s]=l;let f=o,g=0;for(;f!==s;)g+=n[f++],f=f%t;if(s=(s+1)%t,s===o&&(o=(o+1)%t),l-i<e)return;const S=u&&l-u;return S?Math.round(g*1e3/S):void 0}}function fn(t,e){let n=0,r=1e3/e,s,o;const i=(l,u=Date.now())=>{n=u,s=null,o&&(clearTimeout(o),o=null),t(...l)};return[(...l)=>{const u=Date.now(),f=u-n;f>=r?i(l,u):(s=l,o||(o=setTimeout(()=>{o=null,i(s)},r-f)))},()=>s&&i(s)]}const re=(t,e,n=3)=>{let r=0;const s=dn(50,250);return fn(o=>{const i=o.loaded,c=o.lengthComputable?o.total:void 0,d=i-r,l=s(d),u=i<=c;r=i;const f={loaded:i,total:c,progress:c?i/c:void 0,bytes:d,rate:l||void 0,estimated:l&&c&&u?(c-i)/l:void 0,event:o,lengthComputable:c!=null,[e?"download":"upload"]:!0};t(f)},n)},ze=(t,e)=>{const n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},Je=t=>(...e)=>a.asap(()=>t(...e)),hn=O.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,O.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(O.origin),O.navigator&&/(msie|trident)/i.test(O.navigator.userAgent)):()=>!0,pn=O.hasStandardBrowserEnv?{write(t,e,n,r,s,o){const i=[t+"="+encodeURIComponent(e)];a.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),a.isString(r)&&i.push("path="+r),a.isString(s)&&i.push("domain="+s),o===!0&&i.push("secure"),document.cookie=i.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function mn(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function wn(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function Ve(t,e,n){let r=!mn(e);return t&&(r||n==!1)?wn(t,e):e}const Ke=t=>t instanceof A?{...t}:t;function D(t,e){e=e||{};const n={};function r(l,u,f,g){return a.isPlainObject(l)&&a.isPlainObject(u)?a.merge.call({caseless:g},l,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function s(l,u,f,g){if(a.isUndefined(u)){if(!a.isUndefined(l))return r(void 0,l,f,g)}else return r(l,u,f,g)}function o(l,u){if(!a.isUndefined(u))return r(void 0,u)}function i(l,u){if(a.isUndefined(u)){if(!a.isUndefined(l))return r(void 0,l)}else return r(void 0,u)}function c(l,u,f){if(f in e)return r(l,u);if(f in t)return r(void 0,l)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(l,u,f)=>s(Ke(l),Ke(u),f,!0)};return a.forEach(Object.keys({...t,...e}),function(u){const f=d[u]||s,g=f(t[u],e[u],u);a.isUndefined(g)&&f!==c||(n[u]=g)}),n}const Xe=t=>{const e=D({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:s,xsrfCookieName:o,headers:i,auth:c}=e;e.headers=i=A.from(i),e.url=Ue(Ve(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let d;if(a.isFormData(n)){if(O.hasStandardBrowserEnv||O.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((d=i.getContentType())!==!1){const[l,...u]=d?d.split(";").map(f=>f.trim()).filter(Boolean):[];i.setContentType([l||"multipart/form-data",...u].join("; "))}}if(O.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(e)),r||r!==!1&&hn(e.url))){const l=s&&o&&pn.read(o);l&&i.set(s,l)}return e},yn=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(n,r){const s=Xe(t);let o=s.data;const i=A.from(s.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:l}=s,u,f,g,S,h;function w(){S&&S(),h&&h(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function v(){if(!p)return;const k=A.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),C={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:k,config:t,request:p};$e(function(q){n(q),w()},function(q){r(q),w()},C),p=null}"onloadend"in p?p.onloadend=v:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(v)},p.onabort=function(){p&&(r(new m("Request aborted",m.ECONNABORTED,t,p)),p=null)},p.onerror=function(){r(new m("Network Error",m.ERR_NETWORK,t,p)),p=null},p.ontimeout=function(){let I=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const C=s.transitional||Me;s.timeoutErrorMessage&&(I=s.timeoutErrorMessage),r(new m(I,C.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,t,p)),p=null},o===void 0&&i.setContentType(null),"setRequestHeader"in p&&a.forEach(i.toJSON(),function(I,C){p.setRequestHeader(C,I)}),a.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),c&&c!=="json"&&(p.responseType=s.responseType),l&&([g,h]=re(l,!0),p.addEventListener("progress",g)),d&&p.upload&&([f,S]=re(d),p.upload.addEventListener("progress",f),p.upload.addEventListener("loadend",S)),(s.cancelToken||s.signal)&&(u=k=>{p&&(r(!k||k.type?new H(null,t,p):k),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const T=un(s.url);if(T&&O.protocols.indexOf(T)===-1){r(new m("Unsupported protocol "+T+":",m.ERR_BAD_REQUEST,t));return}p.send(o||null)})},bn=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,s;const o=function(l){if(!s){s=!0,c();const u=l instanceof Error?l:this.reason;r.abort(u instanceof m?u:new H(u instanceof Error?u.message:u))}};let i=e&&setTimeout(()=>{i=null,o(new m(`timeout ${e} of ms exceeded`,m.ETIMEDOUT))},e);const c=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(l=>{l.unsubscribe?l.unsubscribe(o):l.removeEventListener("abort",o)}),t=null)};t.forEach(l=>l.addEventListener("abort",o));const{signal:d}=r;return d.unsubscribe=()=>a.asap(c),d}},gn=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let r=0,s;for(;r<n;)s=r+e,yield t.slice(r,s),r=s},En=async function*(t,e){for await(const n of vn(t))yield*gn(n,e)},vn=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:r}=await e.read();if(n)break;yield r}}finally{await e.cancel()}},We=(t,e,n,r)=>{const s=En(t,e);let o=0,i,c=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:l,value:u}=await s.next();if(l){c(),d.close();return}let f=u.byteLength;if(n){let g=o+=f;n(g)}d.enqueue(new Uint8Array(u))}catch(l){throw c(l),l}},cancel(d){return c(d),s.return()}},{highWaterMark:2})},se=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Ze=se&&typeof ReadableStream=="function",Sn=se&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),Ge=(t,...e)=>{try{return!!t(...e)}catch{return!1}},Tn=Ze&&Ge(()=>{let t=!1;const e=new Request(O.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),Qe=64*1024,ye=Ze&&Ge(()=>a.isReadableStream(new Response("").body)),oe={stream:ye&&(t=>t.body)};se&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!oe[e]&&(oe[e]=a.isFunction(t[e])?n=>n[e]():(n,r)=>{throw new m(`Response type '${e}' is not supported`,m.ERR_NOT_SUPPORT,r)})})})(new Response);const Rn=async t=>{if(t==null)return 0;if(a.isBlob(t))return t.size;if(a.isSpecCompliantForm(t))return(await new Request(O.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(a.isArrayBufferView(t)||a.isArrayBuffer(t))return t.byteLength;if(a.isURLSearchParams(t)&&(t=t+""),a.isString(t))return(await Sn(t)).byteLength},kn=async(t,e)=>{const n=a.toFiniteNumber(t.getContentLength());return n??Rn(e)},be={http:Jt,xhr:yn,fetch:se&&(async t=>{let{url:e,method:n,data:r,signal:s,cancelToken:o,timeout:i,onDownloadProgress:c,onUploadProgress:d,responseType:l,headers:u,withCredentials:f="same-origin",fetchOptions:g}=Xe(t);l=l?(l+"").toLowerCase():"text";let S=bn([s,o&&o.toAbortSignal()],i),h;const w=S&&S.unsubscribe&&(()=>{S.unsubscribe()});let p;try{if(d&&Tn&&n!=="get"&&n!=="head"&&(p=await kn(u,r))!==0){let C=new Request(e,{method:"POST",body:r,duplex:"half"}),F;if(a.isFormData(r)&&(F=C.headers.get("content-type"))&&u.setContentType(F),C.body){const[q,ce]=ze(p,re(Je(d)));r=We(C.body,Qe,q,ce)}}a.isString(f)||(f=f?"include":"omit");const v="credentials"in Request.prototype;h=new Request(e,{...g,signal:S,method:n.toUpperCase(),headers:u.normalize().toJSON(),body:r,duplex:"half",credentials:v?f:void 0});let T=await fetch(h,g);const k=ye&&(l==="stream"||l==="response");if(ye&&(c||k&&w)){const C={};["status","statusText","headers"].forEach(ot=>{C[ot]=T[ot]});const F=a.toFiniteNumber(T.headers.get("content-length")),[q,ce]=c&&ze(F,re(Je(c),!0))||[];T=new Response(We(T.body,Qe,q,()=>{ce&&ce(),w&&w()}),C)}l=l||"text";let I=await oe[a.findKey(oe,l)||"text"](T,t);return!k&&w&&w(),await new Promise((C,F)=>{$e(C,F,{data:I,headers:A.from(T.headers),status:T.status,statusText:T.statusText,config:t,request:h})})}catch(v){throw w&&w(),v&&v.name==="TypeError"&&/Load failed|fetch/i.test(v.message)?Object.assign(new m("Network Error",m.ERR_NETWORK,t,h),{cause:v.cause||v}):m.from(v,v&&v.code,t,h)}})};a.forEach(be,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Ye=t=>`- ${t}`,On=t=>a.isFunction(t)||t===null||t===!1,et={getAdapter:t=>{t=a.isArray(t)?t:[t];const{length:e}=t;let n,r;const s={};for(let o=0;o<e;o++){n=t[o];let i;if(r=n,!On(n)&&(r=be[(i=String(n)).toLowerCase()],r===void 0))throw new m(`Unknown adapter '${i}'`);if(r)break;s[i||"#"+o]=r}if(!r){const o=Object.entries(s).map(([c,d])=>`adapter ${c} `+(d===!1?"is not supported by the environment":"is not available in the build"));let i=e?o.length>1?`since :
|
|
`+o.map(Ye).join(`
|
|
`):" "+Ye(o[0]):"as no adapter specified";throw new m("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return r},adapters:be};function ge(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new H(null,t)}function tt(t){return ge(t),t.headers=A.from(t.headers),t.data=we.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),et.getAdapter(t.adapter||W.adapter)(t).then(function(r){return ge(t),r.data=we.call(t,t.transformResponse,r),r.headers=A.from(r.headers),r},function(r){return He(r)||(ge(t),r&&r.response&&(r.response.data=we.call(t,t.transformResponse,r.response),r.response.headers=A.from(r.response.headers))),Promise.reject(r)})}const nt="1.11.0",ie={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{ie[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const rt={};ie.transitional=function(e,n,r){function s(o,i){return"[Axios v"+nt+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(e===!1)throw new m(s(i," has been removed"+(n?" in "+n:"")),m.ERR_DEPRECATED);return n&&!rt[i]&&(rt[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(o,i,c):!0}},ie.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function Pn(t,e,n){if(typeof t!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let s=r.length;for(;s-- >0;){const o=r[s],i=e[o];if(i){const c=t[o],d=c===void 0||i(c,o,t);if(d!==!0)throw new m("option "+o+" must be "+d,m.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new m("Unknown option "+o,m.ERR_BAD_OPTION)}}const ae={assertOptions:Pn,validators:ie},N=ae.validators;let M=class{constructor(e){this.defaults=e||{},this.interceptors={request:new De,response:new De}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack?s.stack.replace(/^.+\n/,""):"";try{r.stack?o&&!String(r.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
`+o):r.stack=o}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=D(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ae.assertOptions(r,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:ae.assertOptions(s,{encode:N.function,serialize:N.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ae.assertOptions(n,{baseUrl:N.spelling("baseURL"),withXsrfToken:N.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),n.headers=A.concat(i,o);const c=[];let d=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(n)===!1||(d=d&&w.synchronous,c.unshift(w.fulfilled,w.rejected))});const l=[];this.interceptors.response.forEach(function(w){l.push(w.fulfilled,w.rejected)});let u,f=0,g;if(!d){const h=[tt.bind(this),void 0];for(h.unshift(...c),h.push(...l),g=h.length,u=Promise.resolve(n);f<g;)u=u.then(h[f++],h[f++]);return u}g=c.length;let S=n;for(f=0;f<g;){const h=c[f++],w=c[f++];try{S=h(S)}catch(p){w.call(this,p);break}}try{u=tt.call(this,S)}catch(h){return Promise.reject(h)}for(f=0,g=l.length;f<g;)u=u.then(l[f++],l[f++]);return u}getUri(e){e=D(this.defaults,e);const n=Ve(e.baseURL,e.url,e.allowAbsoluteUrls);return Ue(n,e.params,e.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(e){M.prototype[e]=function(n,r){return this.request(D(r||{},{method:e,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(e){function n(r){return function(o,i,c){return this.request(D(c||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}M.prototype[e]=n(),M.prototype[e+"Form"]=n(!0)});let An=class it{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},e(function(o,i,c){r.reason||(r.reason=new H(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new it(function(s){e=s}),cancel:e}}};function Cn(t){return function(n){return t.apply(null,n)}}function _n(t){return a.isObject(t)&&t.isAxiosError===!0}const Ee={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(Ee).forEach(([t,e])=>{Ee[e]=t});function st(t){const e=new M(t),n=Se(M.prototype.request,e);return a.extend(n,M.prototype,e,{allOwnKeys:!0}),a.extend(n,e,null,{allOwnKeys:!0}),n.create=function(s){return st(D(t,s))},n}const E=st(W);E.Axios=M,E.CanceledError=H,E.CancelToken=An,E.isCancel=He,E.VERSION=nt,E.toFormData=te,E.AxiosError=m,E.Cancel=E.CanceledError,E.all=function(e){return Promise.all(e)},E.spread=Cn,E.isAxiosError=_n,E.mergeConfig=D,E.AxiosHeaders=A,E.formToJSON=t=>qe(a.isHTMLForm(t)?new FormData(t):t),E.getAdapter=et.getAdapter,E.HttpStatusCode=Ee,E.default=E;const{Axios:Jn,AxiosError:Vn,CanceledError:Kn,isCancel:Xn,CancelToken:Wn,VERSION:Zn,all:Gn,Cancel:Qn,isAxiosError:Yn,spread:er,toFormData:tr,AxiosHeaders:nr,HttpStatusCode:rr,formToJSON:sr,getAdapter:or,mergeConfig:ir}=E,$=E.create({baseURL:"https://aitool.danielvu.com/auto-list/",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2ludC5pcHN1cHBseS5jb20uYXUvYXBpL2xvZ2luIiwiaWF0IjoxNzIxNjA5MTEzLCJleHAiOjMyMzUzMzcxMTMsIm5iZiI6MTcyMTYwOTExMywianRpIjoiWHpCZkZPc0ZJUlFxaEZvaiIsInN1YiI6MSwicHJ2IjoiYzhlZTFmYzg5ZTc3NWVjNGM3Mzg2NjdlNWJlMTdhNTkwYjZkNDBmYyJ9.kFFEPpdmNUp-kn_G3cIIc26bivO6tbfcvkpG9I8Im7M"}});class xn{item_per_page=10;async index(e){const n={skip:0,limit:10,order:"updatedAt desc",where:{account:"prology_net",status:"Updated"}};return $({method:"POST",data:{urlAPI:"/api/ebay-listing/listing-get-list",filter:{...n,...e,where:{...n.where,...e?.where}}}})}async get(e){return $({method:"POST",data:{filter:{where:{account:"prology_net",condition:e.raw_condition,productModelCode:e.sku}},pageCurrent:"/ebaytools/listing-ebay",urlAPI:"/api/ebay-listing/get-image-listing"}})}async getProductOnLocalServer(e){return $({method:"GET",url:"products/"+e.id})}async saveProductOnLocalServer(e){return $({method:"POST",url:"products",data:e})}async sync(e){return $({url:"sync",method:"POST",data:e})}async getPublistedProducts(){return $({url:"data"})}async apiRequest(e,n){return new Promise((r,s)=>{const o="req_"+Date.now()+"_"+Math.random();function i(c){c.data.type==="API_RESPONSE"&&c.data.requestId===o&&(window.removeEventListener("message",i),c.data.error?s(c.data.error):r(c.data.payload))}window.addEventListener("message",i),window.postMessage({type:"API_REQUEST",requestId:o,payload:n,fn:e},"*")})}}const L=new xn;function B(t){return new Promise(e=>setTimeout(e,t))}function b(t,e){const n=Math.floor(Math.random()*(e-t+1))+t;return B(n)}class Nn{static ID_EXTENSION="ex-root"}class ve{items=[];storageKey="notiQueue";constructor(e){this.items=e,chrome.storage.onChanged.addListener((n,r)=>{r==="local"&&n[this.storageKey]&&(this.items=n[this.storageKey].newValue?JSON.parse(n[this.storageKey].newValue):[],console.log("Queue updated from another tab:",this.items))})}static async create(){const e="notiQueue",n=await chrome.storage.local.get(e),r=n[e]?JSON.parse(n[e]):[];return new ve(r)}async save(){await chrome.storage.local.set({[this.storageKey]:JSON.stringify(this.items)})}async enqueue(e){this.items.push(e),await this.save()}async dequeue(){const e=this.items.shift();return await this.save(),e}peek(){return this.items[0]}isEmpty(){return this.items.length===0}size(){return this.items.length}}class In{base64ToFile(e,n,r){const s=e.includes(",")?e.split(",")[1]:e,o=atob(s),i=new ArrayBuffer(o.length),c=new Uint8Array(i);for(let l=0;l<o.length;l++)c[l]=o.charCodeAt(l);const d=new Blob([i],{type:r});return new File([d],n,{type:r})}clickByPoint(e){const n=e.getBoundingClientRect(),r=n.left+n.width/2,s=n.top+n.height/2,o=document.elementFromPoint(r,s);o&&o.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}))}async getElementByXPath(e,{retryCount:n=2,delay:r=100,xpathFallback:s}={}){return new Promise(o=>{let i=0,c=!1;const d=()=>{const l=document.evaluate(c&&s?s:e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(l instanceof HTMLElement){o(l);return}i++,i<n?setTimeout(d,r):!c&&s?(c=!0,i=0,setTimeout(d,r)):o(null)};d()})}async imageUrlToBase64(e){const r=await(await fetch(e)).blob();return new Promise((s,o)=>{const i=new FileReader;i.onloadend=()=>{typeof i.result=="string"?s(i.result.split(",")[1]):o("Không thể đọc dữ liệu ảnh")},i.onerror=o,i.readAsDataURL(r)})}getImageExtension(e){try{const r=new URL(e).pathname.match(/\.([a-zA-Z0-9]+)$/);return r?r[1].toLowerCase():null}catch{const s=e.split("?")[0].match(/\.([a-zA-Z0-9]+)$/);return s?s[1].toLowerCase():null}}imageLocalToBase64(e){return new Promise((n,r)=>{try{const s=chrome.runtime.getURL(`${e}`);fetch(s).then(o=>o.blob()).then(o=>{const i=new FileReader;i.onloadend=()=>n(i.result),i.onerror=r,i.readAsDataURL(o)}).catch(r)}catch(s){r(s)}})}scrollToElement(e,n="smooth"){e&&e.scrollIntoView({behavior:n,block:"center",inline:"nearest"})}getElementPointCoores(e){if(!e)return null;const n=e.getBoundingClientRect(),r=n.left+n.width/2,s=n.top+n.height/2;return{x:r,y:s}}setInputValue(e,n){e&&(e.value=n,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})))}writeToInput=async(e,n)=>{let r;if(typeof n=="string"?r=await this.getElementByXPath(n):r=n,!r)throw new Error("Xpath is not found with value: "+e);this.scrollToElement(r),this.clickByPoint(r),this.setInputValue(r,e)};pressEnter(e){if(!e)throw new Error("Textarea not found:",e);e.focus(),["keydown","keypress","keyup"].forEach(n=>{e.dispatchEvent(new KeyboardEvent(n,{key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0}))})}findNestedElement(e,n,r){const s=document.querySelector(e);if(!s)return null;const o=s.querySelectorAll(n);for(const i of o)if(i.innerText.trim().toLowerCase()===r.toLowerCase())return i;return null}findNestedIcElement(e,n,r){let s=null;if(typeof e=="string"){if(document.querySelector(e),!s)return null}else s=e;const o=s.querySelectorAll(n);for(const i of o)if(i.innerText.trim().toLowerCase().includes(r.toLowerCase()))return i;return null}findElInParent(e,n){return e&&e.parentElement?.querySelector(n)||null}waitForElement(e,n=100){return new Promise(r=>{const s=d=>d.offsetParent!==null&&(d.childElementCount>0||d.innerText.trim().length>0),o=()=>{const d=document.querySelector(e);d&&s(d)&&(i.disconnect(),clearInterval(c),r(d))},i=new MutationObserver(o);i.observe(document.body,{childList:!0,subtree:!0});const c=setInterval(o,n);o()})}}const y=new In;class Ln{sellingPath="https://www.facebook.com/marketplace/you/selling";marketPath="https://www.facebook.com/marketplace";createItem="https://www.facebook.com/marketplace/create/item";editItem="https://www.facebook.com/marketplace/edit";selectors={file__image_input:'input[type="file"]',next_btn:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[5]/div/div/div",update_btn:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[4]/div/div/div",publish_btn:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[4]/div[2]/div/div",option_btn:"/html/body/div[1]/div/div[1]/div/div[4]/div/div/div[1]/div/div[2]/div/div/div/div/div/div/div[3]/div/div/div/div/div[1]/div",option_btn_fallback:"/html/body/div[1]/div/div[1]/div/div[4]/div/div/div[1]/div/div[2]/div/div/div/div[3]/div[2]/div/div[2]/div[1]",close_btn_modal_feedback:"/html/body/div[1]/div/div[1]/div/div[4]/div/div/div[1]/div/div[2]/div/div/div/div[2]/div",images_container:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[2]/div[1]/div[2]/div/div/div[3]/div[2]/div",description_edit_input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[2]/div/div/div/label/div/div/textarea",sku_edit_input:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[9]/div/div/div[5]/div/div/div[1]/label/div/input",new_item_btn:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div/div[3]/div[1]/div[2]/div/div/div[7]/a/div",item_for_sell:"/html/body/div[1]/div/div[1]/div/div[5]/div/div/div[3]/div[2]/div[2]/div/div/div[2]/div[1]/div/span/div/div/div[1]/div/div",market_container:'[aria-label="Marketplace"]',collection_marketplace:'[aria-label="Collection of your Marketplace items"]'};findInputByTitle(e,n="input"){const r=y.findNestedElement(this.selectors.market_container,"span",e);if(!r)throw new Error("Not found input by title: "+e);return y.findElInParent(r,n)}clearImages=async()=>{document.querySelectorAll('[aria-label="Remove"]').forEach(e=>e?.click())};uploadImages=async e=>{const n=new DataTransfer;for(const s of e.images){const o=await y.imageUrlToBase64(s),i=y.base64ToFile(o,e.sku,y.getImageExtension(s)||"jpg");n.items.add(i)}const r=document.querySelector(this.selectors.file__image_input);r?(r.files=n.files,r.dispatchEvent(new Event("change",{bubbles:!0}))):console.error("Không tìm thấy input[type='file']")};chooseSelect=async(e,n,r='[aria-label="Dropdown menu"]')=>{const s=y.findNestedElement(this.selectors.market_container,"span",n);y.scrollToElement(s),await b(500,600),s?.click(),await b(500,600);const o=y.findNestedElement(r,"span",e);if(await b(500,600),!o)throw new Error(`No child found with text "${e}"`);y.scrollToElement(o),await b(500,600),o.click(),await b(500,600)};chooseLocation=async e=>{const n=this.findInputByTitle("location");await y.writeToInput(e,n),await B(600);const r=document.querySelector('[role="listbox"]')?.querySelectorAll("li")||[],s=Array.from(r).find(o=>o.innerHTML.trim().toLowerCase().includes(e.toLowerCase()));if(!s)throw new Error(`No child found with text "${e}"`);y.scrollToElement(s),await B(400),y.clickByPoint(s)};writeTags=async e=>{const n=this.findInputByTitle("product tags","textarea");if(!n)throw new Error("Input is not found");y.scrollToElement(n),await B(500);for(const r of e)await y.writeToInput(r,n),await B(300),y.pressEnter(n)};clickNext=async()=>{const e=await y.getElementByXPath(this.selectors.next_btn);if(!e)throw new Error("Next button is not found");y.clickByPoint(e)};clickUpdate=async()=>{const e=await y.getElementByXPath(this.selectors.update_btn);if(!e)throw new Error("Next button is not found");y.clickByPoint(e)};clickPublist=async()=>{const e=await y.getElementByXPath(this.selectors.publish_btn);if(!e)throw new Error("Publist button is not found");y.clickByPoint(e)};handlePublist=async e=>{await b(600,1e3),await this.uploadImages(e),await b(600,1e3);const n=this.findInputByTitle("title");y.writeToInput(e.title,n),await b(600,1e3);const r=this.findInputByTitle("price");if(y.writeToInput(String(e.price),r),await b(600,1e3),await this.chooseSelect(e.category,"category"),await b(600,1e3),await this.chooseSelect(e.condition,"condition",'[aria-label="Select an option"]'),e.brand){await b(600,1e3);const i=this.findInputByTitle("brand");await y.writeToInput(e.brand,i)}await b(600,1e3);const s=this.findInputByTitle("description","textarea");await y.writeToInput(e.description,s),await b(600,1e3),await this.writeTags(e.tags),await b(600,1e3);const o=this.findInputByTitle("sku");return await y.writeToInput(e.sku,o),e?.location&&(await b(600,1e3),await this.chooseLocation(e.location)),await b(300,500),await this.clickNext(),!0};handleRePublist=async e=>{await y.waitForElement('[aria-label="Collection of your Marketplace items"]');const n=await this.getOptionEls(e);this.clickItemInList(n,"edit"),await B(1e3),await this.waitForPageReady(this.editItem,this.selectors.market_container),await b(1e3,2e3),await this.clearImages(),await b(600,1e3),await this.uploadImages(e),await b(600,1e3);const r=this.findInputByTitle("title");y.writeToInput(e.title,r),await b(600,1e3);const s=this.findInputByTitle("price");y.writeToInput(String(e.price),s),await b(600,1e3),await this.chooseSelect(e.category,"category"),await b(600,1e3),await this.chooseSelect(e.condition,"condition",'[aria-label="Select an option"]'),await b(600,1e3);const o=this.findInputByTitle("description","textarea");return await y.writeToInput(e.description,o),await b(600,1e3),await this.writeTags(e.tags),await b(600,1e3),e?.location&&(await b(600,1e3),await this.chooseLocation(e.location)),!0};async getInfo(){try{const n=Date.now(),r=await new Promise(o=>{chrome.storage.local.get("meCache",i=>{o(i.meCache?JSON.parse(i.meCache):null)})});if(r&&n-r.timestamp<72e5)return r.data;const s=await fetch("/me");if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return chrome.storage.local.set({meCache:JSON.stringify({data:{url:s.url},timestamp:n})}),s}catch(n){return console.error("Failed to get /me:",n),null}}getProductContainer(){const e=document.querySelectorAll('[aria-label="Collection of your Marketplace items"] span > div > div'),n=Array.from(e).filter(r=>r.querySelector("span > div > div")&&r.classList.length>0);return n.length>0?n[0]:null}getProducts=async()=>{const e=this.getProductContainer();if(!e)throw new Error("List element has changed. Please connect to DEV");const n=await this.getInfo();return this.extractListings(e,n)};extractListings(e,n){return Array.from(e.children).map(s=>{const i=s.querySelector('span[dir="auto"], div[dir="auto"]')?.textContent?.trim()||"",c=document.querySelectorAll(`[aria-label="${i}"]`),d=Array.from(c).filter(g=>!g.querySelector("img"))[0],u=y.findNestedIcElement(d,"span","AU$")?.textContent?.match(/[\d,]+(?:\.\d+)?/),f=u?parseFloat(u[0].replace(/,/g,"")):0;return{title:i,price:f,el:e,url_info:n?.url}})}closeTab=async e=>{chrome.runtime.sendMessage({type:"close-tab",payload:e})};clickOptionOfProduct(e){const n=document.querySelector(`[aria-label="More options for ${e.title}"]`);if(!n)throw new Error(`Not found option buttin in product ${`[aria-label="More options for ${e.title}"]`}, ID: ${e.id}`);y.scrollToElement(n),n.click?.()}async getOptionEls(e){return this.clickOptionOfProduct(e),await B(2e3),Array.from(document.querySelectorAll('[role="menuitem"]'))}clickItemInList(e,n){const r=e.find(s=>s.textContent.toLocaleLowerCase().includes(n));if(!r)throw new Error(`Not found item ${n} in options list`);r.click?.()}getItemInList(e,n){const r=e.find(s=>s.textContent.toLocaleLowerCase().includes(n));if(!r)throw new Error(`Not found item ${n} in options list`);return r}handleDelete=async e=>{const n=await this.getOptionEls(e);this.clickItemInList(n,"delete"),await B(1e3),(await y.getElementByXPath(this.selectors.option_btn,{xpathFallback:this.selectors.option_btn_fallback}))?.click(),(await y.getElementByXPath(this.selectors.close_btn_modal_feedback))?.click(),chrome.runtime.sendMessage({type:"delete-done"})};waitForUrlContains(e,n=1e4){return new Promise((r,s)=>{const o=Date.now(),i=()=>{window.location.href.includes(e)?r():Date.now()-o>n?s(new Error("Timeout waiting for URL change")):setTimeout(i,500)};i()})}waitForPageReady(e,n,r=15e3){return new Promise((s,o)=>{const i=Date.now(),c=async()=>{window.location.href.includes(e)&&document.querySelector(n)?s():Date.now()-i>r?o(new Error("Timeout waiting for selling page ready")):setTimeout(c,500)};c()})}extractMarketplaceItemId(e){const n=e.match(/\/marketplace\/item\/(\d+)/);return n?n[1]:null}handleGetPublistID=async e=>{const r=(await R.getProducts()).find(c=>c.title==e.title&&c.price==e.price);if(!r)return;r.el;const s=await this.getOptionEls(e),o=this.getItemInList(s,"view listing"),i=this.extractMarketplaceItemId(o.href);return this.clickOptionOfProduct(e),i};async gotoPublist(){(await y.getElementByXPath(this.selectors.new_item_btn))?.click(),await b(400,800),(await y.getElementByXPath(this.selectors.item_for_sell))?.click()}async gotoSell(){document.querySelector('[href="/marketplace/you/selling/"]')?.click()}}const R=new Ln;class Bn{role;listeners;constructor(e){this.role=e,this.listeners=new Map,chrome.runtime.onMessage.addListener((n,r,s)=>{if(n?.type&&this.listeners.has(n.type))return this.listeners.get(n.type)(n.payload,r,s),!0})}on(e,n){this.listeners.set(e,n)}send(e,n,r){const s={from:this.role,to:e,type:n,payload:r};(this.role==="popup"||this.role==="content")&&chrome.runtime.sendMessage(s),this.role==="background"&&(e==="content"?chrome.tabs.query({active:!0,currentWindow:!0},o=>{o[0]?.id&&chrome.tabs.sendMessage(o[0].id,s,()=>{chrome.runtime.lastError&&console.warn("Không gửi được tới content script:",chrome.runtime.lastError.message)})}):e==="popup"&&chrome.runtime.sendMessage(s,()=>{chrome.runtime.lastError&&console.warn("Không gửi được tới popup:",chrome.runtime.lastError.message)}))}sendToTab(e,n,r){if(this.role!=="background")throw new Error("sendToTab chỉ được gọi từ background");const s={from:this.role,to:"content",type:n,payload:r};chrome.tabs.sendMessage(e,s,()=>{chrome.runtime.lastError&&console.warn(`Không gửi được tới content script ở tab ${e}:`,chrome.runtime.lastError.message)})}waitForMessage(e,n=3e4){return new Promise((r,s)=>{let o;const i=c=>{clearTimeout(o),this.off(e,i),r(c)};o=setTimeout(()=>{this.off(e,i),s(new Error(`Timeout khi chờ message: ${e}`))},n),this.on(e,i)})}off(e,n){this.listeners.get(e)===n&&this.listeners.delete(e)}}const _=new Bn("content"),z=async t=>{await window.QUEUE.enqueue(t)},Fn=()=>{const t=Nn.ID_EXTENSION;if(document.getElementById(t))return;const e=document.createElement("div");e.id=t,document.body.appendChild(e);const n=document.createElement("script");n.src=chrome.runtime.getURL("content/inject-ui.js"),n.type="module",document.body.appendChild(n);const r=document.createElement("link");r.rel="stylesheet",r.type="text/css",r.href=chrome.runtime.getURL("assets/style.css"),document.head.prepend(r)};_.on("background-to-content-publish",async t=>{try{console.log("[publish] Content nhận:",t),await b(800,1e3),await R.handlePublist(t.data),z({title:"Publist Completed !",message:"Please review",type:"success"})}catch(e){console.log({error:e}),z({title:`Publist Error - ${t.data.title||"Unknow"}`,message:e?.message,type:"error"})}finally{_.send("background","content-to-background-publish",{msg:t})}}),_.on("background-to-content-unlist",async t=>{try{console.log("[unlist] Content nhận:",t),await b(800,1e3),await R.gotoSell(),await b(800,1e3),await R.handleDelete(t.data),await b(800,1e3);const e=await R.getProducts();await b(800,1e3),await L.sync(e),z({title:"Unlist Completed !",message:"Please review",type:"success"})}catch(e){console.log({error:e}),z({title:`Unlist Error - ${t.data.title||""}`,message:e?.message,type:"error"})}finally{console.log("Send su kien da unlist"),_.send("background","content-to-background-unlist",{msg:t})}}),_.on("background-to-content-re-publist",async t=>{try{console.log("[re-publist] Content nhận:",t),await b(800,1e3),await R.gotoSell(),await b(800,1e3),await R.handleRePublist(t.data)}catch(e){console.log({error:e}),z({title:"Re-Publist Error",message:e?.message,type:"error"})}finally{_.send("background","content-to-background-re-publist",{msg:t})}}),window.addEventListener("message",async t=>{if(t.source===window&&t.data.type==="API_REQUEST"){const e=t.data.payload,n=t.data.fn,{requestId:r}=t.data;try{let s=null;switch(n){case"index":{const o=await R.getInfo();s=(await L.index({info:o,...e})).data;break}case"getPublistedProducts":{s=(await L.getPublistedProducts()).data;break}case"get":{s=(await L.get(e)).data,console.log({data:s,body:e});break}case"createBlobUrl":{_.send("background","content-to-background-create-blod-urls",e),s=await _.waitForMessage("background-to-content-create-blod-urls");break}case"publist":{_.send("background","content-to-background-actions",{type:"publist",data:e}),s=await _.waitForMessage("background-to-content-actions");break}case"unlist":{_.send("background","content-to-background-actions",{type:"unlist",data:e}),s=await _.waitForMessage("background-to-content-actions");break}case"sync":{const o=await y.waitForElement(R.selectors.collection_marketplace);console.log("Element đã xuất hiện:",o),await R.waitForPageReady(R.sellingPath,R.selectors.collection_marketplace),await b(800,1e3);const i=await R.getProducts();await L.sync(i);break}case"dequeue":{s=await window.QUEUE.dequeue();break}case"getProductLocalServer":{s=(await L.getProductOnLocalServer(e)).data,console.log({data:s,body:e});break}case"saveProductLocalServer":{s=(await L.saveProductOnLocalServer(e)).data,console.log({data:s,body:e});break}}window.postMessage({type:"API_RESPONSE",requestId:r,payload:s},"*")}catch(s){window.postMessage({type:"API_RESPONSE",requestId:r,error:s.message},"*")}}});const Un=()=>{let t=0;const e=3,n=setInterval(async()=>{if(window.location.href.includes(R.sellingPath))try{const r=await R.getProducts();await L.sync(r),t=0}catch(r){t++,console.error("Sync error:",r),t>=e&&(clearInterval(n),z({title:"Sync Error",message:r.message,type:"error"}))}},1e4)};(async()=>{window.QUEUE=await ve.create(),await R.getInfo();const t=()=>{Un(),Fn()};if(window.location.href.includes(R.sellingPath))try{await b(800,1e3);const e=await y.waitForElement(R.selectors.collection_marketplace);console.log("Element đã xuất hiện:",e),await b(800,1e3)}catch(e){console.error(e)}t()})()})();
|