frappe-react-sdk
Version:
React hooks for Frappe Framework
23 lines • 124 kB
JavaScript
(function(N,ye){typeof exports=="object"&&typeof module<"u"?ye(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],ye):(N=typeof globalThis<"u"?globalThis:N||self,ye(N["Frappe React"]={},N.jsxRuntime,N.React))})(this,function(N,ye,E){"use strict";var fa=Object.defineProperty;var ha=(N,ye,E)=>ye in N?fa(N,ye,{enumerable:!0,configurable:!0,writable:!0,value:E}):N[ye]=E;var Je=(N,ye,E)=>ha(N,typeof ye!="symbol"?ye+"":ye,E);var Or=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ke={},ct={},Ee={},Jn;function Kn(){if(Jn)return Ee;Jn=1;var t=Ee&&Ee.__assign||function(){return t=Object.assign||function(a){for(var c,o=1,d=arguments.length;o<d;o++){c=arguments[o];for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&(a[h]=c[h])}return a},t.apply(this,arguments)},e=Ee&&Ee.__awaiter||function(a,c,o,d){function h(u){return u instanceof o?u:new o(function(m){m(u)})}return new(o||(o=Promise))(function(u,m){function b(_){try{p(d.next(_))}catch(O){m(O)}}function S(_){try{p(d.throw(_))}catch(O){m(O)}}function p(_){_.done?u(_.value):h(_.value).then(b,S)}p((d=d.apply(a,c||[])).next())})},n=Ee&&Ee.__generator||function(a,c){var o={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},d,h,u,m;return m={next:b(0),throw:b(1),return:b(2)},typeof Symbol=="function"&&(m[Symbol.iterator]=function(){return this}),m;function b(p){return function(_){return S([p,_])}}function S(p){if(d)throw new TypeError("Generator is already executing.");for(;m&&(m=0,p[0]&&(o=0)),o;)try{if(d=1,h&&(u=p[0]&2?h.return:p[0]?h.throw||((u=h.return)&&u.call(h),0):h.next)&&!(u=u.call(h,p[1])).done)return u;switch(h=0,u&&(p=[p[0]&2,u.value]),p[0]){case 0:case 1:u=p;break;case 4:return o.label++,{value:p[1],done:!1};case 5:o.label++,h=p[1],p=[0];continue;case 7:p=o.ops.pop(),o.trys.pop();continue;default:if(u=o.trys,!(u=u.length>0&&u[u.length-1])&&(p[0]===6||p[0]===2)){o=0;continue}if(p[0]===3&&(!u||p[1]>u[0]&&p[1]<u[3])){o.label=p[1];break}if(p[0]===6&&o.label<u[1]){o.label=u[1],u=p;break}if(u&&o.label<u[2]){o.label=u[2],o.ops.push(p);break}u[2]&&o.ops.pop(),o.trys.pop();continue}p=c.call(a,o)}catch(_){p=[6,_],h=0}finally{d=u=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}};Object.defineProperty(Ee,"__esModule",{value:!0}),Ee.FrappeCall=void 0;var s=function(){function a(c,o,d,h,u){this.appURL=c,this.axios=o,this.useToken=d??!1,this.token=h,this.tokenType=u}return a.prototype.get=function(c,o){return e(this,void 0,void 0,function(){var d;return n(this,function(h){return d=new URLSearchParams,o&&Object.entries(o).forEach(function(u){var m=u[0],b=u[1];if(b!=null){var S=typeof b=="object"?JSON.stringify(b):b;d.set(m,S)}}),[2,this.axios.get("/api/method/".concat(c),{params:d}).then(function(u){return u.data}).catch(function(u){var m,b;throw t(t({},u.response.data),{httpStatus:u.response.status,httpStatusText:u.response.statusText,message:(m=u.response.data.message)!==null&&m!==void 0?m:"There was an error.",exception:(b=u.response.data.exception)!==null&&b!==void 0?b:""})})]})})},a.prototype.post=function(c,o){return e(this,void 0,void 0,function(){return n(this,function(d){return[2,this.axios.post("/api/method/".concat(c),t({},o)).then(function(h){return h.data}).catch(function(h){var u,m;throw t(t({},h.response.data),{httpStatus:h.response.status,httpStatusText:h.response.statusText,message:(u=h.response.data.message)!==null&&u!==void 0?u:"There was an error.",exception:(m=h.response.data.exception)!==null&&m!==void 0?m:""})})]})})},a.prototype.put=function(c,o){return e(this,void 0,void 0,function(){return n(this,function(d){return[2,this.axios.put("/api/method/".concat(c),t({},o)).then(function(h){return h.data}).catch(function(h){var u,m;throw t(t({},h.response.data),{httpStatus:h.response.status,httpStatusText:h.response.statusText,message:(u=h.response.data.message)!==null&&u!==void 0?u:"There was an error.",exception:(m=h.response.data.exception)!==null&&m!==void 0?m:""})})]})})},a.prototype.delete=function(c,o){return e(this,void 0,void 0,function(){return n(this,function(d){return[2,this.axios.delete("/api/method/".concat(c),{params:o}).then(function(h){return h.data}).catch(function(h){var u,m;throw t(t({},h.response.data),{httpStatus:h.response.status,httpStatusText:h.response.statusText,message:(u=h.response.data.message)!==null&&u!==void 0?u:"There was an error.",exception:(m=h.response.data.exception)!==null&&m!==void 0?m:""})})]})})},a}();return Ee.FrappeCall=s,Ee}var Te={},Gn;function Xn(){if(Gn)return Te;Gn=1;var t=Te&&Te.__assign||function(){return t=Object.assign||function(a){for(var c,o=1,d=arguments.length;o<d;o++){c=arguments[o];for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&(a[h]=c[h])}return a},t.apply(this,arguments)},e=Te&&Te.__awaiter||function(a,c,o,d){function h(u){return u instanceof o?u:new o(function(m){m(u)})}return new(o||(o=Promise))(function(u,m){function b(_){try{p(d.next(_))}catch(O){m(O)}}function S(_){try{p(d.throw(_))}catch(O){m(O)}}function p(_){_.done?u(_.value):h(_.value).then(b,S)}p((d=d.apply(a,c||[])).next())})},n=Te&&Te.__generator||function(a,c){var o={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},d,h,u,m;return m={next:b(0),throw:b(1),return:b(2)},typeof Symbol=="function"&&(m[Symbol.iterator]=function(){return this}),m;function b(p){return function(_){return S([p,_])}}function S(p){if(d)throw new TypeError("Generator is already executing.");for(;m&&(m=0,p[0]&&(o=0)),o;)try{if(d=1,h&&(u=p[0]&2?h.return:p[0]?h.throw||((u=h.return)&&u.call(h),0):h.next)&&!(u=u.call(h,p[1])).done)return u;switch(h=0,u&&(p=[p[0]&2,u.value]),p[0]){case 0:case 1:u=p;break;case 4:return o.label++,{value:p[1],done:!1};case 5:o.label++,h=p[1],p=[0];continue;case 7:p=o.ops.pop(),o.trys.pop();continue;default:if(u=o.trys,!(u=u.length>0&&u[u.length-1])&&(p[0]===6||p[0]===2)){o=0;continue}if(p[0]===3&&(!u||p[1]>u[0]&&p[1]<u[3])){o.label=p[1];break}if(p[0]===6&&o.label<u[1]){o.label=u[1],u=p;break}if(u&&o.label<u[2]){o.label=u[2],o.ops.push(p);break}u[2]&&o.ops.pop(),o.trys.pop();continue}p=c.call(a,o)}catch(_){p=[6,_],h=0}finally{d=u=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}};Object.defineProperty(Te,"__esModule",{value:!0}),Te.FrappeDB=void 0;var s=function(){function a(c,o,d,h,u){this.appURL=c,this.axios=o,this.useToken=d??!1,this.token=h,this.tokenType=u}return a.prototype.getDoc=function(c,o){return o===void 0&&(o=""),e(this,void 0,void 0,function(){return n(this,function(d){return[2,this.axios.get("/api/resource/".concat(c,"/").concat(encodeURIComponent(o))).then(function(h){return h.data.data}).catch(function(h){var u,m;throw t(t({},h.response.data),{httpStatus:h.response.status,httpStatusText:h.response.statusText,message:"There was an error while fetching the document.",exception:(m=(u=h.response.data.exception)!==null&&u!==void 0?u:h.response.data.exc_type)!==null&&m!==void 0?m:""})})]})})},a.prototype.getDocList=function(c,o){var d;return e(this,void 0,void 0,function(){var h,u,m,b,S,p,_,O,j,R,Y;return n(this,function(z){return h={},o&&(u=o.fields,m=o.filters,b=o.orFilters,S=o.orderBy,p=o.limit,_=o.limit_start,O=o.groupBy,j=o.asDict,R=j===void 0?!0:j,Y=S?"".concat(String(S==null?void 0:S.field)," ").concat((d=S==null?void 0:S.order)!==null&&d!==void 0?d:"asc"):"",h={fields:u?JSON.stringify(u):void 0,filters:m?JSON.stringify(m):void 0,or_filters:b?JSON.stringify(b):void 0,order_by:Y,group_by:O,limit:p,limit_start:_,as_dict:R}),[2,this.axios.get("/api/resource/".concat(c),{params:h}).then(function(H){return H.data.data}).catch(function(H){var I,J;throw t(t({},H.response.data),{httpStatus:H.response.status,httpStatusText:H.response.statusText,message:"There was an error while fetching the documents.",exception:(J=(I=H.response.data.exception)!==null&&I!==void 0?I:H.response.data.exc_type)!==null&&J!==void 0?J:""})})]})})},a.prototype.createDoc=function(c,o){return e(this,void 0,void 0,function(){return n(this,function(d){return[2,this.axios.post("/api/resource/".concat(c),t({},o)).then(function(h){return h.data.data}).catch(function(h){var u,m,b;throw t(t({},h.response.data),{httpStatus:h.response.status,httpStatusText:h.response.statusText,message:(u=h.response.data.message)!==null&&u!==void 0?u:"There was an error while creating the document.",exception:(b=(m=h.response.data.exception)!==null&&m!==void 0?m:h.response.data.exc_type)!==null&&b!==void 0?b:""})})]})})},a.prototype.updateDoc=function(c,o,d){return e(this,void 0,void 0,function(){return n(this,function(h){return[2,this.axios.put("/api/resource/".concat(c,"/").concat(o&&encodeURIComponent(o)),t({},d)).then(function(u){return u.data.data}).catch(function(u){var m,b,S;throw t(t({},u.response.data),{httpStatus:u.response.status,httpStatusText:u.response.statusText,message:(m=u.response.data.message)!==null&&m!==void 0?m:"There was an error while updating the document.",exception:(S=(b=u.response.data.exception)!==null&&b!==void 0?b:u.response.data.exc_type)!==null&&S!==void 0?S:""})})]})})},a.prototype.deleteDoc=function(c,o){return e(this,void 0,void 0,function(){return n(this,function(d){return[2,this.axios.delete("/api/resource/".concat(c,"/").concat(o&&encodeURIComponent(o))).then(function(h){return h.data}).catch(function(h){var u,m;throw t(t({},h.response.data),{httpStatus:h.response.status,httpStatusText:h.response.statusText,message:"There was an error while deleting the document.",exception:(m=(u=h.response.data.exception)!==null&&u!==void 0?u:h.response.data.exc_type)!==null&&m!==void 0?m:""})})]})})},a.prototype.getCount=function(c,o,d,h){return d===void 0&&(d=!1),h===void 0&&(h=!1),e(this,void 0,void 0,function(){var u;return n(this,function(m){return u={doctype:c,filters:[]},d&&(u.cache=d),h&&(u.debug=h),o&&(u.filters=o?JSON.stringify(o):void 0),[2,this.axios.get("/api/method/frappe.client.get_count",{params:u}).then(function(b){return b.data.message}).catch(function(b){var S,p;throw t(t({},b.response.data),{httpStatus:b.response.status,httpStatusText:b.response.statusText,message:"There was an error while getting the count.",exception:(p=(S=b.response.data.exception)!==null&&S!==void 0?S:b.response.data.exc_type)!==null&&p!==void 0?p:""})})]})})},a.prototype.getLastDoc=function(c,o){return e(this,void 0,void 0,function(){var d,h;return n(this,function(u){switch(u.label){case 0:return d={orderBy:{field:"creation",order:"desc"}},o&&(d=t(t({},d),o)),[4,this.getDocList(c,t(t({},d),{limit:1,fields:["name"]}))];case 1:return h=u.sent(),h.length>0?[2,this.getDoc(c,h[0].name)]:[2,{}]}})})},a.prototype.renameDoc=function(c,o,d,h){return h===void 0&&(h=!1),e(this,void 0,void 0,function(){return n(this,function(u){return[2,this.axios.post("/api/method/frappe.client.rename_doc",{doctype:c,old_name:o,new_name:d,merge:h}).then(function(m){return m.data}).catch(function(m){var b,S,p;throw t(t({},m.response.data),{httpStatus:m.response.status,httpStatusText:m.response.statusText,message:(b=m.response.data.message)!==null&&b!==void 0?b:"There was an error while renaming the document.",exception:(p=(S=m.response.data.exception)!==null&&S!==void 0?S:m.response.data.exc_type)!==null&&p!==void 0?p:""})})]})})},a.prototype.getValue=function(c,o,d,h,u,m){return h===void 0&&(h=!0),u===void 0&&(u=!1),m===void 0&&(m=null),e(this,void 0,void 0,function(){var b;return n(this,function(S){return b={doctype:c,fieldname:"[]",filters:[],as_dict:h,debug:u,parent:null},o&&(b.fieldname=typeof o=="object"?JSON.stringify(o):o),d&&(b.filters=d?JSON.stringify(d):void 0),m&&(b.parent=m),[2,this.axios.get("/api/method/frappe.client.get_value",{params:b}).then(function(p){return p.data}).catch(function(p){var _,O;throw t(t({},p.response.data),{httpStatus:p.response.status,httpStatusText:p.response.statusText,message:"There was an error while getting the value.",exception:(O=(_=p.response.data.exception)!==null&&_!==void 0?_:p.response.data.exc_type)!==null&&O!==void 0?O:""})})]})})},a.prototype.setValue=function(c,o,d,h){return e(this,void 0,void 0,function(){return n(this,function(u){return d!==null&&typeof d=="object"&&!Array.isArray(d)&&(h=void 0),[2,this.axios.post("/api/method/frappe.client.set_value",{doctype:c,name:o,fieldname:d,value:h}).then(function(m){return m.data}).catch(function(m){var b,S;throw t(t({},m.response.data),{httpStatus:m.response.status,httpStatusText:m.response.statusText,message:"There was an error while setting the value.",exception:(S=(b=m.response.data.exception)!==null&&b!==void 0?b:m.response.data.exc_type)!==null&&S!==void 0?S:""})})]})})},a.prototype.getSingleValue=function(c,o){return e(this,void 0,void 0,function(){var d;return n(this,function(h){return d={doctype:c,field:o},[2,this.axios.get("/api/method/frappe.client.get_single_value",{params:d}).then(function(u){return u.data}).catch(function(u){var m,b;throw t(t({},u.response.data),{httpStatus:u.response.status,httpStatusText:u.response.statusText,message:"There was an error while getting the value of single doctype.",exception:(b=(m=u.response.data.exception)!==null&&m!==void 0?m:u.response.data.exc_type)!==null&&b!==void 0?b:""})})]})})},a.prototype.submit=function(c){return e(this,void 0,void 0,function(){return n(this,function(o){return[2,this.axios.post("/api/method/frappe.client.submit",{doc:c}).then(function(d){return d.data.message}).catch(function(d){var h,u;throw t(t({},d.response.data),{httpStatus:d.response.status,httpStatusText:d.response.statusText,message:"There was an error while submitting the document.",exception:(u=(h=d.response.data.exception)!==null&&h!==void 0?h:d.response.data.exc_type)!==null&&u!==void 0?u:""})})]})})},a.prototype.cancel=function(c,o){return e(this,void 0,void 0,function(){return n(this,function(d){return[2,this.axios.post("/api/method/frappe.client.cancel",{doctype:c,name:o}).then(function(h){return h.data}).catch(function(h){var u,m;throw t(t({},h.response.data),{httpStatus:h.response.status,httpStatusText:h.response.statusText,message:"There was an error while cancelling the document.",exception:(m=(u=h.response.data.exception)!==null&&u!==void 0?u:h.response.data.exc_type)!==null&&m!==void 0?m:""})})]})})},a}();return Te.FrappeDB=s,Te}var Oe={},Ue={};/*! Axios v1.8.2 Copyright (c) 2025 Matt Zabriskie and contributors */var Yt,Yn;function Cr(){if(Yn)return Yt;Yn=1;function t(r,i){return function(){return r.apply(i,arguments)}}const{toString:e}=Object.prototype,{getPrototypeOf:n}=Object,s=(r=>i=>{const l=e.call(i);return r[l]||(r[l]=l.slice(8,-1).toLowerCase())})(Object.create(null)),a=r=>(r=r.toLowerCase(),i=>s(i)===r),c=r=>i=>typeof i===r,{isArray:o}=Array,d=c("undefined");function h(r){return r!==null&&!d(r)&&r.constructor!==null&&!d(r.constructor)&&S(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const u=a("ArrayBuffer");function m(r){let i;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?i=ArrayBuffer.isView(r):i=r&&r.buffer&&u(r.buffer),i}const b=c("string"),S=c("function"),p=c("number"),_=r=>r!==null&&typeof r=="object",O=r=>r===!0||r===!1,j=r=>{if(s(r)!=="object")return!1;const i=n(r);return(i===null||i===Object.prototype||Object.getPrototypeOf(i)===null)&&!(Symbol.toStringTag in r)&&!(Symbol.iterator in r)},R=a("Date"),Y=a("File"),z=a("Blob"),H=a("FileList"),I=r=>_(r)&&S(r.pipe),J=r=>{let i;return r&&(typeof FormData=="function"&&r instanceof FormData||S(r.append)&&((i=s(r))==="formdata"||i==="object"&&S(r.toString)&&r.toString()==="[object FormData]"))},Fe=a("URLSearchParams"),[B,de,V,ae]=["ReadableStream","Request","Response","Headers"].map(a),be=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function G(r,i,{allOwnKeys:l=!1}={}){if(r===null||typeof r>"u")return;let f,y;if(typeof r!="object"&&(r=[r]),o(r))for(f=0,y=r.length;f<y;f++)i.call(null,r[f],f,r);else{const g=l?Object.getOwnPropertyNames(r):Object.keys(r),w=g.length;let T;for(f=0;f<w;f++)T=g[f],i.call(null,r[T],T,r)}}function ce(r,i){i=i.toLowerCase();const l=Object.keys(r);let f=l.length,y;for(;f-- >0;)if(y=l[f],i===y.toLowerCase())return y;return null}const ue=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:Or,Ne=r=>!d(r)&&r!==ue;function Q(){const{caseless:r}=Ne(this)&&this||{},i={},l=(f,y)=>{const g=r&&ce(i,y)||y;j(i[g])&&j(f)?i[g]=Q(i[g],f):j(f)?i[g]=Q({},f):o(f)?i[g]=f.slice():i[g]=f};for(let f=0,y=arguments.length;f<y;f++)arguments[f]&&G(arguments[f],l);return i}const ge=(r,i,l,{allOwnKeys:f}={})=>(G(i,(y,g)=>{l&&S(y)?r[g]=t(y,l):r[g]=y},{allOwnKeys:f}),r),Ve=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),gt=(r,i,l,f)=>{r.prototype=Object.create(i.prototype,f),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:i.prototype}),l&&Object.assign(r.prototype,l)},Be=(r,i,l,f)=>{let y,g,w;const T={};if(i=i||{},r==null)return i;do{for(y=Object.getOwnPropertyNames(r),g=y.length;g-- >0;)w=y[g],(!f||f(w,r,i))&&!T[w]&&(i[w]=r[w],T[w]=!0);r=l!==!1&&n(r)}while(r&&(!l||l(r,i))&&r!==Object.prototype);return i},se=(r,i,l)=>{r=String(r),(l===void 0||l>r.length)&&(l=r.length),l-=i.length;const f=r.indexOf(i,l);return f!==-1&&f===l},$e=r=>{if(!r)return null;if(o(r))return r;let i=r.length;if(!p(i))return null;const l=new Array(i);for(;i-- >0;)l[i]=r[i];return l},He=(r=>i=>r&&i instanceof r)(typeof Uint8Array<"u"&&n(Uint8Array)),Xe=(r,i)=>{const f=(r&&r[Symbol.iterator]).call(r);let y;for(;(y=f.next())&&!y.done;){const g=y.value;i.call(r,g[0],g[1])}},rt=(r,i)=>{let l;const f=[];for(;(l=r.exec(i))!==null;)f.push(l);return f},Pt=a("HTMLFormElement"),Nn=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(l,f,y){return f.toUpperCase()+y}),Ut=(({hasOwnProperty:r})=>(i,l)=>r.call(i,l))(Object.prototype),Ye=a("RegExp"),wt=(r,i)=>{const l=Object.getOwnPropertyDescriptors(r),f={};G(l,(y,g)=>{let w;(w=i(y,g,r))!==!1&&(f[g]=w||y)}),Object.defineProperties(r,f)},Zs=r=>{wt(r,(i,l)=>{if(S(r)&&["arguments","caller","callee"].indexOf(l)!==-1)return!1;const f=r[l];if(S(f)){if(i.enumerable=!1,"writable"in i){i.writable=!1;return}i.set||(i.set=()=>{throw Error("Can not rewrite read-only method '"+l+"'")})}})},$=(r,i)=>{const l={},f=y=>{y.forEach(g=>{l[g]=!0})};return o(r)?f(r):f(String(r).split(i)),l},M=()=>{},le=(r,i)=>r!=null&&Number.isFinite(r=+r)?r:i;function K(r){return!!(r&&S(r.append)&&r[Symbol.toStringTag]==="FormData"&&r[Symbol.iterator])}const ve=r=>{const i=new Array(10),l=(f,y)=>{if(_(f)){if(i.indexOf(f)>=0)return;if(!("toJSON"in f)){i[y]=f;const g=o(f)?[]:{};return G(f,(w,T)=>{const A=l(w,y+1);!d(A)&&(g[T]=A)}),i[y]=void 0,g}}return f};return l(r,0)},We=a("AsyncFunction"),re=r=>r&&(_(r)||S(r))&&S(r.then)&&S(r.catch),fe=((r,i)=>r?setImmediate:i?((l,f)=>(ue.addEventListener("message",({source:y,data:g})=>{y===ue&&g===l&&f.length&&f.shift()()},!1),y=>{f.push(y),ue.postMessage(l,"*")}))(`axios@${Math.random()}`,[]):l=>setTimeout(l))(typeof setImmediate=="function",S(ue.postMessage)),Ae=typeof queueMicrotask<"u"?queueMicrotask.bind(ue):typeof process<"u"&&process.nextTick||fe;var v={isArray:o,isArrayBuffer:u,isBuffer:h,isFormData:J,isArrayBufferView:m,isString:b,isNumber:p,isBoolean:O,isObject:_,isPlainObject:j,isReadableStream:B,isRequest:de,isResponse:V,isHeaders:ae,isUndefined:d,isDate:R,isFile:Y,isBlob:z,isRegExp:Ye,isFunction:S,isStream:I,isURLSearchParams:Fe,isTypedArray:He,isFileList:H,forEach:G,merge:Q,extend:ge,trim:be,stripBOM:Ve,inherits:gt,toFlatObject:Be,kindOf:s,kindOfTest:a,endsWith:se,toArray:$e,forEachEntry:Xe,matchAll:rt,isHTMLForm:Pt,hasOwnProperty:Ut,hasOwnProp:Ut,reduceDescriptors:wt,freezeMethods:Zs,toObjectSet:$,toCamelCase:Nn,noop:M,toFiniteNumber:le,findKey:ce,global:ue,isContextDefined:Ne,isSpecCompliantForm:K,toJSONObject:ve,isAsyncFn:We,isThenable:re,setImmediate:fe,asap:Ae};function F(r,i,l,f,y){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",i&&(this.code=i),l&&(this.config=l),f&&(this.request=f),y&&(this.response=y,this.status=y.status?y.status:null)}v.inherits(F,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:v.toJSONObject(this.config),code:this.code,status:this.status}}});const bt=F.prototype,me={};["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(r=>{me[r]={value:r}}),Object.defineProperties(F,me),Object.defineProperty(bt,"isAxiosError",{value:!0}),F.from=(r,i,l,f,y,g)=>{const w=Object.create(bt);return v.toFlatObject(r,w,function(A){return A!==Error.prototype},T=>T!=="isAxiosError"),F.call(w,r.message,i,l,f,y),w.cause=r,w.name=r.name,g&&Object.assign(w,g),w};var ke=null;function Qe(r){return v.isPlainObject(r)||v.isArray(r)}function qt(r){return v.endsWith(r,"[]")?r.slice(0,-2):r}function it(r,i,l){return r?r.concat(i).map(function(y,g){return y=qt(y),!l&&g?"["+y+"]":y}).join(l?".":""):i}function vo(r){return v.isArray(r)&&!r.some(Qe)}const _o=v.toFlatObject(v,{},null,function(i){return/^is[A-Z]/.test(i)});function It(r,i,l){if(!v.isObject(r))throw new TypeError("target must be an object");i=i||new FormData,l=v.toFlatObject(l,{metaTokens:!0,dots:!1,indexes:!1},!1,function(U,L){return!v.isUndefined(L[U])});const f=l.metaTokens,y=l.visitor||x,g=l.dots,w=l.indexes,A=(l.Blob||typeof Blob<"u"&&Blob)&&v.isSpecCompliantForm(i);if(!v.isFunction(y))throw new TypeError("visitor must be a function");function C(D){if(D===null)return"";if(v.isDate(D))return D.toISOString();if(!A&&v.isBlob(D))throw new F("Blob is not supported. Use a Buffer instead.");return v.isArrayBuffer(D)||v.isTypedArray(D)?A&&typeof Blob=="function"?new Blob([D]):Buffer.from(D):D}function x(D,U,L){let Z=D;if(D&&!L&&typeof D=="object"){if(v.endsWith(U,"{}"))U=f?U:U.slice(0,-2),D=JSON.stringify(D);else if(v.isArray(D)&&vo(D)||(v.isFileList(D)||v.endsWith(U,"[]"))&&(Z=v.toArray(D)))return U=qt(U),Z.forEach(function(he,Ie){!(v.isUndefined(he)||he===null)&&i.append(w===!0?it([U],Ie,g):w===null?U:U+"[]",C(he))}),!1}return Qe(D)?!0:(i.append(it(L,U,g),C(D)),!1)}const k=[],W=Object.assign(_o,{defaultVisitor:x,convertValue:C,isVisitable:Qe});function ie(D,U){if(!v.isUndefined(D)){if(k.indexOf(D)!==-1)throw Error("Circular reference detected in "+U.join("."));k.push(D),v.forEach(D,function(Z,oe){(!(v.isUndefined(Z)||Z===null)&&y.call(i,Z,v.isString(oe)?oe.trim():oe,U,W))===!0&&ie(Z,U?U.concat(oe):[oe])}),k.pop()}}if(!v.isObject(r))throw new TypeError("data must be an object");return ie(r),i}function er(r){const i={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(f){return i[f]})}function Bn(r,i){this._pairs=[],r&&It(r,this,i)}const tr=Bn.prototype;tr.append=function(i,l){this._pairs.push([i,l])},tr.toString=function(i){const l=i?function(f){return i.call(this,f,er)}:er;return this._pairs.map(function(y){return l(y[0])+"="+l(y[1])},"").join("&")};function So(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function nr(r,i,l){if(!i)return r;const f=l&&l.encode||So;v.isFunction(l)&&(l={serialize:l});const y=l&&l.serialize;let g;if(y?g=y(i,l):g=v.isURLSearchParams(i)?i.toString():new Bn(i,l).toString(f),g){const w=r.indexOf("#");w!==-1&&(r=r.slice(0,w)),r+=(r.indexOf("?")===-1?"?":"&")+g}return r}class Eo{constructor(){this.handlers=[]}use(i,l,f){return this.handlers.push({fulfilled:i,rejected:l,synchronous:f?f.synchronous:!1,runWhen:f?f.runWhen:null}),this.handlers.length-1}eject(i){this.handlers[i]&&(this.handlers[i]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(i){v.forEach(this.handlers,function(f){f!==null&&i(f)})}}var sr=Eo,rr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},To=typeof URLSearchParams<"u"?URLSearchParams:Bn,Oo=typeof FormData<"u"?FormData:null,Co=typeof Blob<"u"?Blob:null,xo={isBrowser:!0,classes:{URLSearchParams:To,FormData:Oo,Blob:Co},protocols:["http","https","file","blob","url","data"]};const Pn=typeof window<"u"&&typeof document<"u",Un=typeof navigator=="object"&&navigator||void 0,Ro=Pn&&(!Un||["ReactNative","NativeScript","NS"].indexOf(Un.product)<0),Ao=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",ko=Pn&&window.location.href||"http://localhost";var Do=Object.freeze({__proto__:null,hasBrowserEnv:Pn,hasStandardBrowserWebWorkerEnv:Ao,hasStandardBrowserEnv:Ro,navigator:Un,origin:ko}),pe={...Do,...xo};function Lo(r,i){return It(r,new pe.classes.URLSearchParams,Object.assign({visitor:function(l,f,y,g){return pe.isNode&&v.isBuffer(l)?(this.append(f,l.toString("base64")),!1):g.defaultVisitor.apply(this,arguments)}},i))}function Fo(r){return v.matchAll(/\w+|\[(\w*)]/g,r).map(i=>i[0]==="[]"?"":i[1]||i[0])}function No(r){const i={},l=Object.keys(r);let f;const y=l.length;let g;for(f=0;f<y;f++)g=l[f],i[g]=r[g];return i}function ir(r){function i(l,f,y,g){let w=l[g++];if(w==="__proto__")return!0;const T=Number.isFinite(+w),A=g>=l.length;return w=!w&&v.isArray(y)?y.length:w,A?(v.hasOwnProp(y,w)?y[w]=[y[w],f]:y[w]=f,!T):((!y[w]||!v.isObject(y[w]))&&(y[w]=[]),i(l,f,y[w],g)&&v.isArray(y[w])&&(y[w]=No(y[w])),!T)}if(v.isFormData(r)&&v.isFunction(r.entries)){const l={};return v.forEachEntry(r,(f,y)=>{i(Fo(f),y,l,0)}),l}return null}function Bo(r,i,l){if(v.isString(r))try{return(i||JSON.parse)(r),v.trim(r)}catch(f){if(f.name!=="SyntaxError")throw f}return(l||JSON.stringify)(r)}const qn={transitional:rr,adapter:["xhr","http","fetch"],transformRequest:[function(i,l){const f=l.getContentType()||"",y=f.indexOf("application/json")>-1,g=v.isObject(i);if(g&&v.isHTMLForm(i)&&(i=new FormData(i)),v.isFormData(i))return y?JSON.stringify(ir(i)):i;if(v.isArrayBuffer(i)||v.isBuffer(i)||v.isStream(i)||v.isFile(i)||v.isBlob(i)||v.isReadableStream(i))return i;if(v.isArrayBufferView(i))return i.buffer;if(v.isURLSearchParams(i))return l.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),i.toString();let T;if(g){if(f.indexOf("application/x-www-form-urlencoded")>-1)return Lo(i,this.formSerializer).toString();if((T=v.isFileList(i))||f.indexOf("multipart/form-data")>-1){const A=this.env&&this.env.FormData;return It(T?{"files[]":i}:i,A&&new A,this.formSerializer)}}return g||y?(l.setContentType("application/json",!1),Bo(i)):i}],transformResponse:[function(i){const l=this.transitional||qn.transitional,f=l&&l.forcedJSONParsing,y=this.responseType==="json";if(v.isResponse(i)||v.isReadableStream(i))return i;if(i&&v.isString(i)&&(f&&!this.responseType||y)){const w=!(l&&l.silentJSONParsing)&&y;try{return JSON.parse(i)}catch(T){if(w)throw T.name==="SyntaxError"?F.from(T,F.ERR_BAD_RESPONSE,this,null,this.response):T}}return i}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:pe.classes.FormData,Blob:pe.classes.Blob},validateStatus:function(i){return i>=200&&i<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};v.forEach(["delete","get","head","post","put","patch"],r=>{qn.headers[r]={}});var In=qn;const Po=v.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"]);var Uo=r=>{const i={};let l,f,y;return r&&r.split(`
`).forEach(function(w){y=w.indexOf(":"),l=w.substring(0,y).trim().toLowerCase(),f=w.substring(y+1).trim(),!(!l||i[l]&&Po[l])&&(l==="set-cookie"?i[l]?i[l].push(f):i[l]=[f]:i[l]=i[l]?i[l]+", "+f:f)}),i};const or=Symbol("internals");function vt(r){return r&&String(r).trim().toLowerCase()}function jt(r){return r===!1||r==null?r:v.isArray(r)?r.map(jt):String(r)}function qo(r){const i=Object.create(null),l=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let f;for(;f=l.exec(r);)i[f[1]]=f[2];return i}const Io=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function jn(r,i,l,f,y){if(v.isFunction(f))return f.call(this,i,l);if(y&&(i=l),!!v.isString(i)){if(v.isString(f))return i.indexOf(f)!==-1;if(v.isRegExp(f))return f.test(i)}}function jo(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(i,l,f)=>l.toUpperCase()+f)}function Mo(r,i){const l=v.toCamelCase(" "+i);["get","set","has"].forEach(f=>{Object.defineProperty(r,f+l,{value:function(y,g,w){return this[f].call(this,i,y,g,w)},configurable:!0})})}class Mt{constructor(i){i&&this.set(i)}set(i,l,f){const y=this;function g(T,A,C){const x=vt(A);if(!x)throw new Error("header name must be a non-empty string");const k=v.findKey(y,x);(!k||y[k]===void 0||C===!0||C===void 0&&y[k]!==!1)&&(y[k||A]=jt(T))}const w=(T,A)=>v.forEach(T,(C,x)=>g(C,x,A));if(v.isPlainObject(i)||i instanceof this.constructor)w(i,l);else if(v.isString(i)&&(i=i.trim())&&!Io(i))w(Uo(i),l);else if(v.isHeaders(i))for(const[T,A]of i.entries())g(A,T,f);else i!=null&&g(l,i,f);return this}get(i,l){if(i=vt(i),i){const f=v.findKey(this,i);if(f){const y=this[f];if(!l)return y;if(l===!0)return qo(y);if(v.isFunction(l))return l.call(this,y,f);if(v.isRegExp(l))return l.exec(y);throw new TypeError("parser must be boolean|regexp|function")}}}has(i,l){if(i=vt(i),i){const f=v.findKey(this,i);return!!(f&&this[f]!==void 0&&(!l||jn(this,this[f],f,l)))}return!1}delete(i,l){const f=this;let y=!1;function g(w){if(w=vt(w),w){const T=v.findKey(f,w);T&&(!l||jn(f,f[T],T,l))&&(delete f[T],y=!0)}}return v.isArray(i)?i.forEach(g):g(i),y}clear(i){const l=Object.keys(this);let f=l.length,y=!1;for(;f--;){const g=l[f];(!i||jn(this,this[g],g,i,!0))&&(delete this[g],y=!0)}return y}normalize(i){const l=this,f={};return v.forEach(this,(y,g)=>{const w=v.findKey(f,g);if(w){l[w]=jt(y),delete l[g];return}const T=i?jo(g):String(g).trim();T!==g&&delete l[g],l[T]=jt(y),f[T]=!0}),this}concat(...i){return this.constructor.concat(this,...i)}toJSON(i){const l=Object.create(null);return v.forEach(this,(f,y)=>{f!=null&&f!==!1&&(l[y]=i&&v.isArray(f)?f.join(", "):f)}),l}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([i,l])=>i+": "+l).join(`
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(i){return i instanceof this?i:new this(i)}static concat(i,...l){const f=new this(i);return l.forEach(y=>f.set(y)),f}static accessor(i){const f=(this[or]=this[or]={accessors:{}}).accessors,y=this.prototype;function g(w){const T=vt(w);f[T]||(Mo(y,w),f[T]=!0)}return v.isArray(i)?i.forEach(g):g(i),this}}Mt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),v.reduceDescriptors(Mt.prototype,({value:r},i)=>{let l=i[0].toUpperCase()+i.slice(1);return{get:()=>r,set(f){this[l]=f}}}),v.freezeMethods(Mt);var De=Mt;function Mn(r,i){const l=this||In,f=i||l,y=De.from(f.headers);let g=f.data;return v.forEach(r,function(T){g=T.call(l,g,y.normalize(),i?i.status:void 0)}),y.normalize(),g}function ar(r){return!!(r&&r.__CANCEL__)}function ot(r,i,l){F.call(this,r??"canceled",F.ERR_CANCELED,i,l),this.name="CanceledError"}v.inherits(ot,F,{__CANCEL__:!0});function cr(r,i,l){const f=l.config.validateStatus;!l.status||!f||f(l.status)?r(l):i(new F("Request failed with status code "+l.status,[F.ERR_BAD_REQUEST,F.ERR_BAD_RESPONSE][Math.floor(l.status/100)-4],l.config,l.request,l))}function Vo(r){const i=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return i&&i[1]||""}function $o(r,i){r=r||10;const l=new Array(r),f=new Array(r);let y=0,g=0,w;return i=i!==void 0?i:1e3,function(A){const C=Date.now(),x=f[g];w||(w=C),l[y]=A,f[y]=C;let k=g,W=0;for(;k!==y;)W+=l[k++],k=k%r;if(y=(y+1)%r,y===g&&(g=(g+1)%r),C-w<i)return;const ie=x&&C-x;return ie?Math.round(W*1e3/ie):void 0}}function Ho(r,i){let l=0,f=1e3/i,y,g;const w=(C,x=Date.now())=>{l=x,y=null,g&&(clearTimeout(g),g=null),r.apply(null,C)};return[(...C)=>{const x=Date.now(),k=x-l;k>=f?w(C,x):(y=C,g||(g=setTimeout(()=>{g=null,w(y)},f-k)))},()=>y&&w(y)]}const Vt=(r,i,l=3)=>{let f=0;const y=$o(50,250);return Ho(g=>{const w=g.loaded,T=g.lengthComputable?g.total:void 0,A=w-f,C=y(A),x=w<=T;f=w;const k={loaded:w,total:T,progress:T?w/T:void 0,bytes:A,rate:C||void 0,estimated:C&&T&&x?(T-w)/C:void 0,event:g,lengthComputable:T!=null,[i?"download":"upload"]:!0};r(k)},l)},ur=(r,i)=>{const l=r!=null;return[f=>i[0]({lengthComputable:l,total:r,loaded:f}),i[1]]},lr=r=>(...i)=>v.asap(()=>r(...i));var Wo=pe.hasStandardBrowserEnv?((r,i)=>l=>(l=new URL(l,pe.origin),r.protocol===l.protocol&&r.host===l.host&&(i||r.port===l.port)))(new URL(pe.origin),pe.navigator&&/(msie|trident)/i.test(pe.navigator.userAgent)):()=>!0,zo=pe.hasStandardBrowserEnv?{write(r,i,l,f,y,g){const w=[r+"="+encodeURIComponent(i)];v.isNumber(l)&&w.push("expires="+new Date(l).toGMTString()),v.isString(f)&&w.push("path="+f),v.isString(y)&&w.push("domain="+y),g===!0&&w.push("secure"),document.cookie=w.join("; ")},read(r){const i=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return i?decodeURIComponent(i[3]):null},remove(r){this.write(r,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Jo(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Ko(r,i){return i?r.replace(/\/?\/$/,"")+"/"+i.replace(/^\/+/,""):r}function fr(r,i,l){let f=!Jo(i);return r&&f||l==!1?Ko(r,i):i}const hr=r=>r instanceof De?{...r}:r;function Ze(r,i){i=i||{};const l={};function f(C,x,k,W){return v.isPlainObject(C)&&v.isPlainObject(x)?v.merge.call({caseless:W},C,x):v.isPlainObject(x)?v.merge({},x):v.isArray(x)?x.slice():x}function y(C,x,k,W){if(v.isUndefined(x)){if(!v.isUndefined(C))return f(void 0,C,k,W)}else return f(C,x,k,W)}function g(C,x){if(!v.isUndefined(x))return f(void 0,x)}function w(C,x){if(v.isUndefined(x)){if(!v.isUndefined(C))return f(void 0,C)}else return f(void 0,x)}function T(C,x,k){if(k in i)return f(C,x);if(k in r)return f(void 0,C)}const A={url:g,method:g,data:g,baseURL:w,transformRequest:w,transformResponse:w,paramsSerializer:w,timeout:w,timeoutMessage:w,withCredentials:w,withXSRFToken:w,adapter:w,responseType:w,xsrfCookieName:w,xsrfHeaderName:w,onUploadProgress:w,onDownloadProgress:w,decompress:w,maxContentLength:w,maxBodyLength:w,beforeRedirect:w,transport:w,httpAgent:w,httpsAgent:w,cancelToken:w,socketPath:w,responseEncoding:w,validateStatus:T,headers:(C,x,k)=>y(hr(C),hr(x),k,!0)};return v.forEach(Object.keys(Object.assign({},r,i)),function(x){const k=A[x]||y,W=k(r[x],i[x],x);v.isUndefined(W)&&k!==T||(l[x]=W)}),l}var dr=r=>{const i=Ze({},r);let{data:l,withXSRFToken:f,xsrfHeaderName:y,xsrfCookieName:g,headers:w,auth:T}=i;i.headers=w=De.from(w),i.url=nr(fr(i.baseURL,i.url),r.params,r.paramsSerializer),T&&w.set("Authorization","Basic "+btoa((T.username||"")+":"+(T.password?unescape(encodeURIComponent(T.password)):"")));let A;if(v.isFormData(l)){if(pe.hasStandardBrowserEnv||pe.hasStandardBrowserWebWorkerEnv)w.setContentType(void 0);else if((A=w.getContentType())!==!1){const[C,...x]=A?A.split(";").map(k=>k.trim()).filter(Boolean):[];w.setContentType([C||"multipart/form-data",...x].join("; "))}}if(pe.hasStandardBrowserEnv&&(f&&v.isFunction(f)&&(f=f(i)),f||f!==!1&&Wo(i.url))){const C=y&&g&&zo.read(g);C&&w.set(y,C)}return i},Go=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(l,f){const y=dr(r);let g=y.data;const w=De.from(y.headers).normalize();let{responseType:T,onUploadProgress:A,onDownloadProgress:C}=y,x,k,W,ie,D;function U(){ie&&ie(),D&&D(),y.cancelToken&&y.cancelToken.unsubscribe(x),y.signal&&y.signal.removeEventListener("abort",x)}let L=new XMLHttpRequest;L.open(y.method.toUpperCase(),y.url,!0),L.timeout=y.timeout;function Z(){if(!L)return;const he=De.from("getAllResponseHeaders"in L&&L.getAllResponseHeaders()),we={data:!T||T==="text"||T==="json"?L.responseText:L.response,status:L.status,statusText:L.statusText,headers:he,config:r,request:L};cr(function(et){l(et),U()},function(et){f(et),U()},we),L=null}"onloadend"in L?L.onloadend=Z:L.onreadystatechange=function(){!L||L.readyState!==4||L.status===0&&!(L.responseURL&&L.responseURL.indexOf("file:")===0)||setTimeout(Z)},L.onabort=function(){L&&(f(new F("Request aborted",F.ECONNABORTED,r,L)),L=null)},L.onerror=function(){f(new F("Network Error",F.ERR_NETWORK,r,L)),L=null},L.ontimeout=function(){let Ie=y.timeout?"timeout of "+y.timeout+"ms exceeded":"timeout exceeded";const we=y.transitional||rr;y.timeoutErrorMessage&&(Ie=y.timeoutErrorMessage),f(new F(Ie,we.clarifyTimeoutError?F.ETIMEDOUT:F.ECONNABORTED,r,L)),L=null},g===void 0&&w.setContentType(null),"setRequestHeader"in L&&v.forEach(w.toJSON(),function(Ie,we){L.setRequestHeader(we,Ie)}),v.isUndefined(y.withCredentials)||(L.withCredentials=!!y.withCredentials),T&&T!=="json"&&(L.responseType=y.responseType),C&&([W,D]=Vt(C,!0),L.addEventListener("progress",W)),A&&L.upload&&([k,ie]=Vt(A),L.upload.addEventListener("progress",k),L.upload.addEventListener("loadend",ie)),(y.cancelToken||y.signal)&&(x=he=>{L&&(f(!he||he.type?new ot(null,r,L):he),L.abort(),L=null)},y.cancelToken&&y.cancelToken.subscribe(x),y.signal&&(y.signal.aborted?x():y.signal.addEventListener("abort",x)));const oe=Vo(y.url);if(oe&&pe.protocols.indexOf(oe)===-1){f(new F("Unsupported protocol "+oe+":",F.ERR_BAD_REQUEST,r));return}L.send(g||null)})},Xo=(r,i)=>{const{length:l}=r=r?r.filter(Boolean):[];if(i||l){let f=new AbortController,y;const g=function(C){if(!y){y=!0,T();const x=C instanceof Error?C:this.reason;f.abort(x instanceof F?x:new ot(x instanceof Error?x.message:x))}};let w=i&&setTimeout(()=>{w=null,g(new F(`timeout ${i} of ms exceeded`,F.ETIMEDOUT))},i);const T=()=>{r&&(w&&clearTimeout(w),w=null,r.forEach(C=>{C.unsubscribe?C.unsubscribe(g):C.removeEventListener("abort",g)}),r=null)};r.forEach(C=>C.addEventListener("abort",g));const{signal:A}=f;return A.unsubscribe=()=>v.asap(T),A}};const Yo=function*(r,i){let l=r.byteLength;if(l<i){yield r;return}let f=0,y;for(;f<l;)y=f+i,yield r.slice(f,y),f=y},Qo=async function*(r,i){for await(const l of Zo(r))yield*Yo(l,i)},Zo=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const i=r.getReader();try{for(;;){const{done:l,value:f}=await i.read();if(l)break;yield f}}finally{await i.cancel()}},pr=(r,i,l,f)=>{const y=Qo(r,i);let g=0,w,T=A=>{w||(w=!0,f&&f(A))};return new ReadableStream({async pull(A){try{const{done:C,value:x}=await y.next();if(C){T(),A.close();return}let k=x.byteLength;if(l){let W=g+=k;l(W)}A.enqueue(new Uint8Array(x))}catch(C){throw T(C),C}},cancel(A){return T(A),y.return()}},{highWaterMark:2})},$t=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",mr=$t&&typeof ReadableStream=="function",ea=$t&&(typeof TextEncoder=="function"?(r=>i=>r.encode(i))(new TextEncoder):async r=>new Uint8Array(await new Response(r).arrayBuffer())),yr=(r,...i)=>{try{return!!r(...i)}catch{return!1}},ta=mr&&yr(()=>{let r=!1;const i=new Request(pe.origin,{body:new ReadableStream,method:"POST",get duplex(){return r=!0,"half"}}).headers.has("Content-Type");return r&&!i}),gr=64*1024,Vn=mr&&yr(()=>v.isReadableStream(new Response("").body)),Ht={stream:Vn&&(r=>r.body)};$t&&(r=>{["text","arrayBuffer","blob","formData","stream"].forEach(i=>{!Ht[i]&&(Ht[i]=v.isFunction(r[i])?l=>l[i]():(l,f)=>{throw new F(`Response type '${i}' is not supported`,F.ERR_NOT_SUPPORT,f)})})})(new Response);const na=async r=>{if(r==null)return 0;if(v.isBlob(r))return r.size;if(v.isSpecCompliantForm(r))return(await new Request(pe.origin,{method:"POST",body:r}).arrayBuffer()).byteLength;if(v.isArrayBufferView(r)||v.isArrayBuffer(r))return r.byteLength;if(v.isURLSearchParams(r)&&(r=r+""),v.isString(r))return(await ea(r)).byteLength},sa=async(r,i)=>{const l=v.toFiniteNumber(r.getContentLength());return l??na(i)};var ra=$t&&(async r=>{let{url:i,method:l,data:f,signal:y,cancelToken:g,timeout:w,onDownloadProgress:T,onUploadProgress:A,responseType:C,headers:x,withCredentials:k="same-origin",fetchOptions:W}=dr(r);C=C?(C+"").toLowerCase():"text";let ie=Xo([y,g&&g.toAbortSignal()],w),D;const U=ie&&ie.unsubscribe&&(()=>{ie.unsubscribe()});let L;try{if(A&&ta&&l!=="get"&&l!=="head"&&(L=await sa(x,f))!==0){let we=new Request(i,{method:"POST",body:f,duplex:"half"}),ze;if(v.isFormData(f)&&(ze=we.headers.get("content-type"))&&x.setContentType(ze),we.body){const[et,Gt]=ur(L,Vt(lr(A)));f=pr(we.body,gr,et,Gt)}}v.isString(k)||(k=k?"include":"omit");const Z="credentials"in Request.prototype;D=new Request(i,{...W,signal:ie,method:l.toUpperCase(),headers:x.normalize().toJSON(),body:f,duplex:"half",credentials:Z?k:void 0});let oe=await fetch(D);const he=Vn&&(C==="stream"||C==="response");if(Vn&&(T||he&&U)){const we={};["status","statusText","headers"].forEach(Tr=>{we[Tr]=oe[Tr]});const ze=v.toFiniteNumber(oe.headers.get("content-length")),[et,Gt]=T&&ur(ze,Vt(lr(T),!0))||[];oe=new Response(pr(oe.body,gr,et,()=>{Gt&&Gt(),U&&U()}),we)}C=C||"text";let Ie=await Ht[v.findKey(Ht,C)||"text"](oe,r);return!he&&U&&U(),await new Promise((we,ze)=>{cr(we,ze,{data:Ie,headers:De.from(oe.headers),status:oe.status,statusText:oe.statusText,config:r,request:D})})}catch(Z){throw U&&U(),Z&&Z.name==="TypeError"&&/fetch/i.test(Z.message)?Object.assign(new F("Network Error",F.ERR_NETWORK,r,D),{cause:Z.cause||Z}):F.from(Z,Z&&Z.code,r,D)}});const $n={http:ke,xhr:Go,fetch:ra};v.forEach($n,(r,i)=>{if(r){try{Object.defineProperty(r,"name",{value:i})}catch{}Object.defineProperty(r,"adapterName",{value:i})}});const wr=r=>`- ${r}`,ia=r=>v.isFunction(r)||r===null||r===!1;var br={getAdapter:r=>{r=v.isArray(r)?r:[r];const{length:i}=r;let l,f;const y={};for(let g=0;g<i;g++){l=r[g];let w;if(f=l,!ia(l)&&(f=$n[(w=String(l)).toLowerCase()],f===void 0))throw new F(`Unknown adapter '${w}'`);if(f)break;y[w||"#"+g]=f}if(!f){const g=Object.entries(y).map(([T,A])=>`adapter ${T} `+(A===!1?"is not supported by the environment":"is not available in the build"));let w=i?g.length>1?`since :
`+g.map(wr).join(`
`):" "+wr(g[0]):"as no adapter specified";throw new F("There is no suitable adapter to dispatch the request "+w,"ERR_NOT_SUPPORT")}return f},adapters:$n};function Hn(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new ot(null,r)}function vr(r){return Hn(r),r.headers=De.from(r.headers),r.data=Mn.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),br.getAdapter(r.adapter||In.adapter)(r).then(function(f){return Hn(r),f.data=Mn.call(r,r.transformResponse,f),f.headers=De.from(f.headers),f},function(f){return ar(f)||(Hn(r),f&&f.response&&(f.response.data=Mn.call(r,r.transformResponse,f.response),f.response.headers=De.from(f.response.headers))),Promise.reject(f)})}const _r="1.8.2",Wt={};["object","boolean","number","function","string","symbol"].forEach((r,i)=>{Wt[r]=function(f){return typeof f===r||"a"+(i<1?"n ":" ")+r}});const Sr={};Wt.transitional=function(i,l,f){function y(g,w){return"[Axios v"+_r+"] Transitional option '"+g+"'"+w+(f?". "+f:"")}return(g,w,T)=>{if(i===!1)throw new F(y(w," has been removed"+(l?" in "+l:"")),F.ERR_DEPRECATED);return l&&!Sr[w]&&(Sr[w]=!0,console.warn(y(w," has been deprecated since v"+l+" and will be removed in the near future"))),i?i(g,w,T):!0}},Wt.spelling=function(i){return(l,f)=>(console.warn(`${f} is likely a misspelling of ${i}`),!0)};function oa(r,i,l){if(typeof r!="object")throw new F("options must be an object",F.ERR_BAD_OPTION_VALUE);const f=Object.keys(r);let y=f.length;for(;y-- >0;){const g=f[y],w=i[g];if(w){const T=r[g],A=T===void 0||w(T,g,r);if(A!==!0)throw new F("option "+g+" must be "+A,F.ERR_BAD_OPTION_VALUE);continue}if(l!==!0)throw new F("Unknown option "+g,F.ERR_BAD_OPTION)}}var zt={assertOptions:oa,validators:Wt};const Pe=zt.validators;class Jt{constructor(i){this.defaults=i,this.interceptors={request:new sr,response:new sr}}async request(i,l){try{return await this._request(i,l)}catch(f){if(f instanceof Error){let y={};Error.captureStackTrace?Error.captureStackTrace(y):y=new Error;const g=y.stack?y.stack.replace(/^.+\n/,""):"";try{f.stack?g&&!String(f.stack).endsWith(g.replace(/^.+\n.+\n/,""))&&(f.stack+=`
`+g):f.stack=g}catch{}}throw f}}_request(i,l){typeof i=="string"?(l=l||{},l.url=i):l=i||{},l=Ze(this.defaults,l);const{transitional:f,paramsSerializer:y,headers:g}=l;f!==void 0&&zt.assertOptions(f,{silentJSONParsing:Pe.transitional(Pe.boolean),forcedJSONParsing:Pe.transitional(Pe.boolean),clarifyTimeoutError:Pe.transitional(Pe.boolean)},!1),y!=null&&(v.isFunction(y)?l.paramsSerializer={serialize:y}:zt.assertOptions(y,{encode:Pe.function,serialize:Pe.function},!0)),l.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?l.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:l.allowAbsoluteUrls=!0),zt.assertOptions(l,{baseUrl:Pe.spelling("baseURL"),withXsrfToken:Pe.spelling("withXSRFToken")},!0),l.method=(l.method||this.defaults.method||"get").toLowerCase();let w=g&&v.merge(g.common,g[l.method]);g&&v.forEach(["delete","get","head","post","put","patch","common"],D=>{delete g[D]}),l.headers=De.concat(w,g);const T=[];let A=!0;this.interceptors.request.forEach(function(U){typeof U.runWhen=="function"&&U.runWhen(l)===!1||(A=A&&U.synchronous,T.unshift(U.fulfilled,U.rejected))});const C=[];this.interceptors.response.forEach(function(U){C.push(U.fulfilled,U.rejected)});let x,k=0,W;if(!A){const D=[vr.bind(this),void 0];for(D.unshift.apply(D,T),D.push.apply(D,C),W=D.length,x=Promise.resolve(l);k<W;)x=x.then(D[k++],D[k++]);return x}W=T.length;let ie=l;for(k=0;k<W;){const D=T[k++],U=T[k++];try{ie=D(ie)}catch(L){U.call(this,L);break}}try{x=vr.call(this,ie)}catch(D){return Promise.reject(D)}for(k=0,W=C.length;k<W;)x=x.then(C[k++],C[k++]);return x}getUri(i){i=Ze(this.defaults,i);const l=fr(i.baseURL,i.url,i.allowAbsoluteUrls);return nr(l,i.params,i.paramsSerializer)}}v.forEach(["delete","get","head","options"],function(i){Jt.prototype[i]=function(l,f){return this.request(Ze(f||{},{method:i,url:l,data:(f||{}).data}))}}),v.forEach(["post","put","patch"],function(i){function l(f){return function(g,w,T){return this.request(Ze(T||{},{method:i,headers:f?{"Content-Type":"multipart/form-data"}:{},url:g,data:w}))}}Jt.prototype[i]=l(),Jt.prototype[i+"Form"]=l(!0)});var Kt=Jt;class Wn{constructor(i){if(typeof i!="function")throw new TypeError("executor must be a function.");let l;this.promise=new Promise(function(g){l=g});const f=this;this.promise.then(y=>{if(!f._listeners)return;let g=f._listeners.length;for(;g-- >0;)f._listeners[g](y);f._listeners=null}),this.promise.then=y=>{let g;const w=new Promise(T=>{f.subscribe(T),g=T}).then(y);return w.cancel=function(){f.unsubscribe(g)},w},i(function(g,w,T){f.reason||(f.reason=new ot(g,w,T),l(f.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(i){if(this.reason){i(this.reason);return}this._listeners?this._listeners.push(i):this._listeners=[i]}unsubscribe(i){if(!this._listeners)return;const l=this._listeners.indexOf(i);l!==-1&&this._listeners.splice(l,1)}toAbortSignal(){const i=new AbortController,l=f=>{i.abort(f)};return this.subscribe(l),i.signal.unsubscribe=()=>this.unsubscribe(l),i.signal}static source(){let i;return{token:new Wn(function(y){i=y}),cancel:i}}}var aa=Wn;function ca(r){return function(l){return r.apply(null,l)}}function ua(r){return v.isObject(r)&&r.isAxiosError===!0}const zn={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(zn).forEach(([r,i])=>{zn[i]=r});var la=zn;function Er(r){const i=new Kt(r),l=t(Kt.prototype.request,i);return v.extend(l,Kt.prototype,i,{allOwnKeys:!0}),v.extend(l,i,null,{allOwnKeys:!0}),l.create=function(y){return Er(Ze(r,y))},l}const te=Er(In);return te.Axios=Kt,te.CanceledError=ot,te.CancelToken=aa,te.isCancel=ar,te.VERSION=_r,te.toFormData=It,te.AxiosError=F,te.Cancel=te.CanceledError,te.all=function(i){return Promise.all(i)},te.spread=ca,te.isAxiosError=ua,te.mergeConfig=Ze,te.AxiosHeaders=De,te.formToJSON=r=>ir(v.isHTMLForm(r)?new FormData(r):r),te.getAdapter=br.getAdapter,te.HttpStatusCode=la,te.default=te,Yt=te,Yt}var Qn;function Zn(){if(Qn)return Ue;Qn=1;var t=Ue&&Ue.__assign||function(){return t=Object.assign||function(a){for(var c,o=1,d=arguments.length;o<d;o++){c=arguments[o];for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&(a[h]=c[h])}return a},t.apply(this,arguments)};Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.getRequestHeaders=Ue.getAxiosClient=void 0;var e=Cr();function n(a,c,o,d,h){var u=e.default.create({baseURL:a,headers:s(c,d,o,a,h),withCredentials:!0});return u.interceptors.request.use(function(m){return typeof window<"u"&&window.csrf_token&&window.csrf_token!=="{{ csrf_token }}"&&(m.headers["X-Frappe-CSRF-Token"]=window.csrf_token),c&&d&&o&&(m.headers.Authorization="".concat(d," ").concat(o())),m}),u}Ue.getAxiosClient=n;function s(a,c,o,d,h){a===void 0&&(a=!1);var u={Accept:"application/json","Content-Type":"application/json; charset=utf-8"};return a&&c&&o&&(u.Authorization="".concat(c," ").concat(o())),typeof window<"u"&&typeof document<"u"&&(window.location&&(d&&d!==window.location.origin||(u["X-Frappe-Site-Name"]=window.location.hostname)),window.csrf_token&&window.csrf_token!=="{{ csrf_token }}"&&(u["X-Frappe-CSRF-Token"]=window.csrf_token)),t(t({},u),h??{})}return Ue.getRequestHeaders=s,Ue}var es;function ts(){if(es)return Oe;es=1;var t=Oe&&Oe.__assign||function(){return t=Object.assign||function(c){for(var o,d=1,h=arguments.length;d<h;d++){o=arguments[d];for(var u in o)Object.prototype.hasOwnProperty.call(o,u)&&(c[u]=o[u])}return c},t.apply(this,arguments)},e=Oe&&Oe.__awaiter||function(c,o,d,h){function u(m){return m instanceof d?m:new d(function(b){b(m)})}return new(d||(d=Promise))(function(m,b){function S(O){try{_(h.next(O))}catch(j){b(j)}}function p(O){try{_(h.throw(O))}catch(j){b(j)}}function _(O){O.done?m(O.value):u(O.value).then(S,p)}_((h=h.apply(c,o||[])).next())})},n=Oe&&Oe.__generator||function(c,o){var d={label:0,sent:function(){if(m[0]&1)throw m[1];return m[1]},trys:[],ops:[]},h,u,m,b;return b={next:S(0),throw:S(1),return:S(2)},typeof Symbol=="function"&&(b[Symbol.iterator]=function(){return this}),b;function S(_){return function(O){return p([_,O])}}function p(_){if(h)throw new TypeError("Generator is already executing.");for(;b&&(b=0,_[0]&&(d=0)),d;)try{if(h=1,u&&(m=_[0]&2?u.return:_[0]?u.throw||((m=u.return)&&m.call(u),0):u.next)&&!(m=m.call(u,_[1])).done)return m;switch(u=0,m&&(_=[_[0]&2,m.value]),_[0]){case 0:case 1:m=_;break;case 4:return d.label++,{value:_[1],done:!1};case 5:d.label++,u=_[1],_=[0];continue;case 7:_=d.ops.pop(),d.trys.pop();continue;default:if(m=d.trys,!(m=m.length>0&&m[m.length-1])&&(_[0]===6||_[0]===2)){d=0;continue}if(_[0]===3&&(!m||_[1]>m[0]&&_[1]<m[3])){d.label=_[1];break}if(_[0]===6&&d.label<m[1]){d.label=m[1],m=_;break}if(m&&d.label<m[2]){d.label=m[2],d.ops.push(_);break}m[2]&&d.ops.pop(),d.trys.pop();continue}_=o.call(c,d)}catch(O){_=[6,O],u=0}finally{h=m=0}if(_[0]&5)throw _[1];return{value:_[0]?_[1]:void 0,done:!0}}};Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.FrappeFileUpload=void 0;var s=Zn(),a=function(){function c(o,d,h,u,m,b){this.appURL=o,this.axios=d,this.useToken=h??!1,this.token=u,this.tokenType=m,this.customHeaders=b}return c.prototype.uploadFile=function(o,d,h,u){return u===void 0&&(u="upload_file"),e(this,void 0,void 0,function(){var m,b,S,p,_,O,j,R;return n(this,function(Y){return m=new FormData,o&&m.append("file",o,o.name),b=d.isPrivate,S=d.folder,p=d.file_url,_=d.doctype,O=d.docname,j=d.fieldname,R=d.otherData,b&&m.append("is_private","1"),S&&m.append("folder",S),p&&m.append("file_url",p),_&&O&&(m.append("doctype",_),m.append("docname",O),j&&m.append("fieldname",j)),R&&Object.keys(R).forEach(function(z){var H=R[z];m.append(z,H)}),[2,this.axios.post("/api/method/".concat(u),m,{onUploadProgress:function(z){h&&h(z.loaded,z.total,z)},headers:t(t({},(0,s.getRequestHeaders)(this.useToken,this.tokenType,this.token,this.appURL,this.customHeaders)),{"Content-Type":"multipart/form-data"})}).catch(function(z){var H,I;throw t(t({},z.response.data),{httpStatus:z.response.status,httpStatusText:z.response.statusText,message:(H=z.response.data.message)!==null&&H!==void 0?H:"There was an error while uploading the file.",exception:(I=z.response.data.exception)!==null&&I!==void 0?I:""})})]})})},c}();return Oe.FrappeFileUpload=a,Oe}var ns;function xr(){if(ns)return ct;ns=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.FrappeApp=void 0;var t=is(),e=Kn(),n=Xn(),s=ts(),a=Zn(),c=function(){function o(d,h,u,m){var b,S;this.url=d,this.name=u??"FrappeApp",this.useToken=(b=h==null?void 0:h.useToken)!==null&&b!==void 0?b:!1,this.token=h==null?void 0:h.token,this.tokenType=(S=h==null?void 0:h.type)!==null&&S!==void 0?S:"Bearer",this.customHeaders=m,this.axios=(0,a.getAxiosClient)(this.url,this.useToken,this.token,this.tokenType,this.customHeaders)}return o.prototype.auth=function(){return new t.FrappeAuth(this.url,this.axios,this.useToken,this.token,this.tokenType)},o.prototype.db=function(){return new n.FrappeDB(this.url,this.axios,this.useToken,this.token,this.tokenType)},o.prototype.file=function(){return new s.FrappeFileUpload(this.url,this.axios,this.useToken,this.token,this.tokenType,this.customHeaders)},o.prototype.call=function(){return new e.FrappeCall(this.url,this.axios,this.useToken,this.token,this.tokenType)},o}();return ct.FrappeApp=c,ct}var Ce={},ss;function Rr(){if(ss)return Ce;ss=1;var t=Ce&&Ce.__assign||function(){return t=Object.assign||function(a){for(var c,o=1,d=arguments.length;o<d;o++){c=arguments[o];for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&(a[h]=c[h])}return a},t.apply(this,arguments)},e=Ce&&Ce.__awaiter||function(a,c,o,d){function h(u){return u instanceof o?u:new o(function(m){m(u)})}return new(o||(o=Promise))(function(u,m){function b(_){try{p(d.next(_))}catch(O){m(O)}}function S(_){try{p(d.throw(_))}catch(O){m(O)}}function p(_){_.done?u(_.value):h(_.value).then(b,S)}p((d=d.apply(a,c||[])).next())})},n=Ce&&Ce.__generator||function(a,c){var o={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},d,h,u,m;return m={next:b(0),throw:b(1),return:b(2)},typeof Symbol=="function"&&(m[Symbol.iterator]=function(){return this}),m;function b(p){return function(_){return S([p,_])}}function S(p){if(d)throw new TypeError("Generator is already executing.");for(;m&&(m=0,p[0]&&(o=0)),o;)try{if(d=1,h&&(u=p[0]&2?h.return:p[0]?h.throw||((u=h.return)&&u.call(h),0):h.next)&&!(u=u.call(h,p[1])).done)return u;switch(h=0,u&&(p=[p[0]&2,u.value]),p[0]){case 0:case 1:u=p;break;case 4:return o.label++,{value:p[1],done:!1};case 5:o.label++,h=p[1],p=[0];continue;case 7:p=o.ops.pop(),o.trys.pop();continue;default:if(u=o.trys,!(u=u.length>0&&u[u.length-1])&&(p[0]===6||p[0]===2)){o=0;continue}if(p[0]===3&&(!u||p[1]>u[0]&&p[1]<u[3])){o.label=p[1];break}if(p[0]===6&&o.label<u[1]){o.label=u[1],u=p;break}if(u&&o.label<u[2]){o.label=u[2],o.ops.push(p);break}u[2]&&o.ops.pop(),o.trys.pop();continue}p=c.call(a,o)}catch(_){p=[6,_],h=0}finally{d=u=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}};Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.FrappeAuth=void 0;var s=function(){function a(c,o,d,h,u){this.appURL=c,this.axios=o,this.useToken=d??!1,this.token=h,this.tokenType=u}return a.prototype.loginWithUsernamePassword=function(c){return e(this,void 0,void 0,function(){return n(this,function(o){return[2,this.axios.post("/api/method/login",{usr:c.username,pwd:c.password,otp:c.otp,tmp_id:c.tmp_id,device:c.device}).then(function(d){return d.data}).catch(function(d){var h,u;throw t(t({},d.response.data),{httpStatus:d.response.status,httpStatusText:d.response.statusText,message:(h=d.response.data.message)!==null&&h!==void 0?h:"There was an error while logging in",exception:(u=d.response.data.exception)!==null&&u!==void 0?u:""})})]})})},a.prototype.getLoggedInUser=function(){return e(this,void 0,void 0,function(){return n(this,function(c){return[2,this.axios.get("/api/method/frappe.auth.get_logged_user").then(function(o){return o.data.message}).catch(function(o){var d;throw t(t({},o.response.data),{httpStatus:o.response.status,httpStatusText:o.response.statusText,message:"There was an error while fetching the logged in user",exception:(d=o.response.data.exception)!==null&&d!==void 0?d:""})})]})})},a.prototype.logout=function(){return e(this,void 0,void 0,function(){return n(this,function(c){return[2,this.axios.post("/api/method/logout",{}).then(function(){}).catch(function(o){var d,h;throw t(t({},o.response.data),{httpStatus:o.response.status,httpStatusText:o.response.statusText,message:(d=o.response.data.message)!==null&&d!==void 0?d:"There was an error while logging out",exception:(h=o.response.data.exception)!==null&&h!==void 0?h:""})})]})})},a.prototype.forgetPassword=function(c){return e(this,void 0,void 0,function(){return n(this,function(o){return[2,this.axios.post("/",{cmd:"frappe.core.doctype.user.user.reset_password",user:c}).then(function(){}).catch(function(d){var h,u;throw t(t({},d.response.data),{httpStatus:d.response.status,httpStatusText:d.response.statusText,message:(h=d.response.data.message)!==null&&h!==void 0?h:"There was an error sending password reset email.",exception:(u=d.response.data.exception)!==null&&u!==void 0?u:""})})]})})},a}();return Ce.FrappeAuth=s,Ce}var rs;function is(){return rs||(rs=1,function(t){var e=Ke&&Ke.__createBinding||(Object.create?function(s,a,c,o){o===void 0&&(o=c);var d=Object.getOwnPropertyDescriptor(a,c);(!d||("get"in d?!a.__esModule:d.writable||d.configurable))&&(d={enumerable:!0,get:function(){return a[c]}}),Object.defineProperty(s,o,d)}:function(s,a,c,o){o===void 0&&(o=c),s[o]=a[c]}),n=Ke&&Ke.__exportStar||function(s,a){for(var c in s)c!=="default"&&!Object.prototype.hasOwnProperty.call(a,c)&&e(a,s,c)};Object.defineProperty(t,"__esModule",{value:!0}),n(xr(),t),n(Rr(),t),n(Xn(),t),n(ts(),t),n(Kn(),t)}(Ke)),Ke}var Ar=is(),_t={exports:{}},Qt={};/**
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var os;function kr(){if(os)return Qt;os=1;var t=E;function e(b,S){return b===S&&(b!==0||1/b===1/S)||b!==b&&S!==S}var n=typeof Object.is=="function"?Object.is:e,s=t.useState,a=t.useEffect,c=t.useLayoutEffect,o=t.useDebugValue;function d(b,S){var p=S(),_=s({inst:{value:p,getSnapshot:S}}),O=_[0].inst,j=_[1];return c(function(){O.value=p,O.getSnapshot=S,h(O)&&j({inst:O})},[b,p,S]),a(function(){return h(O)&&j({inst:O}),b(function(){h(O)&&j({inst:O})})},[b]),o(p),p}function h(b){var S=b.getSnapshot;b=b.value;try{var p=S();return!n(b,p)}catch{return!0}}function u(b,S){return S()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:d;return Qt.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:m,Qt}var Zt={};/**
* @license React
* use-sync-external-store-shim.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var as;function Dr(){return as||(as=1,process.env.NODE_ENV!=="production"&&function(){function t(p,_){return p===_&&(p!==0||1/p===1/_)||p!==p&&_!==_}function e(p,_){m||a.startTransition===void 0||(m=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var O=_();if(!b){var j=_();c(O,j)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),b=!0)}j=o({inst:{value:O,getSnapshot:_}});var R=j[0].inst,Y=j[1];return h(function(){R.value=O,R.getSnapshot=_,n(R)&&Y({inst:R})},[p,O,_]),d(function(){return n(R)&&Y({inst:R}),p(function(){n(R)&&Y({inst:R})})},[p]),u(O),O}function n(p){var _=p.getSnapshot;p=p.value;try{var O=_();return!c(p,O)}catch{return!0}}function s(p,_){return _()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=E,c=typeof Object.is=="function"?Object.is:t,o=a.useState,d=a.useEffect,h=a.useLayoutEffect,u=a.useDebugValue,m=!1,b=!1,S=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?s:e;Zt.useSyncExternalStore=a.useSyncExternalStore!==void 0?a.useSyncExternalStore:S,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),Zt}var cs;function Lr(){return cs||(cs=1,process.env.NODE_ENV==="production"?_t.exports=kr():_t.exports=Dr()),_t.exports}var us=Lr();const ls=0,fs=1,hs=2,ds=3;var ps=Object.prototype.hasOwnProperty;function en(t,e){var n,s;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((s=t.length)===e.length)for(;s--&&en(t[s],e[s]););return s===-1}if(!n||typeof t=="object"){s=0;for(n in t)if(ps.call(t,n)&&++s&&!ps.call(e,n)||!(n in e)||!en(t[n],e[n]))return!1;return Object.keys(e).length===s}}return t!==t&&e!==e}const xe=new WeakMap,je=()=>{},ne=je(),St=Object,P=t=>t===ne,_e=t=>typeof t=="function",qe=(t,e)=>({...t,...e}),ms=t=>_e(t.then),tn={},Et={},nn="undefined",ut=typeof window!=nn,sn=typeof document!=nn,Fr=ut&&"Deno"in window,Nr=()=>ut&&typeof window.requestAnimationFrame!=nn,Me=(t,e)=>{const n=xe.get(t);return[()=>!P(e)&&t.get(e)||tn,s=>{if(!P(e)){const a=t.get(e);e in Et||(Et[e]=a),n[5](e,qe(a,s),a||tn)}},n[6],()=>!P(e)&&e in Et?Et[e]:!P(e)&&t.get(e)||tn]};let rn=!0;const Br=()=>rn,[on,an]=ut&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[je,je],Pr=()=>{const t=sn&&document.visibilityState;return P(t)||t!=="hidden"},Ur=t=>(sn&&document.addEventListener("visibilitychange",t),on("focus",t),()=>{sn&&document.removeEventListener("visibilitychange",t),an("focus",t)}),qr=t=>{const e=()=>{rn=!0,t()},n=()=>{rn=!1};return on("online",e),on("offline",n),()=>{an("online",e),an("offline",n)}},Ir={isOnline:Br,isVisible:Pr},jr={initFocus:Ur,initReconnect:qr},ys=!E.useId,lt=!ut||Fr,Mr=t=>Nr()?window.requestAnimationFrame(t):setTimeout(t,1),ft=lt?E.useEffect:E.useLayoutEffect,cn=typeof navigator<"u"&&navigator.connection,gs=!lt&&cn&&(["slow-2g","2g"].includes(cn.effectiveType)||cn.saveData),Tt=new WeakMap,un=(t,e)=>St.prototype.toString.call(t)===`[object ${e}]`;let Vr=0;const ln=t=>{const e=typeof t,n=un(t,"Date"),s=un(t,"RegExp"),a=un(t,"Object");let c,o;if(St(t)===t&&!n&&!s){if(c=Tt.get(t),c)return c;if(c=++Vr+"~",Tt.set(t,c),Array.isArray(t)){for(c="@",o=0;o<t.length;o++)c+=ln(t[o])+",";Tt.set(t,c)}if(a){c="#";const d=St.keys(t).sort();for(;!P(o=d.pop());)P(t[o])||(c+=o+":"+ln(t[o])+",");Tt.set(t,c)}}else c=n?t.toJSON():e=="symbol"?t.toString():e=="string"?JSON.stringify(t):""+t;return c},tt=t=>{if(_e(t))try{t=t()}catch{t=""}const e=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?ln(t):"",[t,e]};let $r=0;const fn=()=>++$r;async function ws(...t){const[e,n,s,a]=t,c=qe({populateCache:!0,throwOnError:!0},typeof a=="boolean"?{revalidate:a}:a||{});let o=c.populateCache;const d=c.rollbackOnError;let h=c.optimisticData;const u=S=>typeof d=="function"?d(S):d!==!1,m=c.throwOnError;if(_e(n)){const S=n,p=[],_=e.keys();for(const O of _)!/^\$(inf|sub)\$/.test(O)&&S(e.get(O)._k)&&p.push(O);return Promise.all(p.map(b))}return b(n);async function b(S){const[p]=tt(S);if(!p)return;const[_,O]=Me(e,p),[j,R,Y,z]=xe.get(e),H=()=>{const G=j[p];return(_e(c.revalidate)?c.revalidate(_().data,S):c.revalidate!==!1)&&(delete Y[p],delete z[p],G&&G[0])?G[0](hs).then(()=>_().data):_().data};if(t.length<3)return H();let I=s,J;const Fe=fn();R[p]=[Fe,0];const B=!P(h),de=_(),V=de.data,ae=de._c,be=P(ae)?V:ae;if(B&&(h=_e(h)?h(be,V):h,O({data:h,_c:be})),_e(I))try{I=I(be)}catch(G){J=G}if(I&&ms(I))if(I=await I.catch(G=>{J=G}),Fe!==R[p][0]){if(J)throw J;return I}else J&&B&&u(J)&&(o=!0,O({data:be,_c:ne}));if(o&&!J)if(_e(o)){const G=o(I,be);O({data:G,error:ne,_c:ne})}else O({data:I,error:ne,_c:ne});if(R[p][1]=fn(),Promise.resolve(H()).then(()=>{O({_c:ne})}),J){if(m)throw J;return}return I}}const bs=(t,e)=>{for(const n in t)t[n][0]&&t[n][0](e)},vs=(t,e)=>{if(!xe.has(t)){const n=qe(jr,e),s=Object.create(null),a=ws.bind(ne,t);let c=je;const o=Object.create(null),d=(m,b)=>{const S=o[m]||[];return o[m]=S,S.push(b),()=>S.splice(S.indexOf(b),1)},h=(m,b,S)=>{t.set(m,b);const p=o[m];if(p)for(const _ of p)_(b,S)},u=()=>{if(!xe.has(t)&&(xe.set(t,[s,Object.create(null),Object.create(null),Object.create(null),a,h,d]),!lt)){const m=n.initFocus(setTimeout.bind(ne,bs.bind(ne,s,ls))),b=n.initReconnect(setTimeout.bind(ne,bs.bind(ne,s,fs)));c=()=>{m&&m(),b&&b(),xe.delete(t)}}};return u(),[t,a,u,c]}return[t,xe.get(t)[4]]},Hr=(t,e,n,s,a)=>{const c=n.errorRetryCount,o=a.retryCount,d=~~((Math.random()+.5)*(1<<(o<8?o:8)))*n.errorRetryInterval;!P(c)&&o>c||setTimeout(s,d,a)},Wr=en,[ht,zr]=vs(new Map),_s=qe({onLoadingSlow:je,onSuccess:je,onError:je,onErrorRetry:Hr,onDiscarded:je,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:gs?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:gs?5e3:3e3,compare:Wr,isPaused:()=>!1,cache:ht,mutate:zr,fallback:{}},Ir),Ss=(t,e)=>{const n=qe(t,e);if(e){const{use:s,fallback:a}=t,{use:c,fallback:o}=e;s&&c&&(n.use=s.concat(c)),a&&o&&(n.fallback=qe(a,o))}return n},hn=E.createContext({}),Jr=t=>{const{value:e}=t,n=E.useContext(hn),s=_e(e),a=E.useMemo(()=>s?e(n):e,[s,n,e]),c=E.useMemo(()=>s?a:Ss(n,a),[s,n,a]),o=a&&a.provider,d=E.useRef(ne);o&&!d.current&&(d.current=vs(o(c.cache||ht),a));const h=d.current;return h&&(c.cache=h[0],c.mutate=h[1]),ft(()=>{if(h)return h[2]&&h[2](),h[3]},[]),E.createElement(hn.Provider,qe(t,{value:c}))},Es="$inf$",Ts=ut&&window.__SWR_DEVTOOLS_USE__,Kr=Ts?window.__SWR_DEVTOOLS_USE__:[],Gr=()=>{Ts&&(window.__SWR_DEVTOOLS_REACT__=E)},Os=t=>_e(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],Cs=()=>qe(_s,E.useContext(hn)),dt=(t,e)=>{const[n,s]=tt(t),[,,,a]=xe.get(ht);if(a[n])return a[n];const c=e(s);return a[n]=c,c},Xr=t=>(e,n,s)=>t(e,n&&((...c)=>{const[o]=tt(e),[,,,d]=xe.get(ht);if(o.startsWith(Es))return n(...c);const h=d[o];return P(h)?n(...c):(delete d[o],h)}),s),Yr=Kr.concat(Xr),Qr=t=>function(...n){const s=Cs(),[a,c,o]=Os(n),d=Ss(s,o);let h=t;const{use:u}=d,m=(u||[]).concat(Yr);for(let b=m.length;b--;)h=m[b](h);return h(a,c||d.fetcher||null,d)},Zr=(t,e,n)=>{const s=e[t]||(e[t]=[]);return s.push(n),()=>{const a=s.indexOf(n);a>=0&&(s[a]=s[s.length-1],s.pop())}},ei=(t,e)=>(...n)=>{const[s,a,c]=Os(n),o=(c.use||[]).concat(e);return t(s,a,{...c,use:o})};Gr();const dn=E.use||(t=>{switch(t.status){case"pending":throw t;case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t.status="pending",t.then(e=>{t.status="fulfilled",t.value=e},e=>{t.status="rejected",t.reason=e}),t}}),pn={dedupe:!0},ti=(t,e,n)=>{const{cache:s,compare:a,suspense:c,fallbackData:o,revalidateOnMount:d,revalidateIfStale:h,refreshInterval:u,refreshWhenHidden:m,refreshWhenOffline:b,keepPreviousData:S}=n,[p,_,O,j]=xe.get(s),[R,Y]=tt(t),z=E.useRef(!1),H=E.useRef(!1),I=E.useRef(R),J=E.useRef(e),Fe=E.useRef(n),B=()=>Fe.current,de=()=>B().isVisible()&&B().isOnline(),[V,ae,be,G]=Me(s,R),ce=E.useRef({}).current,ue=P(o)?P(n.fallback)?ne:n.fallback[R]:o,Ne=($,M)=>{for(const le in ce){const K=le;if(K==="data"){if(!a($[K],M[K])&&(!P($[K])||!a(Xe,M[K])))return!1}else if(M[K]!==$[K])return!1}return!0},Q=E.useMemo(()=>{const $=!R||!e?!1:P(d)?B().isPaused()||c?!1:h!==!1:d,M=fe=>{const Ae=qe(fe);return delete Ae._k,$?{isValidating:!0,isLoading:!0,...Ae}:Ae},le=V(),K=G(),ve=M(le),We=le===K?ve:M(K);let re=ve;return[()=>{const fe=M(V());return Ne(fe,re)?(re.data=fe.data,re.isLoading=fe.isLoading,re.isValidating=fe.isValidating,re.error=fe.error,re):(re=fe,fe)},()=>We]},[s,R]),ge=us.useSyncExternalStore(E.useCallback($=>be(R,(M,le)=>{Ne(le,M)||$()}),[s,R]),Q[0],Q[1]),Ve=!z.current,gt=p[R]&&p[R].length>0,Be=ge.data,se=P(Be)?ue&&ms(ue)?dn(ue):ue:Be,$e=ge.error,He=E.useRef(se),Xe=S?P(Be)?P(He.current)?se:He.current:Be:se,rt=gt&&!P($e)?!1:Ve&&!P(d)?d:B().isPaused()?!1:c?P(se)?!1:h:P(se)||h,Pt=!!(R&&e&&Ve&&rt),Nn=P(ge.isValidating)?Pt:ge.isValidating,Ut=P(ge.isLoading)?Pt:ge.isLoading,Ye=E.useCallback(async $=>{const M=J.current;if(!R||!M||H.current||B().isPaused())return!1;let le,K,ve=!0;const We=$||{},re=!O[R]||!We.dedupe,fe=()=>ys?!H.current&&R===I.current&&z.current:R===I.current,Ae={isValidating:!1,isLoading:!1},v=()=>{ae(Ae)},F=()=>{const me=O[R];me&&me[1]===K&&delete O[R]},bt={isValidating:!0};P(V().data)&&(bt.isLoading=!0);try{if(re&&(ae(bt),n.loadingTimeout&&P(V().data)&&setTimeout(()=>{ve&&fe()&&B().onLoadingSlow(R,n)},n.loadingTimeout),O[R]=[M(Y),fn()]),[le,K]=O[R],le=await le,re&&setTimeout(F,n.dedupingInterval),!O[R]||O[R][1]!==K)return re&&fe()&&B().onDiscarded(R),!1;Ae.error=ne;const me=_[R];if(!P(me)&&(K<=me[0]||K<=me[1]||me[1]===0))return v(),re&&fe()&&B().onDiscarded(R),!1;const ke=V().data;Ae.data=a(ke,le)?ke:le,re&&fe()&&B().onSuccess(le,R,n)}catch(me){F();const ke=B(),{shouldRetryOnError:Qe}=ke;ke.isPaused()||(Ae.error=me,re&&fe()&&(ke.onError(me,R,ke),(Qe===!0||_e(Qe)&&Qe(me))&&(!B().revalidateOnFocus||!B().revalidateOnReconnect||de())&&ke.onErrorRetry(me,R,ke,qt=>{const it=p[R];it&&it[0]&&it[0](ds,qt)},{retryCount:(We.retryCount||0)+1,dedupe:!0})))}return ve=!1,v(),!0},[R,s]),wt=E.useCallback((...$)=>ws(s,I.current,...$),[]);if(ft(()=>{J.current=e,Fe.current=n,P(Be)||(He.current=Be)}),ft(()=>{if(!R)return;const $=Ye.bind(ne,pn);let M=0;B().revalidateOnFocus&&(M=Date.now()+B().focusThrottleInterval);const K=Zr(R,p,(ve,We={})=>{if(ve==ls){const re=Date.now();B().revalidateOnFocus&&re>M&&de()&&(M=re+B().focusThrottleInterval,$())}else if(ve==fs)B().revalidateOnReconnect&&de()&&$();else{if(ve==hs)return Ye();if(ve==ds)return Ye(We)}});return H.current=!1,I.current=R,z.current=!0,ae({_k:Y}),rt&&(P(se)||lt?$():Mr($)),()=>{H.current=!0,K()}},[R]),ft(()=>{let $;function M(){const K=_e(u)?u(V().data):u;K&&$!==-1&&($=setTimeout(le,K))}function le(){!V().error&&(m||B().isVisible())&&(b||B().isOnline())?Ye(pn).then(M):M()}return M(),()=>{$&&(clearTimeout($),$=-1)}},[u,m,b,R]),E.useDebugValue(Xe),c&&P(se)&&R){if(!ys&<)throw new Error("Fallback data is required when using Suspense in SSR.");J.current=e,Fe.current=n,H.current=!1;const $=j[R];if(!P($)){const M=wt($);dn(M)}if(P($e)){const M=Ye(pn);P(Xe)||(M.status="fulfilled",M.value=!0),dn(M)}else throw $e}return{mutate:wt,get data(){return ce.data=!0,Xe},get error(){return ce.error=!0,$e},get isValidating(){return ce.isValidating=!0,Nn},get isLoading(){return ce.isLoading=!0,Ut}}},ni=St.defineProperty(Jr,"defaultValue",{value:_s}),Ge=Qr(ti),si=void 0,mn=Object,xs=t=>t===si,ri=t=>typeof t=="function",Ot=new WeakMap,yn=(t,e)=>mn.prototype.toString.call(t)===`[object ${e}]`;let ii=0;const gn=t=>{const e=typeof t,n=yn(t,"Date"),s=yn(t,"RegExp"),a=yn(t,"Object");let c,o;if(mn(t)===t&&!n&&!s){if(c=Ot.get(t),c)return c;if(c=++ii+"~",Ot.set(t,c),Array.isArray(t)){for(c="@",o=0;o<t.length;o++)c+=gn(t[o])+",";Ot.set(t,c)}if(a){c="#";const d=mn.keys(t).sort();for(;!xs(o=d.pop());)xs(t[o])||(c+=o+":"+gn(t[o])+",");Ot.set(t,c)}}else c=n?t.toJSON():e=="symbol"?t.toString():e=="string"?JSON.stringify(t):""+t;return c},oi=t=>{if(ri(t))try{t=t()}catch{t=""}const e=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?gn(t):"",[t,e]},ai=t=>oi(t?t(0,null):null)[0],wn=Promise.resolve(),ci=ei(Ge,t=>(e,n,s)=>{const a=E.useRef(!1),{cache:c,initialSize:o=1,revalidateAll:d=!1,persistSize:h=!1,revalidateFirstPage:u=!0,revalidateOnMount:m=!1,parallel:b=!1}=s,[,,,S]=xe.get(ht);let p;try{p=ai(e),p&&(p=Es+p)}catch{}const[_,O,j]=Me(c,p),R=E.useCallback(()=>P(_()._l)?o:_()._l,[c,p,o]);us.useSyncExternalStore(E.useCallback(B=>p?j(p,()=>{B()}):()=>{},[c,p]),R,R);const Y=E.useCallback(()=>{const B=_()._l;return P(B)?o:B},[p,o]),z=E.useRef(Y());ft(()=>{if(!a.current){a.current=!0;return}p&&O({_l:h?z.current:Y()})},[p,c]);const H=m&&!a.current,I=t(p,async B=>{const de=_()._i,V=_()._r;O({_r:ne});const ae=[],be=Y(),[G]=Me(c,B),ce=G().data,ue=[];let Ne=null;for(let Q=0;Q<be;++Q){const[ge,Ve]=tt(e(Q,b?null:Ne));if(!ge)break;const[gt,Be]=Me(c,ge);let se=gt().data;const $e=d||de||P(se)||u&&!Q&&!P(ce)||H||ce&&!P(ce[Q])&&!s.compare(ce[Q],se);if(n&&(typeof V=="function"?V(se,Ve):$e)){const He=async()=>{if(!(ge in S))se=await n(Ve);else{const rt=S[ge];delete S[ge],se=await rt}Be({data:se,_k:Ve}),ae[Q]=se};b?ue.push(He):await He()}else ae[Q]=se;b||(Ne=se)}return b&&await Promise.all(ue.map(Q=>Q())),O({_i:ne}),ae},s),J=E.useCallback(function(B,de){const V=typeof de=="boolean"?{revalidate:de}:de||{},ae=V.revalidate!==!1;return p?(ae&&(P(B)?O({_i:!0,_r:V.revalidate}):O({_i:!1,_r:V.revalidate})),arguments.length?I.mutate(B,{...V,revalidate:ae}):I.mutate()):wn},[p,c]),Fe=E.useCallback(B=>{if(!p)return wn;const[,de]=Me(c,p);let V;if(_e(B)?V=B(Y()):typeof B=="number"&&(V=B),typeof V!="number")return wn;de({_l:V}),z.current=V;const ae=[],[be]=Me(c,p);let G=null;for(let ce=0;ce<V;++ce){const[ue]=tt(e(ce,G)),[Ne]=Me(c,ue),Q=ue?Ne().data:ne;if(P(Q))return J(be().data);ae.push(Q),G=Q}return J(ae)},[p,c,J,Y]);return{size:Y(),setSize:Fe,mutate:J,get data(){return I.data},get error(){return I.error},get isValidating(){return I.isValidating},get isLoading(){return I.isLoading}}}),Le=Object.create(null);Le.open="0",Le.close="1",Le.ping="2",Le.pong="3",Le.message="4",Le.upgrade="5",Le.noop="6";const Ct=Object.create(null);Object.keys(Le).forEach(t=>{Ct[Le[t]]=t});const bn={type:"error",data:"parser error"},Rs=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",As=typeof ArrayBuffer=="function",ks=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t&&t.buffer instanceof ArrayBuffer,vn=({type:t,data:e},n,s)=>Rs&&e instanceof Blob?n?s(e):Ds(e,s):As&&(e instanceof ArrayBuffer||ks(e))?n?s(e):Ds(new Blob([e]),s):s(Le[t]+(e||"")),Ds=(t,e)=>{const n=new FileReader;return n.onload=function(){const s=n.result.split(",")[1];e("b"+(s||""))},n.readAsDataURL(t)};function Ls(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}let _n;function ui(t,e){if(Rs&&t.data instanceof Blob)return t.data.arrayBuffer().then(Ls).then(e);if(As&&(t.data instanceof ArrayBuffer||ks(t.data)))return e(Ls(t.data));vn(t,!1,n=>{_n||(_n=new TextEncoder),e(_n.encode(n))})}const Fs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pt=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let t=0;t<Fs.length;t++)pt[Fs.charCodeAt(t)]=t;const li=t=>{let e=t.length*.75,n=t.length,s,a=0,c,o,d,h;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);const u=new ArrayBuffer(e),m=new Uint8Array(u);for(s=0;s<n;s+=4)c=pt[t.charCodeAt(s)],o=pt[t.charCodeAt(s+1)],d=pt[t.charCodeAt(s+2)],h=pt[t.charCodeAt(s+3)],m[a++]=c<<2|o>>4,m[a++]=(o&15)<<4|d>>2,m[a++]=(d&3)<<6|h&63;return u},fi=typeof ArrayBuffer=="function",Sn=(t,e)=>{if(typeof t!="string")return{type:"message",data:Ns(t,e)};const n=t.charAt(0);return n==="b"?{type:"message",data:hi(t.substring(1),e)}:Ct[n]?t.length>1?{type:Ct[n],data:t.substring(1)}:{type:Ct[n]}:bn},hi=(t,e)=>{if(fi){const n=li(t);return Ns(n,e)}else return{base64:!0,data:t}},Ns=(t,e)=>{switch(e){case"blob":return t instanceof Blob?t:new Blob([t]);case"arraybuffer":default:return t instanceof ArrayBuffer?t:t.buffer}},Bs="",di=(t,e)=>{const n=t.length,s=new Array(n);let a=0;t.forEach((c,o)=>{vn(c,!1,d=>{s[o]=d,++a===n&&e(s.join(Bs))})})},pi=(t,e)=>{const n=t.split(Bs),s=[];for(let a=0;a<n.length;a++){const c=Sn(n[a],e);if(s.push(c),c.type==="error")break}return s};function mi(){return new TransformStream({transform(t,e){ui(t,n=>{const s=n.length;let a;if(s<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,s);else if(s<65536){a=new Uint8Array(3);const c=new DataView(a.buffer);c.setUint8(0,126),c.setUint16(1,s)}else{a=new Uint8Array(9);const c=new DataView(a.buffer);c.setUint8(0,127),c.setBigUint64(1,BigInt(s))}t.data&&typeof t.data!="string"&&(a[0]|=128),e.enqueue(a),e.enqueue(n)})}})}let En;function xt(t){return t.reduce((e,n)=>e+n.length,0)}function Rt(t,e){if(t[0].length===e)return t.shift();const n=new Uint8Array(e);let s=0;for(let a=0;a<e;a++)n[a]=t[0][s++],s===t[0].length&&(t.shift(),s=0);return t.length&&s<t[0].length&&(t[0]=t[0].slice(s)),n}function yi(t,e){En||(En=new TextDecoder);const n=[];let s=0,a=-1,c=!1;return new TransformStream({transform(o,d){for(n.push(o);;){if(s===0){if(xt(n)<1)break;const h=Rt(n,1);c=(h[0]&128)===128,a=h[0]&127,a<126?s=3:a===126?s=1:s=2}else if(s===1){if(xt(n)<2)break;const h=Rt(n,2);a=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),s=3}else if(s===2){if(xt(n)<8)break;const h=Rt(n,8),u=new DataView(h.buffer,h.byteOffset,h.length),m=u.getUint32(0);if(m>Math.pow(2,21)-1){d.enqueue(bn);break}a=m*Math.pow(2,32)+u.getUint32(4),s=3}else{if(xt(n)<a)break;const h=Rt(n,a);d.enqueue(Sn(c?h:En.decode(h),e)),s=0}if(a===0||a>t){d.enqueue(bn);break}}}})}const Ps=4;function ee(t){if(t)return gi(t)}function gi(t){for(var e in ee.prototype)t[e]=ee.prototype[e];return t}ee.prototype.on=ee.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},ee.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},ee.prototype.off=ee.prototype.removeListener=ee.prototype.removeAllListeners=ee.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+t],this;for(var s,a=0;a<n.length;a++)if(s=n[a],s===e||s.fn===e){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+t],this},ee.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),n=this._callbacks["$"+t],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(n){n=n.slice(0);for(var s=0,a=n.length;s<a;++s)n[s].apply(this,e)}return this},ee.prototype.emitReserved=ee.prototype.emit,ee.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},ee.prototype.hasListeners=function(t){return!!this.listeners(t).length};const Se=typeof self<"u"?self:typeof window<"u"?window:Function("return this")();function Us(t,...e){return e.reduce((n,s)=>(t.hasOwnProperty(s)&&(n[s]=t[s]),n),{})}const wi=Se.setTimeout,bi=Se.clearTimeout;function At(t,e){e.useNativeTimers?(t.setTimeoutFn=wi.bind(Se),t.clearTimeoutFn=bi.bind(Se)):(t.setTimeoutFn=Se.setTimeout.bind(Se),t.clearTimeoutFn=Se.clearTimeout.bind(Se))}const vi=1.33;function _i(t){return typeof t=="string"?Si(t):Math.ceil((t.byteLength||t.size)*vi)}function Si(t){let e=0,n=0;for(let s=0,a=t.length;s<a;s++)e=t.charCodeAt(s),e<128?n+=1:e<2048?n+=2:e<55296||e>=57344?n+=3:(s++,n+=4);return n}function Ei(t){let e="";for(let n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function Ti(t){let e={},n=t.split("&");for(let s=0,a=n.length;s<a;s++){let c=n[s].split("=");e[decodeURIComponent(c[0])]=decodeURIComponent(c[1])}return e}class Oi extends Error{constructor(e,n,s){super(e),this.description=n,this.context=s,this.type="TransportError"}}class Tn extends ee{constructor(e){super(),this.writable=!1,At(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,n,s){return super.emitReserved("error",new Oi(e,n,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const n=Sn(e,this.socket.binaryType);this.onPacket(n)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,n={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const n=Ei(e);return n.length?"?"+n:""}}const qs="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),On=64,Ci={};let Is=0,kt=0,js;function Ms(t){let e="";do e=qs[t%On]+e,t=Math.floor(t/On);while(t>0);return e}function Vs(){const t=Ms(+new Date);return t!==js?(Is=0,js=t):t+"."+Ms(Is++)}for(;kt<On;kt++)Ci[qs[kt]]=kt;let $s=!1;try{$s=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const xi=$s;function Hs(t){const e=t.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||xi))return new XMLHttpRequest}catch{}if(!e)try{return new Se[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}function ma(){}function Ri(){}const Ai=function(){return new Hs({xdomain:!1}).responseType!=null}();class ki extends Tn{constructor(e){if(super(e),this.polling=!1,typeof location<"u"){const s=location.protocol==="https:";let a=location.port;a||(a=s?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||a!==e.port}const n=e&&e.forceBase64;this.supportsBinary=Ai&&!n,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const n=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let s=0;this.polling&&(s++,this.once("pollComplete",function(){--s||n()})),this.writable||(s++,this.once("drain",function(){--s||n()}))}else n()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const n=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};pi(e,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this.polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,di(e,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=Vs()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(e,n)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new nt(this.uri(),e)}doWrite(e,n){const s=this.request({method:"POST",data:e});s.on("success",n),s.on("error",(a,c)=>{this.onError("xhr post error",a,c)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(n,s)=>{this.onError("xhr poll error",n,s)}),this.pollXhr=e}}let nt=class Xt extends ee{constructor(e,n){super(),At(this,n),this.opts=n,this.method=n.method||"GET",this.uri=e,this.data=n.data!==void 0?n.data:null,this.create()}create(){var e;const n=Us(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this.opts.xd;const s=this.xhr=new Hs(n);try{s.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let a in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(a)&&s.setRequestHeader(a,this.opts.extraHeaders[a])}}catch{}if(this.method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(e=this.opts.cookieJar)===null||e===void 0||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(s.timeout=this.opts.requestTimeout),s.onreadystatechange=()=>{var a;s.readyState===3&&((a=this.opts.cookieJar)===null||a===void 0||a.parseCookies(s)),s.readyState===4&&(s.status===200||s.status===1223?this.onLoad():this.setTimeoutFn(()=>{this.onError(typeof s.status=="number"?s.status:0)},0))},s.send(this.data)}catch(a){this.setTimeoutFn(()=>{this.onError(a)},0);return}typeof document<"u"&&(this.index=Xt.requestsCount++,Xt.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.xhr.onreadystatechange=Ri,e)try{this.xhr.abort()}catch{}typeof document<"u"&&delete Xt.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}};if(nt.requestsCount=0,nt.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Ws);else if(typeof addEventListener=="function"){const t="onpagehide"in Se?"pagehide":"unload";addEventListener(t,Ws,!1)}}function Ws(){for(let t in nt.requests)nt.requests.hasOwnProperty(t)&&nt.requests[t].abort()}const Cn=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,n)=>n(e,0),Dt=Se.WebSocket||Se.MozWebSocket,zs=!0,Di="arraybuffer",Js=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Li extends Tn{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),n=this.opts.protocols,s=Js?{}:Us(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=zs&&!Js?n?new Dt(e,n):new Dt(e):new Dt(e,n,s)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const s=e[n],a=n===e.length-1;vn(s,this.supportsBinary,c=>{const o={};try{zs&&this.ws.send(c)}catch{}a&&Cn(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=Vs()),this.supportsBinary||(n.b64=1),this.createUri(e,n)}check(){return!!Dt}}class Fi extends Tn{get name(){return"webtransport"}doOpen(){typeof WebTransport=="function"&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this.transport.ready.then(()=>{this.transport.createBidirectionalStream().then(e=>{const n=yi(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(n).getReader(),a=mi();a.readable.pipeTo(e.writable),this.writer=a.writable.getWriter();const c=()=>{s.read().then(({done:d,value:h})=>{d||(this.onPacket(h),c())}).catch(d=>{})};c();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then(()=>this.onOpen())})}))}write(e){this.writable=!1;for(let n=0;n<e.length;n++){const s=e[n],a=n===e.length-1;this.writer.write(s).then(()=>{a&&Cn(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this.transport)===null||e===void 0||e.close()}}const Ni={websocket:Li,webtransport:Fi,polling:ki},Bi=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Pi=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function xn(t){if(t.length>2e3)throw"URI too long";const e=t,n=t.indexOf("["),s=t.indexOf("]");n!=-1&&s!=-1&&(t=t.substring(0,n)+t.substring(n,s).replace(/:/g,";")+t.substring(s,t.length));let a=Bi.exec(t||""),c={},o=14;for(;o--;)c[Pi[o]]=a[o]||"";return n!=-1&&s!=-1&&(c.source=e,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c.pathNames=Ui(c,c.path),c.queryKey=qi(c,c.query),c}function Ui(t,e){const n=/\/{2,9}/g,s=e.replace(n,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function qi(t,e){const n={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,a,c){a&&(n[a]=c)}),n}let Ks=class at extends ee{constructor(e,n={}){super(),this.binaryType=Di,this.writeBuffer=[],e&&typeof e=="object"&&(n=e,e=null),e?(e=xn(e),n.hostname=e.host,n.secure=e.protocol==="https"||e.protocol==="wss",n.port=e.port,e.query&&(n.query=e.query)):n.host&&(n.hostname=xn(n.host).host),At(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=n.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ti(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,typeof addEventListener=="function"&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const n=Object.assign({},this.opts.query);n.EIO=Ps,n.transport=e,this.id&&(n.sid=this.id);const s=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new Ni[e](s)}open(){let e;if(this.opts.rememberUpgrade&&at.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1)e="websocket";else if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}else e=this.transports[0];this.readyState="opening";try{e=this.createTransport(e)}catch{this.transports.shift(),this.open();return}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",n=>this.onClose("transport close",n))}probe(e){let n=this.createTransport(e),s=!1;at.priorWebsocketSuccess=!1;const a=()=>{s||(n.send([{type:"ping",data:"probe"}]),n.once("packet",b=>{if(!s)if(b.type==="pong"&&b.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;at.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(m(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const S=new Error("probe error");S.transport=n.name,this.emitReserved("upgradeError",S)}}))};function c(){s||(s=!0,m(),n.close(),n=null)}const o=b=>{const S=new Error("probe error: "+b);S.transport=n.name,c(),this.emitReserved("upgradeError",S)};function d(){o("transport closed")}function h(){o("socket closed")}function u(b){n&&b.name!==n.name&&c()}const m=()=>{n.removeListener("open",a),n.removeListener("error",o),n.removeListener("close",d),this.off("close",h),this.off("upgrading",u)};n.once("open",a),n.once("error",o),n.once("close",d),this.once("close",h),this.once("upgrading",u),this.upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||n.open()},200):n.open()}onOpen(){if(this.readyState="open",at.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade){let e=0;const n=this.upgrades.length;for(;e<n;e++)this.probe(this.upgrades[e])}}onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const n=new Error("server error");n.code=e.data,this.onError(n);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let s=0;s<this.writeBuffer.length;s++){const a=this.writeBuffer[s].data;if(a&&(n+=_i(a)),s>0&&n>this.maxPayload)return this.writeBuffer.slice(0,s);n+=2}return this.writeBuffer}write(e,n,s){return this.sendPacket("message",e,n,s),this}send(e,n,s){return this.sendPacket("message",e,n,s),this}sendPacket(e,n,s,a){if(typeof n=="function"&&(a=n,n=void 0),typeof s=="function"&&(a=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const c={type:e,data:n,options:s};this.emitReserved("packetCreate",c),this.writeBuffer.push(c),a&&this.once("flush",a),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),e()},s=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}onError(e){at.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,n){(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")&&(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),typeof removeEventListener=="function"&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,n),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const n=[];let s=0;const a=e.length;for(;s<a;s++)~this.transports.indexOf(e[s])&&n.push(e[s]);return n}};Ks.protocol=Ps;function Ii(t,e="",n){let s=t;n=n||typeof location<"u"&&location,t==null&&(t=n.protocol+"//"+n.host),typeof t=="string"&&(t.charAt(0)==="/"&&(t.charAt(1)==="/"?t=n.protocol+t:t=n.host+t),/^(https?|wss?):\/\//.test(t)||(typeof n<"u"?t=n.protocol+"//"+t:t="https://"+t),s=xn(t)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const c=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+c+":"+s.port+e,s.href=s.protocol+"://"+c+(n&&n.port===s.port?"":":"+s.port),s}const ji=typeof ArrayBuffer=="function",Mi=t=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer,Gs=Object.prototype.toString,Vi=typeof Blob=="function"||typeof Blob<"u"&&Gs.call(Blob)==="[object BlobConstructor]",$i=typeof File=="function"||typeof File<"u"&&Gs.call(File)==="[object FileConstructor]";function Rn(t){return ji&&(t instanceof ArrayBuffer||Mi(t))||Vi&&t instanceof Blob||$i&&t instanceof File}function Lt(t,e){if(!t||typeof t!="object")return!1;if(Array.isArray(t)){for(let n=0,s=t.length;n<s;n++)if(Lt(t[n]))return!0;return!1}if(Rn(t))return!0;if(t.toJSON&&typeof t.toJSON=="function"&&arguments.length===1)return Lt(t.toJSON(),!0);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&Lt(t[n]))return!0;return!1}function Hi(t){const e=[],n=t.data,s=t;return s.data=An(n,e),s.attachments=e.length,{packet:s,buffers:e}}function An(t,e){if(!t)return t;if(Rn(t)){const n={_placeholder:!0,num:e.length};return e.push(t),n}else if(Array.isArray(t)){const n=new Array(t.length);for(let s=0;s<t.length;s++)n[s]=An(t[s],e);return n}else if(typeof t=="object"&&!(t instanceof Date)){const n={};for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[s]=An(t[s],e));return n}return t}function Wi(t,e){return t.data=kn(t.data,e),delete t.attachments,t}function kn(t,e){if(!t)return t;if(t&&t._placeholder===!0){if(typeof t.num=="number"&&t.num>=0&&t.num<e.length)return e[t.num];throw new Error("illegal attachments")}else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]=kn(t[n],e);else if(typeof t=="object")for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=kn(t[n],e));return t}const zi=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],Ji=5;var q;(function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"})(q||(q={}));class Ki{constructor(e){this.replacer=e}encode(e){return(e.type===q.EVENT||e.type===q.ACK)&&Lt(e)?this.encodeAsBinary({type:e.type===q.EVENT?q.BINARY_EVENT:q.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let n=""+e.type;return(e.type===q.BINARY_EVENT||e.type===q.BINARY_ACK)&&(n+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(n+=e.nsp+","),e.id!=null&&(n+=e.id),e.data!=null&&(n+=JSON.stringify(e.data,this.replacer)),n}encodeAsBinary(e){const n=Hi(e),s=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(s),a}}function Xs(t){return Object.prototype.toString.call(t)==="[object Object]"}class Dn extends ee{constructor(e){super(),this.reviver=e}add(e){let n;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(e);const s=n.type===q.BINARY_EVENT;s||n.type===q.BINARY_ACK?(n.type=s?q.EVENT:q.ACK,this.reconstructor=new Gi(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Rn(e)||e.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(e),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let n=0;const s={type:Number(e.charAt(0))};if(q[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===q.BINARY_EVENT||s.type===q.BINARY_ACK){const c=n+1;for(;e.charAt(++n)!=="-"&&n!=e.length;);const o=e.substring(c,n);if(o!=Number(o)||e.charAt(n)!=="-")throw new Error("Illegal attachments");s.attachments=Number(o)}if(e.charAt(n+1)==="/"){const c=n+1;for(;++n&&!(e.charAt(n)===","||n===e.length););s.nsp=e.substring(c,n)}else s.nsp="/";const a=e.charAt(n+1);if(a!==""&&Number(a)==a){const c=n+1;for(;++n;){const o=e.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===e.length)break}s.id=Number(e.substring(c,n+1))}if(e.charAt(++n)){const c=this.tryParse(e.substr(n));if(Dn.isPayloadValid(s.type,c))s.data=c;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,n){switch(e){case q.CONNECT:return Xs(n);case q.DISCONNECT:return n===void 0;case q.CONNECT_ERROR:return typeof n=="string"||Xs(n);case q.EVENT:case q.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&zi.indexOf(n[0])===-1);case q.ACK:case q.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Gi{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const n=Wi(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Xi=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Dn,Encoder:Ki,get PacketType(){return q},protocol:Ji},Symbol.toStringTag,{value:"Module"}));function Re(t,e,n){return t.on(e,n),function(){t.off(e,n)}}const Yi=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Ys extends ee{constructor(e,n,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=n,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Re(e,"open",this.onopen.bind(this)),Re(e,"packet",this.onpacket.bind(this)),Re(e,"error",this.onerror.bind(this)),Re(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...n){if(Yi.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(n.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const s={type:q.EVENT,data:n};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const o=this.ids++,d=n.pop();this._registerAckCallback(o,d),s.id=o}const a=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!a||!this.connected)||(this.connected?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(e,n){var s;const a=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(a===void 0){this.acks[e]=n;return}const c=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let o=0;o<this.sendBuffer.length;o++)this.sendBuffer[o].id===e&&this.sendBuffer.splice(o,1);n.call(this,new Error("operation has timed out"))},a);this.acks[e]=(...o)=>{this.io.clearTimeoutFn(c),n.apply(this,[null,...o])}}emitWithAck(e,...n){const s=this.flags.timeout!==void 0||this._opts.ackTimeout!==void 0;return new Promise((a,c)=>{n.push((o,d)=>s?o?c(o):a(d):a(o)),this.emit(e,...n)})}_addToQueue(e){let n;typeof e[e.length-1]=="function"&&(n=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((a,...c)=>s!==this._queue[0]?void 0:(a!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...c)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!e||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:q.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,n)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case q.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case q.EVENT:case q.BINARY_EVENT:this.onevent(e);break;case q.ACK:case q.BINARY_ACK:this.onack(e);break;case q.DISCONNECT:this.ondisconnect();break;case q.CONNECT_ERROR:this.destroy();const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){const n=e.data||[];e.id!=null&&n.push(this.ack(e.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const s of n)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const n=this;let s=!1;return function(...a){s||(s=!0,n.packet({type:q.ACK,id:e,data:a}))}}onack(e){const n=this.acks[e.id];typeof n=="function"&&(n.apply(this,e.data),delete this.acks[e.id])}onconnect(e,n){this.id=e,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:q.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const n=this._anyListeners;for(let s=0;s<n.length;s++)if(e===n[s])return n.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const n=this._anyOutgoingListeners;for(let s=0;s<n.length;s++)if(e===n[s])return n.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const s of n)s.apply(this,e.data)}}}function st(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}st.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=(Math.floor(e*10)&1)==0?t-n:t+n}return Math.min(t,this.max)|0},st.prototype.reset=function(){this.attempts=0},st.prototype.setMin=function(t){this.ms=t},st.prototype.setMax=function(t){this.max=t},st.prototype.setJitter=function(t){this.jitter=t};class Ln extends ee{constructor(e,n){var s;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(n=e,e=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,At(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((s=n.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new st({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=e;const a=n.parser||Xi;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var n;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(n=this.backoff)===null||n===void 0||n.setMin(e),this)}randomizationFactor(e){var n;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(n=this.backoff)===null||n===void 0||n.setJitter(e),this)}reconnectionDelayMax(e){var n;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(n=this.backoff)===null||n===void 0||n.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new Ks(this.uri,this.opts);const n=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const a=Re(n,"open",function(){s.onopen(),e&&e()}),c=d=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",d),e?e(d):this.maybeReconnectOnOpen()},o=Re(n,"error",c);if(this._timeout!==!1){const d=this._timeout,h=this.setTimeoutFn(()=>{a(),c(new Error("timeout")),n.close()},d);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(a),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Re(e,"ping",this.onping.bind(this)),Re(e,"data",this.ondata.bind(this)),Re(e,"error",this.onerror.bind(this)),Re(e,"close",this.onclose.bind(this)),Re(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(n){this.onclose("parse error",n)}}ondecoded(e){Cn(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,n){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new Ys(this,e,n),this.nsps[e]=s),s}_destroy(e){const n=Object.keys(this.nsps);for(const s of n)if(this.nsps[s].active)return;this._close()}_packet(e){const n=this.encoder.encode(e);for(let s=0;s<n.length;s++)this.engine.write(n[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,n){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(a=>{a?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",a)):e.onreconnect()}))},n);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const mt={};function Ft(t,e){typeof t=="object"&&(e=t,t=void 0),e=e||{};const n=Ii(t,e.path||"/socket.io"),s=n.source,a=n.id,c=n.path,o=mt[a]&&c in mt[a].nsps,d=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let h;return d?h=new Ln(s,e):(mt[a]||(mt[a]=new Ln(s,e)),h=mt[a]),n.query&&!e.query&&(e.query=n.queryKey),h.socket(n.path,e)}Object.assign(Ft,{Manager:Ln,Socket:Ys,io:Ft,connect:Ft});class Qi{constructor(e,n,s,a){Je(this,"socket_port");Je(this,"host");Je(this,"port");Je(this,"protocol");Je(this,"url");Je(this,"site_name");Je(this,"socket");var c,o,d,h;if(this.socket_port=s??"9000",this.host=(c=window.location)==null?void 0:c.hostname,this.port=(o=window.location)!=null&&o.port?`:${this.socket_port}`:"",this.protocol=((d=window.location)==null?void 0:d.protocol)==="https:"?"https":"http",e){let u=new URL(e);u.port="",s?(u.port=s,this.url=u.toString()):this.url=u.toString()}else this.url=`${this.protocol}://${this.host}${this.port}/`;n&&(this.url=`${this.url}${n}`),this.site_name=n,this.socket=Ft(`${this.url}`,{withCredentials:!0,secure:this.protocol==="https",extraHeaders:a&&a.useToken===!0?{Authorization:`${a.type} ${(h=a.token)==null?void 0:h.call(a)}`}:{}})}}const X=E.createContext(null),Zi=({url:t="",tokenParams:e,socketPort:n,swrConfig:s,siteName:a,enableSocket:c=!0,children:o,customHeaders:d})=>{const h=E.useMemo(()=>{const u=new Ar.FrappeApp(t,e,void 0,d);return{url:t,tokenParams:e,app:u,auth:u.auth(),db:u.db(),call:u.call(),file:u.file(),socket:c?new Qi(t,a,n,e).socket:void 0,enableSocket:c,socketPort:n}},[t,e,n,c,d]);return ye.jsx(X.Provider,{value:h,children:ye.jsx(ni,{value:s,children:o})})},eo=t=>{const{url:e,auth:n,tokenParams:s}=E.useContext(X),[a,c]=E.useState(),o=E.useCallback(()=>{const _=document.cookie.split(";").find(O=>O.trim().startsWith("user_id="));if(_){const O=_.split("=")[1];c(O&&O!=="Guest"?O:null)}else c(null)},[]);E.useEffect(()=>{s&&s.useToken?c(null):o()},[]);const{data:d,error:h,isLoading:u,isValidating:m,mutate:b}=Ge(()=>s&&s.useToken||a?`${e}/api/method/frappe.auth.get_logged_user`:null,()=>n.getLoggedInUser(),{onError:()=>{c(null)},shouldRetryOnError:!1,revalidateOnFocus:!1,...t}),S=E.useCallback(async _=>n.loginWithUsernamePassword(_).then(O=>(o(),O)),[]),p=E.useCallback(async()=>n.logout().then(()=>b(null)).then(()=>c(null)),[]);return{isLoading:a===void 0||u,currentUser:d,isValidating:m,error:h,login:S,logout:p,updateCurrentUser:b,getUserCookie:o}},yt=(t,e,n)=>{let s=`${e}/api/resource/`;return n?s+=`${t}/${n}`:s+=`${t}`,s},to=(t,e,n,s)=>{const{url:a,db:c}=E.useContext(X);return Ge(n===void 0?yt(t,a,e):n,()=>c.getDoc(t,e),s)},no=(t,e,n,s)=>{const{db:a,url:c}=E.useContext(X),o=n===void 0?yt(t,c,e):n;return E.useCallback(()=>{dt(o,()=>a.getDoc(t,e))},[o,t,e])},Fn=t=>{var n,s;let e="";if(t!=null&&t.fields&&(e+="fields="+JSON.stringify(t==null?void 0:t.fields)+"&"),t!=null&&t.filters&&(e+="filters="+JSON.stringify(t==null?void 0:t.filters)+"&"),t!=null&&t.orFilters&&(e+="or_filters="+JSON.stringify(t==null?void 0:t.orFilters)+"&"),t!=null&&t.limit_start&&(e+="limit_start="+JSON.stringify(t==null?void 0:t.limit_start)+"&"),t!=null&&t.limit&&(e+="limit="+JSON.stringify(t==null?void 0:t.limit)+"&"),t!=null&&t.groupBy&&(e+="group_by="+String(t.groupBy)+"&"),t!=null&&t.orderBy){const a=`${String((n=t.orderBy)==null?void 0:n.field)} ${((s=t.orderBy)==null?void 0:s.order)??"asc"}`;e+="order_by="+a+"&"}return t!=null&&t.asDict&&(e+="as_dict="+t.asDict),e},so=(t,e,n,s)=>{const{url:a,db:c}=E.useContext(X);return Ge(n===void 0?`${yt(t,a)}?${Fn(e)}`:n,()=>c.getDocList(t,e),s)},ro=(t,e,n)=>{const{db:s,url:a}=E.useContext(X),c=n===void 0?`${yt(t,a)}?${Fn(e)}`:n;return E.useCallback(()=>{dt(c,()=>s.getDocList(t,e))},[c,t,e])},io=()=>{const{db:t}=E.useContext(X),[e,n]=E.useState(!1),[s,a]=E.useState(null),[c,o]=E.useState(!1),d=E.useCallback(()=>{n(!1),a(null),o(!1)},[]);return{createDoc:E.useCallback(async(u,m)=>(a(null),o(!1),n(!0),t.createDoc(u,m).then(b=>(n(!1),o(!0),b)).catch(b=>{throw n(!1),o(!1),a(b),b})),[]),loading:e,error:s,isCompleted:c,reset:d}},oo=()=>{const{db:t}=E.useContext(X),[e,n]=E.useState(!1),[s,a]=E.useState(null),[c,o]=E.useState(!1),d=E.useCallback(()=>{n(!1),a(null),o(!1)},[]);return{updateDoc:E.useCallback(async(u,m,b)=>(a(null),o(!1),n(!0),t.updateDoc(u,m,b).then(S=>(n(!1),o(!0),S)).catch(S=>{throw n(!1),o(!1),a(S),S})),[]),loading:e,error:s,reset:d,isCompleted:c}},ao=()=>{const{db:t}=E.useContext(X),[e,n]=E.useState(!1),[s,a]=E.useState(null),[c,o]=E.useState(!1),d=E.useCallback(()=>{n(!1),a(null),o(!1)},[]);return{deleteDoc:E.useCallback(async(u,m)=>(a(null),o(!1),n(!0),t.deleteDoc(u,m).then(b=>(n(!1),o(!0),b)).catch(b=>{throw n(!1),o(!1),a(b),b})),[]),loading:e,error:s,reset:d,isCompleted:c}};function Nt(t){const e=[];for(let n in t)e.push(encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e.join("&")}const co=(t,e,n=!1,s=!1,a,c)=>{const{url:o,db:d}=E.useContext(X);return Ge(a===void 0?(()=>{const m=Nt(n?{doctype:t,filters:e??[],cache:n,debug:s}:{doctype:t,filters:e??[],debug:s});return`${o}/api/method/frappe.client.get_count?${m}`})():a,()=>d.getCount(t,e,n,s),c)},uo=(t,e,n=!1,s=!1,a)=>{const{db:c,url:o}=E.useContext(X),d=a===void 0?`${o}/api/method/frappe.client.get_count?${Nt({doctype:t,filters:e??[],cache:n,debug:s})}`:a;return E.useCallback(()=>{dt(d,()=>c.getCount(t,e,!1,!1))},[d,t,e])},Qs=(t,e,n,s,a="GET")=>{const{call:c}=E.useContext(X),o=Nt(e??{}),d=`${t}?${o}`;return{...Ge(n===void 0?d:n,a==="GET"?()=>c.get(t,e):()=>c.post(t,e),s)}},lo=(t,e,n,s="GET")=>{const{call:a}=E.useContext(X),c=Nt(e??{}),o=`${t}?${c}`;return E.useCallback(()=>{dt(n??o,s==="GET"?()=>a.get(t,e):()=>a.post(t,e))},[o,t,e,n])},fo=t=>{const{call:e}=E.useContext(X),[n,s]=E.useState(null),[a,c]=E.useState(!1),[o,d]=E.useState(null),[h,u]=E.useState(!1),m=E.useCallback(()=>{s(null),c(!1),d(null),u(!1)},[]);return{call:E.useCallback(async S=>(d(null),u(!1),c(!0),s(null),e.post(t,S).then(p=>(s(p),c(!1),u(!0),p)).catch(p=>{throw c(!1),u(!1),d(p),p})),[]),result:n,loading:a,error:o,reset:m,isCompleted:h}},ho=t=>{const{call:e}=E.useContext(X),[n,s]=E.useState(null),[a,c]=E.useState(!1),[o,d]=E.useState(null),[h,u]=E.useState(!1),m=E.useCallback(()=>{s(null),c(!1),d(null),u(!1)},[]);return{call:E.useCallback(async S=>(d(null),u(!1),c(!0),s(null),e.put(t,S).then(p=>(s(p),c(!1),u(!0),p)).catch(p=>{throw c(!1),u(!1),d(p),p})),[]),result:n,loading:a,error:o,reset:m,isCompleted:h}},po=t=>{const{call:e}=E.useContext(X),[n,s]=E.useState(null),[a,c]=E.useState(!1),[o,d]=E.useState(null),[h,u]=E.useState(!1),m=E.useCallback(()=>{s(null),c(!1),d(null),u(!1)},[]);return{call:E.useCallback(async S=>(d(null),u(!1),c(!0),s(null),e.delete(t,S).then(p=>(s(p),c(!1),u(!0),p)).catch(p=>{throw c(!1),u(!1),d(p),p})),[]),result:n,loading:a,error:o,reset:m,isCompleted:h}},mo=()=>{const{file:t}=E.useContext(X),[e,n]=E.useState(0),[s,a]=E.useState(!1),[c,o]=E.useState(null),[d,h]=E.useState(!1),u=E.useCallback(async(b,S,p)=>(m(),a(!0),t.uploadFile(b,S,(_,O)=>{O&&n(Math.round(_/O*100))},p).then(_=>(h(!0),n(100),a(!1),_.data.message)).catch(_=>{throw console.error(_),o(_),a(!1),_})),[]),m=E.useCallback(()=>{n(0),a(!1),o(null),h(!1)},[]);return{upload:u,progress:e,loading:s,isCompleted:d,error:c,reset:m}},yo=(t,e,n=[],s=20,a=250)=>{const c=go(e,a);return Qs("frappe.desk.search.search_link",{doctype:t,page_length:s,txt:c,filters:JSON.stringify(n??[])})},go=(t,e)=>{const[n,s]=E.useState(t);return E.useEffect(()=>{const a=setTimeout(()=>{s(t)},e);return()=>{clearTimeout(a)}},[t,e]),n},Bt=(t,e)=>{const{socket:n}=E.useContext(X);E.useEffect(()=>{n===void 0&&console.warn("Socket is not enabled. Please enable socket in FrappeProvider.");let s=n==null?void 0:n.on(t,e);return()=>{s==null||s.off(t)}},[t,e])},wo=(t,e,n,s=!0)=>{const{socket:a}=E.useContext(X),[c,o]=E.useState([]);E.useEffect(()=>(a===void 0&&console.warn("Socket is not enabled. Please enable socket in FrappeProvider."),a==null||a.emit("doc_subscribe",t,e),a==null||a.io.on("reconnect",()=>{a==null||a.emit("doc_subscribe",t,e)}),s&&(a==null||a.emit("doc_open",t,e)),()=>{a==null||a.emit("doc_unsubscribe",t,e),s&&(a==null||a.emit("doc_close",t,e))}),[t,e,s]),Bt("doc_update",n);const d=E.useCallback(()=>{a==null||a.emit("doc_open",t,e)},[t,e]),h=E.useCallback(()=>{a==null||a.emit("doc_close",t,e)},[t,e]),u=E.useCallback(m=>{m.doctype===t&&m.docname===e&&o(m.users)},[t,e]);return Bt("doc_viewers",u),{viewers:c,emitDocOpen:d,emitDocClose:h}},bo=(t,e)=>{const{socket:n}=E.useContext(X);E.useEffect(()=>(n===void 0&&console.warn("Socket is not enabled. Please enable socket in FrappeProvider."),n==null||n.emit("doctype_subscribe",t),n==null||n.io.on("reconnect",()=>{n==null||n.emit("doctype_subscribe",t)}),()=>{n==null||n.emit("doctype_unsubscribe",t)}),[t]),Bt("list_update",e)};N.FrappeContext=X,N.FrappeProvider=Zi,N.getDocListQueryString=Fn,N.getRequestURL=yt,N.preload=dt,N.useFrappeAuth=eo,N.useFrappeCreateDoc=io,N.useFrappeDeleteCall=po,N.useFrappeDeleteDoc=ao,N.useFrappeDocTypeEventListener=bo,N.useFrappeDocumentEventListener=wo,N.useFrappeEventListener=Bt,N.useFrappeFileUpload=mo,N.useFrappeGetCall=Qs,N.useFrappeGetDoc=to,N.useFrappeGetDocCount=co,N.useFrappeGetDocList=so,N.useFrappePostCall=fo,N.useFrappePrefetchCall=lo,N.useFrappePrefetchDoc=no,N.useFrappePrefetchDocCount=uo,N.useFrappePrefetchDocList=ro,N.useFrappePutCall=ho,N.useFrappeUpdateDoc=oo,N.useSWR=Ge,N.useSWRConfig=Cs,N.useSWRInfinite=ci,N.useSearch=yo,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});