@nvwa-app/sdk-uniapp 0.4.12 → 0.4.13

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})},qt=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Bt(t))!kt.call(e,o)&&o!==r&&de(e,o,{get:()=>t[o],enumerable:!(s=Ct(t,o))||s.enumerable});return e};var Ft=e=>qt(de({},"__esModule",{value:!0}),e);var ms={};Mt(ms,{default:()=>fe,httpClient:()=>he,localStorage:()=>Ut,polyfill:()=>xt});module.exports=Ft(ms);var Ht=Object.create,le=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Wt=Object.getOwnPropertyNames,Vt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty,Jt=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),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 o of Wt(t))!zt.call(e,o)&&o!==r&&le(e,o,{get:()=>t[o],enumerable:!(s=Gt(t,o))||s.enumerable});return e},Yt=(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:()=>J,__asyncDelegator:()=>Qe,__asyncGenerator:()=>Xe,__asyncValues:()=>Ze,__await:()=>F,__awaiter:()=>We,__classPrivateFieldGet:()=>st,__classPrivateFieldIn:()=>ot,__classPrivateFieldSet:()=>nt,__createBinding:()=>K,__decorate:()=>Be,__disposeResources:()=>it,__esDecorate:()=>Me,__exportStar:()=>ze,__extends:()=>Le,__generator:()=>Ve,__importDefault:()=>rt,__importStar:()=>tt,__makeTemplateObject:()=>et,__metadata:()=>Ge,__param:()=>ke,__propKey:()=>Fe,__read:()=>we,__rest:()=>Ce,__rewriteRelativeImportExtension:()=>lt,__runInitializers:()=>qe,__setFunctionName:()=>He,__spread:()=>Je,__spreadArray:()=>Ye,__spreadArrays:()=>Ke,__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 o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(r[s[o]]=e[s[o]]);return r}function Be(e,t,r,s){var o=arguments.length,n=o<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(n=(o<3?a(n):o>3?a(t,r,n):a(t,r))||n);return o>3&&n&&Object.defineProperty(t,r,n),n}function ke(e,t){return function(r,s){t(r,s,e)}}function Me(e,t,r,s,o,n){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,d=!1,f=r.length-1;f>=0;f--){var m={};for(var g in s)m[g]=g==="access"?{}:s[g];for(var g in s.access)m.access[g]=s.access[g];m.addInitializer=function(b){if(d)throw new TypeError("Cannot add initializers after decoration has completed");n.push(a(b||null))};var v=(0,r[f])(l==="accessor"?{get:c.get,set:c.set}:c[u],m);if(l==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(h=a(v.get))&&(c.get=h),(h=a(v.set))&&(c.set=h),(h=a(v.init))&&o.unshift(h)}else(h=a(v))&&(l==="field"?o.unshift(h):c[u]=h)}i&&Object.defineProperty(i,s.name,c),d=!0}function qe(e,t,r){for(var s=arguments.length>2,o=0;o<t.length;o++)r=s?t[o].call(e,r):t[o].call(e);return s?r:void 0}function Fe(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 o(n){return n instanceof r?n:new r(function(a){a(n)})}return new(r||(r=Promise))(function(n,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?n(c.value):o(c.value).then(l,u)}i((s=s.apply(e,t||[])).next())})}function Ve(e,t){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},s,o,n,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,o&&(n=i[0]&2?o.return:i[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,i[1])).done)return n;switch(o=0,n&&(i=[i[0]&2,n.value]),i[0]){case 0:case 1:n=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,o=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!n||i[1]>n[0]&&i[1]<n[3])){r.label=i[1];break}if(i[0]===6&&r.label<n[1]){r.label=n[1],n=i;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(i);break}n[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],o=0}finally{s=n=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)&&K(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),o,n=[],a;try{for(;(t===void 0||t-- >0)&&!(o=s.next()).done;)n.push(o.value)}catch(l){a={error:l}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return n}function Je(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(we(arguments[t]));return e}function Ke(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),o=0,t=0;t<r;t++)for(var n=arguments[t],a=0,l=n.length;a<l;a++,o++)s[o]=n[a];return s}function Ye(e,t,r){if(r||arguments.length===2)for(var s=0,o=t.length,n;s<o;s++)(n||!(s in t))&&(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}function F(e){return this instanceof F?(this.v=e,this):new F(e)}function Xe(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),o,n=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(f){return function(m){return Promise.resolve(m).then(f,h)}}function l(f,m){s[f]&&(o[f]=function(g){return new Promise(function(v,b){n.push([f,g,v,b])>1||u(f,g)})},m&&(o[f]=m(o[f])))}function u(f,m){try{i(s[f](m))}catch(g){d(n[0][3],g)}}function i(f){f.value instanceof F?Promise.resolve(f.value.v).then(c,h):d(n[0][2],f)}function c(f){u("next",f)}function h(f){u("throw",f)}function d(f,m){f(m),n.shift(),n.length&&u(n[0][0],n[0][1])}}function Qe(e){var t,r;return t={},s("next"),s("throw",function(o){throw o}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(o,n){t[o]=e[o]?function(a){return(r=!r)?{value:F(e[o](a)),done:!1}:n?n(a):a}:n}}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(n){r[n]=e[n]&&function(a){return new Promise(function(l,u){a=e[n](a),o(l,u,a.done,a.value)})}}function o(n,a,l,u){Promise.resolve(u).then(function(i){n({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"&&K(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,o){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(e,r):o?o.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,o;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&&(o=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");o&&(s=function(){try{o.call(this)}catch(n){return Promise.reject(n)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}function it(e){function t(n){e.error=e.hasError?new ct(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}var r,s=0;function o(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(o);if(r.dispose){var n=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(n).then(o,function(a){return t(a),o()})}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 o()}function lt(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,o,n,a){return s?t?".jsx":".js":o&&(!n||!a)?r:o+n+"."+a.toLowerCase()+"js"}):e}var re,J,K,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 o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},re(e,t)},J=function(){return J=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},J.apply(this,arguments)},K=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,o)}):(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:J,__rest:Ce,__decorate:Be,__param:ke,__esDecorate:Me,__runInitializers:qe,__propKey:Fe,__setFunctionName:He,__metadata:Ge,__awaiter:We,__generator:Ve,__createBinding:K,__exportStar:ze,__values:ae,__read:we,__spread:Je,__spreadArrays:Ke,__spreadArray:Ye,__await:F,__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(Jt("@supabase/node-fetch")),s=t.__importDefault(ft()),o=class{constructor(n){var a,l;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=(a=n.shouldThrowOnError)!==null&&a!==void 0?a:!1,this.signal=n.signal,this.isMaybeSingle=(l=n.isMaybeSingle)!==null&&l!==void 0?l:!1,n.fetch?this.fetch=n.fetch:typeof fetch>"u"?this.fetch=r.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(n,a){return this.headers=new Headers(this.headers),this.headers.set(n,a),this}then(n,a){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 l=this.fetch,u=l(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var c,h,d,f;let m=null,g=null,v=null,b=i.status,S=i.statusText;if(i.ok){if(this.method!=="HEAD"){let j=await i.text();j===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((c=this.headers.get("Accept"))===null||c===void 0)&&c.includes("application/vnd.pgrst.plan+text")?g=j:g=JSON.parse(j))}let E=(h=this.headers.get("Prefer"))===null||h===void 0?void 0:h.match(/count=(exact|planned|estimated)/),y=(d=i.headers.get("content-range"))===null||d===void 0?void 0:d.split("/");E&&y&&y.length>1&&(v=parseInt(y[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(g)&&(g.length>1?(m={code:"PGRST116",details:`Results contain ${g.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},g=null,v=null,b=406,S="Not Acceptable"):g.length===1?g=g[0]:g=null)}else{let E=await i.text();try{m=JSON.parse(E),Array.isArray(m)&&i.status===404&&(g=[],m=null,b=200,S="OK")}catch{i.status===404&&E===""?(b=204,S="No Content"):m={message:E}}if(m&&this.isMaybeSingle&&!((f=m?.details)===null||f===void 0)&&f.includes("0 rows")&&(m=null,b=200,S="OK"),m&&this.shouldThrowOnError)throw new s.default(m)}return{error:m,data:g,count:v,status:b,statusText:S}});return this.shouldThrowOnError||(u=u.catch(i=>{var c,h,d;return{error:{message:`${(c=i?.name)!==null&&c!==void 0?c:"FetchError"}: ${i?.message}`,details:`${(h=i?.stack)!==null&&h!==void 0?h:""}`,hint:"",code:`${(d=i?.code)!==null&&d!==void 0?d:""}`},data:null,count:null,status:0,statusText:""}})),u.then(n,a)}returns(){return this}overrideTypes(){return this}};e.default=o}),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(o){let n=!1,a=(o??"*").split("").map(l=>/\s/.test(l)&&!n?"":(l==='"'&&(n=!n),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(o,{ascending:n=!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},`:""}${o}.${n?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(o,{foreignTable:n,referencedTable:a=n}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${o}`),this}range(o,n,{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,`${o}`),this.url.searchParams.set(i,`${n-o+1}`),this}abortSignal(o){return this.signal=o,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:o=!1,verbose:n=!1,settings:a=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[o?"analyze":null,n?"verbose":null,a?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),d=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${d}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(o){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${o}`),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("[,()]"),o=class extends r.default{eq(n,a){return this.url.searchParams.append(n,`eq.${a}`),this}neq(n,a){return this.url.searchParams.append(n,`neq.${a}`),this}gt(n,a){return this.url.searchParams.append(n,`gt.${a}`),this}gte(n,a){return this.url.searchParams.append(n,`gte.${a}`),this}lt(n,a){return this.url.searchParams.append(n,`lt.${a}`),this}lte(n,a){return this.url.searchParams.append(n,`lte.${a}`),this}like(n,a){return this.url.searchParams.append(n,`like.${a}`),this}likeAllOf(n,a){return this.url.searchParams.append(n,`like(all).{${a.join(",")}}`),this}likeAnyOf(n,a){return this.url.searchParams.append(n,`like(any).{${a.join(",")}}`),this}ilike(n,a){return this.url.searchParams.append(n,`ilike.${a}`),this}ilikeAllOf(n,a){return this.url.searchParams.append(n,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(n,a){return this.url.searchParams.append(n,`ilike(any).{${a.join(",")}}`),this}is(n,a){return this.url.searchParams.append(n,`is.${a}`),this}in(n,a){let l=Array.from(new Set(a)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(n,`in.(${l})`),this}contains(n,a){return typeof a=="string"?this.url.searchParams.append(n,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(n,`cs.{${a.join(",")}}`):this.url.searchParams.append(n,`cs.${JSON.stringify(a)}`),this}containedBy(n,a){return typeof a=="string"?this.url.searchParams.append(n,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(n,`cd.{${a.join(",")}}`):this.url.searchParams.append(n,`cd.${JSON.stringify(a)}`),this}rangeGt(n,a){return this.url.searchParams.append(n,`sr.${a}`),this}rangeGte(n,a){return this.url.searchParams.append(n,`nxl.${a}`),this}rangeLt(n,a){return this.url.searchParams.append(n,`sl.${a}`),this}rangeLte(n,a){return this.url.searchParams.append(n,`nxr.${a}`),this}rangeAdjacent(n,a){return this.url.searchParams.append(n,`adj.${a}`),this}overlaps(n,a){return typeof a=="string"?this.url.searchParams.append(n,`ov.${a}`):this.url.searchParams.append(n,`ov.{${a.join(",")}}`),this}textSearch(n,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(n,`${i}fts${c}.${a}`),this}match(n){return Object.entries(n).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(n,a,l){return this.url.searchParams.append(n,`not.${a}.${l}`),this}or(n,{foreignTable:a,referencedTable:l=a}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${n})`),this}filter(n,a,l){return this.url.searchParams.append(n,`${a}.${l}`),this}};e.default=o}),yt=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),H(B)),r=t.__importDefault(_e()),s=class{constructor(o,{headers:n={},schema:a,fetch:l}){this.url=o,this.headers=new Headers(n),this.schema=a,this.fetch=l}select(o,n){let{head:a=!1,count:l}=n??{},u=a?"HEAD":"GET",i=!1,c=(o??"*").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(o,{count:n,defaultToNull:a=!0}={}){var l;let u="POST";if(n&&this.headers.append("Prefer",`count=${n}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let i=o.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:o,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(o,{onConflict:n,ignoreDuplicates:a=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),n!==void 0&&this.url.searchParams.set("on_conflict",n),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let h=o.reduce((d,f)=>d.concat(Object.keys(f)),[]);if(h.length>0){let d=[...new Set(h)].map(f=>`"${f}"`);this.url.searchParams.set("columns",d.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(o,{count:n}={}){var a;let l="PATCH";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:o}={}){var n;let a="DELETE";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}};e.default=s}),Xt=C(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),H(B)),r=t.__importDefault(yt()),s=t.__importDefault(_e()),o=class mt{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 mt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let d,f=new URL(`${this.url}/rpc/${a}`),m;u||i?(d=u?"HEAD":"GET",Object.entries(l).filter(([v,b])=>b!==void 0).map(([v,b])=>[v,Array.isArray(b)?`{${b.join(",")}}`:`${b}`]).forEach(([v,b])=>{f.searchParams.append(v,b)})):(d="POST",m=l);let g=new Headers(this.headers);return c&&g.set("Prefer",`count=${c}`),new s.default({method:d,url:f,headers:g,schema:this.schemaName,body:m,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=o}),Qt=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(Xt());e.PostgrestClient=r.default;var s=t.__importDefault(yt());e.PostgrestQueryBuilder=s.default;var o=t.__importDefault(_e());e.PostgrestFilterBuilder=o.default;var n=t.__importDefault(dt());e.PostgrestTransformBuilder=n.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:o.default,PostgrestTransformBuilder:n.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var Zt=Object.defineProperty,er=Object.defineProperties,tr=Object.getOwnPropertyDescriptors,Re=Object.getOwnPropertySymbols,rr=Object.prototype.hasOwnProperty,sr=Object.prototype.propertyIsEnumerable,Pe=(e,t,r)=>t in e?Zt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,I=(e,t)=>{for(var r in t||(t={}))rr.call(t,r)&&Pe(e,r,t[r]);if(Re)for(var r of Re(t))sr.call(t,r)&&Pe(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,o,n,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((o=c.hooks)==null?void 0:o.onResponse),i.onSuccess.push((n=c.hooks)==null?void 0:n.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}},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 Ae({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Ae(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),o=r(e.auth.password);if(!s||!o)return t;t.authorization=`Basic ${btoa(`${s}:${o}`)}`}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 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 je(e){try{return JSON.parse(e)}catch{return e}}function $e(e){return typeof e=="function"}function fr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&$e(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&$e(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,o]of Object.entries(r||{}))t.set(s,o);if(!t.has("content-type")){let s=dr(e?.body);s&&t.set("content-type",s)}return t}function dr(e){return gt(e)?"application/json":null}function yr(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 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 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 vr(r.issues);return r.value}var bt=["get","post","put","patch","delete"],br=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var s,o,n,a;let l=((o=(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:o.schema)||e.schema;if(l){let u=t;(n=l.config)!=null&&n.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(I({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=N(I({},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}}}),wr=e=>{async function t(r,s){let o=N(I(I({},e),s),{plugins:[...e?.plugins||[],br(e||{})]});if(e?.catchAllError)try{return await me(r,o)}catch(n){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:n}}}return await me(r,o)}return t};function _r(e,t){let{baseURL:r,params:s,query:o}=t||{query:{},params:{},baseURL:""},n=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}/`,"/"))}n.endsWith("/")||(n+="/");let[a,l]=e.replace(n,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(o||{}))h!=null&&u.set(c,String(h));if(s)if(Array.isArray(s)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,d]of c.entries()){let f=s[h];a=a.replace(d,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"):"",n.startsWith("http")?new URL(`${a}${i}`,n):`${n}${a}${i}`}var me=async(e,t)=>{var r,s,o,n,a,l,u,i;let{hooks:c,url:h,options:d}=await or(e,t),f=fr(d),m=new AbortController,g=(r=d.signal)!=null?r:m.signal,v=_r(h,d),b=yr(d),S=await pr(d),E=mr(h,d),y=N(I({},d),{url:v,headers:S,body:b,method:E,signal:g});for(let R of c.onRequest)if(R){let O=await R(y);O instanceof Object&&(y=O)}("pipeTo"in y&&typeof y.pipeTo=="function"||typeof((s=t?.body)==null?void 0:s.pipe)=="function")&&("duplex"in y||(y.duplex="half"));let{clearTimeout:j}=gr(d,m),_=await f(y.url,y);j();let Te={response:_,request:y};for(let R of c.onResponse)if(R){let O=await R(N(I({},Te),{response:(o=t?.hookOptions)!=null&&o.cloneResponse?_.clone():_}));O instanceof Response?_=O:O instanceof Object&&(_=O.response)}if(_.ok){if(y.method==="HEAD")return{data:"",error:null};let R=cr(_),O={data:"",response:_,request:y};if(R==="json"||R==="text"){let k=await _.text(),M=await((n=y.jsonParser)!=null?n:je)(k);O.data=M}else O.data=await _[R]();y?.output&&y.output&&!y.disableValidation&&(O.data=await ne(y.output,O.data));for(let k of c.onSuccess)k&&await k(N(I({},O),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?O.data:{data:O.data,error:null}}let Dt=(l=t?.jsonParser)!=null?l:je,Q=await _.text(),Se=hr(Q),pe=Se?await Dt(Q):null,Lt={response:_,responseText:Q,request:y,error:N(I({},pe),{status:_.status,statusText:_.statusText})};for(let R of c.onError)R&&await R(N(I({},Lt),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let R=ir(t.retry),O=(i=t.retryAttempt)!=null?i:0;if(await R.shouldAttemptRetry(O,_)){for(let M of c.onRetry)M&&await M(Te);let k=R.getDelay(O);return await new Promise(M=>setTimeout(M,k)),await me(e,N(I({},t),{retryAttempt:O+1}))}}if(t?.throw)throw new nr(_.status,_.statusText,Se?pe:Q);return{data:null,error:N(I({},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)}}),vs=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 bs=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,T=4,U=8,P=24,Ie={eterm:T,cons25:T,console:T,cygwin:T,dtterm:T,gnome:T,hurd:T,jfbterm:T,konsole:T,kterm:T,mlterm:T,mosh:P,putty:T,st:T,"rxvt-unicode-24bit":P,terminator:P,"xterm-kitty":P},Er=new Map(Object.entries({APPVEYOR:U,BUILDKITE:U,CIRCLECI:P,DRONE:U,GITEA_ACTIONS:P,GITHUB_ACTIONS:P,GITLAB_CI:U,TRAVIS:U})),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 T;case"2":return U;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 T;if("CI"in A){for(let{0:e,1:t}of Er)if(e in A)return t;return w("CI_NAME")==="codeship"?U:V}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(w("TEAMCITY_VERSION"))!==null?T:V;switch(w("TERM_PROGRAM")){case"iTerm.app":return!w("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(w("TERM_PROGRAM_VERSION"))!==null?U:P;case"HyperTerm":case"MacTerm":return P;case"Apple_Terminal":return U}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 U;let e=w("TERM").toLowerCase();if(Ie[e])return Ie[e];if(Or.some(t=>t.exec(e)!==null))return T}return w("COLORTERM")?T:V}var D={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 Sr(e,t){return ge.indexOf(t)<=ge.indexOf(e)}var Rr={info:D.fg.blue,success:D.fg.green,warn:D.fg.yellow,error:D.fg.red,debug:D.fg.magenta},Pr=(e,t,r)=>{let s=new Date().toISOString();return r?`${D.dim}${s}${D.reset} ${Rr[e]}${e.toUpperCase()}${D.reset} ${D.bright}[Better Auth]:${D.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,o=(n,a,l=[])=>{if(!t||!Sr(r,n))return;let u=Pr(n,a,s);if(!e||typeof e.log!="function"){n==="error"?console.error(u,...l):n==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(n==="success"?"info":n,a,...l)};return{...Object.fromEntries(ge.map(n=>[n,(...[a,...l])=>o(n,a,l)])),get level(){return r}}},ws=Ar();p();p();var Ee=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 Ee(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function z(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 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 o=r?.headers.get("x-forwarded-host"),n=r?.headers.get("x-forwarded-proto");if(o&&n)return z(`${n}://${o}`,t);if(r){let a=Ir(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 Ir(e){try{return new URL(e).origin}catch{return null}}p();p();p();var ve=Symbol("clean"),$=[],L=0,Z=4,xr=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 n=L+Z;n<$.length;)$[n]===s?$.splice(n,Z):n+=Z;let o=t.indexOf(s);~o&&(t.splice(o,1),--r.lc||r.off())}},notify(s,o){xr++;let n=!$.length;for(let a of t)$.push(a,r.value,s,o);if(n){for(L=0;L<$.length;L+=Z)$[L]($[L+1],$[L+2],$[L+3]);$.length=0}},off(){},set(s){let o=r.value;o!==s&&(r.value=s,r.notify(o))},subscribe(s){let o=r.listen(s);return s(r.value),o},value:e};return process.env.NODE_ENV!=="production"&&(r[ve]=()=>{t=[],r.lc=0,r.off()}),r};p();var Nr=5,q=6,ee=10,Ur=(e,t,r,s)=>(e.events=e.events||{},e.events[r+ee]||(e.events[r+ee]=s(o=>{e.events[r].reduceRight((n,a)=>(a(n),n),{shared:{},...o})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let o=e.events[r],n=o.indexOf(t);o.splice(n,1),o.length||(delete e.events[r],e.events[r+ee](),delete e.events[r+ee])}),Dr=1e3,Lr=(e,t)=>Ur(e,r=>{let s=t(r);s&&e.events[q].push(s)},Nr,r=>{let s=e.listen;e.listen=(...n)=>(!e.lc&&!e.active&&(e.active=!0,r()),s(...n));let o=e.off;if(e.events[q]=[],e.off=()=>{o(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let n of e.events[q])n();e.events[q]=[]}},Dr)},process.env.NODE_ENV!=="production"){let n=e[ve];e[ve]=()=>{for(let a of e.events[q])a();e.events[q]=[],e.active=!1,n()}}return()=>{e.listen=s,e.off=o}});p();var Cr=typeof window>"u",Br=(e,t,r,s)=>{let o=wt({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>n(l)}),n=l=>{let u=typeof s=="function"?s({data:o.get().data,error:o.get().error,isPending:o.get().isPending}):s;r(t,{...u,query:{...u?.query,...l?.query},async onSuccess(i){o.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:o.value.refetch}),await u?.onSuccess?.(i)},async onError(i){let{request:c}=i,h=typeof c.retry=="number"?c.retry:c.retry?.attempts,d=c.retryAttempt||0;h&&d<h||(o.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:o.value.refetch}),await u?.onError?.(i))},async onRequest(i){let c=o.get();o.set({isPending:c.data===null,data:c.data,error:null,isRefetching:!0,refetch:o.value.refetch}),await u?.onRequest?.(i)}}).catch(i=>{o.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:o.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{Cr||(a?n():Lr(o,()=>{let u=setTimeout(()=>{a||(n(),a=!0)},0);return()=>{o.off(),l.off(),clearTimeout(u)}}))});return o};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},qr=/^(\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 Hr(e){let t=qr.exec(e);if(!t)return null;let[,r,s,o,n,a,l,u,i,c,h]=t,d=new Date(Date.UTC(parseInt(r,10),parseInt(s,10)-1,parseInt(o,10),parseInt(n,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);d.setUTCMinutes(d.getUTCMinutes()+f)}return Fr(d)?d:null}function Gr(e,t={}){let{strict:r=!1,warnings:s=!1,reviver:o,parseDates:n=!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(n&&typeof i=="string"){let c=Hr(i);if(c)return c}return o?o(u,i):i})}catch(u){if(r)throw u;return e}}function Wr(e,t={strict:!0}){return Gr(e,t)}var Vr={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 zr(e){let t=wt(!1);return{session:Br(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var Jr=(e,t)=>{let r="credentials"in Request.prototype,s=$r(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",o=e?.plugins?.flatMap(y=>y.fetchPlugins).filter(y=>y!==void 0)||[],n={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(y){return y?Wr(y,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[n,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Vr],...o]}),{$sessionSignal:d,session:f}=zr(h),m=e?.plugins||[],g={},v={$sessionSignal:d,session:f},b={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},S=[{signal:"$sessionSignal",matcher(y){return y==="/sign-out"||y==="/update-user"||y.startsWith("/sign-in")||y.startsWith("/sign-up")||y==="/delete-user"||y==="/verify-email"}}];for(let y of m)y.getAtoms&&Object.assign(v,y.getAtoms?.(h)),y.pathMethods&&Object.assign(b,y.pathMethods),y.atomListeners&&S.push(...y.atomListeners);let E={notify:y=>{v[y].set(!v[y].get())},listen:(y,j)=>{v[y].subscribe(j)},atoms:v};for(let y of m)y.getActions&&Object.assign(g,y.getActions?.(h,E,e));return{get baseURL(){return s},pluginsActions:g,pluginsAtoms:v,pluginPathMethods:b,atomListeners:S,$fetch:h,$store:E}};function Kr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Yr(e,t,r){let s=t[e],{fetchOptions:o,query:n,...a}=r||{};return s||(o?.method?o.method:a&&Object.keys(a).length>0?"POST":"GET")}function Xr(e,t,r,s,o){function n(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:n(i)},apply:async(l,u,i)=>{let c="/"+a.map(S=>S.replace(/[A-Z]/g,E=>`-${E.toLowerCase()}`)).join("/"),h=i[0]||{},d=i[1]||{},{query:f,fetchOptions:m,...g}=h,v={...d,...m},b=Yr(c,r,h);return await t(c,{...v,body:b==="GET"?void 0:{...g,...v?.body||{}},query:f||v?.query,method:b,async onSuccess(S){if(await v?.onSuccess?.(S),!o)return;let E=o.filter(y=>y.matcher(c));if(E.length)for(let y of E){let j=s[y.signal];if(!j)return;let _=j.get();setTimeout(()=>{j.set(!_)},10)}}})}})}return n()}p();function Qr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Zr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:s,$fetch:o,atomListeners:n,$store:a}=Jr(e),l={};for(let[i,c]of Object.entries(s))l[`use${Qr(i)}`]=c;let u={...r,...l,$fetch:o,$store:a};return Xr(u,o,t,s,n)}p();p();p();function es(e){return{authorize(t,r="AND"){let s=!1;for(let[o,n]of Object.entries(t)){let a=e[o];if(!a)return{success:!1,error:`You are not allowed to access resource: ${o}`};if(Array.isArray(n))s=n.every(l=>a.includes(l));else if(typeof n=="object"){let l=n;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 "${o}"`}}return s?{success:s}:{success:!1,error:"Not authorized"}},statements:e}}function _t(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"]},Oe=_t(ts),_s=Oe.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Es=Oe.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Os=Oe.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}}},Ts=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"]},Et=_t(ss),Ss=Et.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Rs=Et.newRole({user:[],session:[]});p();p();var ns=()=>({id:"username",$InferServerPlugin:{}}),os="/auth",te="nvwa_login_token",ye="nvwa_user_profile",Ot=class{constructor(e,t,r){this.storage=r,this.authClient=Zr({baseURL:e,basePath:os,fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>r.get(te)},onSuccess:s=>{let o=s.response.headers.get("set-auth-token");o&&r.set(te,o)}},plugins:[ns()]})}async currentUser(){return await this.storage.get(ye)}async signUp(e,t){let r=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:t});this.saveSession(r)}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(ye,e.data?.user)}async signOut(){await this.storage.remove(te),await this.storage.remove(ye)}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 as="/storage",is=as+"/generateUploadUrl",Rt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+is,{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=Yt(Qt(),1),{PostgrestClient:ls,PostgrestQueryBuilder:Ps,PostgrestFilterBuilder:As,PostgrestTransformBuilder:js,PostgrestBuilder:$s,PostgrestError:Is}=Ne.default||Ne;p();p();var x=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(),o=this.headerMap.get(s);this.headerMap.set(s,o?`${o}, ${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 jt{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof jt)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[o,n]=s.split("=");o&&this.append(decodeURIComponent(o),n?decodeURIComponent(n):"")}}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 o of s)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(o)}`);return t.join("&")}forEach(t){for(let[r,s]of this.params.entries())for(let o of s)t(o,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 o of s)t.push([r,o]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},us=class be{constructor(t,r){let s;if(t instanceof be)s=t.href;else if(r){let n=r instanceof be?r.href:r;s=this.resolve(n,t)}else s=t;let o=this.parseUrl(s);this.href=s,this.origin=`${o.protocol}//${o.host}`,this.protocol=o.protocol,this.username=o.username,this.password=o.password,this.host=o.host,this.hostname=o.hostname,this.port=o.port,this.pathname=o.pathname,this.search=o.search,this.searchParams=new At(o.search),this.hash=o.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 n=this.parseUrl(t);return`${n.protocol}//${n.host}${r}`}let s=this.parseUrl(t),o=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${o}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",o=r[4]||"",n=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!o&&!n.startsWith("/")&&!n.includes("/")&&!n.includes("."))throw new TypeError("Invalid URL");let u=o.match(/^([^@]*)@(.+)$/),i="",c="",h=o;if(u){let g=u[1];h=u[2];let v=g.match(/^([^:]*):?(.*)$/);v&&(i=v[1]||"",c=v[2]||"")}let d=h.match(/^([^:]+):?(\d*)$/),f=d?d[1]:h,m=d&&d[2]?d[2]:"";return{protocol:s?`${s}:`:"",username:i,password:c,host:h,hostname:f,port:m,pathname:n,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 cs=class $t{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 x?r.headers:new x(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new $t(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=hs(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 hs(e){return e?new x(e):new x}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]"}},fs=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=us,e.URLSearchParams=At,e.Headers=x,e.Request=cs,e.Response=Y,e.AbortController=fs,e.AbortSignal=It}var ps="/entities",ds=(e,t)=>async(r,s)=>{console.log("customFetch",r,s);let o;if(typeof r=="string")o=r;else if(r&&typeof r=="object")if(typeof r.toString=="function"&&!r.url)o=r.toString();else if(r.url)o=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 n=(s?.method||"GET").toUpperCase(),a={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((h,d)=>{a[d]=h});else if(Array.isArray(s.headers))for(let[h,d]of s.headers)a[h]=d;else Object.assign(a,s.headers);let l=s?.body,u;try{u=await e.requestWithAuth(o,{method:n,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 x(u.headers)})},Nt=(e,t,r)=>new ls(e+ps,{fetch:ds(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(),o={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{o[i]=u});else if(Array.isArray(l))for(let[u,i]of l)o[u]=i;else Object.assign(o,l)}let n;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")n=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),n=u}else n=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=[],d=uni.request({url:r,method:s,data:n,header:o,timeout:a,success:f=>{if(c)return;c=!0;let m=f.statusCode,g="",v=new x,b=f.header||f.headers||{};Object.keys(b).forEach(S=>{let E=b[S];v.set(S,typeof E=="string"?E:String(E))}),l(new Y(f.data,{status:m,statusText:g,headers:v}))},fail:f=>{if(c)return;c=!0;let m=f?.errMsg||f?.message||"Network Error",g=new Error(m);/(abort|aborted|canceled|cancelled)/i.test(String(m))&&(g.name="AbortError"),u(g)}});if(i&&typeof i.addEventListener=="function"){let f=()=>{if(c)return;try{d?.abort?.()}catch{}let m=new Error("The operation was aborted");m.name="AbortError",c=!0,u(m)};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 x(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 o=await this.fetchWithAuth(s,t,{method:r.method,headers:new x(r.headers),body:r.data});return{status:o.status,body:await o.json(),headers:Object.fromEntries(o.headers.entries())}}async fetchWithAuth(t,r,s){let o=await X(r,s);if(o.status===401)throw t(),new Error("\u672A\u767B\u5F55");return o}};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 o=this.getKey(t),n={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(o,n)}catch(o){throw console.error("UniAppStorageService set error:",o),o}}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 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 ms={};Mt(ms,{default:()=>fe,httpClient:()=>he,localStorage:()=>Ut,polyfill:()=>xt});module.exports=qt(ms);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),Jt=(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},Kt=(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={};Jt(B,{__addDisposableResource:()=>at,__assign:()=>J,__asyncDelegator:()=>Qe,__asyncGenerator:()=>Xe,__asyncValues:()=>Ze,__await:()=>q,__awaiter:()=>We,__classPrivateFieldGet:()=>st,__classPrivateFieldIn:()=>ot,__classPrivateFieldSet:()=>nt,__createBinding:()=>K,__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:()=>Je,__spreadArray:()=>Ye,__spreadArrays:()=>Ke,__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)&&K(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 Je(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(we(arguments[t]));return e}function Ke(){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"&&K(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,J,K,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)},J=function(){return J=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},J.apply(this,arguments)},K=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:J,__rest:Ce,__decorate:Be,__param:ke,__esDecorate:Me,__runInitializers:Fe,__propKey:qe,__setFunctionName:He,__metadata:Ge,__awaiter:We,__generator:Ve,__createBinding:K,__exportStar:ze,__values:ae,__read:we,__spread:Je,__spreadArrays:Ke,__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,$=(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 je(e){try{return JSON.parse(e)}catch{return e}}function $e(e){return typeof e=="function"}function hr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&$e(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&$e(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($({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=x($({},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($($({},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($({},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($({},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:je)(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($({},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:je,Q=await _.text(),Se=cr(Q),pe=Se?await Dt(Q):null,Lt={response:_,responseText:Q,request:d,error:x($({},pe),{status:_.status,statusText:_.statusText})};for(let R of c.onError)R&&await R(x($({},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($({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new sr(_.status,_.statusText,Se?pe:Q);return{data:null,error:x($({},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)}}),gs=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 vs=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}}},bs=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 jr(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=$r(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 $r(e){try{return new URL(e).origin}catch{return null}}p();p();p();var ve=Symbol("clean"),j=[],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<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){Ir++;let o=!j.length;for(let a of t)j.push(a,r.value,s,n);if(o){for(D=0;D<j.length;D+=Z)j[D](j[D+1],j[D+2],j[D+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[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=jr(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 Jr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Kr(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"||Jr(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=Kr(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),ws=Oe.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),_s=Oe.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Es=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}}},Os=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),Ts=Et.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Ss=Et.newRole({user:[],session:[]});p();p();var ss=()=>({id:"username",$InferServerPlugin:{}}),ns="/auth",te="nvwa_login_token",me="nvwa_user_profile",Ot=class{constructor(e,t,r){this.storage=r,this.authClient=Qr({baseURL:e,basePath:ns,fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>r.get(te)},onSuccess:s=>{let n=s.response.headers.get("set-auth-token");n&&r.set(te,n)}},plugins:[ss()]})}async currentUser(){return await this.storage.get(me)}async signUp(e,t){let r=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:t});this.saveSession(r)}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 os="/storage",as=os+"/generateUploadUrl",Rt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+as,{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=Kt(Xt(),1),{PostgrestClient:is,PostgrestQueryBuilder:Rs,PostgrestFilterBuilder:Ps,PostgrestTransformBuilder:As,PostgrestBuilder:js,PostgrestError:$s}=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 jt{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof jt)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}},ls=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 us=class $t{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 $t(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=cs(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 cs(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]"}},hs=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=ls,e.URLSearchParams=At,e.Headers=I,e.Request=us,e.Response=Y,e.AbortController=hs,e.AbortSignal=It}var fs="/entities",ps=(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 is(e+fs,{fetch:ps(t,r)});var ds=(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=ds;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});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var C=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Lt=Object.create,ce=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,Bt=Object.getOwnPropertyNames,kt=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty,qt=(e=>typeof C<"u"?C:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof C<"u"?C:t)[r]}):e)(function(e){if(typeof C<"u")return C.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),De=(e,t)=>()=>(e&&(t=e(e=0)),t),B=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ft=(e,t)=>{for(var r in t)ce(e,r,{get:t[r],enumerable:!0})},Le=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Bt(t))!Mt.call(e,o)&&o!==r&&ce(e,o,{get:()=>t[o],enumerable:!(s=Ct(t,o))||s.enumerable});return e},Ht=(e,t,r)=>(r=e!=null?Lt(kt(e)):{},Le(t||!e||!e.__esModule?ce(r,"default",{value:e,enumerable:!0}):r,e)),G=e=>Le(ce({},"__esModule",{value:!0}),e),p=De(()=>{"use strict"}),k={};Ft(k,{__addDisposableResource:()=>it,__assign:()=>K,__asyncDelegator:()=>Ze,__asyncGenerator:()=>Qe,__asyncValues:()=>et,__await:()=>H,__awaiter:()=>Ve,__classPrivateFieldGet:()=>nt,__classPrivateFieldIn:()=>at,__classPrivateFieldSet:()=>ot,__createBinding:()=>Y,__decorate:()=>ke,__disposeResources:()=>lt,__esDecorate:()=>qe,__exportStar:()=>Je,__extends:()=>Ce,__generator:()=>ze,__importDefault:()=>st,__importStar:()=>rt,__makeTemplateObject:()=>tt,__metadata:()=>We,__param:()=>Me,__propKey:()=>He,__read:()=>be,__rest:()=>Be,__rewriteRelativeImportExtension:()=>ut,__runInitializers:()=>Fe,__setFunctionName:()=>Ge,__spread:()=>Ke,__spreadArray:()=>Xe,__spreadArrays:()=>Ye,__values:()=>ie,default:()=>ft});function Ce(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");se(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 o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(r[s[o]]=e[s[o]]);return r}function ke(e,t,r,s){var o=arguments.length,n=o<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(n=(o<3?a(n):o>3?a(t,r,n):a(t,r))||n);return o>3&&n&&Object.defineProperty(t,r,n),n}function Me(e,t){return function(r,s){t(r,s,e)}}function qe(e,t,r,s,o,n){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,d=!1,f=r.length-1;f>=0;f--){var m={};for(var g in s)m[g]=g==="access"?{}:s[g];for(var g in s.access)m.access[g]=s.access[g];m.addInitializer=function(b){if(d)throw new TypeError("Cannot add initializers after decoration has completed");n.push(a(b||null))};var v=(0,r[f])(l==="accessor"?{get:c.get,set:c.set}:c[u],m);if(l==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(h=a(v.get))&&(c.get=h),(h=a(v.set))&&(c.set=h),(h=a(v.init))&&o.unshift(h)}else(h=a(v))&&(l==="field"?o.unshift(h):c[u]=h)}i&&Object.defineProperty(i,s.name,c),d=!0}function Fe(e,t,r){for(var s=arguments.length>2,o=0;o<t.length;o++)r=s?t[o].call(e,r):t[o].call(e);return s?r:void 0}function He(e){return typeof e=="symbol"?e:"".concat(e)}function Ge(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 We(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Ve(e,t,r,s){function o(n){return n instanceof r?n:new r(function(a){a(n)})}return new(r||(r=Promise))(function(n,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?n(c.value):o(c.value).then(l,u)}i((s=s.apply(e,t||[])).next())})}function ze(e,t){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},s,o,n,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,o&&(n=i[0]&2?o.return:i[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,i[1])).done)return n;switch(o=0,n&&(i=[i[0]&2,n.value]),i[0]){case 0:case 1:n=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,o=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!n||i[1]>n[0]&&i[1]<n[3])){r.label=i[1];break}if(i[0]===6&&r.label<n[1]){r.label=n[1],n=i;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(i);break}n[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],o=0}finally{s=n=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function Je(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Y(t,e,r)}function ie(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),o,n=[],a;try{for(;(t===void 0||t-- >0)&&!(o=s.next()).done;)n.push(o.value)}catch(l){a={error:l}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return n}function Ke(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(be(arguments[t]));return e}function Ye(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),o=0,t=0;t<r;t++)for(var n=arguments[t],a=0,l=n.length;a<l;a++,o++)s[o]=n[a];return s}function Xe(e,t,r){if(r||arguments.length===2)for(var s=0,o=t.length,n;s<o;s++)(n||!(s in t))&&(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}function H(e){return this instanceof H?(this.v=e,this):new H(e)}function Qe(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),o,n=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(f){return function(m){return Promise.resolve(m).then(f,h)}}function l(f,m){s[f]&&(o[f]=function(g){return new Promise(function(v,b){n.push([f,g,v,b])>1||u(f,g)})},m&&(o[f]=m(o[f])))}function u(f,m){try{i(s[f](m))}catch(g){d(n[0][3],g)}}function i(f){f.value instanceof H?Promise.resolve(f.value.v).then(c,h):d(n[0][2],f)}function c(f){u("next",f)}function h(f){u("throw",f)}function d(f,m){f(m),n.shift(),n.length&&u(n[0][0],n[0][1])}}function Ze(e){var t,r;return t={},s("next"),s("throw",function(o){throw o}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(o,n){t[o]=e[o]?function(a){return(r=!r)?{value:H(e[o](a)),done:!1}:n?n(a):a}:n}}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 ie=="function"?ie(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(n){r[n]=e[n]&&function(a){return new Promise(function(l,u){a=e[n](a),o(l,u,a.done,a.value)})}}function o(n,a,l,u){Promise.resolve(u).then(function(i){n({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=ne(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,o){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(e,r):o?o.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,o;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&&(o=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");o&&(s=function(){try{o.call(this)}catch(n){return Promise.reject(n)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}function lt(e){function t(n){e.error=e.hasError?new ht(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}var r,s=0;function o(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(o);if(r.dispose){var n=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(n).then(o,function(a){return t(a),o()})}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 o()}function ut(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,o,n,a){return s?t?".jsx":".js":o&&(!n||!a)?r:o+n+"."+a.toLowerCase()+"js"}):e}var se,K,Y,ct,ne,ht,ft,W=De(()=>{"use strict";p(),se=function(e,t){return se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},se(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 o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},K.apply(this,arguments)},Y=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,o)}):(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},ne=function(e){return ne=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},ne(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:Ce,__assign:K,__rest:Be,__decorate:ke,__param:Me,__esDecorate:qe,__runInitializers:Fe,__propKey:He,__setFunctionName:Ge,__metadata:We,__awaiter:Ve,__generator:ze,__createBinding:Y,__exportStar:Je,__values:ie,__read:be,__spread:Ke,__spreadArrays:Ye,__spreadArray:Xe,__await:H,__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=B(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=B(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),G(k)),r=t.__importDefault(qt("@supabase/node-fetch")),s=t.__importDefault(pt()),o=class{constructor(n){var a,l;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=(a=n.shouldThrowOnError)!==null&&a!==void 0?a:!1,this.signal=n.signal,this.isMaybeSingle=(l=n.isMaybeSingle)!==null&&l!==void 0?l:!1,n.fetch?this.fetch=n.fetch:typeof fetch>"u"?this.fetch=r.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(n,a){return this.headers=new Headers(this.headers),this.headers.set(n,a),this}then(n,a){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 l=this.fetch,u=l(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var c,h,d,f;let m=null,g=null,v=null,b=i.status,S=i.statusText;if(i.ok){if(this.method!=="HEAD"){let j=await i.text();j===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((c=this.headers.get("Accept"))===null||c===void 0)&&c.includes("application/vnd.pgrst.plan+text")?g=j:g=JSON.parse(j))}let E=(h=this.headers.get("Prefer"))===null||h===void 0?void 0:h.match(/count=(exact|planned|estimated)/),y=(d=i.headers.get("content-range"))===null||d===void 0?void 0:d.split("/");E&&y&&y.length>1&&(v=parseInt(y[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(g)&&(g.length>1?(m={code:"PGRST116",details:`Results contain ${g.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},g=null,v=null,b=406,S="Not Acceptable"):g.length===1?g=g[0]:g=null)}else{let E=await i.text();try{m=JSON.parse(E),Array.isArray(m)&&i.status===404&&(g=[],m=null,b=200,S="OK")}catch{i.status===404&&E===""?(b=204,S="No Content"):m={message:E}}if(m&&this.isMaybeSingle&&!((f=m?.details)===null||f===void 0)&&f.includes("0 rows")&&(m=null,b=200,S="OK"),m&&this.shouldThrowOnError)throw new s.default(m)}return{error:m,data:g,count:v,status:b,statusText:S}});return this.shouldThrowOnError||(u=u.catch(i=>{var c,h,d;return{error:{message:`${(c=i?.name)!==null&&c!==void 0?c:"FetchError"}: ${i?.message}`,details:`${(h=i?.stack)!==null&&h!==void 0?h:""}`,hint:"",code:`${(d=i?.code)!==null&&d!==void 0?d:""}`},data:null,count:null,status:0,statusText:""}})),u.then(n,a)}returns(){return this}overrideTypes(){return this}};e.default=o}),yt=B(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),G(k)),r=t.__importDefault(dt()),s=class extends r.default{select(o){let n=!1,a=(o??"*").split("").map(l=>/\s/.test(l)&&!n?"":(l==='"'&&(n=!n),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(o,{ascending:n=!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},`:""}${o}.${n?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(o,{foreignTable:n,referencedTable:a=n}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${o}`),this}range(o,n,{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,`${o}`),this.url.searchParams.set(i,`${n-o+1}`),this}abortSignal(o){return this.signal=o,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:o=!1,verbose:n=!1,settings:a=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[o?"analyze":null,n?"verbose":null,a?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),d=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${d}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(o){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${o}`),this}};e.default=s}),we=B(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),G(k)),r=t.__importDefault(yt()),s=new RegExp("[,()]"),o=class extends r.default{eq(n,a){return this.url.searchParams.append(n,`eq.${a}`),this}neq(n,a){return this.url.searchParams.append(n,`neq.${a}`),this}gt(n,a){return this.url.searchParams.append(n,`gt.${a}`),this}gte(n,a){return this.url.searchParams.append(n,`gte.${a}`),this}lt(n,a){return this.url.searchParams.append(n,`lt.${a}`),this}lte(n,a){return this.url.searchParams.append(n,`lte.${a}`),this}like(n,a){return this.url.searchParams.append(n,`like.${a}`),this}likeAllOf(n,a){return this.url.searchParams.append(n,`like(all).{${a.join(",")}}`),this}likeAnyOf(n,a){return this.url.searchParams.append(n,`like(any).{${a.join(",")}}`),this}ilike(n,a){return this.url.searchParams.append(n,`ilike.${a}`),this}ilikeAllOf(n,a){return this.url.searchParams.append(n,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(n,a){return this.url.searchParams.append(n,`ilike(any).{${a.join(",")}}`),this}is(n,a){return this.url.searchParams.append(n,`is.${a}`),this}in(n,a){let l=Array.from(new Set(a)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(n,`in.(${l})`),this}contains(n,a){return typeof a=="string"?this.url.searchParams.append(n,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(n,`cs.{${a.join(",")}}`):this.url.searchParams.append(n,`cs.${JSON.stringify(a)}`),this}containedBy(n,a){return typeof a=="string"?this.url.searchParams.append(n,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(n,`cd.{${a.join(",")}}`):this.url.searchParams.append(n,`cd.${JSON.stringify(a)}`),this}rangeGt(n,a){return this.url.searchParams.append(n,`sr.${a}`),this}rangeGte(n,a){return this.url.searchParams.append(n,`nxl.${a}`),this}rangeLt(n,a){return this.url.searchParams.append(n,`sl.${a}`),this}rangeLte(n,a){return this.url.searchParams.append(n,`nxr.${a}`),this}rangeAdjacent(n,a){return this.url.searchParams.append(n,`adj.${a}`),this}overlaps(n,a){return typeof a=="string"?this.url.searchParams.append(n,`ov.${a}`):this.url.searchParams.append(n,`ov.{${a.join(",")}}`),this}textSearch(n,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(n,`${i}fts${c}.${a}`),this}match(n){return Object.entries(n).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(n,a,l){return this.url.searchParams.append(n,`not.${a}.${l}`),this}or(n,{foreignTable:a,referencedTable:l=a}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${n})`),this}filter(n,a,l){return this.url.searchParams.append(n,`${a}.${l}`),this}};e.default=o}),mt=B(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),G(k)),r=t.__importDefault(we()),s=class{constructor(o,{headers:n={},schema:a,fetch:l}){this.url=o,this.headers=new Headers(n),this.schema=a,this.fetch=l}select(o,n){let{head:a=!1,count:l}=n??{},u=a?"HEAD":"GET",i=!1,c=(o??"*").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(o,{count:n,defaultToNull:a=!0}={}){var l;let u="POST";if(n&&this.headers.append("Prefer",`count=${n}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let i=o.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:o,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(o,{onConflict:n,ignoreDuplicates:a=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),n!==void 0&&this.url.searchParams.set("on_conflict",n),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let h=o.reduce((d,f)=>d.concat(Object.keys(f)),[]);if(h.length>0){let d=[...new Set(h)].map(f=>`"${f}"`);this.url.searchParams.set("columns",d.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(o,{count:n}={}){var a;let l="PATCH";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:o}={}){var n;let a="DELETE";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}};e.default=s}),Gt=B(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(W(),G(k)),r=t.__importDefault(mt()),s=t.__importDefault(we()),o=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 d,f=new URL(`${this.url}/rpc/${a}`),m;u||i?(d=u?"HEAD":"GET",Object.entries(l).filter(([v,b])=>b!==void 0).map(([v,b])=>[v,Array.isArray(b)?`{${b.join(",")}}`:`${b}`]).forEach(([v,b])=>{f.searchParams.append(v,b)})):(d="POST",m=l);let g=new Headers(this.headers);return c&&g.set("Prefer",`count=${c}`),new s.default({method:d,url:f,headers:g,schema:this.schemaName,body:m,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=o}),Wt=B(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(),G(k)),r=t.__importDefault(Gt());e.PostgrestClient=r.default;var s=t.__importDefault(mt());e.PostgrestQueryBuilder=s.default;var o=t.__importDefault(we());e.PostgrestFilterBuilder=o.default;var n=t.__importDefault(yt());e.PostgrestTransformBuilder=n.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:o.default,PostgrestTransformBuilder:n.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var Vt=Object.defineProperty,zt=Object.defineProperties,Jt=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Kt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable,Ae=(e,t,r)=>t in e?Vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,I=(e,t)=>{for(var r in t||(t={}))Kt.call(t,r)&&Ae(e,r,t[r]);if(Pe)for(var r of Pe(t))Yt.call(t,r)&&Ae(e,r,t[r]);return e},N=(e,t)=>zt(e,Jt(t)),Xt=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},Qt=async(e,t)=>{var r,s,o,n,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((o=c.hooks)==null?void 0:o.onResponse),i.onSuccess.push((n=c.hooks)==null?void 0:n.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}},Zt=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 er(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 Zt(e);default:throw new Error("Invalid retry strategy")}}var tr=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),o=r(e.auth.password);if(!s||!o)return t;t.authorization=`Basic ${btoa(`${s}:${o}`)}`}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},rr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function sr(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 rr.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function nr(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 or(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 ar(e){let t=new Headers(e?.headers),r=await tr(e);for(let[s,o]of Object.entries(r||{}))t.set(s,o);if(!t.has("content-type")){let s=ir(e?.body);s&&t.set("content-type",s)}return t}function ir(e){return vt(e)?"application/json":null}function lr(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 ur(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 cr(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var hr=class bt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,bt.prototype)}};async function oe(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new hr(r.issues);return r.value}var wt=["get","post","put","patch","delete"],fr=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var s,o,n,a;let l=((o=(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:o.schema)||e.schema;if(l){let u=t;(n=l.config)!=null&&n.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(I({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=N(I({},c),{body:i.input?await oe(i.input,r?.body):r?.body,params:i.params?await oe(i.params,r?.params):r?.params,query:i.query?await oe(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),pr=e=>{async function t(r,s){let o=N(I(I({},e),s),{plugins:[...e?.plugins||[],fr(e||{})]});if(e?.catchAllError)try{return await ye(r,o)}catch(n){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:n}}}return await ye(r,o)}return t};function dr(e,t){let{baseURL:r,params:s,query:o}=t||{query:{},params:{},baseURL:""},n=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}/`,"/"))}n.endsWith("/")||(n+="/");let[a,l]=e.replace(n,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(o||{}))h!=null&&u.set(c,String(h));if(s)if(Array.isArray(s)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,d]of c.entries()){let f=s[h];a=a.replace(d,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"):"",n.startsWith("http")?new URL(`${a}${i}`,n):`${n}${a}${i}`}var ye=async(e,t)=>{var r,s,o,n,a,l,u,i;let{hooks:c,url:h,options:d}=await Qt(e,t),f=or(d),m=new AbortController,g=(r=d.signal)!=null?r:m.signal,v=dr(h,d),b=lr(d),S=await ar(d),E=ur(h,d),y=N(I({},d),{url:v,headers:S,body:b,method:E,signal:g});for(let R of c.onRequest)if(R){let O=await R(y);O instanceof Object&&(y=O)}("pipeTo"in y&&typeof y.pipeTo=="function"||typeof((s=t?.body)==null?void 0:s.pipe)=="function")&&("duplex"in y||(y.duplex="half"));let{clearTimeout:j}=cr(d,m),_=await f(y.url,y);j();let Se={response:_,request:y};for(let R of c.onResponse)if(R){let O=await R(N(I({},Se),{response:(o=t?.hookOptions)!=null&&o.cloneResponse?_.clone():_}));O instanceof Response?_=O:O instanceof Object&&(_=O.response)}if(_.ok){if(y.method==="HEAD")return{data:"",error:null};let R=sr(_),O={data:"",response:_,request:y};if(R==="json"||R==="text"){let M=await _.text(),q=await((n=y.jsonParser)!=null?n:$e)(M);O.data=q}else O.data=await _[R]();y?.output&&y.output&&!y.disableValidation&&(O.data=await oe(y.output,O.data));for(let M of c.onSuccess)M&&await M(N(I({},O),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?O.data:{data:O.data,error:null}}let Ut=(l=t?.jsonParser)!=null?l:$e,Z=await _.text(),Re=nr(Z),pe=Re?await Ut(Z):null,Dt={response:_,responseText:Z,request:y,error:N(I({},pe),{status:_.status,statusText:_.statusText})};for(let R of c.onError)R&&await R(N(I({},Dt),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let R=er(t.retry),O=(i=t.retryAttempt)!=null?i:0;if(await R.shouldAttemptRetry(O,_)){for(let q of c.onRetry)q&&await q(Se);let M=R.getDelay(O);return await new Promise(q=>setTimeout(q,M)),await ye(e,N(I({},t),{retryAttempt:O+1}))}}if(t?.throw)throw new Xt(_.status,_.statusText,Re?pe:Z);return{data:null,error:N(I({},pe),{status:_.status,statusText:_.statusText})}};p();p();var ae=Object.create(null),V=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?ae:globalThis),A=new Proxy(ae,{get(e,t){return V()[t]??ae[t]},has(e,t){let r=V();return t in r||t in ae},set(e,t,r){let s=V(!0);return s[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=V(!0);return delete r[t],!0},ownKeys(){let e=V(!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")}}),z=1,T=4,U=8,P=24,xe={eterm:T,cons25:T,console:T,cygwin:T,dtterm:T,gnome:T,hurd:T,jfbterm:T,konsole:T,kterm:T,mlterm:T,mosh:P,putty:T,st:T,"rxvt-unicode-24bit":P,terminator:P,"xterm-kitty":P},yr=new Map(Object.entries({APPVEYOR:U,BUILDKITE:U,CIRCLECI:P,DRONE:U,GITEA_ACTIONS:P,GITHUB_ACTIONS:P,GITLAB_CI:U,TRAVIS:U})),mr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function gr(){if(w("FORCE_COLOR")!==void 0)switch(w("FORCE_COLOR")){case"":case"1":case"true":return T;case"2":return U;case"3":return P;default:return z}if(w("NODE_DISABLE_COLORS")!==void 0&&w("NODE_DISABLE_COLORS")!==""||w("NO_COLOR")!==void 0&&w("NO_COLOR")!==""||w("TERM")==="dumb")return z;if(w("TMUX"))return P;if("TF_BUILD"in A&&"AGENT_NAME"in A)return T;if("CI"in A){for(let{0:e,1:t}of yr)if(e in A)return t;return w("CI_NAME")==="codeship"?U:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(w("TEAMCITY_VERSION"))!==null?T:z;switch(w("TERM_PROGRAM")){case"iTerm.app":return!w("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(w("TERM_PROGRAM_VERSION"))!==null?U:P;case"HyperTerm":case"MacTerm":return P;case"Apple_Terminal":return U}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 U;let e=w("TERM").toLowerCase();if(xe[e])return xe[e];if(mr.some(t=>t.exec(e)!==null))return T}return w("COLORTERM")?T:z}var D={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 vr(e,t){return me.indexOf(t)<=me.indexOf(e)}var br={info:D.fg.blue,success:D.fg.green,warn:D.fg.yellow,error:D.fg.red,debug:D.fg.magenta},wr=(e,t,r)=>{let s=new Date().toISOString();return r?`${D.dim}${s}${D.reset} ${br[e]}${e.toUpperCase()}${D.reset} ${D.bright}[Better Auth]:${D.reset} ${t}`:`${s} ${e.toUpperCase()} [Better Auth]: ${t}`},_r=e=>{let t=e?.disabled!==!0,r=e?.level??"error",s=e?.disableColors!==void 0?!e.disableColors:gr()!==1,o=(n,a,l=[])=>{if(!t||!vr(r,n))return;let u=wr(n,a,s);if(!e||typeof e.log!="function"){n==="error"?console.error(u,...l):n==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(n==="success"?"info":n,a,...l)};return{...Object.fromEntries(me.map(n=>[n,(...[a,...l])=>o(n,a,l)])),get level(){return r}}},ds=_r();p();p();var _e=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Er(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new _e(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function J(e,t="/api/auth"){if(Er(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function Or(e,t,r,s){if(e)return J(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 J(a,t)}let o=r?.headers.get("x-forwarded-host"),n=r?.headers.get("x-forwarded-proto");if(o&&n)return J(`${n}://${o}`,t);if(r){let a=Tr(r.url);if(!a)throw new _e("Could not get origin from request. Please provide a valid base URL.");return J(a,t)}if(typeof window<"u"&&window.location)return J(window.location.origin,t)}function Tr(e){try{return new URL(e).origin}catch{return null}}p();p();p();var ge=Symbol("clean"),$=[],L=0,ee=4,Sr=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 n=L+ee;n<$.length;)$[n]===s?$.splice(n,ee):n+=ee;let o=t.indexOf(s);~o&&(t.splice(o,1),--r.lc||r.off())}},notify(s,o){Sr++;let n=!$.length;for(let a of t)$.push(a,r.value,s,o);if(n){for(L=0;L<$.length;L+=ee)$[L]($[L+1],$[L+2],$[L+3]);$.length=0}},off(){},set(s){let o=r.value;o!==s&&(r.value=s,r.notify(o))},subscribe(s){let o=r.listen(s);return s(r.value),o},value:e};return process.env.NODE_ENV!=="production"&&(r[ge]=()=>{t=[],r.lc=0,r.off()}),r};p();var Rr=5,F=6,te=10,Pr=(e,t,r,s)=>(e.events=e.events||{},e.events[r+te]||(e.events[r+te]=s(o=>{e.events[r].reduceRight((n,a)=>(a(n),n),{shared:{},...o})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let o=e.events[r],n=o.indexOf(t);o.splice(n,1),o.length||(delete e.events[r],e.events[r+te](),delete e.events[r+te])}),Ar=1e3,jr=(e,t)=>Pr(e,r=>{let s=t(r);s&&e.events[F].push(s)},Rr,r=>{let s=e.listen;e.listen=(...n)=>(!e.lc&&!e.active&&(e.active=!0,r()),s(...n));let o=e.off;if(e.events[F]=[],e.off=()=>{o(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let n of e.events[F])n();e.events[F]=[]}},Ar)},process.env.NODE_ENV!=="production"){let n=e[ge];e[ge]=()=>{for(let a of e.events[F])a();e.events[F]=[],e.active=!1,n()}}return()=>{e.listen=s,e.off=o}});p();var $r=typeof window>"u",Ir=(e,t,r,s)=>{let o=_t({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>n(l)}),n=l=>{let u=typeof s=="function"?s({data:o.get().data,error:o.get().error,isPending:o.get().isPending}):s;r(t,{...u,query:{...u?.query,...l?.query},async onSuccess(i){o.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:o.value.refetch}),await u?.onSuccess?.(i)},async onError(i){let{request:c}=i,h=typeof c.retry=="number"?c.retry:c.retry?.attempts,d=c.retryAttempt||0;h&&d<h||(o.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:o.value.refetch}),await u?.onError?.(i))},async onRequest(i){let c=o.get();o.set({isPending:c.data===null,data:c.data,error:null,isRefetching:!0,refetch:o.value.refetch}),await u?.onRequest?.(i)}}).catch(i=>{o.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:o.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{$r||(a?n():jr(o,()=>{let u=setTimeout(()=>{a||(n(),a=!0)},0);return()=>{o.off(),l.off(),clearTimeout(u)}}))});return o};p();var xr={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*$/,Ne={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},Ur=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Dr(e){return e instanceof Date&&!isNaN(e.getTime())}function Lr(e){let t=Ur.exec(e);if(!t)return null;let[,r,s,o,n,a,l,u,i,c,h]=t,d=new Date(Date.UTC(parseInt(r,10),parseInt(s,10)-1,parseInt(o,10),parseInt(n,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);d.setUTCMinutes(d.getUTCMinutes()+f)}return Dr(d)?d:null}function Cr(e,t={}){let{strict:r=!1,warnings:s=!1,reviver:o,parseDates:n=!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 Ne)return Ne[l];if(!Nr.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(xr).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(n&&typeof i=="string"){let c=Lr(i);if(c)return c}return o?o(u,i):i})}catch(u){if(r)throw u;return e}}function Br(e,t={strict:!0}){return Cr(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 Mr(e){let t=_t(!1);return{session:Ir(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var qr=(e,t)=>{let r="credentials"in Request.prototype,s=Or(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",o=e?.plugins?.flatMap(y=>y.fetchPlugins).filter(y=>y!==void 0)||[],n={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=pr({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(y){return y?Br(y,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[n,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[kr],...o]}),{$sessionSignal:d,session:f}=Mr(h),m=e?.plugins||[],g={},v={$sessionSignal:d,session:f},b={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},S=[{signal:"$sessionSignal",matcher(y){return y==="/sign-out"||y==="/update-user"||y.startsWith("/sign-in")||y.startsWith("/sign-up")||y==="/delete-user"||y==="/verify-email"}}];for(let y of m)y.getAtoms&&Object.assign(v,y.getAtoms?.(h)),y.pathMethods&&Object.assign(b,y.pathMethods),y.atomListeners&&S.push(...y.atomListeners);let E={notify:y=>{v[y].set(!v[y].get())},listen:(y,j)=>{v[y].subscribe(j)},atoms:v};for(let y of m)y.getActions&&Object.assign(g,y.getActions?.(h,E,e));return{get baseURL(){return s},pluginsActions:g,pluginsAtoms:v,pluginPathMethods:b,atomListeners:S,$fetch:h,$store:E}};function Fr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Hr(e,t,r){let s=t[e],{fetchOptions:o,query:n,...a}=r||{};return s||(o?.method?o.method:a&&Object.keys(a).length>0?"POST":"GET")}function Gr(e,t,r,s,o){function n(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:n(i)},apply:async(l,u,i)=>{let c="/"+a.map(S=>S.replace(/[A-Z]/g,E=>`-${E.toLowerCase()}`)).join("/"),h=i[0]||{},d=i[1]||{},{query:f,fetchOptions:m,...g}=h,v={...d,...m},b=Hr(c,r,h);return await t(c,{...v,body:b==="GET"?void 0:{...g,...v?.body||{}},query:f||v?.query,method:b,async onSuccess(S){if(await v?.onSuccess?.(S),!o)return;let E=o.filter(y=>y.matcher(c));if(E.length)for(let y of E){let j=s[y.signal];if(!j)return;let _=j.get();setTimeout(()=>{j.set(!_)},10)}}})}})}return n()}p();function Wr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Vr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:s,$fetch:o,atomListeners:n,$store:a}=qr(e),l={};for(let[i,c]of Object.entries(s))l[`use${Wr(i)}`]=c;let u={...r,...l,$fetch:o,$store:a};return Gr(u,o,t,s,n)}p();p();p();function zr(e){return{authorize(t,r="AND"){let s=!1;for(let[o,n]of Object.entries(t)){let a=e[o];if(!a)return{success:!1,error:`You are not allowed to access resource: ${o}`};if(Array.isArray(n))s=n.every(l=>a.includes(l));else if(typeof n=="object"){let l=n;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 "${o}"`}}return s?{success:s}:{success:!1,error:"Not authorized"}},statements:e}}function Et(e){return{newRole(t){return zr(t)},statements:e}}var Jr={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},Ee=Et(Jr),ys=Ee.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ms=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 Kr=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 Kr;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 Xr=()=>({id:"username",$InferServerPlugin:{}}),Qr="/auth",re="nvwa_login_token",de="nvwa_user_profile",Tt=class{constructor(e,t,r){this.storage=r,this.authClient=Vr({baseURL:e,basePath:Qr,fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>r.get(re)},onSuccess:s=>{let o=s.response.headers.get("set-auth-token");o&&r.set(re,o)}},plugins:[Xr()]})}async currentUser(){return await this.storage.get(de)}async signUp(e,t){let r=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:t});this.saveSession(r)}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(re,e.data?.token),this.storage.set(de,e.data?.user)}async signOut(){await this.storage.remove(re),await this.storage.remove(de)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.saveSession(s)}};p();var St=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 Zr="/storage",es=Zr+"/generateUploadUrl",Pt=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 Ue=Ht(Wt(),1),{PostgrestClient:ts,PostgrestQueryBuilder:_s,PostgrestFilterBuilder:Es,PostgrestTransformBuilder:Os,PostgrestBuilder:Ts,PostgrestError:Ss}=Ue.default||Ue;p();p();var x=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(),o=this.headerMap.get(s);this.headerMap.set(s,o?`${o}, ${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[o,n]=s.split("=");o&&this.append(decodeURIComponent(o),n?decodeURIComponent(n):"")}}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 o of s)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(o)}`);return t.join("&")}forEach(t){for(let[r,s]of this.params.entries())for(let o of s)t(o,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 o of s)t.push([r,o]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},rs=class ve{constructor(t,r){let s;if(t instanceof ve)s=t.href;else if(r){let n=r instanceof ve?r.href:r;s=this.resolve(n,t)}else s=t;let o=this.parseUrl(s);this.href=s,this.origin=`${o.protocol}//${o.host}`,this.protocol=o.protocol,this.username=o.username,this.password=o.password,this.host=o.host,this.hostname=o.hostname,this.port=o.port,this.pathname=o.pathname,this.search=o.search,this.searchParams=new jt(o.search),this.hash=o.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 n=this.parseUrl(t);return`${n.protocol}//${n.host}${r}`}let s=this.parseUrl(t),o=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${o}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",o=r[4]||"",n=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!o&&!n.startsWith("/")&&!n.includes("/")&&!n.includes("."))throw new TypeError("Invalid URL");let u=o.match(/^([^@]*)@(.+)$/),i="",c="",h=o;if(u){let g=u[1];h=u[2];let v=g.match(/^([^:]*):?(.*)$/);v&&(i=v[1]||"",c=v[2]||"")}let d=h.match(/^([^:]+):?(\d*)$/),f=d?d[1]:h,m=d&&d[2]?d[2]:"";return{protocol:s?`${s}:`:"",username:i,password:c,host:h,hostname:f,port:m,pathname:n,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 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 x?r.headers:new x(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 X=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 x(e):new x}p();var xt=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 xt}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function as(e){e.URL=rs,e.URLSearchParams=jt,e.Headers=x,e.Request=ss,e.Response=X,e.AbortController=os,e.AbortSignal=xt}var is="/entities",ls=(e,t)=>async(r,s)=>{console.log("customFetch",r,s);let o;if(typeof r=="string")o=r;else if(r&&typeof r=="object")if(typeof r.toString=="function"&&!r.url)o=r.toString();else if(r.url)o=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 n=(s?.method||"GET").toUpperCase(),a={};if(s?.headers)if(s.headers&&typeof s.headers.forEach=="function")s.headers.forEach((h,d)=>{a[d]=h});else if(Array.isArray(s.headers))for(let[h,d]of s.headers)a[h]=d;else Object.assign(a,s.headers);let l=s?.body,u;try{u=await e.requestWithAuth(o,{method:n,data:l,headers:a},t)}catch(h){return new X(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 X(c,{status:u.status,headers:new x(u.headers)})},Nt=(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(),o={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{o[i]=u});else if(Array.isArray(l))for(let[u,i]of l)o[u]=i;else Object.assign(o,l)}let n;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")n=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),n=u}else n=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=[],d=uni.request({url:r,method:s,data:n,header:o,timeout:a,success:f=>{if(c)return;c=!0;let m=f.statusCode,g="",v=new x,b=f.header||f.headers||{};Object.keys(b).forEach(S=>{let E=b[S];v.set(S,typeof E=="string"?E:String(E))}),l(new X(f.data,{status:m,statusText:g,headers:v}))},fail:f=>{if(c)return;c=!0;let m=f?.errMsg||f?.message||"Network Error",g=new Error(m);/(abort|aborted|canceled|cancelled)/i.test(String(m))&&(g.name="AbortError"),u(g)}});if(i&&typeof i.addEventListener=="function"){let f=()=>{if(c)return;try{d?.abort?.()}catch{}let m=new Error("The operation was aborted");m.name="AbortError",c=!0,u(m)};i.addEventListener("abort",f),h.push(()=>{try{i.removeEventListener?.("abort",f)}catch{}})}})},Q=us;var he=class extends Rt{async request(t,r){let s=await Q(t,{method:r.method,headers:new x(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 o=await this.fetchWithAuth(s,t,{method:r.method,headers:new x(r.headers),body:r.data});return{status:o.status,body:await o.json(),headers:Object.fromEntries(o.headers.entries())}}async fetchWithAuth(t,r,s){let o=await Q(r,s);if(o.status===401)throw t(),new Error("\u672A\u767B\u5F55");return o}};var fe=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 o=this.getKey(t),n={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(o,n)}catch(o){throw console.error("UniAppStorageService set error:",o),o}}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 fe,Oe=new he,Te=class{constructor(t,r){this.auth=new Tt(t,Q,cs),this.fileStorage=new Pt(t,Oe),this.entities=Nt(t,Oe,r),this.functions=new St(Oe)}};export{Te as default,Oe as httpClient,cs as localStorage,as as polyfill};
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:()=>J,__asyncDelegator:()=>Qe,__asyncGenerator:()=>Xe,__asyncValues:()=>Ze,__await:()=>q,__awaiter:()=>We,__classPrivateFieldGet:()=>st,__classPrivateFieldIn:()=>ot,__classPrivateFieldSet:()=>nt,__createBinding:()=>K,__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:()=>Je,__spreadArray:()=>Ye,__spreadArrays:()=>Ke,__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)&&K(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 Je(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ve(arguments[t]));return e}function Ke(){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"&&K(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,J,K,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)},J=function(){return J=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},J.apply(this,arguments)},K=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:J,__rest:Ce,__decorate:Be,__param:ke,__esDecorate:Me,__runInitializers:Fe,__propKey:qe,__setFunctionName:He,__metadata:Ge,__awaiter:We,__generator:Ve,__createBinding:K,__exportStar:ze,__values:ae,__read:ve,__spread:Je,__spreadArrays:Ke,__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,Jt=Object.prototype.propertyIsEnumerable,Pe=(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)&&Pe(e,r,t[r]);if(Re)for(var r of Re(t))Jt.call(t,r)&&Pe(e,r,t[r]);return e},x=(e,t)=>Wt(e,Vt(t)),Kt=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 je(e){try{return JSON.parse(e)}catch{return e}}function $e(e){return typeof e=="function"}function sr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&$e(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&$e(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($({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=x($({},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($($({},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($({},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($({},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:je)(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($({},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:je,Q=await _.text(),Se=rr(Q),fe=Se?await Nt(Q):null,Ut={response:_,responseText:Q,request:d,error:x($({},fe),{status:_.status,statusText:_.statusText})};for(let R of c.onError)R&&await R(x($({},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($({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new Kt(_.status,_.statusText,Se?fe:Q);return{data:null,error:x($({},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)}}),us=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 cs=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}}},hs=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"),j=[],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<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){Or++;let o=!j.length;for(let a of t)j.push(a,r.value,s,n);if(o){for(D=0;D<j.length;D+=Z)j[D](j[D+1],j[D+2],j[D+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[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",jr=(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 $r={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($r).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:jr(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),fs=_e.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ps=_e.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ds=_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}}},ms=new zr;p();p();p();p();p();p();p();p();var Jr={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Et=_t(Jr),ys=Et.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),gs=Et.newRole({user:[],session:[]});p();p();var Kr=()=>({id:"username",$InferServerPlugin:{}}),Yr="/auth",te="nvwa_login_token",pe="nvwa_user_profile",Ot=class{constructor(e,t,r){this.storage=r,this.authClient=Gr({baseURL:e,basePath:Yr,fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:()=>r.get(te)},onSuccess:s=>{let n=s.response.headers.get("set-auth-token");n&&r.set(te,n)}},plugins:[Kr()]})}async currentUser(){return await this.storage.get(pe)}async signUp(e,t){let r=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:t});this.saveSession(r)}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 Xr="/storage",Qr=Xr+"/generateUploadUrl",Rt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.request(this.baseUrl+Qr,{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:Zr,PostgrestQueryBuilder:vs,PostgrestFilterBuilder:bs,PostgrestTransformBuilder:ws,PostgrestBuilder:_s,PostgrestError:Es}=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 jt{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof jt)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}},es=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 ts=class $t{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 $t(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=rs(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 rs(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]"}},ss=class{constructor(){this._signal=new It}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function ns(e){e.URL=es,e.URLSearchParams=At,e.Headers=I,e.Request=ts,e.Response=Y,e.AbortController=ss,e.AbortSignal=It}var os="/entities",as=(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 Zr(e+os,{fetch:as(t,r)});var is=(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=is;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 ls=new he,Ee=new ce,Oe=class{constructor(t,r){this.auth=new Ot(t,X,ls),this.fileStorage=new Rt(t,Ee),this.entities=xt(t,Ee,r),this.functions=new Tt(Ee)}};export{Oe as default,Ee as httpClient,ls as localStorage,ns as polyfill};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-uniapp",
3
- "version": "0.4.12",
3
+ "version": "0.4.13",
4
4
  "description": "NVWA跨端通用工具类UniApp端实现",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -29,7 +29,7 @@
29
29
  "directory": "packages/uniapp"
30
30
  },
31
31
  "dependencies": {
32
- "@nvwa-app/sdk-core": "0.4.12"
32
+ "@nvwa-app/sdk-core": "workspace:*"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "^24.3.0",