7 lines
51 KiB
JavaScript
7 lines
51 KiB
JavaScript
(function(){"use strict";function ge(t,e){return function(){return t.apply(e,arguments)}}const{toString:ot}=Object.prototype,{getPrototypeOf:ae}=Object,{iterator:K,toStringTag:Ee}=Symbol,W=(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=>W(e)===t),Z=t=>e=>typeof e===t,{isArray:M}=Array,H=Z("undefined");function $(t){return t!==null&&!H(t)&&t.constructor!==null&&!H(t.constructor)&&A(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const ve=x("ArrayBuffer");function st(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&ve(t.buffer),e}const at=Z("string"),A=Z("function"),Se=Z("number"),z=t=>t!==null&&typeof t=="object",ct=t=>t===!0||t===!1,G=t=>{if(W(t)!=="object")return!1;const e=ae(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Ee in t)&&!(K 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)&&A(t.pipe),mt=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||A(t.append)&&((e=W(t))==="formdata"||e==="object"&&A(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]),M(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 Te(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 I=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Re=t=>!H(t)&&t!==I;function ce(){const{caseless:t}=Re(this)&&this||{},e={},n=(r,i)=>{const o=t&&Te(e,i)||i;G(e[o])&&G(r)?e[o]=ce(e[o],r):G(r)?e[o]=ce({},r):M(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&&A(i)?t[o]=ge(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)},Ot=(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&&ae(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},kt=t=>{if(!t)return null;if(M(t))return t;let e=t.length;if(!Se(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},Pt=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&ae(Uint8Array)),xt=(t,e)=>{const r=(t&&t[K]).call(t);let i;for(;(i=r.next())&&!i.done;){const o=i.value;e.call(t,o[0],o[1])}},Ct=(t,e)=>{let n;const r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},_t=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),Bt=x("RegExp"),Ae=(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)},Lt=t=>{Ae(t,(e,n)=>{if(A(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(A(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+"'")})}})},It=(t,e)=>{const n={},r=i=>{i.forEach(o=>{n[o]=!0})};return M(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&&A(t.append)&&t[Ee]==="FormData"&&t[K])}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=M(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)||A(t))&&A(t.then)&&A(t.catch),ke=((t,e)=>t?setImmediate:e?((n,r)=>(I.addEventListener("message",({source:i,data:o})=>{i===I&&o===n&&r.length&&r.shift()()},!1),i=>{r.push(i),I.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",A(I.postMessage)),Ht=typeof queueMicrotask<"u"?queueMicrotask.bind(I):typeof process<"u"&&process.nextTick||ke,a={isArray:M,isArrayBuffer:ve,isBuffer:$,isFormData:mt,isArrayBufferView:st,isString:at,isNumber:Se,isBoolean:ct,isObject:z,isPlainObject:G,isEmptyObject:lt,isReadableStream:yt,isRequest:bt,isResponse:gt,isHeaders:Et,isUndefined:H,isDate:ut,isFile:dt,isBlob:ft,isRegExp:Bt,isFunction:A,isStream:pt,isURLSearchParams:wt,isTypedArray:Pt,isFileList:ht,forEach:J,merge:ce,extend:St,trim:vt,stripBOM:Tt,inherits:Rt,toFlatObject:Ot,kindOf:W,kindOfTest:x,endsWith:At,toArray:kt,forEachEntry:xt,matchAll:Ct,isHTMLForm:_t,hasOwnProperty:Oe,hasOwnProp:Oe,reduceDescriptors:Ae,freezeMethods:Lt,toObjectSet:It,toCamelCase:Nt,noop:Ft,toFiniteNumber:Ut,findKey:Te,global:I,isContextDefined:Re,isSpecCompliantForm:Dt,toJSONObject:Mt,isAsyncFn:qt,isThenable:jt,setImmediate:ke,asap:Ht,isIterable:t=>t!=null&&A(t[K])};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 Pe=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(Pe,"isAxiosError",{value:!0}),m.from=(t,e,n,r,i,o)=>{const s=Object.create(Pe);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 le(t){return a.isPlainObject(t)||a.isArray(t)}function Ce(t){return a.endsWith(t,"[]")?t.slice(0,-2):t}function _e(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(le)}const Jt=a.toFlatObject(a,{},null,function(e){return/^is[A-Z]/.test(e)});function Y(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,N){!(a.isUndefined(R)||R===null)&&e.append(s===!0?_e([w],N,o):s===null?w:w+"[]",l(R))}),!1}return le(h)?!0:(e.append(_e(p,w,o),l(h)),!1)}const f=[],g=Object.assign(Jt,{defaultVisitor:u,convertValue:l,isVisitable:le});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 Ne(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function ue(t,e){this._pairs=[],t&&Y(t,this,e)}const Be=ue.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,Ne)}:Ne;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 ue(e,n).toString(r),o){const s=t.indexOf("#");s!==-1&&(t=t.slice(0,s)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}class Ie{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 Fe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Xt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ue,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},de=typeof window<"u"&&typeof document<"u",fe=typeof navigator=="object"&&navigator||void 0,Kt=de&&(!fe||["ReactNative","NativeScript","NS"].indexOf(fe.product)<0),Wt=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Zt=de&&window.location.href||"http://localhost",O={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:de,hasStandardBrowserEnv:Kt,hasStandardBrowserWebWorkerEnv:Wt,navigator:fe,origin:Zt},Symbol.toStringTag,{value:"Module"})),...Xt};function Gt(t,e){return Y(t,new O.classes.URLSearchParams,{visitor:function(n,r,i,o){return O.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 Ue(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:Fe,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(Ue(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 Y(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: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=>{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},De=Symbol("internals");function X(t){return t&&String(t).trim().toLowerCase()}function Q(t){return t===!1||t==null?t:a.isArray(t)?t.map(Q):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 he(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 k=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]=Q(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||he(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||he(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||he(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]=Q(i),delete n[o];return}const c=e?sn(o):String(o).trim();c!==o&&delete n[o],n[c]=Q(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[De]=this[De]={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}};k.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(k.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}}),a.freezeMethods(k);function pe(t,e){const n=this||V,r=e||n,i=k.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 Me(t){return!!(t&&t.__CANCEL__)}function q(t,e,n){m.call(this,t??"canceled",m.ERR_CANCELED,e,n),this.name="CanceledError"}a.inherits(q,m,{__CANCEL__:!0});function qe(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 ee=(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)},je=(t,e)=>{const n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},He=t=>(...e)=>a.asap(()=>t(...e)),dn=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,fn=O.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 $e(t,e,n){let r=!hn(e);return t&&(r||n==!1)?pn(t,e):e}const ze=t=>t instanceof k?{...t}:t;function F(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(ze(l),ze(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 Je=t=>{const e=F({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:c}=e;e.headers=s=k.from(s),e.url=Le($e(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(O.hasStandardBrowserEnv||O.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(O.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=Je(t);let o=i.data;const s=k.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=k.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),P={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:R,config:t,request:p};qe(function(D){n(D),w()},function(D){r(D),w()},P),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 N=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const P=i.transitional||Fe;i.timeoutErrorMessage&&(N=i.timeoutErrorMessage),r(new m(N,P.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,t,p)),p=null},o===void 0&&s.setContentType(null),"setRequestHeader"in p&&a.forEach(s.toJSON(),function(N,P){p.setRequestHeader(P,N)}),a.isUndefined(i.withCredentials)||(p.withCredentials=!!i.withCredentials),c&&c!=="json"&&(p.responseType=i.responseType),l&&([g,h]=ee(l,!0),p.addEventListener("progress",g)),d&&p.upload&&([f,S]=ee(d),p.upload.addEventListener("progress",f),p.upload.addEventListener("loadend",S)),(i.cancelToken||i.signal)&&(u=R=>{p&&(r(!R||R.type?new q(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&&O.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 q(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()}},Ve=(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})},te=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Xe=te&&typeof ReadableStream=="function",En=te&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),Ke=(t,...e)=>{try{return!!t(...e)}catch{return!1}},vn=Xe&&Ke(()=>{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}),We=64*1024,me=Xe&&Ke(()=>a.isReadableStream(new Response("").body)),ne={stream:me&&(t=>t.body)};te&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!ne[e]&&(ne[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(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 En(t)).byteLength},Tn=async(t,e)=>{const n=a.toFiniteNumber(t.getContentLength());return n??Sn(e)},we={http:$t,xhr:mn,fetch:te&&(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}=Je(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 P=new Request(e,{method:"POST",body:r,duplex:"half"}),L;if(a.isFormData(r)&&(L=P.headers.get("content-type"))&&u.setContentType(L),P.body){const[D,se]=je(p,ee(He(d)));r=Ve(P.body,We,D,se)}}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=me&&(l==="stream"||l==="response");if(me&&(c||R&&w)){const P={};["status","statusText","headers"].forEach(rt=>{P[rt]=T[rt]});const L=a.toFiniteNumber(T.headers.get("content-length")),[D,se]=c&&je(L,ee(He(c),!0))||[];T=new Response(Ve(T.body,We,D,()=>{se&&se(),w&&w()}),P)}l=l||"text";let N=await ne[a.findKey(ne,l)||"text"](T,t);return!R&&w&&w(),await new Promise((P,L)=>{qe(P,L,{data:N,headers:k.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(we,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Ze=t=>`- ${t}`,Rn=t=>a.isFunction(t)||t===null||t===!1,Ge={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=we[(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(Ze).join(`
|
|
`):" "+Ze(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:we};function ye(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new q(null,t)}function Ye(t){return ye(t),t.headers=k.from(t.headers),t.data=pe.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Ge.getAdapter(t.adapter||V.adapter)(t).then(function(r){return ye(t),r.data=pe.call(t,t.transformResponse,r),r.headers=k.from(r.headers),r},function(r){return Me(r)||(ye(t),r&&r.response&&(r.response.data=pe.call(t,t.transformResponse,r.response),r.response.headers=k.from(r.response.headers))),Promise.reject(r)})}const Qe="1.11.0",re={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{re[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const et={};re.transitional=function(e,n,r){function i(o,s){return"[Axios v"+Qe+"] 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&&!et[s]&&(et[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}},re.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function On(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 ie={assertOptions:On,validators:re},_=ie.validators;let U=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Ie,response:new Ie}}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=F(this.defaults,n);const{transitional:r,paramsSerializer:i,headers:o}=n;r!==void 0&&ie.assertOptions(r,{silentJSONParsing:_.transitional(_.boolean),forcedJSONParsing:_.transitional(_.boolean),clarifyTimeoutError:_.transitional(_.boolean)},!1),i!=null&&(a.isFunction(i)?n.paramsSerializer={serialize:i}:ie.assertOptions(i,{encode:_.function,serialize:_.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ie.assertOptions(n,{baseUrl:_.spelling("baseURL"),withXsrfToken:_.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=k.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=[Ye.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=Ye.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=F(this.defaults,e);const n=$e(e.baseURL,e.url,e.allowAbsoluteUrls);return Le(n,e.params,e.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(e){U.prototype[e]=function(n,r){return this.request(F(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(F(c||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}U.prototype[e]=n(),U.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(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 q(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 kn(t){return function(n){return t.apply(null,n)}}function Pn(t){return a.isObject(t)&&t.isAxiosError===!0}const be={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(be).forEach(([t,e])=>{be[e]=t});function tt(t){const e=new U(t),n=ge(U.prototype.request,e);return a.extend(n,U.prototype,e,{allOwnKeys:!0}),a.extend(n,e,null,{allOwnKeys:!0}),n.create=function(i){return tt(F(t,i))},n}const E=tt(V);E.Axios=U,E.CanceledError=q,E.CancelToken=An,E.isCancel=Me,E.VERSION=Qe,E.toFormData=Y,E.AxiosError=m,E.Cancel=E.CanceledError,E.all=function(e){return Promise.all(e)},E.spread=kn,E.isAxiosError=Pn,E.mergeConfig=F,E.AxiosHeaders=k,E.formToJSON=t=>Ue(a.isHTMLForm(t)?new FormData(t):t),E.getAdapter=Ge.getAdapter,E.HttpStatusCode=be,E.default=E;const{Axios:qn,AxiosError:jn,CanceledError:Hn,isCancel:$n,CancelToken:zn,VERSION:Jn,all:Vn,Cancel:Xn,isAxiosError:Kn,spread:Wn,toFormData:Zn,AxiosHeaders:Gn,HttpStatusCode:Yn,formToJSON:Qn,getAdapter:er,mergeConfig:tr}=E,oe=E.create({baseURL:"https://int.ipsupply.com.au/api/",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 oe({url:"transferGetData",method:"POST",data:{urlAPI:"/api/ebay-listing/listing-get-list",filter:{...n,...e,where:{...n.where,...e?.where}}}})}async get(e){return oe({url:"transferGetData",method:"POST",data:{urlAPI:"/api/product-model/get-info/"+e.id,pageCurrent:"/productdata/products/edit/"+e.id}})}async sync(e){return oe({baseURL:"http://localhost:3000/",url:"sync",method:"POST",data:e})}async getPublistedProducts(){return oe({baseURL:"http://localhost:3000/",url:"data"})}}const nt=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 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 _n{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 _n;class Nn{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 j=new Nn("content");j.on("background-to-content-publish",async t=>{try{console.log("[publish] Content nhận:",t),await b(1e3,2e3),await C.handlePublist(t.data)}catch(e){console.log({error:e})}finally{j.send("background","content-to-background-publish",{msg:t})}}),j.on("background-to-content-unlist",async t=>{try{console.log("[unlist] Content nhận:",t),await b(1e3,2e3),await C.gotoSell(),await b(1e3,2e3),await C.handleDelete(t.data),await b(1e3,2e3);const e=await C.getProducts();await b(1e3,2e3),nt.sync(e)}catch(e){console.log({error:e})}finally{j.send("background","content-to-background-unlist",{msg:t})}}),j.on("background-to-content-re-publist",async t=>{try{console.log("[re-publist] Content nhận:",t),await b(1e3,2e3),await C.gotoSell(),await b(1e3,2e3),await C.handleRePublist(t.data)}catch(e){console.log({error:e})}finally{j.send("background","content-to-background-re-publist",{msg:t})}}),(async()=>(await b(1e3,2e3),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(1e3,2e3);const e=await C.getProducts();console.log({products:e}),nt.sync(e)}).catch(t=>{console.error(t)})))()})();
|