import{W as q}from"./util-Di1GNq-L-D-kgTTr0.js";import"./index-xuotMAFm-B-PTrwYx.js";import"./index-69shuAsh-DF18H7zf.js";import"./_commonjsHelpers-B4e78b8K-W3E8ocG7.js";import"./inherits_browser-BPb0V7-q-C7Z2MfVc.js";var p,d;function N(){if(d)return p;d=1;const c=q();class i{constructor(r,e){typeof r=="string"?this.#t(r):e!==void 0?this.#e(r,e):this.#r(r)}toPostgres(){const r=this.values,e=this.indices.map((s,n)=>c.format("%i:%f",s+1,r[n])).join(",");return c.format("{%s}/%d",e,this.dimensions)}toString(){return this.toPostgres()}toArray(){const r=Array(this.dimensions).fill(0);for(const[e,s]of this.indices.entries())r[s]=this.values[e];return r}#t(r){const e=r.split("/",2);this.dimensions=parseInt(e[1]),this.indices=[],this.values=[];const s=e[0].slice(1,-1).split(",");for(const n of s){const o=n.split(":",2);this.indices.push(parseInt(o[0])-1),this.values.push(parseFloat(o[1]))}}#r(r){this.dimensions=r.length,this.indices=[],this.values=[];for(const[e,s]of r.entries()){const n=Number(s);n!=0&&(this.indices.push(Number(e)),this.values.push(n))}}#e(r,e){this.dimensions=Number(e),this.indices=[],this.values=[];const s=r instanceof Map?r.entries():Object.entries(r);for(const[n,o]of s){const a=Number(o);a!=0&&(this.indices.push(Number(n)),this.values.push(a))}}}return p={SparseVector:i},p}var h,S;function A(){if(S)return h;S=1;const c=q(),{SparseVector:i}=N();function l(t){return t===null?null:t.substring(1,t.length-1).split(",").map(u=>parseFloat(u))}function r(t){return Array.isArray(t)?JSON.stringify(t.map(u=>Number(u))):t}const e=l,s=r;function n(t){return t===null?null:new i(t)}function o(t){return t instanceof i?t.toPostgres():t}function a(t){if(t===null)return null;if(t[0]=="[")return l(t);if(t[0]=="{")return n(t);throw new Error("invalid text representation")}function b(t){if(t===null)return null;if(Array.isArray(t))return r(t);if(t instanceof i)return o(t);throw new Error("expected array or sparse vector")}function f(t,u){if(u==null)return t;if(!Number.isInteger(u))throw new Error("expected integer");return c.format("%s(%d)",t,u)}function v(t){return f("vector",t)}function g(t){return f("halfvec",t)}function T(t){return f("bit",t)}function w(t){return f("sparsevec",t)}return h={fromSql:a,toSql:b,vectorFromSql:l,vectorToSql:r,halfvecFromSql:e,halfvecToSql:s,sparsevecFromSql:n,sparsevecToSql:o,sqlType:v,vectorType:v,halfvecType:g,bitType:T,sparsevecType:w,SparseVector:i},h}var m,y;function F(){if(y)return m;y=1;const{fromSql:c,toSql:i,SparseVector:l}=A();return m={fromSql:c,toSql:i,SparseVector:l},m}F();
