@nvwa-app/sdk-uniapp 0.7.1 → 0.7.2
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 +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ue=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var Bt=Object.prototype.hasOwnProperty;var Mt=(e,t)=>{for(var r in t)ue(e,r,{get:t[r],enumerable:!0})},Ft=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of kt(t))!Bt.call(e,n)&&n!==r&&ue(e,n,{get:()=>t[n],enumerable:!(s=Dt(t,n))||s.enumerable});return e};var Ht=e=>Ft(ue({},"__esModule",{value:!0}),e);var ys={};Mt(ys,{default:()=>ie,localStorage:()=>Te,polyfill:()=>jt});module.exports=Ht(ys);var qt=Object.create,oe=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Wt=Object.getOwnPropertyNames,zt=Object.getPrototypeOf,Kt=Object.prototype.hasOwnProperty,Ue=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Vt=(e,t)=>{for(var r in t)oe(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Wt(t))!Kt.call(e,n)&&n!==r&&oe(e,n,{get:()=>t[n],enumerable:!(s=Gt(t,n))||s.enumerable});return e},Yt=(e,t,r)=>(r=e!=null?qt(zt(e)):{},Ce(t||!e||!e.__esModule?oe(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>Ce(oe({},"__esModule",{value:!0}),e),p=Ue(()=>{"use strict"}),k={};Vt(k,{__addDisposableResource:()=>at,__assign:()=>V,__asyncDelegator:()=>Qe,__asyncGenerator:()=>Xe,__asyncValues:()=>Ze,__await:()=>H,__awaiter:()=>We,__classPrivateFieldGet:()=>st,__classPrivateFieldIn:()=>ot,__classPrivateFieldSet:()=>nt,__createBinding:()=>Y,__decorate:()=>ke,__disposeResources:()=>it,__esDecorate:()=>Me,__exportStar:()=>Ke,__extends:()=>Le,__generator:()=>ze,__importDefault:()=>rt,__importStar:()=>tt,__makeTemplateObject:()=>et,__metadata:()=>Ge,__param:()=>Be,__propKey:()=>He,__read:()=>ge,__rest:()=>De,__rewriteRelativeImportExtension:()=>lt,__runInitializers:()=>Fe,__setFunctionName:()=>qe,__spread:()=>Ve,__spreadArray:()=>Je,__spreadArrays:()=>Ye,__values:()=>ne,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");Z(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function De(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(r[s[n]]=e[s[n]]);return r}function ke(e,t,r,s){var n=arguments.length,o=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(n<3?a(o):n>3?a(t,r,o):a(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function Be(e,t){return function(r,s){t(r,s,e)}}function Me(e,t,r,s,n,o){function a(w){if(w!==void 0&&typeof w!="function")throw new TypeError("Function expected");return w}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(w){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(w||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 He(e){return typeof e=="symbol"?e:"".concat(e)}function qe(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 ze(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 Ke(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Y(t,e,r)}function ne(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 ge(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 Ve(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ge(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),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 Je(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 H(e){return this instanceof H?(this.v=e,this):new H(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,w){o.push([f,v,g,w])>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 H?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:H(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 ne=="function"?ne(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=ee(e),s=0;s<r.length;s++)r[s]!=="default"&&Y(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 Z,V,Y,ut,ee,ct,ht,G=Ue(()=>{"use strict";p(),Z=function(e,t){return Z=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])},Z(e,t)},V=function(){return V=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},V.apply(this,arguments)},Y=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),ut=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},ee=function(e){return ee=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},ee(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:V,__rest:De,__decorate:ke,__param:Be,__esDecorate:Me,__runInitializers:Fe,__propKey:He,__setFunctionName:qe,__metadata:Ge,__awaiter:We,__generator:ze,__createBinding:Y,__exportStar:Ke,__values:ne,__read:ge,__spread:Ve,__spreadArrays:Ye,__spreadArray:Je,__await:H,__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=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),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,w=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 O=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),P=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");O&&P&&P.length>1&&(v=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(f={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,v=null,g=406,w="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{let O=await u.text();try{f=JSON.parse(O),Array.isArray(f)&&u.status===404&&(y=[],f=null,g=200,w="OK")}catch{u.status===404&&O===""?(g=204,w="No Content"):f={message:O}}if(f&&this.isMaybeSingle&&!((m=f?.details)===null||m===void 0)&&m.includes("0 rows")&&(f=null,g=200,w="OK"),f&&this.shouldThrowOnError)throw new r.default(f)}return{error:f,data:y,count:v,status:g,statusText:w}});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=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),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}),ve=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),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=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(ve()),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}),Jt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(mt()),s=t.__importDefault(ve()),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,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{f.searchParams.append(g,w)})):(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=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),q(k)),r=t.__importDefault(Jt());e.PostgrestClient=r.default;var s=t.__importDefault(mt());e.PostgrestQueryBuilder=s.default;var n=t.__importDefault(ve());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,Se=Object.getOwnPropertySymbols,tr=Object.prototype.hasOwnProperty,rr=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?Qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,j=(e,t)=>{for(var r in t||(t={}))tr.call(t,r)&&Re(e,r,t[r]);if(Se)for(var r of Se(t))rr.call(t,r)&&Re(e,r,t[r]);return e},I=(e,t)=>Zt(e,er(t)),sr=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},nr=async(e,t)=>{var r,s,n,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((s=c.hooks)==null?void 0:s.onRequest),i.onResponse.push((n=c.hooks)==null?void 0:n.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},Ae=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},or=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function ar(e){if(typeof e=="number")return new Ae({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Ae(e);case"exponential":return new or(e);default:throw new Error("Invalid retry strategy")}}var ir=async e=>{let t={},r=async s=>typeof s=="function"?await s():s;if(e?.auth){if(e.auth.type==="Bearer"){let s=await r(e.auth.token);if(!s)return t;t.authorization=`Bearer ${s}`}else if(e.auth.type==="Basic"){let s=r(e.auth.username),n=r(e.auth.password);if(!s||!n)return t;t.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(e.auth.type==="Custom"){let s=r(e.auth.value);if(!s)return t;t.authorization=`${r(e.auth.prefix)} ${s}`}}return t},lr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function ur(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let s=t.split(";").shift()||"";return lr.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function cr(e){try{return JSON.parse(e),!0}catch{return!1}}function gt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function $e(e){try{return JSON.parse(e)}catch{return e}}function je(e){return typeof e=="function"}function hr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&je(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&je(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function fr(e){let t=new Headers(e?.headers),r=await ir(e);for(let[s,n]of Object.entries(r||{}))t.set(s,n);if(!t.has("content-type")){let s=pr(e?.body);s&&t.set("content-type",s)}return t}function pr(e){return gt(e)?"application/json":null}function dr(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(gt(e.body)&&!t.has("content-type")){for(let[r,s]of Object.entries(e?.body))s instanceof Date&&(e.body[r]=s.toISOString());return JSON.stringify(e.body)}return e.body}function mr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let s=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return wt.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 te(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new gr(r.issues);return r.value}var wt=["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=I(j({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=I(j({},c),{body:i.input?await te(i.input,r?.body):r?.body,params:i.params?await te(i.params,r?.params):r?.params,query:i.query?await te(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),wr=e=>{async function t(r,s){let n=I(j(j({},e),s),{plugins:[...e?.plugins||[],vr(e||{})]});if(e?.catchAllError)try{return await fe(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 fe(r,n)}return t};function br(e,t){let{baseURL:r,params:s,query:n}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];wt.includes(c)&&(e=e.replace(`@${c}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(n||{}))h!=null&&u.set(c,String(h));if(s)if(Array.isArray(s)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,m]of c.entries()){let f=s[h];a=a.replace(m,f)}}else for(let[c,h]of Object.entries(s))a=a.replace(`:${c}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=u.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var fe=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=br(h,m),w=dr(m),O=await fr(m),P=mr(h,m),d=I(j({},m),{url:g,headers:O,body:w,method:P,signal:v});for(let S of c.onRequest)if(S){let E=await S(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 Oe={response:_,request:d};for(let S of c.onResponse)if(S){let E=await S(I(j({},Oe),{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 S=ur(_),E={data:"",response:_,request:d};if(S==="json"||S==="text"){let B=await _.text(),M=await((o=d.jsonParser)!=null?o:$e)(B);E.data=M}else E.data=await _[S]();d?.output&&d.output&&!d.disableValidation&&(E.data=await te(d.output,E.data));for(let B of c.onSuccess)B&&await B(I(j({},E),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?E.data:{data:E.data,error:null}}let Ct=(l=t?.jsonParser)!=null?l:$e,J=await _.text(),Pe=cr(J),le=Pe?await Ct(J):null,Lt={response:_,responseText:J,request:d,error:I(j({},le),{status:_.status,statusText:_.statusText})};for(let S of c.onError)S&&await S(I(j({},Lt),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let S=ar(t.retry),E=(i=t.retryAttempt)!=null?i:0;if(await S.shouldAttemptRetry(E,_)){for(let M of c.onRetry)M&&await M(Oe);let B=S.getDelay(E);return await new Promise(M=>setTimeout(M,B)),await fe(e,I(j({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new sr(_.status,_.statusText,Pe?le:J);return{data:null,error:I(j({},le),{status:_.status,statusText:_.statusText})}};p();p();var re=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?re:globalThis),A=new Proxy(re,{get(e,t){return W()[t]??re[t]},has(e,t){let r=W();return t in r||t in re},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 b(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var ws=Object.freeze({get BETTER_AUTH_SECRET(){return b("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return b("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return b("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return b("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return b("NODE_ENV","development")},get PACKAGE_VERSION(){return b("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return b("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),z=1,T=4,N=8,R=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:R,putty:T,st:T,"rxvt-unicode-24bit":R,terminator:R,"xterm-kitty":R},_r=new Map(Object.entries({APPVEYOR:N,BUILDKITE:N,CIRCLECI:R,DRONE:N,GITEA_ACTIONS:R,GITHUB_ACTIONS:R,GITLAB_CI:N,TRAVIS:N})),Er=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Tr(){if(b("FORCE_COLOR")!==void 0)switch(b("FORCE_COLOR")){case"":case"1":case"true":return T;case"2":return N;case"3":return R;default:return z}if(b("NODE_DISABLE_COLORS")!==void 0&&b("NODE_DISABLE_COLORS")!==""||b("NO_COLOR")!==void 0&&b("NO_COLOR")!==""||b("TERM")==="dumb")return z;if(b("TMUX"))return R;if("TF_BUILD"in A&&"AGENT_NAME"in A)return T;if("CI"in A){for(let{0:e,1:t}of _r)if(e in A)return t;return b("CI_NAME")==="codeship"?N:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(b("TEAMCITY_VERSION"))!==null?T:z;switch(b("TERM_PROGRAM")){case"iTerm.app":return!b("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(b("TERM_PROGRAM_VERSION"))!==null?N:R;case"HyperTerm":case"MacTerm":return R;case"Apple_Terminal":return N}if(b("COLORTERM")==="truecolor"||b("COLORTERM")==="24bit")return R;if(b("TERM")){if(/truecolor/.exec(b("TERM"))!==null)return R;if(/^xterm-256/.exec(b("TERM"))!==null)return N;let e=b("TERM").toLowerCase();if(Ie[e])return Ie[e];if(Er.some(t=>t.exec(e)!==null))return T}return b("COLORTERM")?T:z}var x={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"}},pe=["info","success","warn","error","debug"];function Or(e,t){return pe.indexOf(t)<=pe.indexOf(e)}var Pr={info:x.fg.blue,success:x.fg.green,warn:x.fg.yellow,error:x.fg.red,debug:x.fg.magenta},Sr=(e,t,r)=>{let s=new Date().toISOString();return r?`${x.dim}${s}${x.reset} ${Pr[e]}${e.toUpperCase()}${x.reset} ${x.bright}[Better Auth]:${x.reset} ${t}`:`${s} ${e.toUpperCase()} [Better Auth]: ${t}`},Rr=e=>{let t=e?.disabled!==!0,r=e?.level??"error",s=e?.disableColors!==void 0?!e.disableColors:Tr()!==1,n=(o,a,l=[])=>{if(!t||!Or(r,o))return;let u=Sr(o,a,s);if(!e||typeof e.log!="function"){o==="error"?console.error(u,...l):o==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(pe.map(o=>[o,(...[a,...l])=>n(o,a,l)])),get level(){return r}}},bs=Rr();p();p();var we=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 we(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function K(e,t="/api/auth"){if(Ar(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function $r(e,t,r,s){if(e)return K(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 K(a,t)}let n=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(n&&o)return K(`${o}://${n}`,t);if(r){let a=jr(r.url);if(!a)throw new we("Could not get origin from request. Please provide a valid base URL.");return K(a,t)}if(typeof window<"u"&&window.location)return K(window.location.origin,t)}function jr(e){try{return new URL(e).origin}catch{return null}}p();p();p();var de=Symbol("clean"),$=[],C=0,X=4,Ir=0,bt=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=C+X;o<$.length;)$[o]===s?$.splice(o,X):o+=X;let n=t.indexOf(s);~n&&(t.splice(n,1),--r.lc||r.off())}},notify(s,n){Ir++;let o=!$.length;for(let a of t)$.push(a,r.value,s,n);if(o){for(C=0;C<$.length;C+=X)$[C]($[C+1],$[C+2],$[C+3]);$.length=0}},off(){},set(s){let n=r.value;n!==s&&(r.value=s,r.notify(n))},subscribe(s){let n=r.listen(s);return s(r.value),n},value:e};return process.env.NODE_ENV!=="production"&&(r[de]=()=>{t=[],r.lc=0,r.off()}),r};p();var Nr=5,F=6,Q=10,xr=(e,t,r,s)=>(e.events=e.events||{},e.events[r+Q]||(e.events[r+Q]=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+Q](),delete e.events[r+Q])}),Ur=1e3,Cr=(e,t)=>xr(e,r=>{let s=t(r);s&&e.events[F].push(s)},Nr,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[de];e[de]=()=>{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",Dr=(e,t,r,s)=>{let n=bt({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():Cr(n,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{n.off(),l.off(),clearTimeout(u)}}))});return n};p();var kr={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Br=/^\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},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 Hr(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 qr(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 Ne)return Ne[l];if(!Br.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(kr).some(([u,i])=>{let c=i.test(a);return c&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=Hr(i);if(c)return c}return n?n(u,i):i})}catch(u){if(r)throw u;return e}}function Gr(e,t={strict:!0}){return qr(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 zr(e){let t=bt(!1);return{session:Dr(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=wr({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(d){return d?Gr(d,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Wr],...n]}),{$sessionSignal:m,session:f}=zr(h),y=e?.plugins||[],v={},g={$sessionSignal:m,session:f},w={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},O=[{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(w,d.pathMethods),d.atomListeners&&O.push(...d.atomListeners);let P={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,P,e));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:w,atomListeners:O,$fetch:h,$store:P}};function Vr(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:n,query:o,...a}=r||{};return s||(n?.method?n.method:a&&Object.keys(a).length>0?"POST":"GET")}function Jr(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"||Vr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(O=>O.replace(/[A-Z]/g,P=>`-${P.toLowerCase()}`)).join("/"),h=i[0]||{},m=i[1]||{},{query:f,fetchOptions:y,...v}=h,g={...m,...y},w=Yr(c,r,h);return await t(c,{...g,body:w==="GET"?void 0:{...v,...g?.body||{}},query:f||g?.query,method:w,async onSuccess(O){if(await g?.onSuccess?.(O),!n)return;let P=n.filter(d=>d.matcher(c));if(P.length)for(let d of P){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}=Kr(e),l={};for(let[i,c]of Object.entries(s))l[`use${Xr(i)}`]=c;let u={...r,...l,$fetch:n,$store:a};return Jr(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 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 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"]},be=_t(es),_s=be.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Es=be.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Ts=be.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),Ps=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=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),os=()=>({id:"better-auth-client",$InferServerPlugin:{}}),as="/auth",ce="nvwa_login_token",se="nvwa_current_jwt",he="nvwa_user_profile",Tt=class{constructor(e,t,r){this.storage=r;let s=Qr({baseURL:e,basePath:as,plugins:[ss(),ns(),os()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let n=await this.storage.get(se);if(console.log("jwt",n),n)return n;let o=await this.storage.get(ce);return console.log("loginToken",o),o}}}});this.authClient=s}async currentUser(){return await this.storage.get(he)}async getCurrentJwt(){return await this.storage.get(se)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(s)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(ce,e.data?.token),await this.storage.set(he,e.data?.user);let{data:t,error:r}=await this.authClient.token();if(r)throw new Error(r.message);await this.storage.set(se,t.token)}async signOut(){await this.storage.remove(ce),await this.storage.remove(he)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(s)}};p();var Ot=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};p();p();p();var U=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()}},St=class Rt{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof Rt)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}},is=class me{constructor(t,r){let s;if(t instanceof me)s=t.href;else if(r){let o=r instanceof me?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 St(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 ls=class At{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 U?r.headers:new U(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new At(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var _e=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=us(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 us(e){return e?new U(e):new U}p();var $t=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]"}},cs=class{constructor(){this._signal=new $t}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function jt(e){e.URL=is,e.URLSearchParams=St,e.Headers=U,e.Request=ls,e.Response=_e,e.AbortController=cs,e.AbortSignal=$t}var It=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(se),s=new U(t?.headers);r&&s.set("Authorization",`Bearer ${r}`);let n=await this.customFetch(e,{...t,headers:s});if(n.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return n}};p();var hs="/storage",fs=hs+"/generateUploadUrl",Nt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+fs,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:e,headers:new U({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:n}=await s.json();return{url:n.split("?")[0]}}};p();p();p();var xe=Yt(Xt(),1),{PostgrestClient:ps,PostgrestQueryBuilder:Rs,PostgrestFilterBuilder:As,PostgrestTransformBuilder:$s,PostgrestBuilder:js,PostgrestError:Is}=xe.default||xe,ds="/entities",xt=(e,t)=>new ps(e+ds,{fetch:t.fetchWithAuth.bind(t)});p();var Ut=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:t})).json();if(s.status!==200)throw new Error(s.message);return s.data}};var ae=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 ms=(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 U,w=f.header||f.headers||{};Object.keys(w).forEach(O=>{let P=w[O];g.set(O,typeof P=="string"?P:String(P))}),l(new _e(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{}})}})},Ee=ms;var Te=new ae,ie=class{constructor(t,r){this.auth=new Tt(t,Ee,Te),this.httpClient=new It(Te,Ee,r),this.fileStorage=new Nt(t,this.httpClient),this.entities=xt(t,this.httpClient),this.functions=new Ot(this.httpClient),this.skill=new Ut(t,this.httpClient)}};0&&(module.exports={localStorage,polyfill});
|
|
1
|
+
"use strict";var ue=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var Bt=Object.prototype.hasOwnProperty;var Mt=(e,t)=>{for(var r in t)ue(e,r,{get:t[r],enumerable:!0})},Ft=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of kt(t))!Bt.call(e,n)&&n!==r&&ue(e,n,{get:()=>t[n],enumerable:!(s=Dt(t,n))||s.enumerable});return e};var Ht=e=>Ft(ue({},"__esModule",{value:!0}),e);var ys={};Mt(ys,{default:()=>ie,localStorage:()=>Te,polyfill:()=>jt});module.exports=Ht(ys);var qt=Object.create,oe=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Wt=Object.getOwnPropertyNames,zt=Object.getPrototypeOf,Kt=Object.prototype.hasOwnProperty,Ue=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Vt=(e,t)=>{for(var r in t)oe(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Wt(t))!Kt.call(e,n)&&n!==r&&oe(e,n,{get:()=>t[n],enumerable:!(s=Gt(t,n))||s.enumerable});return e},Yt=(e,t,r)=>(r=e!=null?qt(zt(e)):{},Ce(t||!e||!e.__esModule?oe(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>Ce(oe({},"__esModule",{value:!0}),e),p=Ue(()=>{"use strict"}),k={};Vt(k,{__addDisposableResource:()=>at,__assign:()=>V,__asyncDelegator:()=>Qe,__asyncGenerator:()=>Xe,__asyncValues:()=>Ze,__await:()=>H,__awaiter:()=>We,__classPrivateFieldGet:()=>st,__classPrivateFieldIn:()=>ot,__classPrivateFieldSet:()=>nt,__createBinding:()=>Y,__decorate:()=>ke,__disposeResources:()=>it,__esDecorate:()=>Me,__exportStar:()=>Ke,__extends:()=>Le,__generator:()=>ze,__importDefault:()=>rt,__importStar:()=>tt,__makeTemplateObject:()=>et,__metadata:()=>Ge,__param:()=>Be,__propKey:()=>He,__read:()=>ge,__rest:()=>De,__rewriteRelativeImportExtension:()=>lt,__runInitializers:()=>Fe,__setFunctionName:()=>qe,__spread:()=>Ve,__spreadArray:()=>Je,__spreadArrays:()=>Ye,__values:()=>ne,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");Z(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function De(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(r[s[n]]=e[s[n]]);return r}function ke(e,t,r,s){var n=arguments.length,o=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(n<3?a(o):n>3?a(t,r,o):a(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function Be(e,t){return function(r,s){t(r,s,e)}}function Me(e,t,r,s,n,o){function a(w){if(w!==void 0&&typeof w!="function")throw new TypeError("Function expected");return w}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(w){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(w||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 He(e){return typeof e=="symbol"?e:"".concat(e)}function qe(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 ze(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 Ke(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Y(t,e,r)}function ne(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 ge(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 Ve(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ge(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),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 Je(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 H(e){return this instanceof H?(this.v=e,this):new H(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,w){o.push([f,v,g,w])>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 H?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:H(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 ne=="function"?ne(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=ee(e),s=0;s<r.length;s++)r[s]!=="default"&&Y(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 Z,V,Y,ut,ee,ct,ht,G=Ue(()=>{"use strict";p(),Z=function(e,t){return Z=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])},Z(e,t)},V=function(){return V=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},V.apply(this,arguments)},Y=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),ut=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},ee=function(e){return ee=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},ee(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:V,__rest:De,__decorate:ke,__param:Be,__esDecorate:Me,__runInitializers:Fe,__propKey:He,__setFunctionName:qe,__metadata:Ge,__awaiter:We,__generator:ze,__createBinding:Y,__exportStar:Ke,__values:ne,__read:ge,__spread:Ve,__spreadArrays:Ye,__spreadArray:Je,__await:H,__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=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),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,w=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 O=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),P=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");O&&P&&P.length>1&&(v=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(f={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,v=null,g=406,w="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{let O=await u.text();try{f=JSON.parse(O),Array.isArray(f)&&u.status===404&&(y=[],f=null,g=200,w="OK")}catch{u.status===404&&O===""?(g=204,w="No Content"):f={message:O}}if(f&&this.isMaybeSingle&&!((m=f?.details)===null||m===void 0)&&m.includes("0 rows")&&(f=null,g=200,w="OK"),f&&this.shouldThrowOnError)throw new r.default(f)}return{error:f,data:y,count:v,status:g,statusText:w}});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=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),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}),ve=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),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=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(ve()),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}),Jt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(mt()),s=t.__importDefault(ve()),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,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{f.searchParams.append(g,w)})):(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=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),q(k)),r=t.__importDefault(Jt());e.PostgrestClient=r.default;var s=t.__importDefault(mt());e.PostgrestQueryBuilder=s.default;var n=t.__importDefault(ve());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,Se=Object.getOwnPropertySymbols,tr=Object.prototype.hasOwnProperty,rr=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?Qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,j=(e,t)=>{for(var r in t||(t={}))tr.call(t,r)&&Re(e,r,t[r]);if(Se)for(var r of Se(t))rr.call(t,r)&&Re(e,r,t[r]);return e},I=(e,t)=>Zt(e,er(t)),sr=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},nr=async(e,t)=>{var r,s,n,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((s=c.hooks)==null?void 0:s.onRequest),i.onResponse.push((n=c.hooks)==null?void 0:n.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},Ae=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},or=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function ar(e){if(typeof e=="number")return new Ae({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Ae(e);case"exponential":return new or(e);default:throw new Error("Invalid retry strategy")}}var ir=async e=>{let t={},r=async s=>typeof s=="function"?await s():s;if(e?.auth){if(e.auth.type==="Bearer"){let s=await r(e.auth.token);if(!s)return t;t.authorization=`Bearer ${s}`}else if(e.auth.type==="Basic"){let s=r(e.auth.username),n=r(e.auth.password);if(!s||!n)return t;t.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(e.auth.type==="Custom"){let s=r(e.auth.value);if(!s)return t;t.authorization=`${r(e.auth.prefix)} ${s}`}}return t},lr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function ur(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let s=t.split(";").shift()||"";return lr.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function cr(e){try{return JSON.parse(e),!0}catch{return!1}}function gt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function $e(e){try{return JSON.parse(e)}catch{return e}}function je(e){return typeof e=="function"}function hr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&je(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&je(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function fr(e){let t=new Headers(e?.headers),r=await ir(e);for(let[s,n]of Object.entries(r||{}))t.set(s,n);if(!t.has("content-type")){let s=pr(e?.body);s&&t.set("content-type",s)}return t}function pr(e){return gt(e)?"application/json":null}function dr(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(gt(e.body)&&!t.has("content-type")){for(let[r,s]of Object.entries(e?.body))s instanceof Date&&(e.body[r]=s.toISOString());return JSON.stringify(e.body)}return e.body}function mr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let s=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return wt.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 te(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new gr(r.issues);return r.value}var wt=["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=I(j({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=I(j({},c),{body:i.input?await te(i.input,r?.body):r?.body,params:i.params?await te(i.params,r?.params):r?.params,query:i.query?await te(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),wr=e=>{async function t(r,s){let n=I(j(j({},e),s),{plugins:[...e?.plugins||[],vr(e||{})]});if(e?.catchAllError)try{return await fe(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 fe(r,n)}return t};function br(e,t){let{baseURL:r,params:s,query:n}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];wt.includes(c)&&(e=e.replace(`@${c}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(n||{}))h!=null&&u.set(c,String(h));if(s)if(Array.isArray(s)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,m]of c.entries()){let f=s[h];a=a.replace(m,f)}}else for(let[c,h]of Object.entries(s))a=a.replace(`:${c}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=u.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var fe=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=br(h,m),w=dr(m),O=await fr(m),P=mr(h,m),d=I(j({},m),{url:g,headers:O,body:w,method:P,signal:v});for(let S of c.onRequest)if(S){let E=await S(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 Oe={response:_,request:d};for(let S of c.onResponse)if(S){let E=await S(I(j({},Oe),{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 S=ur(_),E={data:"",response:_,request:d};if(S==="json"||S==="text"){let B=await _.text(),M=await((o=d.jsonParser)!=null?o:$e)(B);E.data=M}else E.data=await _[S]();d?.output&&d.output&&!d.disableValidation&&(E.data=await te(d.output,E.data));for(let B of c.onSuccess)B&&await B(I(j({},E),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?E.data:{data:E.data,error:null}}let Ct=(l=t?.jsonParser)!=null?l:$e,J=await _.text(),Pe=cr(J),le=Pe?await Ct(J):null,Lt={response:_,responseText:J,request:d,error:I(j({},le),{status:_.status,statusText:_.statusText})};for(let S of c.onError)S&&await S(I(j({},Lt),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let S=ar(t.retry),E=(i=t.retryAttempt)!=null?i:0;if(await S.shouldAttemptRetry(E,_)){for(let M of c.onRetry)M&&await M(Oe);let B=S.getDelay(E);return await new Promise(M=>setTimeout(M,B)),await fe(e,I(j({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new sr(_.status,_.statusText,Pe?le:J);return{data:null,error:I(j({},le),{status:_.status,statusText:_.statusText})}};p();p();var re=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?re:globalThis),A=new Proxy(re,{get(e,t){return W()[t]??re[t]},has(e,t){let r=W();return t in r||t in re},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 b(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var ws=Object.freeze({get BETTER_AUTH_SECRET(){return b("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return b("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return b("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return b("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return b("NODE_ENV","development")},get PACKAGE_VERSION(){return b("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return b("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),z=1,T=4,N=8,R=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:R,putty:T,st:T,"rxvt-unicode-24bit":R,terminator:R,"xterm-kitty":R},_r=new Map(Object.entries({APPVEYOR:N,BUILDKITE:N,CIRCLECI:R,DRONE:N,GITEA_ACTIONS:R,GITHUB_ACTIONS:R,GITLAB_CI:N,TRAVIS:N})),Er=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Tr(){if(b("FORCE_COLOR")!==void 0)switch(b("FORCE_COLOR")){case"":case"1":case"true":return T;case"2":return N;case"3":return R;default:return z}if(b("NODE_DISABLE_COLORS")!==void 0&&b("NODE_DISABLE_COLORS")!==""||b("NO_COLOR")!==void 0&&b("NO_COLOR")!==""||b("TERM")==="dumb")return z;if(b("TMUX"))return R;if("TF_BUILD"in A&&"AGENT_NAME"in A)return T;if("CI"in A){for(let{0:e,1:t}of _r)if(e in A)return t;return b("CI_NAME")==="codeship"?N:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(b("TEAMCITY_VERSION"))!==null?T:z;switch(b("TERM_PROGRAM")){case"iTerm.app":return!b("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(b("TERM_PROGRAM_VERSION"))!==null?N:R;case"HyperTerm":case"MacTerm":return R;case"Apple_Terminal":return N}if(b("COLORTERM")==="truecolor"||b("COLORTERM")==="24bit")return R;if(b("TERM")){if(/truecolor/.exec(b("TERM"))!==null)return R;if(/^xterm-256/.exec(b("TERM"))!==null)return N;let e=b("TERM").toLowerCase();if(Ie[e])return Ie[e];if(Er.some(t=>t.exec(e)!==null))return T}return b("COLORTERM")?T:z}var x={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"}},pe=["info","success","warn","error","debug"];function Or(e,t){return pe.indexOf(t)<=pe.indexOf(e)}var Pr={info:x.fg.blue,success:x.fg.green,warn:x.fg.yellow,error:x.fg.red,debug:x.fg.magenta},Sr=(e,t,r)=>{let s=new Date().toISOString();return r?`${x.dim}${s}${x.reset} ${Pr[e]}${e.toUpperCase()}${x.reset} ${x.bright}[Better Auth]:${x.reset} ${t}`:`${s} ${e.toUpperCase()} [Better Auth]: ${t}`},Rr=e=>{let t=e?.disabled!==!0,r=e?.level??"error",s=e?.disableColors!==void 0?!e.disableColors:Tr()!==1,n=(o,a,l=[])=>{if(!t||!Or(r,o))return;let u=Sr(o,a,s);if(!e||typeof e.log!="function"){o==="error"?console.error(u,...l):o==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(pe.map(o=>[o,(...[a,...l])=>n(o,a,l)])),get level(){return r}}},bs=Rr();p();p();var we=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 we(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function K(e,t="/api/auth"){if(Ar(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function $r(e,t,r,s){if(e)return K(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 K(a,t)}let n=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(n&&o)return K(`${o}://${n}`,t);if(r){let a=jr(r.url);if(!a)throw new we("Could not get origin from request. Please provide a valid base URL.");return K(a,t)}if(typeof window<"u"&&window.location)return K(window.location.origin,t)}function jr(e){try{return new URL(e).origin}catch{return null}}p();p();p();var de=Symbol("clean"),$=[],C=0,X=4,Ir=0,bt=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=C+X;o<$.length;)$[o]===s?$.splice(o,X):o+=X;let n=t.indexOf(s);~n&&(t.splice(n,1),--r.lc||r.off())}},notify(s,n){Ir++;let o=!$.length;for(let a of t)$.push(a,r.value,s,n);if(o){for(C=0;C<$.length;C+=X)$[C]($[C+1],$[C+2],$[C+3]);$.length=0}},off(){},set(s){let n=r.value;n!==s&&(r.value=s,r.notify(n))},subscribe(s){let n=r.listen(s);return s(r.value),n},value:e};return process.env.NODE_ENV!=="production"&&(r[de]=()=>{t=[],r.lc=0,r.off()}),r};p();var Nr=5,F=6,Q=10,xr=(e,t,r,s)=>(e.events=e.events||{},e.events[r+Q]||(e.events[r+Q]=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+Q](),delete e.events[r+Q])}),Ur=1e3,Cr=(e,t)=>xr(e,r=>{let s=t(r);s&&e.events[F].push(s)},Nr,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[de];e[de]=()=>{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",Dr=(e,t,r,s)=>{let n=bt({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():Cr(n,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{n.off(),l.off(),clearTimeout(u)}}))});return n};p();var kr={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Br=/^\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},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 Hr(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 qr(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 Ne)return Ne[l];if(!Br.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(kr).some(([u,i])=>{let c=i.test(a);return c&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=Hr(i);if(c)return c}return n?n(u,i):i})}catch(u){if(r)throw u;return e}}function Gr(e,t={strict:!0}){return qr(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 zr(e){let t=bt(!1);return{session:Dr(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=wr({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(d){return d?Gr(d,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Wr],...n]}),{$sessionSignal:m,session:f}=zr(h),y=e?.plugins||[],v={},g={$sessionSignal:m,session:f},w={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},O=[{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(w,d.pathMethods),d.atomListeners&&O.push(...d.atomListeners);let P={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,P,e));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:w,atomListeners:O,$fetch:h,$store:P}};function Vr(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:n,query:o,...a}=r||{};return s||(n?.method?n.method:a&&Object.keys(a).length>0?"POST":"GET")}function Jr(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"||Vr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(O=>O.replace(/[A-Z]/g,P=>`-${P.toLowerCase()}`)).join("/"),h=i[0]||{},m=i[1]||{},{query:f,fetchOptions:y,...v}=h,g={...m,...y},w=Yr(c,r,h);return await t(c,{...g,body:w==="GET"?void 0:{...v,...g?.body||{}},query:f||g?.query,method:w,async onSuccess(O){if(await g?.onSuccess?.(O),!n)return;let P=n.filter(d=>d.matcher(c));if(P.length)for(let d of P){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}=Kr(e),l={};for(let[i,c]of Object.entries(s))l[`use${Xr(i)}`]=c;let u={...r,...l,$fetch:n,$store:a};return Jr(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 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 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"]},be=_t(es),_s=be.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Es=be.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Ts=be.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),Ps=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=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),os=()=>({id:"better-auth-client",$InferServerPlugin:{}}),as="/auth",ce="nvwa_login_token",se="nvwa_current_jwt",he="nvwa_user_profile",Tt=class{constructor(e,t,r){this.storage=r;let s=Qr({baseURL:e,basePath:as,plugins:[ss(),ns(),os()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let n=await this.storage.get(se);if(console.log("jwt",n),n)return n;let o=await this.storage.get(ce);return console.log("loginToken",o),o}}}});this.authClient=s}async currentUser(){return await this.storage.get(he)}async getCurrentJwt(){return await this.storage.get(se)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(s)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(ce,e.data?.token),await this.storage.set(he,e.data?.user);let{data:t,error:r}=await this.authClient.token();if(r)throw new Error(r.message);await this.storage.set(se,t.token)}async signOut(){await this.storage.remove(ce),await this.storage.remove(he)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(s)}};p();var Ot=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};p();p();p();var U=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()}},St=class Rt{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof Rt)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}},is=class me{constructor(t,r){let s;if(t instanceof me)s=t.href;else if(r){let o=r instanceof me?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 St(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 ls=class At{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 U?r.headers:new U(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new At(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var _e=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=us(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 us(e){return e?new U(e):new U}p();var $t=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]"}},cs=class{constructor(){this._signal=new $t}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function jt(e){e.URL=is,e.URLSearchParams=St,e.Headers=U,e.Request=ls,e.Response=_e,e.AbortController=cs,e.AbortSignal=$t}var It=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(se),s=new U(t?.headers);r&&s.set("Authorization",`Bearer ${r}`);let n=await this.customFetch(e,{...t,headers:s});if(n.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return n}};p();var hs="/storage",fs=hs+"/generateUploadUrl",Nt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+fs,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:e,headers:new U({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:n}=await s.json();return{url:n.split("?")[0]}}};p();p();p();var xe=Yt(Xt(),1),{PostgrestClient:ps,PostgrestQueryBuilder:Rs,PostgrestFilterBuilder:As,PostgrestTransformBuilder:$s,PostgrestBuilder:js,PostgrestError:Is}=xe.default||xe,ds="/entities",xt=(e,t)=>new ps(e+ds,{fetch:t.fetchWithAuth.bind(t)});p();var Ut=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:t,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};var ae=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 ms=(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 U,w=f.header||f.headers||{};Object.keys(w).forEach(O=>{let P=w[O];g.set(O,typeof P=="string"?P:String(P))}),l(new _e(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{}})}})},Ee=ms;var Te=new ae,ie=class{constructor(t,r){this.auth=new Tt(t,Ee,Te),this.httpClient=new It(Te,Ee,r),this.fileStorage=new Nt(t,this.httpClient),this.entities=xt(t,this.httpClient),this.functions=new Ot(this.httpClient),this.skill=new Ut(t,this.httpClient)}};0&&(module.exports={localStorage,polyfill});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Lt=Object.create,oe=Object.defineProperty,Dt=Object.getOwnPropertyDescriptor,kt=Object.getOwnPropertyNames,Bt=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty,xe=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ft=(e,t)=>{for(var r in t)oe(e,r,{get:t[r],enumerable:!0})},Ue=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of kt(t))!Mt.call(e,n)&&n!==r&&oe(e,n,{get:()=>t[n],enumerable:!(s=Dt(t,n))||s.enumerable});return e},Ht=(e,t,r)=>(r=e!=null?Lt(Bt(e)):{},Ue(t||!e||!e.__esModule?oe(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>Ue(oe({},"__esModule",{value:!0}),e),p=xe(()=>{"use strict"}),k={};Ft(k,{__addDisposableResource:()=>ot,__assign:()=>V,__asyncDelegator:()=>Xe,__asyncGenerator:()=>Je,__asyncValues:()=>Qe,__await:()=>H,__awaiter:()=>Ge,__classPrivateFieldGet:()=>rt,__classPrivateFieldIn:()=>nt,__classPrivateFieldSet:()=>st,__createBinding:()=>Y,__decorate:()=>De,__disposeResources:()=>at,__esDecorate:()=>Be,__exportStar:()=>ze,__extends:()=>Ce,__generator:()=>We,__importDefault:()=>tt,__importStar:()=>et,__makeTemplateObject:()=>Ze,__metadata:()=>qe,__param:()=>ke,__propKey:()=>Fe,__read:()=>ye,__rest:()=>Le,__rewriteRelativeImportExtension:()=>it,__runInitializers:()=>Me,__setFunctionName:()=>He,__spread:()=>Ke,__spreadArray:()=>Ye,__spreadArrays:()=>Ve,__values:()=>ne,default:()=>ct});function Ce(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Z(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Le(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 De(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 Be(e,t,r,s,n,o){function a(w){if(w!==void 0&&typeof w!="function")throw new TypeError("Function expected");return w}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(w){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(w||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 Me(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 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 qe(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Ge(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 We(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,n,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(c){return u([i,c])}}function u(i){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(s=1,n&&(o=i[0]&2?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,n=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],n=0}finally{s=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ze(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Y(t,e,r)}function ne(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 ye(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),n,o=[],a;try{for(;(t===void 0||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(l){a={error:l}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return o}function Ke(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ye(arguments[t]));return e}function Ve(){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 H(e){return this instanceof H?(this.v=e,this):new H(e)}function Je(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,w){o.push([f,v,g,w])>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 H?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 Xe(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:H(e[n](a)),done:!1}:o?o(a):a}:o}}function Qe(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 ne=="function"?ne(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 Ze(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function et(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ee(e),s=0;s<r.length;s++)r[s]!=="default"&&Y(t,e,r[s]);return lt(t,e),t}function tt(e){return e&&e.__esModule?e:{default:e}}function rt(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 st(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 nt(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 ot(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 at(e){function t(o){e.error=e.hasError?new ut(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 it(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 Z,V,Y,lt,ee,ut,ct,G=xe(()=>{"use strict";p(),Z=function(e,t){return Z=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])},Z(e,t)},V=function(){return V=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},V.apply(this,arguments)},Y=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),lt=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},ee=function(e){return ee=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},ee(e)},ut=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s},ct={__extends:Ce,__assign:V,__rest:Le,__decorate:De,__param:ke,__esDecorate:Be,__runInitializers:Me,__propKey:Fe,__setFunctionName:He,__metadata:qe,__awaiter:Ge,__generator:We,__createBinding:Y,__exportStar:ze,__values:ne,__read:ye,__spread:Ke,__spreadArrays:Ve,__spreadArray:Ye,__await:H,__asyncGenerator:Je,__asyncDelegator:Xe,__asyncValues:Qe,__makeTemplateObject:Ze,__importStar:et,__importDefault:tt,__classPrivateFieldGet:rt,__classPrivateFieldSet:st,__classPrivateFieldIn:nt,__addDisposableResource:ot,__disposeResources:at,__rewriteRelativeImportExtension:it}}),ht=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),ft=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(ht()),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,w=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 O=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),P=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");O&&P&&P.length>1&&(v=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(f={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,v=null,g=406,w="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{let O=await u.text();try{f=JSON.parse(O),Array.isArray(f)&&u.status===404&&(y=[],f=null,g=200,w="OK")}catch{u.status===404&&O===""?(g=204,w="No Content"):f={message:O}}if(f&&this.isMaybeSingle&&!((m=f?.details)===null||m===void 0)&&m.includes("0 rows")&&(f=null,g=200,w="OK"),f&&this.shouldThrowOnError)throw new r.default(f)}return{error:f,data:y,count:v,status:g,statusText:w}});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}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(ft()),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}),ge=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(pt()),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}),dt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(ge()),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=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(dt()),s=t.__importDefault(ge()),n=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 m,f=new URL(`${this.url}/rpc/${a}`),y;u||i?(m=u?"HEAD":"GET",Object.entries(l).filter(([g,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{f.searchParams.append(g,w)})):(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}),Gt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),q(k)),r=t.__importDefault(qt());e.PostgrestClient=r.default;var s=t.__importDefault(dt());e.PostgrestQueryBuilder=s.default;var n=t.__importDefault(ge());e.PostgrestFilterBuilder=n.default;var o=t.__importDefault(pt());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(ft());e.PostgrestBuilder=a.default;var l=t.__importDefault(ht());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 Wt=Object.defineProperty,zt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Vt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?Wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,j=(e,t)=>{for(var r in t||(t={}))Vt.call(t,r)&&Se(e,r,t[r]);if(Pe)for(var r of Pe(t))Yt.call(t,r)&&Se(e,r,t[r]);return e},I=(e,t)=>zt(e,Kt(t)),Jt=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},Xt=async(e,t)=>{var r,s,n,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((s=c.hooks)==null?void 0:s.onRequest),i.onResponse.push((n=c.hooks)==null?void 0:n.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},Re=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},Qt=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function Zt(e){if(typeof e=="number")return new Re({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Re(e);case"exponential":return new Qt(e);default:throw new Error("Invalid retry strategy")}}var er=async e=>{let t={},r=async s=>typeof s=="function"?await s():s;if(e?.auth){if(e.auth.type==="Bearer"){let s=await r(e.auth.token);if(!s)return t;t.authorization=`Bearer ${s}`}else if(e.auth.type==="Basic"){let s=r(e.auth.username),n=r(e.auth.password);if(!s||!n)return t;t.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(e.auth.type==="Custom"){let s=r(e.auth.value);if(!s)return t;t.authorization=`${r(e.auth.prefix)} ${s}`}}return t},tr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function rr(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let s=t.split(";").shift()||"";return tr.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function sr(e){try{return JSON.parse(e),!0}catch{return!1}}function yt(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 Ae(e){try{return JSON.parse(e)}catch{return e}}function $e(e){return typeof e=="function"}function nr(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 or(e){let t=new Headers(e?.headers),r=await er(e);for(let[s,n]of Object.entries(r||{}))t.set(s,n);if(!t.has("content-type")){let s=ar(e?.body);s&&t.set("content-type",s)}return t}function ar(e){return yt(e)?"application/json":null}function ir(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(yt(e.body)&&!t.has("content-type")){for(let[r,s]of Object.entries(e?.body))s instanceof Date&&(e.body[r]=s.toISOString());return JSON.stringify(e.body)}return e.body}function lr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let s=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return vt.includes(s)?s.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function ur(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var cr=class gt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,gt.prototype)}};async function te(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new cr(r.issues);return r.value}var vt=["get","post","put","patch","delete"],hr=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var s,n,o,a;let l=((n=(s=e.plugins)==null?void 0:s.find(u=>{var i;return(i=u.schema)!=null&&i.config?t.startsWith(u.schema.config.baseURL||"")||t.startsWith(u.schema.config.prefix||""):!1}))==null?void 0:n.schema)||e.schema;if(l){let u=t;(o=l.config)!=null&&o.prefix&&u.startsWith(l.config.prefix)&&(u=u.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&u.startsWith(l.config.baseURL)&&(u=u.replace(l.config.baseURL,""));let i=l.schema[u];if(i){let c=I(j({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=I(j({},c),{body:i.input?await te(i.input,r?.body):r?.body,params:i.params?await te(i.params,r?.params):r?.params,query:i.query?await te(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),fr=e=>{async function t(r,s){let n=I(j(j({},e),s),{plugins:[...e?.plugins||[],hr(e||{})]});if(e?.catchAllError)try{return await ce(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 ce(r,n)}return t};function pr(e,t){let{baseURL:r,params:s,query:n}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];vt.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 ce=async(e,t)=>{var r,s,n,o,a,l,u,i;let{hooks:c,url:h,options:m}=await Xt(e,t),f=nr(m),y=new AbortController,v=(r=m.signal)!=null?r:y.signal,g=pr(h,m),w=ir(m),O=await or(m),P=lr(h,m),d=I(j({},m),{url:g,headers:O,body:w,method:P,signal:v});for(let S of c.onRequest)if(S){let E=await S(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}=ur(m,y),_=await f(d.url,d);L();let Te={response:_,request:d};for(let S of c.onResponse)if(S){let E=await S(I(j({},Te),{response:(n=t?.hookOptions)!=null&&n.cloneResponse?_.clone():_}));E instanceof Response?_=E:E instanceof Object&&(_=E.response)}if(_.ok){if(d.method==="HEAD")return{data:"",error:null};let S=rr(_),E={data:"",response:_,request:d};if(S==="json"||S==="text"){let B=await _.text(),M=await((o=d.jsonParser)!=null?o:Ae)(B);E.data=M}else E.data=await _[S]();d?.output&&d.output&&!d.disableValidation&&(E.data=await te(d.output,E.data));for(let B of c.onSuccess)B&&await B(I(j({},E),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?E.data:{data:E.data,error:null}}let Ut=(l=t?.jsonParser)!=null?l:Ae,J=await _.text(),Oe=sr(J),ie=Oe?await Ut(J):null,Ct={response:_,responseText:J,request:d,error:I(j({},ie),{status:_.status,statusText:_.statusText})};for(let S of c.onError)S&&await S(I(j({},Ct),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let S=Zt(t.retry),E=(i=t.retryAttempt)!=null?i:0;if(await S.shouldAttemptRetry(E,_)){for(let M of c.onRetry)M&&await M(Te);let B=S.getDelay(E);return await new Promise(M=>setTimeout(M,B)),await ce(e,I(j({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new Jt(_.status,_.statusText,Oe?ie:J);return{data:null,error:I(j({},ie),{status:_.status,statusText:_.statusText})}};p();p();var re=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?re:globalThis),A=new Proxy(re,{get(e,t){return W()[t]??re[t]},has(e,t){let r=W();return t in r||t in re},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)}}),cs=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function b(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 hs=Object.freeze({get BETTER_AUTH_SECRET(){return b("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return b("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return b("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return b("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return b("NODE_ENV","development")},get PACKAGE_VERSION(){return b("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return b("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),z=1,T=4,N=8,R=24,je={eterm:T,cons25:T,console:T,cygwin:T,dtterm:T,gnome:T,hurd:T,jfbterm:T,konsole:T,kterm:T,mlterm:T,mosh:R,putty:T,st:T,"rxvt-unicode-24bit":R,terminator:R,"xterm-kitty":R},dr=new Map(Object.entries({APPVEYOR:N,BUILDKITE:N,CIRCLECI:R,DRONE:N,GITEA_ACTIONS:R,GITHUB_ACTIONS:R,GITLAB_CI:N,TRAVIS:N})),mr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function yr(){if(b("FORCE_COLOR")!==void 0)switch(b("FORCE_COLOR")){case"":case"1":case"true":return T;case"2":return N;case"3":return R;default:return z}if(b("NODE_DISABLE_COLORS")!==void 0&&b("NODE_DISABLE_COLORS")!==""||b("NO_COLOR")!==void 0&&b("NO_COLOR")!==""||b("TERM")==="dumb")return z;if(b("TMUX"))return R;if("TF_BUILD"in A&&"AGENT_NAME"in A)return T;if("CI"in A){for(let{0:e,1:t}of dr)if(e in A)return t;return b("CI_NAME")==="codeship"?N:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(b("TEAMCITY_VERSION"))!==null?T:z;switch(b("TERM_PROGRAM")){case"iTerm.app":return!b("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(b("TERM_PROGRAM_VERSION"))!==null?N:R;case"HyperTerm":case"MacTerm":return R;case"Apple_Terminal":return N}if(b("COLORTERM")==="truecolor"||b("COLORTERM")==="24bit")return R;if(b("TERM")){if(/truecolor/.exec(b("TERM"))!==null)return R;if(/^xterm-256/.exec(b("TERM"))!==null)return N;let e=b("TERM").toLowerCase();if(je[e])return je[e];if(mr.some(t=>t.exec(e)!==null))return T}return b("COLORTERM")?T:z}var x={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"}},he=["info","success","warn","error","debug"];function gr(e,t){return he.indexOf(t)<=he.indexOf(e)}var vr={info:x.fg.blue,success:x.fg.green,warn:x.fg.yellow,error:x.fg.red,debug:x.fg.magenta},wr=(e,t,r)=>{let s=new Date().toISOString();return r?`${x.dim}${s}${x.reset} ${vr[e]}${e.toUpperCase()}${x.reset} ${x.bright}[Better Auth]:${x.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:yr()!==1,n=(o,a,l=[])=>{if(!t||!gr(r,o))return;let u=wr(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(he.map(o=>[o,(...[a,...l])=>n(o,a,l)])),get level(){return r}}},fs=br();p();p();var ve=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function _r(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new ve(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function K(e,t="/api/auth"){if(_r(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function Er(e,t,r,s){if(e)return K(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 K(a,t)}let n=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(n&&o)return K(`${o}://${n}`,t);if(r){let a=Tr(r.url);if(!a)throw new ve("Could not get origin from request. Please provide a valid base URL.");return K(a,t)}if(typeof window<"u"&&window.location)return K(window.location.origin,t)}function Tr(e){try{return new URL(e).origin}catch{return null}}p();p();p();var fe=Symbol("clean"),$=[],C=0,X=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=C+X;o<$.length;)$[o]===s?$.splice(o,X):o+=X;let n=t.indexOf(s);~n&&(t.splice(n,1),--r.lc||r.off())}},notify(s,n){Or++;let o=!$.length;for(let a of t)$.push(a,r.value,s,n);if(o){for(C=0;C<$.length;C+=X)$[C]($[C+1],$[C+2],$[C+3]);$.length=0}},off(){},set(s){let n=r.value;n!==s&&(r.value=s,r.notify(n))},subscribe(s){let n=r.listen(s);return s(r.value),n},value:e};return process.env.NODE_ENV!=="production"&&(r[fe]=()=>{t=[],r.lc=0,r.off()}),r};p();var Pr=5,F=6,Q=10,Sr=(e,t,r,s)=>(e.events=e.events||{},e.events[r+Q]||(e.events[r+Q]=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+Q](),delete e.events[r+Q])}),Rr=1e3,Ar=(e,t)=>Sr(e,r=>{let s=t(r);s&&e.events[F].push(s)},Pr,r=>{let s=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),s(...o));let n=e.off;if(e.events[F]=[],e.off=()=>{n(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[F])o();e.events[F]=[]}},Rr)},process.env.NODE_ENV!=="production"){let o=e[fe];e[fe]=()=>{for(let a of e.events[F])a();e.events[F]=[],e.active=!1,o()}}return()=>{e.listen=s,e.off=n}});p();var $r=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(()=>{$r||(a?o():Ar(n,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{n.off(),l.off(),clearTimeout(u)}}))});return n};p();var Ir={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Nr=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,Ie={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},xr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Ur(e){return e instanceof Date&&!isNaN(e.getTime())}function Cr(e){let t=xr.exec(e);if(!t)return null;let[,r,s,n,o,a,l,u,i,c,h]=t,m=new Date(Date.UTC(parseInt(r,10),parseInt(s,10)-1,parseInt(n,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),u?parseInt(u.padEnd(3,"0"),10):0));if(i){let f=(parseInt(c,10)*60+parseInt(h,10))*(i==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+f)}return Ur(m)?m:null}function Lr(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 Ie)return Ie[l];if(!Nr.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(Ir).some(([u,i])=>{let c=i.test(a);return c&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=Cr(i);if(c)return c}return n?n(u,i):i})}catch(u){if(r)throw u;return e}}function Dr(e,t={strict:!0}){return Lr(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 Br(e){let t=wt(!1);return{session:jr(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var Mr=(e,t)=>{let r="credentials"in Request.prototype,s=Er(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",n=e?.plugins?.flatMap(d=>d.fetchPlugins).filter(d=>d!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:u,onResponse:i,...c}=e?.fetchOptions||{},h=fr({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(d){return d?Dr(d,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[kr],...n]}),{$sessionSignal:m,session:f}=Br(h),y=e?.plugins||[],v={},g={$sessionSignal:m,session:f},w={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},O=[{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(w,d.pathMethods),d.atomListeners&&O.push(...d.atomListeners);let P={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,P,e));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:w,atomListeners:O,$fetch:h,$store:P}};function Fr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Hr(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"||Fr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(O=>O.replace(/[A-Z]/g,P=>`-${P.toLowerCase()}`)).join("/"),h=i[0]||{},m=i[1]||{},{query:f,fetchOptions:y,...v}=h,g={...m,...y},w=Hr(c,r,h);return await t(c,{...g,body:w==="GET"?void 0:{...v,...g?.body||{}},query:f||g?.query,method:w,async onSuccess(O){if(await g?.onSuccess?.(O),!n)return;let P=n.filter(d=>d.matcher(c));if(P.length)for(let d of P){let L=s[d.signal];if(!L)return;let _=L.get();setTimeout(()=>{L.set(!_)},10)}}})}})}return o()}p();function Gr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Wr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:s,$fetch:n,atomListeners:o,$store:a}=Mr(e),l={};for(let[i,c]of Object.entries(s))l[`use${Gr(i)}`]=c;let u={...r,...l,$fetch:n,$store:a};return qr(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 ve("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 bt(e){return{newRole(t){return zr(t)},statements:e}}var Kr={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},we=bt(Kr),ps=we.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ds=we.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ms=we.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var Vr=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}}},ys=new Vr;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"]},_t=bt(Yr),gs=_t.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),vs=_t.newRole({user:[],session:[]});p();p();var Jr=()=>({id:"username",$InferServerPlugin:{}}),Xr=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),Qr=()=>({id:"better-auth-client",$InferServerPlugin:{}}),Zr="/auth",le="nvwa_login_token",se="nvwa_current_jwt",ue="nvwa_user_profile",Et=class{constructor(e,t,r){this.storage=r;let s=Wr({baseURL:e,basePath:Zr,plugins:[Jr(),Xr(),Qr()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let n=await this.storage.get(se);if(console.log("jwt",n),n)return n;let o=await this.storage.get(le);return console.log("loginToken",o),o}}}});this.authClient=s}async currentUser(){return await this.storage.get(ue)}async getCurrentJwt(){return await this.storage.get(se)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(s)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(le,e.data?.token),await this.storage.set(ue,e.data?.user);let{data:t,error:r}=await this.authClient.token();if(r)throw new Error(r.message);await this.storage.set(se,t.token)}async signOut(){await this.storage.remove(le),await this.storage.remove(ue)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(s)}};p();var Tt=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};p();p();p();var U=class Ot{constructor(t){if(this.headerMap=new Map,t){if(t instanceof Ot)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()}},Pt=class St{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof St)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 pe{constructor(t,r){let s;if(t instanceof pe)s=t.href;else if(r){let o=r instanceof pe?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 Pt(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 Rt{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 U?r.headers:new U(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new Rt(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var be=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 U(e):new U}p();var At=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 At}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function ns(e){e.URL=es,e.URLSearchParams=Pt,e.Headers=U,e.Request=ts,e.Response=be,e.AbortController=ss,e.AbortSignal=At}var $t=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(se),s=new U(t?.headers);r&&s.set("Authorization",`Bearer ${r}`);let n=await this.customFetch(e,{...t,headers:s});if(n.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return n}};p();var os="/storage",as=os+"/generateUploadUrl",jt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+as,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:e,headers:new U({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:n}=await s.json();return{url:n.split("?")[0]}}};p();p();p();var Ne=Ht(Gt(),1),{PostgrestClient:is,PostgrestQueryBuilder:ws,PostgrestFilterBuilder:bs,PostgrestTransformBuilder:_s,PostgrestBuilder:Es,PostgrestError:Ts}=Ne.default||Ne,ls="/entities",It=(e,t)=>new is(e+ls,{fetch:t.fetchWithAuth.bind(t)});p();var Nt=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:t})).json();if(s.status!==200)throw new Error(s.message);return s.data}};var ae=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 us=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let s=(t?.method||"GET").toUpperCase(),n={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{n[i]=u});else if(Array.isArray(l))for(let[u,i]of l)n[u]=i;else Object.assign(n,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),o=u}else o=l}let a=t?.timeout||3e4;return new Promise((l,u)=>{let i=t?.signal;if(i?.aborted){let f=new Error("The operation was aborted");f.name="AbortError",u(f);return}let c=!1,h=[],m=uni.request({url:r,method:s,data:o,header:n,timeout:a,success:f=>{if(c)return;c=!0;let y=f.statusCode,v="",g=new U,w=f.header||f.headers||{};Object.keys(w).forEach(O=>{let P=w[O];g.set(O,typeof P=="string"?P:String(P))}),l(new be(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{}})}})},_e=us;var xt=new ae,Ee=class{constructor(t,r){this.auth=new Et(t,_e,xt),this.httpClient=new $t(xt,_e,r),this.fileStorage=new jt(t,this.httpClient),this.entities=It(t,this.httpClient),this.functions=new Tt(this.httpClient),this.skill=new Nt(t,this.httpClient)}};export{Ee as default,xt as localStorage,ns as polyfill};
|
|
1
|
+
var Lt=Object.create,oe=Object.defineProperty,Dt=Object.getOwnPropertyDescriptor,kt=Object.getOwnPropertyNames,Bt=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty,xe=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ft=(e,t)=>{for(var r in t)oe(e,r,{get:t[r],enumerable:!0})},Ue=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of kt(t))!Mt.call(e,n)&&n!==r&&oe(e,n,{get:()=>t[n],enumerable:!(s=Dt(t,n))||s.enumerable});return e},Ht=(e,t,r)=>(r=e!=null?Lt(Bt(e)):{},Ue(t||!e||!e.__esModule?oe(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>Ue(oe({},"__esModule",{value:!0}),e),p=xe(()=>{"use strict"}),k={};Ft(k,{__addDisposableResource:()=>ot,__assign:()=>V,__asyncDelegator:()=>Xe,__asyncGenerator:()=>Je,__asyncValues:()=>Qe,__await:()=>H,__awaiter:()=>Ge,__classPrivateFieldGet:()=>rt,__classPrivateFieldIn:()=>nt,__classPrivateFieldSet:()=>st,__createBinding:()=>Y,__decorate:()=>De,__disposeResources:()=>at,__esDecorate:()=>Be,__exportStar:()=>ze,__extends:()=>Ce,__generator:()=>We,__importDefault:()=>tt,__importStar:()=>et,__makeTemplateObject:()=>Ze,__metadata:()=>qe,__param:()=>ke,__propKey:()=>Fe,__read:()=>ye,__rest:()=>Le,__rewriteRelativeImportExtension:()=>it,__runInitializers:()=>Me,__setFunctionName:()=>He,__spread:()=>Ke,__spreadArray:()=>Ye,__spreadArrays:()=>Ve,__values:()=>ne,default:()=>ct});function Ce(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Z(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Le(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 De(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 Be(e,t,r,s,n,o){function a(w){if(w!==void 0&&typeof w!="function")throw new TypeError("Function expected");return w}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(w){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(w||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 Me(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 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 qe(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Ge(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 We(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,n,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(c){return u([i,c])}}function u(i){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(s=1,n&&(o=i[0]&2?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,n=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],n=0}finally{s=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ze(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Y(t,e,r)}function ne(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 ye(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),n,o=[],a;try{for(;(t===void 0||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(l){a={error:l}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return o}function Ke(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ye(arguments[t]));return e}function Ve(){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 H(e){return this instanceof H?(this.v=e,this):new H(e)}function Je(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,w){o.push([f,v,g,w])>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 H?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 Xe(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:H(e[n](a)),done:!1}:o?o(a):a}:o}}function Qe(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 ne=="function"?ne(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 Ze(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function et(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ee(e),s=0;s<r.length;s++)r[s]!=="default"&&Y(t,e,r[s]);return lt(t,e),t}function tt(e){return e&&e.__esModule?e:{default:e}}function rt(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 st(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 nt(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 ot(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 at(e){function t(o){e.error=e.hasError?new ut(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 it(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 Z,V,Y,lt,ee,ut,ct,G=xe(()=>{"use strict";p(),Z=function(e,t){return Z=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])},Z(e,t)},V=function(){return V=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},V.apply(this,arguments)},Y=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),lt=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},ee=function(e){return ee=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},ee(e)},ut=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s},ct={__extends:Ce,__assign:V,__rest:Le,__decorate:De,__param:ke,__esDecorate:Be,__runInitializers:Me,__propKey:Fe,__setFunctionName:He,__metadata:qe,__awaiter:Ge,__generator:We,__createBinding:Y,__exportStar:ze,__values:ne,__read:ye,__spread:Ke,__spreadArrays:Ve,__spreadArray:Ye,__await:H,__asyncGenerator:Je,__asyncDelegator:Xe,__asyncValues:Qe,__makeTemplateObject:Ze,__importStar:et,__importDefault:tt,__classPrivateFieldGet:rt,__classPrivateFieldSet:st,__classPrivateFieldIn:nt,__addDisposableResource:ot,__disposeResources:at,__rewriteRelativeImportExtension:it}}),ht=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),ft=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(ht()),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,w=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 O=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),P=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");O&&P&&P.length>1&&(v=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(f={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,v=null,g=406,w="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{let O=await u.text();try{f=JSON.parse(O),Array.isArray(f)&&u.status===404&&(y=[],f=null,g=200,w="OK")}catch{u.status===404&&O===""?(g=204,w="No Content"):f={message:O}}if(f&&this.isMaybeSingle&&!((m=f?.details)===null||m===void 0)&&m.includes("0 rows")&&(f=null,g=200,w="OK"),f&&this.shouldThrowOnError)throw new r.default(f)}return{error:f,data:y,count:v,status:g,statusText:w}});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}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(ft()),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}),ge=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(pt()),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}),dt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(ge()),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=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(k)),r=t.__importDefault(dt()),s=t.__importDefault(ge()),n=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 m,f=new URL(`${this.url}/rpc/${a}`),y;u||i?(m=u?"HEAD":"GET",Object.entries(l).filter(([g,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{f.searchParams.append(g,w)})):(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}),Gt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),q(k)),r=t.__importDefault(qt());e.PostgrestClient=r.default;var s=t.__importDefault(dt());e.PostgrestQueryBuilder=s.default;var n=t.__importDefault(ge());e.PostgrestFilterBuilder=n.default;var o=t.__importDefault(pt());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(ft());e.PostgrestBuilder=a.default;var l=t.__importDefault(ht());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 Wt=Object.defineProperty,zt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Vt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?Wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,j=(e,t)=>{for(var r in t||(t={}))Vt.call(t,r)&&Se(e,r,t[r]);if(Pe)for(var r of Pe(t))Yt.call(t,r)&&Se(e,r,t[r]);return e},I=(e,t)=>zt(e,Kt(t)),Jt=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},Xt=async(e,t)=>{var r,s,n,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((s=c.hooks)==null?void 0:s.onRequest),i.onResponse.push((n=c.hooks)==null?void 0:n.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},Re=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},Qt=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function Zt(e){if(typeof e=="number")return new Re({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Re(e);case"exponential":return new Qt(e);default:throw new Error("Invalid retry strategy")}}var er=async e=>{let t={},r=async s=>typeof s=="function"?await s():s;if(e?.auth){if(e.auth.type==="Bearer"){let s=await r(e.auth.token);if(!s)return t;t.authorization=`Bearer ${s}`}else if(e.auth.type==="Basic"){let s=r(e.auth.username),n=r(e.auth.password);if(!s||!n)return t;t.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(e.auth.type==="Custom"){let s=r(e.auth.value);if(!s)return t;t.authorization=`${r(e.auth.prefix)} ${s}`}}return t},tr=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function rr(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let s=t.split(";").shift()||"";return tr.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function sr(e){try{return JSON.parse(e),!0}catch{return!1}}function yt(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 Ae(e){try{return JSON.parse(e)}catch{return e}}function $e(e){return typeof e=="function"}function nr(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 or(e){let t=new Headers(e?.headers),r=await er(e);for(let[s,n]of Object.entries(r||{}))t.set(s,n);if(!t.has("content-type")){let s=ar(e?.body);s&&t.set("content-type",s)}return t}function ar(e){return yt(e)?"application/json":null}function ir(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(yt(e.body)&&!t.has("content-type")){for(let[r,s]of Object.entries(e?.body))s instanceof Date&&(e.body[r]=s.toISOString());return JSON.stringify(e.body)}return e.body}function lr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let s=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return vt.includes(s)?s.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function ur(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var cr=class gt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,gt.prototype)}};async function te(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new cr(r.issues);return r.value}var vt=["get","post","put","patch","delete"],hr=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var s,n,o,a;let l=((n=(s=e.plugins)==null?void 0:s.find(u=>{var i;return(i=u.schema)!=null&&i.config?t.startsWith(u.schema.config.baseURL||"")||t.startsWith(u.schema.config.prefix||""):!1}))==null?void 0:n.schema)||e.schema;if(l){let u=t;(o=l.config)!=null&&o.prefix&&u.startsWith(l.config.prefix)&&(u=u.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&u.startsWith(l.config.baseURL)&&(u=u.replace(l.config.baseURL,""));let i=l.schema[u];if(i){let c=I(j({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=I(j({},c),{body:i.input?await te(i.input,r?.body):r?.body,params:i.params?await te(i.params,r?.params):r?.params,query:i.query?await te(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),fr=e=>{async function t(r,s){let n=I(j(j({},e),s),{plugins:[...e?.plugins||[],hr(e||{})]});if(e?.catchAllError)try{return await ce(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 ce(r,n)}return t};function pr(e,t){let{baseURL:r,params:s,query:n}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];vt.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 ce=async(e,t)=>{var r,s,n,o,a,l,u,i;let{hooks:c,url:h,options:m}=await Xt(e,t),f=nr(m),y=new AbortController,v=(r=m.signal)!=null?r:y.signal,g=pr(h,m),w=ir(m),O=await or(m),P=lr(h,m),d=I(j({},m),{url:g,headers:O,body:w,method:P,signal:v});for(let S of c.onRequest)if(S){let E=await S(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}=ur(m,y),_=await f(d.url,d);L();let Te={response:_,request:d};for(let S of c.onResponse)if(S){let E=await S(I(j({},Te),{response:(n=t?.hookOptions)!=null&&n.cloneResponse?_.clone():_}));E instanceof Response?_=E:E instanceof Object&&(_=E.response)}if(_.ok){if(d.method==="HEAD")return{data:"",error:null};let S=rr(_),E={data:"",response:_,request:d};if(S==="json"||S==="text"){let B=await _.text(),M=await((o=d.jsonParser)!=null?o:Ae)(B);E.data=M}else E.data=await _[S]();d?.output&&d.output&&!d.disableValidation&&(E.data=await te(d.output,E.data));for(let B of c.onSuccess)B&&await B(I(j({},E),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?E.data:{data:E.data,error:null}}let Ut=(l=t?.jsonParser)!=null?l:Ae,J=await _.text(),Oe=sr(J),ie=Oe?await Ut(J):null,Ct={response:_,responseText:J,request:d,error:I(j({},ie),{status:_.status,statusText:_.statusText})};for(let S of c.onError)S&&await S(I(j({},Ct),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let S=Zt(t.retry),E=(i=t.retryAttempt)!=null?i:0;if(await S.shouldAttemptRetry(E,_)){for(let M of c.onRetry)M&&await M(Te);let B=S.getDelay(E);return await new Promise(M=>setTimeout(M,B)),await ce(e,I(j({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new Jt(_.status,_.statusText,Oe?ie:J);return{data:null,error:I(j({},ie),{status:_.status,statusText:_.statusText})}};p();p();var re=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?re:globalThis),A=new Proxy(re,{get(e,t){return W()[t]??re[t]},has(e,t){let r=W();return t in r||t in re},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)}}),cs=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function b(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 hs=Object.freeze({get BETTER_AUTH_SECRET(){return b("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return b("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return b("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return b("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return b("NODE_ENV","development")},get PACKAGE_VERSION(){return b("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return b("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),z=1,T=4,N=8,R=24,je={eterm:T,cons25:T,console:T,cygwin:T,dtterm:T,gnome:T,hurd:T,jfbterm:T,konsole:T,kterm:T,mlterm:T,mosh:R,putty:T,st:T,"rxvt-unicode-24bit":R,terminator:R,"xterm-kitty":R},dr=new Map(Object.entries({APPVEYOR:N,BUILDKITE:N,CIRCLECI:R,DRONE:N,GITEA_ACTIONS:R,GITHUB_ACTIONS:R,GITLAB_CI:N,TRAVIS:N})),mr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function yr(){if(b("FORCE_COLOR")!==void 0)switch(b("FORCE_COLOR")){case"":case"1":case"true":return T;case"2":return N;case"3":return R;default:return z}if(b("NODE_DISABLE_COLORS")!==void 0&&b("NODE_DISABLE_COLORS")!==""||b("NO_COLOR")!==void 0&&b("NO_COLOR")!==""||b("TERM")==="dumb")return z;if(b("TMUX"))return R;if("TF_BUILD"in A&&"AGENT_NAME"in A)return T;if("CI"in A){for(let{0:e,1:t}of dr)if(e in A)return t;return b("CI_NAME")==="codeship"?N:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(b("TEAMCITY_VERSION"))!==null?T:z;switch(b("TERM_PROGRAM")){case"iTerm.app":return!b("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(b("TERM_PROGRAM_VERSION"))!==null?N:R;case"HyperTerm":case"MacTerm":return R;case"Apple_Terminal":return N}if(b("COLORTERM")==="truecolor"||b("COLORTERM")==="24bit")return R;if(b("TERM")){if(/truecolor/.exec(b("TERM"))!==null)return R;if(/^xterm-256/.exec(b("TERM"))!==null)return N;let e=b("TERM").toLowerCase();if(je[e])return je[e];if(mr.some(t=>t.exec(e)!==null))return T}return b("COLORTERM")?T:z}var x={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"}},he=["info","success","warn","error","debug"];function gr(e,t){return he.indexOf(t)<=he.indexOf(e)}var vr={info:x.fg.blue,success:x.fg.green,warn:x.fg.yellow,error:x.fg.red,debug:x.fg.magenta},wr=(e,t,r)=>{let s=new Date().toISOString();return r?`${x.dim}${s}${x.reset} ${vr[e]}${e.toUpperCase()}${x.reset} ${x.bright}[Better Auth]:${x.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:yr()!==1,n=(o,a,l=[])=>{if(!t||!gr(r,o))return;let u=wr(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(he.map(o=>[o,(...[a,...l])=>n(o,a,l)])),get level(){return r}}},fs=br();p();p();var ve=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function _r(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new ve(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function K(e,t="/api/auth"){if(_r(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function Er(e,t,r,s){if(e)return K(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 K(a,t)}let n=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(n&&o)return K(`${o}://${n}`,t);if(r){let a=Tr(r.url);if(!a)throw new ve("Could not get origin from request. Please provide a valid base URL.");return K(a,t)}if(typeof window<"u"&&window.location)return K(window.location.origin,t)}function Tr(e){try{return new URL(e).origin}catch{return null}}p();p();p();var fe=Symbol("clean"),$=[],C=0,X=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=C+X;o<$.length;)$[o]===s?$.splice(o,X):o+=X;let n=t.indexOf(s);~n&&(t.splice(n,1),--r.lc||r.off())}},notify(s,n){Or++;let o=!$.length;for(let a of t)$.push(a,r.value,s,n);if(o){for(C=0;C<$.length;C+=X)$[C]($[C+1],$[C+2],$[C+3]);$.length=0}},off(){},set(s){let n=r.value;n!==s&&(r.value=s,r.notify(n))},subscribe(s){let n=r.listen(s);return s(r.value),n},value:e};return process.env.NODE_ENV!=="production"&&(r[fe]=()=>{t=[],r.lc=0,r.off()}),r};p();var Pr=5,F=6,Q=10,Sr=(e,t,r,s)=>(e.events=e.events||{},e.events[r+Q]||(e.events[r+Q]=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+Q](),delete e.events[r+Q])}),Rr=1e3,Ar=(e,t)=>Sr(e,r=>{let s=t(r);s&&e.events[F].push(s)},Pr,r=>{let s=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),s(...o));let n=e.off;if(e.events[F]=[],e.off=()=>{n(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[F])o();e.events[F]=[]}},Rr)},process.env.NODE_ENV!=="production"){let o=e[fe];e[fe]=()=>{for(let a of e.events[F])a();e.events[F]=[],e.active=!1,o()}}return()=>{e.listen=s,e.off=n}});p();var $r=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(()=>{$r||(a?o():Ar(n,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{n.off(),l.off(),clearTimeout(u)}}))});return n};p();var Ir={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Nr=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,Ie={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},xr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Ur(e){return e instanceof Date&&!isNaN(e.getTime())}function Cr(e){let t=xr.exec(e);if(!t)return null;let[,r,s,n,o,a,l,u,i,c,h]=t,m=new Date(Date.UTC(parseInt(r,10),parseInt(s,10)-1,parseInt(n,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),u?parseInt(u.padEnd(3,"0"),10):0));if(i){let f=(parseInt(c,10)*60+parseInt(h,10))*(i==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+f)}return Ur(m)?m:null}function Lr(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 Ie)return Ie[l];if(!Nr.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(Ir).some(([u,i])=>{let c=i.test(a);return c&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=Cr(i);if(c)return c}return n?n(u,i):i})}catch(u){if(r)throw u;return e}}function Dr(e,t={strict:!0}){return Lr(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 Br(e){let t=wt(!1);return{session:jr(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var Mr=(e,t)=>{let r="credentials"in Request.prototype,s=Er(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",n=e?.plugins?.flatMap(d=>d.fetchPlugins).filter(d=>d!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:u,onResponse:i,...c}=e?.fetchOptions||{},h=fr({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(d){return d?Dr(d,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[kr],...n]}),{$sessionSignal:m,session:f}=Br(h),y=e?.plugins||[],v={},g={$sessionSignal:m,session:f},w={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},O=[{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(w,d.pathMethods),d.atomListeners&&O.push(...d.atomListeners);let P={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,P,e));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:w,atomListeners:O,$fetch:h,$store:P}};function Fr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Hr(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"||Fr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(O=>O.replace(/[A-Z]/g,P=>`-${P.toLowerCase()}`)).join("/"),h=i[0]||{},m=i[1]||{},{query:f,fetchOptions:y,...v}=h,g={...m,...y},w=Hr(c,r,h);return await t(c,{...g,body:w==="GET"?void 0:{...v,...g?.body||{}},query:f||g?.query,method:w,async onSuccess(O){if(await g?.onSuccess?.(O),!n)return;let P=n.filter(d=>d.matcher(c));if(P.length)for(let d of P){let L=s[d.signal];if(!L)return;let _=L.get();setTimeout(()=>{L.set(!_)},10)}}})}})}return o()}p();function Gr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Wr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:s,$fetch:n,atomListeners:o,$store:a}=Mr(e),l={};for(let[i,c]of Object.entries(s))l[`use${Gr(i)}`]=c;let u={...r,...l,$fetch:n,$store:a};return qr(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 ve("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 bt(e){return{newRole(t){return zr(t)},statements:e}}var Kr={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},we=bt(Kr),ps=we.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ds=we.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ms=we.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var Vr=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}}},ys=new Vr;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"]},_t=bt(Yr),gs=_t.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),vs=_t.newRole({user:[],session:[]});p();p();var Jr=()=>({id:"username",$InferServerPlugin:{}}),Xr=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),Qr=()=>({id:"better-auth-client",$InferServerPlugin:{}}),Zr="/auth",le="nvwa_login_token",se="nvwa_current_jwt",ue="nvwa_user_profile",Et=class{constructor(e,t,r){this.storage=r;let s=Wr({baseURL:e,basePath:Zr,plugins:[Jr(),Xr(),Qr()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let n=await this.storage.get(se);if(console.log("jwt",n),n)return n;let o=await this.storage.get(le);return console.log("loginToken",o),o}}}});this.authClient=s}async currentUser(){return await this.storage.get(ue)}async getCurrentJwt(){return await this.storage.get(se)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(s)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(le,e.data?.token),await this.storage.set(ue,e.data?.user);let{data:t,error:r}=await this.authClient.token();if(r)throw new Error(r.message);await this.storage.set(se,t.token)}async signOut(){await this.storage.remove(le),await this.storage.remove(ue)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(s)}};p();var Tt=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};p();p();p();var U=class Ot{constructor(t){if(this.headerMap=new Map,t){if(t instanceof Ot)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()}},Pt=class St{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof St)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 pe{constructor(t,r){let s;if(t instanceof pe)s=t.href;else if(r){let o=r instanceof pe?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 Pt(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 Rt{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 U?r.headers:new U(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new Rt(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var be=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 U(e):new U}p();var At=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 At}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function ns(e){e.URL=es,e.URLSearchParams=Pt,e.Headers=U,e.Request=ts,e.Response=be,e.AbortController=ss,e.AbortSignal=At}var $t=class{constructor(e,t,r){console.log("NvwaHttpClient constructor",e,t,r),this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(se),s=new U(t?.headers);r&&s.set("Authorization",`Bearer ${r}`);let n=await this.customFetch(e,{...t,headers:s});if(n.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return n}};p();var os="/storage",as=os+"/generateUploadUrl",jt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+as,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:e,headers:new U({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:n}=await s.json();return{url:n.split("?")[0]}}};p();p();p();var Ne=Ht(Gt(),1),{PostgrestClient:is,PostgrestQueryBuilder:ws,PostgrestFilterBuilder:bs,PostgrestTransformBuilder:_s,PostgrestBuilder:Es,PostgrestError:Ts}=Ne.default||Ne,ls="/entities",It=(e,t)=>new is(e+ls,{fetch:t.fetchWithAuth.bind(t)});p();var Nt=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/skill/${e}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:t,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};var ae=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 us=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let s=(t?.method||"GET").toUpperCase(),n={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{n[i]=u});else if(Array.isArray(l))for(let[u,i]of l)n[u]=i;else Object.assign(n,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),o=u}else o=l}let a=t?.timeout||3e4;return new Promise((l,u)=>{let i=t?.signal;if(i?.aborted){let f=new Error("The operation was aborted");f.name="AbortError",u(f);return}let c=!1,h=[],m=uni.request({url:r,method:s,data:o,header:n,timeout:a,success:f=>{if(c)return;c=!0;let y=f.statusCode,v="",g=new U,w=f.header||f.headers||{};Object.keys(w).forEach(O=>{let P=w[O];g.set(O,typeof P=="string"?P:String(P))}),l(new be(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{}})}})},_e=us;var xt=new ae,Ee=class{constructor(t,r){this.auth=new Et(t,_e,xt),this.httpClient=new $t(xt,_e,r),this.fileStorage=new jt(t,this.httpClient),this.entities=It(t,this.httpClient),this.functions=new Tt(this.httpClient),this.skill=new Nt(t,this.httpClient)}};export{Ee as default,xt as localStorage,ns as polyfill};
|