@nvwa-app/sdk-uniapp 6.0.55 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var B=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var Ve=(t,e)=>{for(var r in e)B(t,r,{get:e[r],enumerable:!0})},Ye=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Je(e))!Ke.call(t,a)&&a!==r&&B(t,a,{get:()=>e[a],enumerable:!(s=Ge(e,a))||s.enumerable});return t};var Qe=t=>Ye(B({},"__esModule",{value:!0}),t);var Pt={};Ve(Pt,{default:()=>F,disableIframeHoverInspector:()=>vt,enableIframeHoverInspector:()=>wt,getIframeSourceLocation:()=>bt,localStorage:()=>J,polyfill:()=>He,setupIframeHoverInspector:()=>gt,setupIframeSourceLocationListener:()=>Et,uniappFetch:()=>I});module.exports=Qe(Pt);var Xe=Object.create,M=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,et=Object.getOwnPropertyNames,tt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty,V=(t,e)=>()=>(t&&(e=t(t=0)),e),S=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),st=(t,e)=>{for(var r in e)M(t,r,{get:e[r],enumerable:!0})},Y=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of et(e))!rt.call(t,a)&&a!==r&&M(t,a,{get:()=>e[a],enumerable:!(s=Ze(e,a))||s.enumerable});return t},at=(t,e,r)=>(r=t!=null?Xe(tt(t)):{},Y(e||!t||!t.__esModule?M(r,"default",{value:t,enumerable:!0}):r,t)),L=t=>Y(M({},"__esModule",{value:!0}),t),w=V(()=>{"use strict"}),T={};st(T,{__addDisposableResource:()=>Ee,__assign:()=>N,__asyncDelegator:()=>pe,__asyncGenerator:()=>de,__asyncValues:()=>fe,__await:()=>A,__awaiter:()=>oe,__classPrivateFieldGet:()=>we,__classPrivateFieldIn:()=>be,__classPrivateFieldSet:()=>ve,__createBinding:()=>j,__decorate:()=>Z,__disposeResources:()=>_e,__esDecorate:()=>te,__exportStar:()=>le,__extends:()=>Q,__generator:()=>ie,__importDefault:()=>ge,__importStar:()=>ye,__makeTemplateObject:()=>me,__metadata:()=>ne,__param:()=>ee,__propKey:()=>se,__read:()=>W,__rest:()=>X,__rewriteRelativeImportExtension:()=>Pe,__runInitializers:()=>re,__setFunctionName:()=>ae,__spread:()=>ue,__spreadArray:()=>he,__spreadArrays:()=>ce,__values:()=>U,default:()=>Te});function Q(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");k(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function X(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(t);a<s.length;a++)e.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(t,s[a])&&(r[s[a]]=t[s[a]]);return r}function Z(t,e,r,s){var a=arguments.length,n=a<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,s);else for(var i=t.length-1;i>=0;i--)(o=t[i])&&(n=(a<3?o(n):a>3?o(e,r,n):o(e,r))||n);return a>3&&n&&Object.defineProperty(e,r,n),n}function ee(t,e){return function(r,s){e(r,s,t)}}function te(t,e,r,s,a,n){function o(g){if(g!==void 0&&typeof g!="function")throw new TypeError("Function expected");return g}for(var i=s.kind,c=i==="getter"?"get":i==="setter"?"set":"value",l=!e&&t?s.static?t:t.prototype:null,u=e||(l?Object.getOwnPropertyDescriptor(l,s.name):{}),h,f=!1,d=r.length-1;d>=0;d--){var p={};for(var m in s)p[m]=m==="access"?{}:s[m];for(var m in s.access)p.access[m]=s.access[m];p.addInitializer=function(g){if(f)throw new TypeError("Cannot add initializers after decoration has completed");n.push(o(g||null))};var y=(0,r[d])(i==="accessor"?{get:u.get,set:u.set}:u[c],p);if(i==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(h=o(y.get))&&(u.get=h),(h=o(y.set))&&(u.set=h),(h=o(y.init))&&a.unshift(h)}else(h=o(y))&&(i==="field"?a.unshift(h):u[c]=h)}l&&Object.defineProperty(l,s.name,u),f=!0}function re(t,e,r){for(var s=arguments.length>2,a=0;a<e.length;a++)r=s?e[a].call(t,r):e[a].call(t);return s?r:void 0}function se(t){return typeof t=="symbol"?t:"".concat(t)}function ae(t,e,r){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function ne(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function oe(t,e,r,s){function a(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function i(u){try{l(s.next(u))}catch(h){o(h)}}function c(u){try{l(s.throw(u))}catch(h){o(h)}}function l(u){u.done?n(u.value):a(u.value).then(i,c)}l((s=s.apply(t,e||[])).next())})}function ie(t,e){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},s,a,n,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=i(0),o.throw=i(1),o.return=i(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function i(l){return function(u){return c([l,u])}}function c(l){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(r=0)),r;)try{if(s=1,a&&(n=l[0]&2?a.return:l[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,l[1])).done)return n;switch(a=0,n&&(l=[l[0]&2,n.value]),l[0]){case 0:case 1:n=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,a=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]<n[3])){r.label=l[1];break}if(l[0]===6&&r.label<n[1]){r.label=n[1],n=l;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(l);break}n[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(u){l=[6,u],a=0}finally{s=n=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function le(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&j(e,t,r)}function U(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],s=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function W(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var s=r.call(t),a,n=[],o;try{for(;(e===void 0||e-- >0)&&!(a=s.next()).done;)n.push(a.value)}catch(i){o={error:i}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return n}function ue(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(W(arguments[e]));return t}function ce(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var s=Array(t),a=0,e=0;e<r;e++)for(var n=arguments[e],o=0,i=n.length;o<i;o++,a++)s[a]=n[o];return s}function he(t,e,r){if(r||arguments.length===2)for(var s=0,a=e.length,n;s<a;s++)(n||!(s in e))&&(n||(n=Array.prototype.slice.call(e,0,s)),n[s]=e[s]);return t.concat(n||Array.prototype.slice.call(e))}function A(t){return this instanceof A?(this.v=t,this):new A(t)}function de(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(t,e||[]),a,n=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",o),a[Symbol.asyncIterator]=function(){return this},a;function o(d){return function(p){return Promise.resolve(p).then(d,h)}}function i(d,p){s[d]&&(a[d]=function(m){return new Promise(function(y,g){n.push([d,m,y,g])>1||c(d,m)})},p&&(a[d]=p(a[d])))}function c(d,p){try{l(s[d](p))}catch(m){f(n[0][3],m)}}function l(d){d.value instanceof A?Promise.resolve(d.value.v).then(u,h):f(n[0][2],d)}function u(d){c("next",d)}function h(d){c("throw",d)}function f(d,p){d(p),n.shift(),n.length&&c(n[0][0],n[0][1])}}function pe(t){var e,r;return e={},s("next"),s("throw",function(a){throw a}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(a,n){e[a]=t[a]?function(o){return(r=!r)?{value:A(t[a](o)),done:!1}:n?n(o):o}:n}}function fe(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof U=="function"?U(t):t[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(n){r[n]=t[n]&&function(o){return new Promise(function(i,c){o=t[n](o),a(i,c,o.done,o.value)})}}function a(n,o,i,c){Promise.resolve(c).then(function(l){n({value:l,done:i})},o)}}function me(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function ye(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=R(t),s=0;s<r.length;s++)r[s]!=="default"&&j(e,t,r[s]);return Oe(e,t),e}function ge(t){return t&&t.__esModule?t:{default:t}}function we(t,e,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(t):s?s.value:e.get(t)}function ve(t,e,r,s,a){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?a.call(t,r):a?a.value=r:e.set(t,r),r}function be(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function Ee(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var s,a;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=e[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose],r&&(a=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");a&&(s=function(){try{a.call(this)}catch(n){return Promise.reject(n)}}),t.stack.push({value:e,dispose:s,async:r})}else r&&t.stack.push({async:!0});return e}function _e(t){function e(n){t.error=t.hasError?new Se(n,t.error,"An error was suppressed during disposal."):n,t.hasError=!0}var r,s=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&s===1)return s=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var n=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(n).then(a,function(o){return e(o),a()})}else s|=1}catch(o){e(o)}if(s===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}function Pe(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,a,n,o){return s?e?".jsx":".js":a&&(!n||!o)?r:a+n+"."+o.toLowerCase()+"js"}):t}var k,N,j,Oe,R,Se,Te,C=V(()=>{"use strict";w(),k=function(t,e){return k=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(r[a]=s[a])},k(t,e)},N=function(){return N=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},N.apply(this,arguments)},j=Object.create?(function(t,e,r,s){s===void 0&&(s=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,a)}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]}),Oe=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},R=function(t){return R=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},R(t)},Se=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Te={__extends:Q,__assign:N,__rest:X,__decorate:Z,__param:ee,__esDecorate:te,__runInitializers:re,__propKey:se,__setFunctionName:ae,__metadata:ne,__awaiter:oe,__generator:ie,__createBinding:j,__exportStar:le,__values:U,__read:W,__spread:ue,__spreadArrays:ce,__spreadArray:he,__await:A,__asyncGenerator:de,__asyncDelegator:pe,__asyncValues:fe,__makeTemplateObject:me,__importStar:ye,__importDefault:ge,__classPrivateFieldGet:we,__classPrivateFieldSet:ve,__classPrivateFieldIn:be,__addDisposableResource:Ee,__disposeResources:_e,__rewriteRelativeImportExtension:Pe}}),$e=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};t.default=e}),Ae=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),L(T)),r=e.__importDefault($e()),s=class{constructor(a){var n,o;this.shouldThrowOnError=!1,this.method=a.method,this.url=a.url,this.headers=new Headers(a.headers),this.schema=a.schema,this.body=a.body,this.shouldThrowOnError=(n=a.shouldThrowOnError)!==null&&n!==void 0?n:!1,this.signal=a.signal,this.isMaybeSingle=(o=a.isMaybeSingle)!==null&&o!==void 0?o:!1,a.fetch?this.fetch=a.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(a,n){return this.headers=new Headers(this.headers),this.headers.set(a,n),this}then(a,n){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 o=this.fetch,i=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var l,u,h,f;let d=null,p=null,m=null,y=c.status,g=c.statusText;if(c.ok){if(this.method!=="HEAD"){let D=await c.text();D===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((l=this.headers.get("Accept"))===null||l===void 0)&&l.includes("application/vnd.pgrst.plan+text")?p=D:p=JSON.parse(D))}let P=(u=this.headers.get("Prefer"))===null||u===void 0?void 0:u.match(/count=(exact|planned|estimated)/),O=(h=c.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");P&&O&&O.length>1&&(m=parseInt(O[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(d={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,m=null,y=406,g="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let P=await c.text();try{d=JSON.parse(P),Array.isArray(d)&&c.status===404&&(p=[],d=null,y=200,g="OK")}catch{c.status===404&&P===""?(y=204,g="No Content"):d={message:P}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,y=200,g="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:m,status:y,statusText:g}});return this.shouldThrowOnError||(i=i.catch(c=>{var l,u,h;return{error:{message:`${(l=c?.name)!==null&&l!==void 0?l:"FetchError"}: ${c?.message}`,details:`${(u=c?.stack)!==null&&u!==void 0?u:""}`,hint:"",code:`${(h=c?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),i.then(a,n)}returns(){return this}overrideTypes(){return this}};t.default=s}),xe=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),L(T)),r=e.__importDefault(Ae()),s=class extends r.default{select(a){let n=!1,o=(a??"*").split("").map(i=>/\s/.test(i)&&!n?"":(i==='"'&&(n=!n),i)).join("");return this.url.searchParams.set("select",o),this.headers.append("Prefer","return=representation"),this}order(a,{ascending:n=!0,nullsFirst:o,foreignTable:i,referencedTable:c=i}={}){let l=c?`${c}.order`:"order",u=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${u?`${u},`:""}${a}.${n?"asc":"desc"}${o===void 0?"":o?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:n,referencedTable:o=n}={}){let i=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(i,`${a}`),this}range(a,n,{foreignTable:o,referencedTable:i=o}={}){let c=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(c,`${a}`),this.url.searchParams.set(l,`${n-a+1}`),this}abortSignal(a){return this.signal=a,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:a=!1,verbose:n=!1,settings:o=!1,buffers:i=!1,wal:c=!1,format:l="text"}={}){var u;let h=[a?"analyze":null,n?"verbose":null,o?"settings":null,i?"buffers":null,c?"wal":null].filter(Boolean).join("|"),f=(u=this.headers.get("Accept"))!==null&&u!==void 0?u:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${l}; for="${f}"; options=${h};`),l==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(a){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${a}`),this}};t.default=s}),z=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),L(T)),r=e.__importDefault(xe()),s=new RegExp("[,()]"),a=class extends r.default{eq(n,o){return this.url.searchParams.append(n,`eq.${o}`),this}neq(n,o){return this.url.searchParams.append(n,`neq.${o}`),this}gt(n,o){return this.url.searchParams.append(n,`gt.${o}`),this}gte(n,o){return this.url.searchParams.append(n,`gte.${o}`),this}lt(n,o){return this.url.searchParams.append(n,`lt.${o}`),this}lte(n,o){return this.url.searchParams.append(n,`lte.${o}`),this}like(n,o){return this.url.searchParams.append(n,`like.${o}`),this}likeAllOf(n,o){return this.url.searchParams.append(n,`like(all).{${o.join(",")}}`),this}likeAnyOf(n,o){return this.url.searchParams.append(n,`like(any).{${o.join(",")}}`),this}ilike(n,o){return this.url.searchParams.append(n,`ilike.${o}`),this}ilikeAllOf(n,o){return this.url.searchParams.append(n,`ilike(all).{${o.join(",")}}`),this}ilikeAnyOf(n,o){return this.url.searchParams.append(n,`ilike(any).{${o.join(",")}}`),this}is(n,o){return this.url.searchParams.append(n,`is.${o}`),this}in(n,o){let i=Array.from(new Set(o)).map(c=>typeof c=="string"&&s.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(n,`in.(${i})`),this}contains(n,o){return typeof o=="string"?this.url.searchParams.append(n,`cs.${o}`):Array.isArray(o)?this.url.searchParams.append(n,`cs.{${o.join(",")}}`):this.url.searchParams.append(n,`cs.${JSON.stringify(o)}`),this}containedBy(n,o){return typeof o=="string"?this.url.searchParams.append(n,`cd.${o}`):Array.isArray(o)?this.url.searchParams.append(n,`cd.{${o.join(",")}}`):this.url.searchParams.append(n,`cd.${JSON.stringify(o)}`),this}rangeGt(n,o){return this.url.searchParams.append(n,`sr.${o}`),this}rangeGte(n,o){return this.url.searchParams.append(n,`nxl.${o}`),this}rangeLt(n,o){return this.url.searchParams.append(n,`sl.${o}`),this}rangeLte(n,o){return this.url.searchParams.append(n,`nxr.${o}`),this}rangeAdjacent(n,o){return this.url.searchParams.append(n,`adj.${o}`),this}overlaps(n,o){return typeof o=="string"?this.url.searchParams.append(n,`ov.${o}`):this.url.searchParams.append(n,`ov.{${o.join(",")}}`),this}textSearch(n,o,{config:i,type:c}={}){let l="";c==="plain"?l="pl":c==="phrase"?l="ph":c==="websearch"&&(l="w");let u=i===void 0?"":`(${i})`;return this.url.searchParams.append(n,`${l}fts${u}.${o}`),this}match(n){return Object.entries(n).forEach(([o,i])=>{this.url.searchParams.append(o,`eq.${i}`)}),this}not(n,o,i){return this.url.searchParams.append(n,`not.${o}.${i}`),this}or(n,{foreignTable:o,referencedTable:i=o}={}){let c=i?`${i}.or`:"or";return this.url.searchParams.append(c,`(${n})`),this}filter(n,o,i){return this.url.searchParams.append(n,`${o}.${i}`),this}};t.default=a}),Le=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),L(T)),r=e.__importDefault(z()),s=class{constructor(a,{headers:n={},schema:o,fetch:i}){this.url=a,this.headers=new Headers(n),this.schema=o,this.fetch=i}select(a,n){let{head:o=!1,count:i}=n??{},c=o?"HEAD":"GET",l=!1,u=(a??"*").split("").map(h=>/\s/.test(h)&&!l?"":(h==='"'&&(l=!l),h)).join("");return this.url.searchParams.set("select",u),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:n,defaultToNull:o=!0}={}){var i;let c="POST";if(n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let l=a.reduce((u,h)=>u.concat(Object.keys(h)),[]);if(l.length>0){let u=[...new Set(l)].map(h=>`"${h}"`);this.url.searchParams.set("columns",u.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}upsert(a,{onConflict:n,ignoreDuplicates:o=!1,count:i,defaultToNull:c=!0}={}){var l;let u="POST";if(this.headers.append("Prefer",`resolution=${o?"ignore":"merge"}-duplicates`),n!==void 0&&this.url.searchParams.set("on_conflict",n),i&&this.headers.append("Prefer",`count=${i}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let h=a.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(h.length>0){let f=[...new Set(h)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}update(a,{count:n}={}){var o;let i="PATCH";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}delete({count:a}={}){var n;let o="DELETE";return a&&this.headers.append("Prefer",`count=${a}`),new r.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}};t.default=s}),nt=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),L(T)),r=e.__importDefault(Le()),s=e.__importDefault(z()),a=class Ce{constructor(o,{headers:i={},schema:c,fetch:l}={}){this.url=o,this.headers=new Headers(i),this.schemaName=c,this.fetch=l}from(o){let i=new URL(`${this.url}/${o}`);return new r.default(i,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new Ce(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,i={},{head:c=!1,get:l=!1,count:u}={}){var h;let f,d=new URL(`${this.url}/rpc/${o}`),p;c||l?(f=c?"HEAD":"GET",Object.entries(i).filter(([y,g])=>g!==void 0).map(([y,g])=>[y,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([y,g])=>{d.searchParams.append(y,g)})):(f="POST",p=i);let m=new Headers(this.headers);return u&&m.set("Prefer",`count=${u}`),new s.default({method:f,url:d,headers:m,schema:this.schemaName,body:p,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};t.default=a}),ot=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;var e=(C(),L(T)),r=e.__importDefault(nt());t.PostgrestClient=r.default;var s=e.__importDefault(Le());t.PostgrestQueryBuilder=s.default;var a=e.__importDefault(z());t.PostgrestFilterBuilder=a.default;var n=e.__importDefault(xe());t.PostgrestTransformBuilder=n.default;var o=e.__importDefault(Ae());t.PostgrestBuilder=o.default;var i=e.__importDefault($e());t.PostgrestError=i.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:a.default,PostgrestTransformBuilder:n.default,PostgrestBuilder:o.default,PostgrestError:i.default}});w();w();var Ie=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};w();w();var v="nvwa_current_jwt",E="nvwa_login_token",$="nvwa_user_profile",it="set-auth-token",lt=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},Ne=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??lt,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get($);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set($,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(v);if(e!=null)return e;let r=await this.storage.get(E),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(v,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let r=e?.headers.get(it)?.trim()||t.token||t.session?.token;r&&await this.storage.set(E,r),t.user&&await this.storage.set($,t.user);let s=r??await this.storage.get(E),{data:a}=await this.getToken(s??void 0);a?.token&&await this.storage.set(v,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(E),await this.storage.remove($),await this.storage.remove(v))}url(t){let e=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",e),!e.startsWith("http://")&&!e.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),e}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(E)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:t,password:e})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):void 0;return a&&await this.persistLogin({user:a.user,session:a.session},r),{data:a}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(E)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data,e.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let n=await this.storage.get(E)??await this.storage.get(v);n!=null&&(e.Authorization=`Bearer ${n}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):void 0;return{data:a?.token!=null?{token:a.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data,r.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.token||!n.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(v,n.token),await this.storage.set(E,n.token),await this.storage.set($,n.user)),{data:n})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async loginWithAlipayCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("alipay/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.token||!n.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(v,n.token),await this.storage.set(E,n.token),await this.storage.set($,n.user)),{data:n})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`wechat/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.openid||!n.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:n}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`alipay/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.openid||!n.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:n}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):void 0;return{data:a?.data??a??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};w();w();var _=class je{constructor(e){if(this.headerMap=new Map,e){if(e instanceof je)e.forEach((r,s)=>this.set(s,r));else if(Array.isArray(e))for(let[r,s]of e)this.set(r,String(s));else if(typeof e=="object")for(let r of Object.keys(e))this.set(r,String(e[r]))}}append(e,r){let s=e.toLowerCase(),a=this.headerMap.get(s);this.headerMap.set(s,a?`${a}, ${r}`:r)}set(e,r){this.headerMap.set(e.toLowerCase(),String(r))}get(e){return this.headerMap.get(e.toLowerCase())??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[r,s]of this.headerMap.entries())e(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},ke=class Re{constructor(e){if(this.params=new Map,e){if(typeof e=="string")this.parseString(e);else if(e instanceof Re)this.params=new Map(e.params);else if(Array.isArray(e))for(let[r,s]of e)this.append(r,s);else if(e&&typeof e=="object")for(let[r,s]of Object.entries(e))this.set(r,s)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let r=e.split("&");for(let s of r)if(s){let[a,n]=s.split("=");a&&this.append(decodeURIComponent(a),n?decodeURIComponent(n):"")}}append(e,r){let s=this.params.get(e)||[];s.push(r),this.params.set(e,s)}delete(e){this.params.delete(e)}get(e){let r=this.params.get(e);return r?r[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,r){this.params.set(e,[r])}sort(){let e=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(e)}toString(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push(`${encodeURIComponent(r)}=${encodeURIComponent(a)}`);return e.join("&")}forEach(e){for(let[r,s]of this.params.entries())for(let a of s)e(a,r,this)}keys(){return this.params.keys()}values(){let e=[];for(let r of this.params.values())e.push(...r);return e[Symbol.iterator]()}entries(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push([r,a]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},ut=class q{constructor(e,r){let s;if(e instanceof q)s=e.href;else if(r){let n=r instanceof q?r.href:r;s=this.resolve(n,e)}else s=e;let a=this.parseUrl(s);this.href=s,this.origin=`${a.protocol}//${a.host}`,this.protocol=a.protocol,this.username=a.username,this.password=a.password,this.host=a.host,this.hostname=a.hostname,this.port=a.port,this.pathname=a.pathname,this.search=a.search,this.searchParams=new ke(a.search),this.hash=a.hash}resolve(e,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(e).protocol}${r}`;if(r.startsWith("/")){let n=this.parseUrl(e);return`${n.protocol}//${n.host}${r}`}let s=this.parseUrl(e),a=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${a}${r}`}parseUrl(e){let r=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",a=r[4]||"",n=r[5]||"/",o=r[7]?`?${r[7]}`:"",i=r[9]?`#${r[9]}`:"";if(!s&&!a&&!n.startsWith("/")&&!n.includes("/")&&!n.includes("."))throw new TypeError("Invalid URL");let c=a.match(/^([^@]*)@(.+)$/),l="",u="",h=a;if(c){let m=c[1];h=c[2];let y=m.match(/^([^:]*):?(.*)$/);y&&(l=y[1]||"",u=y[2]||"")}let f=h.match(/^([^:]+):?(\d*)$/),d=f?f[1]:h,p=f&&f[2]?f[2]:"";return{protocol:s?`${s}:`:"",username:l,password:u,host:h,hostname:d,port:p,pathname:n,search:o,hash:i}}toString(){let e=this.searchParams.toString(),r=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};w();var ct=class Ue{constructor(e,r){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof _?r.headers:new _(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new Ue(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};w();var G=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=ht(e?.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 t=await this.text();return new TextEncoder().encode(t).buffer}};function ht(t){return t?new _(t):new _}w();var Me=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 t of Array.from(this.listeners))try{t()}catch{}this.listeners.clear()}}addEventListener(t,e){if(this._aborted){try{e()}catch{}return}this.listeners.add(e)}removeEventListener(t,e){this.listeners.delete(e)}toString(){return"[object AbortSignal]"}},dt=class{constructor(){this._signal=new Me}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};w();function He(t){t.URL=ut,t.URLSearchParams=ke,t.Headers=_,t.Request=ct,t.Response=G,t.AbortController=dt,t.AbortSignal=Me}var Fe=class{constructor(t,e,r){this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(v),s=new _(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let a=e?.method||"GET";if((a==="POST"||a==="PUT"||a==="PATCH")&&e?.body){let o=s.get("Content-Type");(!o||o.includes("text/plain"))&&s.set("Content-Type","application/json")}let n=await this.customFetch(t,{...e,headers:s});if(n.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return n}};w();var pt="/storage",ft=pt+"/generateUploadUrl",De=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+ft,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new _({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:a}=await s.json();return{url:a.split("?")[0]}}};w();w();w();var K=at(ot(),1),{PostgrestClient:mt,PostgrestQueryBuilder:St,PostgrestFilterBuilder:Tt,PostgrestTransformBuilder:$t,PostgrestBuilder:At,PostgrestError:xt}=K.default||K,yt="/entities",Be=(t,e)=>new mt(t+yt,{fetch:e.fetchWithAuth.bind(e)});w();var qe=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
1
+ "use strict";var q=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var Ye=(t,e)=>{for(var r in e)q(t,r,{get:e[r],enumerable:!0})},Xe=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ve(e))!Qe.call(t,a)&&a!==r&&q(t,a,{get:()=>e[a],enumerable:!(s=Ke(e,a))||s.enumerable});return t};var Ze=t=>Xe(q({},"__esModule",{value:!0}),t);var It={};Ye(It,{default:()=>F,disableIframeHoverInspector:()=>At,enableIframeHoverInspector:()=>$t,getIframeSourceLocation:()=>xt,localStorage:()=>J,polyfill:()=>He,setupIframeHoverInspector:()=>Tt,setupIframeSourceLocationListener:()=>Ct,uniappFetch:()=>I});module.exports=Ze(It);var et=Object.create,M=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,rt=Object.getOwnPropertyNames,st=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty,V=(t,e)=>()=>(t&&(e=t(t=0)),e),S=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),nt=(t,e)=>{for(var r in e)M(t,r,{get:e[r],enumerable:!0})},Q=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of rt(e))!at.call(t,a)&&a!==r&&M(t,a,{get:()=>e[a],enumerable:!(s=tt(e,a))||s.enumerable});return t},ot=(t,e,r)=>(r=t!=null?et(st(t)):{},Q(e||!t||!t.__esModule?M(r,"default",{value:t,enumerable:!0}):r,t)),C=t=>Q(M({},"__esModule",{value:!0}),t),w=V(()=>{"use strict"}),T={};nt(T,{__addDisposableResource:()=>_e,__assign:()=>N,__asyncDelegator:()=>pe,__asyncGenerator:()=>de,__asyncValues:()=>fe,__await:()=>A,__awaiter:()=>oe,__classPrivateFieldGet:()=>we,__classPrivateFieldIn:()=>be,__classPrivateFieldSet:()=>ve,__createBinding:()=>j,__decorate:()=>Z,__disposeResources:()=>Ee,__esDecorate:()=>te,__exportStar:()=>le,__extends:()=>Y,__generator:()=>ie,__importDefault:()=>ge,__importStar:()=>ye,__makeTemplateObject:()=>me,__metadata:()=>ne,__param:()=>ee,__propKey:()=>se,__read:()=>W,__rest:()=>X,__rewriteRelativeImportExtension:()=>Pe,__runInitializers:()=>re,__setFunctionName:()=>ae,__spread:()=>ce,__spreadArray:()=>he,__spreadArrays:()=>ue,__values:()=>R,default:()=>Te});function Y(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");k(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function X(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(t);a<s.length;a++)e.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(t,s[a])&&(r[s[a]]=t[s[a]]);return r}function Z(t,e,r,s){var a=arguments.length,n=a<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,s);else for(var l=t.length-1;l>=0;l--)(o=t[l])&&(n=(a<3?o(n):a>3?o(e,r,n):o(e,r))||n);return a>3&&n&&Object.defineProperty(e,r,n),n}function ee(t,e){return function(r,s){e(r,s,t)}}function te(t,e,r,s,a,n){function o(g){if(g!==void 0&&typeof g!="function")throw new TypeError("Function expected");return g}for(var l=s.kind,u=l==="getter"?"get":l==="setter"?"set":"value",i=!e&&t?s.static?t:t.prototype:null,c=e||(i?Object.getOwnPropertyDescriptor(i,s.name):{}),h,f=!1,d=r.length-1;d>=0;d--){var p={};for(var m in s)p[m]=m==="access"?{}:s[m];for(var m in s.access)p.access[m]=s.access[m];p.addInitializer=function(g){if(f)throw new TypeError("Cannot add initializers after decoration has completed");n.push(o(g||null))};var y=(0,r[d])(l==="accessor"?{get:c.get,set:c.set}:c[u],p);if(l==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(h=o(y.get))&&(c.get=h),(h=o(y.set))&&(c.set=h),(h=o(y.init))&&a.unshift(h)}else(h=o(y))&&(l==="field"?a.unshift(h):c[u]=h)}i&&Object.defineProperty(i,s.name,c),f=!0}function re(t,e,r){for(var s=arguments.length>2,a=0;a<e.length;a++)r=s?e[a].call(t,r):e[a].call(t);return s?r:void 0}function se(t){return typeof t=="symbol"?t:"".concat(t)}function ae(t,e,r){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function ne(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function oe(t,e,r,s){function a(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function l(c){try{i(s.next(c))}catch(h){o(h)}}function u(c){try{i(s.throw(c))}catch(h){o(h)}}function i(c){c.done?n(c.value):a(c.value).then(l,u)}i((s=s.apply(t,e||[])).next())})}function ie(t,e){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},s,a,n,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=l(0),o.throw=l(1),o.return=l(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(i){return function(c){return u([i,c])}}function u(i){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(r=0)),r;)try{if(s=1,a&&(n=i[0]&2?a.return:i[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,i[1])).done)return n;switch(a=0,n&&(i=[i[0]&2,n.value]),i[0]){case 0:case 1:n=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,a=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!n||i[1]>n[0]&&i[1]<n[3])){r.label=i[1];break}if(i[0]===6&&r.label<n[1]){r.label=n[1],n=i;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(i);break}n[2]&&r.ops.pop(),r.trys.pop();continue}i=e.call(t,r)}catch(c){i=[6,c],a=0}finally{s=n=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function le(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&j(e,t,r)}function R(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],s=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function W(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var s=r.call(t),a,n=[],o;try{for(;(e===void 0||e-- >0)&&!(a=s.next()).done;)n.push(a.value)}catch(l){o={error:l}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return n}function ce(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(W(arguments[e]));return t}function ue(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var s=Array(t),a=0,e=0;e<r;e++)for(var n=arguments[e],o=0,l=n.length;o<l;o++,a++)s[a]=n[o];return s}function he(t,e,r){if(r||arguments.length===2)for(var s=0,a=e.length,n;s<a;s++)(n||!(s in e))&&(n||(n=Array.prototype.slice.call(e,0,s)),n[s]=e[s]);return t.concat(n||Array.prototype.slice.call(e))}function A(t){return this instanceof A?(this.v=t,this):new A(t)}function de(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(t,e||[]),a,n=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",o),a[Symbol.asyncIterator]=function(){return this},a;function o(d){return function(p){return Promise.resolve(p).then(d,h)}}function l(d,p){s[d]&&(a[d]=function(m){return new Promise(function(y,g){n.push([d,m,y,g])>1||u(d,m)})},p&&(a[d]=p(a[d])))}function u(d,p){try{i(s[d](p))}catch(m){f(n[0][3],m)}}function i(d){d.value instanceof A?Promise.resolve(d.value.v).then(c,h):f(n[0][2],d)}function c(d){u("next",d)}function h(d){u("throw",d)}function f(d,p){d(p),n.shift(),n.length&&u(n[0][0],n[0][1])}}function pe(t){var e,r;return e={},s("next"),s("throw",function(a){throw a}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(a,n){e[a]=t[a]?function(o){return(r=!r)?{value:A(t[a](o)),done:!1}:n?n(o):o}:n}}function fe(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof R=="function"?R(t):t[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(n){r[n]=t[n]&&function(o){return new Promise(function(l,u){o=t[n](o),a(l,u,o.done,o.value)})}}function a(n,o,l,u){Promise.resolve(u).then(function(i){n({value:i,done:l})},o)}}function me(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function ye(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=U(t),s=0;s<r.length;s++)r[s]!=="default"&&j(e,t,r[s]);return Oe(e,t),e}function ge(t){return t&&t.__esModule?t:{default:t}}function we(t,e,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(t):s?s.value:e.get(t)}function ve(t,e,r,s,a){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?a.call(t,r):a?a.value=r:e.set(t,r),r}function be(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function _e(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var s,a;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=e[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose],r&&(a=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");a&&(s=function(){try{a.call(this)}catch(n){return Promise.reject(n)}}),t.stack.push({value:e,dispose:s,async:r})}else r&&t.stack.push({async:!0});return e}function Ee(t){function e(n){t.error=t.hasError?new Se(n,t.error,"An error was suppressed during disposal."):n,t.hasError=!0}var r,s=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&s===1)return s=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var n=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(n).then(a,function(o){return e(o),a()})}else s|=1}catch(o){e(o)}if(s===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}function Pe(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,a,n,o){return s?e?".jsx":".js":a&&(!n||!o)?r:a+n+"."+o.toLowerCase()+"js"}):t}var k,N,j,Oe,U,Se,Te,L=V(()=>{"use strict";w(),k=function(t,e){return k=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(r[a]=s[a])},k(t,e)},N=function(){return N=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},N.apply(this,arguments)},j=Object.create?(function(t,e,r,s){s===void 0&&(s=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,a)}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]}),Oe=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},U=function(t){return U=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},U(t)},Se=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Te={__extends:Y,__assign:N,__rest:X,__decorate:Z,__param:ee,__esDecorate:te,__runInitializers:re,__propKey:se,__setFunctionName:ae,__metadata:ne,__awaiter:oe,__generator:ie,__createBinding:j,__exportStar:le,__values:R,__read:W,__spread:ce,__spreadArrays:ue,__spreadArray:he,__await:A,__asyncGenerator:de,__asyncDelegator:pe,__asyncValues:fe,__makeTemplateObject:me,__importStar:ye,__importDefault:ge,__classPrivateFieldGet:we,__classPrivateFieldSet:ve,__classPrivateFieldIn:be,__addDisposableResource:_e,__disposeResources:Ee,__rewriteRelativeImportExtension:Pe}}),$e=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};t.default=e}),Ae=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(L(),C(T)),r=e.__importDefault($e()),s=class{constructor(a){var n,o;this.shouldThrowOnError=!1,this.method=a.method,this.url=a.url,this.headers=new Headers(a.headers),this.schema=a.schema,this.body=a.body,this.shouldThrowOnError=(n=a.shouldThrowOnError)!==null&&n!==void 0?n:!1,this.signal=a.signal,this.isMaybeSingle=(o=a.isMaybeSingle)!==null&&o!==void 0?o:!1,a.fetch?this.fetch=a.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(a,n){return this.headers=new Headers(this.headers),this.headers.set(a,n),this}then(a,n){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 o=this.fetch,l=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var i,c,h,f;let d=null,p=null,m=null,y=u.status,g=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")?p=D:p=JSON.parse(D))}let P=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),O=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");P&&O&&O.length>1&&(m=parseInt(O[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(d={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,m=null,y=406,g="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let P=await u.text();try{d=JSON.parse(P),Array.isArray(d)&&u.status===404&&(p=[],d=null,y=200,g="OK")}catch{u.status===404&&P===""?(y=204,g="No Content"):d={message:P}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,y=200,g="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:m,status:y,statusText:g}});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(a,n)}returns(){return this}overrideTypes(){return this}};t.default=s}),xe=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(L(),C(T)),r=e.__importDefault(Ae()),s=class extends r.default{select(a){let n=!1,o=(a??"*").split("").map(l=>/\s/.test(l)&&!n?"":(l==='"'&&(n=!n),l)).join("");return this.url.searchParams.set("select",o),this.headers.append("Prefer","return=representation"),this}order(a,{ascending:n=!0,nullsFirst:o,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},`:""}${a}.${n?"asc":"desc"}${o===void 0?"":o?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:n,referencedTable:o=n}={}){let l=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(l,`${a}`),this}range(a,n,{foreignTable:o,referencedTable:l=o}={}){let u=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(u,`${a}`),this.url.searchParams.set(i,`${n-a+1}`),this}abortSignal(a){return this.signal=a,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:a=!1,verbose:n=!1,settings:o=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[a?"analyze":null,n?"verbose":null,o?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),f=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${f}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(a){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${a}`),this}};t.default=s}),z=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(L(),C(T)),r=e.__importDefault(xe()),s=new RegExp("[,()]"),a=class extends r.default{eq(n,o){return this.url.searchParams.append(n,`eq.${o}`),this}neq(n,o){return this.url.searchParams.append(n,`neq.${o}`),this}gt(n,o){return this.url.searchParams.append(n,`gt.${o}`),this}gte(n,o){return this.url.searchParams.append(n,`gte.${o}`),this}lt(n,o){return this.url.searchParams.append(n,`lt.${o}`),this}lte(n,o){return this.url.searchParams.append(n,`lte.${o}`),this}like(n,o){return this.url.searchParams.append(n,`like.${o}`),this}likeAllOf(n,o){return this.url.searchParams.append(n,`like(all).{${o.join(",")}}`),this}likeAnyOf(n,o){return this.url.searchParams.append(n,`like(any).{${o.join(",")}}`),this}ilike(n,o){return this.url.searchParams.append(n,`ilike.${o}`),this}ilikeAllOf(n,o){return this.url.searchParams.append(n,`ilike(all).{${o.join(",")}}`),this}ilikeAnyOf(n,o){return this.url.searchParams.append(n,`ilike(any).{${o.join(",")}}`),this}is(n,o){return this.url.searchParams.append(n,`is.${o}`),this}in(n,o){let l=Array.from(new Set(o)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(n,`in.(${l})`),this}contains(n,o){return typeof o=="string"?this.url.searchParams.append(n,`cs.${o}`):Array.isArray(o)?this.url.searchParams.append(n,`cs.{${o.join(",")}}`):this.url.searchParams.append(n,`cs.${JSON.stringify(o)}`),this}containedBy(n,o){return typeof o=="string"?this.url.searchParams.append(n,`cd.${o}`):Array.isArray(o)?this.url.searchParams.append(n,`cd.{${o.join(",")}}`):this.url.searchParams.append(n,`cd.${JSON.stringify(o)}`),this}rangeGt(n,o){return this.url.searchParams.append(n,`sr.${o}`),this}rangeGte(n,o){return this.url.searchParams.append(n,`nxl.${o}`),this}rangeLt(n,o){return this.url.searchParams.append(n,`sl.${o}`),this}rangeLte(n,o){return this.url.searchParams.append(n,`nxr.${o}`),this}rangeAdjacent(n,o){return this.url.searchParams.append(n,`adj.${o}`),this}overlaps(n,o){return typeof o=="string"?this.url.searchParams.append(n,`ov.${o}`):this.url.searchParams.append(n,`ov.{${o.join(",")}}`),this}textSearch(n,o,{config:l,type:u}={}){let i="";u==="plain"?i="pl":u==="phrase"?i="ph":u==="websearch"&&(i="w");let c=l===void 0?"":`(${l})`;return this.url.searchParams.append(n,`${i}fts${c}.${o}`),this}match(n){return Object.entries(n).forEach(([o,l])=>{this.url.searchParams.append(o,`eq.${l}`)}),this}not(n,o,l){return this.url.searchParams.append(n,`not.${o}.${l}`),this}or(n,{foreignTable:o,referencedTable:l=o}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${n})`),this}filter(n,o,l){return this.url.searchParams.append(n,`${o}.${l}`),this}};t.default=a}),Ce=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(L(),C(T)),r=e.__importDefault(z()),s=class{constructor(a,{headers:n={},schema:o,fetch:l}){this.url=a,this.headers=new Headers(n),this.schema=o,this.fetch=l}select(a,n){let{head:o=!1,count:l}=n??{},u=o?"HEAD":"GET",i=!1,c=(a??"*").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(a,{count:n,defaultToNull:o=!0}={}){var l;let u="POST";if(n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let i=a.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:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(a,{onConflict:n,ignoreDuplicates:o=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${o?"ignore":"merge"}-duplicates`),n!==void 0&&this.url.searchParams.set("on_conflict",n),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let h=a.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(h.length>0){let f=[...new Set(h)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(a,{count:n}={}){var o;let l="PATCH";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}delete({count:a}={}){var n;let o="DELETE";return a&&this.headers.append("Prefer",`count=${a}`),new r.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}};t.default=s}),it=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(L(),C(T)),r=e.__importDefault(Ce()),s=e.__importDefault(z()),a=class Le{constructor(o,{headers:l={},schema:u,fetch:i}={}){this.url=o,this.headers=new Headers(l),this.schemaName=u,this.fetch=i}from(o){let l=new URL(`${this.url}/${o}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new Le(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let f,d=new URL(`${this.url}/rpc/${o}`),p;u||i?(f=u?"HEAD":"GET",Object.entries(l).filter(([y,g])=>g!==void 0).map(([y,g])=>[y,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([y,g])=>{d.searchParams.append(y,g)})):(f="POST",p=l);let m=new Headers(this.headers);return c&&m.set("Prefer",`count=${c}`),new s.default({method:f,url:d,headers:m,schema:this.schemaName,body:p,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};t.default=a}),lt=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;var e=(L(),C(T)),r=e.__importDefault(it());t.PostgrestClient=r.default;var s=e.__importDefault(Ce());t.PostgrestQueryBuilder=s.default;var a=e.__importDefault(z());t.PostgrestFilterBuilder=a.default;var n=e.__importDefault(xe());t.PostgrestTransformBuilder=n.default;var o=e.__importDefault(Ae());t.PostgrestBuilder=o.default;var l=e.__importDefault($e());t.PostgrestError=l.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:a.default,PostgrestTransformBuilder:n.default,PostgrestBuilder:o.default,PostgrestError:l.default}});w();w();var Ie=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};w();w();var v="nvwa_current_jwt",_="nvwa_login_token",$="nvwa_user_profile",ct="set-auth-token",ut=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},Ne=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??ut,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get($);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set($,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(v);if(e!=null)return e;let r=await this.storage.get(_),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(v,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let r=e?.headers.get(ct)?.trim()||t.token||t.session?.token;r&&await this.storage.set(_,r),t.user&&await this.storage.set($,t.user);let s=r??await this.storage.get(_),{data:a}=await this.getToken(s??void 0);a?.token&&await this.storage.set(v,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(_),await this.storage.remove($),await this.storage.remove(v))}url(t){let e=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",e),!e.startsWith("http://")&&!e.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),e}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(_)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:t,password:e})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):void 0;return a&&await this.persistLogin({user:a.user,session:a.session},r),{data:a}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(_)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data,e.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let n=await this.storage.get(_)??await this.storage.get(v);n!=null&&(e.Authorization=`Bearer ${n}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):void 0;return{data:a?.token!=null?{token:a.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data,r.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.token||!n.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(v,n.token),await this.storage.set(_,n.token),await this.storage.set($,n.user)),{data:n})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async loginWithAlipayCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("alipay/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.token||!n.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(v,n.token),await this.storage.set(_,n.token),await this.storage.set($,n.user)),{data:n})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`wechat/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.openid||!n.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:n}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`alipay/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.openid||!n.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:n}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):void 0;return{data:a?.data??a??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};w();w();var E=class je{constructor(e){if(this.headerMap=new Map,e){if(e instanceof je)e.forEach((r,s)=>this.set(s,r));else if(Array.isArray(e))for(let[r,s]of e)this.set(r,String(s));else if(typeof e=="object")for(let r of Object.keys(e))this.set(r,String(e[r]))}}append(e,r){let s=e.toLowerCase(),a=this.headerMap.get(s);this.headerMap.set(s,a?`${a}, ${r}`:r)}set(e,r){this.headerMap.set(e.toLowerCase(),String(r))}get(e){return this.headerMap.get(e.toLowerCase())??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[r,s]of this.headerMap.entries())e(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},ke=class Ue{constructor(e){if(this.params=new Map,e){if(typeof e=="string")this.parseString(e);else if(e instanceof Ue)this.params=new Map(e.params);else if(Array.isArray(e))for(let[r,s]of e)this.append(r,s);else if(e&&typeof e=="object")for(let[r,s]of Object.entries(e))this.set(r,s)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let r=e.split("&");for(let s of r)if(s){let[a,n]=s.split("=");a&&this.append(decodeURIComponent(a),n?decodeURIComponent(n):"")}}append(e,r){let s=this.params.get(e)||[];s.push(r),this.params.set(e,s)}delete(e){this.params.delete(e)}get(e){let r=this.params.get(e);return r?r[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,r){this.params.set(e,[r])}sort(){let e=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(e)}toString(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push(`${encodeURIComponent(r)}=${encodeURIComponent(a)}`);return e.join("&")}forEach(e){for(let[r,s]of this.params.entries())for(let a of s)e(a,r,this)}keys(){return this.params.keys()}values(){let e=[];for(let r of this.params.values())e.push(...r);return e[Symbol.iterator]()}entries(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push([r,a]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},ht=class B{constructor(e,r){let s;if(e instanceof B)s=e.href;else if(r){let n=r instanceof B?r.href:r;s=this.resolve(n,e)}else s=e;let a=this.parseUrl(s);this.href=s,this.origin=`${a.protocol}//${a.host}`,this.protocol=a.protocol,this.username=a.username,this.password=a.password,this.host=a.host,this.hostname=a.hostname,this.port=a.port,this.pathname=a.pathname,this.search=a.search,this.searchParams=new ke(a.search),this.hash=a.hash}resolve(e,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(e).protocol}${r}`;if(r.startsWith("/")){let n=this.parseUrl(e);return`${n.protocol}//${n.host}${r}`}let s=this.parseUrl(e),a=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${a}${r}`}parseUrl(e){let r=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",a=r[4]||"",n=r[5]||"/",o=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!a&&!n.startsWith("/")&&!n.includes("/")&&!n.includes("."))throw new TypeError("Invalid URL");let u=a.match(/^([^@]*)@(.+)$/),i="",c="",h=a;if(u){let m=u[1];h=u[2];let y=m.match(/^([^:]*):?(.*)$/);y&&(i=y[1]||"",c=y[2]||"")}let f=h.match(/^([^:]+):?(\d*)$/),d=f?f[1]:h,p=f&&f[2]?f[2]:"";return{protocol:s?`${s}:`:"",username:i,password:c,host:h,hostname:d,port:p,pathname:n,search:o,hash:l}}toString(){let e=this.searchParams.toString(),r=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};w();var dt=class Re{constructor(e,r){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof E?r.headers:new E(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new Re(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};w();var G=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=pt(e?.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 t=await this.text();return new TextEncoder().encode(t).buffer}};function pt(t){return t?new E(t):new E}w();var Me=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 t of Array.from(this.listeners))try{t()}catch{}this.listeners.clear()}}addEventListener(t,e){if(this._aborted){try{e()}catch{}return}this.listeners.add(e)}removeEventListener(t,e){this.listeners.delete(e)}toString(){return"[object AbortSignal]"}},ft=class{constructor(){this._signal=new Me}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};w();function He(t){t.URL=ht,t.URLSearchParams=ke,t.Headers=E,t.Request=dt,t.Response=G,t.AbortController=ft,t.AbortSignal=Me}var Fe=class{constructor(t,e,r){this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(v),s=new E(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let a=e?.method||"GET";if((a==="POST"||a==="PUT"||a==="PATCH")&&e?.body){let o=s.get("Content-Type");(!o||o.includes("text/plain"))&&s.set("Content-Type","application/json")}let n=await this.customFetch(t,{...e,headers:s});if(n.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return n}};w();var mt="/storage",yt=mt+"/generateUploadUrl",De=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+yt,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new E({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:a}=await s.json();return{url:a.split("?")[0]}}};w();w();w();var K=ot(lt(),1),{PostgrestClient:gt,PostgrestQueryBuilder:jt,PostgrestFilterBuilder:kt,PostgrestTransformBuilder:Ut,PostgrestBuilder:Rt,PostgrestError:Mt}=K.default||K,wt="/entities",qe=(t,e)=>new gt(t+wt,{fetch:e.fetchWithAuth.bind(e)});w();var Be=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
2
2
  .__nvwa-inspector-overlay {
3
3
  position: absolute;
4
4
  pointer-events: none;
@@ -30,4 +30,4 @@
30
30
  max-width: 400px;
31
31
  word-break: break-all;
32
32
  }
33
- `,document.head.appendChild(t)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(t){let e=document.createElement("div");return e.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${t}`,document.body.appendChild(e),e}updateOverlayPosition(t,e){if(!e.isConnected)return;let r=e.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,a=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+a}px`,t.style.width=`${r.width}px`,t.style.height=`${r.height}px`,t.style.display="block"):t.style.display="none"}removeOverlay(t){t&&t.parentNode&&t.parentNode.removeChild(t)}highlightElement(t,e){if(!t.isConnected)return;if(this.hoverElement===t&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,t);let o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let i=t.getBoundingClientRect();o.style.left=`${i.left+window.scrollX}px`,o.style.top=`${i.top+window.scrollY-o.offsetHeight-8}px`,i.top<o.offsetHeight+8&&(o.style.top=`${i.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,t),this.hoverOverlay=r,this.hoverElement=t;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let a=this.createTooltip();e?a.textContent=e:a.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let n=t.getBoundingClientRect();a.style.left=`${n.left+window.scrollX}px`,a.style.top=`${n.top+window.scrollY-a.offsetHeight-8}px`,n.top<a.offsetHeight+8&&(a.style.top=`${n.bottom+window.scrollY+8}px`)}selectElement(t,e){if(!t.isConnected)return;if(this.selectedElement===t&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,t);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,t),this.selectedOverlay=r,this.selectedElement=t;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let t=document.getElementById("__nvwa-inspector-overlay-style");t&&t.parentNode&&t.parentNode.removeChild(t)}};function We(t="root"){if(typeof document>"u")return null;let e=document.getElementById(t)||document.body;if(!e)return null;let r=e.querySelector("[data-source-location]");if(r){let s=r.getAttribute("data-source-location");if(s)return s}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}w();var H=class{constructor(){this.prefix="nvwa_"}getKey(e){return`${this.prefix}${e}`}async get(e){try{let r=this.getKey(e),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(e),null):s.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(e,r,s){try{let a=this.getKey(e),n={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(a,n)}catch(a){throw console.error("UniAppStorageService set error:",a),a}}async remove(e){try{let r=this.getKey(e);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(e){throw console.error("UniAppStorageService clear error:",e),e}}};var I=(t,e)=>{let r;if(typeof t=="string")r=t;else if(t&&typeof t.toString=="function")r=t.toString();else if(t?.url)r=t.url;else throw new Error("Invalid input for uniappFetch");typeof console<"u"&&(console.warn("[NvwaUni] request url:",r,"method:",(e?.method||"GET").toUpperCase()),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaUni] url \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F uni.request \u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 baseUrl \u662F\u5426\u4F20\u5165\u5B8C\u6574\u57DF\u540D"));let s=(e?.method||"GET").toUpperCase(),a={};if(e?.headers){let i=e.headers;if(typeof i?.forEach=="function")i.forEach((c,l)=>{a[l]=c});else if(Array.isArray(i))for(let[c,l]of i)a[c]=l;else Object.assign(a,i)}let n;if(e?.body!==void 0){let i=e.body;if(typeof i=="string")n=i;else if(i&&typeof i=="object"&&typeof i.forEach=="function"){let c={};i.forEach((l,u)=>{c[u]=l}),n=c}else n=i}let o=e?.timeout||3e4;return new Promise((i,c)=>{let l=e?.signal;if(l?.aborted){let d=new Error("The operation was aborted");d.name="AbortError",c(d);return}let u=!1,h=[],f=uni.request({url:r,method:s,data:n,header:a,timeout:o,success:d=>{if(u)return;u=!0;let p=d.statusCode,m="",y=new _,g=d.header||d.headers||{};Object.keys(g).forEach(P=>{let O=g[P];y.set(P,typeof O=="string"?O:String(O))}),i(new G(d.data,{status:p,statusText:m,headers:y}))},fail:d=>{if(u)return;u=!0;let p=d?.errMsg||d?.message||"Network Error",m=new Error(p);/(abort|aborted|canceled|cancelled)/i.test(String(p))&&(m.name="AbortError"),c(m)}});if(l&&typeof l.addEventListener=="function"){let d=()=>{if(u)return;try{f?.abort?.()}catch{}let p=new Error("The operation was aborted");p.name="AbortError",u=!0,c(p)};l.addEventListener("abort",d),h.push(()=>{try{l.removeEventListener?.("abort",d)}catch{}})}})};typeof globalThis.fetch!="function"&&(globalThis.fetch=I);var b="Mobile-web";try{if(typeof uni<"u"&&typeof uni?.getSystemInfoSync=="function"){let t=uni.getSystemInfoSync()??{},e=t.uniPlatform,r=t.osName,s=t.ua??(typeof navigator<"u"?navigator.userAgent:"");e==="mp-weixin"?b="MP-Wechat":e==="mp-alipay"?b="MP-Alipay":e==="app"?r==="ios"?b="IOS":r==="android"?b="Android":r==="harmonyos"&&(b="Harmony"):(e==="web"||e==="h5")&&(b=s&&/MicroMessenger/i.test(s)?"Wechat-H5":"Mobile-web")}else typeof navigator<"u"&&/MicroMessenger/i.test(navigator.userAgent)&&(b="Wechat-H5")}catch{b="Mobile-web"}var ze={async requestPayment(t){let e=t,r=typeof e.tradeNO=="string"?e.tradeNO:void 0;if(r){await new Promise((n,o)=>{let i=globalThis.my;if(!i?.tradePay){o(new Error("requestPayment: my.tradePay is unavailable"));return}i.tradePay({tradeNO:r,success:()=>n(),fail:c=>o(c)})});return}let s=e.jsapiPayParams??e;if(typeof s.timeStamp=="string"&&typeof s.nonceStr=="string"&&typeof s.package=="string"&&typeof s.paySign=="string"){await new Promise((n,o)=>{uni.requestPayment({provider:"wxpay",timeStamp:s.timeStamp,nonceStr:s.nonceStr,package:s.package,signType:s.signType??"RSA",paySign:s.paySign,success:()=>n(),fail:i=>o(i)})});return}if(typeof e.redirectUrl=="string"){typeof window<"u"?window.location.href=e.redirectUrl:globalThis.plus?.runtime?.openURL?.(e.redirectUrl);return}if(typeof e.codeUrl=="string"){let n=`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e.codeUrl)}`;typeof window<"u"?window.open(n,"_blank"):globalThis.plus?.runtime?.openURL?.(n);return}throw new Error("requestPayment: unsupported payParams for current endpoint")}};function gt(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new qe;function r(l){if(!l)return!1;let u=l.toLowerCase();return u.includes("/components/")||u.includes("\\components\\")}function s(l){let u=l,h=null;for(;u;){let f=u.getAttribute("data-source-location");if(f)if(r(f)){h||(h=f),u=u.parentElement;continue}else return f;u=u.parentElement}return h}let a=null;function n(l){t&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{let u=l.target;if(!u||u===document.body||u===document.documentElement){e.removeHighlight();return}if(u.tagName.toLowerCase()==="img"){let p=s(u);e.highlightElement(u,p);let m={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(m,"*");return}let h=u,f=s(u);if(!f){let p=u.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let m=s(p);if(m){h=p,f=m;break}p=p.parentElement}}e.highlightElement(h,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(d,"*")}))}function o(){if(!t)return;e.removeHighlight();let l={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(l,"*")}function i(l){if(!t)return;l.preventDefault(),l.stopPropagation();let u=l.target;if(!u||u===document.body||u===document.documentElement)return;let h=s(u);e.selectElement(u,h);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:h,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(f,"*")}function c(l){l.data?.type==="HOVER_INSPECTOR_ENABLE"?(t=!0,document.addEventListener("mousemove",n),document.addEventListener("mouseleave",o),document.addEventListener("click",i,!0)):l.data?.type==="HOVER_INSPECTOR_DISABLE"&&(t=!1,document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",i,!0),e.removeHighlight(),e.clearSelection())}return window.addEventListener("message",c),()=>{window.removeEventListener("message",c),document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",i,!0),e.cleanup()}}function wt(t,e){if(!t||!t.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};t.contentWindow.postMessage(r,e)}function vt(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function bt(t,e,r=5e3){return new Promise((s,a)=>{if(!t||!t.contentWindow){a(new Error("Invalid iframe element"));return}let n=`source-location-${Date.now()}-${Math.random()}`,o=setTimeout(()=>{window.removeEventListener("message",i),a(new Error("Request timeout"))},r),i=l=>{l.origin===e&&l.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&l.data?.requestId===n&&(clearTimeout(o),window.removeEventListener("message",i),l.data.error?a(new Error(l.data.error)):s(l.data.sourceLocation||null))};window.addEventListener("message",i);let c={type:"GET_SOURCE_LOCATION_REQUEST",requestId:n};try{t.contentWindow.postMessage(c,e)}catch(l){clearTimeout(o),window.removeEventListener("message",i),a(l)}})}function Et(){if(typeof window>"u"||window===window.parent)return;let t=e=>{if(e.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:_t(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function _t(){return We("app")}var J=new H,F=class{constructor(e,r){this.payment=ze;this.endpointType=b;typeof console<"u"&&console.warn("[Nvwa] uniapp init baseUrl:",e||"(empty)"),this.auth=new Ne(e,{fetchImpl:I,storage:J}),this.httpClient=new Fe(J,I,r),this.fileStorage=new De(e,this.httpClient),this.entities=Be(e,this.httpClient),this.functions=new Ie(this.httpClient,e)}};0&&(module.exports={disableIframeHoverInspector,enableIframeHoverInspector,getIframeSourceLocation,localStorage,polyfill,setupIframeHoverInspector,setupIframeSourceLocationListener,uniappFetch});
33
+ `,document.head.appendChild(t)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(t){let e=document.createElement("div");return e.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${t}`,document.body.appendChild(e),e}updateOverlayPosition(t,e){if(!e.isConnected)return;let r=e.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,a=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+a}px`,t.style.width=`${r.width}px`,t.style.height=`${r.height}px`,t.style.display="block"):t.style.display="none"}removeOverlay(t){t&&t.parentNode&&t.parentNode.removeChild(t)}highlightElement(t,e){if(!t.isConnected)return;if(this.hoverElement===t&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,t);let o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let l=t.getBoundingClientRect();o.style.left=`${l.left+window.scrollX}px`,o.style.top=`${l.top+window.scrollY-o.offsetHeight-8}px`,l.top<o.offsetHeight+8&&(o.style.top=`${l.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,t),this.hoverOverlay=r,this.hoverElement=t;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let a=this.createTooltip();e?a.textContent=e:a.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let n=t.getBoundingClientRect();a.style.left=`${n.left+window.scrollX}px`,a.style.top=`${n.top+window.scrollY-a.offsetHeight-8}px`,n.top<a.offsetHeight+8&&(a.style.top=`${n.bottom+window.scrollY+8}px`)}selectElement(t,e){if(!t.isConnected)return;if(this.selectedElement===t&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,t);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,t),this.selectedOverlay=r,this.selectedElement=t;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let t=document.getElementById("__nvwa-inspector-overlay-style");t&&t.parentNode&&t.parentNode.removeChild(t)}};function We(t="root"){if(typeof document>"u")return null;let e=document.getElementById(t)||document.body;if(!e)return null;let r=e.querySelector("[data-source-location]");if(r){let s=r.getAttribute("data-source-location");if(s)return s}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}w();function ze(t){let e=t;if(typeof e.kind=="string")return e;if(typeof e.tradeNO=="string")return{kind:"alipay_miniprogram",tradeNO:e.tradeNO};if(typeof e.clientSecret=="string")return{kind:"stripe_client_secret",clientSecret:e.clientSecret};if(typeof e.redirectUrl=="string")return{kind:"redirect_url",redirectUrl:e.redirectUrl};if(typeof e.formHtml=="string")return{kind:"alipay_page",formHtml:e.formHtml};if(typeof e.codeUrl=="string")return{kind:"wechat_native_qr",codeUrl:e.codeUrl};let r=e.jsapiPayParams??e;return typeof r.timeStamp=="string"&&typeof r.nonceStr=="string"&&typeof r.package=="string"&&typeof r.paySign=="string"&&typeof r.appId=="string"?{kind:"wechat_jsapi",mode:"jsapi",jsapiPayParams:{appId:r.appId,timeStamp:r.timeStamp,nonceStr:r.nonceStr,package:r.package,signType:r.signType??"RSA",paySign:r.paySign}}:null}var H=class{constructor(){this.prefix="nvwa_"}getKey(e){return`${this.prefix}${e}`}async get(e){try{let r=this.getKey(e),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(e),null):s.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(e,r,s){try{let a=this.getKey(e),n={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(a,n)}catch(a){throw console.error("UniAppStorageService set error:",a),a}}async remove(e){try{let r=this.getKey(e);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(e){throw console.error("UniAppStorageService clear error:",e),e}}};var I=(t,e)=>{let r;if(typeof t=="string")r=t;else if(t&&typeof t.toString=="function")r=t.toString();else if(t?.url)r=t.url;else throw new Error("Invalid input for uniappFetch");typeof console<"u"&&(console.warn("[NvwaUni] request url:",r,"method:",(e?.method||"GET").toUpperCase()),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaUni] url \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F uni.request \u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 baseUrl \u662F\u5426\u4F20\u5165\u5B8C\u6574\u57DF\u540D"));let s=(e?.method||"GET").toUpperCase(),a={};if(e?.headers){let l=e.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{a[i]=u});else if(Array.isArray(l))for(let[u,i]of l)a[u]=i;else Object.assign(a,l)}let n;if(e?.body!==void 0){let l=e.body;if(typeof l=="string")n=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),n=u}else n=l}let o=e?.timeout||3e4;return new Promise((l,u)=>{let i=e?.signal;if(i?.aborted){let d=new Error("The operation was aborted");d.name="AbortError",u(d);return}let c=!1,h=[],f=uni.request({url:r,method:s,data:n,header:a,timeout:o,success:d=>{if(c)return;c=!0;let p=d.statusCode,m="",y=new E,g=d.header||d.headers||{};Object.keys(g).forEach(P=>{let O=g[P];y.set(P,typeof O=="string"?O:String(O))}),l(new G(d.data,{status:p,statusText:m,headers:y}))},fail:d=>{if(c)return;c=!0;let p=d?.errMsg||d?.message||"Network Error",m=new Error(p);/(abort|aborted|canceled|cancelled)/i.test(String(p))&&(m.name="AbortError"),u(m)}});if(i&&typeof i.addEventListener=="function"){let d=()=>{if(c)return;try{f?.abort?.()}catch{}let p=new Error("The operation was aborted");p.name="AbortError",c=!0,u(p)};i.addEventListener("abort",d),h.push(()=>{try{i.removeEventListener?.("abort",d)}catch{}})}})};typeof globalThis.fetch!="function"&&(globalThis.fetch=I);var b="Mobile-web";try{if(typeof uni<"u"&&typeof uni?.getSystemInfoSync=="function"){let t=uni.getSystemInfoSync()??{},e=t.uniPlatform,r=t.osName,s=t.ua??(typeof navigator<"u"?navigator.userAgent:"");e==="mp-weixin"?b="MP-Wechat":e==="mp-alipay"?b="MP-Alipay":e==="app"?r==="ios"?b="IOS":r==="android"?b="Android":r==="harmonyos"&&(b="Harmony"):(e==="web"||e==="h5")&&(b=s&&/MicroMessenger/i.test(s)?"Wechat-H5":"Mobile-web")}else typeof navigator<"u"&&/MicroMessenger/i.test(navigator.userAgent)&&(b="Wechat-H5")}catch{b="Mobile-web"}function vt(t){return`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(t)}`}function Ge(t){if(typeof window<"u"){window.open(t,"_blank");return}globalThis.plus?.runtime?.openURL?.(t)}function bt(t){let e=t,r=`${e?.errMsg??""} ${e?.message??""}`.toLowerCase();return r.includes("cancel")||r.includes("canceled")||r.includes("\u53D6\u6D88")||e?.code==="USER_CANCEL"}async function _t(t){if(t.kind!=="alipay_miniprogram")throw new Error("requestPayment: invalid payParams for alipay miniprogram");await new Promise((e,r)=>{let s=globalThis.my;if(!s?.tradePay){r(new Error("requestPayment: my.tradePay is unavailable"));return}s.tradePay({tradeNO:t.tradeNO,success:()=>e(),fail:a=>r(a)})})}async function Et(t){if(t.kind!=="wechat_jsapi")throw new Error("requestPayment: invalid payParams for wechat jsapi");let e=t.jsapiPayParams;await new Promise((r,s)=>{uni.requestPayment({provider:"wxpay",timeStamp:e.timeStamp,nonceStr:e.nonceStr,package:e.package,signType:e.signType??"RSA",paySign:e.paySign,success:()=>r(),fail:a=>s(a)})})}function Pt(t){if(t.kind!=="redirect_url")throw new Error("requestPayment: invalid payParams for redirect");typeof window<"u"?window.location.href=t.redirectUrl:Ge(t.redirectUrl)}function Ot(t){if(t.kind!=="wechat_native_qr")throw new Error("requestPayment: invalid payParams for wechat qr");let e=vt(t.codeUrl);Ge(e)}async function St(t){if(!t)return!1;switch(t.kind){case"alipay_miniprogram":return await _t(t),!0;case"wechat_jsapi":return await Et(t),!0;case"redirect_url":return Pt(t),!0;case"wechat_native_qr":return Ot(t),!0;default:return!1}}var Je={async requestPayment(t,e){try{let r=ze(t);if(!await St(r))throw new Error("requestPayment: unsupported payParams for current endpoint");e?.onSuccess?.()}catch(r){throw bt(r)?e?.onCancel?.(r):e?.onFailure?.(r),r}}};function Tt(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new Be;function r(i){if(!i)return!1;let c=i.toLowerCase();return c.includes("/components/")||c.includes("\\components\\")}function s(i){let c=i,h=null;for(;c;){let f=c.getAttribute("data-source-location");if(f)if(r(f)){h||(h=f),c=c.parentElement;continue}else return f;c=c.parentElement}return h}let a=null;function n(i){t&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{let c=i.target;if(!c||c===document.body||c===document.documentElement){e.removeHighlight();return}if(c.tagName.toLowerCase()==="img"){let p=s(c);e.highlightElement(c,p);let m={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(m,"*");return}let h=c,f=s(c);if(!f){let p=c.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let m=s(p);if(m){h=p,f=m;break}p=p.parentElement}}e.highlightElement(h,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(d,"*")}))}function o(){if(!t)return;e.removeHighlight();let i={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(i,"*")}function l(i){if(!t)return;i.preventDefault(),i.stopPropagation();let c=i.target;if(!c||c===document.body||c===document.documentElement)return;let h=s(c);e.selectElement(c,h);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:h,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(f,"*")}function u(i){i.data?.type==="HOVER_INSPECTOR_ENABLE"?(t=!0,document.addEventListener("mousemove",n),document.addEventListener("mouseleave",o),document.addEventListener("click",l,!0)):i.data?.type==="HOVER_INSPECTOR_DISABLE"&&(t=!1,document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",l,!0),e.removeHighlight(),e.clearSelection())}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",l,!0),e.cleanup()}}function $t(t,e){if(!t||!t.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};t.contentWindow.postMessage(r,e)}function At(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function xt(t,e,r=5e3){return new Promise((s,a)=>{if(!t||!t.contentWindow){a(new Error("Invalid iframe element"));return}let n=`source-location-${Date.now()}-${Math.random()}`,o=setTimeout(()=>{window.removeEventListener("message",l),a(new Error("Request timeout"))},r),l=i=>{i.origin===e&&i.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&i.data?.requestId===n&&(clearTimeout(o),window.removeEventListener("message",l),i.data.error?a(new Error(i.data.error)):s(i.data.sourceLocation||null))};window.addEventListener("message",l);let u={type:"GET_SOURCE_LOCATION_REQUEST",requestId:n};try{t.contentWindow.postMessage(u,e)}catch(i){clearTimeout(o),window.removeEventListener("message",l),a(i)}})}function Ct(){if(typeof window>"u"||window===window.parent)return;let t=e=>{if(e.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:Lt(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function Lt(){return We("app")}var J=new H,F=class{constructor(e,r){this.payment=Je;this.endpointType=b;typeof console<"u"&&console.warn("[Nvwa] uniapp init baseUrl:",e||"(empty)"),this.auth=new Ne(e,{fetchImpl:I,storage:J}),this.httpClient=new Fe(J,I,r),this.fileStorage=new De(e,this.httpClient),this.entities=qe(e,this.httpClient),this.functions=new Ie(this.httpClient,e)}};0&&(module.exports={disableIframeHoverInspector,enableIframeHoverInspector,getIframeSourceLocation,localStorage,polyfill,setupIframeHoverInspector,setupIframeSourceLocationListener,uniappFetch});
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var ze=Object.create,H=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,Je=Object.getOwnPropertyNames,Ke=Object.getPrototypeOf,Ve=Object.prototype.hasOwnProperty,K=(t,e)=>()=>(t&&(e=t(t=0)),e),S=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ye=(t,e)=>{for(var r in e)H(t,r,{get:e[r],enumerable:!0})},V=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Je(e))!Ve.call(t,n)&&n!==r&&H(t,n,{get:()=>e[n],enumerable:!(s=Ge(e,n))||s.enumerable});return t},Qe=(t,e,r)=>(r=t!=null?ze(Ke(t)):{},V(e||!t||!t.__esModule?H(r,"default",{value:t,enumerable:!0}):r,t)),C=t=>V(H({},"__esModule",{value:!0}),t),w=K(()=>{"use strict"}),T={};Ye(T,{__addDisposableResource:()=>be,__assign:()=>N,__asyncDelegator:()=>de,__asyncGenerator:()=>he,__asyncValues:()=>pe,__await:()=>A,__awaiter:()=>ne,__classPrivateFieldGet:()=>ge,__classPrivateFieldIn:()=>ve,__classPrivateFieldSet:()=>we,__createBinding:()=>j,__decorate:()=>X,__disposeResources:()=>Ee,__esDecorate:()=>ee,__exportStar:()=>ie,__extends:()=>Y,__generator:()=>oe,__importDefault:()=>ye,__importStar:()=>me,__makeTemplateObject:()=>fe,__metadata:()=>ae,__param:()=>Z,__propKey:()=>re,__read:()=>q,__rest:()=>Q,__rewriteRelativeImportExtension:()=>_e,__runInitializers:()=>te,__setFunctionName:()=>se,__spread:()=>le,__spreadArray:()=>ce,__spreadArrays:()=>ue,__values:()=>M,default:()=>Se});function Y(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");R(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function Q(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r}function X(t,e,r,s){var n=arguments.length,a=n<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,s);else for(var i=t.length-1;i>=0;i--)(o=t[i])&&(a=(n<3?o(a):n>3?o(e,r,a):o(e,r))||a);return n>3&&a&&Object.defineProperty(e,r,a),a}function Z(t,e){return function(r,s){e(r,s,t)}}function ee(t,e,r,s,n,a){function o(g){if(g!==void 0&&typeof g!="function")throw new TypeError("Function expected");return g}for(var i=s.kind,c=i==="getter"?"get":i==="setter"?"set":"value",l=!e&&t?s.static?t:t.prototype:null,u=e||(l?Object.getOwnPropertyDescriptor(l,s.name):{}),h,f=!1,d=r.length-1;d>=0;d--){var p={};for(var m in s)p[m]=m==="access"?{}:s[m];for(var m in s.access)p.access[m]=s.access[m];p.addInitializer=function(g){if(f)throw new TypeError("Cannot add initializers after decoration has completed");a.push(o(g||null))};var y=(0,r[d])(i==="accessor"?{get:u.get,set:u.set}:u[c],p);if(i==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(h=o(y.get))&&(u.get=h),(h=o(y.set))&&(u.set=h),(h=o(y.init))&&n.unshift(h)}else(h=o(y))&&(i==="field"?n.unshift(h):u[c]=h)}l&&Object.defineProperty(l,s.name,u),f=!0}function te(t,e,r){for(var s=arguments.length>2,n=0;n<e.length;n++)r=s?e[n].call(t,r):e[n].call(t);return s?r:void 0}function re(t){return typeof t=="symbol"?t:"".concat(t)}function se(t,e,r){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function ae(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function ne(t,e,r,s){function n(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function i(u){try{l(s.next(u))}catch(h){o(h)}}function c(u){try{l(s.throw(u))}catch(h){o(h)}}function l(u){u.done?a(u.value):n(u.value).then(i,c)}l((s=s.apply(t,e||[])).next())})}function oe(t,e){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},s,n,a,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=i(0),o.throw=i(1),o.return=i(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function i(l){return function(u){return c([l,u])}}function c(l){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(r=0)),r;)try{if(s=1,n&&(a=l[0]&2?n.return:l[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,l[1])).done)return a;switch(n=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,n=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){r.label=l[1];break}if(l[0]===6&&r.label<a[1]){r.label=a[1],a=l;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(l);break}a[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(u){l=[6,u],n=0}finally{s=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function ie(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&j(e,t,r)}function M(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],s=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function q(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var s=r.call(t),n,a=[],o;try{for(;(e===void 0||e-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(i){o={error:i}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return a}function le(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(q(arguments[e]));return t}function ue(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var s=Array(t),n=0,e=0;e<r;e++)for(var a=arguments[e],o=0,i=a.length;o<i;o++,n++)s[n]=a[o];return s}function ce(t,e,r){if(r||arguments.length===2)for(var s=0,n=e.length,a;s<n;s++)(a||!(s in e))&&(a||(a=Array.prototype.slice.call(e,0,s)),a[s]=e[s]);return t.concat(a||Array.prototype.slice.call(e))}function A(t){return this instanceof A?(this.v=t,this):new A(t)}function he(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(t,e||[]),n,a=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",o),n[Symbol.asyncIterator]=function(){return this},n;function o(d){return function(p){return Promise.resolve(p).then(d,h)}}function i(d,p){s[d]&&(n[d]=function(m){return new Promise(function(y,g){a.push([d,m,y,g])>1||c(d,m)})},p&&(n[d]=p(n[d])))}function c(d,p){try{l(s[d](p))}catch(m){f(a[0][3],m)}}function l(d){d.value instanceof A?Promise.resolve(d.value.v).then(u,h):f(a[0][2],d)}function u(d){c("next",d)}function h(d){c("throw",d)}function f(d,p){d(p),a.shift(),a.length&&c(a[0][0],a[0][1])}}function de(t){var e,r;return e={},s("next"),s("throw",function(n){throw n}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(n,a){e[n]=t[n]?function(o){return(r=!r)?{value:A(t[n](o)),done:!1}:a?a(o):o}:a}}function pe(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof M=="function"?M(t):t[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(a){r[a]=t[a]&&function(o){return new Promise(function(i,c){o=t[a](o),n(i,c,o.done,o.value)})}}function n(a,o,i,c){Promise.resolve(c).then(function(l){a({value:l,done:i})},o)}}function fe(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function me(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=U(t),s=0;s<r.length;s++)r[s]!=="default"&&j(e,t,r[s]);return Pe(e,t),e}function ye(t){return t&&t.__esModule?t:{default:t}}function ge(t,e,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(t):s?s.value:e.get(t)}function we(t,e,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 e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(t,r):n?n.value=r:e.set(t,r),r}function ve(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function be(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var s,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=e[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose],r&&(n=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");n&&(s=function(){try{n.call(this)}catch(a){return Promise.reject(a)}}),t.stack.push({value:e,dispose:s,async:r})}else r&&t.stack.push({async:!0});return e}function Ee(t){function e(a){t.error=t.hasError?new Oe(a,t.error,"An error was suppressed during disposal."):a,t.hasError=!0}var r,s=0;function n(){for(;r=t.stack.pop();)try{if(!r.async&&s===1)return s=0,t.stack.push(r),Promise.resolve().then(n);if(r.dispose){var a=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(a).then(n,function(o){return e(o),n()})}else s|=1}catch(o){e(o)}if(s===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return n()}function _e(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,n,a,o){return s?e?".jsx":".js":n&&(!a||!o)?r:n+a+"."+o.toLowerCase()+"js"}):t}var R,N,j,Pe,U,Oe,Se,I=K(()=>{"use strict";w(),R=function(t,e){return R=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])},R(t,e)},N=function(){return N=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},N.apply(this,arguments)},j=Object.create?(function(t,e,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,n)}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]}),Pe=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},U=function(t){return U=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},U(t)},Oe=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Se={__extends:Y,__assign:N,__rest:Q,__decorate:X,__param:Z,__esDecorate:ee,__runInitializers:te,__propKey:re,__setFunctionName:se,__metadata:ae,__awaiter:ne,__generator:oe,__createBinding:j,__exportStar:ie,__values:M,__read:q,__spread:le,__spreadArrays:ue,__spreadArray:ce,__await:A,__asyncGenerator:he,__asyncDelegator:de,__asyncValues:pe,__makeTemplateObject:fe,__importStar:me,__importDefault:ye,__classPrivateFieldGet:ge,__classPrivateFieldSet:we,__classPrivateFieldIn:ve,__addDisposableResource:be,__disposeResources:Ee,__rewriteRelativeImportExtension:_e}}),Te=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};t.default=e}),$e=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(I(),C(T)),r=e.__importDefault(Te()),s=class{constructor(n){var a,o;this.shouldThrowOnError=!1,this.method=n.method,this.url=n.url,this.headers=new Headers(n.headers),this.schema=n.schema,this.body=n.body,this.shouldThrowOnError=(a=n.shouldThrowOnError)!==null&&a!==void 0?a:!1,this.signal=n.signal,this.isMaybeSingle=(o=n.isMaybeSingle)!==null&&o!==void 0?o:!1,n.fetch?this.fetch=n.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(n,a){return this.headers=new Headers(this.headers),this.headers.set(n,a),this}then(n,a){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let o=this.fetch,i=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var l,u,h,f;let d=null,p=null,m=null,y=c.status,g=c.statusText;if(c.ok){if(this.method!=="HEAD"){let D=await c.text();D===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((l=this.headers.get("Accept"))===null||l===void 0)&&l.includes("application/vnd.pgrst.plan+text")?p=D:p=JSON.parse(D))}let P=(u=this.headers.get("Prefer"))===null||u===void 0?void 0:u.match(/count=(exact|planned|estimated)/),O=(h=c.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");P&&O&&O.length>1&&(m=parseInt(O[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(d={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,m=null,y=406,g="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let P=await c.text();try{d=JSON.parse(P),Array.isArray(d)&&c.status===404&&(p=[],d=null,y=200,g="OK")}catch{c.status===404&&P===""?(y=204,g="No Content"):d={message:P}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,y=200,g="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:m,status:y,statusText:g}});return this.shouldThrowOnError||(i=i.catch(c=>{var l,u,h;return{error:{message:`${(l=c?.name)!==null&&l!==void 0?l:"FetchError"}: ${c?.message}`,details:`${(u=c?.stack)!==null&&u!==void 0?u:""}`,hint:"",code:`${(h=c?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),i.then(n,a)}returns(){return this}overrideTypes(){return this}};t.default=s}),Ae=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(I(),C(T)),r=e.__importDefault($e()),s=class extends r.default{select(n){let a=!1,o=(n??"*").split("").map(i=>/\s/.test(i)&&!a?"":(i==='"'&&(a=!a),i)).join("");return this.url.searchParams.set("select",o),this.headers.append("Prefer","return=representation"),this}order(n,{ascending:a=!0,nullsFirst:o,foreignTable:i,referencedTable:c=i}={}){let l=c?`${c}.order`:"order",u=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${u?`${u},`:""}${n}.${a?"asc":"desc"}${o===void 0?"":o?".nullsfirst":".nullslast"}`),this}limit(n,{foreignTable:a,referencedTable:o=a}={}){let i=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(i,`${n}`),this}range(n,a,{foreignTable:o,referencedTable:i=o}={}){let c=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(c,`${n}`),this.url.searchParams.set(l,`${a-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:a=!1,settings:o=!1,buffers:i=!1,wal:c=!1,format:l="text"}={}){var u;let h=[n?"analyze":null,a?"verbose":null,o?"settings":null,i?"buffers":null,c?"wal":null].filter(Boolean).join("|"),f=(u=this.headers.get("Accept"))!==null&&u!==void 0?u:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${l}; for="${f}"; options=${h};`),l==="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}};t.default=s}),W=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(I(),C(T)),r=e.__importDefault(Ae()),s=new RegExp("[,()]"),n=class extends r.default{eq(a,o){return this.url.searchParams.append(a,`eq.${o}`),this}neq(a,o){return this.url.searchParams.append(a,`neq.${o}`),this}gt(a,o){return this.url.searchParams.append(a,`gt.${o}`),this}gte(a,o){return this.url.searchParams.append(a,`gte.${o}`),this}lt(a,o){return this.url.searchParams.append(a,`lt.${o}`),this}lte(a,o){return this.url.searchParams.append(a,`lte.${o}`),this}like(a,o){return this.url.searchParams.append(a,`like.${o}`),this}likeAllOf(a,o){return this.url.searchParams.append(a,`like(all).{${o.join(",")}}`),this}likeAnyOf(a,o){return this.url.searchParams.append(a,`like(any).{${o.join(",")}}`),this}ilike(a,o){return this.url.searchParams.append(a,`ilike.${o}`),this}ilikeAllOf(a,o){return this.url.searchParams.append(a,`ilike(all).{${o.join(",")}}`),this}ilikeAnyOf(a,o){return this.url.searchParams.append(a,`ilike(any).{${o.join(",")}}`),this}is(a,o){return this.url.searchParams.append(a,`is.${o}`),this}in(a,o){let i=Array.from(new Set(o)).map(c=>typeof c=="string"&&s.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(a,`in.(${i})`),this}contains(a,o){return typeof o=="string"?this.url.searchParams.append(a,`cs.${o}`):Array.isArray(o)?this.url.searchParams.append(a,`cs.{${o.join(",")}}`):this.url.searchParams.append(a,`cs.${JSON.stringify(o)}`),this}containedBy(a,o){return typeof o=="string"?this.url.searchParams.append(a,`cd.${o}`):Array.isArray(o)?this.url.searchParams.append(a,`cd.{${o.join(",")}}`):this.url.searchParams.append(a,`cd.${JSON.stringify(o)}`),this}rangeGt(a,o){return this.url.searchParams.append(a,`sr.${o}`),this}rangeGte(a,o){return this.url.searchParams.append(a,`nxl.${o}`),this}rangeLt(a,o){return this.url.searchParams.append(a,`sl.${o}`),this}rangeLte(a,o){return this.url.searchParams.append(a,`nxr.${o}`),this}rangeAdjacent(a,o){return this.url.searchParams.append(a,`adj.${o}`),this}overlaps(a,o){return typeof o=="string"?this.url.searchParams.append(a,`ov.${o}`):this.url.searchParams.append(a,`ov.{${o.join(",")}}`),this}textSearch(a,o,{config:i,type:c}={}){let l="";c==="plain"?l="pl":c==="phrase"?l="ph":c==="websearch"&&(l="w");let u=i===void 0?"":`(${i})`;return this.url.searchParams.append(a,`${l}fts${u}.${o}`),this}match(a){return Object.entries(a).forEach(([o,i])=>{this.url.searchParams.append(o,`eq.${i}`)}),this}not(a,o,i){return this.url.searchParams.append(a,`not.${o}.${i}`),this}or(a,{foreignTable:o,referencedTable:i=o}={}){let c=i?`${i}.or`:"or";return this.url.searchParams.append(c,`(${a})`),this}filter(a,o,i){return this.url.searchParams.append(a,`${o}.${i}`),this}};t.default=n}),xe=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(I(),C(T)),r=e.__importDefault(W()),s=class{constructor(n,{headers:a={},schema:o,fetch:i}){this.url=n,this.headers=new Headers(a),this.schema=o,this.fetch=i}select(n,a){let{head:o=!1,count:i}=a??{},c=o?"HEAD":"GET",l=!1,u=(n??"*").split("").map(h=>/\s/.test(h)&&!l?"":(h==='"'&&(l=!l),h)).join("");return this.url.searchParams.set("select",u),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(n,{count:a,defaultToNull:o=!0}={}){var i;let c="POST";if(a&&this.headers.append("Prefer",`count=${a}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let l=n.reduce((u,h)=>u.concat(Object.keys(h)),[]);if(l.length>0){let u=[...new Set(l)].map(h=>`"${h}"`);this.url.searchParams.set("columns",u.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})}upsert(n,{onConflict:a,ignoreDuplicates:o=!1,count:i,defaultToNull:c=!0}={}){var l;let u="POST";if(this.headers.append("Prefer",`resolution=${o?"ignore":"merge"}-duplicates`),a!==void 0&&this.url.searchParams.set("on_conflict",a),i&&this.headers.append("Prefer",`count=${i}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let h=n.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(h.length>0){let f=[...new Set(h)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.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})}update(n,{count:a}={}){var o;let i="PATCH";return a&&this.headers.append("Prefer",`count=${a}`),new r.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}delete({count:n}={}){var a;let o="DELETE";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};t.default=s}),Xe=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(I(),C(T)),r=e.__importDefault(xe()),s=e.__importDefault(W()),n=class Le{constructor(o,{headers:i={},schema:c,fetch:l}={}){this.url=o,this.headers=new Headers(i),this.schemaName=c,this.fetch=l}from(o){let i=new URL(`${this.url}/${o}`);return new r.default(i,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new Le(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,i={},{head:c=!1,get:l=!1,count:u}={}){var h;let f,d=new URL(`${this.url}/rpc/${o}`),p;c||l?(f=c?"HEAD":"GET",Object.entries(i).filter(([y,g])=>g!==void 0).map(([y,g])=>[y,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([y,g])=>{d.searchParams.append(y,g)})):(f="POST",p=i);let m=new Headers(this.headers);return u&&m.set("Prefer",`count=${u}`),new s.default({method:f,url:d,headers:m,schema:this.schemaName,body:p,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};t.default=n}),Ze=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;var e=(I(),C(T)),r=e.__importDefault(Xe());t.PostgrestClient=r.default;var s=e.__importDefault(xe());t.PostgrestQueryBuilder=s.default;var n=e.__importDefault(W());t.PostgrestFilterBuilder=n.default;var a=e.__importDefault(Ae());t.PostgrestTransformBuilder=a.default;var o=e.__importDefault($e());t.PostgrestBuilder=o.default;var i=e.__importDefault(Te());t.PostgrestError=i.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:n.default,PostgrestTransformBuilder:a.default,PostgrestBuilder:o.default,PostgrestError:i.default}});w();w();var Ce=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};w();w();var v="nvwa_current_jwt",E="nvwa_login_token",$="nvwa_user_profile",et="set-auth-token",tt=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},Ie=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??tt,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get($);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set($,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(v);if(e!=null)return e;let r=await this.storage.get(E),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(v,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let r=e?.headers.get(et)?.trim()||t.token||t.session?.token;r&&await this.storage.set(E,r),t.user&&await this.storage.set($,t.user);let s=r??await this.storage.get(E),{data:n}=await this.getToken(s??void 0);n?.token&&await this.storage.set(v,n.token)}async clearLogin(){this.storage&&(await this.storage.remove(E),await this.storage.remove($),await this.storage.remove(v))}url(t){let e=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",e),!e.startsWith("http://")&&!e.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),e}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(E)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:t,password:e})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):void 0;return n&&await this.persistLogin({user:n.user,session:n.session},r),{data:n}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(E)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data,e.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(E)??await this.storage.get(v);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):void 0;return{data:n?.token!=null?{token:n.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data,r.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(E,a.token),await this.storage.set($,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async loginWithAlipayCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("alipay/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):null;return!a?.token||!a.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(E,a.token),await this.storage.set($,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`wechat/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):null;return!a?.openid||!a.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`alipay/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):null;return!a?.openid||!a.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let n=s?JSON.parse(s):void 0;return{data:n?.data??n??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};w();w();var _=class Ne{constructor(e){if(this.headerMap=new Map,e){if(e instanceof Ne)e.forEach((r,s)=>this.set(s,r));else if(Array.isArray(e))for(let[r,s]of e)this.set(r,String(s));else if(typeof e=="object")for(let r of Object.keys(e))this.set(r,String(e[r]))}}append(e,r){let s=e.toLowerCase(),n=this.headerMap.get(s);this.headerMap.set(s,n?`${n}, ${r}`:r)}set(e,r){this.headerMap.set(e.toLowerCase(),String(r))}get(e){return this.headerMap.get(e.toLowerCase())??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[r,s]of this.headerMap.entries())e(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},je=class ke{constructor(e){if(this.params=new Map,e){if(typeof e=="string")this.parseString(e);else if(e instanceof ke)this.params=new Map(e.params);else if(Array.isArray(e))for(let[r,s]of e)this.append(r,s);else if(e&&typeof e=="object")for(let[r,s]of Object.entries(e))this.set(r,s)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let r=e.split("&");for(let s of r)if(s){let[n,a]=s.split("=");n&&this.append(decodeURIComponent(n),a?decodeURIComponent(a):"")}}append(e,r){let s=this.params.get(e)||[];s.push(r),this.params.set(e,s)}delete(e){this.params.delete(e)}get(e){let r=this.params.get(e);return r?r[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,r){this.params.set(e,[r])}sort(){let e=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(e)}toString(){let e=[];for(let[r,s]of this.params.entries())for(let n of s)e.push(`${encodeURIComponent(r)}=${encodeURIComponent(n)}`);return e.join("&")}forEach(e){for(let[r,s]of this.params.entries())for(let n of s)e(n,r,this)}keys(){return this.params.keys()}values(){let e=[];for(let r of this.params.values())e.push(...r);return e[Symbol.iterator]()}entries(){let e=[];for(let[r,s]of this.params.entries())for(let n of s)e.push([r,n]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},rt=class B{constructor(e,r){let s;if(e instanceof B)s=e.href;else if(r){let a=r instanceof B?r.href:r;s=this.resolve(a,e)}else s=e;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 je(n.search),this.hash=n.hash}resolve(e,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(e).protocol}${r}`;if(r.startsWith("/")){let a=this.parseUrl(e);return`${a.protocol}//${a.host}${r}`}let s=this.parseUrl(e),n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${n}${r}`}parseUrl(e){let r=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",n=r[4]||"",a=r[5]||"/",o=r[7]?`?${r[7]}`:"",i=r[9]?`#${r[9]}`:"";if(!s&&!n&&!a.startsWith("/")&&!a.includes("/")&&!a.includes("."))throw new TypeError("Invalid URL");let c=n.match(/^([^@]*)@(.+)$/),l="",u="",h=n;if(c){let m=c[1];h=c[2];let y=m.match(/^([^:]*):?(.*)$/);y&&(l=y[1]||"",u=y[2]||"")}let f=h.match(/^([^:]+):?(\d*)$/),d=f?f[1]:h,p=f&&f[2]?f[2]:"";return{protocol:s?`${s}:`:"",username:l,password:u,host:h,hostname:d,port:p,pathname:a,search:o,hash:i}}toString(){let e=this.searchParams.toString(),r=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};w();var st=class Re{constructor(e,r){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof _?r.headers:new _(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new Re(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};w();var z=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=at(e?.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 t=await this.text();return new TextEncoder().encode(t).buffer}};function at(t){return t?new _(t):new _}w();var Ue=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 t of Array.from(this.listeners))try{t()}catch{}this.listeners.clear()}}addEventListener(t,e){if(this._aborted){try{e()}catch{}return}this.listeners.add(e)}removeEventListener(t,e){this.listeners.delete(e)}toString(){return"[object AbortSignal]"}},nt=class{constructor(){this._signal=new Ue}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};w();function ot(t){t.URL=rt,t.URLSearchParams=je,t.Headers=_,t.Request=st,t.Response=z,t.AbortController=nt,t.AbortSignal=Ue}var Me=class{constructor(t,e,r){this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(v),s=new _(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let n=e?.method||"GET";if((n==="POST"||n==="PUT"||n==="PATCH")&&e?.body){let o=s.get("Content-Type");(!o||o.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};w();var it="/storage",lt=it+"/generateUploadUrl",He=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+lt,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new _({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:n}=await s.json();return{url:n.split("?")[0]}}};w();w();w();var J=Qe(Ze(),1),{PostgrestClient:ut,PostgrestQueryBuilder:dt,PostgrestFilterBuilder:pt,PostgrestTransformBuilder:ft,PostgrestBuilder:mt,PostgrestError:yt}=J.default||J,ct="/entities",Fe=(t,e)=>new ut(t+ct,{fetch:e.fetchWithAuth.bind(e)});w();var De=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
1
+ var Je=Object.create,H=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ve=Object.getOwnPropertyNames,Qe=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty,K=(t,e)=>()=>(t&&(e=t(t=0)),e),S=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Xe=(t,e)=>{for(var r in e)H(t,r,{get:e[r],enumerable:!0})},V=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ve(e))!Ye.call(t,a)&&a!==r&&H(t,a,{get:()=>e[a],enumerable:!(s=Ke(e,a))||s.enumerable});return t},Ze=(t,e,r)=>(r=t!=null?Je(Qe(t)):{},V(e||!t||!t.__esModule?H(r,"default",{value:t,enumerable:!0}):r,t)),L=t=>V(H({},"__esModule",{value:!0}),t),w=K(()=>{"use strict"}),T={};Xe(T,{__addDisposableResource:()=>be,__assign:()=>N,__asyncDelegator:()=>de,__asyncGenerator:()=>he,__asyncValues:()=>pe,__await:()=>A,__awaiter:()=>ne,__classPrivateFieldGet:()=>ge,__classPrivateFieldIn:()=>ve,__classPrivateFieldSet:()=>we,__createBinding:()=>j,__decorate:()=>X,__disposeResources:()=>_e,__esDecorate:()=>ee,__exportStar:()=>ie,__extends:()=>Q,__generator:()=>oe,__importDefault:()=>ye,__importStar:()=>me,__makeTemplateObject:()=>fe,__metadata:()=>ae,__param:()=>Z,__propKey:()=>re,__read:()=>B,__rest:()=>Y,__rewriteRelativeImportExtension:()=>Ee,__runInitializers:()=>te,__setFunctionName:()=>se,__spread:()=>le,__spreadArray:()=>ue,__spreadArrays:()=>ce,__values:()=>M,default:()=>Se});function Q(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");U(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function Y(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(t);a<s.length;a++)e.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(t,s[a])&&(r[s[a]]=t[s[a]]);return r}function X(t,e,r,s){var a=arguments.length,n=a<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,s);else for(var l=t.length-1;l>=0;l--)(o=t[l])&&(n=(a<3?o(n):a>3?o(e,r,n):o(e,r))||n);return a>3&&n&&Object.defineProperty(e,r,n),n}function Z(t,e){return function(r,s){e(r,s,t)}}function ee(t,e,r,s,a,n){function o(g){if(g!==void 0&&typeof g!="function")throw new TypeError("Function expected");return g}for(var l=s.kind,u=l==="getter"?"get":l==="setter"?"set":"value",i=!e&&t?s.static?t:t.prototype:null,c=e||(i?Object.getOwnPropertyDescriptor(i,s.name):{}),h,f=!1,d=r.length-1;d>=0;d--){var p={};for(var m in s)p[m]=m==="access"?{}:s[m];for(var m in s.access)p.access[m]=s.access[m];p.addInitializer=function(g){if(f)throw new TypeError("Cannot add initializers after decoration has completed");n.push(o(g||null))};var y=(0,r[d])(l==="accessor"?{get:c.get,set:c.set}:c[u],p);if(l==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(h=o(y.get))&&(c.get=h),(h=o(y.set))&&(c.set=h),(h=o(y.init))&&a.unshift(h)}else(h=o(y))&&(l==="field"?a.unshift(h):c[u]=h)}i&&Object.defineProperty(i,s.name,c),f=!0}function te(t,e,r){for(var s=arguments.length>2,a=0;a<e.length;a++)r=s?e[a].call(t,r):e[a].call(t);return s?r:void 0}function re(t){return typeof t=="symbol"?t:"".concat(t)}function se(t,e,r){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function ae(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function ne(t,e,r,s){function a(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function l(c){try{i(s.next(c))}catch(h){o(h)}}function u(c){try{i(s.throw(c))}catch(h){o(h)}}function i(c){c.done?n(c.value):a(c.value).then(l,u)}i((s=s.apply(t,e||[])).next())})}function oe(t,e){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},s,a,n,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=l(0),o.throw=l(1),o.return=l(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(i){return function(c){return u([i,c])}}function u(i){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(r=0)),r;)try{if(s=1,a&&(n=i[0]&2?a.return:i[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,i[1])).done)return n;switch(a=0,n&&(i=[i[0]&2,n.value]),i[0]){case 0:case 1:n=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,a=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!n||i[1]>n[0]&&i[1]<n[3])){r.label=i[1];break}if(i[0]===6&&r.label<n[1]){r.label=n[1],n=i;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(i);break}n[2]&&r.ops.pop(),r.trys.pop();continue}i=e.call(t,r)}catch(c){i=[6,c],a=0}finally{s=n=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ie(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&j(e,t,r)}function M(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],s=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function B(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var s=r.call(t),a,n=[],o;try{for(;(e===void 0||e-- >0)&&!(a=s.next()).done;)n.push(a.value)}catch(l){o={error:l}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return n}function le(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(B(arguments[e]));return t}function ce(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var s=Array(t),a=0,e=0;e<r;e++)for(var n=arguments[e],o=0,l=n.length;o<l;o++,a++)s[a]=n[o];return s}function ue(t,e,r){if(r||arguments.length===2)for(var s=0,a=e.length,n;s<a;s++)(n||!(s in e))&&(n||(n=Array.prototype.slice.call(e,0,s)),n[s]=e[s]);return t.concat(n||Array.prototype.slice.call(e))}function A(t){return this instanceof A?(this.v=t,this):new A(t)}function he(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(t,e||[]),a,n=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",o),a[Symbol.asyncIterator]=function(){return this},a;function o(d){return function(p){return Promise.resolve(p).then(d,h)}}function l(d,p){s[d]&&(a[d]=function(m){return new Promise(function(y,g){n.push([d,m,y,g])>1||u(d,m)})},p&&(a[d]=p(a[d])))}function u(d,p){try{i(s[d](p))}catch(m){f(n[0][3],m)}}function i(d){d.value instanceof A?Promise.resolve(d.value.v).then(c,h):f(n[0][2],d)}function c(d){u("next",d)}function h(d){u("throw",d)}function f(d,p){d(p),n.shift(),n.length&&u(n[0][0],n[0][1])}}function de(t){var e,r;return e={},s("next"),s("throw",function(a){throw a}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(a,n){e[a]=t[a]?function(o){return(r=!r)?{value:A(t[a](o)),done:!1}:n?n(o):o}:n}}function pe(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof M=="function"?M(t):t[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(n){r[n]=t[n]&&function(o){return new Promise(function(l,u){o=t[n](o),a(l,u,o.done,o.value)})}}function a(n,o,l,u){Promise.resolve(u).then(function(i){n({value:i,done:l})},o)}}function fe(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function me(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=R(t),s=0;s<r.length;s++)r[s]!=="default"&&j(e,t,r[s]);return Pe(e,t),e}function ye(t){return t&&t.__esModule?t:{default:t}}function ge(t,e,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(t):s?s.value:e.get(t)}function we(t,e,r,s,a){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?a.call(t,r):a?a.value=r:e.set(t,r),r}function ve(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function be(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var s,a;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=e[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose],r&&(a=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");a&&(s=function(){try{a.call(this)}catch(n){return Promise.reject(n)}}),t.stack.push({value:e,dispose:s,async:r})}else r&&t.stack.push({async:!0});return e}function _e(t){function e(n){t.error=t.hasError?new Oe(n,t.error,"An error was suppressed during disposal."):n,t.hasError=!0}var r,s=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&s===1)return s=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var n=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(n).then(a,function(o){return e(o),a()})}else s|=1}catch(o){e(o)}if(s===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}function Ee(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,a,n,o){return s?e?".jsx":".js":a&&(!n||!o)?r:a+n+"."+o.toLowerCase()+"js"}):t}var U,N,j,Pe,R,Oe,Se,I=K(()=>{"use strict";w(),U=function(t,e){return U=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(r[a]=s[a])},U(t,e)},N=function(){return N=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},N.apply(this,arguments)},j=Object.create?(function(t,e,r,s){s===void 0&&(s=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,a)}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]}),Pe=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},R=function(t){return R=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},R(t)},Oe=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Se={__extends:Q,__assign:N,__rest:Y,__decorate:X,__param:Z,__esDecorate:ee,__runInitializers:te,__propKey:re,__setFunctionName:se,__metadata:ae,__awaiter:ne,__generator:oe,__createBinding:j,__exportStar:ie,__values:M,__read:B,__spread:le,__spreadArrays:ce,__spreadArray:ue,__await:A,__asyncGenerator:he,__asyncDelegator:de,__asyncValues:pe,__makeTemplateObject:fe,__importStar:me,__importDefault:ye,__classPrivateFieldGet:ge,__classPrivateFieldSet:we,__classPrivateFieldIn:ve,__addDisposableResource:be,__disposeResources:_e,__rewriteRelativeImportExtension:Ee}}),Te=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};t.default=e}),$e=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(I(),L(T)),r=e.__importDefault(Te()),s=class{constructor(a){var n,o;this.shouldThrowOnError=!1,this.method=a.method,this.url=a.url,this.headers=new Headers(a.headers),this.schema=a.schema,this.body=a.body,this.shouldThrowOnError=(n=a.shouldThrowOnError)!==null&&n!==void 0?n:!1,this.signal=a.signal,this.isMaybeSingle=(o=a.isMaybeSingle)!==null&&o!==void 0?o:!1,a.fetch?this.fetch=a.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(a,n){return this.headers=new Headers(this.headers),this.headers.set(a,n),this}then(a,n){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 o=this.fetch,l=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var i,c,h,f;let d=null,p=null,m=null,y=u.status,g=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")?p=D:p=JSON.parse(D))}let P=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),O=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");P&&O&&O.length>1&&(m=parseInt(O[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(d={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,m=null,y=406,g="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let P=await u.text();try{d=JSON.parse(P),Array.isArray(d)&&u.status===404&&(p=[],d=null,y=200,g="OK")}catch{u.status===404&&P===""?(y=204,g="No Content"):d={message:P}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,y=200,g="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:m,status:y,statusText:g}});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(a,n)}returns(){return this}overrideTypes(){return this}};t.default=s}),Ae=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(I(),L(T)),r=e.__importDefault($e()),s=class extends r.default{select(a){let n=!1,o=(a??"*").split("").map(l=>/\s/.test(l)&&!n?"":(l==='"'&&(n=!n),l)).join("");return this.url.searchParams.set("select",o),this.headers.append("Prefer","return=representation"),this}order(a,{ascending:n=!0,nullsFirst:o,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},`:""}${a}.${n?"asc":"desc"}${o===void 0?"":o?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:n,referencedTable:o=n}={}){let l=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(l,`${a}`),this}range(a,n,{foreignTable:o,referencedTable:l=o}={}){let u=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(u,`${a}`),this.url.searchParams.set(i,`${n-a+1}`),this}abortSignal(a){return this.signal=a,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:a=!1,verbose:n=!1,settings:o=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[a?"analyze":null,n?"verbose":null,o?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),f=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${f}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(a){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${a}`),this}};t.default=s}),W=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(I(),L(T)),r=e.__importDefault(Ae()),s=new RegExp("[,()]"),a=class extends r.default{eq(n,o){return this.url.searchParams.append(n,`eq.${o}`),this}neq(n,o){return this.url.searchParams.append(n,`neq.${o}`),this}gt(n,o){return this.url.searchParams.append(n,`gt.${o}`),this}gte(n,o){return this.url.searchParams.append(n,`gte.${o}`),this}lt(n,o){return this.url.searchParams.append(n,`lt.${o}`),this}lte(n,o){return this.url.searchParams.append(n,`lte.${o}`),this}like(n,o){return this.url.searchParams.append(n,`like.${o}`),this}likeAllOf(n,o){return this.url.searchParams.append(n,`like(all).{${o.join(",")}}`),this}likeAnyOf(n,o){return this.url.searchParams.append(n,`like(any).{${o.join(",")}}`),this}ilike(n,o){return this.url.searchParams.append(n,`ilike.${o}`),this}ilikeAllOf(n,o){return this.url.searchParams.append(n,`ilike(all).{${o.join(",")}}`),this}ilikeAnyOf(n,o){return this.url.searchParams.append(n,`ilike(any).{${o.join(",")}}`),this}is(n,o){return this.url.searchParams.append(n,`is.${o}`),this}in(n,o){let l=Array.from(new Set(o)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(n,`in.(${l})`),this}contains(n,o){return typeof o=="string"?this.url.searchParams.append(n,`cs.${o}`):Array.isArray(o)?this.url.searchParams.append(n,`cs.{${o.join(",")}}`):this.url.searchParams.append(n,`cs.${JSON.stringify(o)}`),this}containedBy(n,o){return typeof o=="string"?this.url.searchParams.append(n,`cd.${o}`):Array.isArray(o)?this.url.searchParams.append(n,`cd.{${o.join(",")}}`):this.url.searchParams.append(n,`cd.${JSON.stringify(o)}`),this}rangeGt(n,o){return this.url.searchParams.append(n,`sr.${o}`),this}rangeGte(n,o){return this.url.searchParams.append(n,`nxl.${o}`),this}rangeLt(n,o){return this.url.searchParams.append(n,`sl.${o}`),this}rangeLte(n,o){return this.url.searchParams.append(n,`nxr.${o}`),this}rangeAdjacent(n,o){return this.url.searchParams.append(n,`adj.${o}`),this}overlaps(n,o){return typeof o=="string"?this.url.searchParams.append(n,`ov.${o}`):this.url.searchParams.append(n,`ov.{${o.join(",")}}`),this}textSearch(n,o,{config:l,type:u}={}){let i="";u==="plain"?i="pl":u==="phrase"?i="ph":u==="websearch"&&(i="w");let c=l===void 0?"":`(${l})`;return this.url.searchParams.append(n,`${i}fts${c}.${o}`),this}match(n){return Object.entries(n).forEach(([o,l])=>{this.url.searchParams.append(o,`eq.${l}`)}),this}not(n,o,l){return this.url.searchParams.append(n,`not.${o}.${l}`),this}or(n,{foreignTable:o,referencedTable:l=o}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${n})`),this}filter(n,o,l){return this.url.searchParams.append(n,`${o}.${l}`),this}};t.default=a}),xe=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(I(),L(T)),r=e.__importDefault(W()),s=class{constructor(a,{headers:n={},schema:o,fetch:l}){this.url=a,this.headers=new Headers(n),this.schema=o,this.fetch=l}select(a,n){let{head:o=!1,count:l}=n??{},u=o?"HEAD":"GET",i=!1,c=(a??"*").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(a,{count:n,defaultToNull:o=!0}={}){var l;let u="POST";if(n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let i=a.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:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(a,{onConflict:n,ignoreDuplicates:o=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${o?"ignore":"merge"}-duplicates`),n!==void 0&&this.url.searchParams.set("on_conflict",n),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let h=a.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(h.length>0){let f=[...new Set(h)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(a,{count:n}={}){var o;let l="PATCH";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}delete({count:a}={}){var n;let o="DELETE";return a&&this.headers.append("Prefer",`count=${a}`),new r.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}};t.default=s}),et=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0});var e=(I(),L(T)),r=e.__importDefault(xe()),s=e.__importDefault(W()),a=class Ce{constructor(o,{headers:l={},schema:u,fetch:i}={}){this.url=o,this.headers=new Headers(l),this.schemaName=u,this.fetch=i}from(o){let l=new URL(`${this.url}/${o}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new Ce(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let f,d=new URL(`${this.url}/rpc/${o}`),p;u||i?(f=u?"HEAD":"GET",Object.entries(l).filter(([y,g])=>g!==void 0).map(([y,g])=>[y,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([y,g])=>{d.searchParams.append(y,g)})):(f="POST",p=l);let m=new Headers(this.headers);return c&&m.set("Prefer",`count=${c}`),new s.default({method:f,url:d,headers:m,schema:this.schemaName,body:p,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};t.default=a}),tt=S(t=>{"use strict";w(),Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;var e=(I(),L(T)),r=e.__importDefault(et());t.PostgrestClient=r.default;var s=e.__importDefault(xe());t.PostgrestQueryBuilder=s.default;var a=e.__importDefault(W());t.PostgrestFilterBuilder=a.default;var n=e.__importDefault(Ae());t.PostgrestTransformBuilder=n.default;var o=e.__importDefault($e());t.PostgrestBuilder=o.default;var l=e.__importDefault(Te());t.PostgrestError=l.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:a.default,PostgrestTransformBuilder:n.default,PostgrestBuilder:o.default,PostgrestError:l.default}});w();w();var Le=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};w();w();var v="nvwa_current_jwt",_="nvwa_login_token",$="nvwa_user_profile",rt="set-auth-token",st=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},Ie=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??st,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get($);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set($,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(v);if(e!=null)return e;let r=await this.storage.get(_),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(v,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let r=e?.headers.get(rt)?.trim()||t.token||t.session?.token;r&&await this.storage.set(_,r),t.user&&await this.storage.set($,t.user);let s=r??await this.storage.get(_),{data:a}=await this.getToken(s??void 0);a?.token&&await this.storage.set(v,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(_),await this.storage.remove($),await this.storage.remove(v))}url(t){let e=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",e),!e.startsWith("http://")&&!e.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),e}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(_)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:t,password:e})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):void 0;return a&&await this.persistLogin({user:a.user,session:a.session},r),{data:a}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(_)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data,e.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let n=await this.storage.get(_)??await this.storage.get(v);n!=null&&(e.Authorization=`Bearer ${n}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):void 0;return{data:a?.token!=null?{token:a.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data,r.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.token||!n.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(v,n.token),await this.storage.set(_,n.token),await this.storage.set($,n.user)),{data:n})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async loginWithAlipayCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}let s=await this.fetchImpl(this.url("alipay/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.token||!n.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(v,n.token),await this.storage.set(_,n.token),await this.storage.set($,n.user)),{data:n})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`wechat/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.openid||!n.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:n}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}let r=t?.trim()?`?applicationCode=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`alipay/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.openid||!n.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:n}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):void 0;return{data:a?.data??a??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};w();w();var E=class Ne{constructor(e){if(this.headerMap=new Map,e){if(e instanceof Ne)e.forEach((r,s)=>this.set(s,r));else if(Array.isArray(e))for(let[r,s]of e)this.set(r,String(s));else if(typeof e=="object")for(let r of Object.keys(e))this.set(r,String(e[r]))}}append(e,r){let s=e.toLowerCase(),a=this.headerMap.get(s);this.headerMap.set(s,a?`${a}, ${r}`:r)}set(e,r){this.headerMap.set(e.toLowerCase(),String(r))}get(e){return this.headerMap.get(e.toLowerCase())??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[r,s]of this.headerMap.entries())e(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},je=class ke{constructor(e){if(this.params=new Map,e){if(typeof e=="string")this.parseString(e);else if(e instanceof ke)this.params=new Map(e.params);else if(Array.isArray(e))for(let[r,s]of e)this.append(r,s);else if(e&&typeof e=="object")for(let[r,s]of Object.entries(e))this.set(r,s)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let r=e.split("&");for(let s of r)if(s){let[a,n]=s.split("=");a&&this.append(decodeURIComponent(a),n?decodeURIComponent(n):"")}}append(e,r){let s=this.params.get(e)||[];s.push(r),this.params.set(e,s)}delete(e){this.params.delete(e)}get(e){let r=this.params.get(e);return r?r[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,r){this.params.set(e,[r])}sort(){let e=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(e)}toString(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push(`${encodeURIComponent(r)}=${encodeURIComponent(a)}`);return e.join("&")}forEach(e){for(let[r,s]of this.params.entries())for(let a of s)e(a,r,this)}keys(){return this.params.keys()}values(){let e=[];for(let r of this.params.values())e.push(...r);return e[Symbol.iterator]()}entries(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push([r,a]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},at=class q{constructor(e,r){let s;if(e instanceof q)s=e.href;else if(r){let n=r instanceof q?r.href:r;s=this.resolve(n,e)}else s=e;let a=this.parseUrl(s);this.href=s,this.origin=`${a.protocol}//${a.host}`,this.protocol=a.protocol,this.username=a.username,this.password=a.password,this.host=a.host,this.hostname=a.hostname,this.port=a.port,this.pathname=a.pathname,this.search=a.search,this.searchParams=new je(a.search),this.hash=a.hash}resolve(e,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(e).protocol}${r}`;if(r.startsWith("/")){let n=this.parseUrl(e);return`${n.protocol}//${n.host}${r}`}let s=this.parseUrl(e),a=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${a}${r}`}parseUrl(e){let r=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",a=r[4]||"",n=r[5]||"/",o=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!a&&!n.startsWith("/")&&!n.includes("/")&&!n.includes("."))throw new TypeError("Invalid URL");let u=a.match(/^([^@]*)@(.+)$/),i="",c="",h=a;if(u){let m=u[1];h=u[2];let y=m.match(/^([^:]*):?(.*)$/);y&&(i=y[1]||"",c=y[2]||"")}let f=h.match(/^([^:]+):?(\d*)$/),d=f?f[1]:h,p=f&&f[2]?f[2]:"";return{protocol:s?`${s}:`:"",username:i,password:c,host:h,hostname:d,port:p,pathname:n,search:o,hash:l}}toString(){let e=this.searchParams.toString(),r=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};w();var nt=class Ue{constructor(e,r){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof E?r.headers:new E(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new Ue(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};w();var z=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=ot(e?.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 t=await this.text();return new TextEncoder().encode(t).buffer}};function ot(t){return t?new E(t):new E}w();var Re=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 t of Array.from(this.listeners))try{t()}catch{}this.listeners.clear()}}addEventListener(t,e){if(this._aborted){try{e()}catch{}return}this.listeners.add(e)}removeEventListener(t,e){this.listeners.delete(e)}toString(){return"[object AbortSignal]"}},it=class{constructor(){this._signal=new Re}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};w();function lt(t){t.URL=at,t.URLSearchParams=je,t.Headers=E,t.Request=nt,t.Response=z,t.AbortController=it,t.AbortSignal=Re}var Me=class{constructor(t,e,r){this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(v),s=new E(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let a=e?.method||"GET";if((a==="POST"||a==="PUT"||a==="PATCH")&&e?.body){let o=s.get("Content-Type");(!o||o.includes("text/plain"))&&s.set("Content-Type","application/json")}let n=await this.customFetch(t,{...e,headers:s});if(n.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return n}};w();var ct="/storage",ut=ct+"/generateUploadUrl",He=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+ut,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new E({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:a}=await s.json();return{url:a.split("?")[0]}}};w();w();w();var J=Ze(tt(),1),{PostgrestClient:ht,PostgrestQueryBuilder:_t,PostgrestFilterBuilder:Et,PostgrestTransformBuilder:Pt,PostgrestBuilder:Ot,PostgrestError:St}=J.default||J,dt="/entities",Fe=(t,e)=>new ht(t+dt,{fetch:e.fetchWithAuth.bind(e)});w();var De=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
2
2
  .__nvwa-inspector-overlay {
3
3
  position: absolute;
4
4
  pointer-events: none;
@@ -30,4 +30,4 @@ var ze=Object.create,H=Object.defineProperty,Ge=Object.getOwnPropertyDescriptor,
30
30
  max-width: 400px;
31
31
  word-break: break-all;
32
32
  }
33
- `,document.head.appendChild(t)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(t){let e=document.createElement("div");return e.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${t}`,document.body.appendChild(e),e}updateOverlayPosition(t,e){if(!e.isConnected)return;let r=e.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,n=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+n}px`,t.style.width=`${r.width}px`,t.style.height=`${r.height}px`,t.style.display="block"):t.style.display="none"}removeOverlay(t){t&&t.parentNode&&t.parentNode.removeChild(t)}highlightElement(t,e){if(!t.isConnected)return;if(this.hoverElement===t&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,t);let o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let i=t.getBoundingClientRect();o.style.left=`${i.left+window.scrollX}px`,o.style.top=`${i.top+window.scrollY-o.offsetHeight-8}px`,i.top<o.offsetHeight+8&&(o.style.top=`${i.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,t),this.hoverOverlay=r,this.hoverElement=t;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let n=this.createTooltip();e?n.textContent=e:n.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,n.style.display="block";let a=t.getBoundingClientRect();n.style.left=`${a.left+window.scrollX}px`,n.style.top=`${a.top+window.scrollY-n.offsetHeight-8}px`,a.top<n.offsetHeight+8&&(n.style.top=`${a.bottom+window.scrollY+8}px`)}selectElement(t,e){if(!t.isConnected)return;if(this.selectedElement===t&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,t);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,t),this.selectedOverlay=r,this.selectedElement=t;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let t=document.getElementById("__nvwa-inspector-overlay-style");t&&t.parentNode&&t.parentNode.removeChild(t)}};function Be(t="root"){if(typeof document>"u")return null;let e=document.getElementById(t)||document.body;if(!e)return null;let r=e.querySelector("[data-source-location]");if(r){let s=r.getAttribute("data-source-location");if(s)return s}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}w();var F=class{constructor(){this.prefix="nvwa_"}getKey(e){return`${this.prefix}${e}`}async get(e){try{let r=this.getKey(e),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(e),null):s.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(e,r,s){try{let n=this.getKey(e),a={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(n,a)}catch(n){throw console.error("UniAppStorageService set error:",n),n}}async remove(e){try{let r=this.getKey(e);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(e){throw console.error("UniAppStorageService clear error:",e),e}}};var k=(t,e)=>{let r;if(typeof t=="string")r=t;else if(t&&typeof t.toString=="function")r=t.toString();else if(t?.url)r=t.url;else throw new Error("Invalid input for uniappFetch");typeof console<"u"&&(console.warn("[NvwaUni] request url:",r,"method:",(e?.method||"GET").toUpperCase()),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaUni] url \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F uni.request \u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 baseUrl \u662F\u5426\u4F20\u5165\u5B8C\u6574\u57DF\u540D"));let s=(e?.method||"GET").toUpperCase(),n={};if(e?.headers){let i=e.headers;if(typeof i?.forEach=="function")i.forEach((c,l)=>{n[l]=c});else if(Array.isArray(i))for(let[c,l]of i)n[c]=l;else Object.assign(n,i)}let a;if(e?.body!==void 0){let i=e.body;if(typeof i=="string")a=i;else if(i&&typeof i=="object"&&typeof i.forEach=="function"){let c={};i.forEach((l,u)=>{c[u]=l}),a=c}else a=i}let o=e?.timeout||3e4;return new Promise((i,c)=>{let l=e?.signal;if(l?.aborted){let d=new Error("The operation was aborted");d.name="AbortError",c(d);return}let u=!1,h=[],f=uni.request({url:r,method:s,data:a,header:n,timeout:o,success:d=>{if(u)return;u=!0;let p=d.statusCode,m="",y=new _,g=d.header||d.headers||{};Object.keys(g).forEach(P=>{let O=g[P];y.set(P,typeof O=="string"?O:String(O))}),i(new z(d.data,{status:p,statusText:m,headers:y}))},fail:d=>{if(u)return;u=!0;let p=d?.errMsg||d?.message||"Network Error",m=new Error(p);/(abort|aborted|canceled|cancelled)/i.test(String(p))&&(m.name="AbortError"),c(m)}});if(l&&typeof l.addEventListener=="function"){let d=()=>{if(u)return;try{f?.abort?.()}catch{}let p=new Error("The operation was aborted");p.name="AbortError",u=!0,c(p)};l.addEventListener("abort",d),h.push(()=>{try{l.removeEventListener?.("abort",d)}catch{}})}})};typeof globalThis.fetch!="function"&&(globalThis.fetch=k);var b="Mobile-web";try{if(typeof uni<"u"&&typeof uni?.getSystemInfoSync=="function"){let t=uni.getSystemInfoSync()??{},e=t.uniPlatform,r=t.osName,s=t.ua??(typeof navigator<"u"?navigator.userAgent:"");e==="mp-weixin"?b="MP-Wechat":e==="mp-alipay"?b="MP-Alipay":e==="app"?r==="ios"?b="IOS":r==="android"?b="Android":r==="harmonyos"&&(b="Harmony"):(e==="web"||e==="h5")&&(b=s&&/MicroMessenger/i.test(s)?"Wechat-H5":"Mobile-web")}else typeof navigator<"u"&&/MicroMessenger/i.test(navigator.userAgent)&&(b="Wechat-H5")}catch{b="Mobile-web"}var qe={async requestPayment(t){let e=t,r=typeof e.tradeNO=="string"?e.tradeNO:void 0;if(r){await new Promise((a,o)=>{let i=globalThis.my;if(!i?.tradePay){o(new Error("requestPayment: my.tradePay is unavailable"));return}i.tradePay({tradeNO:r,success:()=>a(),fail:c=>o(c)})});return}let s=e.jsapiPayParams??e;if(typeof s.timeStamp=="string"&&typeof s.nonceStr=="string"&&typeof s.package=="string"&&typeof s.paySign=="string"){await new Promise((a,o)=>{uni.requestPayment({provider:"wxpay",timeStamp:s.timeStamp,nonceStr:s.nonceStr,package:s.package,signType:s.signType??"RSA",paySign:s.paySign,success:()=>a(),fail:i=>o(i)})});return}if(typeof e.redirectUrl=="string"){typeof window<"u"?window.location.href=e.redirectUrl:globalThis.plus?.runtime?.openURL?.(e.redirectUrl);return}if(typeof e.codeUrl=="string"){let a=`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e.codeUrl)}`;typeof window<"u"?window.open(a,"_blank"):globalThis.plus?.runtime?.openURL?.(a);return}throw new Error("requestPayment: unsupported payParams for current endpoint")}};function Jt(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new De;function r(l){if(!l)return!1;let u=l.toLowerCase();return u.includes("/components/")||u.includes("\\components\\")}function s(l){let u=l,h=null;for(;u;){let f=u.getAttribute("data-source-location");if(f)if(r(f)){h||(h=f),u=u.parentElement;continue}else return f;u=u.parentElement}return h}let n=null;function a(l){t&&(n!==null&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{let u=l.target;if(!u||u===document.body||u===document.documentElement){e.removeHighlight();return}if(u.tagName.toLowerCase()==="img"){let p=s(u);e.highlightElement(u,p);let m={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(m,"*");return}let h=u,f=s(u);if(!f){let p=u.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let m=s(p);if(m){h=p,f=m;break}p=p.parentElement}}e.highlightElement(h,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(d,"*")}))}function o(){if(!t)return;e.removeHighlight();let l={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(l,"*")}function i(l){if(!t)return;l.preventDefault(),l.stopPropagation();let u=l.target;if(!u||u===document.body||u===document.documentElement)return;let h=s(u);e.selectElement(u,h);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:h,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(f,"*")}function c(l){l.data?.type==="HOVER_INSPECTOR_ENABLE"?(t=!0,document.addEventListener("mousemove",a),document.addEventListener("mouseleave",o),document.addEventListener("click",i,!0)):l.data?.type==="HOVER_INSPECTOR_DISABLE"&&(t=!1,document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",o),document.removeEventListener("click",i,!0),e.removeHighlight(),e.clearSelection())}return window.addEventListener("message",c),()=>{window.removeEventListener("message",c),document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",o),document.removeEventListener("click",i,!0),e.cleanup()}}function Kt(t,e){if(!t||!t.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};t.contentWindow.postMessage(r,e)}function Vt(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function Yt(t,e,r=5e3){return new Promise((s,n)=>{if(!t||!t.contentWindow){n(new Error("Invalid iframe element"));return}let a=`source-location-${Date.now()}-${Math.random()}`,o=setTimeout(()=>{window.removeEventListener("message",i),n(new Error("Request timeout"))},r),i=l=>{l.origin===e&&l.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&l.data?.requestId===a&&(clearTimeout(o),window.removeEventListener("message",i),l.data.error?n(new Error(l.data.error)):s(l.data.sourceLocation||null))};window.addEventListener("message",i);let c={type:"GET_SOURCE_LOCATION_REQUEST",requestId:a};try{t.contentWindow.postMessage(c,e)}catch(l){clearTimeout(o),window.removeEventListener("message",i),n(l)}})}function Qt(){if(typeof window>"u"||window===window.parent)return;let t=e=>{if(e.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:ht(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function ht(){return Be("app")}var We=new F,G=class{constructor(e,r){this.payment=qe;this.endpointType=b;typeof console<"u"&&console.warn("[Nvwa] uniapp init baseUrl:",e||"(empty)"),this.auth=new Ie(e,{fetchImpl:k,storage:We}),this.httpClient=new Me(We,k,r),this.fileStorage=new He(e,this.httpClient),this.entities=Fe(e,this.httpClient),this.functions=new Ce(this.httpClient,e)}};export{G as default,Vt as disableIframeHoverInspector,Kt as enableIframeHoverInspector,Yt as getIframeSourceLocation,We as localStorage,ot as polyfill,Jt as setupIframeHoverInspector,Qt as setupIframeSourceLocationListener,k as uniappFetch};
33
+ `,document.head.appendChild(t)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(t){let e=document.createElement("div");return e.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${t}`,document.body.appendChild(e),e}updateOverlayPosition(t,e){if(!e.isConnected)return;let r=e.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,a=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+a}px`,t.style.width=`${r.width}px`,t.style.height=`${r.height}px`,t.style.display="block"):t.style.display="none"}removeOverlay(t){t&&t.parentNode&&t.parentNode.removeChild(t)}highlightElement(t,e){if(!t.isConnected)return;if(this.hoverElement===t&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,t);let o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let l=t.getBoundingClientRect();o.style.left=`${l.left+window.scrollX}px`,o.style.top=`${l.top+window.scrollY-o.offsetHeight-8}px`,l.top<o.offsetHeight+8&&(o.style.top=`${l.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,t),this.hoverOverlay=r,this.hoverElement=t;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let a=this.createTooltip();e?a.textContent=e:a.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let n=t.getBoundingClientRect();a.style.left=`${n.left+window.scrollX}px`,a.style.top=`${n.top+window.scrollY-a.offsetHeight-8}px`,n.top<a.offsetHeight+8&&(a.style.top=`${n.bottom+window.scrollY+8}px`)}selectElement(t,e){if(!t.isConnected)return;if(this.selectedElement===t&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,t);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,t),this.selectedOverlay=r,this.selectedElement=t;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let t=document.getElementById("__nvwa-inspector-overlay-style");t&&t.parentNode&&t.parentNode.removeChild(t)}};function qe(t="root"){if(typeof document>"u")return null;let e=document.getElementById(t)||document.body;if(!e)return null;let r=e.querySelector("[data-source-location]");if(r){let s=r.getAttribute("data-source-location");if(s)return s}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}w();function Be(t){let e=t;if(typeof e.kind=="string")return e;if(typeof e.tradeNO=="string")return{kind:"alipay_miniprogram",tradeNO:e.tradeNO};if(typeof e.clientSecret=="string")return{kind:"stripe_client_secret",clientSecret:e.clientSecret};if(typeof e.redirectUrl=="string")return{kind:"redirect_url",redirectUrl:e.redirectUrl};if(typeof e.formHtml=="string")return{kind:"alipay_page",formHtml:e.formHtml};if(typeof e.codeUrl=="string")return{kind:"wechat_native_qr",codeUrl:e.codeUrl};let r=e.jsapiPayParams??e;return typeof r.timeStamp=="string"&&typeof r.nonceStr=="string"&&typeof r.package=="string"&&typeof r.paySign=="string"&&typeof r.appId=="string"?{kind:"wechat_jsapi",mode:"jsapi",jsapiPayParams:{appId:r.appId,timeStamp:r.timeStamp,nonceStr:r.nonceStr,package:r.package,signType:r.signType??"RSA",paySign:r.paySign}}:null}var F=class{constructor(){this.prefix="nvwa_"}getKey(e){return`${this.prefix}${e}`}async get(e){try{let r=this.getKey(e),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(e),null):s.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(e,r,s){try{let a=this.getKey(e),n={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(a,n)}catch(a){throw console.error("UniAppStorageService set error:",a),a}}async remove(e){try{let r=this.getKey(e);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(e){throw console.error("UniAppStorageService clear error:",e),e}}};var k=(t,e)=>{let r;if(typeof t=="string")r=t;else if(t&&typeof t.toString=="function")r=t.toString();else if(t?.url)r=t.url;else throw new Error("Invalid input for uniappFetch");typeof console<"u"&&(console.warn("[NvwaUni] request url:",r,"method:",(e?.method||"GET").toUpperCase()),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaUni] url \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F uni.request \u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 baseUrl \u662F\u5426\u4F20\u5165\u5B8C\u6574\u57DF\u540D"));let s=(e?.method||"GET").toUpperCase(),a={};if(e?.headers){let l=e.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{a[i]=u});else if(Array.isArray(l))for(let[u,i]of l)a[u]=i;else Object.assign(a,l)}let n;if(e?.body!==void 0){let l=e.body;if(typeof l=="string")n=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),n=u}else n=l}let o=e?.timeout||3e4;return new Promise((l,u)=>{let i=e?.signal;if(i?.aborted){let d=new Error("The operation was aborted");d.name="AbortError",u(d);return}let c=!1,h=[],f=uni.request({url:r,method:s,data:n,header:a,timeout:o,success:d=>{if(c)return;c=!0;let p=d.statusCode,m="",y=new E,g=d.header||d.headers||{};Object.keys(g).forEach(P=>{let O=g[P];y.set(P,typeof O=="string"?O:String(O))}),l(new z(d.data,{status:p,statusText:m,headers:y}))},fail:d=>{if(c)return;c=!0;let p=d?.errMsg||d?.message||"Network Error",m=new Error(p);/(abort|aborted|canceled|cancelled)/i.test(String(p))&&(m.name="AbortError"),u(m)}});if(i&&typeof i.addEventListener=="function"){let d=()=>{if(c)return;try{f?.abort?.()}catch{}let p=new Error("The operation was aborted");p.name="AbortError",c=!0,u(p)};i.addEventListener("abort",d),h.push(()=>{try{i.removeEventListener?.("abort",d)}catch{}})}})};typeof globalThis.fetch!="function"&&(globalThis.fetch=k);var b="Mobile-web";try{if(typeof uni<"u"&&typeof uni?.getSystemInfoSync=="function"){let t=uni.getSystemInfoSync()??{},e=t.uniPlatform,r=t.osName,s=t.ua??(typeof navigator<"u"?navigator.userAgent:"");e==="mp-weixin"?b="MP-Wechat":e==="mp-alipay"?b="MP-Alipay":e==="app"?r==="ios"?b="IOS":r==="android"?b="Android":r==="harmonyos"&&(b="Harmony"):(e==="web"||e==="h5")&&(b=s&&/MicroMessenger/i.test(s)?"Wechat-H5":"Mobile-web")}else typeof navigator<"u"&&/MicroMessenger/i.test(navigator.userAgent)&&(b="Wechat-H5")}catch{b="Mobile-web"}function pt(t){return`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(t)}`}function We(t){if(typeof window<"u"){window.open(t,"_blank");return}globalThis.plus?.runtime?.openURL?.(t)}function ft(t){let e=t,r=`${e?.errMsg??""} ${e?.message??""}`.toLowerCase();return r.includes("cancel")||r.includes("canceled")||r.includes("\u53D6\u6D88")||e?.code==="USER_CANCEL"}async function mt(t){if(t.kind!=="alipay_miniprogram")throw new Error("requestPayment: invalid payParams for alipay miniprogram");await new Promise((e,r)=>{let s=globalThis.my;if(!s?.tradePay){r(new Error("requestPayment: my.tradePay is unavailable"));return}s.tradePay({tradeNO:t.tradeNO,success:()=>e(),fail:a=>r(a)})})}async function yt(t){if(t.kind!=="wechat_jsapi")throw new Error("requestPayment: invalid payParams for wechat jsapi");let e=t.jsapiPayParams;await new Promise((r,s)=>{uni.requestPayment({provider:"wxpay",timeStamp:e.timeStamp,nonceStr:e.nonceStr,package:e.package,signType:e.signType??"RSA",paySign:e.paySign,success:()=>r(),fail:a=>s(a)})})}function gt(t){if(t.kind!=="redirect_url")throw new Error("requestPayment: invalid payParams for redirect");typeof window<"u"?window.location.href=t.redirectUrl:We(t.redirectUrl)}function wt(t){if(t.kind!=="wechat_native_qr")throw new Error("requestPayment: invalid payParams for wechat qr");let e=pt(t.codeUrl);We(e)}async function vt(t){if(!t)return!1;switch(t.kind){case"alipay_miniprogram":return await mt(t),!0;case"wechat_jsapi":return await yt(t),!0;case"redirect_url":return gt(t),!0;case"wechat_native_qr":return wt(t),!0;default:return!1}}var ze={async requestPayment(t,e){try{let r=Be(t);if(!await vt(r))throw new Error("requestPayment: unsupported payParams for current endpoint");e?.onSuccess?.()}catch(r){throw ft(r)?e?.onCancel?.(r):e?.onFailure?.(r),r}}};function sr(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new De;function r(i){if(!i)return!1;let c=i.toLowerCase();return c.includes("/components/")||c.includes("\\components\\")}function s(i){let c=i,h=null;for(;c;){let f=c.getAttribute("data-source-location");if(f)if(r(f)){h||(h=f),c=c.parentElement;continue}else return f;c=c.parentElement}return h}let a=null;function n(i){t&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{let c=i.target;if(!c||c===document.body||c===document.documentElement){e.removeHighlight();return}if(c.tagName.toLowerCase()==="img"){let p=s(c);e.highlightElement(c,p);let m={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(m,"*");return}let h=c,f=s(c);if(!f){let p=c.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let m=s(p);if(m){h=p,f=m;break}p=p.parentElement}}e.highlightElement(h,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(d,"*")}))}function o(){if(!t)return;e.removeHighlight();let i={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(i,"*")}function l(i){if(!t)return;i.preventDefault(),i.stopPropagation();let c=i.target;if(!c||c===document.body||c===document.documentElement)return;let h=s(c);e.selectElement(c,h);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:h,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(f,"*")}function u(i){i.data?.type==="HOVER_INSPECTOR_ENABLE"?(t=!0,document.addEventListener("mousemove",n),document.addEventListener("mouseleave",o),document.addEventListener("click",l,!0)):i.data?.type==="HOVER_INSPECTOR_DISABLE"&&(t=!1,document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",l,!0),e.removeHighlight(),e.clearSelection())}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",l,!0),e.cleanup()}}function ar(t,e){if(!t||!t.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};t.contentWindow.postMessage(r,e)}function nr(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function or(t,e,r=5e3){return new Promise((s,a)=>{if(!t||!t.contentWindow){a(new Error("Invalid iframe element"));return}let n=`source-location-${Date.now()}-${Math.random()}`,o=setTimeout(()=>{window.removeEventListener("message",l),a(new Error("Request timeout"))},r),l=i=>{i.origin===e&&i.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&i.data?.requestId===n&&(clearTimeout(o),window.removeEventListener("message",l),i.data.error?a(new Error(i.data.error)):s(i.data.sourceLocation||null))};window.addEventListener("message",l);let u={type:"GET_SOURCE_LOCATION_REQUEST",requestId:n};try{t.contentWindow.postMessage(u,e)}catch(i){clearTimeout(o),window.removeEventListener("message",l),a(i)}})}function ir(){if(typeof window>"u"||window===window.parent)return;let t=e=>{if(e.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:bt(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function bt(){return qe("app")}var Ge=new F,G=class{constructor(e,r){this.payment=ze;this.endpointType=b;typeof console<"u"&&console.warn("[Nvwa] uniapp init baseUrl:",e||"(empty)"),this.auth=new Ie(e,{fetchImpl:k,storage:Ge}),this.httpClient=new Me(Ge,k,r),this.fileStorage=new He(e,this.httpClient),this.entities=Fe(e,this.httpClient),this.functions=new Le(this.httpClient,e)}};export{G as default,nr as disableIframeHoverInspector,ar as enableIframeHoverInspector,or as getIframeSourceLocation,Ge as localStorage,lt as polyfill,sr as setupIframeHoverInspector,ir as setupIframeSourceLocationListener,k as uniappFetch};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-uniapp",
3
- "version": "6.0.55",
3
+ "version": "6.1.0",
4
4
  "description": "NVWA跨端通用工具类UniApp端实现",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",