@nvwa-app/sdk-uniapp 0.4.16 → 0.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var de=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var kt=Object.prototype.hasOwnProperty;var Mt=(e,t)=>{for(var r in t)de(e,r,{get:t[r],enumerable:!0})},Ft=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Bt(t))!kt.call(e,n)&&n!==r&&de(e,n,{get:()=>t[n],enumerable:!(s=Ct(t,n))||s.enumerable});return e};var qt=e=>Ft(de({},"__esModule",{value:!0}),e);var gs={};Mt(gs,{default:()=>fe,httpClient:()=>he,localStorage:()=>Ut,polyfill:()=>xt});module.exports=qt(gs);var Ht=Object.create,le=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Wt=Object.getOwnPropertyNames,Vt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty,Ue=(e,t)=>()=>(e&&(t=e(e=0)),t),C=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Kt=(e,t)=>{for(var r in t)le(e,r,{get:t[r],enumerable:!0})},De=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Wt(t))!zt.call(e,n)&&n!==r&&le(e,n,{get:()=>t[n],enumerable:!(s=Gt(t,n))||s.enumerable});return e},Jt=(e,t,r)=>(r=e!=null?Ht(Vt(e)):{},De(t||!e||!e.__esModule?le(r,"default",{value:e,enumerable:!0}):r,e)),H=e=>De(le({},"__esModule",{value:!0}),e),p=Ue(()=>{"use strict"}),B={};Kt(B,{__addDisposableResource:()=>at,__assign:()=>K,__asyncDelegator:()=>Qe,__asyncGenerator:()=>Xe,__asyncValues:()=>Ze,__await:()=>q,__awaiter:()=>We,__classPrivateFieldGet:()=>st,__classPrivateFieldIn:()=>ot,__classPrivateFieldSet:()=>nt,__createBinding:()=>J,__decorate:()=>Be,__disposeResources:()=>it,__esDecorate:()=>Me,__exportStar:()=>ze,__extends:()=>Le,__generator:()=>Ve,__importDefault:()=>rt,__importStar:()=>tt,__makeTemplateObject:()=>et,__metadata:()=>Ge,__param:()=>ke,__propKey:()=>qe,__read:()=>we,__rest:()=>Ce,__rewriteRelativeImportExtension:()=>lt,__runInitializers:()=>Fe,__setFunctionName:()=>He,__spread:()=>Ke,__spreadArray:()=>Ye,__spreadArrays:()=>Je,__values:()=>ae,default:()=>ht});function Le(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");re(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Ce(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(r[s[n]]=e[s[n]]);return r}function Be(e,t,r,s){var n=arguments.length,o=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(n<3?a(o):n>3?a(t,r,o):a(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function ke(e,t){return function(r,s){t(r,s,e)}}function Me(e,t,r,s,n,o){function a(b){if(b!==void 0&&typeof b!="function")throw new TypeError("Function expected");return b}for(var l=s.kind,u=l==="getter"?"get":l==="setter"?"set":"value",i=!t&&e?s.static?e:e.prototype:null,c=t||(i?Object.getOwnPropertyDescriptor(i,s.name):{}),h,m=!1,f=r.length-1;f>=0;f--){var y={};for(var v in s)y[v]=v==="access"?{}:s[v];for(var v in s.access)y.access[v]=s.access[v];y.addInitializer=function(b){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(b||null))};var g=(0,r[f])(l==="accessor"?{get:c.get,set:c.set}:c[u],y);if(l==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(h=a(g.get))&&(c.get=h),(h=a(g.set))&&(c.set=h),(h=a(g.init))&&n.unshift(h)}else(h=a(g))&&(l==="field"?n.unshift(h):c[u]=h)}i&&Object.defineProperty(i,s.name,c),m=!0}function Fe(e,t,r){for(var s=arguments.length>2,n=0;n<t.length;n++)r=s?t[n].call(e,r):t[n].call(e);return s?r:void 0}function qe(e){return typeof e=="symbol"?e:"".concat(e)}function He(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function Ge(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function We(e,t,r,s){function n(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function l(c){try{i(s.next(c))}catch(h){a(h)}}function u(c){try{i(s.throw(c))}catch(h){a(h)}}function i(c){c.done?o(c.value):n(c.value).then(l,u)}i((s=s.apply(e,t||[])).next())})}function Ve(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,n,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(c){return u([i,c])}}function u(i){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(s=1,n&&(o=i[0]&2?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,n=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],n=0}finally{s=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ze(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&J(t,e,r)}function ae(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function we(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),n,o=[],a;try{for(;(t===void 0||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(l){a={error:l}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return o}function Ke(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(we(arguments[t]));return e}function Je(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),n=0,t=0;t<r;t++)for(var o=arguments[t],a=0,l=o.length;a<l;a++,n++)s[n]=o[a];return s}function Ye(e,t,r){if(r||arguments.length===2)for(var s=0,n=t.length,o;s<n;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return e.concat(o||Array.prototype.slice.call(t))}function q(e){return this instanceof q?(this.v=e,this):new q(e)}function Xe(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(f){return function(y){return Promise.resolve(y).then(f,h)}}function l(f,y){s[f]&&(n[f]=function(v){return new Promise(function(g,b){o.push([f,v,g,b])>1||u(f,v)})},y&&(n[f]=y(n[f])))}function u(f,y){try{i(s[f](y))}catch(v){m(o[0][3],v)}}function i(f){f.value instanceof q?Promise.resolve(f.value.v).then(c,h):m(o[0][2],f)}function c(f){u("next",f)}function h(f){u("throw",f)}function m(f,y){f(y),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Qe(e){var t,r;return t={},s("next"),s("throw",function(n){throw n}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(n,o){t[n]=e[n]?function(a){return(r=!r)?{value:q(e[n](a)),done:!1}:o?o(a):a}:o}}function Ze(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof ae=="function"?ae(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(o){r[o]=e[o]&&function(a){return new Promise(function(l,u){a=e[o](a),n(l,u,a.done,a.value)})}}function n(o,a,l,u){Promise.resolve(u).then(function(i){o({value:i,done:l})},a)}}function et(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function tt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=se(e),s=0;s<r.length;s++)r[s]!=="default"&&J(t,e,r[s]);return ut(t,e),t}function rt(e){return e&&e.__esModule?e:{default:e}}function st(e,t,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function nt(e,t,r,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r}function ot(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function at(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(n=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");n&&(s=function(){try{n.call(this)}catch(o){return Promise.reject(o)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}function it(e){function t(o){e.error=e.hasError?new ct(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var r,s=0;function n(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(n);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(o).then(n,function(a){return t(a),n()})}else s|=1}catch(a){t(a)}if(s===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return n()}function lt(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,n,o,a){return s?t?".jsx":".js":n&&(!o||!a)?r:n+o+"."+a.toLowerCase()+"js"}):e}var re,K,J,ut,se,ct,ht,G=Ue(()=>{"use strict";p(),re=function(e,t){return re=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[n]=s[n])},re(e,t)},K=function(){return K=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},K.apply(this,arguments)},J=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),ut=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},se=function(e){return se=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},se(e)},ct=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s},ht={__extends:Le,__assign:K,__rest:Ce,__decorate:Be,__param:ke,__esDecorate:Me,__runInitializers:Fe,__propKey:qe,__setFunctionName:He,__metadata:Ge,__awaiter:We,__generator:Ve,__createBinding:J,__exportStar:ze,__values:ae,__read:we,__spread:Ke,__spreadArrays:Je,__spreadArray:Ye,__await:q,__asyncGenerator:Xe,__asyncDelegator:Qe,__asyncValues:Ze,__makeTemplateObject:et,__importStar:tt,__importDefault:rt,__classPrivateFieldGet:st,__classPrivateFieldSet:nt,__classPrivateFieldIn:ot,__addDisposableResource:at,__disposeResources:it,__rewriteRelativeImportExtension:lt}}),ft=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),pt=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),H(B)),r=t.__importDefault(ft()),s=class{constructor(n){var o,a;this.shouldThrowOnError=!1,this.method=n.method,this.url=n.url,this.headers=new Headers(n.headers),this.schema=n.schema,this.body=n.body,this.shouldThrowOnError=(o=n.shouldThrowOnError)!==null&&o!==void 0?o:!1,this.signal=n.signal,this.isMaybeSingle=(a=n.isMaybeSingle)!==null&&a!==void 0?a:!1,n.fetch?this.fetch=n.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(n,o){return this.headers=new Headers(this.headers),this.headers.set(n,o),this}then(n,o){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let a=this.fetch,l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var i,c,h,m;let f=null,y=null,v=null,g=u.status,b=u.statusText;if(u.ok){if(this.method!=="HEAD"){let d=await u.text();d===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text")?y=d:y=JSON.parse(d))}let T=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),S=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");T&&S&&S.length>1&&(v=parseInt(S[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(f={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,v=null,g=406,b="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{let T=await u.text();try{f=JSON.parse(T),Array.isArray(f)&&u.status===404&&(y=[],f=null,g=200,b="OK")}catch{u.status===404&&T===""?(g=204,b="No Content"):f={message:T}}if(f&&this.isMaybeSingle&&!((m=f?.details)===null||m===void 0)&&m.includes("0 rows")&&(f=null,g=200,b="OK"),f&&this.shouldThrowOnError)throw new r.default(f)}return{error:f,data:y,count:v,status:g,statusText:b}});return this.shouldThrowOnError||(l=l.catch(u=>{var i,c,h;return{error:{message:`${(i=u?.name)!==null&&i!==void 0?i:"FetchError"}: ${u?.message}`,details:`${(c=u?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(h=u?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(n,o)}returns(){return this}overrideTypes(){return this}};e.default=s}),dt=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),H(B)),r=t.__importDefault(pt()),s=class extends r.default{select(n){let o=!1,a=(n??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(n,{ascending:o=!0,nullsFirst:a,foreignTable:l,referencedTable:u=l}={}){let i=u?`${u}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${n}.${o?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(n,{foreignTable:o,referencedTable:a=o}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${n}`),this}range(n,o,{foreignTable:a,referencedTable:l=a}={}){let u=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(u,`${n}`),this.url.searchParams.set(i,`${o-n+1}`),this}abortSignal(n){return this.signal=n,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:n=!1,verbose:o=!1,settings:a=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[n?"analyze":null,o?"verbose":null,a?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),m=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${m}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(n){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${n}`),this}};e.default=s}),_e=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),H(B)),r=t.__importDefault(dt()),s=new RegExp("[,()]"),n=class extends r.default{eq(o,a){return this.url.searchParams.append(o,`eq.${a}`),this}neq(o,a){return this.url.searchParams.append(o,`neq.${a}`),this}gt(o,a){return this.url.searchParams.append(o,`gt.${a}`),this}gte(o,a){return this.url.searchParams.append(o,`gte.${a}`),this}lt(o,a){return this.url.searchParams.append(o,`lt.${a}`),this}lte(o,a){return this.url.searchParams.append(o,`lte.${a}`),this}like(o,a){return this.url.searchParams.append(o,`like.${a}`),this}likeAllOf(o,a){return this.url.searchParams.append(o,`like(all).{${a.join(",")}}`),this}likeAnyOf(o,a){return this.url.searchParams.append(o,`like(any).{${a.join(",")}}`),this}ilike(o,a){return this.url.searchParams.append(o,`ilike.${a}`),this}ilikeAllOf(o,a){return this.url.searchParams.append(o,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(o,a){return this.url.searchParams.append(o,`ilike(any).{${a.join(",")}}`),this}is(o,a){return this.url.searchParams.append(o,`is.${a}`),this}in(o,a){let l=Array.from(new Set(a)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(o,`in.(${l})`),this}contains(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cs.{${a.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(a)}`),this}containedBy(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cd.{${a.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(a)}`),this}rangeGt(o,a){return this.url.searchParams.append(o,`sr.${a}`),this}rangeGte(o,a){return this.url.searchParams.append(o,`nxl.${a}`),this}rangeLt(o,a){return this.url.searchParams.append(o,`sl.${a}`),this}rangeLte(o,a){return this.url.searchParams.append(o,`nxr.${a}`),this}rangeAdjacent(o,a){return this.url.searchParams.append(o,`adj.${a}`),this}overlaps(o,a){return typeof a=="string"?this.url.searchParams.append(o,`ov.${a}`):this.url.searchParams.append(o,`ov.{${a.join(",")}}`),this}textSearch(o,a,{config:l,type:u}={}){let i="";u==="plain"?i="pl":u==="phrase"?i="ph":u==="websearch"&&(i="w");let c=l===void 0?"":`(${l})`;return this.url.searchParams.append(o,`${i}fts${c}.${a}`),this}match(o){return Object.entries(o).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(o,a,l){return this.url.searchParams.append(o,`not.${a}.${l}`),this}or(o,{foreignTable:a,referencedTable:l=a}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${o})`),this}filter(o,a,l){return this.url.searchParams.append(o,`${a}.${l}`),this}};e.default=n}),mt=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),H(B)),r=t.__importDefault(_e()),s=class{constructor(n,{headers:o={},schema:a,fetch:l}){this.url=n,this.headers=new Headers(o),this.schema=a,this.fetch=l}select(n,o){let{head:a=!1,count:l}=o??{},u=a?"HEAD":"GET",i=!1,c=(n??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",c),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(n,{count:o,defaultToNull:a=!0}={}){var l;let u="POST";if(o&&this.headers.append("Prefer",`count=${o}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let i=n.reduce((c,h)=>c.concat(Object.keys(h)),[]);if(i.length>0){let c=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(n,{onConflict:o,ignoreDuplicates:a=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let h=n.reduce((m,f)=>m.concat(Object.keys(f)),[]);if(h.length>0){let m=[...new Set(h)].map(f=>`"${f}"`);this.url.searchParams.set("columns",m.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(n,{count:o}={}){var a;let l="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:n}={}){var o;let a="DELETE";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};e.default=s}),Yt=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),H(B)),r=t.__importDefault(mt()),s=t.__importDefault(_e()),n=class yt{constructor(a,{headers:l={},schema:u,fetch:i}={}){this.url=a,this.headers=new Headers(l),this.schemaName=u,this.fetch=i}from(a){let l=new URL(`${this.url}/${a}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new yt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let m,f=new URL(`${this.url}/rpc/${a}`),y;u||i?(m=u?"HEAD":"GET",Object.entries(l).filter(([g,b])=>b!==void 0).map(([g,b])=>[g,Array.isArray(b)?`{${b.join(",")}}`:`${b}`]).forEach(([g,b])=>{f.searchParams.append(g,b)})):(m="POST",y=l);let v=new Headers(this.headers);return c&&v.set("Prefer",`count=${c}`),new s.default({method:m,url:f,headers:v,schema:this.schemaName,body:y,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=n}),Xt=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),H(B)),r=t.__importDefault(Yt());e.PostgrestClient=r.default;var s=t.__importDefault(mt());e.PostgrestQueryBuilder=s.default;var n=t.__importDefault(_e());e.PostgrestFilterBuilder=n.default;var o=t.__importDefault(dt());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(pt());e.PostgrestBuilder=a.default;var l=t.__importDefault(ft());e.PostgrestError=l.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:n.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var Qt=Object.defineProperty,Zt=Object.defineProperties,er=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,tr=Object.prototype.hasOwnProperty,rr=Object.prototype.propertyIsEnumerable,Pe=(e,t,r)=>t in e?Qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,j=(e,t)=>{for(var r in t||(t={}))tr.call(t,r)&&Pe(e,r,t[r]);if(Re)for(var r of Re(t))rr.call(t,r)&&Pe(e,r,t[r]);return e},x=(e,t)=>Zt(e,er(t)),sr=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},nr=async(e,t)=>{var r,s,n,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((s=c.hooks)==null?void 0:s.onRequest),i.onResponse.push((n=c.hooks)==null?void 0:n.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},Ae=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},or=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function ar(e){if(typeof e=="number")return new Ae({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Ae(e);case"exponential":return new or(e);default:throw new Error("Invalid retry strategy")}}var ir=async e=>{let t={},r=async s=>typeof s=="function"?await s():s;if(e?.auth){if(e.auth.type==="Bearer"){let s=await r(e.auth.token);if(!s)return t;t.authorization=`Bearer ${s}`}else if(e.auth.type==="Basic"){let s=r(e.auth.username),n=r(e.auth.password);if(!s||!n)return t;t.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(e.auth.type==="Custom"){let s=r(e.auth.value);if(!s)return t;t.authorization=`${r(e.auth.prefix)} ${s}`}}return t},lr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function ur(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let s=t.split(";").shift()||"";return lr.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function cr(e){try{return JSON.parse(e),!0}catch{return!1}}function gt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function $e(e){try{return JSON.parse(e)}catch{return e}}function je(e){return typeof e=="function"}function hr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&je(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&je(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function fr(e){let t=new Headers(e?.headers),r=await ir(e);for(let[s,n]of Object.entries(r||{}))t.set(s,n);if(!t.has("content-type")){let s=pr(e?.body);s&&t.set("content-type",s)}return t}function pr(e){return gt(e)?"application/json":null}function dr(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(gt(e.body)&&!t.has("content-type")){for(let[r,s]of Object.entries(e?.body))s instanceof Date&&(e.body[r]=s.toISOString());return JSON.stringify(e.body)}return e.body}function mr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let s=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return bt.includes(s)?s.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function yr(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var gr=class vt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,vt.prototype)}};async function ne(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new gr(r.issues);return r.value}var bt=["get","post","put","patch","delete"],vr=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var s,n,o,a;let l=((n=(s=e.plugins)==null?void 0:s.find(u=>{var i;return(i=u.schema)!=null&&i.config?t.startsWith(u.schema.config.baseURL||"")||t.startsWith(u.schema.config.prefix||""):!1}))==null?void 0:n.schema)||e.schema;if(l){let u=t;(o=l.config)!=null&&o.prefix&&u.startsWith(l.config.prefix)&&(u=u.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&u.startsWith(l.config.baseURL)&&(u=u.replace(l.config.baseURL,""));let i=l.schema[u];if(i){let c=x(j({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=x(j({},c),{body:i.input?await ne(i.input,r?.body):r?.body,params:i.params?await ne(i.params,r?.params):r?.params,query:i.query?await ne(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),br=e=>{async function t(r,s){let n=x(j(j({},e),s),{plugins:[...e?.plugins||[],vr(e||{})]});if(e?.catchAllError)try{return await ye(r,n)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await ye(r,n)}return t};function wr(e,t){let{baseURL:r,params:s,query:n}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];bt.includes(c)&&(e=e.replace(`@${c}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(n||{}))h!=null&&u.set(c,String(h));if(s)if(Array.isArray(s)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,m]of c.entries()){let f=s[h];a=a.replace(m,f)}}else for(let[c,h]of Object.entries(s))a=a.replace(`:${c}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=u.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var ye=async(e,t)=>{var r,s,n,o,a,l,u,i;let{hooks:c,url:h,options:m}=await nr(e,t),f=hr(m),y=new AbortController,v=(r=m.signal)!=null?r:y.signal,g=wr(h,m),b=dr(m),T=await fr(m),S=mr(h,m),d=x(j({},m),{url:g,headers:T,body:b,method:S,signal:v});for(let R of c.onRequest)if(R){let E=await R(d);E instanceof Object&&(d=E)}("pipeTo"in d&&typeof d.pipeTo=="function"||typeof((s=t?.body)==null?void 0:s.pipe)=="function")&&("duplex"in d||(d.duplex="half"));let{clearTimeout:L}=yr(m,y),_=await f(d.url,d);L();let Te={response:_,request:d};for(let R of c.onResponse)if(R){let E=await R(x(j({},Te),{response:(n=t?.hookOptions)!=null&&n.cloneResponse?_.clone():_}));E instanceof Response?_=E:E instanceof Object&&(_=E.response)}if(_.ok){if(d.method==="HEAD")return{data:"",error:null};let R=ur(_),E={data:"",response:_,request:d};if(R==="json"||R==="text"){let k=await _.text(),M=await((o=d.jsonParser)!=null?o:$e)(k);E.data=M}else E.data=await _[R]();d?.output&&d.output&&!d.disableValidation&&(E.data=await ne(d.output,E.data));for(let k of c.onSuccess)k&&await k(x(j({},E),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?E.data:{data:E.data,error:null}}let Dt=(l=t?.jsonParser)!=null?l:$e,Q=await _.text(),Se=cr(Q),pe=Se?await Dt(Q):null,Lt={response:_,responseText:Q,request:d,error:x(j({},pe),{status:_.status,statusText:_.statusText})};for(let R of c.onError)R&&await R(x(j({},Lt),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let R=ar(t.retry),E=(i=t.retryAttempt)!=null?i:0;if(await R.shouldAttemptRetry(E,_)){for(let M of c.onRetry)M&&await M(Te);let k=R.getDelay(E);return await new Promise(M=>setTimeout(M,k)),await ye(e,x(j({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new sr(_.status,_.statusText,Se?pe:Q);return{data:null,error:x(j({},pe),{status:_.status,statusText:_.statusText})}};p();p();var oe=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?oe:globalThis),A=new Proxy(oe,{get(e,t){return W()[t]??oe[t]},has(e,t){let r=W();return t in r||t in oe},set(e,t,r){let s=W(!0);return s[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=W(!0);return delete r[t],!0},ownKeys(){let e=W(!0);return Object.keys(e)}}),bs=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function w(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var ws=Object.freeze({get BETTER_AUTH_SECRET(){return w("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return w("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return w("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return w("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return w("NODE_ENV","development")},get PACKAGE_VERSION(){return w("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return w("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),V=1,O=4,N=8,P=24,Ie={eterm:O,cons25:O,console:O,cygwin:O,dtterm:O,gnome:O,hurd:O,jfbterm:O,konsole:O,kterm:O,mlterm:O,mosh:P,putty:O,st:O,"rxvt-unicode-24bit":P,terminator:P,"xterm-kitty":P},_r=new Map(Object.entries({APPVEYOR:N,BUILDKITE:N,CIRCLECI:P,DRONE:N,GITEA_ACTIONS:P,GITHUB_ACTIONS:P,GITLAB_CI:N,TRAVIS:N})),Er=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Or(){if(w("FORCE_COLOR")!==void 0)switch(w("FORCE_COLOR")){case"":case"1":case"true":return O;case"2":return N;case"3":return P;default:return V}if(w("NODE_DISABLE_COLORS")!==void 0&&w("NODE_DISABLE_COLORS")!==""||w("NO_COLOR")!==void 0&&w("NO_COLOR")!==""||w("TERM")==="dumb")return V;if(w("TMUX"))return P;if("TF_BUILD"in A&&"AGENT_NAME"in A)return O;if("CI"in A){for(let{0:e,1:t}of _r)if(e in A)return t;return w("CI_NAME")==="codeship"?N:V}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(w("TEAMCITY_VERSION"))!==null?O:V;switch(w("TERM_PROGRAM")){case"iTerm.app":return!w("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(w("TERM_PROGRAM_VERSION"))!==null?N:P;case"HyperTerm":case"MacTerm":return P;case"Apple_Terminal":return N}if(w("COLORTERM")==="truecolor"||w("COLORTERM")==="24bit")return P;if(w("TERM")){if(/truecolor/.exec(w("TERM"))!==null)return P;if(/^xterm-256/.exec(w("TERM"))!==null)return N;let e=w("TERM").toLowerCase();if(Ie[e])return Ie[e];if(Er.some(t=>t.exec(e)!==null))return O}return w("COLORTERM")?O:V}var U={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},ge=["info","success","warn","error","debug"];function Tr(e,t){return ge.indexOf(t)<=ge.indexOf(e)}var Sr={info:U.fg.blue,success:U.fg.green,warn:U.fg.yellow,error:U.fg.red,debug:U.fg.magenta},Rr=(e,t,r)=>{let s=new Date().toISOString();return r?`${U.dim}${s}${U.reset} ${Sr[e]}${e.toUpperCase()}${U.reset} ${U.bright}[Better Auth]:${U.reset} ${t}`:`${s} ${e.toUpperCase()} [Better Auth]: ${t}`},Pr=e=>{let t=e?.disabled!==!0,r=e?.level??"error",s=e?.disableColors!==void 0?!e.disableColors:Or()!==1,n=(o,a,l=[])=>{if(!t||!Tr(r,o))return;let u=Rr(o,a,s);if(!e||typeof e.log!="function"){o==="error"?console.error(u,...l):o==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(ge.map(o=>[o,(...[a,...l])=>n(o,a,l)])),get level(){return r}}},_s=Pr();p();p();var Ee=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Ar(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new Ee(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function z(e,t="/api/auth"){if(Ar(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function $r(e,t,r,s){if(e)return z(e,t);if(s!==!1){let a=A.BETTER_AUTH_URL||A.NEXT_PUBLIC_BETTER_AUTH_URL||A.PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_AUTH_URL||(A.BASE_URL!=="/"?A.BASE_URL:void 0);if(a)return z(a,t)}let n=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(n&&o)return z(`${o}://${n}`,t);if(r){let a=jr(r.url);if(!a)throw new Ee("Could not get origin from request. Please provide a valid base URL.");return z(a,t)}if(typeof window<"u"&&window.location)return z(window.location.origin,t)}function jr(e){try{return new URL(e).origin}catch{return null}}p();p();p();var ve=Symbol("clean"),$=[],D=0,Z=4,Ir=0,wt=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(s){return r.lc=t.push(s),()=>{for(let o=D+Z;o<$.length;)$[o]===s?$.splice(o,Z):o+=Z;let n=t.indexOf(s);~n&&(t.splice(n,1),--r.lc||r.off())}},notify(s,n){Ir++;let o=!$.length;for(let a of t)$.push(a,r.value,s,n);if(o){for(D=0;D<$.length;D+=Z)$[D]($[D+1],$[D+2],$[D+3]);$.length=0}},off(){},set(s){let n=r.value;n!==s&&(r.value=s,r.notify(n))},subscribe(s){let n=r.listen(s);return s(r.value),n},value:e};return process.env.NODE_ENV!=="production"&&(r[ve]=()=>{t=[],r.lc=0,r.off()}),r};p();var xr=5,F=6,ee=10,Nr=(e,t,r,s)=>(e.events=e.events||{},e.events[r+ee]||(e.events[r+ee]=s(n=>{e.events[r].reduceRight((o,a)=>(a(o),o),{shared:{},...n})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let n=e.events[r],o=n.indexOf(t);n.splice(o,1),n.length||(delete e.events[r],e.events[r+ee](),delete e.events[r+ee])}),Ur=1e3,Dr=(e,t)=>Nr(e,r=>{let s=t(r);s&&e.events[F].push(s)},xr,r=>{let s=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),s(...o));let n=e.off;if(e.events[F]=[],e.off=()=>{n(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[F])o();e.events[F]=[]}},Ur)},process.env.NODE_ENV!=="production"){let o=e[ve];e[ve]=()=>{for(let a of e.events[F])a();e.events[F]=[],e.active=!1,o()}}return()=>{e.listen=s,e.off=n}});p();var Lr=typeof window>"u",Cr=(e,t,r,s)=>{let n=wt({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let u=typeof s=="function"?s({data:n.get().data,error:n.get().error,isPending:n.get().isPending}):s;r(t,{...u,query:{...u?.query,...l?.query},async onSuccess(i){n.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onSuccess?.(i)},async onError(i){let{request:c}=i,h=typeof c.retry=="number"?c.retry:c.retry?.attempts,m=c.retryAttempt||0;h&&m<h||(n.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onError?.(i))},async onRequest(i){let c=n.get();n.set({isPending:c.data===null,data:c.data,error:null,isRefetching:!0,refetch:n.value.refetch}),await u?.onRequest?.(i)}}).catch(i=>{n.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{Lr||(a?o():Dr(n,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{n.off(),l.off(),clearTimeout(u)}}))});return n};p();var Br={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},kr=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,xe={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},Mr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Fr(e){return e instanceof Date&&!isNaN(e.getTime())}function qr(e){let t=Mr.exec(e);if(!t)return null;let[,r,s,n,o,a,l,u,i,c,h]=t,m=new Date(Date.UTC(parseInt(r,10),parseInt(s,10)-1,parseInt(n,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),u?parseInt(u.padEnd(3,"0"),10):0));if(i){let f=(parseInt(c,10)*60+parseInt(h,10))*(i==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+f)}return Fr(m)?m:null}function Hr(e,t={}){let{strict:r=!1,warnings:s=!1,reviver:n,parseDates:o=!0}=t;if(typeof e!="string")return e;let a=e.trim();if(a.length>0&&a[0]==='"'&&a.endsWith('"')&&!a.slice(1,-1).includes('"'))return a.slice(1,-1);let l=a.toLowerCase();if(l.length<=9&&l in xe)return xe[l];if(!kr.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(Br).some(([u,i])=>{let c=i.test(a);return c&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=qr(i);if(c)return c}return n?n(u,i):i})}catch(u){if(r)throw u;return e}}function Gr(e,t={strict:!0}){return Hr(e,t)}var Wr={id:"redirect",name:"Redirect",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function Vr(e){let t=wt(!1);return{session:Cr(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var zr=(e,t)=>{let r="credentials"in Request.prototype,s=$r(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",n=e?.plugins?.flatMap(d=>d.fetchPlugins).filter(d=>d!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:u,onResponse:i,...c}=e?.fetchOptions||{},h=br({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(d){return d?Gr(d,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Wr],...n]}),{$sessionSignal:m,session:f}=Vr(h),y=e?.plugins||[],v={},g={$sessionSignal:m,session:f},b={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},T=[{signal:"$sessionSignal",matcher(d){return d==="/sign-out"||d==="/update-user"||d.startsWith("/sign-in")||d.startsWith("/sign-up")||d==="/delete-user"||d==="/verify-email"}}];for(let d of y)d.getAtoms&&Object.assign(g,d.getAtoms?.(h)),d.pathMethods&&Object.assign(b,d.pathMethods),d.atomListeners&&T.push(...d.atomListeners);let S={notify:d=>{g[d].set(!g[d].get())},listen:(d,L)=>{g[d].subscribe(L)},atoms:g};for(let d of y)d.getActions&&Object.assign(v,d.getActions?.(h,S,e));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:b,atomListeners:T,$fetch:h,$store:S}};function Kr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Jr(e,t,r){let s=t[e],{fetchOptions:n,query:o,...a}=r||{};return s||(n?.method?n.method:a&&Object.keys(a).length>0?"POST":"GET")}function Yr(e,t,r,s,n){function o(a=[]){return new Proxy(function(){},{get(l,u){if(typeof u!="string"||u==="then"||u==="catch"||u==="finally")return;let i=[...a,u],c=e;for(let h of i)if(c&&typeof c=="object"&&h in c)c=c[h];else{c=void 0;break}return typeof c=="function"||Kr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(T=>T.replace(/[A-Z]/g,S=>`-${S.toLowerCase()}`)).join("/"),h=i[0]||{},m=i[1]||{},{query:f,fetchOptions:y,...v}=h,g={...m,...y},b=Jr(c,r,h);return await t(c,{...g,body:b==="GET"?void 0:{...v,...g?.body||{}},query:f||g?.query,method:b,async onSuccess(T){if(await g?.onSuccess?.(T),!n)return;let S=n.filter(d=>d.matcher(c));if(S.length)for(let d of S){let L=s[d.signal];if(!L)return;let _=L.get();setTimeout(()=>{L.set(!_)},10)}}})}})}return o()}p();function Xr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Qr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:s,$fetch:n,atomListeners:o,$store:a}=zr(e),l={};for(let[i,c]of Object.entries(s))l[`use${Xr(i)}`]=c;let u={...r,...l,$fetch:n,$store:a};return Yr(u,n,t,s,o)}p();p();p();function Zr(e){return{authorize(t,r="AND"){let s=!1;for(let[n,o]of Object.entries(t)){let a=e[n];if(!a)return{success:!1,error:`You are not allowed to access resource: ${n}`};if(Array.isArray(o))s=o.every(l=>a.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?s=l.actions.some(u=>a.includes(u)):s=l.actions.every(u=>a.includes(u))}else throw new Ee("Invalid access control request");if(s&&r==="OR")return{success:s};if(!s&&r==="AND")return{success:!1,error:`unauthorized to access resource "${n}"`}}return s?{success:s}:{success:!1,error:"Not authorized"}},statements:e}}function _t(e){return{newRole(t){return Zr(t)},statements:e}}var es={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Oe=_t(es),Es=Oe.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Os=Oe.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Ts=Oe.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var ts=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},Ss=new ts;p();p();p();p();p();p();p();p();var rs={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Et=_t(rs),Rs=Et.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Ps=Et.newRole({user:[],session:[]});p();p();var ss=()=>({id:"username",$InferServerPlugin:{}}),ns=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),os=()=>({id:"better-auth-client",$InferServerPlugin:{}}),as="/auth",te="nvwa_login_token",me="nvwa_user_profile",Ot=class{constructor(e,t,r){this.storage=r;let s=Qr({baseURL:e,basePath:as,plugins:[ss(),ns(),os()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>r.get(te)},onSuccess:n=>{let o=n.response.headers.get("set-auth-token");console.log("success",n.data,n.request),o&&r.set(te,o)}}});this.authClient=s}async currentUser(){return await this.storage.get(me)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.saveSession(t)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.saveSession(r)}saveSession(e){if(e.error)throw new Error(e.error.message);this.storage.set(te,e.data?.token),this.storage.set(me,e.data?.user)}async signOut(){await this.storage.remove(te),await this.storage.remove(me)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.saveSession(s)}};p();var Tt=class{constructor(e){this.http=e}async invoke(e,t){return(await this.http.request("/functions/"+e,{method:t.method||"POST",data:t.body,headers:t.headers})).body}};p();var St=class{async jsonRequest(e,t){let r={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,r)}async jsonRequestWithAuth(e,t,r){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,s,r)}};p();var is="/storage",ls=is+"/generateUploadUrl",Rt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+ls,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=t.body;if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(r,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};p();p();p();var Ne=Jt(Xt(),1),{PostgrestClient:us,PostgrestQueryBuilder:As,PostgrestFilterBuilder:$s,PostgrestTransformBuilder:js,PostgrestBuilder:Is,PostgrestError:xs}=Ne.default||Ne;p();p();var I=class Pt{constructor(t){if(this.headerMap=new Map,t){if(t instanceof Pt)t.forEach((r,s)=>this.set(s,r));else if(Array.isArray(t))for(let[r,s]of t)this.set(r,String(s));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let s=t.toLowerCase(),n=this.headerMap.get(s);this.headerMap.set(s,n?`${n}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,s]of this.headerMap.entries())t(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},At=class $t{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof $t)this.params=new Map(t.params);else if(Array.isArray(t))for(let[r,s]of t)this.append(r,s);else if(t&&typeof t=="object")for(let[r,s]of Object.entries(t))this.set(r,s)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let r=t.split("&");for(let s of r)if(s){let[n,o]=s.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}append(t,r){let s=this.params.get(t)||[];s.push(r),this.params.set(t,s)}delete(t){this.params.delete(t)}get(t){let r=this.params.get(t);return r?r[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,r){this.params.set(t,[r])}sort(){let t=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(t)}toString(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(n)}`);return t.join("&")}forEach(t){for(let[r,s]of this.params.entries())for(let n of s)t(n,r,this)}keys(){return this.params.keys()}values(){let t=[];for(let r of this.params.values())t.push(...r);return t[Symbol.iterator]()}entries(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push([r,n]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},cs=class be{constructor(t,r){let s;if(t instanceof be)s=t.href;else if(r){let o=r instanceof be?r.href:r;s=this.resolve(o,t)}else s=t;let n=this.parseUrl(s);this.href=s,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new At(n.search),this.hash=n.hash}resolve(t,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(t).protocol}${r}`;if(r.startsWith("/")){let o=this.parseUrl(t);return`${o.protocol}//${o.host}${r}`}let s=this.parseUrl(t),n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${n}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",n=r[4]||"",o=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let u=n.match(/^([^@]*)@(.+)$/),i="",c="",h=n;if(u){let v=u[1];h=u[2];let g=v.match(/^([^:]*):?(.*)$/);g&&(i=g[1]||"",c=g[2]||"")}let m=h.match(/^([^:]+):?(\d*)$/),f=m?m[1]:h,y=m&&m[2]?m[2]:"";return{protocol:s?`${s}:`:"",username:i,password:c,host:h,hostname:f,port:y,pathname:o,search:a,hash:l}}toString(){let t=this.searchParams.toString(),r=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};p();var hs=class jt{constructor(t,r){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof I?r.headers:new I(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new jt(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var Y=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=fs(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function fs(e){return e?new I(e):new I}p();var It=class{constructor(){this._aborted=!1,this.listeners=new Set,this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},ps=class{constructor(){this._signal=new It}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function xt(e){e.URL=cs,e.URLSearchParams=At,e.Headers=I,e.Request=hs,e.Response=Y,e.AbortController=ps,e.AbortSignal=It}var ds="/entities",ms=(e,t)=>async(r,s)=>{console.log("customFetch",r,s);let n;if(typeof r=="string")n=r;else if(r&&typeof r=="object")if(typeof r.toString=="function"&&!r.url)n=r.toString();else if(r.url)n=r.url,s||(s={}),s.method=r.method,s.headers=r.headers,s.body=r.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let o=(s?.method||"GET").toUpperCase(),a={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((h,m)=>{a[m]=h});else if(Array.isArray(s.headers))for(let[h,m]of s.headers)a[h]=m;else Object.assign(a,s.headers);let l=s?.body,u;try{u=await e.requestWithAuth(n,{method:o,data:l,headers:a},t)}catch(h){return new Y(h?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let i=u.body,c=null;return(u.headers["content-type"]||u.headers["Content-Type"]||"").startsWith("application/json")&&typeof i!="string"?c=JSON.stringify(i):typeof i=="string"||i&&(i.constructor===Blob||i.constructor===ArrayBuffer||typeof i.getReader=="function")?c=i:c=JSON.stringify(i),new Y(c,{status:u.status,headers:new I(u.headers)})},Nt=(e,t,r)=>new us(e+ds,{fetch:ms(t,r)});var ys=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let s=(t?.method||"GET").toUpperCase(),n={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{n[i]=u});else if(Array.isArray(l))for(let[u,i]of l)n[u]=i;else Object.assign(n,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),o=u}else o=l}let a=t?.timeout||3e4;return new Promise((l,u)=>{let i=t?.signal;if(i?.aborted){let f=new Error("The operation was aborted");f.name="AbortError",u(f);return}let c=!1,h=[],m=uni.request({url:r,method:s,data:o,header:n,timeout:a,success:f=>{if(c)return;c=!0;let y=f.statusCode,v="",g=new I,b=f.header||f.headers||{};Object.keys(b).forEach(T=>{let S=b[T];g.set(T,typeof S=="string"?S:String(S))}),l(new Y(f.data,{status:y,statusText:v,headers:g}))},fail:f=>{if(c)return;c=!0;let y=f?.errMsg||f?.message||"Network Error",v=new Error(y);/(abort|aborted|canceled|cancelled)/i.test(String(y))&&(v.name="AbortError"),u(v)}});if(i&&typeof i.addEventListener=="function"){let f=()=>{if(c)return;try{m?.abort?.()}catch{}let y=new Error("The operation was aborted");y.name="AbortError",c=!0,u(y)};i.addEventListener("abort",f),h.push(()=>{try{i.removeEventListener?.("abort",f)}catch{}})}})},X=ys;var ue=class extends St{async request(t,r){let s=await X(t,{method:r.method,headers:new I(r.headers),body:r.data});return{status:s.status,body:await s.json(),headers:Object.fromEntries(s.headers.entries())}}async requestWithAuth(t,r,s){let n=await this.fetchWithAuth(s,t,{method:r.method,headers:new I(r.headers),body:r.data});return{status:n.status,body:await n.json(),headers:Object.fromEntries(n.headers.entries())}}async fetchWithAuth(t,r,s){let n=await X(r,s);if(n.status===401)throw t(),new Error("\u672A\u767B\u5F55");return n}};var ce=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(t),null):s.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(t,r,s){try{let n=this.getKey(t),o={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(n,o)}catch(n){throw console.error("UniAppStorageService set error:",n),n}}async remove(t){try{let r=this.getKey(t);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(t){throw console.error("UniAppStorageService clear error:",t),t}}};var Ut=new ce,he=new ue,fe=class{constructor(t,r){this.auth=new Ot(t,X,Ut),this.fileStorage=new Rt(t,he),this.entities=Nt(t,he,r),this.functions=new Tt(he)}};0&&(module.exports={httpClient,localStorage,polyfill});
1
+ "use strict";var pe=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var Mt=Object.prototype.hasOwnProperty;var Ft=(e,t)=>{for(var r in t)pe(e,r,{get:t[r],enumerable:!0})},qt=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of kt(t))!Mt.call(e,n)&&n!==r&&pe(e,n,{get:()=>t[n],enumerable:!(s=Bt(t,n))||s.enumerable});return e};var Ht=e=>qt(pe({},"__esModule",{value:!0}),e);var vs={};Ft(vs,{default:()=>he,httpClient:()=>ce,localStorage:()=>Lt,polyfill:()=>xt});module.exports=Ht(vs);var Wt=Object.create,ie=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Kt=Object.getOwnPropertyNames,Vt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty,Le=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Yt=(e,t)=>{for(var r in t)ie(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Kt(t))!zt.call(e,n)&&n!==r&&ie(e,n,{get:()=>t[n],enumerable:!(s=Gt(t,n))||s.enumerable});return e},Jt=(e,t,r)=>(r=e!=null?Wt(Vt(e)):{},Ce(t||!e||!e.__esModule?ie(r,"default",{value:e,enumerable:!0}):r,e)),H=e=>Ce(ie({},"__esModule",{value:!0}),e),p=Le(()=>{"use strict"}),B={};Yt(B,{__addDisposableResource:()=>it,__assign:()=>z,__asyncDelegator:()=>Ze,__asyncGenerator:()=>Qe,__asyncValues:()=>et,__await:()=>q,__awaiter:()=>Ke,__classPrivateFieldGet:()=>nt,__classPrivateFieldIn:()=>at,__classPrivateFieldSet:()=>ot,__createBinding:()=>Y,__decorate:()=>ke,__disposeResources:()=>lt,__esDecorate:()=>Fe,__exportStar:()=>ze,__extends:()=>De,__generator:()=>Ve,__importDefault:()=>st,__importStar:()=>rt,__makeTemplateObject:()=>tt,__metadata:()=>Ge,__param:()=>Me,__propKey:()=>He,__read:()=>_e,__rest:()=>Be,__rewriteRelativeImportExtension:()=>ut,__runInitializers:()=>qe,__setFunctionName:()=>We,__spread:()=>Ye,__spreadArray:()=>Xe,__spreadArrays:()=>Je,__values:()=>oe,default:()=>ft});function De(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");te(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Be(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(r[s[n]]=e[s[n]]);return r}function ke(e,t,r,s){var n=arguments.length,o=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(n<3?a(o):n>3?a(t,r,o):a(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function Me(e,t){return function(r,s){t(r,s,e)}}function Fe(e,t,r,s,n,o){function a(b){if(b!==void 0&&typeof b!="function")throw new TypeError("Function expected");return b}for(var l=s.kind,u=l==="getter"?"get":l==="setter"?"set":"value",i=!t&&e?s.static?e:e.prototype:null,c=t||(i?Object.getOwnPropertyDescriptor(i,s.name):{}),h,m=!1,f=r.length-1;f>=0;f--){var y={};for(var v in s)y[v]=v==="access"?{}:s[v];for(var v in s.access)y.access[v]=s.access[v];y.addInitializer=function(b){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(b||null))};var g=(0,r[f])(l==="accessor"?{get:c.get,set:c.set}:c[u],y);if(l==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(h=a(g.get))&&(c.get=h),(h=a(g.set))&&(c.set=h),(h=a(g.init))&&n.unshift(h)}else(h=a(g))&&(l==="field"?n.unshift(h):c[u]=h)}i&&Object.defineProperty(i,s.name,c),m=!0}function qe(e,t,r){for(var s=arguments.length>2,n=0;n<t.length;n++)r=s?t[n].call(e,r):t[n].call(e);return s?r:void 0}function He(e){return typeof e=="symbol"?e:"".concat(e)}function We(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function Ge(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Ke(e,t,r,s){function n(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function l(c){try{i(s.next(c))}catch(h){a(h)}}function u(c){try{i(s.throw(c))}catch(h){a(h)}}function i(c){c.done?o(c.value):n(c.value).then(l,u)}i((s=s.apply(e,t||[])).next())})}function Ve(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,n,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(c){return u([i,c])}}function u(i){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(s=1,n&&(o=i[0]&2?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,n=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],n=0}finally{s=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ze(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Y(t,e,r)}function oe(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function _e(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),n,o=[],a;try{for(;(t===void 0||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(l){a={error:l}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return o}function Ye(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(_e(arguments[t]));return e}function Je(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),n=0,t=0;t<r;t++)for(var o=arguments[t],a=0,l=o.length;a<l;a++,n++)s[n]=o[a];return s}function Xe(e,t,r){if(r||arguments.length===2)for(var s=0,n=t.length,o;s<n;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return e.concat(o||Array.prototype.slice.call(t))}function q(e){return this instanceof q?(this.v=e,this):new q(e)}function Qe(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(f){return function(y){return Promise.resolve(y).then(f,h)}}function l(f,y){s[f]&&(n[f]=function(v){return new Promise(function(g,b){o.push([f,v,g,b])>1||u(f,v)})},y&&(n[f]=y(n[f])))}function u(f,y){try{i(s[f](y))}catch(v){m(o[0][3],v)}}function i(f){f.value instanceof q?Promise.resolve(f.value.v).then(c,h):m(o[0][2],f)}function c(f){u("next",f)}function h(f){u("throw",f)}function m(f,y){f(y),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Ze(e){var t,r;return t={},s("next"),s("throw",function(n){throw n}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(n,o){t[n]=e[n]?function(a){return(r=!r)?{value:q(e[n](a)),done:!1}:o?o(a):a}:o}}function et(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof oe=="function"?oe(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(o){r[o]=e[o]&&function(a){return new Promise(function(l,u){a=e[o](a),n(l,u,a.done,a.value)})}}function n(o,a,l,u){Promise.resolve(u).then(function(i){o({value:i,done:l})},a)}}function tt(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function rt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=re(e),s=0;s<r.length;s++)r[s]!=="default"&&Y(t,e,r[s]);return ct(t,e),t}function st(e){return e&&e.__esModule?e:{default:e}}function nt(e,t,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function ot(e,t,r,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r}function at(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function it(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(n=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");n&&(s=function(){try{n.call(this)}catch(o){return Promise.reject(o)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}function lt(e){function t(o){e.error=e.hasError?new ht(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var r,s=0;function n(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(n);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(o).then(n,function(a){return t(a),n()})}else s|=1}catch(a){t(a)}if(s===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return n()}function ut(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,n,o,a){return s?t?".jsx":".js":n&&(!o||!a)?r:n+o+"."+a.toLowerCase()+"js"}):e}var te,z,Y,ct,re,ht,ft,W=Le(()=>{"use strict";p(),te=function(e,t){return te=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[n]=s[n])},te(e,t)},z=function(){return z=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},z.apply(this,arguments)},Y=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),ct=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},re=function(e){return re=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},re(e)},ht=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s},ft={__extends:De,__assign:z,__rest:Be,__decorate:ke,__param:Me,__esDecorate:Fe,__runInitializers:qe,__propKey:He,__setFunctionName:We,__metadata:Ge,__awaiter:Ke,__generator:Ve,__createBinding:Y,__exportStar:ze,__values:oe,__read:_e,__spread:Ye,__spreadArrays:Je,__spreadArray:Xe,__await:q,__asyncGenerator:Qe,__asyncDelegator:Ze,__asyncValues:et,__makeTemplateObject:tt,__importStar:rt,__importDefault:st,__classPrivateFieldGet:nt,__classPrivateFieldSet:ot,__classPrivateFieldIn:at,__addDisposableResource:it,__disposeResources:lt,__rewriteRelativeImportExtension:ut}}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),dt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),H(B)),r=t.__importDefault(pt()),s=class{constructor(n){var o,a;this.shouldThrowOnError=!1,this.method=n.method,this.url=n.url,this.headers=new Headers(n.headers),this.schema=n.schema,this.body=n.body,this.shouldThrowOnError=(o=n.shouldThrowOnError)!==null&&o!==void 0?o:!1,this.signal=n.signal,this.isMaybeSingle=(a=n.isMaybeSingle)!==null&&a!==void 0?a:!1,n.fetch?this.fetch=n.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(n,o){return this.headers=new Headers(this.headers),this.headers.set(n,o),this}then(n,o){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let a=this.fetch,l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var i,c,h,m;let f=null,y=null,v=null,g=u.status,b=u.statusText;if(u.ok){if(this.method!=="HEAD"){let d=await u.text();d===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text")?y=d:y=JSON.parse(d))}let T=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),P=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");T&&P&&P.length>1&&(v=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(f={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,v=null,g=406,b="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{let T=await u.text();try{f=JSON.parse(T),Array.isArray(f)&&u.status===404&&(y=[],f=null,g=200,b="OK")}catch{u.status===404&&T===""?(g=204,b="No Content"):f={message:T}}if(f&&this.isMaybeSingle&&!((m=f?.details)===null||m===void 0)&&m.includes("0 rows")&&(f=null,g=200,b="OK"),f&&this.shouldThrowOnError)throw new r.default(f)}return{error:f,data:y,count:v,status:g,statusText:b}});return this.shouldThrowOnError||(l=l.catch(u=>{var i,c,h;return{error:{message:`${(i=u?.name)!==null&&i!==void 0?i:"FetchError"}: ${u?.message}`,details:`${(c=u?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(h=u?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(n,o)}returns(){return this}overrideTypes(){return this}};e.default=s}),mt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),H(B)),r=t.__importDefault(dt()),s=class extends r.default{select(n){let o=!1,a=(n??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(n,{ascending:o=!0,nullsFirst:a,foreignTable:l,referencedTable:u=l}={}){let i=u?`${u}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${n}.${o?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(n,{foreignTable:o,referencedTable:a=o}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${n}`),this}range(n,o,{foreignTable:a,referencedTable:l=a}={}){let u=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(u,`${n}`),this.url.searchParams.set(i,`${o-n+1}`),this}abortSignal(n){return this.signal=n,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:n=!1,verbose:o=!1,settings:a=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[n?"analyze":null,o?"verbose":null,a?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),m=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${m}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(n){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${n}`),this}};e.default=s}),Ee=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),H(B)),r=t.__importDefault(mt()),s=new RegExp("[,()]"),n=class extends r.default{eq(o,a){return this.url.searchParams.append(o,`eq.${a}`),this}neq(o,a){return this.url.searchParams.append(o,`neq.${a}`),this}gt(o,a){return this.url.searchParams.append(o,`gt.${a}`),this}gte(o,a){return this.url.searchParams.append(o,`gte.${a}`),this}lt(o,a){return this.url.searchParams.append(o,`lt.${a}`),this}lte(o,a){return this.url.searchParams.append(o,`lte.${a}`),this}like(o,a){return this.url.searchParams.append(o,`like.${a}`),this}likeAllOf(o,a){return this.url.searchParams.append(o,`like(all).{${a.join(",")}}`),this}likeAnyOf(o,a){return this.url.searchParams.append(o,`like(any).{${a.join(",")}}`),this}ilike(o,a){return this.url.searchParams.append(o,`ilike.${a}`),this}ilikeAllOf(o,a){return this.url.searchParams.append(o,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(o,a){return this.url.searchParams.append(o,`ilike(any).{${a.join(",")}}`),this}is(o,a){return this.url.searchParams.append(o,`is.${a}`),this}in(o,a){let l=Array.from(new Set(a)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(o,`in.(${l})`),this}contains(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cs.{${a.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(a)}`),this}containedBy(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cd.{${a.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(a)}`),this}rangeGt(o,a){return this.url.searchParams.append(o,`sr.${a}`),this}rangeGte(o,a){return this.url.searchParams.append(o,`nxl.${a}`),this}rangeLt(o,a){return this.url.searchParams.append(o,`sl.${a}`),this}rangeLte(o,a){return this.url.searchParams.append(o,`nxr.${a}`),this}rangeAdjacent(o,a){return this.url.searchParams.append(o,`adj.${a}`),this}overlaps(o,a){return typeof a=="string"?this.url.searchParams.append(o,`ov.${a}`):this.url.searchParams.append(o,`ov.{${a.join(",")}}`),this}textSearch(o,a,{config:l,type:u}={}){let i="";u==="plain"?i="pl":u==="phrase"?i="ph":u==="websearch"&&(i="w");let c=l===void 0?"":`(${l})`;return this.url.searchParams.append(o,`${i}fts${c}.${a}`),this}match(o){return Object.entries(o).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(o,a,l){return this.url.searchParams.append(o,`not.${a}.${l}`),this}or(o,{foreignTable:a,referencedTable:l=a}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${o})`),this}filter(o,a,l){return this.url.searchParams.append(o,`${a}.${l}`),this}};e.default=n}),yt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),H(B)),r=t.__importDefault(Ee()),s=class{constructor(n,{headers:o={},schema:a,fetch:l}){this.url=n,this.headers=new Headers(o),this.schema=a,this.fetch=l}select(n,o){let{head:a=!1,count:l}=o??{},u=a?"HEAD":"GET",i=!1,c=(n??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",c),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(n,{count:o,defaultToNull:a=!0}={}){var l;let u="POST";if(o&&this.headers.append("Prefer",`count=${o}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let i=n.reduce((c,h)=>c.concat(Object.keys(h)),[]);if(i.length>0){let c=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(n,{onConflict:o,ignoreDuplicates:a=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let h=n.reduce((m,f)=>m.concat(Object.keys(f)),[]);if(h.length>0){let m=[...new Set(h)].map(f=>`"${f}"`);this.url.searchParams.set("columns",m.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(n,{count:o}={}){var a;let l="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:n}={}){var o;let a="DELETE";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};e.default=s}),Xt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),H(B)),r=t.__importDefault(yt()),s=t.__importDefault(Ee()),n=class gt{constructor(a,{headers:l={},schema:u,fetch:i}={}){this.url=a,this.headers=new Headers(l),this.schemaName=u,this.fetch=i}from(a){let l=new URL(`${this.url}/${a}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new gt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let m,f=new URL(`${this.url}/rpc/${a}`),y;u||i?(m=u?"HEAD":"GET",Object.entries(l).filter(([g,b])=>b!==void 0).map(([g,b])=>[g,Array.isArray(b)?`{${b.join(",")}}`:`${b}`]).forEach(([g,b])=>{f.searchParams.append(g,b)})):(m="POST",y=l);let v=new Headers(this.headers);return c&&v.set("Prefer",`count=${c}`),new s.default({method:m,url:f,headers:v,schema:this.schemaName,body:y,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=n}),Qt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(W(),H(B)),r=t.__importDefault(Xt());e.PostgrestClient=r.default;var s=t.__importDefault(yt());e.PostgrestQueryBuilder=s.default;var n=t.__importDefault(Ee());e.PostgrestFilterBuilder=n.default;var o=t.__importDefault(mt());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(dt());e.PostgrestBuilder=a.default;var l=t.__importDefault(pt());e.PostgrestError=l.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:n.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var Zt=Object.defineProperty,er=Object.defineProperties,tr=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,rr=Object.prototype.hasOwnProperty,sr=Object.prototype.propertyIsEnumerable,Ae=(e,t,r)=>t in e?Zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$=(e,t)=>{for(var r in t||(t={}))rr.call(t,r)&&Ae(e,r,t[r]);if(Se)for(var r of Se(t))sr.call(t,r)&&Ae(e,r,t[r]);return e},N=(e,t)=>er(e,tr(t)),nr=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},or=async(e,t)=>{var r,s,n,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((s=c.hooks)==null?void 0:s.onRequest),i.onResponse.push((n=c.hooks)==null?void 0:n.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},je=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},ar=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function ir(e){if(typeof e=="number")return new je({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new je(e);case"exponential":return new ar(e);default:throw new Error("Invalid retry strategy")}}var lr=async e=>{let t={},r=async s=>typeof s=="function"?await s():s;if(e?.auth){if(e.auth.type==="Bearer"){let s=await r(e.auth.token);if(!s)return t;t.authorization=`Bearer ${s}`}else if(e.auth.type==="Basic"){let s=r(e.auth.username),n=r(e.auth.password);if(!s||!n)return t;t.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(e.auth.type==="Custom"){let s=r(e.auth.value);if(!s)return t;t.authorization=`${r(e.auth.prefix)} ${s}`}}return t},ur=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function cr(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let s=t.split(";").shift()||"";return ur.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function hr(e){try{return JSON.parse(e),!0}catch{return!1}}function vt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function $e(e){try{return JSON.parse(e)}catch{return e}}function Ie(e){return typeof e=="function"}function fr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&Ie(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&Ie(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function pr(e){let t=new Headers(e?.headers),r=await lr(e);for(let[s,n]of Object.entries(r||{}))t.set(s,n);if(!t.has("content-type")){let s=dr(e?.body);s&&t.set("content-type",s)}return t}function dr(e){return vt(e)?"application/json":null}function mr(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(vt(e.body)&&!t.has("content-type")){for(let[r,s]of Object.entries(e?.body))s instanceof Date&&(e.body[r]=s.toISOString());return JSON.stringify(e.body)}return e.body}function yr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let s=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return wt.includes(s)?s.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function gr(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var vr=class bt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,bt.prototype)}};async function se(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new vr(r.issues);return r.value}var wt=["get","post","put","patch","delete"],br=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var s,n,o,a;let l=((n=(s=e.plugins)==null?void 0:s.find(u=>{var i;return(i=u.schema)!=null&&i.config?t.startsWith(u.schema.config.baseURL||"")||t.startsWith(u.schema.config.prefix||""):!1}))==null?void 0:n.schema)||e.schema;if(l){let u=t;(o=l.config)!=null&&o.prefix&&u.startsWith(l.config.prefix)&&(u=u.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&u.startsWith(l.config.baseURL)&&(u=u.replace(l.config.baseURL,""));let i=l.schema[u];if(i){let c=N($({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=N($({},c),{body:i.input?await se(i.input,r?.body):r?.body,params:i.params?await se(i.params,r?.params):r?.params,query:i.query?await se(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),wr=e=>{async function t(r,s){let n=N($($({},e),s),{plugins:[...e?.plugins||[],br(e||{})]});if(e?.catchAllError)try{return await ge(r,n)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await ge(r,n)}return t};function _r(e,t){let{baseURL:r,params:s,query:n}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];wt.includes(c)&&(e=e.replace(`@${c}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(n||{}))h!=null&&u.set(c,String(h));if(s)if(Array.isArray(s)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,m]of c.entries()){let f=s[h];a=a.replace(m,f)}}else for(let[c,h]of Object.entries(s))a=a.replace(`:${c}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=u.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var ge=async(e,t)=>{var r,s,n,o,a,l,u,i;let{hooks:c,url:h,options:m}=await or(e,t),f=fr(m),y=new AbortController,v=(r=m.signal)!=null?r:y.signal,g=_r(h,m),b=mr(m),T=await pr(m),P=yr(h,m),d=N($({},m),{url:g,headers:T,body:b,method:P,signal:v});for(let R of c.onRequest)if(R){let E=await R(d);E instanceof Object&&(d=E)}("pipeTo"in d&&typeof d.pipeTo=="function"||typeof((s=t?.body)==null?void 0:s.pipe)=="function")&&("duplex"in d||(d.duplex="half"));let{clearTimeout:C}=gr(m,y),_=await f(d.url,d);C();let Pe={response:_,request:d};for(let R of c.onResponse)if(R){let E=await R(N($({},Pe),{response:(n=t?.hookOptions)!=null&&n.cloneResponse?_.clone():_}));E instanceof Response?_=E:E instanceof Object&&(_=E.response)}if(_.ok){if(d.method==="HEAD")return{data:"",error:null};let R=cr(_),E={data:"",response:_,request:d};if(R==="json"||R==="text"){let k=await _.text(),M=await((o=d.jsonParser)!=null?o:$e)(k);E.data=M}else E.data=await _[R]();d?.output&&d.output&&!d.disableValidation&&(E.data=await se(d.output,E.data));for(let k of c.onSuccess)k&&await k(N($({},E),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?E.data:{data:E.data,error:null}}let Ct=(l=t?.jsonParser)!=null?l:$e,Q=await _.text(),Re=hr(Q),fe=Re?await Ct(Q):null,Dt={response:_,responseText:Q,request:d,error:N($({},fe),{status:_.status,statusText:_.statusText})};for(let R of c.onError)R&&await R(N($({},Dt),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let R=ir(t.retry),E=(i=t.retryAttempt)!=null?i:0;if(await R.shouldAttemptRetry(E,_)){for(let M of c.onRetry)M&&await M(Pe);let k=R.getDelay(E);return await new Promise(M=>setTimeout(M,k)),await ge(e,N($({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new nr(_.status,_.statusText,Re?fe:Q);return{data:null,error:N($({},fe),{status:_.status,statusText:_.statusText})}};p();p();var ne=Object.create(null),G=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?ne:globalThis),A=new Proxy(ne,{get(e,t){return G()[t]??ne[t]},has(e,t){let r=G();return t in r||t in ne},set(e,t,r){let s=G(!0);return s[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=G(!0);return delete r[t],!0},ownKeys(){let e=G(!0);return Object.keys(e)}}),ws=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function w(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var _s=Object.freeze({get BETTER_AUTH_SECRET(){return w("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return w("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return w("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return w("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return w("NODE_ENV","development")},get PACKAGE_VERSION(){return w("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return w("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),K=1,O=4,x=8,S=24,Ne={eterm:O,cons25:O,console:O,cygwin:O,dtterm:O,gnome:O,hurd:O,jfbterm:O,konsole:O,kterm:O,mlterm:O,mosh:S,putty:O,st:O,"rxvt-unicode-24bit":S,terminator:S,"xterm-kitty":S},Er=new Map(Object.entries({APPVEYOR:x,BUILDKITE:x,CIRCLECI:S,DRONE:x,GITEA_ACTIONS:S,GITHUB_ACTIONS:S,GITLAB_CI:x,TRAVIS:x})),Or=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Tr(){if(w("FORCE_COLOR")!==void 0)switch(w("FORCE_COLOR")){case"":case"1":case"true":return O;case"2":return x;case"3":return S;default:return K}if(w("NODE_DISABLE_COLORS")!==void 0&&w("NODE_DISABLE_COLORS")!==""||w("NO_COLOR")!==void 0&&w("NO_COLOR")!==""||w("TERM")==="dumb")return K;if(w("TMUX"))return S;if("TF_BUILD"in A&&"AGENT_NAME"in A)return O;if("CI"in A){for(let{0:e,1:t}of Er)if(e in A)return t;return w("CI_NAME")==="codeship"?x:K}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(w("TEAMCITY_VERSION"))!==null?O:K;switch(w("TERM_PROGRAM")){case"iTerm.app":return!w("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(w("TERM_PROGRAM_VERSION"))!==null?x:S;case"HyperTerm":case"MacTerm":return S;case"Apple_Terminal":return x}if(w("COLORTERM")==="truecolor"||w("COLORTERM")==="24bit")return S;if(w("TERM")){if(/truecolor/.exec(w("TERM"))!==null)return S;if(/^xterm-256/.exec(w("TERM"))!==null)return x;let e=w("TERM").toLowerCase();if(Ne[e])return Ne[e];if(Or.some(t=>t.exec(e)!==null))return O}return w("COLORTERM")?O:K}var U={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},ve=["info","success","warn","error","debug"];function Pr(e,t){return ve.indexOf(t)<=ve.indexOf(e)}var Rr={info:U.fg.blue,success:U.fg.green,warn:U.fg.yellow,error:U.fg.red,debug:U.fg.magenta},Sr=(e,t,r)=>{let s=new Date().toISOString();return r?`${U.dim}${s}${U.reset} ${Rr[e]}${e.toUpperCase()}${U.reset} ${U.bright}[Better Auth]:${U.reset} ${t}`:`${s} ${e.toUpperCase()} [Better Auth]: ${t}`},Ar=e=>{let t=e?.disabled!==!0,r=e?.level??"error",s=e?.disableColors!==void 0?!e.disableColors:Tr()!==1,n=(o,a,l=[])=>{if(!t||!Pr(r,o))return;let u=Sr(o,a,s);if(!e||typeof e.log!="function"){o==="error"?console.error(u,...l):o==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(ve.map(o=>[o,(...[a,...l])=>n(o,a,l)])),get level(){return r}}},Es=Ar();p();p();var Oe=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function jr(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new Oe(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function V(e,t="/api/auth"){if(jr(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function $r(e,t,r,s){if(e)return V(e,t);if(s!==!1){let a=A.BETTER_AUTH_URL||A.NEXT_PUBLIC_BETTER_AUTH_URL||A.PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_AUTH_URL||(A.BASE_URL!=="/"?A.BASE_URL:void 0);if(a)return V(a,t)}let n=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(n&&o)return V(`${o}://${n}`,t);if(r){let a=Ir(r.url);if(!a)throw new Oe("Could not get origin from request. Please provide a valid base URL.");return V(a,t)}if(typeof window<"u"&&window.location)return V(window.location.origin,t)}function Ir(e){try{return new URL(e).origin}catch{return null}}p();p();p();var be=Symbol("clean"),j=[],L=0,Z=4,Nr=0,_t=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(s){return r.lc=t.push(s),()=>{for(let o=L+Z;o<j.length;)j[o]===s?j.splice(o,Z):o+=Z;let n=t.indexOf(s);~n&&(t.splice(n,1),--r.lc||r.off())}},notify(s,n){Nr++;let o=!j.length;for(let a of t)j.push(a,r.value,s,n);if(o){for(L=0;L<j.length;L+=Z)j[L](j[L+1],j[L+2],j[L+3]);j.length=0}},off(){},set(s){let n=r.value;n!==s&&(r.value=s,r.notify(n))},subscribe(s){let n=r.listen(s);return s(r.value),n},value:e};return process.env.NODE_ENV!=="production"&&(r[be]=()=>{t=[],r.lc=0,r.off()}),r};p();var xr=5,F=6,ee=10,Ur=(e,t,r,s)=>(e.events=e.events||{},e.events[r+ee]||(e.events[r+ee]=s(n=>{e.events[r].reduceRight((o,a)=>(a(o),o),{shared:{},...n})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let n=e.events[r],o=n.indexOf(t);n.splice(o,1),n.length||(delete e.events[r],e.events[r+ee](),delete e.events[r+ee])}),Lr=1e3,Cr=(e,t)=>Ur(e,r=>{let s=t(r);s&&e.events[F].push(s)},xr,r=>{let s=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),s(...o));let n=e.off;if(e.events[F]=[],e.off=()=>{n(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[F])o();e.events[F]=[]}},Lr)},process.env.NODE_ENV!=="production"){let o=e[be];e[be]=()=>{for(let a of e.events[F])a();e.events[F]=[],e.active=!1,o()}}return()=>{e.listen=s,e.off=n}});p();var Dr=typeof window>"u",Br=(e,t,r,s)=>{let n=_t({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let u=typeof s=="function"?s({data:n.get().data,error:n.get().error,isPending:n.get().isPending}):s;r(t,{...u,query:{...u?.query,...l?.query},async onSuccess(i){n.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onSuccess?.(i)},async onError(i){let{request:c}=i,h=typeof c.retry=="number"?c.retry:c.retry?.attempts,m=c.retryAttempt||0;h&&m<h||(n.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onError?.(i))},async onRequest(i){let c=n.get();n.set({isPending:c.data===null,data:c.data,error:null,isRefetching:!0,refetch:n.value.refetch}),await u?.onRequest?.(i)}}).catch(i=>{n.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{Dr||(a?o():Cr(n,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{n.off(),l.off(),clearTimeout(u)}}))});return n};p();var kr={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Mr=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,xe={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},Fr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function qr(e){return e instanceof Date&&!isNaN(e.getTime())}function Hr(e){let t=Fr.exec(e);if(!t)return null;let[,r,s,n,o,a,l,u,i,c,h]=t,m=new Date(Date.UTC(parseInt(r,10),parseInt(s,10)-1,parseInt(n,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),u?parseInt(u.padEnd(3,"0"),10):0));if(i){let f=(parseInt(c,10)*60+parseInt(h,10))*(i==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+f)}return qr(m)?m:null}function Wr(e,t={}){let{strict:r=!1,warnings:s=!1,reviver:n,parseDates:o=!0}=t;if(typeof e!="string")return e;let a=e.trim();if(a.length>0&&a[0]==='"'&&a.endsWith('"')&&!a.slice(1,-1).includes('"'))return a.slice(1,-1);let l=a.toLowerCase();if(l.length<=9&&l in xe)return xe[l];if(!Mr.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(kr).some(([u,i])=>{let c=i.test(a);return c&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=Hr(i);if(c)return c}return n?n(u,i):i})}catch(u){if(r)throw u;return e}}function Gr(e,t={strict:!0}){return Wr(e,t)}var Kr={id:"redirect",name:"Redirect",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function Vr(e){let t=_t(!1);return{session:Br(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var zr=(e,t)=>{let r="credentials"in Request.prototype,s=$r(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",n=e?.plugins?.flatMap(d=>d.fetchPlugins).filter(d=>d!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:u,onResponse:i,...c}=e?.fetchOptions||{},h=wr({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(d){return d?Gr(d,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Kr],...n]}),{$sessionSignal:m,session:f}=Vr(h),y=e?.plugins||[],v={},g={$sessionSignal:m,session:f},b={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},T=[{signal:"$sessionSignal",matcher(d){return d==="/sign-out"||d==="/update-user"||d.startsWith("/sign-in")||d.startsWith("/sign-up")||d==="/delete-user"||d==="/verify-email"}}];for(let d of y)d.getAtoms&&Object.assign(g,d.getAtoms?.(h)),d.pathMethods&&Object.assign(b,d.pathMethods),d.atomListeners&&T.push(...d.atomListeners);let P={notify:d=>{g[d].set(!g[d].get())},listen:(d,C)=>{g[d].subscribe(C)},atoms:g};for(let d of y)d.getActions&&Object.assign(v,d.getActions?.(h,P,e));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:b,atomListeners:T,$fetch:h,$store:P}};function Yr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Jr(e,t,r){let s=t[e],{fetchOptions:n,query:o,...a}=r||{};return s||(n?.method?n.method:a&&Object.keys(a).length>0?"POST":"GET")}function Xr(e,t,r,s,n){function o(a=[]){return new Proxy(function(){},{get(l,u){if(typeof u!="string"||u==="then"||u==="catch"||u==="finally")return;let i=[...a,u],c=e;for(let h of i)if(c&&typeof c=="object"&&h in c)c=c[h];else{c=void 0;break}return typeof c=="function"||Yr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(T=>T.replace(/[A-Z]/g,P=>`-${P.toLowerCase()}`)).join("/"),h=i[0]||{},m=i[1]||{},{query:f,fetchOptions:y,...v}=h,g={...m,...y},b=Jr(c,r,h);return await t(c,{...g,body:b==="GET"?void 0:{...v,...g?.body||{}},query:f||g?.query,method:b,async onSuccess(T){if(await g?.onSuccess?.(T),!n)return;let P=n.filter(d=>d.matcher(c));if(P.length)for(let d of P){let C=s[d.signal];if(!C)return;let _=C.get();setTimeout(()=>{C.set(!_)},10)}}})}})}return o()}p();function Qr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Zr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:s,$fetch:n,atomListeners:o,$store:a}=zr(e),l={};for(let[i,c]of Object.entries(s))l[`use${Qr(i)}`]=c;let u={...r,...l,$fetch:n,$store:a};return Xr(u,n,t,s,o)}p();p();p();function es(e){return{authorize(t,r="AND"){let s=!1;for(let[n,o]of Object.entries(t)){let a=e[n];if(!a)return{success:!1,error:`You are not allowed to access resource: ${n}`};if(Array.isArray(o))s=o.every(l=>a.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?s=l.actions.some(u=>a.includes(u)):s=l.actions.every(u=>a.includes(u))}else throw new Oe("Invalid access control request");if(s&&r==="OR")return{success:s};if(!s&&r==="AND")return{success:!1,error:`unauthorized to access resource "${n}"`}}return s?{success:s}:{success:!1,error:"Not authorized"}},statements:e}}function Et(e){return{newRole(t){return es(t)},statements:e}}var ts={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Te=Et(ts),Os=Te.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Ts=Te.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Ps=Te.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var rs=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},Rs=new rs;p();p();p();p();p();p();p();p();var ss={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Ot=Et(ss),Ss=Ot.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),As=Ot.newRole({user:[],session:[]});p();p();var ns=()=>({id:"username",$InferServerPlugin:{}}),os=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),as=()=>({id:"better-auth-client",$InferServerPlugin:{}}),is="/auth",de="nvwa_login_token",me="nvwa_current_jwt",ye="nvwa_user_profile",Tt=class{constructor(e,t,r){this.storage=r;let s=Zr({baseURL:e,basePath:is,plugins:[ns(),os(),as()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>this.storage.get(me)??this.storage.get(de)}}});this.authClient=s}async currentUser(){return await this.storage.get(ye)}async getCurrentJwt(){return this.storage.get(me)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(s)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);this.storage.set(de,e.data?.token),this.storage.set(ye,e.data?.user);let t=await this.authClient.token();this.storage.set(me,t)}async signOut(){await this.storage.remove(de),await this.storage.remove(ye)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(s)}};p();var Pt=class{constructor(e){this.http=e}async invoke(e,t){return(await this.http.request("/functions/"+e,{method:t.method||"POST",data:t.body,headers:t.headers})).body}};p();var Rt=class{async jsonRequest(e,t){let r={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,r)}async jsonRequestWithAuth(e,t,r){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,s,r)}};p();var ls="/storage",us=ls+"/generateUploadUrl",St=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+us,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=t.body;if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(r,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};p();p();p();var Ue=Jt(Qt(),1),{PostgrestClient:cs,PostgrestQueryBuilder:js,PostgrestFilterBuilder:$s,PostgrestTransformBuilder:Is,PostgrestBuilder:Ns,PostgrestError:xs}=Ue.default||Ue;p();p();var I=class At{constructor(t){if(this.headerMap=new Map,t){if(t instanceof At)t.forEach((r,s)=>this.set(s,r));else if(Array.isArray(t))for(let[r,s]of t)this.set(r,String(s));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let s=t.toLowerCase(),n=this.headerMap.get(s);this.headerMap.set(s,n?`${n}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,s]of this.headerMap.entries())t(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},jt=class $t{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof $t)this.params=new Map(t.params);else if(Array.isArray(t))for(let[r,s]of t)this.append(r,s);else if(t&&typeof t=="object")for(let[r,s]of Object.entries(t))this.set(r,s)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let r=t.split("&");for(let s of r)if(s){let[n,o]=s.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}append(t,r){let s=this.params.get(t)||[];s.push(r),this.params.set(t,s)}delete(t){this.params.delete(t)}get(t){let r=this.params.get(t);return r?r[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,r){this.params.set(t,[r])}sort(){let t=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(t)}toString(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(n)}`);return t.join("&")}forEach(t){for(let[r,s]of this.params.entries())for(let n of s)t(n,r,this)}keys(){return this.params.keys()}values(){let t=[];for(let r of this.params.values())t.push(...r);return t[Symbol.iterator]()}entries(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push([r,n]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},hs=class we{constructor(t,r){let s;if(t instanceof we)s=t.href;else if(r){let o=r instanceof we?r.href:r;s=this.resolve(o,t)}else s=t;let n=this.parseUrl(s);this.href=s,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new jt(n.search),this.hash=n.hash}resolve(t,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(t).protocol}${r}`;if(r.startsWith("/")){let o=this.parseUrl(t);return`${o.protocol}//${o.host}${r}`}let s=this.parseUrl(t),n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${n}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",n=r[4]||"",o=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let u=n.match(/^([^@]*)@(.+)$/),i="",c="",h=n;if(u){let v=u[1];h=u[2];let g=v.match(/^([^:]*):?(.*)$/);g&&(i=g[1]||"",c=g[2]||"")}let m=h.match(/^([^:]+):?(\d*)$/),f=m?m[1]:h,y=m&&m[2]?m[2]:"";return{protocol:s?`${s}:`:"",username:i,password:c,host:h,hostname:f,port:y,pathname:o,search:a,hash:l}}toString(){let t=this.searchParams.toString(),r=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};p();var fs=class It{constructor(t,r){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof I?r.headers:new I(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new It(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var J=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ps(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ps(e){return e?new I(e):new I}p();var Nt=class{constructor(){this._aborted=!1,this.listeners=new Set,this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},ds=class{constructor(){this._signal=new Nt}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function xt(e){e.URL=hs,e.URLSearchParams=jt,e.Headers=I,e.Request=fs,e.Response=J,e.AbortController=ds,e.AbortSignal=Nt}var ms="/entities",ys=(e,t)=>async(r,s)=>{console.log("customFetch",r,s);let n;if(typeof r=="string")n=r;else if(r&&typeof r=="object")if(typeof r.toString=="function"&&!r.url)n=r.toString();else if(r.url)n=r.url,s||(s={}),s.method=r.method,s.headers=r.headers,s.body=r.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let o=(s?.method||"GET").toUpperCase(),a={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((h,m)=>{a[m]=h});else if(Array.isArray(s.headers))for(let[h,m]of s.headers)a[h]=m;else Object.assign(a,s.headers);let l=s?.body,u;try{u=await e.requestWithAuth(n,{method:o,data:l,headers:a},t)}catch(h){return new J(h?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let i=u.body,c=null;return(u.headers["content-type"]||u.headers["Content-Type"]||"").startsWith("application/json")&&typeof i!="string"?c=JSON.stringify(i):typeof i=="string"||i&&(i.constructor===Blob||i.constructor===ArrayBuffer||typeof i.getReader=="function")?c=i:c=JSON.stringify(i),new J(c,{status:u.status,headers:new I(u.headers)})},Ut=(e,t,r)=>new cs(e+ms,{fetch:ys(t,r)});var gs=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let s=(t?.method||"GET").toUpperCase(),n={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{n[i]=u});else if(Array.isArray(l))for(let[u,i]of l)n[u]=i;else Object.assign(n,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),o=u}else o=l}let a=t?.timeout||3e4;return new Promise((l,u)=>{let i=t?.signal;if(i?.aborted){let f=new Error("The operation was aborted");f.name="AbortError",u(f);return}let c=!1,h=[],m=uni.request({url:r,method:s,data:o,header:n,timeout:a,success:f=>{if(c)return;c=!0;let y=f.statusCode,v="",g=new I,b=f.header||f.headers||{};Object.keys(b).forEach(T=>{let P=b[T];g.set(T,typeof P=="string"?P:String(P))}),l(new J(f.data,{status:y,statusText:v,headers:g}))},fail:f=>{if(c)return;c=!0;let y=f?.errMsg||f?.message||"Network Error",v=new Error(y);/(abort|aborted|canceled|cancelled)/i.test(String(y))&&(v.name="AbortError"),u(v)}});if(i&&typeof i.addEventListener=="function"){let f=()=>{if(c)return;try{m?.abort?.()}catch{}let y=new Error("The operation was aborted");y.name="AbortError",c=!0,u(y)};i.addEventListener("abort",f),h.push(()=>{try{i.removeEventListener?.("abort",f)}catch{}})}})},X=gs;var le=class extends Rt{async request(t,r){let s=await X(t,{method:r.method,headers:new I(r.headers),body:r.data});return{status:s.status,body:await s.json(),headers:Object.fromEntries(s.headers.entries())}}async requestWithAuth(t,r,s){let n=await this.fetchWithAuth(s,t,{method:r.method,headers:new I(r.headers),body:r.data});return{status:n.status,body:await n.json(),headers:Object.fromEntries(n.headers.entries())}}async fetchWithAuth(t,r,s){let n=await X(r,s);if(n.status===401)throw t(),new Error("\u672A\u767B\u5F55");return n}};var ue=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(t),null):s.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(t,r,s){try{let n=this.getKey(t),o={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(n,o)}catch(n){throw console.error("UniAppStorageService set error:",n),n}}async remove(t){try{let r=this.getKey(t);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(t){throw console.error("UniAppStorageService clear error:",t),t}}};var Lt=new ue,ce=new le,he=class{constructor(t,r){this.auth=new Tt(t,X,Lt),this.fileStorage=new St(t,ce),this.entities=Ut(t,ce,r),this.functions=new Pt(ce)}};0&&(module.exports={httpClient,localStorage,polyfill});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var Dt=Object.create,ue=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,Ct=Object.getOwnPropertyNames,Bt=Object.getPrototypeOf,kt=Object.prototype.hasOwnProperty,Ue=(e,t)=>()=>(e&&(t=e(e=0)),t),C=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Mt=(e,t)=>{for(var r in t)ue(e,r,{get:t[r],enumerable:!0})},De=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ct(t))!kt.call(e,n)&&n!==r&&ue(e,n,{get:()=>t[n],enumerable:!(s=Lt(t,n))||s.enumerable});return e},Ft=(e,t,r)=>(r=e!=null?Dt(Bt(e)):{},De(t||!e||!e.__esModule?ue(r,"default",{value:e,enumerable:!0}):r,e)),H=e=>De(ue({},"__esModule",{value:!0}),e),p=Ue(()=>{"use strict"}),B={};Mt(B,{__addDisposableResource:()=>at,__assign:()=>K,__asyncDelegator:()=>Qe,__asyncGenerator:()=>Xe,__asyncValues:()=>Ze,__await:()=>q,__awaiter:()=>We,__classPrivateFieldGet:()=>st,__classPrivateFieldIn:()=>ot,__classPrivateFieldSet:()=>nt,__createBinding:()=>J,__decorate:()=>Be,__disposeResources:()=>it,__esDecorate:()=>Me,__exportStar:()=>ze,__extends:()=>Le,__generator:()=>Ve,__importDefault:()=>rt,__importStar:()=>tt,__makeTemplateObject:()=>et,__metadata:()=>Ge,__param:()=>ke,__propKey:()=>qe,__read:()=>ve,__rest:()=>Ce,__rewriteRelativeImportExtension:()=>lt,__runInitializers:()=>Fe,__setFunctionName:()=>He,__spread:()=>Ke,__spreadArray:()=>Ye,__spreadArrays:()=>Je,__values:()=>ae,default:()=>ht});function Le(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");re(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Ce(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(r[s[n]]=e[s[n]]);return r}function Be(e,t,r,s){var n=arguments.length,o=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(n<3?a(o):n>3?a(t,r,o):a(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function ke(e,t){return function(r,s){t(r,s,e)}}function Me(e,t,r,s,n,o){function a(b){if(b!==void 0&&typeof b!="function")throw new TypeError("Function expected");return b}for(var l=s.kind,u=l==="getter"?"get":l==="setter"?"set":"value",i=!t&&e?s.static?e:e.prototype:null,c=t||(i?Object.getOwnPropertyDescriptor(i,s.name):{}),h,m=!1,f=r.length-1;f>=0;f--){var y={};for(var v in s)y[v]=v==="access"?{}:s[v];for(var v in s.access)y.access[v]=s.access[v];y.addInitializer=function(b){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(b||null))};var g=(0,r[f])(l==="accessor"?{get:c.get,set:c.set}:c[u],y);if(l==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(h=a(g.get))&&(c.get=h),(h=a(g.set))&&(c.set=h),(h=a(g.init))&&n.unshift(h)}else(h=a(g))&&(l==="field"?n.unshift(h):c[u]=h)}i&&Object.defineProperty(i,s.name,c),m=!0}function Fe(e,t,r){for(var s=arguments.length>2,n=0;n<t.length;n++)r=s?t[n].call(e,r):t[n].call(e);return s?r:void 0}function qe(e){return typeof e=="symbol"?e:"".concat(e)}function He(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function Ge(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function We(e,t,r,s){function n(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function l(c){try{i(s.next(c))}catch(h){a(h)}}function u(c){try{i(s.throw(c))}catch(h){a(h)}}function i(c){c.done?o(c.value):n(c.value).then(l,u)}i((s=s.apply(e,t||[])).next())})}function Ve(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,n,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(c){return u([i,c])}}function u(i){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(s=1,n&&(o=i[0]&2?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,n=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],n=0}finally{s=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ze(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&J(t,e,r)}function ae(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ve(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),n,o=[],a;try{for(;(t===void 0||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(l){a={error:l}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return o}function Ke(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ve(arguments[t]));return e}function Je(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),n=0,t=0;t<r;t++)for(var o=arguments[t],a=0,l=o.length;a<l;a++,n++)s[n]=o[a];return s}function Ye(e,t,r){if(r||arguments.length===2)for(var s=0,n=t.length,o;s<n;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return e.concat(o||Array.prototype.slice.call(t))}function q(e){return this instanceof q?(this.v=e,this):new q(e)}function Xe(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(f){return function(y){return Promise.resolve(y).then(f,h)}}function l(f,y){s[f]&&(n[f]=function(v){return new Promise(function(g,b){o.push([f,v,g,b])>1||u(f,v)})},y&&(n[f]=y(n[f])))}function u(f,y){try{i(s[f](y))}catch(v){m(o[0][3],v)}}function i(f){f.value instanceof q?Promise.resolve(f.value.v).then(c,h):m(o[0][2],f)}function c(f){u("next",f)}function h(f){u("throw",f)}function m(f,y){f(y),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Qe(e){var t,r;return t={},s("next"),s("throw",function(n){throw n}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(n,o){t[n]=e[n]?function(a){return(r=!r)?{value:q(e[n](a)),done:!1}:o?o(a):a}:o}}function Ze(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof ae=="function"?ae(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(o){r[o]=e[o]&&function(a){return new Promise(function(l,u){a=e[o](a),n(l,u,a.done,a.value)})}}function n(o,a,l,u){Promise.resolve(u).then(function(i){o({value:i,done:l})},a)}}function et(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function tt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=se(e),s=0;s<r.length;s++)r[s]!=="default"&&J(t,e,r[s]);return ut(t,e),t}function rt(e){return e&&e.__esModule?e:{default:e}}function st(e,t,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function nt(e,t,r,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r}function ot(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function at(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(n=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");n&&(s=function(){try{n.call(this)}catch(o){return Promise.reject(o)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}function it(e){function t(o){e.error=e.hasError?new ct(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var r,s=0;function n(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(n);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(o).then(n,function(a){return t(a),n()})}else s|=1}catch(a){t(a)}if(s===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return n()}function lt(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,n,o,a){return s?t?".jsx":".js":n&&(!o||!a)?r:n+o+"."+a.toLowerCase()+"js"}):e}var re,K,J,ut,se,ct,ht,G=Ue(()=>{"use strict";p(),re=function(e,t){return re=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[n]=s[n])},re(e,t)},K=function(){return K=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},K.apply(this,arguments)},J=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),ut=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},se=function(e){return se=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},se(e)},ct=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s},ht={__extends:Le,__assign:K,__rest:Ce,__decorate:Be,__param:ke,__esDecorate:Me,__runInitializers:Fe,__propKey:qe,__setFunctionName:He,__metadata:Ge,__awaiter:We,__generator:Ve,__createBinding:J,__exportStar:ze,__values:ae,__read:ve,__spread:Ke,__spreadArrays:Je,__spreadArray:Ye,__await:q,__asyncGenerator:Xe,__asyncDelegator:Qe,__asyncValues:Ze,__makeTemplateObject:et,__importStar:tt,__importDefault:rt,__classPrivateFieldGet:st,__classPrivateFieldSet:nt,__classPrivateFieldIn:ot,__addDisposableResource:at,__disposeResources:it,__rewriteRelativeImportExtension:lt}}),ft=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),pt=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),H(B)),r=t.__importDefault(ft()),s=class{constructor(n){var o,a;this.shouldThrowOnError=!1,this.method=n.method,this.url=n.url,this.headers=new Headers(n.headers),this.schema=n.schema,this.body=n.body,this.shouldThrowOnError=(o=n.shouldThrowOnError)!==null&&o!==void 0?o:!1,this.signal=n.signal,this.isMaybeSingle=(a=n.isMaybeSingle)!==null&&a!==void 0?a:!1,n.fetch?this.fetch=n.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(n,o){return this.headers=new Headers(this.headers),this.headers.set(n,o),this}then(n,o){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let a=this.fetch,l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var i,c,h,m;let f=null,y=null,v=null,g=u.status,b=u.statusText;if(u.ok){if(this.method!=="HEAD"){let d=await u.text();d===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text")?y=d:y=JSON.parse(d))}let T=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),S=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");T&&S&&S.length>1&&(v=parseInt(S[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(f={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,v=null,g=406,b="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{let T=await u.text();try{f=JSON.parse(T),Array.isArray(f)&&u.status===404&&(y=[],f=null,g=200,b="OK")}catch{u.status===404&&T===""?(g=204,b="No Content"):f={message:T}}if(f&&this.isMaybeSingle&&!((m=f?.details)===null||m===void 0)&&m.includes("0 rows")&&(f=null,g=200,b="OK"),f&&this.shouldThrowOnError)throw new r.default(f)}return{error:f,data:y,count:v,status:g,statusText:b}});return this.shouldThrowOnError||(l=l.catch(u=>{var i,c,h;return{error:{message:`${(i=u?.name)!==null&&i!==void 0?i:"FetchError"}: ${u?.message}`,details:`${(c=u?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(h=u?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(n,o)}returns(){return this}overrideTypes(){return this}};e.default=s}),dt=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),H(B)),r=t.__importDefault(pt()),s=class extends r.default{select(n){let o=!1,a=(n??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(n,{ascending:o=!0,nullsFirst:a,foreignTable:l,referencedTable:u=l}={}){let i=u?`${u}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${n}.${o?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(n,{foreignTable:o,referencedTable:a=o}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${n}`),this}range(n,o,{foreignTable:a,referencedTable:l=a}={}){let u=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(u,`${n}`),this.url.searchParams.set(i,`${o-n+1}`),this}abortSignal(n){return this.signal=n,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:n=!1,verbose:o=!1,settings:a=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[n?"analyze":null,o?"verbose":null,a?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),m=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${m}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(n){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${n}`),this}};e.default=s}),be=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),H(B)),r=t.__importDefault(dt()),s=new RegExp("[,()]"),n=class extends r.default{eq(o,a){return this.url.searchParams.append(o,`eq.${a}`),this}neq(o,a){return this.url.searchParams.append(o,`neq.${a}`),this}gt(o,a){return this.url.searchParams.append(o,`gt.${a}`),this}gte(o,a){return this.url.searchParams.append(o,`gte.${a}`),this}lt(o,a){return this.url.searchParams.append(o,`lt.${a}`),this}lte(o,a){return this.url.searchParams.append(o,`lte.${a}`),this}like(o,a){return this.url.searchParams.append(o,`like.${a}`),this}likeAllOf(o,a){return this.url.searchParams.append(o,`like(all).{${a.join(",")}}`),this}likeAnyOf(o,a){return this.url.searchParams.append(o,`like(any).{${a.join(",")}}`),this}ilike(o,a){return this.url.searchParams.append(o,`ilike.${a}`),this}ilikeAllOf(o,a){return this.url.searchParams.append(o,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(o,a){return this.url.searchParams.append(o,`ilike(any).{${a.join(",")}}`),this}is(o,a){return this.url.searchParams.append(o,`is.${a}`),this}in(o,a){let l=Array.from(new Set(a)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(o,`in.(${l})`),this}contains(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cs.{${a.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(a)}`),this}containedBy(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cd.{${a.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(a)}`),this}rangeGt(o,a){return this.url.searchParams.append(o,`sr.${a}`),this}rangeGte(o,a){return this.url.searchParams.append(o,`nxl.${a}`),this}rangeLt(o,a){return this.url.searchParams.append(o,`sl.${a}`),this}rangeLte(o,a){return this.url.searchParams.append(o,`nxr.${a}`),this}rangeAdjacent(o,a){return this.url.searchParams.append(o,`adj.${a}`),this}overlaps(o,a){return typeof a=="string"?this.url.searchParams.append(o,`ov.${a}`):this.url.searchParams.append(o,`ov.{${a.join(",")}}`),this}textSearch(o,a,{config:l,type:u}={}){let i="";u==="plain"?i="pl":u==="phrase"?i="ph":u==="websearch"&&(i="w");let c=l===void 0?"":`(${l})`;return this.url.searchParams.append(o,`${i}fts${c}.${a}`),this}match(o){return Object.entries(o).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(o,a,l){return this.url.searchParams.append(o,`not.${a}.${l}`),this}or(o,{foreignTable:a,referencedTable:l=a}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${o})`),this}filter(o,a,l){return this.url.searchParams.append(o,`${a}.${l}`),this}};e.default=n}),mt=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),H(B)),r=t.__importDefault(be()),s=class{constructor(n,{headers:o={},schema:a,fetch:l}){this.url=n,this.headers=new Headers(o),this.schema=a,this.fetch=l}select(n,o){let{head:a=!1,count:l}=o??{},u=a?"HEAD":"GET",i=!1,c=(n??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",c),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(n,{count:o,defaultToNull:a=!0}={}){var l;let u="POST";if(o&&this.headers.append("Prefer",`count=${o}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let i=n.reduce((c,h)=>c.concat(Object.keys(h)),[]);if(i.length>0){let c=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(n,{onConflict:o,ignoreDuplicates:a=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let h=n.reduce((m,f)=>m.concat(Object.keys(f)),[]);if(h.length>0){let m=[...new Set(h)].map(f=>`"${f}"`);this.url.searchParams.set("columns",m.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(n,{count:o}={}){var a;let l="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:n}={}){var o;let a="DELETE";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};e.default=s}),qt=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),H(B)),r=t.__importDefault(mt()),s=t.__importDefault(be()),n=class yt{constructor(a,{headers:l={},schema:u,fetch:i}={}){this.url=a,this.headers=new Headers(l),this.schemaName=u,this.fetch=i}from(a){let l=new URL(`${this.url}/${a}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new yt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let m,f=new URL(`${this.url}/rpc/${a}`),y;u||i?(m=u?"HEAD":"GET",Object.entries(l).filter(([g,b])=>b!==void 0).map(([g,b])=>[g,Array.isArray(b)?`{${b.join(",")}}`:`${b}`]).forEach(([g,b])=>{f.searchParams.append(g,b)})):(m="POST",y=l);let v=new Headers(this.headers);return c&&v.set("Prefer",`count=${c}`),new s.default({method:m,url:f,headers:v,schema:this.schemaName,body:y,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=n}),Ht=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),H(B)),r=t.__importDefault(qt());e.PostgrestClient=r.default;var s=t.__importDefault(mt());e.PostgrestQueryBuilder=s.default;var n=t.__importDefault(be());e.PostgrestFilterBuilder=n.default;var o=t.__importDefault(dt());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(pt());e.PostgrestBuilder=a.default;var l=t.__importDefault(ft());e.PostgrestError=l.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:n.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var Gt=Object.defineProperty,Wt=Object.defineProperties,Vt=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,zt=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable,Pe=(e,t,r)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,j=(e,t)=>{for(var r in t||(t={}))zt.call(t,r)&&Pe(e,r,t[r]);if(Re)for(var r of Re(t))Kt.call(t,r)&&Pe(e,r,t[r]);return e},x=(e,t)=>Wt(e,Vt(t)),Jt=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},Yt=async(e,t)=>{var r,s,n,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((s=c.hooks)==null?void 0:s.onRequest),i.onResponse.push((n=c.hooks)==null?void 0:n.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},Ae=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},Xt=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function Qt(e){if(typeof e=="number")return new Ae({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Ae(e);case"exponential":return new Xt(e);default:throw new Error("Invalid retry strategy")}}var Zt=async e=>{let t={},r=async s=>typeof s=="function"?await s():s;if(e?.auth){if(e.auth.type==="Bearer"){let s=await r(e.auth.token);if(!s)return t;t.authorization=`Bearer ${s}`}else if(e.auth.type==="Basic"){let s=r(e.auth.username),n=r(e.auth.password);if(!s||!n)return t;t.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(e.auth.type==="Custom"){let s=r(e.auth.value);if(!s)return t;t.authorization=`${r(e.auth.prefix)} ${s}`}}return t},er=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function tr(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let s=t.split(";").shift()||"";return er.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function rr(e){try{return JSON.parse(e),!0}catch{return!1}}function gt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function $e(e){try{return JSON.parse(e)}catch{return e}}function je(e){return typeof e=="function"}function sr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&je(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&je(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function nr(e){let t=new Headers(e?.headers),r=await Zt(e);for(let[s,n]of Object.entries(r||{}))t.set(s,n);if(!t.has("content-type")){let s=or(e?.body);s&&t.set("content-type",s)}return t}function or(e){return gt(e)?"application/json":null}function ar(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(gt(e.body)&&!t.has("content-type")){for(let[r,s]of Object.entries(e?.body))s instanceof Date&&(e.body[r]=s.toISOString());return JSON.stringify(e.body)}return e.body}function ir(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let s=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return bt.includes(s)?s.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function lr(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var ur=class vt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,vt.prototype)}};async function ne(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new ur(r.issues);return r.value}var bt=["get","post","put","patch","delete"],cr=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var s,n,o,a;let l=((n=(s=e.plugins)==null?void 0:s.find(u=>{var i;return(i=u.schema)!=null&&i.config?t.startsWith(u.schema.config.baseURL||"")||t.startsWith(u.schema.config.prefix||""):!1}))==null?void 0:n.schema)||e.schema;if(l){let u=t;(o=l.config)!=null&&o.prefix&&u.startsWith(l.config.prefix)&&(u=u.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&u.startsWith(l.config.baseURL)&&(u=u.replace(l.config.baseURL,""));let i=l.schema[u];if(i){let c=x(j({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=x(j({},c),{body:i.input?await ne(i.input,r?.body):r?.body,params:i.params?await ne(i.params,r?.params):r?.params,query:i.query?await ne(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),hr=e=>{async function t(r,s){let n=x(j(j({},e),s),{plugins:[...e?.plugins||[],cr(e||{})]});if(e?.catchAllError)try{return await de(r,n)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await de(r,n)}return t};function fr(e,t){let{baseURL:r,params:s,query:n}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];bt.includes(c)&&(e=e.replace(`@${c}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(n||{}))h!=null&&u.set(c,String(h));if(s)if(Array.isArray(s)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,m]of c.entries()){let f=s[h];a=a.replace(m,f)}}else for(let[c,h]of Object.entries(s))a=a.replace(`:${c}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=u.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var de=async(e,t)=>{var r,s,n,o,a,l,u,i;let{hooks:c,url:h,options:m}=await Yt(e,t),f=sr(m),y=new AbortController,v=(r=m.signal)!=null?r:y.signal,g=fr(h,m),b=ar(m),T=await nr(m),S=ir(h,m),d=x(j({},m),{url:g,headers:T,body:b,method:S,signal:v});for(let R of c.onRequest)if(R){let E=await R(d);E instanceof Object&&(d=E)}("pipeTo"in d&&typeof d.pipeTo=="function"||typeof((s=t?.body)==null?void 0:s.pipe)=="function")&&("duplex"in d||(d.duplex="half"));let{clearTimeout:L}=lr(m,y),_=await f(d.url,d);L();let Te={response:_,request:d};for(let R of c.onResponse)if(R){let E=await R(x(j({},Te),{response:(n=t?.hookOptions)!=null&&n.cloneResponse?_.clone():_}));E instanceof Response?_=E:E instanceof Object&&(_=E.response)}if(_.ok){if(d.method==="HEAD")return{data:"",error:null};let R=tr(_),E={data:"",response:_,request:d};if(R==="json"||R==="text"){let k=await _.text(),M=await((o=d.jsonParser)!=null?o:$e)(k);E.data=M}else E.data=await _[R]();d?.output&&d.output&&!d.disableValidation&&(E.data=await ne(d.output,E.data));for(let k of c.onSuccess)k&&await k(x(j({},E),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?E.data:{data:E.data,error:null}}let Nt=(l=t?.jsonParser)!=null?l:$e,Q=await _.text(),Se=rr(Q),fe=Se?await Nt(Q):null,Ut={response:_,responseText:Q,request:d,error:x(j({},fe),{status:_.status,statusText:_.statusText})};for(let R of c.onError)R&&await R(x(j({},Ut),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let R=Qt(t.retry),E=(i=t.retryAttempt)!=null?i:0;if(await R.shouldAttemptRetry(E,_)){for(let M of c.onRetry)M&&await M(Te);let k=R.getDelay(E);return await new Promise(M=>setTimeout(M,k)),await de(e,x(j({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new Jt(_.status,_.statusText,Se?fe:Q);return{data:null,error:x(j({},fe),{status:_.status,statusText:_.statusText})}};p();p();var oe=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?oe:globalThis),A=new Proxy(oe,{get(e,t){return W()[t]??oe[t]},has(e,t){let r=W();return t in r||t in oe},set(e,t,r){let s=W(!0);return s[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=W(!0);return delete r[t],!0},ownKeys(){let e=W(!0);return Object.keys(e)}}),hs=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function w(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var fs=Object.freeze({get BETTER_AUTH_SECRET(){return w("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return w("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return w("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return w("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return w("NODE_ENV","development")},get PACKAGE_VERSION(){return w("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return w("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),V=1,O=4,N=8,P=24,Ie={eterm:O,cons25:O,console:O,cygwin:O,dtterm:O,gnome:O,hurd:O,jfbterm:O,konsole:O,kterm:O,mlterm:O,mosh:P,putty:O,st:O,"rxvt-unicode-24bit":P,terminator:P,"xterm-kitty":P},pr=new Map(Object.entries({APPVEYOR:N,BUILDKITE:N,CIRCLECI:P,DRONE:N,GITEA_ACTIONS:P,GITHUB_ACTIONS:P,GITLAB_CI:N,TRAVIS:N})),dr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function mr(){if(w("FORCE_COLOR")!==void 0)switch(w("FORCE_COLOR")){case"":case"1":case"true":return O;case"2":return N;case"3":return P;default:return V}if(w("NODE_DISABLE_COLORS")!==void 0&&w("NODE_DISABLE_COLORS")!==""||w("NO_COLOR")!==void 0&&w("NO_COLOR")!==""||w("TERM")==="dumb")return V;if(w("TMUX"))return P;if("TF_BUILD"in A&&"AGENT_NAME"in A)return O;if("CI"in A){for(let{0:e,1:t}of pr)if(e in A)return t;return w("CI_NAME")==="codeship"?N:V}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(w("TEAMCITY_VERSION"))!==null?O:V;switch(w("TERM_PROGRAM")){case"iTerm.app":return!w("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(w("TERM_PROGRAM_VERSION"))!==null?N:P;case"HyperTerm":case"MacTerm":return P;case"Apple_Terminal":return N}if(w("COLORTERM")==="truecolor"||w("COLORTERM")==="24bit")return P;if(w("TERM")){if(/truecolor/.exec(w("TERM"))!==null)return P;if(/^xterm-256/.exec(w("TERM"))!==null)return N;let e=w("TERM").toLowerCase();if(Ie[e])return Ie[e];if(dr.some(t=>t.exec(e)!==null))return O}return w("COLORTERM")?O:V}var U={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},me=["info","success","warn","error","debug"];function yr(e,t){return me.indexOf(t)<=me.indexOf(e)}var gr={info:U.fg.blue,success:U.fg.green,warn:U.fg.yellow,error:U.fg.red,debug:U.fg.magenta},vr=(e,t,r)=>{let s=new Date().toISOString();return r?`${U.dim}${s}${U.reset} ${gr[e]}${e.toUpperCase()}${U.reset} ${U.bright}[Better Auth]:${U.reset} ${t}`:`${s} ${e.toUpperCase()} [Better Auth]: ${t}`},br=e=>{let t=e?.disabled!==!0,r=e?.level??"error",s=e?.disableColors!==void 0?!e.disableColors:mr()!==1,n=(o,a,l=[])=>{if(!t||!yr(r,o))return;let u=vr(o,a,s);if(!e||typeof e.log!="function"){o==="error"?console.error(u,...l):o==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(me.map(o=>[o,(...[a,...l])=>n(o,a,l)])),get level(){return r}}},ps=br();p();p();var we=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function wr(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new we(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function z(e,t="/api/auth"){if(wr(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function _r(e,t,r,s){if(e)return z(e,t);if(s!==!1){let a=A.BETTER_AUTH_URL||A.NEXT_PUBLIC_BETTER_AUTH_URL||A.PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_AUTH_URL||(A.BASE_URL!=="/"?A.BASE_URL:void 0);if(a)return z(a,t)}let n=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(n&&o)return z(`${o}://${n}`,t);if(r){let a=Er(r.url);if(!a)throw new we("Could not get origin from request. Please provide a valid base URL.");return z(a,t)}if(typeof window<"u"&&window.location)return z(window.location.origin,t)}function Er(e){try{return new URL(e).origin}catch{return null}}p();p();p();var ye=Symbol("clean"),$=[],D=0,Z=4,Or=0,wt=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(s){return r.lc=t.push(s),()=>{for(let o=D+Z;o<$.length;)$[o]===s?$.splice(o,Z):o+=Z;let n=t.indexOf(s);~n&&(t.splice(n,1),--r.lc||r.off())}},notify(s,n){Or++;let o=!$.length;for(let a of t)$.push(a,r.value,s,n);if(o){for(D=0;D<$.length;D+=Z)$[D]($[D+1],$[D+2],$[D+3]);$.length=0}},off(){},set(s){let n=r.value;n!==s&&(r.value=s,r.notify(n))},subscribe(s){let n=r.listen(s);return s(r.value),n},value:e};return process.env.NODE_ENV!=="production"&&(r[ye]=()=>{t=[],r.lc=0,r.off()}),r};p();var Tr=5,F=6,ee=10,Sr=(e,t,r,s)=>(e.events=e.events||{},e.events[r+ee]||(e.events[r+ee]=s(n=>{e.events[r].reduceRight((o,a)=>(a(o),o),{shared:{},...n})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let n=e.events[r],o=n.indexOf(t);n.splice(o,1),n.length||(delete e.events[r],e.events[r+ee](),delete e.events[r+ee])}),Rr=1e3,Pr=(e,t)=>Sr(e,r=>{let s=t(r);s&&e.events[F].push(s)},Tr,r=>{let s=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),s(...o));let n=e.off;if(e.events[F]=[],e.off=()=>{n(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[F])o();e.events[F]=[]}},Rr)},process.env.NODE_ENV!=="production"){let o=e[ye];e[ye]=()=>{for(let a of e.events[F])a();e.events[F]=[],e.active=!1,o()}}return()=>{e.listen=s,e.off=n}});p();var Ar=typeof window>"u",$r=(e,t,r,s)=>{let n=wt({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let u=typeof s=="function"?s({data:n.get().data,error:n.get().error,isPending:n.get().isPending}):s;r(t,{...u,query:{...u?.query,...l?.query},async onSuccess(i){n.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onSuccess?.(i)},async onError(i){let{request:c}=i,h=typeof c.retry=="number"?c.retry:c.retry?.attempts,m=c.retryAttempt||0;h&&m<h||(n.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onError?.(i))},async onRequest(i){let c=n.get();n.set({isPending:c.data===null,data:c.data,error:null,isRefetching:!0,refetch:n.value.refetch}),await u?.onRequest?.(i)}}).catch(i=>{n.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{Ar||(a?o():Pr(n,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{n.off(),l.off(),clearTimeout(u)}}))});return n};p();var jr={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Ir=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,xe={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},xr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Nr(e){return e instanceof Date&&!isNaN(e.getTime())}function Ur(e){let t=xr.exec(e);if(!t)return null;let[,r,s,n,o,a,l,u,i,c,h]=t,m=new Date(Date.UTC(parseInt(r,10),parseInt(s,10)-1,parseInt(n,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),u?parseInt(u.padEnd(3,"0"),10):0));if(i){let f=(parseInt(c,10)*60+parseInt(h,10))*(i==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+f)}return Nr(m)?m:null}function Dr(e,t={}){let{strict:r=!1,warnings:s=!1,reviver:n,parseDates:o=!0}=t;if(typeof e!="string")return e;let a=e.trim();if(a.length>0&&a[0]==='"'&&a.endsWith('"')&&!a.slice(1,-1).includes('"'))return a.slice(1,-1);let l=a.toLowerCase();if(l.length<=9&&l in xe)return xe[l];if(!Ir.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(jr).some(([u,i])=>{let c=i.test(a);return c&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=Ur(i);if(c)return c}return n?n(u,i):i})}catch(u){if(r)throw u;return e}}function Lr(e,t={strict:!0}){return Dr(e,t)}var Cr={id:"redirect",name:"Redirect",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function Br(e){let t=wt(!1);return{session:$r(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var kr=(e,t)=>{let r="credentials"in Request.prototype,s=_r(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",n=e?.plugins?.flatMap(d=>d.fetchPlugins).filter(d=>d!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:u,onResponse:i,...c}=e?.fetchOptions||{},h=hr({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(d){return d?Lr(d,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Cr],...n]}),{$sessionSignal:m,session:f}=Br(h),y=e?.plugins||[],v={},g={$sessionSignal:m,session:f},b={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},T=[{signal:"$sessionSignal",matcher(d){return d==="/sign-out"||d==="/update-user"||d.startsWith("/sign-in")||d.startsWith("/sign-up")||d==="/delete-user"||d==="/verify-email"}}];for(let d of y)d.getAtoms&&Object.assign(g,d.getAtoms?.(h)),d.pathMethods&&Object.assign(b,d.pathMethods),d.atomListeners&&T.push(...d.atomListeners);let S={notify:d=>{g[d].set(!g[d].get())},listen:(d,L)=>{g[d].subscribe(L)},atoms:g};for(let d of y)d.getActions&&Object.assign(v,d.getActions?.(h,S,e));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:b,atomListeners:T,$fetch:h,$store:S}};function Mr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Fr(e,t,r){let s=t[e],{fetchOptions:n,query:o,...a}=r||{};return s||(n?.method?n.method:a&&Object.keys(a).length>0?"POST":"GET")}function qr(e,t,r,s,n){function o(a=[]){return new Proxy(function(){},{get(l,u){if(typeof u!="string"||u==="then"||u==="catch"||u==="finally")return;let i=[...a,u],c=e;for(let h of i)if(c&&typeof c=="object"&&h in c)c=c[h];else{c=void 0;break}return typeof c=="function"||Mr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(T=>T.replace(/[A-Z]/g,S=>`-${S.toLowerCase()}`)).join("/"),h=i[0]||{},m=i[1]||{},{query:f,fetchOptions:y,...v}=h,g={...m,...y},b=Fr(c,r,h);return await t(c,{...g,body:b==="GET"?void 0:{...v,...g?.body||{}},query:f||g?.query,method:b,async onSuccess(T){if(await g?.onSuccess?.(T),!n)return;let S=n.filter(d=>d.matcher(c));if(S.length)for(let d of S){let L=s[d.signal];if(!L)return;let _=L.get();setTimeout(()=>{L.set(!_)},10)}}})}})}return o()}p();function Hr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Gr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:s,$fetch:n,atomListeners:o,$store:a}=kr(e),l={};for(let[i,c]of Object.entries(s))l[`use${Hr(i)}`]=c;let u={...r,...l,$fetch:n,$store:a};return qr(u,n,t,s,o)}p();p();p();function Wr(e){return{authorize(t,r="AND"){let s=!1;for(let[n,o]of Object.entries(t)){let a=e[n];if(!a)return{success:!1,error:`You are not allowed to access resource: ${n}`};if(Array.isArray(o))s=o.every(l=>a.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?s=l.actions.some(u=>a.includes(u)):s=l.actions.every(u=>a.includes(u))}else throw new we("Invalid access control request");if(s&&r==="OR")return{success:s};if(!s&&r==="AND")return{success:!1,error:`unauthorized to access resource "${n}"`}}return s?{success:s}:{success:!1,error:"Not authorized"}},statements:e}}function _t(e){return{newRole(t){return Wr(t)},statements:e}}var Vr={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},_e=_t(Vr),ds=_e.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ms=_e.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ys=_e.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var zr=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},gs=new zr;p();p();p();p();p();p();p();p();var Kr={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Et=_t(Kr),vs=Et.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),bs=Et.newRole({user:[],session:[]});p();p();var Jr=()=>({id:"username",$InferServerPlugin:{}}),Yr=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),Xr=()=>({id:"better-auth-client",$InferServerPlugin:{}}),Qr="/auth",te="nvwa_login_token",pe="nvwa_user_profile",Ot=class{constructor(e,t,r){this.storage=r;let s=Gr({baseURL:e,basePath:Qr,plugins:[Jr(),Yr(),Xr()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>r.get(te)},onSuccess:n=>{let o=n.response.headers.get("set-auth-token");console.log("success",n.data,n.request),o&&r.set(te,o)}}});this.authClient=s}async currentUser(){return await this.storage.get(pe)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.saveSession(t)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.saveSession(r)}saveSession(e){if(e.error)throw new Error(e.error.message);this.storage.set(te,e.data?.token),this.storage.set(pe,e.data?.user)}async signOut(){await this.storage.remove(te),await this.storage.remove(pe)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.saveSession(s)}};p();var Tt=class{constructor(e){this.http=e}async invoke(e,t){return(await this.http.request("/functions/"+e,{method:t.method||"POST",data:t.body,headers:t.headers})).body}};p();var St=class{async jsonRequest(e,t){let r={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,r)}async jsonRequestWithAuth(e,t,r){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,s,r)}};p();var Zr="/storage",es=Zr+"/generateUploadUrl",Rt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+es,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=t.body;if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(r,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};p();p();p();var Ne=Ft(Ht(),1),{PostgrestClient:ts,PostgrestQueryBuilder:ws,PostgrestFilterBuilder:_s,PostgrestTransformBuilder:Es,PostgrestBuilder:Os,PostgrestError:Ts}=Ne.default||Ne;p();p();var I=class Pt{constructor(t){if(this.headerMap=new Map,t){if(t instanceof Pt)t.forEach((r,s)=>this.set(s,r));else if(Array.isArray(t))for(let[r,s]of t)this.set(r,String(s));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let s=t.toLowerCase(),n=this.headerMap.get(s);this.headerMap.set(s,n?`${n}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,s]of this.headerMap.entries())t(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},At=class $t{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof $t)this.params=new Map(t.params);else if(Array.isArray(t))for(let[r,s]of t)this.append(r,s);else if(t&&typeof t=="object")for(let[r,s]of Object.entries(t))this.set(r,s)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let r=t.split("&");for(let s of r)if(s){let[n,o]=s.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}append(t,r){let s=this.params.get(t)||[];s.push(r),this.params.set(t,s)}delete(t){this.params.delete(t)}get(t){let r=this.params.get(t);return r?r[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,r){this.params.set(t,[r])}sort(){let t=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(t)}toString(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(n)}`);return t.join("&")}forEach(t){for(let[r,s]of this.params.entries())for(let n of s)t(n,r,this)}keys(){return this.params.keys()}values(){let t=[];for(let r of this.params.values())t.push(...r);return t[Symbol.iterator]()}entries(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push([r,n]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},rs=class ge{constructor(t,r){let s;if(t instanceof ge)s=t.href;else if(r){let o=r instanceof ge?r.href:r;s=this.resolve(o,t)}else s=t;let n=this.parseUrl(s);this.href=s,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new At(n.search),this.hash=n.hash}resolve(t,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(t).protocol}${r}`;if(r.startsWith("/")){let o=this.parseUrl(t);return`${o.protocol}//${o.host}${r}`}let s=this.parseUrl(t),n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${n}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",n=r[4]||"",o=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let u=n.match(/^([^@]*)@(.+)$/),i="",c="",h=n;if(u){let v=u[1];h=u[2];let g=v.match(/^([^:]*):?(.*)$/);g&&(i=g[1]||"",c=g[2]||"")}let m=h.match(/^([^:]+):?(\d*)$/),f=m?m[1]:h,y=m&&m[2]?m[2]:"";return{protocol:s?`${s}:`:"",username:i,password:c,host:h,hostname:f,port:y,pathname:o,search:a,hash:l}}toString(){let t=this.searchParams.toString(),r=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};p();var ss=class jt{constructor(t,r){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof I?r.headers:new I(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new jt(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var Y=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ns(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ns(e){return e?new I(e):new I}p();var It=class{constructor(){this._aborted=!1,this.listeners=new Set,this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},os=class{constructor(){this._signal=new It}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function as(e){e.URL=rs,e.URLSearchParams=At,e.Headers=I,e.Request=ss,e.Response=Y,e.AbortController=os,e.AbortSignal=It}var is="/entities",ls=(e,t)=>async(r,s)=>{console.log("customFetch",r,s);let n;if(typeof r=="string")n=r;else if(r&&typeof r=="object")if(typeof r.toString=="function"&&!r.url)n=r.toString();else if(r.url)n=r.url,s||(s={}),s.method=r.method,s.headers=r.headers,s.body=r.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let o=(s?.method||"GET").toUpperCase(),a={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((h,m)=>{a[m]=h});else if(Array.isArray(s.headers))for(let[h,m]of s.headers)a[h]=m;else Object.assign(a,s.headers);let l=s?.body,u;try{u=await e.requestWithAuth(n,{method:o,data:l,headers:a},t)}catch(h){return new Y(h?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let i=u.body,c=null;return(u.headers["content-type"]||u.headers["Content-Type"]||"").startsWith("application/json")&&typeof i!="string"?c=JSON.stringify(i):typeof i=="string"||i&&(i.constructor===Blob||i.constructor===ArrayBuffer||typeof i.getReader=="function")?c=i:c=JSON.stringify(i),new Y(c,{status:u.status,headers:new I(u.headers)})},xt=(e,t,r)=>new ts(e+is,{fetch:ls(t,r)});var us=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let s=(t?.method||"GET").toUpperCase(),n={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{n[i]=u});else if(Array.isArray(l))for(let[u,i]of l)n[u]=i;else Object.assign(n,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),o=u}else o=l}let a=t?.timeout||3e4;return new Promise((l,u)=>{let i=t?.signal;if(i?.aborted){let f=new Error("The operation was aborted");f.name="AbortError",u(f);return}let c=!1,h=[],m=uni.request({url:r,method:s,data:o,header:n,timeout:a,success:f=>{if(c)return;c=!0;let y=f.statusCode,v="",g=new I,b=f.header||f.headers||{};Object.keys(b).forEach(T=>{let S=b[T];g.set(T,typeof S=="string"?S:String(S))}),l(new Y(f.data,{status:y,statusText:v,headers:g}))},fail:f=>{if(c)return;c=!0;let y=f?.errMsg||f?.message||"Network Error",v=new Error(y);/(abort|aborted|canceled|cancelled)/i.test(String(y))&&(v.name="AbortError"),u(v)}});if(i&&typeof i.addEventListener=="function"){let f=()=>{if(c)return;try{m?.abort?.()}catch{}let y=new Error("The operation was aborted");y.name="AbortError",c=!0,u(y)};i.addEventListener("abort",f),h.push(()=>{try{i.removeEventListener?.("abort",f)}catch{}})}})},X=us;var ce=class extends St{async request(t,r){let s=await X(t,{method:r.method,headers:new I(r.headers),body:r.data});return{status:s.status,body:await s.json(),headers:Object.fromEntries(s.headers.entries())}}async requestWithAuth(t,r,s){let n=await this.fetchWithAuth(s,t,{method:r.method,headers:new I(r.headers),body:r.data});return{status:n.status,body:await n.json(),headers:Object.fromEntries(n.headers.entries())}}async fetchWithAuth(t,r,s){let n=await X(r,s);if(n.status===401)throw t(),new Error("\u672A\u767B\u5F55");return n}};var he=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(t),null):s.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(t,r,s){try{let n=this.getKey(t),o={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(n,o)}catch(n){throw console.error("UniAppStorageService set error:",n),n}}async remove(t){try{let r=this.getKey(t);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(t){throw console.error("UniAppStorageService clear error:",t),t}}};var cs=new he,Ee=new ce,Oe=class{constructor(t,r){this.auth=new Ot(t,X,cs),this.fileStorage=new Rt(t,Ee),this.entities=xt(t,Ee,r),this.functions=new Tt(Ee)}};export{Oe as default,Ee as httpClient,cs as localStorage,as as polyfill};
1
+ var Ct=Object.create,le=Object.defineProperty,Dt=Object.getOwnPropertyDescriptor,Bt=Object.getOwnPropertyNames,kt=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty,Le=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ft=(e,t)=>{for(var r in t)le(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Bt(t))!Mt.call(e,n)&&n!==r&&le(e,n,{get:()=>t[n],enumerable:!(s=Dt(t,n))||s.enumerable});return e},qt=(e,t,r)=>(r=e!=null?Ct(kt(e)):{},Ce(t||!e||!e.__esModule?le(r,"default",{value:e,enumerable:!0}):r,e)),H=e=>Ce(le({},"__esModule",{value:!0}),e),p=Le(()=>{"use strict"}),B={};Ft(B,{__addDisposableResource:()=>it,__assign:()=>z,__asyncDelegator:()=>Ze,__asyncGenerator:()=>Qe,__asyncValues:()=>et,__await:()=>q,__awaiter:()=>Ke,__classPrivateFieldGet:()=>nt,__classPrivateFieldIn:()=>at,__classPrivateFieldSet:()=>ot,__createBinding:()=>Y,__decorate:()=>ke,__disposeResources:()=>lt,__esDecorate:()=>Fe,__exportStar:()=>ze,__extends:()=>De,__generator:()=>Ve,__importDefault:()=>st,__importStar:()=>rt,__makeTemplateObject:()=>tt,__metadata:()=>Ge,__param:()=>Me,__propKey:()=>He,__read:()=>be,__rest:()=>Be,__rewriteRelativeImportExtension:()=>ut,__runInitializers:()=>qe,__setFunctionName:()=>We,__spread:()=>Ye,__spreadArray:()=>Xe,__spreadArrays:()=>Je,__values:()=>oe,default:()=>ft});function De(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");te(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Be(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(r[s[n]]=e[s[n]]);return r}function ke(e,t,r,s){var n=arguments.length,o=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(n<3?a(o):n>3?a(t,r,o):a(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function Me(e,t){return function(r,s){t(r,s,e)}}function Fe(e,t,r,s,n,o){function a(b){if(b!==void 0&&typeof b!="function")throw new TypeError("Function expected");return b}for(var l=s.kind,u=l==="getter"?"get":l==="setter"?"set":"value",i=!t&&e?s.static?e:e.prototype:null,c=t||(i?Object.getOwnPropertyDescriptor(i,s.name):{}),h,m=!1,f=r.length-1;f>=0;f--){var y={};for(var v in s)y[v]=v==="access"?{}:s[v];for(var v in s.access)y.access[v]=s.access[v];y.addInitializer=function(b){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(b||null))};var g=(0,r[f])(l==="accessor"?{get:c.get,set:c.set}:c[u],y);if(l==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(h=a(g.get))&&(c.get=h),(h=a(g.set))&&(c.set=h),(h=a(g.init))&&n.unshift(h)}else(h=a(g))&&(l==="field"?n.unshift(h):c[u]=h)}i&&Object.defineProperty(i,s.name,c),m=!0}function qe(e,t,r){for(var s=arguments.length>2,n=0;n<t.length;n++)r=s?t[n].call(e,r):t[n].call(e);return s?r:void 0}function He(e){return typeof e=="symbol"?e:"".concat(e)}function We(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function Ge(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Ke(e,t,r,s){function n(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function l(c){try{i(s.next(c))}catch(h){a(h)}}function u(c){try{i(s.throw(c))}catch(h){a(h)}}function i(c){c.done?o(c.value):n(c.value).then(l,u)}i((s=s.apply(e,t||[])).next())})}function Ve(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,n,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(c){return u([i,c])}}function u(i){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(s=1,n&&(o=i[0]&2?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,n=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],n=0}finally{s=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ze(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Y(t,e,r)}function oe(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function be(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),n,o=[],a;try{for(;(t===void 0||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(l){a={error:l}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return o}function Ye(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(be(arguments[t]));return e}function Je(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),n=0,t=0;t<r;t++)for(var o=arguments[t],a=0,l=o.length;a<l;a++,n++)s[n]=o[a];return s}function Xe(e,t,r){if(r||arguments.length===2)for(var s=0,n=t.length,o;s<n;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return e.concat(o||Array.prototype.slice.call(t))}function q(e){return this instanceof q?(this.v=e,this):new q(e)}function Qe(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(f){return function(y){return Promise.resolve(y).then(f,h)}}function l(f,y){s[f]&&(n[f]=function(v){return new Promise(function(g,b){o.push([f,v,g,b])>1||u(f,v)})},y&&(n[f]=y(n[f])))}function u(f,y){try{i(s[f](y))}catch(v){m(o[0][3],v)}}function i(f){f.value instanceof q?Promise.resolve(f.value.v).then(c,h):m(o[0][2],f)}function c(f){u("next",f)}function h(f){u("throw",f)}function m(f,y){f(y),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Ze(e){var t,r;return t={},s("next"),s("throw",function(n){throw n}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(n,o){t[n]=e[n]?function(a){return(r=!r)?{value:q(e[n](a)),done:!1}:o?o(a):a}:o}}function et(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof oe=="function"?oe(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(o){r[o]=e[o]&&function(a){return new Promise(function(l,u){a=e[o](a),n(l,u,a.done,a.value)})}}function n(o,a,l,u){Promise.resolve(u).then(function(i){o({value:i,done:l})},a)}}function tt(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function rt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=re(e),s=0;s<r.length;s++)r[s]!=="default"&&Y(t,e,r[s]);return ct(t,e),t}function st(e){return e&&e.__esModule?e:{default:e}}function nt(e,t,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function ot(e,t,r,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r}function at(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function it(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(n=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");n&&(s=function(){try{n.call(this)}catch(o){return Promise.reject(o)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}function lt(e){function t(o){e.error=e.hasError?new ht(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var r,s=0;function n(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(n);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(o).then(n,function(a){return t(a),n()})}else s|=1}catch(a){t(a)}if(s===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return n()}function ut(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,n,o,a){return s?t?".jsx":".js":n&&(!o||!a)?r:n+o+"."+a.toLowerCase()+"js"}):e}var te,z,Y,ct,re,ht,ft,W=Le(()=>{"use strict";p(),te=function(e,t){return te=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[n]=s[n])},te(e,t)},z=function(){return z=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},z.apply(this,arguments)},Y=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),ct=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},re=function(e){return re=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},re(e)},ht=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s},ft={__extends:De,__assign:z,__rest:Be,__decorate:ke,__param:Me,__esDecorate:Fe,__runInitializers:qe,__propKey:He,__setFunctionName:We,__metadata:Ge,__awaiter:Ke,__generator:Ve,__createBinding:Y,__exportStar:ze,__values:oe,__read:be,__spread:Ye,__spreadArrays:Je,__spreadArray:Xe,__await:q,__asyncGenerator:Qe,__asyncDelegator:Ze,__asyncValues:et,__makeTemplateObject:tt,__importStar:rt,__importDefault:st,__classPrivateFieldGet:nt,__classPrivateFieldSet:ot,__classPrivateFieldIn:at,__addDisposableResource:it,__disposeResources:lt,__rewriteRelativeImportExtension:ut}}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),dt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),H(B)),r=t.__importDefault(pt()),s=class{constructor(n){var o,a;this.shouldThrowOnError=!1,this.method=n.method,this.url=n.url,this.headers=new Headers(n.headers),this.schema=n.schema,this.body=n.body,this.shouldThrowOnError=(o=n.shouldThrowOnError)!==null&&o!==void 0?o:!1,this.signal=n.signal,this.isMaybeSingle=(a=n.isMaybeSingle)!==null&&a!==void 0?a:!1,n.fetch?this.fetch=n.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(n,o){return this.headers=new Headers(this.headers),this.headers.set(n,o),this}then(n,o){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let a=this.fetch,l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var i,c,h,m;let f=null,y=null,v=null,g=u.status,b=u.statusText;if(u.ok){if(this.method!=="HEAD"){let d=await u.text();d===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text")?y=d:y=JSON.parse(d))}let T=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),P=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");T&&P&&P.length>1&&(v=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(f={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,v=null,g=406,b="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{let T=await u.text();try{f=JSON.parse(T),Array.isArray(f)&&u.status===404&&(y=[],f=null,g=200,b="OK")}catch{u.status===404&&T===""?(g=204,b="No Content"):f={message:T}}if(f&&this.isMaybeSingle&&!((m=f?.details)===null||m===void 0)&&m.includes("0 rows")&&(f=null,g=200,b="OK"),f&&this.shouldThrowOnError)throw new r.default(f)}return{error:f,data:y,count:v,status:g,statusText:b}});return this.shouldThrowOnError||(l=l.catch(u=>{var i,c,h;return{error:{message:`${(i=u?.name)!==null&&i!==void 0?i:"FetchError"}: ${u?.message}`,details:`${(c=u?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(h=u?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(n,o)}returns(){return this}overrideTypes(){return this}};e.default=s}),mt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),H(B)),r=t.__importDefault(dt()),s=class extends r.default{select(n){let o=!1,a=(n??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(n,{ascending:o=!0,nullsFirst:a,foreignTable:l,referencedTable:u=l}={}){let i=u?`${u}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${n}.${o?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(n,{foreignTable:o,referencedTable:a=o}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${n}`),this}range(n,o,{foreignTable:a,referencedTable:l=a}={}){let u=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(u,`${n}`),this.url.searchParams.set(i,`${o-n+1}`),this}abortSignal(n){return this.signal=n,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:n=!1,verbose:o=!1,settings:a=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[n?"analyze":null,o?"verbose":null,a?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),m=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${m}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(n){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${n}`),this}};e.default=s}),we=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),H(B)),r=t.__importDefault(mt()),s=new RegExp("[,()]"),n=class extends r.default{eq(o,a){return this.url.searchParams.append(o,`eq.${a}`),this}neq(o,a){return this.url.searchParams.append(o,`neq.${a}`),this}gt(o,a){return this.url.searchParams.append(o,`gt.${a}`),this}gte(o,a){return this.url.searchParams.append(o,`gte.${a}`),this}lt(o,a){return this.url.searchParams.append(o,`lt.${a}`),this}lte(o,a){return this.url.searchParams.append(o,`lte.${a}`),this}like(o,a){return this.url.searchParams.append(o,`like.${a}`),this}likeAllOf(o,a){return this.url.searchParams.append(o,`like(all).{${a.join(",")}}`),this}likeAnyOf(o,a){return this.url.searchParams.append(o,`like(any).{${a.join(",")}}`),this}ilike(o,a){return this.url.searchParams.append(o,`ilike.${a}`),this}ilikeAllOf(o,a){return this.url.searchParams.append(o,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(o,a){return this.url.searchParams.append(o,`ilike(any).{${a.join(",")}}`),this}is(o,a){return this.url.searchParams.append(o,`is.${a}`),this}in(o,a){let l=Array.from(new Set(a)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(o,`in.(${l})`),this}contains(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cs.{${a.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(a)}`),this}containedBy(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cd.{${a.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(a)}`),this}rangeGt(o,a){return this.url.searchParams.append(o,`sr.${a}`),this}rangeGte(o,a){return this.url.searchParams.append(o,`nxl.${a}`),this}rangeLt(o,a){return this.url.searchParams.append(o,`sl.${a}`),this}rangeLte(o,a){return this.url.searchParams.append(o,`nxr.${a}`),this}rangeAdjacent(o,a){return this.url.searchParams.append(o,`adj.${a}`),this}overlaps(o,a){return typeof a=="string"?this.url.searchParams.append(o,`ov.${a}`):this.url.searchParams.append(o,`ov.{${a.join(",")}}`),this}textSearch(o,a,{config:l,type:u}={}){let i="";u==="plain"?i="pl":u==="phrase"?i="ph":u==="websearch"&&(i="w");let c=l===void 0?"":`(${l})`;return this.url.searchParams.append(o,`${i}fts${c}.${a}`),this}match(o){return Object.entries(o).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(o,a,l){return this.url.searchParams.append(o,`not.${a}.${l}`),this}or(o,{foreignTable:a,referencedTable:l=a}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${o})`),this}filter(o,a,l){return this.url.searchParams.append(o,`${a}.${l}`),this}};e.default=n}),yt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),H(B)),r=t.__importDefault(we()),s=class{constructor(n,{headers:o={},schema:a,fetch:l}){this.url=n,this.headers=new Headers(o),this.schema=a,this.fetch=l}select(n,o){let{head:a=!1,count:l}=o??{},u=a?"HEAD":"GET",i=!1,c=(n??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",c),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(n,{count:o,defaultToNull:a=!0}={}){var l;let u="POST";if(o&&this.headers.append("Prefer",`count=${o}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let i=n.reduce((c,h)=>c.concat(Object.keys(h)),[]);if(i.length>0){let c=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(n,{onConflict:o,ignoreDuplicates:a=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let h=n.reduce((m,f)=>m.concat(Object.keys(f)),[]);if(h.length>0){let m=[...new Set(h)].map(f=>`"${f}"`);this.url.searchParams.set("columns",m.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(n,{count:o}={}){var a;let l="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:n}={}){var o;let a="DELETE";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};e.default=s}),Ht=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),H(B)),r=t.__importDefault(yt()),s=t.__importDefault(we()),n=class gt{constructor(a,{headers:l={},schema:u,fetch:i}={}){this.url=a,this.headers=new Headers(l),this.schemaName=u,this.fetch=i}from(a){let l=new URL(`${this.url}/${a}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new gt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let m,f=new URL(`${this.url}/rpc/${a}`),y;u||i?(m=u?"HEAD":"GET",Object.entries(l).filter(([g,b])=>b!==void 0).map(([g,b])=>[g,Array.isArray(b)?`{${b.join(",")}}`:`${b}`]).forEach(([g,b])=>{f.searchParams.append(g,b)})):(m="POST",y=l);let v=new Headers(this.headers);return c&&v.set("Prefer",`count=${c}`),new s.default({method:m,url:f,headers:v,schema:this.schemaName,body:y,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=n}),Wt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(W(),H(B)),r=t.__importDefault(Ht());e.PostgrestClient=r.default;var s=t.__importDefault(yt());e.PostgrestQueryBuilder=s.default;var n=t.__importDefault(we());e.PostgrestFilterBuilder=n.default;var o=t.__importDefault(mt());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(dt());e.PostgrestBuilder=a.default;var l=t.__importDefault(pt());e.PostgrestError=l.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:n.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var Gt=Object.defineProperty,Kt=Object.defineProperties,Vt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,zt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable,Ae=(e,t,r)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$=(e,t)=>{for(var r in t||(t={}))zt.call(t,r)&&Ae(e,r,t[r]);if(Se)for(var r of Se(t))Yt.call(t,r)&&Ae(e,r,t[r]);return e},N=(e,t)=>Kt(e,Vt(t)),Jt=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},Xt=async(e,t)=>{var r,s,n,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((s=c.hooks)==null?void 0:s.onRequest),i.onResponse.push((n=c.hooks)==null?void 0:n.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},je=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},Qt=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function Zt(e){if(typeof e=="number")return new je({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new je(e);case"exponential":return new Qt(e);default:throw new Error("Invalid retry strategy")}}var er=async e=>{let t={},r=async s=>typeof s=="function"?await s():s;if(e?.auth){if(e.auth.type==="Bearer"){let s=await r(e.auth.token);if(!s)return t;t.authorization=`Bearer ${s}`}else if(e.auth.type==="Basic"){let s=r(e.auth.username),n=r(e.auth.password);if(!s||!n)return t;t.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(e.auth.type==="Custom"){let s=r(e.auth.value);if(!s)return t;t.authorization=`${r(e.auth.prefix)} ${s}`}}return t},tr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function rr(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let s=t.split(";").shift()||"";return tr.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function sr(e){try{return JSON.parse(e),!0}catch{return!1}}function vt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function $e(e){try{return JSON.parse(e)}catch{return e}}function Ie(e){return typeof e=="function"}function nr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&Ie(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&Ie(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function or(e){let t=new Headers(e?.headers),r=await er(e);for(let[s,n]of Object.entries(r||{}))t.set(s,n);if(!t.has("content-type")){let s=ar(e?.body);s&&t.set("content-type",s)}return t}function ar(e){return vt(e)?"application/json":null}function ir(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(vt(e.body)&&!t.has("content-type")){for(let[r,s]of Object.entries(e?.body))s instanceof Date&&(e.body[r]=s.toISOString());return JSON.stringify(e.body)}return e.body}function lr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let s=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return wt.includes(s)?s.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function ur(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var cr=class bt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,bt.prototype)}};async function se(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new cr(r.issues);return r.value}var wt=["get","post","put","patch","delete"],hr=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var s,n,o,a;let l=((n=(s=e.plugins)==null?void 0:s.find(u=>{var i;return(i=u.schema)!=null&&i.config?t.startsWith(u.schema.config.baseURL||"")||t.startsWith(u.schema.config.prefix||""):!1}))==null?void 0:n.schema)||e.schema;if(l){let u=t;(o=l.config)!=null&&o.prefix&&u.startsWith(l.config.prefix)&&(u=u.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&u.startsWith(l.config.baseURL)&&(u=u.replace(l.config.baseURL,""));let i=l.schema[u];if(i){let c=N($({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=N($({},c),{body:i.input?await se(i.input,r?.body):r?.body,params:i.params?await se(i.params,r?.params):r?.params,query:i.query?await se(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),fr=e=>{async function t(r,s){let n=N($($({},e),s),{plugins:[...e?.plugins||[],hr(e||{})]});if(e?.catchAllError)try{return await me(r,n)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await me(r,n)}return t};function pr(e,t){let{baseURL:r,params:s,query:n}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];wt.includes(c)&&(e=e.replace(`@${c}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(n||{}))h!=null&&u.set(c,String(h));if(s)if(Array.isArray(s)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,m]of c.entries()){let f=s[h];a=a.replace(m,f)}}else for(let[c,h]of Object.entries(s))a=a.replace(`:${c}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=u.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var me=async(e,t)=>{var r,s,n,o,a,l,u,i;let{hooks:c,url:h,options:m}=await Xt(e,t),f=nr(m),y=new AbortController,v=(r=m.signal)!=null?r:y.signal,g=pr(h,m),b=ir(m),T=await or(m),P=lr(h,m),d=N($({},m),{url:g,headers:T,body:b,method:P,signal:v});for(let R of c.onRequest)if(R){let E=await R(d);E instanceof Object&&(d=E)}("pipeTo"in d&&typeof d.pipeTo=="function"||typeof((s=t?.body)==null?void 0:s.pipe)=="function")&&("duplex"in d||(d.duplex="half"));let{clearTimeout:C}=ur(m,y),_=await f(d.url,d);C();let Pe={response:_,request:d};for(let R of c.onResponse)if(R){let E=await R(N($({},Pe),{response:(n=t?.hookOptions)!=null&&n.cloneResponse?_.clone():_}));E instanceof Response?_=E:E instanceof Object&&(_=E.response)}if(_.ok){if(d.method==="HEAD")return{data:"",error:null};let R=rr(_),E={data:"",response:_,request:d};if(R==="json"||R==="text"){let k=await _.text(),M=await((o=d.jsonParser)!=null?o:$e)(k);E.data=M}else E.data=await _[R]();d?.output&&d.output&&!d.disableValidation&&(E.data=await se(d.output,E.data));for(let k of c.onSuccess)k&&await k(N($({},E),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?E.data:{data:E.data,error:null}}let Ut=(l=t?.jsonParser)!=null?l:$e,Q=await _.text(),Re=sr(Q),he=Re?await Ut(Q):null,Lt={response:_,responseText:Q,request:d,error:N($({},he),{status:_.status,statusText:_.statusText})};for(let R of c.onError)R&&await R(N($({},Lt),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let R=Zt(t.retry),E=(i=t.retryAttempt)!=null?i:0;if(await R.shouldAttemptRetry(E,_)){for(let M of c.onRetry)M&&await M(Pe);let k=R.getDelay(E);return await new Promise(M=>setTimeout(M,k)),await me(e,N($({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new Jt(_.status,_.statusText,Re?he:Q);return{data:null,error:N($({},he),{status:_.status,statusText:_.statusText})}};p();p();var ne=Object.create(null),G=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?ne:globalThis),A=new Proxy(ne,{get(e,t){return G()[t]??ne[t]},has(e,t){let r=G();return t in r||t in ne},set(e,t,r){let s=G(!0);return s[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=G(!0);return delete r[t],!0},ownKeys(){let e=G(!0);return Object.keys(e)}}),fs=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function w(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var ps=Object.freeze({get BETTER_AUTH_SECRET(){return w("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return w("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return w("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return w("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return w("NODE_ENV","development")},get PACKAGE_VERSION(){return w("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return w("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),K=1,O=4,x=8,S=24,Ne={eterm:O,cons25:O,console:O,cygwin:O,dtterm:O,gnome:O,hurd:O,jfbterm:O,konsole:O,kterm:O,mlterm:O,mosh:S,putty:O,st:O,"rxvt-unicode-24bit":S,terminator:S,"xterm-kitty":S},dr=new Map(Object.entries({APPVEYOR:x,BUILDKITE:x,CIRCLECI:S,DRONE:x,GITEA_ACTIONS:S,GITHUB_ACTIONS:S,GITLAB_CI:x,TRAVIS:x})),mr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function yr(){if(w("FORCE_COLOR")!==void 0)switch(w("FORCE_COLOR")){case"":case"1":case"true":return O;case"2":return x;case"3":return S;default:return K}if(w("NODE_DISABLE_COLORS")!==void 0&&w("NODE_DISABLE_COLORS")!==""||w("NO_COLOR")!==void 0&&w("NO_COLOR")!==""||w("TERM")==="dumb")return K;if(w("TMUX"))return S;if("TF_BUILD"in A&&"AGENT_NAME"in A)return O;if("CI"in A){for(let{0:e,1:t}of dr)if(e in A)return t;return w("CI_NAME")==="codeship"?x:K}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(w("TEAMCITY_VERSION"))!==null?O:K;switch(w("TERM_PROGRAM")){case"iTerm.app":return!w("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(w("TERM_PROGRAM_VERSION"))!==null?x:S;case"HyperTerm":case"MacTerm":return S;case"Apple_Terminal":return x}if(w("COLORTERM")==="truecolor"||w("COLORTERM")==="24bit")return S;if(w("TERM")){if(/truecolor/.exec(w("TERM"))!==null)return S;if(/^xterm-256/.exec(w("TERM"))!==null)return x;let e=w("TERM").toLowerCase();if(Ne[e])return Ne[e];if(mr.some(t=>t.exec(e)!==null))return O}return w("COLORTERM")?O:K}var U={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},ye=["info","success","warn","error","debug"];function gr(e,t){return ye.indexOf(t)<=ye.indexOf(e)}var vr={info:U.fg.blue,success:U.fg.green,warn:U.fg.yellow,error:U.fg.red,debug:U.fg.magenta},br=(e,t,r)=>{let s=new Date().toISOString();return r?`${U.dim}${s}${U.reset} ${vr[e]}${e.toUpperCase()}${U.reset} ${U.bright}[Better Auth]:${U.reset} ${t}`:`${s} ${e.toUpperCase()} [Better Auth]: ${t}`},wr=e=>{let t=e?.disabled!==!0,r=e?.level??"error",s=e?.disableColors!==void 0?!e.disableColors:yr()!==1,n=(o,a,l=[])=>{if(!t||!gr(r,o))return;let u=br(o,a,s);if(!e||typeof e.log!="function"){o==="error"?console.error(u,...l):o==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(ye.map(o=>[o,(...[a,...l])=>n(o,a,l)])),get level(){return r}}},ds=wr();p();p();var _e=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function _r(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new _e(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function V(e,t="/api/auth"){if(_r(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function Er(e,t,r,s){if(e)return V(e,t);if(s!==!1){let a=A.BETTER_AUTH_URL||A.NEXT_PUBLIC_BETTER_AUTH_URL||A.PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_AUTH_URL||(A.BASE_URL!=="/"?A.BASE_URL:void 0);if(a)return V(a,t)}let n=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(n&&o)return V(`${o}://${n}`,t);if(r){let a=Or(r.url);if(!a)throw new _e("Could not get origin from request. Please provide a valid base URL.");return V(a,t)}if(typeof window<"u"&&window.location)return V(window.location.origin,t)}function Or(e){try{return new URL(e).origin}catch{return null}}p();p();p();var ge=Symbol("clean"),j=[],L=0,Z=4,Tr=0,_t=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(s){return r.lc=t.push(s),()=>{for(let o=L+Z;o<j.length;)j[o]===s?j.splice(o,Z):o+=Z;let n=t.indexOf(s);~n&&(t.splice(n,1),--r.lc||r.off())}},notify(s,n){Tr++;let o=!j.length;for(let a of t)j.push(a,r.value,s,n);if(o){for(L=0;L<j.length;L+=Z)j[L](j[L+1],j[L+2],j[L+3]);j.length=0}},off(){},set(s){let n=r.value;n!==s&&(r.value=s,r.notify(n))},subscribe(s){let n=r.listen(s);return s(r.value),n},value:e};return process.env.NODE_ENV!=="production"&&(r[ge]=()=>{t=[],r.lc=0,r.off()}),r};p();var Pr=5,F=6,ee=10,Rr=(e,t,r,s)=>(e.events=e.events||{},e.events[r+ee]||(e.events[r+ee]=s(n=>{e.events[r].reduceRight((o,a)=>(a(o),o),{shared:{},...n})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let n=e.events[r],o=n.indexOf(t);n.splice(o,1),n.length||(delete e.events[r],e.events[r+ee](),delete e.events[r+ee])}),Sr=1e3,Ar=(e,t)=>Rr(e,r=>{let s=t(r);s&&e.events[F].push(s)},Pr,r=>{let s=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),s(...o));let n=e.off;if(e.events[F]=[],e.off=()=>{n(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[F])o();e.events[F]=[]}},Sr)},process.env.NODE_ENV!=="production"){let o=e[ge];e[ge]=()=>{for(let a of e.events[F])a();e.events[F]=[],e.active=!1,o()}}return()=>{e.listen=s,e.off=n}});p();var jr=typeof window>"u",$r=(e,t,r,s)=>{let n=_t({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let u=typeof s=="function"?s({data:n.get().data,error:n.get().error,isPending:n.get().isPending}):s;r(t,{...u,query:{...u?.query,...l?.query},async onSuccess(i){n.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onSuccess?.(i)},async onError(i){let{request:c}=i,h=typeof c.retry=="number"?c.retry:c.retry?.attempts,m=c.retryAttempt||0;h&&m<h||(n.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onError?.(i))},async onRequest(i){let c=n.get();n.set({isPending:c.data===null,data:c.data,error:null,isRefetching:!0,refetch:n.value.refetch}),await u?.onRequest?.(i)}}).catch(i=>{n.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{jr||(a?o():Ar(n,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{n.off(),l.off(),clearTimeout(u)}}))});return n};p();var Ir={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Nr=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,xe={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},xr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Ur(e){return e instanceof Date&&!isNaN(e.getTime())}function Lr(e){let t=xr.exec(e);if(!t)return null;let[,r,s,n,o,a,l,u,i,c,h]=t,m=new Date(Date.UTC(parseInt(r,10),parseInt(s,10)-1,parseInt(n,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),u?parseInt(u.padEnd(3,"0"),10):0));if(i){let f=(parseInt(c,10)*60+parseInt(h,10))*(i==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+f)}return Ur(m)?m:null}function Cr(e,t={}){let{strict:r=!1,warnings:s=!1,reviver:n,parseDates:o=!0}=t;if(typeof e!="string")return e;let a=e.trim();if(a.length>0&&a[0]==='"'&&a.endsWith('"')&&!a.slice(1,-1).includes('"'))return a.slice(1,-1);let l=a.toLowerCase();if(l.length<=9&&l in xe)return xe[l];if(!Nr.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(Ir).some(([u,i])=>{let c=i.test(a);return c&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=Lr(i);if(c)return c}return n?n(u,i):i})}catch(u){if(r)throw u;return e}}function Dr(e,t={strict:!0}){return Cr(e,t)}var Br={id:"redirect",name:"Redirect",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function kr(e){let t=_t(!1);return{session:$r(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var Mr=(e,t)=>{let r="credentials"in Request.prototype,s=Er(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",n=e?.plugins?.flatMap(d=>d.fetchPlugins).filter(d=>d!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:u,onResponse:i,...c}=e?.fetchOptions||{},h=fr({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(d){return d?Dr(d,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Br],...n]}),{$sessionSignal:m,session:f}=kr(h),y=e?.plugins||[],v={},g={$sessionSignal:m,session:f},b={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},T=[{signal:"$sessionSignal",matcher(d){return d==="/sign-out"||d==="/update-user"||d.startsWith("/sign-in")||d.startsWith("/sign-up")||d==="/delete-user"||d==="/verify-email"}}];for(let d of y)d.getAtoms&&Object.assign(g,d.getAtoms?.(h)),d.pathMethods&&Object.assign(b,d.pathMethods),d.atomListeners&&T.push(...d.atomListeners);let P={notify:d=>{g[d].set(!g[d].get())},listen:(d,C)=>{g[d].subscribe(C)},atoms:g};for(let d of y)d.getActions&&Object.assign(v,d.getActions?.(h,P,e));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:b,atomListeners:T,$fetch:h,$store:P}};function Fr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function qr(e,t,r){let s=t[e],{fetchOptions:n,query:o,...a}=r||{};return s||(n?.method?n.method:a&&Object.keys(a).length>0?"POST":"GET")}function Hr(e,t,r,s,n){function o(a=[]){return new Proxy(function(){},{get(l,u){if(typeof u!="string"||u==="then"||u==="catch"||u==="finally")return;let i=[...a,u],c=e;for(let h of i)if(c&&typeof c=="object"&&h in c)c=c[h];else{c=void 0;break}return typeof c=="function"||Fr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(T=>T.replace(/[A-Z]/g,P=>`-${P.toLowerCase()}`)).join("/"),h=i[0]||{},m=i[1]||{},{query:f,fetchOptions:y,...v}=h,g={...m,...y},b=qr(c,r,h);return await t(c,{...g,body:b==="GET"?void 0:{...v,...g?.body||{}},query:f||g?.query,method:b,async onSuccess(T){if(await g?.onSuccess?.(T),!n)return;let P=n.filter(d=>d.matcher(c));if(P.length)for(let d of P){let C=s[d.signal];if(!C)return;let _=C.get();setTimeout(()=>{C.set(!_)},10)}}})}})}return o()}p();function Wr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Gr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:s,$fetch:n,atomListeners:o,$store:a}=Mr(e),l={};for(let[i,c]of Object.entries(s))l[`use${Wr(i)}`]=c;let u={...r,...l,$fetch:n,$store:a};return Hr(u,n,t,s,o)}p();p();p();function Kr(e){return{authorize(t,r="AND"){let s=!1;for(let[n,o]of Object.entries(t)){let a=e[n];if(!a)return{success:!1,error:`You are not allowed to access resource: ${n}`};if(Array.isArray(o))s=o.every(l=>a.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?s=l.actions.some(u=>a.includes(u)):s=l.actions.every(u=>a.includes(u))}else throw new _e("Invalid access control request");if(s&&r==="OR")return{success:s};if(!s&&r==="AND")return{success:!1,error:`unauthorized to access resource "${n}"`}}return s?{success:s}:{success:!1,error:"Not authorized"}},statements:e}}function Et(e){return{newRole(t){return Kr(t)},statements:e}}var Vr={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Ee=Et(Vr),ms=Ee.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ys=Ee.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),gs=Ee.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var zr=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},vs=new zr;p();p();p();p();p();p();p();p();var Yr={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Ot=Et(Yr),bs=Ot.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),ws=Ot.newRole({user:[],session:[]});p();p();var Jr=()=>({id:"username",$InferServerPlugin:{}}),Xr=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),Qr=()=>({id:"better-auth-client",$InferServerPlugin:{}}),Zr="/auth",fe="nvwa_login_token",pe="nvwa_current_jwt",de="nvwa_user_profile",Tt=class{constructor(e,t,r){this.storage=r;let s=Gr({baseURL:e,basePath:Zr,plugins:[Jr(),Xr(),Qr()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>this.storage.get(pe)??this.storage.get(fe)}}});this.authClient=s}async currentUser(){return await this.storage.get(de)}async getCurrentJwt(){return this.storage.get(pe)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(s)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);this.storage.set(fe,e.data?.token),this.storage.set(de,e.data?.user);let t=await this.authClient.token();this.storage.set(pe,t)}async signOut(){await this.storage.remove(fe),await this.storage.remove(de)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(s)}};p();var Pt=class{constructor(e){this.http=e}async invoke(e,t){return(await this.http.request("/functions/"+e,{method:t.method||"POST",data:t.body,headers:t.headers})).body}};p();var Rt=class{async jsonRequest(e,t){let r={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.request(e,r)}async jsonRequestWithAuth(e,t,r){let s={...t,headers:{"Content-Type":"application/json",...t.headers},data:typeof t.data=="object"?JSON.stringify(t.data):t.data};return this.requestWithAuth(e,s,r)}};p();var es="/storage",ts=es+"/generateUploadUrl",St=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+ts,{method:"POST",data:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=t.body;if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");return{url:(await this.http.request(r,{method:"PUT",data:e,headers:{"Content-Type":e.type||e.fileType||"application/octet-stream"}})).body.url.split("?")[0]}}};p();p();p();var Ue=qt(Wt(),1),{PostgrestClient:rs,PostgrestQueryBuilder:_s,PostgrestFilterBuilder:Es,PostgrestTransformBuilder:Os,PostgrestBuilder:Ts,PostgrestError:Ps}=Ue.default||Ue;p();p();var I=class At{constructor(t){if(this.headerMap=new Map,t){if(t instanceof At)t.forEach((r,s)=>this.set(s,r));else if(Array.isArray(t))for(let[r,s]of t)this.set(r,String(s));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let s=t.toLowerCase(),n=this.headerMap.get(s);this.headerMap.set(s,n?`${n}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,s]of this.headerMap.entries())t(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},jt=class $t{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof $t)this.params=new Map(t.params);else if(Array.isArray(t))for(let[r,s]of t)this.append(r,s);else if(t&&typeof t=="object")for(let[r,s]of Object.entries(t))this.set(r,s)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let r=t.split("&");for(let s of r)if(s){let[n,o]=s.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}append(t,r){let s=this.params.get(t)||[];s.push(r),this.params.set(t,s)}delete(t){this.params.delete(t)}get(t){let r=this.params.get(t);return r?r[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,r){this.params.set(t,[r])}sort(){let t=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(t)}toString(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(n)}`);return t.join("&")}forEach(t){for(let[r,s]of this.params.entries())for(let n of s)t(n,r,this)}keys(){return this.params.keys()}values(){let t=[];for(let r of this.params.values())t.push(...r);return t[Symbol.iterator]()}entries(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push([r,n]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},ss=class ve{constructor(t,r){let s;if(t instanceof ve)s=t.href;else if(r){let o=r instanceof ve?r.href:r;s=this.resolve(o,t)}else s=t;let n=this.parseUrl(s);this.href=s,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new jt(n.search),this.hash=n.hash}resolve(t,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(t).protocol}${r}`;if(r.startsWith("/")){let o=this.parseUrl(t);return`${o.protocol}//${o.host}${r}`}let s=this.parseUrl(t),n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${n}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",n=r[4]||"",o=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let u=n.match(/^([^@]*)@(.+)$/),i="",c="",h=n;if(u){let v=u[1];h=u[2];let g=v.match(/^([^:]*):?(.*)$/);g&&(i=g[1]||"",c=g[2]||"")}let m=h.match(/^([^:]+):?(\d*)$/),f=m?m[1]:h,y=m&&m[2]?m[2]:"";return{protocol:s?`${s}:`:"",username:i,password:c,host:h,hostname:f,port:y,pathname:o,search:a,hash:l}}toString(){let t=this.searchParams.toString(),r=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};p();var ns=class It{constructor(t,r){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof I?r.headers:new I(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new It(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var J=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=os(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function os(e){return e?new I(e):new I}p();var Nt=class{constructor(){this._aborted=!1,this.listeners=new Set,this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},as=class{constructor(){this._signal=new Nt}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function is(e){e.URL=ss,e.URLSearchParams=jt,e.Headers=I,e.Request=ns,e.Response=J,e.AbortController=as,e.AbortSignal=Nt}var ls="/entities",us=(e,t)=>async(r,s)=>{console.log("customFetch",r,s);let n;if(typeof r=="string")n=r;else if(r&&typeof r=="object")if(typeof r.toString=="function"&&!r.url)n=r.toString();else if(r.url)n=r.url,s||(s={}),s.method=r.method,s.headers=r.headers,s.body=r.body;else throw new Error("Unsupported input type for fetch");else throw new Error("Unsupported input type for fetch");let o=(s?.method||"GET").toUpperCase(),a={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((h,m)=>{a[m]=h});else if(Array.isArray(s.headers))for(let[h,m]of s.headers)a[h]=m;else Object.assign(a,s.headers);let l=s?.body,u;try{u=await e.requestWithAuth(n,{method:o,data:l,headers:a},t)}catch(h){return new J(h?.message||"Internal Error",{status:500,statusText:"Internal Error"})}let i=u.body,c=null;return(u.headers["content-type"]||u.headers["Content-Type"]||"").startsWith("application/json")&&typeof i!="string"?c=JSON.stringify(i):typeof i=="string"||i&&(i.constructor===Blob||i.constructor===ArrayBuffer||typeof i.getReader=="function")?c=i:c=JSON.stringify(i),new J(c,{status:u.status,headers:new I(u.headers)})},xt=(e,t,r)=>new rs(e+ls,{fetch:us(t,r)});var cs=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let s=(t?.method||"GET").toUpperCase(),n={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{n[i]=u});else if(Array.isArray(l))for(let[u,i]of l)n[u]=i;else Object.assign(n,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),o=u}else o=l}let a=t?.timeout||3e4;return new Promise((l,u)=>{let i=t?.signal;if(i?.aborted){let f=new Error("The operation was aborted");f.name="AbortError",u(f);return}let c=!1,h=[],m=uni.request({url:r,method:s,data:o,header:n,timeout:a,success:f=>{if(c)return;c=!0;let y=f.statusCode,v="",g=new I,b=f.header||f.headers||{};Object.keys(b).forEach(T=>{let P=b[T];g.set(T,typeof P=="string"?P:String(P))}),l(new J(f.data,{status:y,statusText:v,headers:g}))},fail:f=>{if(c)return;c=!0;let y=f?.errMsg||f?.message||"Network Error",v=new Error(y);/(abort|aborted|canceled|cancelled)/i.test(String(y))&&(v.name="AbortError"),u(v)}});if(i&&typeof i.addEventListener=="function"){let f=()=>{if(c)return;try{m?.abort?.()}catch{}let y=new Error("The operation was aborted");y.name="AbortError",c=!0,u(y)};i.addEventListener("abort",f),h.push(()=>{try{i.removeEventListener?.("abort",f)}catch{}})}})},X=cs;var ue=class extends Rt{async request(t,r){let s=await X(t,{method:r.method,headers:new I(r.headers),body:r.data});return{status:s.status,body:await s.json(),headers:Object.fromEntries(s.headers.entries())}}async requestWithAuth(t,r,s){let n=await this.fetchWithAuth(s,t,{method:r.method,headers:new I(r.headers),body:r.data});return{status:n.status,body:await n.json(),headers:Object.fromEntries(n.headers.entries())}}async fetchWithAuth(t,r,s){let n=await X(r,s);if(n.status===401)throw t(),new Error("\u672A\u767B\u5F55");return n}};var ce=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(t),null):s.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(t,r,s){try{let n=this.getKey(t),o={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(n,o)}catch(n){throw console.error("UniAppStorageService set error:",n),n}}async remove(t){try{let r=this.getKey(t);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(t){throw console.error("UniAppStorageService clear error:",t),t}}};var hs=new ce,Oe=new ue,Te=class{constructor(t,r){this.auth=new Tt(t,X,hs),this.fileStorage=new St(t,Oe),this.entities=xt(t,Oe,r),this.functions=new Pt(Oe)}};export{Te as default,Oe as httpClient,hs as localStorage,is as polyfill};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-uniapp",
3
- "version": "0.4.16",
3
+ "version": "0.4.18",
4
4
  "description": "NVWA跨端通用工具类UniApp端实现",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",