7 lines
52 KiB
JavaScript
7 lines
52 KiB
JavaScript
(function(){"use strict";function Ee(t,e){return function(){return t.apply(e,arguments)}}const{toString:ot}=Object.prototype,{getPrototypeOf:ce}=Object,{iterator:W,toStringTag:ve}=Symbol,Z=(t=>e=>{const n=ot.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),x=t=>(t=t.toLowerCase(),e=>Z(e)===t),G=t=>e=>typeof e===t,{isArray:q}=Array,H=G("undefined");function $(t){return t!==null&&!H(t)&&t.constructor!==null&&!H(t.constructor)&&O(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Se=x("ArrayBuffer");function st(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Se(t.buffer),e}const at=G("string"),O=G("function"),Te=G("number"),z=t=>t!==null&&typeof t=="object",ct=t=>t===!0||t===!1,Y=t=>{if(Z(t)!=="object")return!1;const e=ce(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(ve in t)&&!(W in t)},lt=t=>{if(!z(t)||$(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},ut=x("Date"),dt=x("File"),ft=x("Blob"),ht=x("FileList"),pt=t=>z(t)&&O(t.pipe),mt=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||O(t.append)&&((e=Z(t))==="formdata"||e==="object"&&O(t.toString)&&t.toString()==="[object FormData]"))},wt=x("URLSearchParams"),[yt,bt,gt,Et]=["ReadableStream","Request","Response","Headers"].map(x),vt=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function J(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,i;if(typeof t!="object"&&(t=[t]),q(t))for(r=0,i=t.length;r<i;r++)e.call(null,t[r],r,t);else{if($(t))return;const o=n?Object.getOwnPropertyNames(t):Object.keys(t),s=o.length;let c;for(r=0;r<s;r++)c=o[r],e.call(null,t[c],c,t)}}function Re(t,e){if($(t))return null;e=e.toLowerCase();const n=Object.keys(t);let r=n.length,i;for(;r-- >0;)if(i=n[r],e===i.toLowerCase())return i;return null}const F=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ke=t=>!H(t)&&t!==F;function le(){const{caseless:t}=ke(this)&&this||{},e={},n=(r,i)=>{const o=t&&Re(e,i)||i;Y(e[o])&&Y(r)?e[o]=le(e[o],r):Y(r)?e[o]=le({},r):q(r)?e[o]=r.slice():e[o]=r};for(let r=0,i=arguments.length;r<i;r++)arguments[r]&&J(arguments[r],n);return e}const St=(t,e,n,{allOwnKeys:r}={})=>(J(e,(i,o)=>{n&&O(i)?t[o]=Ee(i,n):t[o]=i},{allOwnKeys:r}),t),Tt=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Rt=(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)},kt=(t,e,n,r)=>{let i,o,s;const c={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),o=i.length;o-- >0;)s=i[o],(!r||r(s,t,e))&&!c[s]&&(e[s]=t[s],c[s]=!0);t=n!==!1&&ce(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},Ot=(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},Pt=t=>{if(!t)return null;if(q(t))return t;let e=t.length;if(!Te(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},At=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&ce(Uint8Array)),_t=(t,e)=>{const r=(t&&t[W]).call(t);let i;for(;(i=r.next())&&!i.done;){const o=i.value;e.call(t,o[0],o[1])}},xt=(t,e)=>{let n;const r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},Ct=x("HTMLFormElement"),Nt=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,i){return r.toUpperCase()+i}),Oe=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),It=x("RegExp"),Pe=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};J(n,(i,o)=>{let s;(s=e(i,o,t))!==!1&&(r[o]=s||i)}),Object.defineProperties(t,r)},Bt=t=>{Pe(t,(e,n)=>{if(O(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(O(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+"'")})}})},Lt=(t,e)=>{const n={},r=i=>{i.forEach(o=>{n[o]=!0})};return q(t)?r(t):r(String(t).split(e)),n},Ft=()=>{},Ut=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function Dt(t){return!!(t&&O(t.append)&&t[ve]==="FormData"&&t[W])}const Mt=t=>{const e=new Array(10),n=(r,i)=>{if(z(r)){if(e.indexOf(r)>=0)return;if($(r))return r;if(!("toJSON"in r)){e[i]=r;const o=q(r)?[]:{};return J(r,(s,c)=>{const d=n(s,i+1);!H(d)&&(o[c]=d)}),e[i]=void 0,o}}return r};return n(t,0)},qt=x("AsyncFunction"),jt=t=>t&&(z(t)||O(t))&&O(t.then)&&O(t.catch),Ae=((t,e)=>t?setImmediate:e?((n,r)=>(F.addEventListener("message",({source:i,data:o})=>{i===F&&o===n&&r.length&&r.shift()()},!1),i=>{r.push(i),F.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",O(F.postMessage)),Ht=typeof queueMicrotask<"u"?queueMicrotask.bind(F):typeof process<"u"&&process.nextTick||Ae,a={isArray:q,isArrayBuffer:Se,isBuffer:$,isFormData:mt,isArrayBufferView:st,isString:at,isNumber:Te,isBoolean:ct,isObject:z,isPlainObject:Y,isEmptyObject:lt,isReadableStream:yt,isRequest:bt,isResponse:gt,isHeaders:Et,isUndefined:H,isDate:ut,isFile:dt,isBlob:ft,isRegExp:It,isFunction:O,isStream:pt,isURLSearchParams:wt,isTypedArray:At,isFileList:ht,forEach:J,merge:le,extend:St,trim:vt,stripBOM:Tt,inherits:Rt,toFlatObject:kt,kindOf:Z,kindOfTest:x,endsWith:Ot,toArray:Pt,forEachEntry:_t,matchAll:xt,isHTMLForm:Ct,hasOwnProperty:Oe,hasOwnProp:Oe,reduceDescriptors:Pe,freezeMethods:Bt,toObjectSet:Lt,toCamelCase:Nt,noop:Ft,toFiniteNumber:Ut,findKey:Re,global:F,isContextDefined:ke,isSpecCompliantForm:Dt,toJSONObject:Mt,isAsyncFn:qt,isThenable:jt,setImmediate:Ae,asap:Ht,isIterable:t=>t!=null&&O(t[W])};function m(t,e,n,r,i){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),i&&(this.response=i,this.status=i.status?i.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 _e=m.prototype,xe={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{xe[t]={value:t}}),Object.defineProperties(m,xe),Object.defineProperty(_e,"isAxiosError",{value:!0}),m.from=(t,e,n,r,i,o)=>{const s=Object.create(_e);return a.toFlatObject(t,s,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),m.call(s,t.message,e,n,r,i),s.cause=t,s.name=t.name,o&&Object.assign(s,o),s};const $t=null;function ue(t){return a.isPlainObject(t)||a.isArray(t)}function Ce(t){return a.endsWith(t,"[]")?t.slice(0,-2):t}function Ne(t,e,n){return t?t.concat(e).map(function(i,o){return i=Ce(i),!n&&o?"["+i+"]":i}).join(n?".":""):e}function zt(t){return a.isArray(t)&&!t.some(ue)}const Jt=a.toFlatObject(a,{},null,function(e){return/^is[A-Z]/.test(e)});function Q(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,i=n.visitor||u,o=n.dots,s=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(e);if(!a.isFunction(i))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)&&zt(h)||(a.isFileList(h)||a.endsWith(w,"[]"))&&(v=a.toArray(h)))return w=Ce(w),v.forEach(function(R,I){!(a.isUndefined(R)||R===null)&&e.append(s===!0?Ne([w],I,o):s===null?w:w+"[]",l(R))}),!1}return ue(h)?!0:(e.append(Ne(p,w,o),l(h)),!1)}const f=[],g=Object.assign(Jt,{defaultVisitor:u,convertValue:l,isVisitable:ue});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)&&i.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 Ie(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function de(t,e){this._pairs=[],t&&Q(t,this,e)}const Be=de.prototype;Be.append=function(e,n){this._pairs.push([e,n])},Be.toString=function(e){const n=e?function(r){return e.call(this,r,Ie)}:Ie;return this._pairs.map(function(i){return n(i[0])+"="+n(i[1])},"").join("&")};function Vt(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Le(t,e,n){if(!e)return t;const r=n&&n.encode||Vt;a.isFunction(n)&&(n={serialize:n});const i=n&&n.serialize;let o;if(i?o=i(e,n):o=a.isURLSearchParams(e)?e.toString():new de(e,n).toString(r),o){const s=t.indexOf("#");s!==-1&&(t=t.slice(0,s)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class Fe{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 Ue={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Xt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:de,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},fe=typeof window<"u"&&typeof document<"u",he=typeof navigator=="object"&&navigator||void 0,Kt=fe&&(!he||["ReactNative","NativeScript","NS"].indexOf(he.product)<0),Wt=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Zt=fe&&window.location.href||"http://localhost",k={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:fe,hasStandardBrowserEnv:Kt,hasStandardBrowserWebWorkerEnv:Wt,navigator:he,origin:Zt},Symbol.toStringTag,{value:"Module"})),...Xt};function Gt(t,e){return Q(t,new k.classes.URLSearchParams,{visitor:function(n,r,i,o){return k.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}function Yt(t){return a.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Qt(t){const e={},n=Object.keys(t);let r;const i=n.length;let o;for(r=0;r<i;r++)o=n[r],e[o]=t[o];return e}function De(t){function e(n,r,i,o){let s=n[o++];if(s==="__proto__")return!0;const c=Number.isFinite(+s),d=o>=n.length;return s=!s&&a.isArray(i)?i.length:s,d?(a.hasOwnProp(i,s)?i[s]=[i[s],r]:i[s]=r,!c):((!i[s]||!a.isObject(i[s]))&&(i[s]=[]),e(n,r,i[s],o)&&a.isArray(i[s])&&(i[s]=Qt(i[s])),!c)}if(a.isFormData(t)&&a.isFunction(t.entries)){const n={};return a.forEachEntry(t,(r,i)=>{e(Yt(r),i,n,0)}),n}return null}function en(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 V={transitional:Ue,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",i=r.indexOf("application/json")>-1,o=a.isObject(e);if(o&&a.isHTMLForm(e)&&(e=new FormData(e)),a.isFormData(e))return i?JSON.stringify(De(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 Gt(e,this.formSerializer).toString();if((c=a.isFileList(e))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return Q(c?{"files[]":e}:e,d&&new d,this.formSerializer)}}return o||i?(n.setContentType("application/json",!1),en(e)):e}],transformResponse:[function(e){const n=this.transitional||V.transitional,r=n&&n.forcedJSONParsing,i=this.responseType==="json";if(a.isResponse(e)||a.isReadableStream(e))return e;if(e&&a.isString(e)&&(r&&!this.responseType||i)){const s=!(n&&n.silentJSONParsing)&&i;try{return JSON.parse(e)}catch(c){if(s)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:k.classes.FormData,Blob:k.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=>{V.headers[t]={}});const tn=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"]),nn=t=>{const e={};let n,r,i;return t&&t.split(`
|
|
`).forEach(function(s){i=s.indexOf(":"),n=s.substring(0,i).trim().toLowerCase(),r=s.substring(i+1).trim(),!(!n||e[n]&&tn[n])&&(n==="set-cookie"?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e},Me=Symbol("internals");function X(t){return t&&String(t).trim().toLowerCase()}function ee(t){return t===!1||t==null?t:a.isArray(t)?t.map(ee):String(t)}function rn(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 on=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function pe(t,e,n,r,i){if(a.isFunction(r))return r.call(this,e,n);if(i&&(e=n),!!a.isString(e)){if(a.isString(r))return e.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(e)}}function sn(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function an(t,e){const n=a.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(i,o,s){return this[r].call(this,e,i,o,s)},configurable:!0})})}let P=class{constructor(e){e&&this.set(e)}set(e,n,r){const i=this;function o(c,d,l){const u=X(d);if(!u)throw new Error("header name must be a non-empty string");const f=a.findKey(i,u);(!f||i[f]===void 0||l===!0||l===void 0&&i[f]!==!1)&&(i[f||d]=ee(c))}const s=(c,d)=>a.forEach(c,(l,u)=>o(l,u,d));if(a.isPlainObject(e)||e instanceof this.constructor)s(e,n);else if(a.isString(e)&&(e=e.trim())&&!on(e))s(nn(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]}s(c,n)}else e!=null&&o(n,e,r);return this}get(e,n){if(e=X(e),e){const r=a.findKey(this,e);if(r){const i=this[r];if(!n)return i;if(n===!0)return rn(i);if(a.isFunction(n))return n.call(this,i,r);if(a.isRegExp(n))return n.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=X(e),e){const r=a.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||pe(this,this[r],r,n)))}return!1}delete(e,n){const r=this;let i=!1;function o(s){if(s=X(s),s){const c=a.findKey(r,s);c&&(!n||pe(r,r[c],c,n))&&(delete r[c],i=!0)}}return a.isArray(e)?e.forEach(o):o(e),i}clear(e){const n=Object.keys(this);let r=n.length,i=!1;for(;r--;){const o=n[r];(!e||pe(this,this[o],o,e,!0))&&(delete this[o],i=!0)}return i}normalize(e){const n=this,r={};return a.forEach(this,(i,o)=>{const s=a.findKey(r,o);if(s){n[s]=ee(i),delete n[o];return}const c=e?sn(o):String(o).trim();c!==o&&delete n[o],n[c]=ee(i),r[c]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return a.forEach(this,(r,i)=>{r!=null&&r!==!1&&(n[i]=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(i=>r.set(i)),r}static accessor(e){const r=(this[Me]=this[Me]={accessors:{}}).accessors,i=this.prototype;function o(s){const c=X(s);r[c]||(an(i,s),r[c]=!0)}return a.isArray(e)?e.forEach(o):o(e),this}};P.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(P.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}}),a.freezeMethods(P);function me(t,e){const n=this||V,r=e||n,i=P.from(r.headers);let o=r.data;return a.forEach(t,function(c){o=c.call(n,o,i.normalize(),e?e.status:void 0)}),i.normalize(),o}function qe(t){return!!(t&&t.__CANCEL__)}function j(t,e,n){m.call(this,t??"canceled",m.ERR_CANCELED,e,n),this.name="CanceledError"}a.inherits(j,m,{__CANCEL__:!0});function je(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 cn(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function ln(t,e){t=t||10;const n=new Array(t),r=new Array(t);let i=0,o=0,s;return e=e!==void 0?e:1e3,function(d){const l=Date.now(),u=r[o];s||(s=l),n[i]=d,r[i]=l;let f=o,g=0;for(;f!==i;)g+=n[f++],f=f%t;if(i=(i+1)%t,i===o&&(o=(o+1)%t),l-s<e)return;const S=u&&l-u;return S?Math.round(g*1e3/S):void 0}}function un(t,e){let n=0,r=1e3/e,i,o;const s=(l,u=Date.now())=>{n=u,i=null,o&&(clearTimeout(o),o=null),t(...l)};return[(...l)=>{const u=Date.now(),f=u-n;f>=r?s(l,u):(i=l,o||(o=setTimeout(()=>{o=null,s(i)},r-f)))},()=>i&&s(i)]}const te=(t,e,n=3)=>{let r=0;const i=ln(50,250);return un(o=>{const s=o.loaded,c=o.lengthComputable?o.total:void 0,d=s-r,l=i(d),u=s<=c;r=s;const f={loaded:s,total:c,progress:c?s/c:void 0,bytes:d,rate:l||void 0,estimated:l&&c&&u?(c-s)/l:void 0,event:o,lengthComputable:c!=null,[e?"download":"upload"]:!0};t(f)},n)},He=(t,e)=>{const n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},$e=t=>(...e)=>a.asap(()=>t(...e)),dn=k.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,k.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(k.origin),k.navigator&&/(msie|trident)/i.test(k.navigator.userAgent)):()=>!0,fn=k.hasStandardBrowserEnv?{write(t,e,n,r,i,o){const s=[t+"="+encodeURIComponent(e)];a.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),a.isString(r)&&s.push("path="+r),a.isString(i)&&s.push("domain="+i),o===!0&&s.push("secure"),document.cookie=s.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 hn(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function pn(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function ze(t,e,n){let r=!hn(e);return t&&(r||n==!1)?pn(t,e):e}const Je=t=>t instanceof P?{...t}:t;function U(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 i(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 s(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: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:c,headers:(l,u,f)=>i(Je(l),Je(u),f,!0)};return a.forEach(Object.keys({...t,...e}),function(u){const f=d[u]||i,g=f(t[u],e[u],u);a.isUndefined(g)&&f!==c||(n[u]=g)}),n}const Ve=t=>{const e=U({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:c}=e;e.headers=s=P.from(s),e.url=Le(ze(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),c&&s.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let d;if(a.isFormData(n)){if(k.hasStandardBrowserEnv||k.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((d=s.getContentType())!==!1){const[l,...u]=d?d.split(";").map(f=>f.trim()).filter(Boolean):[];s.setContentType([l||"multipart/form-data",...u].join("; "))}}if(k.hasStandardBrowserEnv&&(r&&a.isFunction(r)&&(r=r(e)),r||r!==!1&&dn(e.url))){const l=i&&o&&fn.read(o);l&&s.set(i,l)}return e},mn=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(n,r){const i=Ve(t);let o=i.data;const s=P.from(i.headers).normalize();let{responseType:c,onUploadProgress:d,onDownloadProgress:l}=i,u,f,g,S,h;function w(){S&&S(),h&&h(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let p=new XMLHttpRequest;p.open(i.method.toUpperCase(),i.url,!0),p.timeout=i.timeout;function v(){if(!p)return;const R=P.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),A={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:R,config:t,request:p};je(function(M){n(M),w()},function(M){r(M),w()},A),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=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const A=i.transitional||Ue;i.timeoutErrorMessage&&(I=i.timeoutErrorMessage),r(new m(I,A.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,t,p)),p=null},o===void 0&&s.setContentType(null),"setRequestHeader"in p&&a.forEach(s.toJSON(),function(I,A){p.setRequestHeader(A,I)}),a.isUndefined(i.withCredentials)||(p.withCredentials=!!i.withCredentials),c&&c!=="json"&&(p.responseType=i.responseType),l&&([g,h]=te(l,!0),p.addEventListener("progress",g)),d&&p.upload&&([f,S]=te(d),p.upload.addEventListener("progress",f),p.upload.addEventListener("loadend",S)),(i.cancelToken||i.signal)&&(u=R=>{p&&(r(!R||R.type?new j(null,t,p):R),p.abort(),p=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const T=cn(i.url);if(T&&k.protocols.indexOf(T)===-1){r(new m("Unsupported protocol "+T+":",m.ERR_BAD_REQUEST,t));return}p.send(o||null)})},wn=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,i;const o=function(l){if(!i){i=!0,c();const u=l instanceof Error?l:this.reason;r.abort(u instanceof m?u:new j(u instanceof Error?u.message:u))}};let s=e&&setTimeout(()=>{s=null,o(new m(`timeout ${e} of ms exceeded`,m.ETIMEDOUT))},e);const c=()=>{t&&(s&&clearTimeout(s),s=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}},yn=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let r=0,i;for(;r<n;)i=r+e,yield t.slice(r,i),r=i},bn=async function*(t,e){for await(const n of gn(t))yield*yn(n,e)},gn=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()}},Xe=(t,e,n,r)=>{const i=bn(t,e);let o=0,s,c=d=>{s||(s=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:l,value:u}=await i.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),i.return()}},{highWaterMark:2})},ne=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Ke=ne&&typeof ReadableStream=="function",En=ne&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),We=(t,...e)=>{try{return!!t(...e)}catch{return!1}},vn=Ke&&We(()=>{let t=!1;const e=new Request(k.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),Ze=64*1024,we=Ke&&We(()=>a.isReadableStream(new Response("").body)),re={stream:we&&(t=>t.body)};ne&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!re[e]&&(re[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 Sn=async t=>{if(t==null)return 0;if(a.isBlob(t))return t.size;if(a.isSpecCompliantForm(t))return(await new Request(k.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 En(t)).byteLength},Tn=async(t,e)=>{const n=a.toFiniteNumber(t.getContentLength());return n??Sn(e)},ye={http:$t,xhr:mn,fetch:ne&&(async t=>{let{url:e,method:n,data:r,signal:i,cancelToken:o,timeout:s,onDownloadProgress:c,onUploadProgress:d,responseType:l,headers:u,withCredentials:f="same-origin",fetchOptions:g}=Ve(t);l=l?(l+"").toLowerCase():"text";let S=wn([i,o&&o.toAbortSignal()],s),h;const w=S&&S.unsubscribe&&(()=>{S.unsubscribe()});let p;try{if(d&&vn&&n!=="get"&&n!=="head"&&(p=await Tn(u,r))!==0){let A=new Request(e,{method:"POST",body:r,duplex:"half"}),L;if(a.isFormData(r)&&(L=A.headers.get("content-type"))&&u.setContentType(L),A.body){const[M,ae]=He(p,te($e(d)));r=Xe(A.body,Ze,M,ae)}}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 R=we&&(l==="stream"||l==="response");if(we&&(c||R&&w)){const A={};["status","statusText","headers"].forEach(rt=>{A[rt]=T[rt]});const L=a.toFiniteNumber(T.headers.get("content-length")),[M,ae]=c&&He(L,te($e(c),!0))||[];T=new Response(Xe(T.body,Ze,M,()=>{ae&&ae(),w&&w()}),A)}l=l||"text";let I=await re[a.findKey(re,l)||"text"](T,t);return!R&&w&&w(),await new Promise((A,L)=>{je(A,L,{data:I,headers:P.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(ye,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Ge=t=>`- ${t}`,Rn=t=>a.isFunction(t)||t===null||t===!1,Ye={getAdapter:t=>{t=a.isArray(t)?t:[t];const{length:e}=t;let n,r;const i={};for(let o=0;o<e;o++){n=t[o];let s;if(r=n,!Rn(n)&&(r=ye[(s=String(n)).toLowerCase()],r===void 0))throw new m(`Unknown adapter '${s}'`);if(r)break;i[s||"#"+o]=r}if(!r){const o=Object.entries(i).map(([c,d])=>`adapter ${c} `+(d===!1?"is not supported by the environment":"is not available in the build"));let s=e?o.length>1?`since :
|
|
`+o.map(Ge).join(`
|
|
`):" "+Ge(o[0]):"as no adapter specified";throw new m("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return r},adapters:ye};function be(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new j(null,t)}function Qe(t){return be(t),t.headers=P.from(t.headers),t.data=me.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Ye.getAdapter(t.adapter||V.adapter)(t).then(function(r){return be(t),r.data=me.call(t,t.transformResponse,r),r.headers=P.from(r.headers),r},function(r){return qe(r)||(be(t),r&&r.response&&(r.response.data=me.call(t,t.transformResponse,r.response),r.response.headers=P.from(r.response.headers))),Promise.reject(r)})}const et="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 tt={};ie.transitional=function(e,n,r){function i(o,s){return"[Axios v"+et+"] Transitional option '"+o+"'"+s+(r?". "+r:"")}return(o,s,c)=>{if(e===!1)throw new m(i(s," has been removed"+(n?" in "+n:"")),m.ERR_DEPRECATED);return n&&!tt[s]&&(tt[s]=!0,console.warn(i(s," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(o,s,c):!0}},ie.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function kn(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 i=r.length;for(;i-- >0;){const o=r[i],s=e[o];if(s){const c=t[o],d=c===void 0||s(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 oe={assertOptions:kn,validators:ie},N=oe.validators;let D=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Fe,response:new Fe}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const o=i.stack?i.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=U(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:o}=n;r!==void 0&&oe.assertOptions(r,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),i!=null&&(a.isFunction(i)?n.paramsSerializer={serialize:i}:oe.assertOptions(i,{encode:N.function,serialize:N.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),oe.assertOptions(n,{baseUrl:N.spelling("baseURL"),withXsrfToken:N.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let s=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],h=>{delete o[h]}),n.headers=P.concat(s,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=[Qe.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=Qe.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=U(this.defaults,e);const n=ze(e.baseURL,e.url,e.allowAbsoluteUrls);return Le(n,e.params,e.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(e){D.prototype[e]=function(n,r){return this.request(U(r||{},{method:e,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(e){function n(r){return function(o,s,c){return this.request(U(c||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}D.prototype[e]=n(),D.prototype[e+"Form"]=n(!0)});let On=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(i=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](i);r._listeners=null}),this.promise.then=i=>{let o;const s=new Promise(c=>{r.subscribe(c),o=c}).then(i);return s.cancel=function(){r.unsubscribe(o)},s},e(function(o,s,c){r.reason||(r.reason=new j(o,s,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(i){e=i}),cancel:e}}};function Pn(t){return function(n){return t.apply(null,n)}}function An(t){return a.isObject(t)&&t.isAxiosError===!0}const ge={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(ge).forEach(([t,e])=>{ge[e]=t});function nt(t){const e=new D(t),n=Ee(D.prototype.request,e);return a.extend(n,D.prototype,e,{allOwnKeys:!0}),a.extend(n,e,null,{allOwnKeys:!0}),n.create=function(i){return nt(U(t,i))},n}const E=nt(V);E.Axios=D,E.CanceledError=j,E.CancelToken=On,E.isCancel=qe,E.VERSION=et,E.toFormData=Q,E.AxiosError=m,E.Cancel=E.CanceledError,E.all=function(e){return Promise.all(e)},E.spread=Pn,E.isAxiosError=An,E.mergeConfig=U,E.AxiosHeaders=P,E.formToJSON=t=>De(a.isHTMLForm(t)?new FormData(t):t),E.getAdapter=Ye.getAdapter,E.HttpStatusCode=ge,E.default=E;const{Axios:Hn,AxiosError:$n,CanceledError:zn,isCancel:Jn,CancelToken:Vn,VERSION:Xn,all:Kn,Cancel:Wn,isAxiosError:Zn,spread:Gn,toFormData:Yn,AxiosHeaders:Qn,HttpStatusCode:er,formToJSON:tr,getAdapter:nr,mergeConfig:rr}=E,se=E.create({baseURL:"https://aitool.danielvu.com/auto-list/",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2ludC5pcHN1cHBseS5jb20uYXUvYXBpL2xvZ2luIiwiaWF0IjoxNzIxNjA5MTEzLCJleHAiOjMyMzUzMzcxMTMsIm5iZiI6MTcyMTYwOTExMywianRpIjoiWHpCZkZPc0ZJUlFxaEZvaiIsInN1YiI6MSwicHJ2IjoiYzhlZTFmYzg5ZTc3NWVjNGM3Mzg2NjdlNWJlMTdhNTkwYjZkNDBmYyJ9.kFFEPpdmNUp-kn_G3cIIc26bivO6tbfcvkpG9I8Im7M"}});class _n{item_per_page=10;async index(e){const n={skip:0,limit:10,order:"updatedAt desc",where:{account:"prology_net",status:"Updated"}};return se({method:"POST",data:{urlAPI:"/api/ebay-listing/listing-get-list",filter:{...n,...e,where:{...n.where,...e?.where}}}})}async get(e){return se({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 sync(e){return se({url:"sync",method:"POST",data:e})}async getPublistedProducts(){return se({url:"data"})}async apiRequest(e,n){return new Promise((r,i)=>{const o="req_"+Date.now()+"_"+Math.random();function s(c){c.data.type==="API_RESPONSE"&&c.data.requestId===o&&(window.removeEventListener("message",s),c.data.error?i(c.data.error):r(c.data.payload))}window.addEventListener("message",s),window.postMessage({type:"API_REQUEST",requestId:o,payload:n,fn:e},"*")})}}const K=new _n;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 xn{static ID_EXTENSION="ex-root"}class Cn{base64ToFile(e,n,r){const i=e.includes(",")?e.split(",")[1]:e,o=atob(i),s=new ArrayBuffer(o.length),c=new Uint8Array(s);for(let l=0;l<o.length;l++)c[l]=o.charCodeAt(l);const d=new Blob([s],{type:r});return new File([d],n,{type:r})}clickByPoint(e){const n=e.getBoundingClientRect(),r=n.left+n.width/2,i=n.top+n.height/2,o=document.elementFromPoint(r,i);o&&o.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}))}async getElementByXPath(e,{retryCount:n=2,delay:r=100,xpathFallback:i}={}){return new Promise(o=>{let s=0,c=!1;const d=()=>{const l=document.evaluate(c&&i?i:e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(l instanceof HTMLElement){o(l);return}s++,s<n?setTimeout(d,r):!c&&i?(c=!0,s=0,setTimeout(d,r)):o(null)};d()})}async imageUrlToBase64(e){const r=await(await fetch(e)).blob();return new Promise((i,o)=>{const s=new FileReader;s.onloadend=()=>{typeof s.result=="string"?i(s.result.split(",")[1]):o("Không thể đọc dữ liệu ảnh")},s.onerror=o,s.readAsDataURL(r)})}getImageExtension(e){try{const r=new URL(e).pathname.match(/\.([a-zA-Z0-9]+)$/);return r?r[1].toLowerCase():null}catch{const i=e.split("?")[0].match(/\.([a-zA-Z0-9]+)$/);return i?i[1].toLowerCase():null}}imageLocalToBase64(e){return new Promise((n,r)=>{try{const i=chrome.runtime.getURL(`${e}`);fetch(i).then(o=>o.blob()).then(o=>{const s=new FileReader;s.onloadend=()=>n(s.result),s.onerror=r,s.readAsDataURL(o)}).catch(r)}catch(i){r(i)}})}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,i=n.top+n.height/2;return{x:r,y:i}}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 i=document.querySelector(e);if(!i)return null;const o=i.querySelectorAll(n);for(const s of o)if(s.innerText.trim().toLowerCase()===r.toLowerCase())return s;return null}findNestedIcElement(e,n,r){let i=null;if(typeof e=="string"){if(document.querySelector(e),!i)return null}else i=e;const o=i.querySelectorAll(n);for(const s of o)if(s.innerText.trim().toLowerCase().includes(r.toLowerCase()))return s;return null}findElInParent(e,n){return e&&e.parentElement?.querySelector(n)||null}waitForElement(e,n=100){return new Promise(r=>{const i=d=>d.offsetParent!==null&&(d.childElementCount>0||d.innerText.trim().length>0),o=()=>{const d=document.querySelector(e);d&&i(d)&&(s.disconnect(),clearInterval(c),r(d))},s=new MutationObserver(o);s.observe(document.body,{childList:!0,subtree:!0});const c=setInterval(o,n);o()})}}const y=new Cn;class Nn{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",products:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[2]/div/div/div[2]/div[1]/div/div[2]/div[2]/div",products_fallback:"/html/body/div[1]/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[2]/div/div/div[2]/div[1]/div/div[3]/div/div/span/div[2]/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"]'};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 i of e.images){const o=await y.imageUrlToBase64(i);console.log("Base64:",i.slice(0,50)+"...");const s=y.base64ToFile(o,e.sku,y.getImageExtension(i)||"jpg");n.items.add(s)}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 i=y.findNestedElement(this.selectors.market_container,"span",n);y.scrollToElement(i),await b(500,600),i?.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")||[],i=Array.from(r).find(o=>o.innerHTML.trim().toLowerCase().includes(e.toLowerCase()));if(console.log(i),!i)throw new Error(`No child found with text "${e}"`);y.scrollToElement(i),await B(400),y.clickByPoint(i)};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=>{console.log({item: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 s=this.findInputByTitle("brand");await y.writeToInput(e.brand,s)}await b(600,1e3);const i=this.findInputByTitle("description","textarea");await y.writeToInput(e.description,i),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=>{console.log({item:e}),await y.waitForElement('[aria-label="Collection of your Marketplace items"]');const n=await this.getOptionEls(e);console.log({items:n}),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 i=this.findInputByTitle("price");y.writeToInput(String(e.price),i),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};getProducts=async()=>{const e=await y.getElementByXPath(this.selectors.products),n=await y.getElementByXPath(this.selectors.products_fallback);console.log({products1:e,products2:n});const r=[e,n].filter(Boolean);return r.length===0?[]:r.flatMap(i=>this.extractListings(i))};extractListings(e){return Array.from(e.children).map(r=>{const o=r.querySelector('span[dir="auto"], div[dir="auto"]')?.textContent?.trim()||"",s=document.querySelectorAll(`[aria-label="${o}"]`),c=Array.from(s).filter(f=>!f.querySelector("img"))[0],l=y.findNestedIcElement(c,"span","AU$")?.textContent?.match(/[\d,]+(?:\.\d+)?/),u=l?parseFloat(l[0].replace(/,/g,"")):0;return{title:o,price:u,el:e}})}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(i=>i.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(i=>i.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);console.log({items:n}),this.clickItemInList(n,"delete"),await B(1e3);const r=await y.getElementByXPath(this.selectors.option_btn,{xpathFallback:this.selectors.option_btn_fallback});console.log({confirmBtn:r}),r?.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,i)=>{const o=Date.now(),s=()=>{window.location.href.includes(e)?r():Date.now()-o>n?i(new Error("Timeout waiting for URL change")):setTimeout(s,500)};s()})}waitForPageReady(e,n,r=15e3){return new Promise((i,o)=>{const s=Date.now(),c=async()=>{window.location.href.includes(e)&&document.querySelector(n)?i():Date.now()-s>r?o(new Error("Timeout waiting for selling page ready")):setTimeout(c,500)};c()})}syncListing=async()=>{window.location.href.includes(this.sellingPath)||(document.querySelector('a[href="/marketplace/you/selling/"]')?.click?.(),await this.waitForPageReady(this.sellingPath,this.selectors.products)),await C.getProducts()};extractMarketplaceItemId(e){const n=e.match(/\/marketplace\/item\/(\d+)/);return n?n[1]:null}handleGetPublistID=async e=>{const n=await C.getProducts(),r=n.find(c=>c.title==e.title&&c.price==e.price);if(console.log({payload:e,product:r,products:n}),!r)return;r.el;const i=await this.getOptionEls(e),o=this.getItemInList(i,"view listing"),s=this.extractMarketplaceItemId(o.href);return this.clickOptionOfProduct(e),s};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 C=new Nn;class In{role;listeners;constructor(e){this.role=e,this.listeners=new Map,chrome.runtime.onMessage.addListener((n,r,i)=>{if(n?.type&&this.listeners.has(n.type))return this.listeners.get(n.type)(n.payload,r,i),!0})}on(e,n){this.listeners.set(e,n)}send(e,n,r){const i={from:this.role,to:e,type:n,payload:r};(this.role==="popup"||this.role==="content")&&chrome.runtime.sendMessage(i),this.role==="background"&&(e==="content"?chrome.tabs.query({active:!0,currentWindow:!0},o=>{o[0]?.id&&chrome.tabs.sendMessage(o[0].id,i,()=>{chrome.runtime.lastError&&console.warn("Không gửi được tới content script:",chrome.runtime.lastError.message)})}):e==="popup"&&chrome.runtime.sendMessage(i,()=>{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 i={from:this.role,to:"content",type:n,payload:r};chrome.tabs.sendMessage(e,i,()=>{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,i)=>{let o;const s=c=>{clearTimeout(o),this.off(e,s),r(c)};o=setTimeout(()=>{this.off(e,s),i(new Error(`Timeout khi chờ message: ${e}`))},n),this.on(e,s)})}off(e,n){this.listeners.get(e)===n&&this.listeners.delete(e)}}const _=new In("content"),Bn=()=>{const t=xn.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.appendChild(r)};_.on("background-to-content-publish",async t=>{try{console.log("[publish] Content nhận:",t),await b(800,1e3),await C.handlePublist(t.data)}catch(e){console.log({error:e})}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 C.gotoSell(),await b(800,1e3),await C.handleDelete(t.data),await b(800,1e3);const e=await C.getProducts();await b(800,1e3),K.sync(e)}catch(e){console.log({error:e})}finally{_.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 C.gotoSell(),await b(800,1e3),await C.handleRePublist(t.data)}catch(e){console.log({error:e})}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;console.log({requestId:r,event:t,body:e});try{let i=null;switch(n){case"index":{i=(await K.index(e)).data;break}case"getPublistedProducts":{i=(await K.getPublistedProducts()).data;break}case"get":{i=(await K.get(e)).data,console.log({data:i,body:e});break}case"createBlobUrl":{_.send("background","content-to-background-create-blod-urls",e),i=await _.waitForMessage("background-to-content-create-blod-urls"),console.log({data:i});break}case"publist":{_.send("background","content-to-background-actions",{type:"publist",data:e}),i=await _.waitForMessage("background-to-content-actions"),console.log({publisted:i});break}case"unlist":{_.send("background","content-to-background-actions",{type:"unlist",data:e}),console.log({body:e}),i=await _.waitForMessage("background-to-content-actions"),console.log({data:i});break}}window.postMessage({type:"API_RESPONSE",requestId:r,payload:i},"*")}catch(i){window.postMessage({type:"API_RESPONSE",requestId:r,error:i.message},"*")}}}),(async()=>(Bn(),await b(800,1e3),y.waitForElement('[aria-label="Collection of your Marketplace items"]').then(async t=>{console.log("Element đã xuất hiện:",t),await C.waitForPageReady(C.sellingPath,'[aria-label="Collection of your Marketplace items"]'),await b(800,1e3);const e=await C.getProducts();console.log({products:e}),K.sync(e)}).catch(t=>{console.error(t)})))()})();
|