@vtj/utils 0.18.10 → 0.18.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2,6 +2,6 @@
2
2
  * Copyright (c) 2026, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/utils
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.18.10
5
+ * @version 0.18.11
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
- */const Q="0.18.10",Y={form:"application/x-www-form-urlencoded",json:"application/json",data:"multipart/form-data"},K=["put","post","patch"],L="Local-Request-Id",G=100,Z=300,ee="/api/proxy";class D{constructor(e={}){h(this,"axios");h(this,"settings");h(this,"records",{});h(this,"isLoading",!1);h(this,"stopSkipWarn");h(this,"showLoading");h(this,"showError");this.settings=Object.assign({type:"form"},e.settings||{});const t=u.omit(e,["settings","query"]);this.axios=E.create(u.merge({headers:{"Content-Type":"application/x-www-form-urlencoded"},timeout:120*1e3},t)),this.setupSkipWarn(this.settings),this.showLoading=u.debounce(this.openLoading.bind(this),G),this.showError=u.throttle(this._showError.bind(this),Z,{leading:!0,trailing:!1})}setConfig(e={}){this.settings=u.merge(this.settings,e.settings||{});const t=u.omit(e,["settings","query"]);this.axios.defaults=u.merge(this.axios.defaults,t),this.setupSkipWarn(this.settings)}cancel(e,t="请求已取消"){if(e){const o=this.records[e];if(!o)return;o.source.cancel(t)}else for(const o of Object.values(this.records))o.source.cancel(t)}createHeaders(e,t,o){const r=t.injectHeaders?typeof t.headers=="function"?t.headers(e,o,t):t.headers||{}:{},s={"Content-Type":Y[t.type||"form"],...o.headers,...r};return t.skipWarn&&(s[L]=e),s}isJsonType(e){return Object.entries(e).some(([t,o])=>t.toLowerCase()==="content-type"&&String(o).includes("application/json"))}toFormData(e,t="data"){if(e instanceof FormData||e instanceof URLSearchParams)return e;const o=t==="data"?new FormData:new URLSearchParams;return Object.entries(e).forEach(([r,s])=>{o.append(r,s)}),o}createSendData(e,t,o,r,s={}){const{type:i,skipWarn:c}=e,{name:a="skipWarn"}=c||{};let{data:d,params:l={},method:f="get"}=t;const g=r?{[a]:!0}:{};return K.includes(f.toLowerCase())?(d=Object.assign(d||{},g),d=i!=="json"||!this.isJsonType(o)?this.toFormData(d,i):d,l={...s}):i==="form"?l={...d||{},...s,...g}:(d&&(i!=="json"||!this.isJsonType(o))&&(d=this.toFormData(d,i)),l={...s,...g}),{data:d,params:l}}createUrl(e){let{url:t,params:o}=e;if(t){let r=u.isUrl(t)?new URL(t).origin:"";const s=r?t.replace(r,""):t;try{const i=u.pathToRegexpCompile(s,{encode:encodeURIComponent});return r+i(o||{})}catch{console.warn("createUrl","pathToRegexpCompile error",t)}}return t}createProxy(e,t,o){if(!e.proxy)return{url:t,headers:o};const r=e.proxyPath||ee,{protocol:s,host:i}=location||{},c=u.isUrl(t)?t:`${s}//${i}${t}`;return o.Target=c,{url:r,headers:o}}openLoading(e){const{loading:t,showLoading:o}=e;t&&o&&Object.keys(this.records).length>0&&(this.isLoading=!0,o())}closeLoading(e){const{hideLoading:t}=e;this.isLoading=!1;const o=Object.keys(this.records);t&&o.length===0&&(this.isLoading=!1,t())}_showError(e,t){const{failMessage:o,showError:r}=e;if(o&&r){const s=t?.response?.data,i=s?.message||s?.msg||t?.message||t?.msg||"未知错误";r(i,t)}}validResponse(e,t){const{validSuccess:o,validate:r}=e;return o&&r?!!r(t):!0}isSkipWarnResponse(e){return!!e.promise}send(e={},t=!1){const o=u.merge({},this.settings,e.settings||{}),r=e.query||{},s=u.omit(e,["settings","query"]),i=u.uuid(!1),c=E.CancelToken.source();this.records[i]={settings:o,config:s,source:c};const a=this.createUrl(s)||"",d=this.createHeaders(i,o,s),{url:l,headers:f}=this.createProxy(o,a,d),{data:g,params:v}=this.createSendData(o,s,f,t,r);return this.showLoading(o),new Promise((m,j)=>{this.axios({cancelToken:c.token,...s,url:l,headers:f,data:g,params:v}).then(p=>this.isSkipWarnResponse(p)?m(p.promise):this.validResponse(o,p)?m(o.originResponse?p:p.data?.data):(this.showError(o,p.data),j(p.data))).catch(p=>(this.showError(o,p),j(p))).finally(()=>{delete this.records[i],this.closeLoading(o)})})}useResponse(e,t){const{response:o}=this.axios.interceptors,r=o.use(e,t);return()=>o.eject(r)}useRequest(e,t){const{request:o}=this.axios.interceptors,r=o.use(e,t);return()=>o.eject(r)}setupSkipWarn(e){if(this.stopSkipWarn&&(this.stopSkipWarn(),this.stopSkipWarn=void 0),!e.skipWarn)return;const{code:t,executor:o,callback:r,complete:s}=e.skipWarn;this.stopSkipWarn=this.useResponse(i=>{const a=(i.config.headers||{})[L],d=this.records[a];if(!d)return i;const{data:l}=i;if(!l||typeof l!="object")return i;if(l?.code===t){r&&r(i);const f=new Promise(o).then(()=>this.send({...d.config,settings:d.settings},!0));f.catch(g=>g).finally(()=>{s&&s()}),i.promise=f}return i})}}function I(n={}){const e=new D(n),t=e.send.bind(e),o=e.cancel.bind(e),r=e.setConfig.bind(e),s=e.useRequest.bind(e),i=e.useResponse.bind(e);return Object.assign(t,{...e,instance:e,send:t,cancel:o,setConfig:r,useRequest:s,useResponse:i})}const k=I({settings:{injectHeaders:!0,loading:!0,originResponse:!0}});function J(n,e=k){const t=typeof n=="string"?{url:n}:n;return(o,r)=>e.send(u.merge({},t,r||{},{data:o}))}function te(n,e=k){const t={};for(const[o,r]of Object.entries(n))t[o]=J(r,e);return t}function ne(n,e){const t=R.ref(null),o=R.ref(),r=R.ref(!0),s=()=>{r.value=!0,o.value=void 0,(typeof n=="function"?n():n).then(c=>{t.value=e?e(c):c}).catch(c=>{o.value=c}).finally(()=>{r.value=!1})};return s(),{data:t,error:o,loading:r,reload:s}}const b=typeof window<"u",oe=n=>new Promise((e,t)=>{const o=new FileReader;o.readAsDataURL(n),o.onload=()=>{e(o.result)},o.onerror=r=>{t(r)}});function re(n){const e={};return n?(n.forEach((t,o)=>{e[o]=typeof t=="string"?decodeURIComponent(t):t}),e):{}}function se(n){const e=n.split(","),t=e[0].match(/:(.*?);/)?.[1],o=atob(e[1]);let r=o.length;const s=new Uint8Array(r);for(;r--;)s[r]=o.charCodeAt(r);return new Blob([s],{type:t})}function ie(n,e){const t=n;return t.lastModified=Date.now(),t.lastModifiedDate=new Date,t.name=e,t}const ce=n=>b?window.requestAnimationFrame(n):setTimeout(n,16),ae=n=>b?window.cancelAnimationFrame(n):clearTimeout(n);class q{constructor(e={}){h(this,"options",{type:"cache",expired:0,prefix:"__VTJ_"});h(this,"caches",{});h(this,"types");this.types={local:b?window.localStorage:this.caches,session:b?window.sessionStorage:this.caches,cache:this.caches},this.config(e)}config(e={}){this.options=Object.assign(this.options,e)}save(e,t,o={}){const{type:r,expired:s,prefix:i}={...this.options,...o},c=Date.now(),a=i+e,d=this.types[r]||this.caches,l={value:t,timestamp:c,expired:s};d===this.caches?d[a]=l:d.setItem(a,JSON.stringify(l))}get(e,t={}){const{type:o,prefix:r}={...this.options,...t},s=r+e,i=this.types[o]||this.caches;let c;if(i===this.caches)c=i[s];else{const g=i.getItem(s);if(g)try{c=JSON.parse(g)}catch(v){console.warn("[Storage] JSON.parse",v)}}if(!c)return null;const{value:a,timestamp:d,expired:l}=c;return l>0&&d+l<Date.now()?(this.remove(e,t),null):a}remove(e,t={}){const{type:o,prefix:r}={...this.options,...t},s=this.types[o]||this.caches,i=r+e;s===this.caches?delete s[i]:s.removeItem(i)}clear(e={}){const{type:t}={...this.options,...e},o=this.types[t]||this.caches;o===this.caches?this.caches={}:o.clear()}}const le=new q;function W(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var S={exports:{}},de=S.exports,U;function ue(){return U||(U=1,(function(n,e){(function(t,o){o(e,n)})(de,function(t,o){var r={timeout:5e3,jsonpCallback:"callback"};function s(){return"jsonp_"+Date.now()+"_"+Math.ceil(Math.random()*1e5)}function i(d){try{delete window[d]}catch{window[d]=void 0}}function c(d){var l=document.getElementById(d);l&&document.getElementsByTagName("head")[0].removeChild(l)}function a(d){var l=arguments.length<=1||arguments[1]===void 0?{}:arguments[1],f=d,g=l.timeout||r.timeout,v=l.jsonpCallback||r.jsonpCallback,m=void 0;return new Promise(function(j,p){var w=l.jsonpCallbackFunction||s(),O=v+"_"+w;window[w]=function(V){j({ok:!0,json:function(){return Promise.resolve(V)}}),m&&clearTimeout(m),c(O),i(w)},f+=f.indexOf("?")===-1?"?":"&";var y=document.createElement("script");y.setAttribute("src",""+f+v+"="+w),l.charset&&y.setAttribute("charset",l.charset),l.nonce&&y.setAttribute("nonce",l.nonce),l.referrerPolicy&&y.setAttribute("referrerPolicy",l.referrerPolicy),l.crossorigin&&y.setAttribute("crossorigin","true"),y.id=O,document.getElementsByTagName("head")[0].appendChild(y),m=setTimeout(function(){p(new Error("JSONP request to "+d+" timed out")),i(w),c(O),window[w]=function(){i(w)}},g),y.onerror=function(){p(new Error("JSONP request to "+d+" failed")),i(w),c(O),m&&clearTimeout(m)}})}o.exports=a})})(S,S.exports)),S.exports}var fe=ue();const pe=W(fe);function he(n){if(b){const{protocol:e,host:t,pathname:o}=location;return`${e}//${t}${n?o:""}`}else return null}function ge(n=""){const e=n.match(u.rURL);return e?e[0]:""}function B(n){const e=[];for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.push([t,encodeURIComponent(n[t])].join("="));return e.join("&")}function C(n,e,t){const o={};n=(n||location.search).replace(/^[^]*\?/,""),e=e||"&",t=t||"=";let r;const s=new RegExp("(?:^|\\"+e+")([^\\"+t+"\\"+e+"]+)(?:\\"+t+"([^\\"+e+"]*))?","g");for(;(r=s.exec(n))!==null;)r[1]!==n&&(o[decodeURIComponent(r[1])]=decodeURIComponent(r[2]||""));return o}function N(n,e){e=typeof e=="string"?C(e):e;const t=n.split("?")[0],o=C(n),r=Object.assign({},o,e),s=B(r);return s?[t,s].join("?"):n}const me=Object.freeze(Object.defineProperty({__proto__:null,append:N,getCurrentHost:he,getHost:ge,parse:C,stringify:B},Symbol.toStringTag,{value:"Module"}));async function we(n,e={}){const{query:t={}}=e;n.includes("${")&&(n=u.template(n)(t||{}));const o=N(n,t);return await(await pe(o,e)).json()}var _,F;function ye(){if(F)return _;F=1,_=function(r,s,i){var c=document.head||document.getElementsByTagName("head")[0],a=document.createElement("script");typeof s=="function"&&(i=s,s={}),s=s||{},i=i||function(){},a.type=s.type||"text/javascript",a.charset=s.charset||"utf8",a.async="async"in s?!!s.async:!0,a.src=r,s.attrs&&n(a,s.attrs),s.text&&(a.text=""+s.text);var d="onload"in a?e:t;d(a,i),a.onload||e(a,i),c.appendChild(a)};function n(o,r){for(var s in r)o.setAttribute(s,r[s])}function e(o,r){o.onload=function(){this.onerror=this.onload=null,r(null,o)},o.onerror=function(){this.onerror=this.onload=null,r(new Error("Failed to load "+this.src),o)}}function t(o,r){o.onreadystatechange=function(){this.readyState!="complete"&&this.readyState!="loaded"||(this.onreadystatechange=null,r(null,o))}}return _}var ve=ye();const be=W(ve);function Se(n,e={}){return new Promise((t,o)=>{const{library:r}=e;be(n,e,(s,i)=>{s?o(s):t(r?window[r]:void 0)})})}const M={debug:-1,log:0,info:0,warn:1,error:2},je=function(n,e,t,o){return function(...r){if(e&&M[e]<=M[n]&&console[n].apply&&(o==="*"||t.startsWith(o)))return console[n].apply(console,Oe(r,t))}};function Oe(n,e){return e!=="*"&&(typeof n[0]=="string"?n[0]=`[${e}] ${n[0]}`:n=["["+e+"]"].concat(n)),n}function xe(n,e){if(!n)return{targetLevel:e.level,targetBizName:e.bizName};if(~n.indexOf(":")){const t=n.split(":");return{targetLevel:t[0],targetBizName:t[1]}}return{targetLevel:n,targetBizName:"*"}}const Re={level:"warn",bizName:"*"};class ${constructor(e){h(this,"config");h(this,"options");this.options={...Re,...e};const t=typeof location<"u"?location:{},o=(/__(?:logConf|logLevel)__=([^#/&]*)/.exec(t.href)||[])[1];this.config=xe(o,e)}_log(e){const{targetLevel:t,targetBizName:o}=this.config,{bizName:r}=this.options;return je(e,t,r,o)}debug(...e){return this._log("debug")(...e)}log(...e){return this._log("log")(...e)}info(...e){return this._log("info")(...e)}warn(...e){return this._log("warn")(...e)}error(...e){return this._log("error")(...e)}}function H(n){return new $(n)}const _e=H({level:"log",bizName:"VTJ"});/*! js-cookie v3.0.8 | MIT */function x(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)o!=="__proto__"&&(n[o]=t[o])}return n}var Ee={read:function(n){return n[0]==='"'&&(n=n.slice(1,-1)),n.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(n){return encodeURIComponent(n).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function T(n,e){function t(r,s,i){if(!(typeof document>"u")){i=x({},e,i),typeof i.expires=="number"&&(i.expires=new Date(Date.now()+i.expires*864e5)),i.expires&&(i.expires=i.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var a in i)i[a]&&(c+="; "+a,i[a]!==!0&&(c+="="+i[a].split(";")[0]));return document.cookie=r+"="+n.write(s,r)+c}}function o(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var s=document.cookie?document.cookie.split("; "):[],i={},c=0;c<s.length;c++){var a=s[c].split("="),d=a.slice(1).join("=");try{var l=decodeURIComponent(a[0]);if(l in i||(i[l]=n.read(d,l)),r===l)break}catch{}}return r?i[r]:i}}return Object.create({set:t,get:o,remove:function(r,s){t(r,"",x({},s,{expires:-1}))},withAttributes:function(r){return T(this.converter,x({},this.attributes,r))},withConverter:function(r){return T(x({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(n)}})}var A=T(Ee,{path:"/"});function Le(n,e,t){A.set(n,e,t)}function Ce(n){return A.get(n)}function Te(n,e){A.remove(n,e)}const ke=Object.freeze(Object.defineProperty({__proto__:null,get:Ce,remove:Te,set:Le},Symbol.toStringTag,{value:"Module"}));function Ae(n,e=""){const t=document.createElement("a");t.download=e,t.href=n,t.target="_blank",t.click()}function P(n,e="",t){const o=new Blob([n],{type:t}),r=document.createElement("a");r.download=e,r.style.display="none",r.href=URL.createObjectURL(o),r.click(),URL.revokeObjectURL(r.href)}async function Pe(n,e="",t){return fetch(n,{credentials:"include"}).then(async o=>{const r=await o.blob();return P(r,e,t),r})}function Ue(n,e=""){const t=JSON.stringify(n);P(t,e,"application/json")}function Fe(){const n=navigator.userAgent;let e="Unknown",t="Unknown",o="Unknown",r="Unknown",s=!1;if(/Windows NT/i.test(n)){e="Windows";const c={"12.0":"12","11.0":"11","10.0":"10","6.3":"8.1","6.2":"8","6.1":"7","6.0":"Vista","5.2":"XP 64-bit","5.1":"XP"},a=n.match(/Windows NT (\d+\.\d+)/);a&&(t=c[a[1]]||a[1])}else if(/Mac OS X/i.test(n)){e="Mac OS";const c=n.match(/Mac OS X (\d+[._]\d+[._]?\d*)/);c&&(t=c[1].replace(/_/g,"."))}else if(/(iPhone|iPad|iPod)/i.test(n)){e="iOS";const c=n.match(/OS (\d+[_\.]\d+[_\.]?\d*)/);c&&(t=c[1].replace(/_/g,"."))}else if(/Android/i.test(n)){e="Android";const c=n.match(/Android (\d+\.\d+)/);c&&(t=c[1])}else/Linux/i.test(n)&&(e="Linux");const i=n.match(/(Edge|Edg|Edga|EdgA)\/(\d+)/i);if(i)o="Microsoft Edge",r=i[2];else{const c=n.match(/Firefox\/(\d+)/i);if(c)o="Firefox",r=c[1];else{const a=n.match(/(Opera|OPR)\/(\d+)/i);if(a)o="Opera",r=a[2];else{const d=n.match(/Chrome\/(\d+)/i);if(d)o="Chrome",r=d[1];else{const l=n.match(/Version\/(\d+\.\d+)/i);if(l&&/Safari/i.test(n))o="Safari",r=l[1];else{const f=n.match(/(MSIE |Trident.*rv:)(\d+)/i);f&&(o="Internet Explorer",r=f[2])}}}}}return s=/(iPhone|iPod|iPad|Android|Windows Phone|Mobile)/i.test(n)||["iOS","Android"].includes(e),/(iPad|Tablet|Android(?!.*Mobile))/i.test(n)&&(s=!0),{os:e,osVersion:t,browser:o,browserVersion:r,isMobile:s}}exports.axios=E;exports.LOCAL_REQUEST_ID=L;exports.Logger=$;exports.Request=D;exports.Storage=q;exports.VTJ_UTILS_VERSION=Q;exports.blobToFile=ie;exports.cAF=ae;exports.cookie=ke;exports.createApi=J;exports.createApis=te;exports.createRequest=I;exports.dataURLtoBlob=se;exports.downloadBlob=P;exports.downloadJson=Ue;exports.downloadRemoteFile=Pe;exports.downloadUrl=Ae;exports.fileToBase64=oe;exports.formDataToJson=re;exports.getClientInfo=Fe;exports.getLogger=H;exports.isClient=b;exports.jsonp=we;exports.loadScript=Se;exports.logger=_e;exports.rAF=ce;exports.request=k;exports.storage=le;exports.url=me;exports.useApi=ne;Object.keys(u).forEach(n=>{n!=="default"&&!Object.prototype.hasOwnProperty.call(exports,n)&&Object.defineProperty(exports,n,{enumerable:!0,get:()=>u[n]})});
7
+ */const Q="0.18.11",Y={form:"application/x-www-form-urlencoded",json:"application/json",data:"multipart/form-data"},K=["put","post","patch"],L="Local-Request-Id",G=100,Z=300,ee="/api/proxy";class D{constructor(e={}){h(this,"axios");h(this,"settings");h(this,"records",{});h(this,"isLoading",!1);h(this,"stopSkipWarn");h(this,"showLoading");h(this,"showError");this.settings=Object.assign({type:"form"},e.settings||{});const t=u.omit(e,["settings","query"]);this.axios=E.create(u.merge({headers:{"Content-Type":"application/x-www-form-urlencoded"},timeout:120*1e3},t)),this.setupSkipWarn(this.settings),this.showLoading=u.debounce(this.openLoading.bind(this),G),this.showError=u.throttle(this._showError.bind(this),Z,{leading:!0,trailing:!1})}setConfig(e={}){this.settings=u.merge(this.settings,e.settings||{});const t=u.omit(e,["settings","query"]);this.axios.defaults=u.merge(this.axios.defaults,t),this.setupSkipWarn(this.settings)}cancel(e,t="请求已取消"){if(e){const o=this.records[e];if(!o)return;o.source.cancel(t)}else for(const o of Object.values(this.records))o.source.cancel(t)}createHeaders(e,t,o){const r=t.injectHeaders?typeof t.headers=="function"?t.headers(e,o,t):t.headers||{}:{},s={"Content-Type":Y[t.type||"form"],...o.headers,...r};return t.skipWarn&&(s[L]=e),s}isJsonType(e){return Object.entries(e).some(([t,o])=>t.toLowerCase()==="content-type"&&String(o).includes("application/json"))}toFormData(e,t="data"){if(e instanceof FormData||e instanceof URLSearchParams)return e;const o=t==="data"?new FormData:new URLSearchParams;return Object.entries(e).forEach(([r,s])=>{o.append(r,s)}),o}createSendData(e,t,o,r,s={}){const{type:i,skipWarn:c}=e,{name:a="skipWarn"}=c||{};let{data:d,params:l={},method:f="get"}=t;const g=r?{[a]:!0}:{};return K.includes(f.toLowerCase())?(d=Object.assign(d||{},g),d=i!=="json"||!this.isJsonType(o)?this.toFormData(d,i):d,l={...s}):i==="form"?l={...d||{},...s,...g}:(d&&(i!=="json"||!this.isJsonType(o))&&(d=this.toFormData(d,i)),l={...s,...g}),{data:d,params:l}}createUrl(e){let{url:t,params:o}=e;if(t){let r=u.isUrl(t)?new URL(t).origin:"";const s=r?t.replace(r,""):t;try{const i=u.pathToRegexpCompile(s,{encode:encodeURIComponent});return r+i(o||{})}catch{console.warn("createUrl","pathToRegexpCompile error",t)}}return t}createProxy(e,t,o){if(!e.proxy)return{url:t,headers:o};const r=e.proxyPath||ee,{protocol:s,host:i}=location||{},c=u.isUrl(t)?t:`${s}//${i}${t}`;return o.Target=c,{url:r,headers:o}}openLoading(e){const{loading:t,showLoading:o}=e;t&&o&&Object.keys(this.records).length>0&&(this.isLoading=!0,o())}closeLoading(e){const{hideLoading:t}=e;this.isLoading=!1;const o=Object.keys(this.records);t&&o.length===0&&(this.isLoading=!1,t())}_showError(e,t){const{failMessage:o,showError:r}=e;if(o&&r){const s=t?.response?.data,i=s?.message||s?.msg||t?.message||t?.msg||"未知错误";r(i,t)}}validResponse(e,t){const{validSuccess:o,validate:r}=e;return o&&r?!!r(t):!0}isSkipWarnResponse(e){return!!e.promise}send(e={},t=!1){const o=u.merge({},this.settings,e.settings||{}),r=e.query||{},s=u.omit(e,["settings","query"]),i=u.uuid(!1),c=E.CancelToken.source();this.records[i]={settings:o,config:s,source:c};const a=this.createUrl(s)||"",d=this.createHeaders(i,o,s),{url:l,headers:f}=this.createProxy(o,a,d),{data:g,params:v}=this.createSendData(o,s,f,t,r);return this.showLoading(o),new Promise((m,j)=>{this.axios({cancelToken:c.token,...s,url:l,headers:f,data:g,params:v}).then(p=>this.isSkipWarnResponse(p)?m(p.promise):this.validResponse(o,p)?m(o.originResponse?p:p.data?.data):(this.showError(o,p.data),j(p.data))).catch(p=>(this.showError(o,p),j(p))).finally(()=>{delete this.records[i],this.closeLoading(o)})})}useResponse(e,t){const{response:o}=this.axios.interceptors,r=o.use(e,t);return()=>o.eject(r)}useRequest(e,t){const{request:o}=this.axios.interceptors,r=o.use(e,t);return()=>o.eject(r)}setupSkipWarn(e){if(this.stopSkipWarn&&(this.stopSkipWarn(),this.stopSkipWarn=void 0),!e.skipWarn)return;const{code:t,executor:o,callback:r,complete:s}=e.skipWarn;this.stopSkipWarn=this.useResponse(i=>{const a=(i.config.headers||{})[L],d=this.records[a];if(!d)return i;const{data:l}=i;if(!l||typeof l!="object")return i;if(l?.code===t){r&&r(i);const f=new Promise(o).then(()=>this.send({...d.config,settings:d.settings},!0));f.catch(g=>g).finally(()=>{s&&s()}),i.promise=f}return i})}}function I(n={}){const e=new D(n),t=e.send.bind(e),o=e.cancel.bind(e),r=e.setConfig.bind(e),s=e.useRequest.bind(e),i=e.useResponse.bind(e);return Object.assign(t,{...e,instance:e,send:t,cancel:o,setConfig:r,useRequest:s,useResponse:i})}const k=I({settings:{injectHeaders:!0,loading:!0,originResponse:!0}});function J(n,e=k){const t=typeof n=="string"?{url:n}:n;return(o,r)=>e.send(u.merge({},t,r||{},{data:o}))}function te(n,e=k){const t={};for(const[o,r]of Object.entries(n))t[o]=J(r,e);return t}function ne(n,e){const t=R.ref(null),o=R.ref(),r=R.ref(!0),s=()=>{r.value=!0,o.value=void 0,(typeof n=="function"?n():n).then(c=>{t.value=e?e(c):c}).catch(c=>{o.value=c}).finally(()=>{r.value=!1})};return s(),{data:t,error:o,loading:r,reload:s}}const b=typeof window<"u",oe=n=>new Promise((e,t)=>{const o=new FileReader;o.readAsDataURL(n),o.onload=()=>{e(o.result)},o.onerror=r=>{t(r)}});function re(n){const e={};return n?(n.forEach((t,o)=>{e[o]=typeof t=="string"?decodeURIComponent(t):t}),e):{}}function se(n){const e=n.split(","),t=e[0].match(/:(.*?);/)?.[1],o=atob(e[1]);let r=o.length;const s=new Uint8Array(r);for(;r--;)s[r]=o.charCodeAt(r);return new Blob([s],{type:t})}function ie(n,e){const t=n;return t.lastModified=Date.now(),t.lastModifiedDate=new Date,t.name=e,t}const ce=n=>b?window.requestAnimationFrame(n):setTimeout(n,16),ae=n=>b?window.cancelAnimationFrame(n):clearTimeout(n);class q{constructor(e={}){h(this,"options",{type:"cache",expired:0,prefix:"__VTJ_"});h(this,"caches",{});h(this,"types");this.types={local:b?window.localStorage:this.caches,session:b?window.sessionStorage:this.caches,cache:this.caches},this.config(e)}config(e={}){this.options=Object.assign(this.options,e)}save(e,t,o={}){const{type:r,expired:s,prefix:i}={...this.options,...o},c=Date.now(),a=i+e,d=this.types[r]||this.caches,l={value:t,timestamp:c,expired:s};d===this.caches?d[a]=l:d.setItem(a,JSON.stringify(l))}get(e,t={}){const{type:o,prefix:r}={...this.options,...t},s=r+e,i=this.types[o]||this.caches;let c;if(i===this.caches)c=i[s];else{const g=i.getItem(s);if(g)try{c=JSON.parse(g)}catch(v){console.warn("[Storage] JSON.parse",v)}}if(!c)return null;const{value:a,timestamp:d,expired:l}=c;return l>0&&d+l<Date.now()?(this.remove(e,t),null):a}remove(e,t={}){const{type:o,prefix:r}={...this.options,...t},s=this.types[o]||this.caches,i=r+e;s===this.caches?delete s[i]:s.removeItem(i)}clear(e={}){const{type:t}={...this.options,...e},o=this.types[t]||this.caches;o===this.caches?this.caches={}:o.clear()}}const le=new q;function W(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var S={exports:{}},de=S.exports,U;function ue(){return U||(U=1,(function(n,e){(function(t,o){o(e,n)})(de,function(t,o){var r={timeout:5e3,jsonpCallback:"callback"};function s(){return"jsonp_"+Date.now()+"_"+Math.ceil(Math.random()*1e5)}function i(d){try{delete window[d]}catch{window[d]=void 0}}function c(d){var l=document.getElementById(d);l&&document.getElementsByTagName("head")[0].removeChild(l)}function a(d){var l=arguments.length<=1||arguments[1]===void 0?{}:arguments[1],f=d,g=l.timeout||r.timeout,v=l.jsonpCallback||r.jsonpCallback,m=void 0;return new Promise(function(j,p){var w=l.jsonpCallbackFunction||s(),O=v+"_"+w;window[w]=function(V){j({ok:!0,json:function(){return Promise.resolve(V)}}),m&&clearTimeout(m),c(O),i(w)},f+=f.indexOf("?")===-1?"?":"&";var y=document.createElement("script");y.setAttribute("src",""+f+v+"="+w),l.charset&&y.setAttribute("charset",l.charset),l.nonce&&y.setAttribute("nonce",l.nonce),l.referrerPolicy&&y.setAttribute("referrerPolicy",l.referrerPolicy),l.crossorigin&&y.setAttribute("crossorigin","true"),y.id=O,document.getElementsByTagName("head")[0].appendChild(y),m=setTimeout(function(){p(new Error("JSONP request to "+d+" timed out")),i(w),c(O),window[w]=function(){i(w)}},g),y.onerror=function(){p(new Error("JSONP request to "+d+" failed")),i(w),c(O),m&&clearTimeout(m)}})}o.exports=a})})(S,S.exports)),S.exports}var fe=ue();const pe=W(fe);function he(n){if(b){const{protocol:e,host:t,pathname:o}=location;return`${e}//${t}${n?o:""}`}else return null}function ge(n=""){const e=n.match(u.rURL);return e?e[0]:""}function B(n){const e=[];for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e.push([t,encodeURIComponent(n[t])].join("="));return e.join("&")}function C(n,e,t){const o={};n=(n||location.search).replace(/^[^]*\?/,""),e=e||"&",t=t||"=";let r;const s=new RegExp("(?:^|\\"+e+")([^\\"+t+"\\"+e+"]+)(?:\\"+t+"([^\\"+e+"]*))?","g");for(;(r=s.exec(n))!==null;)r[1]!==n&&(o[decodeURIComponent(r[1])]=decodeURIComponent(r[2]||""));return o}function N(n,e){e=typeof e=="string"?C(e):e;const t=n.split("?")[0],o=C(n),r=Object.assign({},o,e),s=B(r);return s?[t,s].join("?"):n}const me=Object.freeze(Object.defineProperty({__proto__:null,append:N,getCurrentHost:he,getHost:ge,parse:C,stringify:B},Symbol.toStringTag,{value:"Module"}));async function we(n,e={}){const{query:t={}}=e;n.includes("${")&&(n=u.template(n)(t||{}));const o=N(n,t);return await(await pe(o,e)).json()}var _,F;function ye(){if(F)return _;F=1,_=function(r,s,i){var c=document.head||document.getElementsByTagName("head")[0],a=document.createElement("script");typeof s=="function"&&(i=s,s={}),s=s||{},i=i||function(){},a.type=s.type||"text/javascript",a.charset=s.charset||"utf8",a.async="async"in s?!!s.async:!0,a.src=r,s.attrs&&n(a,s.attrs),s.text&&(a.text=""+s.text);var d="onload"in a?e:t;d(a,i),a.onload||e(a,i),c.appendChild(a)};function n(o,r){for(var s in r)o.setAttribute(s,r[s])}function e(o,r){o.onload=function(){this.onerror=this.onload=null,r(null,o)},o.onerror=function(){this.onerror=this.onload=null,r(new Error("Failed to load "+this.src),o)}}function t(o,r){o.onreadystatechange=function(){this.readyState!="complete"&&this.readyState!="loaded"||(this.onreadystatechange=null,r(null,o))}}return _}var ve=ye();const be=W(ve);function Se(n,e={}){return new Promise((t,o)=>{const{library:r}=e;be(n,e,(s,i)=>{s?o(s):t(r?window[r]:void 0)})})}const M={debug:-1,log:0,info:0,warn:1,error:2},je=function(n,e,t,o){return function(...r){if(e&&M[e]<=M[n]&&console[n].apply&&(o==="*"||t.startsWith(o)))return console[n].apply(console,Oe(r,t))}};function Oe(n,e){return e!=="*"&&(typeof n[0]=="string"?n[0]=`[${e}] ${n[0]}`:n=["["+e+"]"].concat(n)),n}function xe(n,e){if(!n)return{targetLevel:e.level,targetBizName:e.bizName};if(~n.indexOf(":")){const t=n.split(":");return{targetLevel:t[0],targetBizName:t[1]}}return{targetLevel:n,targetBizName:"*"}}const Re={level:"warn",bizName:"*"};class ${constructor(e){h(this,"config");h(this,"options");this.options={...Re,...e};const t=typeof location<"u"?location:{},o=(/__(?:logConf|logLevel)__=([^#/&]*)/.exec(t.href)||[])[1];this.config=xe(o,e)}_log(e){const{targetLevel:t,targetBizName:o}=this.config,{bizName:r}=this.options;return je(e,t,r,o)}debug(...e){return this._log("debug")(...e)}log(...e){return this._log("log")(...e)}info(...e){return this._log("info")(...e)}warn(...e){return this._log("warn")(...e)}error(...e){return this._log("error")(...e)}}function H(n){return new $(n)}const _e=H({level:"log",bizName:"VTJ"});/*! js-cookie v3.0.8 | MIT */function x(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var o in t)o!=="__proto__"&&(n[o]=t[o])}return n}var Ee={read:function(n){return n[0]==='"'&&(n=n.slice(1,-1)),n.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(n){return encodeURIComponent(n).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function T(n,e){function t(r,s,i){if(!(typeof document>"u")){i=x({},e,i),typeof i.expires=="number"&&(i.expires=new Date(Date.now()+i.expires*864e5)),i.expires&&(i.expires=i.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var a in i)i[a]&&(c+="; "+a,i[a]!==!0&&(c+="="+i[a].split(";")[0]));return document.cookie=r+"="+n.write(s,r)+c}}function o(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var s=document.cookie?document.cookie.split("; "):[],i={},c=0;c<s.length;c++){var a=s[c].split("="),d=a.slice(1).join("=");try{var l=decodeURIComponent(a[0]);if(l in i||(i[l]=n.read(d,l)),r===l)break}catch{}}return r?i[r]:i}}return Object.create({set:t,get:o,remove:function(r,s){t(r,"",x({},s,{expires:-1}))},withAttributes:function(r){return T(this.converter,x({},this.attributes,r))},withConverter:function(r){return T(x({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(n)}})}var A=T(Ee,{path:"/"});function Le(n,e,t){A.set(n,e,t)}function Ce(n){return A.get(n)}function Te(n,e){A.remove(n,e)}const ke=Object.freeze(Object.defineProperty({__proto__:null,get:Ce,remove:Te,set:Le},Symbol.toStringTag,{value:"Module"}));function Ae(n,e=""){const t=document.createElement("a");t.download=e,t.href=n,t.target="_blank",t.click()}function P(n,e="",t){const o=new Blob([n],{type:t}),r=document.createElement("a");r.download=e,r.style.display="none",r.href=URL.createObjectURL(o),r.click(),URL.revokeObjectURL(r.href)}async function Pe(n,e="",t){return fetch(n,{credentials:"include"}).then(async o=>{const r=await o.blob();return P(r,e,t),r})}function Ue(n,e=""){const t=JSON.stringify(n);P(t,e,"application/json")}function Fe(){const n=navigator.userAgent;let e="Unknown",t="Unknown",o="Unknown",r="Unknown",s=!1;if(/Windows NT/i.test(n)){e="Windows";const c={"12.0":"12","11.0":"11","10.0":"10","6.3":"8.1","6.2":"8","6.1":"7","6.0":"Vista","5.2":"XP 64-bit","5.1":"XP"},a=n.match(/Windows NT (\d+\.\d+)/);a&&(t=c[a[1]]||a[1])}else if(/Mac OS X/i.test(n)){e="Mac OS";const c=n.match(/Mac OS X (\d+[._]\d+[._]?\d*)/);c&&(t=c[1].replace(/_/g,"."))}else if(/(iPhone|iPad|iPod)/i.test(n)){e="iOS";const c=n.match(/OS (\d+[_\.]\d+[_\.]?\d*)/);c&&(t=c[1].replace(/_/g,"."))}else if(/Android/i.test(n)){e="Android";const c=n.match(/Android (\d+\.\d+)/);c&&(t=c[1])}else/Linux/i.test(n)&&(e="Linux");const i=n.match(/(Edge|Edg|Edga|EdgA)\/(\d+)/i);if(i)o="Microsoft Edge",r=i[2];else{const c=n.match(/Firefox\/(\d+)/i);if(c)o="Firefox",r=c[1];else{const a=n.match(/(Opera|OPR)\/(\d+)/i);if(a)o="Opera",r=a[2];else{const d=n.match(/Chrome\/(\d+)/i);if(d)o="Chrome",r=d[1];else{const l=n.match(/Version\/(\d+\.\d+)/i);if(l&&/Safari/i.test(n))o="Safari",r=l[1];else{const f=n.match(/(MSIE |Trident.*rv:)(\d+)/i);f&&(o="Internet Explorer",r=f[2])}}}}}return s=/(iPhone|iPod|iPad|Android|Windows Phone|Mobile)/i.test(n)||["iOS","Android"].includes(e),/(iPad|Tablet|Android(?!.*Mobile))/i.test(n)&&(s=!0),{os:e,osVersion:t,browser:o,browserVersion:r,isMobile:s}}exports.axios=E;exports.LOCAL_REQUEST_ID=L;exports.Logger=$;exports.Request=D;exports.Storage=q;exports.VTJ_UTILS_VERSION=Q;exports.blobToFile=ie;exports.cAF=ae;exports.cookie=ke;exports.createApi=J;exports.createApis=te;exports.createRequest=I;exports.dataURLtoBlob=se;exports.downloadBlob=P;exports.downloadJson=Ue;exports.downloadRemoteFile=Pe;exports.downloadUrl=Ae;exports.fileToBase64=oe;exports.formDataToJson=re;exports.getClientInfo=Fe;exports.getLogger=H;exports.isClient=b;exports.jsonp=we;exports.loadScript=Se;exports.logger=_e;exports.rAF=ce;exports.request=k;exports.storage=le;exports.url=me;exports.useApi=ne;Object.keys(u).forEach(n=>{n!=="default"&&!Object.prototype.hasOwnProperty.call(exports,n)&&Object.defineProperty(exports,n,{enumerable:!0,get:()=>u[n]})});