@supabase/lite 0.8.0 → 0.8.1-next.1

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/cli/lib.js CHANGED
@@ -1,4 +1,4 @@
1
- import'pgsql-deparser';import*as at from'node:path';import at__default from'node:path';import Ui from'node:os';import ge from'node:fs';import {createClient}from'@supabase/supabase-js';import {ensureVar,App,cloud,splitSqlStatements}from'@supabase/lite';import {createConnection}from'@supabase/lite/sqlite';import*as V from'node:fs/promises';import V__default from'node:fs/promises';import {createHash}from'node:crypto';import {parse}from'dotenv';import'node:url';import*as Ps from'fs';import {statSync,stat,realpathSync,realpath,readdirSync,readdir}from'fs';import {resolve,posix,sep,isAbsolute,basename,dirname,normalize,relative}from'path';import {fileURLToPath}from'url';import {createRequire}from'module';import Cl from'chokidar';try {
1
+ import'pgsql-deparser';import*as ie from'node:path';import ie__default from'node:path';import os from'node:os';import xt from'node:fs';import {createClient}from'@supabase/supabase-js';import {ensureVar,SqliteConnection,App,cloud,splitSqlStatements}from'@supabase/lite';import {createConnection}from'@supabase/lite/sqlite';import*as V from'node:fs/promises';import V__default from'node:fs/promises';import {createHash}from'node:crypto';import'jsonv-ts';import {parse}from'dotenv';import'node:url';import*as no from'fs';import {statSync,stat,realpathSync,realpath,readdirSync,readdir}from'fs';import {resolve,posix,sep,isAbsolute,basename,dirname,normalize,relative}from'path';import {fileURLToPath}from'url';import {createRequire}from'module';import sc from'chokidar';try {
2
2
  /**
3
3
  * Adding this to avoid warnings from node:sqlite being experimental
4
4
  */
@@ -9,41 +9,44 @@ import'pgsql-deparser';import*as at from'node:path';import at__default from'node
9
9
  };
10
10
  } catch {}
11
11
 
12
- var ki=Object.create;var Me=Object.defineProperty;var Li=Object.getOwnPropertyDescriptor;var Pi=Object.getOwnPropertyNames;var Oi=Object.getPrototypeOf,Fi=Object.prototype.hasOwnProperty;var F=(e,t)=>()=>(e&&(t=e(e=0)),t);var bt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ii=(e,t)=>{for(var n in t)Me(e,n,{get:t[n],enumerable:true});},Di=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Pi(t))!Fi.call(e,i)&&i!==n&&Me(e,i,{get:()=>t[i],enumerable:!(r=Li(t,i))||r.enumerable});return e};var Lt=(e,t,n)=>(n=e!=null?ki(Oi(e)):{},Di(Me(n,"default",{value:e,enumerable:true}),e));var Ot=bt((Ec,qe)=>{var Ee=process||{},Gn=Ee.argv||[],Se=Ee.env||{},qi=!(Se.NO_COLOR||Gn.includes("--no-color"))&&(!!Se.FORCE_COLOR||Gn.includes("--color")||Ee.platform==="win32"||(Ee.stdout||{}).isTTY&&Se.TERM!=="dumb"||!!Se.CI),Vi=(e,t,n=e)=>r=>{let i=""+r,s=i.indexOf(t,e.length);return ~s?e+Gi(i,t,n,s)+t:e+i+t},Gi=(e,t,n,r)=>{let i="",s=0;do i+=e.substring(s,r)+n,s=r+t.length,r=e.indexOf(t,s);while(~r);return i+e.substring(s)},Xn=(e=qi)=>{let t=e?Vi:()=>String;return {isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};qe.exports=Xn();qe.exports.createColors=Xn;});var Ht=bt((Nf,wr)=>{var hr="[^\\\\/]",$o="(?=.)",gr="[^/]",on="(?:\\/|$)",yr="(?:^|\\/)",an=`\\.{1,2}${on}`,No="(?!\\.)",vo=`(?!${yr}${an})`,ko=`(?!\\.{0,1}${on})`,Lo=`(?!${an})`,Po="[^.\\/]",Oo=`${gr}*?`,Fo="/",br={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:$o,QMARK:gr,END_ANCHOR:on,DOTS_SLASH:an,NO_DOT:No,NO_DOTS:vo,NO_DOT_SLASH:ko,NO_DOTS_SLASH:Lo,QMARK_NO_DOT:Po,STAR:Oo,START_ANCHOR:yr,SEP:Fo},Io={...br,SLASH_LITERAL:"[\\\\/]",QMARK:hr,STAR:`${hr}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},Do={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};wr.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:Do,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(e){return {"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===true?Io:br}};});var qt=bt(J=>{var{REGEX_BACKSLASH:jo,REGEX_REMOVE_BACKSLASH:Uo,REGEX_SPECIAL_CHARS:Bo,REGEX_SPECIAL_CHARS_GLOBAL:Mo}=Ht();J.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);J.hasRegexChars=e=>Bo.test(e);J.isRegexChar=e=>e.length===1&&J.hasRegexChars(e);J.escapeRegex=e=>e.replace(Mo,"\\$1");J.toPosixSlashes=e=>e.replace(jo,"/");J.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let e=navigator.platform.toLowerCase();return e==="win32"||e==="windows"}return typeof process<"u"&&process.platform?process.platform==="win32":false};J.removeBackslashes=e=>e.replace(Uo,t=>t==="\\"?"":t);J.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?J.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};J.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};J.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",i=n.contains?"":"$",s=`${r}(?:${e})${i}`;return t.negated===true&&(s=`(?:^(?!${s}).*$)`),s};J.basename=(e,{windows:t}={})=>{let n=e.split(t?/[\\/]/:"/"),r=n[n.length-1];return r===""?n[n.length-2]:r};});var Rr=bt((kf,Cr)=>{var xr=qt(),{CHAR_ASTERISK:ln,CHAR_AT:Ho,CHAR_BACKWARD_SLASH:Vt,CHAR_COMMA:qo,CHAR_DOT:cn,CHAR_EXCLAMATION_MARK:un,CHAR_FORWARD_SLASH:Ar,CHAR_LEFT_CURLY_BRACE:fn,CHAR_LEFT_PARENTHESES:pn,CHAR_LEFT_SQUARE_BRACKET:Vo,CHAR_PLUS:Go,CHAR_QUESTION_MARK:Sr,CHAR_RIGHT_CURLY_BRACE:Xo,CHAR_RIGHT_PARENTHESES:Er,CHAR_RIGHT_SQUARE_BRACKET:Wo}=Ht(),Tr=e=>e===Ar||e===Vt,_r=e=>{e.isPrefix!==true&&(e.depth=e.isGlobstar?1/0:1);},zo=(e,t)=>{let n=t||{},r=e.length-1,i=n.parts===true||n.scanToEnd===true,s=[],o=[],a=[],l=e,c=-1,u=0,p=0,h=false,y=false,g=false,E=false,_=false,q=false,S=false,M=false,W=false,O=false,N=0,v,T,C={value:"",depth:0,isGlob:false},m=()=>c>=r,z=()=>l.charCodeAt(c+1),x=()=>(v=T,l.charCodeAt(++c));for(;c<r;){T=x();let P;if(T===Vt){S=C.backslashes=true,T=x(),T===fn&&(q=true);continue}if(q===true||T===fn){for(N++;m()!==true&&(T=x());){if(T===Vt){S=C.backslashes=true,x();continue}if(T===fn){N++;continue}if(q!==true&&T===cn&&(T=x())===cn){if(h=C.isBrace=true,g=C.isGlob=true,O=true,i===true)continue;break}if(q!==true&&T===qo){if(h=C.isBrace=true,g=C.isGlob=true,O=true,i===true)continue;break}if(T===Xo&&(N--,N===0)){q=false,h=C.isBrace=true,O=true;break}}if(i===true)continue;break}if(T===Ar){if(s.push(c),o.push(C),C={value:"",depth:0,isGlob:false},O===true)continue;if(v===cn&&c===u+1){u+=2;continue}p=c+1;continue}if(n.noext!==true&&(T===Go||T===Ho||T===ln||T===Sr||T===un)===true&&z()===pn){if(g=C.isGlob=true,E=C.isExtglob=true,O=true,T===un&&c===u&&(W=true),i===true){for(;m()!==true&&(T=x());){if(T===Vt){S=C.backslashes=true,T=x();continue}if(T===Er){g=C.isGlob=true,O=true;break}}continue}break}if(T===ln){if(v===ln&&(_=C.isGlobstar=true),g=C.isGlob=true,O=true,i===true)continue;break}if(T===Sr){if(g=C.isGlob=true,O=true,i===true)continue;break}if(T===Vo){for(;m()!==true&&(P=x());){if(P===Vt){S=C.backslashes=true,x();continue}if(P===Wo){y=C.isBracket=true,g=C.isGlob=true,O=true;break}}if(i===true)continue;break}if(n.nonegate!==true&&T===un&&c===u){M=C.negated=true,u++;continue}if(n.noparen!==true&&T===pn){if(g=C.isGlob=true,i===true){for(;m()!==true&&(T=x());){if(T===pn){S=C.backslashes=true,T=x();continue}if(T===Er){O=true;break}}continue}break}if(g===true){if(O=true,i===true)continue;break}}n.noext===true&&(E=false,g=false);let L=l,d="",f="";u>0&&(d=l.slice(0,u),l=l.slice(u),p-=u),L&&g===true&&p>0?(L=l.slice(0,p),f=l.slice(p)):g===true?(L="",f=l):L=l,L&&L!==""&&L!=="/"&&L!==l&&Tr(L.charCodeAt(L.length-1))&&(L=L.slice(0,-1)),n.unescape===true&&(f&&(f=xr.removeBackslashes(f)),L&&S===true&&(L=xr.removeBackslashes(L)));let Q={prefix:d,input:e,start:u,base:L,glob:f,isBrace:h,isBracket:y,isGlob:g,isExtglob:E,isGlobstar:_,negated:M,negatedExtglob:W};if(n.tokens===true&&(Q.maxDepth=0,Tr(T)||o.push(C),Q.tokens=o),n.parts===true||n.tokens===true){let P;for(let U=0;U<s.length;U++){let lt=P?P+1:u,Z=s[U],mt=e.slice(lt,Z);n.tokens&&(U===0&&u!==0?(o[U].isPrefix=true,o[U].value=d):o[U].value=mt,_r(o[U]),Q.maxDepth+=o[U].depth),(U!==0||mt!=="")&&a.push(mt),P=Z;}if(P&&P+1<e.length){let U=e.slice(P+1);a.push(U),n.tokens&&(o[o.length-1].value=U,_r(o[o.length-1]),Q.maxDepth+=o[o.length-1].depth);}Q.slashes=s,Q.parts=a;}return Q};Cr.exports=zo;});var Lr=bt((Lf,kr)=>{var Gt=Ht(),Y=qt(),{MAX_LENGTH:Ie,POSIX_REGEX_SOURCE:Ko,REGEX_NON_SPECIAL_CHARS:Jo,REGEX_SPECIAL_CHARS_BACKREF:Yo,REPLACEMENTS:$r}=Gt,Qo=(e,t)=>{if(typeof t.expandRange=="function")return t.expandRange(...e,t);e.sort();let n=`[${e.join("-")}]`;try{new RegExp(n);}catch{return e.map(i=>Y.escapeRegex(i)).join("..")}return n},$t=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,Nr=e=>{let t=[],n=0,r=0,i=0,s="",o=false;for(let a of e){if(o===true){s+=a,o=false;continue}if(a==="\\"){s+=a,o=true;continue}if(a==='"'){i=i===1?0:1,s+=a;continue}if(i===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")r++;else if(a===")"&&r>0)r--;else if(a==="|"&&r===0){t.push(s),s="";continue}}}s+=a;}return t.push(s),t},Zo=e=>{let t=false;for(let n of e){if(t===true){t=false;continue}if(n==="\\"){t=true;continue}if(/[?*+@!()[\]{}]/.test(n))return false}return true},vr=e=>{let t=e.trim(),n=true;for(;n===true;)n=false,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=true);if(Zo(t))return t.replace(/\\(.)/g,"$1")},ta=e=>{let t=e.map(vr).filter(Boolean);for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let i=t[n],s=t[r],o=i[0];if(!(!o||i!==o.repeat(i.length)||s!==o.repeat(s.length))&&(i===s||i.startsWith(s)||s.startsWith(i)))return true}return false},mn=(e,t=true)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,r=0,i=0,s=false;for(let o=1;o<e.length;o++){let a=e[o];if(s===true){s=false;continue}if(a==="\\"){s=true;continue}if(a==='"'){i=i===1?0:1;continue}if(i!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){r++;continue}if(a===")"&&(r--,r===0))return t===true&&o!==e.length-1?void 0:{type:e[0],body:e.slice(2,o),end:o}}}}},ea=e=>{let t=0,n=[];for(;t<e.length;){let i=mn(e.slice(t),false);if(!i||i.type!=="*")return;let s=Nr(i.body).map(a=>a.trim());if(s.length!==1)return;let o=vr(s[0]);if(!o||o.length!==1)return;n.push(o),t+=i.end+1;}return n.length<1?void 0:`${n.length===1?Y.escapeRegex(n[0]):`[${n.map(i=>Y.escapeRegex(i)).join("")}]`}*`},na=e=>{let t=0,n=e.trim(),r=mn(n);for(;r;)t++,n=r.body.trim(),r=mn(n);return t},ra=(e,t)=>{if(t.maxExtglobRecursion===false)return {risky:false};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:Gt.DEFAULT_MAX_EXTGLOB_RECURSION,r=Nr(e).map(i=>i.trim());if(r.length>1&&(r.some(i=>i==="")||r.some(i=>/^[*?]+$/.test(i))||ta(r)))return {risky:true};for(let i of r){let s=ea(i);if(s)return {risky:true,safeOutput:s};if(na(i)>n)return {risky:true}}return {risky:false}},dn=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=$r[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(Ie,n.maxLength):Ie,i=e.length;if(i>r)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},o=[s],a=n.capture?"":"?:",l=Gt.globChars(n.windows),c=Gt.extglobChars(l),{DOT_LITERAL:u,PLUS_LITERAL:p,SLASH_LITERAL:h,ONE_CHAR:y,DOTS_SLASH:g,NO_DOT:E,NO_DOT_SLASH:_,NO_DOTS_SLASH:q,QMARK:S,QMARK_NO_DOT:M,STAR:W,START_ANCHOR:O}=l,N=w=>`(${a}(?:(?!${O}${w.dot?g:u}).)*?)`,v=n.dot?"":E,T=n.dot?S:M,C=n.bash===true?N(n):W;n.capture&&(C=`(${C})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let m={input:e,index:-1,start:0,dot:n.dot===true,consumed:"",output:"",prefix:"",backtrack:false,negated:false,brackets:0,braces:0,parens:0,quotes:0,globstar:false,tokens:o};e=Y.removePrefix(e,m),i=e.length;let z=[],x=[],L=[],d=s,f,Q=()=>m.index===i-1,P=m.peek=(w=1)=>e[m.index+w],U=m.advance=()=>e[++m.index]||"",lt=()=>e.slice(m.index+1),Z=(w="",j=0)=>{m.consumed+=w,m.index+=j;},mt=w=>{m.output+=w.output!=null?w.output:w.value,Z(w.value);},Ni=()=>{let w=1;for(;P()==="!"&&(P(2)!=="("||P(3)==="?");)U(),m.start++,w++;return w%2===0?false:(m.negated=true,m.start++,true)},de=w=>{m[w]++,L.push(w);},dt=w=>{m[w]--,L.pop();},R=w=>{if(d.type==="globstar"){let j=m.braces>0&&(w.type==="comma"||w.type==="brace"),b=w.extglob===true||z.length&&(w.type==="pipe"||w.type==="paren");w.type!=="slash"&&w.type!=="paren"&&!j&&!b&&(m.output=m.output.slice(0,-d.output.length),d.type="star",d.value="*",d.output=C,m.output+=d.output);}if(z.length&&w.type!=="paren"&&(z[z.length-1].inner+=w.value),(w.value||w.output)&&mt(w),d&&d.type==="text"&&w.type==="text"){d.output=(d.output||d.value)+w.value,d.value+=w.value;return}w.prev=d,o.push(w),d=w;},he=(w,j)=>{let b={...c[j],conditions:1,inner:""};b.prev=d,b.parens=m.parens,b.output=m.output,b.startIndex=m.index,b.tokensIndex=o.length;let $=(n.capture?"(":"")+b.open;de("parens"),R({type:w,value:j,output:m.output?"":y}),R({type:"paren",extglob:true,value:U(),output:$}),z.push(b);},vi=w=>{let j=e.slice(w.startIndex,m.index+1),b=e.slice(w.startIndex+2,m.index),$=ra(b,n);if((w.type==="plus"||w.type==="star")&&$.risky){let I=$.safeOutput?(w.output?"":y)+(n.capture?`(${$.safeOutput})`:$.safeOutput):void 0,it=o[w.tokensIndex];it.type="text",it.value=j,it.output=I||Y.escapeRegex(j);for(let st=w.tokensIndex+1;st<o.length;st++)o[st].value="",o[st].output="",delete o[st].suffix;m.output=w.output+it.output,m.backtrack=true,R({type:"paren",extglob:true,value:f,output:""}),dt("parens");return}let D=w.close+(n.capture?")":""),G;if(w.type==="negate"){let I=C;if(w.inner&&w.inner.length>1&&w.inner.includes("/")&&(I=N(n)),(I!==C||Q()||/^\)+$/.test(lt()))&&(D=w.close=`)$))${I}`),w.inner.includes("*")&&(G=lt())&&/^\.[^\\/.]+$/.test(G)){let it=dn(G,{...t,fastpaths:false}).output;D=w.close=`)${it})${I})`;}w.prev.type==="bos"&&(m.negatedExtglob=true);}R({type:"paren",extglob:true,value:f,output:D}),dt("parens");};if(n.fastpaths!==false&&!/(^[*!]|[/()[\]{}"])/.test(e)){let w=false,j=e.replace(Yo,(b,$,D,G,I,it)=>G==="\\"?(w=true,b):G==="?"?$?$+G+(I?S.repeat(I.length):""):it===0?T+(I?S.repeat(I.length):""):S.repeat(D.length):G==="."?u.repeat(D.length):G==="*"?$?$+G+(I?C:""):C:$?b:`\\${b}`);return w===true&&(n.unescape===true?j=j.replace(/\\/g,""):j=j.replace(/\\+/g,b=>b.length%2===0?"\\\\":b?"\\":"")),j===e&&n.contains===true?(m.output=e,m):(m.output=Y.wrapOutput(j,m,t),m)}for(;!Q();){if(f=U(),f==="\0")continue;if(f==="\\"){let b=P();if(b==="/"&&n.bash!==true||b==="."||b===";")continue;if(!b){f+="\\",R({type:"text",value:f});continue}let $=/^\\+/.exec(lt()),D=0;if($&&$[0].length>2&&(D=$[0].length,m.index+=D,D%2!==0&&(f+="\\")),n.unescape===true?f=U():f+=U(),m.brackets===0){R({type:"text",value:f});continue}}if(m.brackets>0&&(f!=="]"||d.value==="["||d.value==="[^")){if(n.posix!==false&&f===":"){let b=d.value.slice(1);if(b.includes("[")&&(d.posix=true,b.includes(":"))){let $=d.value.lastIndexOf("["),D=d.value.slice(0,$),G=d.value.slice($+2),I=Ko[G];if(I){d.value=D+I,m.backtrack=true,U(),!s.output&&o.indexOf(d)===1&&(s.output=y);continue}}}(f==="["&&P()!==":"||f==="-"&&P()==="]")&&(f=`\\${f}`),f==="]"&&(d.value==="["||d.value==="[^")&&(f=`\\${f}`),n.posix===true&&f==="!"&&d.value==="["&&(f="^"),d.value+=f,mt({value:f});continue}if(m.quotes===1&&f!=='"'){f=Y.escapeRegex(f),d.value+=f,mt({value:f});continue}if(f==='"'){m.quotes=m.quotes===1?0:1,n.keepQuotes===true&&R({type:"text",value:f});continue}if(f==="("){de("parens"),R({type:"paren",value:f});continue}if(f===")"){if(m.parens===0&&n.strictBrackets===true)throw new SyntaxError($t("opening","("));let b=z[z.length-1];if(b&&m.parens===b.parens+1){vi(z.pop());continue}R({type:"paren",value:f,output:m.parens?")":"\\)"}),dt("parens");continue}if(f==="["){if(n.nobracket===true||!lt().includes("]")){if(n.nobracket!==true&&n.strictBrackets===true)throw new SyntaxError($t("closing","]"));f=`\\${f}`;}else de("brackets");R({type:"bracket",value:f});continue}if(f==="]"){if(n.nobracket===true||d&&d.type==="bracket"&&d.value.length===1){R({type:"text",value:f,output:`\\${f}`});continue}if(m.brackets===0){if(n.strictBrackets===true)throw new SyntaxError($t("opening","["));R({type:"text",value:f,output:`\\${f}`});continue}dt("brackets");let b=d.value.slice(1);if(d.posix!==true&&b[0]==="^"&&!b.includes("/")&&(f=`/${f}`),d.value+=f,mt({value:f}),n.literalBrackets===false||Y.hasRegexChars(b))continue;let $=Y.escapeRegex(d.value);if(m.output=m.output.slice(0,-d.value.length),n.literalBrackets===true){m.output+=$,d.value=$;continue}d.value=`(${a}${$}|${d.value})`,m.output+=d.value;continue}if(f==="{"&&n.nobrace!==true){de("braces");let b={type:"brace",value:f,output:"(",outputIndex:m.output.length,tokensIndex:m.tokens.length};x.push(b),R(b);continue}if(f==="}"){let b=x[x.length-1];if(n.nobrace===true||!b){R({type:"text",value:f,output:f});continue}let $=")";if(b.dots===true){let D=o.slice(),G=[];for(let I=D.length-1;I>=0&&(o.pop(),D[I].type!=="brace");I--)D[I].type!=="dots"&&G.unshift(D[I].value);$=Qo(G,n),m.backtrack=true;}if(b.comma!==true&&b.dots!==true){let D=m.output.slice(0,b.outputIndex),G=m.tokens.slice(b.tokensIndex);b.value=b.output="\\{",f=$="\\}",m.output=D;for(let I of G)m.output+=I.output||I.value;}R({type:"brace",value:f,output:$}),dt("braces"),x.pop();continue}if(f==="|"){z.length>0&&z[z.length-1].conditions++,R({type:"text",value:f});continue}if(f===","){let b=f,$=x[x.length-1];$&&L[L.length-1]==="braces"&&($.comma=true,b="|"),R({type:"comma",value:f,output:b});continue}if(f==="/"){if(d.type==="dot"&&m.index===m.start+1){m.start=m.index+1,m.consumed="",m.output="",o.pop(),d=s;continue}R({type:"slash",value:f,output:h});continue}if(f==="."){if(m.braces>0&&d.type==="dot"){d.value==="."&&(d.output=u);let b=x[x.length-1];d.type="dots",d.output+=f,d.value+=f,b.dots=true;continue}if(m.braces+m.parens===0&&d.type!=="bos"&&d.type!=="slash"){R({type:"text",value:f,output:u});continue}R({type:"dot",value:f,output:u});continue}if(f==="?"){if(!(d&&d.value==="(")&&n.noextglob!==true&&P()==="("&&P(2)!=="?"){he("qmark",f);continue}if(d&&d.type==="paren"){let $=P(),D=f;(d.value==="("&&!/[!=<:]/.test($)||$==="<"&&!/<([!=]|\w+>)/.test(lt()))&&(D=`\\${f}`),R({type:"text",value:f,output:D});continue}if(n.dot!==true&&(d.type==="slash"||d.type==="bos")){R({type:"qmark",value:f,output:M});continue}R({type:"qmark",value:f,output:S});continue}if(f==="!"){if(n.noextglob!==true&&P()==="("&&(P(2)!=="?"||!/[!=<:]/.test(P(3)))){he("negate",f);continue}if(n.nonegate!==true&&m.index===0){Ni();continue}}if(f==="+"){if(n.noextglob!==true&&P()==="("&&P(2)!=="?"){he("plus",f);continue}if(d&&d.value==="("||n.regex===false){R({type:"plus",value:f,output:p});continue}if(d&&(d.type==="bracket"||d.type==="paren"||d.type==="brace")||m.parens>0){R({type:"plus",value:f});continue}R({type:"plus",value:p});continue}if(f==="@"){if(n.noextglob!==true&&P()==="("&&P(2)!=="?"){R({type:"at",extglob:true,value:f,output:""});continue}R({type:"text",value:f});continue}if(f!=="*"){(f==="$"||f==="^")&&(f=`\\${f}`);let b=Jo.exec(lt());b&&(f+=b[0],m.index+=b[0].length),R({type:"text",value:f});continue}if(d&&(d.type==="globstar"||d.star===true)){d.type="star",d.star=true,d.value+=f,d.output=C,m.backtrack=true,m.globstar=true,Z(f);continue}let w=lt();if(n.noextglob!==true&&/^\([^?]/.test(w)){he("star",f);continue}if(d.type==="star"){if(n.noglobstar===true){Z(f);continue}let b=d.prev,$=b.prev,D=b.type==="slash"||b.type==="bos",G=$&&($.type==="star"||$.type==="globstar");if(n.bash===true&&(!D||w[0]&&w[0]!=="/")){R({type:"star",value:f,output:""});continue}let I=m.braces>0&&(b.type==="comma"||b.type==="brace"),it=z.length&&(b.type==="pipe"||b.type==="paren");if(!D&&b.type!=="paren"&&!I&&!it){R({type:"star",value:f,output:""});continue}for(;w.slice(0,3)==="/**";){let st=e[m.index+4];if(st&&st!=="/")break;w=w.slice(3),Z("/**",3);}if(b.type==="bos"&&Q()){d.type="globstar",d.value+=f,d.output=N(n),m.output=d.output,m.globstar=true,Z(f);continue}if(b.type==="slash"&&b.prev.type!=="bos"&&!G&&Q()){m.output=m.output.slice(0,-(b.output+d.output).length),b.output=`(?:${b.output}`,d.type="globstar",d.output=N(n)+(n.strictSlashes?")":"|$)"),d.value+=f,m.globstar=true,m.output+=b.output+d.output,Z(f);continue}if(b.type==="slash"&&b.prev.type!=="bos"&&w[0]==="/"){let st=w[1]!==void 0?"|$":"";m.output=m.output.slice(0,-(b.output+d.output).length),b.output=`(?:${b.output}`,d.type="globstar",d.output=`${N(n)}${h}|${h}${st})`,d.value+=f,m.output+=b.output+d.output,m.globstar=true,Z(f+U()),R({type:"slash",value:"/",output:""});continue}if(b.type==="bos"&&w[0]==="/"){d.type="globstar",d.value+=f,d.output=`(?:^|${h}|${N(n)}${h})`,m.output=d.output,m.globstar=true,Z(f+U()),R({type:"slash",value:"/",output:""});continue}m.output=m.output.slice(0,-d.output.length),d.type="globstar",d.output=N(n),d.value+=f,m.output+=d.output,m.globstar=true,Z(f);continue}let j={type:"star",value:f,output:C};if(n.bash===true){j.output=".*?",(d.type==="bos"||d.type==="slash")&&(j.output=v+j.output),R(j);continue}if(d&&(d.type==="bracket"||d.type==="paren")&&n.regex===true){j.output=f,R(j);continue}(m.index===m.start||d.type==="slash"||d.type==="dot")&&(d.type==="dot"?(m.output+=_,d.output+=_):n.dot===true?(m.output+=q,d.output+=q):(m.output+=v,d.output+=v),P()!=="*"&&(m.output+=y,d.output+=y)),R(j);}for(;m.brackets>0;){if(n.strictBrackets===true)throw new SyntaxError($t("closing","]"));m.output=Y.escapeLast(m.output,"["),dt("brackets");}for(;m.parens>0;){if(n.strictBrackets===true)throw new SyntaxError($t("closing",")"));m.output=Y.escapeLast(m.output,"("),dt("parens");}for(;m.braces>0;){if(n.strictBrackets===true)throw new SyntaxError($t("closing","}"));m.output=Y.escapeLast(m.output,"{"),dt("braces");}if(n.strictSlashes!==true&&(d.type==="star"||d.type==="bracket")&&R({type:"maybe_slash",value:"",output:`${h}?`}),m.backtrack===true){m.output="";for(let w of m.tokens)m.output+=w.output!=null?w.output:w.value,w.suffix&&(m.output+=w.suffix);}return m};dn.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(Ie,n.maxLength):Ie,i=e.length;if(i>r)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${r}`);e=$r[e]||e;let{DOT_LITERAL:s,SLASH_LITERAL:o,ONE_CHAR:a,DOTS_SLASH:l,NO_DOT:c,NO_DOTS:u,NO_DOTS_SLASH:p,STAR:h,START_ANCHOR:y}=Gt.globChars(n.windows),g=n.dot?u:c,E=n.dot?p:c,_=n.capture?"":"?:",q={negated:false,prefix:""},S=n.bash===true?".*?":h;n.capture&&(S=`(${S})`);let M=v=>v.noglobstar===true?S:`(${_}(?:(?!${y}${v.dot?l:s}).)*?)`,W=v=>{switch(v){case "*":return `${g}${a}${S}`;case ".*":return `${s}${a}${S}`;case "*.*":return `${g}${S}${s}${a}${S}`;case "*/*":return `${g}${S}${o}${a}${E}${S}`;case "**":return g+M(n);case "**/*":return `(?:${g}${M(n)}${o})?${E}${a}${S}`;case "**/*.*":return `(?:${g}${M(n)}${o})?${E}${S}${s}${a}${S}`;case "**/.*":return `(?:${g}${M(n)}${o})?${s}${a}${S}`;default:{let T=/^(.*?)\.(\w+)$/.exec(v);if(!T)return;let C=W(T[1]);return C?C+s+T[2]:void 0}}},O=Y.removePrefix(e,q),N=W(O);return N&&n.strictSlashes!==true&&(N+=`${o}?`),N};kr.exports=dn;});var Fr=bt((Pf,Or)=>{var ia=Rr(),hn=Lr(),Pr=qt(),sa=Ht(),oa=e=>e&&typeof e=="object"&&!Array.isArray(e),H=(e,t,n=false)=>{if(Array.isArray(e)){let u=e.map(h=>H(h,t,n));return h=>{for(let y of u){let g=y(h);if(g)return g}return false}}let r=oa(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let i=t||{},s=i.windows,o=r?H.compileRe(e,t):H.makeRe(e,t,false,true),a=o.state;delete o.state;let l=()=>false;if(i.ignore){let u={...t,ignore:null,onMatch:null,onResult:null};l=H(i.ignore,u,n);}let c=(u,p=false)=>{let{isMatch:h,match:y,output:g}=H.test(u,o,t,{glob:e,posix:s}),E={glob:e,state:a,regex:o,posix:s,input:u,output:g,match:y,isMatch:h};return typeof i.onResult=="function"&&i.onResult(E),h===false?(E.isMatch=false,p?E:false):l(u)?(typeof i.onIgnore=="function"&&i.onIgnore(E),E.isMatch=false,p?E:false):(typeof i.onMatch=="function"&&i.onMatch(E),p?E:true)};return n&&(c.state=a),c};H.test=(e,t,n,{glob:r,posix:i}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return {isMatch:false,output:""};let s=n||{},o=s.format||(i?Pr.toPosixSlashes:null),a=e===r,l=a&&o?o(e):e;return a===false&&(l=o?o(e):e,a=l===r),(a===false||s.capture===true)&&(s.matchBase===true||s.basename===true?a=H.matchBase(e,t,n,i):a=t.exec(l)),{isMatch:!!a,match:a,output:l}};H.matchBase=(e,t,n)=>(t instanceof RegExp?t:H.makeRe(t,n)).test(Pr.basename(e));H.isMatch=(e,t,n)=>H(t,n)(e);H.parse=(e,t)=>Array.isArray(e)?e.map(n=>H.parse(n,t)):hn(e,{...t,fastpaths:false});H.scan=(e,t)=>ia(e,t);H.compileRe=(e,t,n=false,r=false)=>{if(n===true)return e.output;let i=t||{},s=i.contains?"":"^",o=i.contains?"":"$",a=`${s}(?:${e.output})${o}`;e&&e.negated===true&&(a=`^(?!${a}).*$`);let l=H.toRegex(a,t);return r===true&&(l.state=e),l};H.makeRe=(e,t={},n=false,r=false)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let i={negated:false,fastpaths:true};return t.fastpaths!==false&&(e[0]==="."||e[0]==="*")&&(i.output=hn.fastpaths(e,t)),i.output||(i=hn(e,t)),H.compileRe(i,t,n,r)};H.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?"i":""))}catch(n){if(t&&t.debug===true)throw n;return /$^/}};H.constants=sa;Or.exports=H;});var Ur=bt((Of,jr)=>{var Ir=Fr(),aa=qt();function Dr(e,t,n=false){return t&&(t.windows===null||t.windows===void 0)&&(t={...t,windows:aa.isWindows()}),Ir(e,t,n)}Object.assign(Dr,Ir);jr.exports=Dr;});function Jt(e){if("String"in e)return e.String.sval}function gt(e){return e.map(Jt).filter(t=>t!=null)}function Zr(e){return Object.keys(e)[0]}function ti(e){if("A_Const"in e){if(e.A_Const.ival)return e.A_Const.ival.ival;if(e.A_Const.fval)return e.A_Const.fval.fval;if(e.A_Const.sval)return e.A_Const.sval.sval;if(e.A_Const.boolval)return e.A_Const.boolval.boolval;if(e.A_Const.isnull)return null}}var De=F(()=>{});function ei(e){let t=e.toLowerCase();return ["serial","serial4","bigserial","serial8","smallserial","serial2"].includes(t)}function ni(e){let t=e.toLowerCase();return ["varchar","character varying","char","character","bpchar"].includes(t)}function ri(e){let t=e.toLowerCase();return ["numeric","decimal"].includes(t)}var xn,je,za,Sn=F(()=>{De();xn=class extends Error{},je=class extends xn{constructor(n,r){super(r??`Unsupported node type: ${Zr(n)}`);this.node=n;}};za={CreateEnumStmt:{react:"ignore"},CreateDomainStmt:{react:"warn"},CreateSeqStmt:{react:"ignore"},AlterSeqStmt:{react:"ignore"},CreateSchemaStmt:{react:"warn"},CreatePolicyStmt:{react:"ignore"},AlterPolicyStmt:{react:"ignore"},PartitionElem:{react:"error"},PartitionCmd:{react:"error"},VariableSetStmt:{react:"ignore"},CompositeTypeStmt:{react:"error"},AlterEnumStmt:{react:"error"},AlterObjectSchemaStmt:{react:"error"},AlterOwnerStmt:{react:"error"},AlterTypeStmt:{react:"error"},AlterFunctionStmt:{react:"error"},AlterDefaultPrivilegesStmt:{react:"error"},GrantStmt:{react:"error"},GrantRoleStmt:{react:"error"},CopyStmt:{react:"error"},CreateCastStmt:{react:"error"},AlterOpFamilyStmt:{react:"error"},AlterOperatorStmt:{react:"error"},TruncateStmt:{react:"error"},A_Indirection:{react:"error"},XmlExpr:{react:"error"},XmlSerialize:{react:"error"},RangeTableSample:{react:"error"},GroupingSet:{react:"error"}},new Map(Object.entries(za));});var tt,Ue,ii=F(()=>{De();Sn();tt=class extends je{constructor(t,n){super(t,`Unsupported expression: ${n}`);}},Ue=class{deparse(t){if("A_Const"in t){let i=t.A_Const;if(i.boolval!==void 0)return i.boolval.boolval?{}:{$always:false}}let n=Object.keys(t)[0],r=this[n];if(!r)throw new tt({[n]:t},`Unsupported expression: ${n}`);return r.call(this,t[n])}deparseValue(t){if("A_Const"in t)return this.A_Const(t.A_Const);if("ColumnRef"in t)return this.ColumnRef(t.ColumnRef);if("FuncCall"in t)return this.FuncCall(t.FuncCall);if("SubLink"in t)return this.SubLink(t.SubLink);if("TypeCast"in t)return this.TypeCast(t.TypeCast);if("A_Expr"in t){let r=this.isJwtAccessor(t.A_Expr);return r||this.A_Expr(t.A_Expr)}if("BoolExpr"in t)return this.BoolExpr(t.BoolExpr);let n=Object.keys(t)[0];throw new tt({[n]:t},`deparseValue: ${n}`)}A_Expr(t){if(t.kind==="AEXPR_OP"){let n=t.name?.[0],r=n?Jt(n):void 0;if(!r)throw new tt({A_Expr:t},"A_Expr missing operator");let i=this.isJwtAccessor(t);if(i)return {[i]:{}};let s=t.lexpr?this.deparseValue(t.lexpr):void 0,o=t.rexpr?this.deparseValue(t.rexpr):void 0,a=this.mapOperator(r);if(!a)throw new tt({A_Expr:t},`Unsupported operator: ${r}`);let l=t.rexpr!=null&&"ColumnRef"in t.rexpr;if(typeof s=="string"&&s.startsWith("{{")&&l)return {[o]:{[a]:s}};let c=l&&typeof o=="string"?{$ref:o}:o;return {[s]:{[a]:c}}}if(t.kind==="AEXPR_LIKE"||t.kind==="AEXPR_ILIKE"){let n=t.lexpr?this.deparseValue(t.lexpr):void 0,r=t.rexpr?this.deparseValue(t.rexpr):void 0,s=(t.name?.[0]?Jt(t.name[0]):"~~")==="!~~"?"$notLike":"$like";return {[n]:{[s]:r}}}if(t.kind==="AEXPR_IN"){let n=t.lexpr?this.deparseValue(t.lexpr):void 0,r=t.rexpr&&"List"in t.rexpr&&t.rexpr.List.items?t.rexpr.List.items.map(i=>this.deparseValue(i)):[];return {[n]:{$in:r}}}throw new tt({A_Expr:t},`A_Expr kind: ${t.kind}`)}BoolExpr(t){let n=t.args??[];switch(t.boolop){case "AND_EXPR":return {$and:n.map(r=>this.deparse(r))};case "OR_EXPR":return {$or:n.map(r=>this.deparse(r))};case "NOT_EXPR":return {$not:this.deparse(n[0])};default:throw new tt({BoolExpr:t},`BoolExpr op: ${t.boolop}`)}}NullTest(t){let n=t.arg?this.deparseValue(t.arg):void 0;return t.nulltesttype==="IS_NULL"?{[n]:{$is:null}}:{[n]:{$isNot:null}}}SubLink(t){if(t.subLinkType==="ANY_SUBLINK"){let n=t.testexpr?this.deparseValue(t.testexpr):void 0,r=t.subselect?this.SelectStmt(t.subselect.SelectStmt):void 0;return {[n]:{$in:r}}}if(t.subLinkType==="EXISTS_SUBLINK")return {$exists:t.subselect?this.SelectStmt(t.subselect.SelectStmt):void 0};if(t.subLinkType==="EXPR_SUBLINK"){let n=t.subselect?t.subselect.SelectStmt:void 0;if(n?.fromClause?.length)return this.SelectStmt(n);if(n?.targetList?.[0]){let r=n.targetList[0],i="ResTarget"in r?r.ResTarget:void 0;if(i?.val){let s=this.deparseValue(i.val);return s}}}throw new tt({SubLink:t},`SubLink type: ${t.subLinkType}`)}SelectStmt(t){let{from:n,schema:r,join:i}=this.deparseFromClause(t.fromClause??[]),s=[];for(let h of t.targetList??[]){let y="ResTarget"in h?h.ResTarget:void 0;if(y?.val){let g=this.deparseValue(y.val);Array.isArray(g)?s.push(...g.map(String)):g!=null&&g!==""&&s.push(String(g));}}let o=t.whereClause?this.deparse(t.whereClause):void 0,a=this.deparseSortClause(t.sortClause),l=this.deparseLimit(t.limitCount),c=this.deparseLimit(t.limitOffset),u=this.deparseGroupClause(t.groupClause),p={type:"query",from:n,select:s};return r&&(p.schema=r),Object.keys(i).length>0&&(p.join=i),o&&(p.where=o),a.length>0&&(p.order=a),l!==void 0&&(p.limit=l),c!==void 0&&(p.offset=c),u.length>0&&(p.group=u),p}FuncCall(t){let n=this.isAuthFunc(t.funcname??[]);if(n)return n;throw new tt({FuncCall:t},`FuncCall: ${gt(t.funcname??[]).join(".")}`)}ColumnRef(t){let n=gt(t.fields??[]);return n.length===1?n[0]:n.join(".")}A_Const(t){if(t.boolval!==void 0)return t.boolval.boolval;if(t.ival!==void 0)return t.ival.ival??0;if(t.fval!==void 0)return parseFloat(t.fval.fval??"0");if(t.sval!==void 0)return t.sval.sval??"";if(t.isnull)return null;throw new tt({A_Const:t},"A_Const: unknown variant")}TypeCast(t){if(!t.arg)throw new tt({TypeCast:t},"TypeCast: missing arg");return this.deparseValue(t.arg)}BooleanTest(t){let n=t.arg?this.deparseValue(t.arg):void 0;return t.booltesttype==="IS_TRUE"?{[n]:{$eq:true}}:{[n]:{$eq:false}}}deparseFromClause(t){let n={};if(t.length===0)return {from:"",join:n};let r=t[0];if("RangeVar"in r){let i=r.RangeVar;return {from:i.relname??"",schema:i.schemaname,join:n}}if("JoinExpr"in r){let{from:i,schema:s}=this.walkJoinExpr(r.JoinExpr,n);return {from:i,schema:s,join:n}}return {from:"",join:n}}walkJoinExpr(t,n){let r={from:""};if(t.larg)if("RangeVar"in t.larg){let i=t.larg.RangeVar;r={from:i.relname??"",schema:i.schemaname};}else "JoinExpr"in t.larg&&(r=this.walkJoinExpr(t.larg.JoinExpr,n));if(t.rarg&&"RangeVar"in t.rarg){let i=t.rarg.RangeVar,s=i.relname??"",o=i.alias?.aliasname??s,a=t.jointype==="JOIN_LEFT"?"left":"inner",l={from:s,type:a};t.quals&&(l.on=this.deparse(t.quals));let c=o;if(c in n){let u=2;for(;`${c}_${u}`in n;)u++;c=`${c}_${u}`;}n[c]=l;}return r}deparseSortClause(t){if(!t)return [];let n=[];for(let r of t){if(!("SortBy"in r))continue;let i=r.SortBy;if(!i.node)continue;let s=String(this.deparseValue(i.node)),o=i.sortby_dir==="SORTBY_DESC"?"desc":"asc",a={column:s,direction:o};i.sortby_nulls==="SORTBY_NULLS_FIRST"?a.nullsFirst=true:i.sortby_nulls==="SORTBY_NULLS_LAST"&&(a.nullsFirst=false),n.push(a);}return n}deparseLimit(t){if(!t)return;let n=this.deparseValue(t);return typeof n=="number"?n:Number(n)}deparseGroupClause(t){return t?t.map(n=>String(this.deparseValue(n))):[]}isAuthFunc(t){let n=gt(t);if(n.length===2&&n[0]==="auth"){if(n[1]==="uid")return "{{auth.uid}}";if(n[1]==="jwt")return "{{auth.jwt}}";if(n[1]==="role")return "{{auth.role}}";throw new Error(`Unsupported auth function: "${n.slice(1).join(".")}"`)}return null}isJwtAccessor(t){if(t.kind!=="AEXPR_OP")return null;let n=t.name?.[0]?Jt(t.name[0]):void 0;if(n!=="->"&&n!=="->>")return null;let r=t.rexpr&&"A_Const"in t.rexpr?t.rexpr.A_Const.sval?.sval:void 0;if(r===void 0)return null;if(t.lexpr&&"FuncCall"in t.lexpr)return this.isAuthFunc(t.lexpr.FuncCall.funcname??[])==="{{auth.jwt}}"?`{{auth.jwt.${r}}}`:null;if(t.lexpr&&"A_Expr"in t.lexpr){let i=this.isJwtAccessor(t.lexpr.A_Expr);if(i)return `${i.slice(0,-2)}.${r}}}`}return null}mapOperator(t){switch(t){case "=":return "$eq";case "<>":case "!=":return "$neq";case ">":return "$gt";case ">=":return "$gte";case "<":return "$lt";case "<=":return "$lte";case "~~":return "$like";case "!~~":return "$notLike";default:return}}};});var vt,si=F(()=>{vt=class e{constructor(t){this.data=t;}appliesTo(t){return this.data.command==="ALL"||this.data.command===t}appliesToRole(t){return this.data.roles.length===0||this.data.roles.includes(t)}toJSON(){return this.data}static fromJSON(t){return new e(t)}};});var Yt,En=F(()=>{Yt=class extends Error{constructor(n,r,i,s){super(`check constraint "${i}" violated for ${n}.${r}`);this.table=n;this.column=r;this.constraint=i;this.value=s;this.name="CheckConstraintError";}};});var X,pt=F(()=>{En();X=class{context;constructor(t){this.context=t;}get isShimBacked(){return false}checkConstraint(){return null}serialize(t){return t}deserialize(t){return t}validateStorage(t){return {status:"pass",message:null}}validationFail(t,n){return {status:"fail",message:t,action:n}}validationPass(){return {status:"pass",message:null}}isNullish(t){return t==null}toColumnDDL(t){let{includeNullable:n=true}=t??{},r=[],i=this.context.column;r.push(this.quoteIfNeeded(i)),r.push(this.sqliteType),this.context.isPrimaryKey&&r.push("PRIMARY KEY"),this.context.isSerial&&this.context.isPrimaryKey&&r.push("AUTOINCREMENT"),n&&!this.context.nullable&&!this.context.isPrimaryKey&&r.push("NOT NULL"),this.context.isUnique&&!this.context.isPrimaryKey&&r.push("UNIQUE"),this.context.defaultValue!==null&&r.push(`DEFAULT ${this.context.defaultValue}`);let s=this.checkConstraint();return s&&r.push(`CHECK (${s})`),r.join(" ")}checkError(t,n){return new Yt(this.context.table,this.context.column,t,n)}quoteIfNeeded(t){return /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)?t:`"${t}"`}};});var Tt,Be=F(()=>{pt();Tt=class extends X{get sqliteType(){return "INTEGER"}};});var Qt,Tn=F(()=>{Be();Qt=class extends Tt{constructor(t){super({...t,isSerial:true});}};});function Ka(e,t){let{precision:n,scale:r}=t,i=10**r,s=10**(n-r);return Math.abs(Math.round(e*i)-e*i)<1e-4&&Math.abs(e)<s}var Zt,_n=F(()=>{pt();Zt=class extends X{numericPrecision;constructor(t,n){super(t),this.numericPrecision=n;}get isShimBacked(){return this.numericPrecision!==void 0}get sqliteType(){return "REAL"}checkConstraint(){if(this.numericPrecision){let{precision:t,scale:n}=this.numericPrecision,r=this.context.column,i=10**n,s=10**(t-n);return `ABS(ROUND(${r} * ${i}) - ${r} * ${i}) < 0.0001 AND ABS(${r}) < ${s}`}return null}validateStorage(t){if(this.isNullish(t))return this.validationPass();if(typeof t!="number"||!Number.isFinite(t))return this.validationFail("Expected finite number.","Patch rows with finite numbers.");if(this.numericPrecision){let{precision:n,scale:r}=this.numericPrecision;if(!Ka(t,this.numericPrecision))return this.validationFail(`Does not fit numeric(${n}, ${r}).`,"Patch rows within numeric precision.")}return this.validationPass()}};});var B,nt=F(()=>{pt();B=class extends X{lengthConstraint;constructor(t,n){super(t),this.lengthConstraint=n;}get isShimBacked(){return this.lengthConstraint!==void 0}get sqliteType(){return "TEXT"}checkConstraint(){return this.lengthConstraint!==void 0?`length(${this.context.column}) <= ${this.lengthConstraint}`:null}validateStorage(t){return this.isNullish(t)?this.validationPass():typeof t!="string"?this.validationFail("Expected text.","Patch rows with text values."):this.lengthConstraint!==void 0&&Array.from(t).length>this.lengthConstraint?this.validationFail(`Exceeds length ${this.lengthConstraint}.`,"Patch rows with shorter text."):this.validationPass()}};});var te,An=F(()=>{pt();te=class extends X{get sqliteType(){return "BLOB"}};});var ee,Cn=F(()=>{pt();ee=class extends X{get isShimBacked(){return true}get sqliteType(){return "INTEGER"}checkConstraint(){return `${this.context.column} IN (0, 1)`}serialize(t){if(this.isNullish(t))return t;if(t===true||t===1)return 1;if(t===false||t===0)return 0;throw this.checkError("boolean_range",t)}deserialize(t){if(this.isNullish(t)||t===true||t===false)return t;if(typeof t=="number"&&Number.isFinite(t)){if(t===1)return true;if(t===0)return false}return t===1n?true:t===0n?false:t==="1"||t==="true"?true:t==="0"||t==="false"?false:t}validateStorage(t){return this.isNullish(t)?this.validationPass():t===1||t===0?this.validationPass():this.validationFail("Expected 0 or 1.","Patch rows with boolean values.")}};});function oi(e){try{return {ok:!0,value:JSON.parse(e)}}catch{return {ok:false}}}var ne,Rn=F(()=>{pt();ne=class extends X{get isShimBacked(){return true}get sqliteType(){return "TEXT"}checkConstraint(){let t=this.context.column;return `${t} IS NULL OR json_valid(${t})`}serialize(t){if(this.isNullish(t))return t;try{return JSON.stringify(t)}catch{throw this.checkError("json_valid",t)}}deserialize(t){if(this.isNullish(t))return t;if(typeof t=="string"){let n=oi(t);return n.ok?n.value:t}return t}validateStorage(t){return this.isNullish(t)?this.validationPass():typeof t!="string"?this.validationFail("Expected JSON text.","Patch rows with JSON values."):oi(t).ok?this.validationPass():this.validationFail("Invalid JSON text.","Patch rows with valid JSON.")}};});function Ja(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return false;let t=new Date(`${e}T00:00:00.000Z`);return !Number.isNaN(t.getTime())&&t.toISOString().slice(0,10)===e}var re,$n=F(()=>{nt();re=class extends B{get isShimBacked(){return true}checkConstraint(){let t=this.context.column;return `${t} IS NULL OR date(${t}) IS NOT NULL`}validateStorage(t){return this.isNullish(t)?this.validationPass():typeof t!="string"||!Ja(t)?this.validationFail("Invalid date.","Patch rows with YYYY-MM-DD dates."):this.validationPass()}};});function Ya(e){let t=e.match(/^(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,6})?)?([+-](\d{2}):?(\d{2}))?$/);if(!t)return false;let n=Number(t[1]),r=Number(t[2]),i=t[3]===void 0?0:Number(t[3]),s=t[5]===void 0?null:Number(t[5]),o=t[6]===void 0?null:Number(t[6]),a=s===null||o!==null&&s<=15&&o<=59;return n<=24&&r<=59&&i<=59&&(n!==24||r===0&&i===0)&&a}var ie,Nn=F(()=>{nt();ie=class extends B{get isShimBacked(){return true}checkConstraint(){let t=this.context.column;return `${t} IS NULL OR time(${t}) IS NOT NULL`}validateStorage(t){return this.isNullish(t)?this.validationPass():typeof t!="string"||!Ya(t)?this.validationFail("Invalid time.","Patch rows with HH:MM[:SS] times."):this.validationPass()}};});function Qa(e){let t=e.match(/^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,6})?)?(?:Z|([+-](\d{2}):?(\d{2})))?$/);if(!t)return false;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),s=Number(t[4]),o=Number(t[5]),a=t[6]===void 0?0:Number(t[6]),l=t[8]===void 0?null:Number(t[8]),c=t[9]===void 0?null:Number(t[9]),u=new Date(Date.UTC(n,r-1,i)),p=u.getUTCFullYear()===n&&u.getUTCMonth()===r-1&&u.getUTCDate()===i,h=s<=24&&o<=59&&a<=59&&(s!==24||o===0&&a===0),y=l===null||c!==null&&l<=15&&c<=59;return p&&h&&y}var se,vn=F(()=>{nt();se=class extends B{get isShimBacked(){return true}checkConstraint(){let t=this.context.column;return `${t} IS NULL OR datetime(${t}) IS NOT NULL`}validateStorage(t){return this.isNullish(t)?this.validationPass():typeof t!="string"||!Qa(t)?this.validationFail("Invalid timestamp.","Patch rows with ISO timestamps."):this.validationPass()}};});var oe,kn=F(()=>{nt();oe=class extends B{get isShimBacked(){return true}validateStorage(t){return this.isNullish(t)?this.validationPass():typeof t!="string"||t.trim().length===0?this.validationFail("Expected interval text.","Patch rows with interval strings."):/^-?\d+(?:\.\d+)?$/.test(t.trim())?this.validationFail("Ambiguous numeric interval.","Patch rows with explicit interval strings."):this.validationPass()}};});var ae,Ln=F(()=>{nt();ae=class extends B{enumValues;constructor(t,n){super(t),this.enumValues=n;}get isShimBacked(){return true}checkConstraint(){let t=this.context.column,n=this.enumValues.map(r=>`'${r.replace(/'/g,"''")}'`).join(", ");return `${t} IN (${n})`}serialize(t){if(this.isNullish(t))return t;if(typeof t!="string"||!this.enumValues.includes(t))throw this.checkError("enum_membership",t);return t}validateStorage(t){return this.isNullish(t)?this.validationPass():typeof t!="string"||!this.enumValues.includes(t)?this.validationFail("Invalid enum value.","Patch rows with declared enum values."):this.validationPass()}};});function ai(e){try{return {ok:!0,value:JSON.parse(e)}}catch{return {ok:false}}}var kt,Pn=F(()=>{pt();kt=class extends X{elementField;constructor(t,n){super(t),this.elementField=n;}get sqliteType(){return "TEXT"}get isShimBacked(){return true}checkConstraint(){let t=this.context.column;return `${t} IS NULL OR (json_valid(${t}) AND json_type(${t}) = 'array')`}serialize(t){if(this.isNullish(t))return t;if(!Array.isArray(t))throw this.checkError("array_type",t);return this.elementField?JSON.stringify(t.map(n=>this.elementField.serialize(n))):JSON.stringify(t)}deserialize(t){if(this.isNullish(t))return t;if(typeof t=="string"){let n=ai(t);if(n.ok&&Array.isArray(n.value))return this.elementField?n.value.map(r=>this.elementField.deserialize(r)):n.value}return t}validateStorage(t){if(this.isNullish(t))return this.validationPass();if(typeof t!="string")return this.validationFail("Expected JSON array text.","Patch rows with array values.");let n=ai(t);if(!n.ok)return this.validationFail("Invalid JSON array text.","Patch rows with array values.");if(!Array.isArray(n.value))return this.validationFail("Expected JSON array.","Patch rows with array values.");if(this.elementField)for(let r of n.value){let i=this.elementField.validateStorage(r);if(i.status==="fail")return this.validationFail(`Invalid ${this.elementField.context.pgTypeName} array element.`,i.action??"Patch rows with valid array elements.")}return this.validationPass()}};});function li(e){return tl.test(e.toLowerCase())}var Za,tl,le,On=F(()=>{nt();Za="????????-????-????-????-????????????",tl=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;le=class extends B{get isShimBacked(){return true}checkConstraint(){let t=this.quoteIfNeeded(this.context.column);return `${t} IS NULL OR ${t} GLOB '${Za}'`}serialize(t){if(this.isNullish(t))return t;if(typeof t!="string")throw this.checkError("uuid_format",t);let n=t.toLowerCase();if(!li(n))throw this.checkError("uuid_format",t);return n}validateStorage(t){return this.isNullish(t)?this.validationPass():typeof t!="string"||!li(t)?this.validationFail("Invalid UUID.","Patch rows with valid UUIDs."):this.validationPass()}};});function el(e){let t=e.split("/");if(t.length>2)return null;let n=t[0];if(!n)return null;if(t.length===1)return {address:n,prefix:null};let r=t[1];return !r||!/^\d+$/.test(r)?null:{address:n,prefix:Number(r)}}function nl(e){let t=e.split(".");return t.length!==4?false:t.every(n=>{if(!/^\d+$/.test(n))return false;let r=Number(n);return r>=0&&r<=255})}function rl(e){if(!e.includes(":"))return false;try{return new URL(`http://[${e}]/`),!0}catch{return false}}function ci(e){let t=el(e);return t?nl(t.address)?t.prefix===null||t.prefix>=0&&t.prefix<=32:rl(t.address)?t.prefix===null||t.prefix>=0&&t.prefix<=128:false:false}var ce,Fn=F(()=>{nt();ce=class extends B{get isShimBacked(){return true}checkConstraint(){let t=this.quoteIfNeeded(this.context.column);return `${t} IS NULL OR (length(${t}) BETWEEN 3 AND 49 AND (instr(${t}, '.') > 0 OR instr(${t}, ':') > 0))`}serialize(t){if(this.isNullish(t))return t;if(typeof t!="string")throw this.checkError("inet_format",t);let n=t.trim();if(!ci(n))throw this.checkError("inet_format",t);return n}validateStorage(t){return this.isNullish(t)?this.validationPass():typeof t!="string"||!ci(t.trim())?this.validationFail("Invalid inet address.","Patch rows with valid inet strings."):this.validationPass()}};});var ue,In=F(()=>{nt();ue=class extends B{serialize(t){throw new Error(`Unsupported type "${this.context.pgTypeName}" for ${this.context.table}.${this.context.column}`)}deserialize(t){throw new Error(`Unsupported type "${this.context.pgTypeName}" for ${this.context.table}.${this.context.column}`)}toColumnDDL(){throw new Error(`Unsupported type "${this.context.pgTypeName}" for ${this.context.table}.${this.context.column}`)}};});function fe(e,t){if(t?.isArray){let r=fe(e,{...t,isArray:false});return new kt(e,r)}if(t?.enumValues)return new ae(e,t.enumValues);let n=e.pgTypeName.toLowerCase().trim();if(n.startsWith("_")||n.endsWith("[]")){let r=n.startsWith("_")?n.slice(1):n.slice(0,-2),i={...e,pgTypeName:r},s=fe(i);return new kt(e,s)}return sl.has(n)?new Qt(e):il.has(n)?new Tt(e):cl.has(n)?new ee(e):ul.has(n)?new ne(e):dl.has(n)?new re(e):hl.has(n)?new ie(e):gl.has(n)?new se(e):yl.has(n)?new oe(e):ll.has(n)?new te(e):ol.has(n)?new Zt(e,t?.numericPrecision):fl.has(n)?new le(e):pl.has(n)?new B(e,63):ml.has(n)?new ce(e):al.has(n)?new B(e,t?.lengthConstraint):new ue(e)}var il,sl,ol,al,ll,cl,ul,fl,pl,ml,dl,hl,gl,yl,ui=F(()=>{Be();Tn();_n();nt();An();Cn();Rn();$n();Nn();vn();kn();Ln();Pn();On();Fn();In();il=new Set(["int2","smallint","int4","integer","int","int8","bigint"]),sl=new Set(["serial","serial4","bigserial","serial8","smallserial","serial2"]),ol=new Set(["float4","real","float8","double precision","numeric","decimal"]),al=new Set(["text","varchar","character varying","char","character","bpchar"]),ll=new Set(["bytea"]),cl=new Set(["bool","boolean"]),ul=new Set(["json","jsonb"]),fl=new Set(["uuid"]),pl=new Set(["name"]),ml=new Set(["inet"]),dl=new Set(["date"]),hl=new Set(["time","timetz","time without time zone","time with time zone"]),gl=new Set(["timestamp","timestamptz","timestamp without time zone","timestamp with time zone"]),yl=new Set(["interval"]);});var fi=F(()=>{});var pe,pi=F(()=>{pe=class{table;schema;fields;constructor(t,n="public",r=new Map){this.table=t,this.schema=n,this.fields=r;}get(t){return this.fields.get(t)}has(t){return this.fields.has(t)}set(t,n){this.fields.set(t,n);}columns(){return Array.from(this.fields.keys())}all(){return Array.from(this.fields.values())}serializeRow(t){let n={};for(let[r,i]of Object.entries(t)){let s=this.fields.get(r);n[r]=s?s.serialize(i):i;}return n}deserializeRow(t){let n={};for(let[r,i]of Object.entries(t)){let s=this.fields.get(r);n[r]=s?s.deserialize(i):i;}return n}applyDefaults(t){let n={...t};for(let[r,i]of this.fields)!(r in n)&&i.context.defaultFn&&(n[r]=i.context.defaultFn());return n}};});var mi=F(()=>{pt();En();Be();Tn();_n();nt();An();Cn();Rn();$n();Nn();vn();kn();Ln();Pn();On();Fn();In();ui();fi();pi();});var gi={};Ii(gi,{_resetWarnedMissingToClauseForTests:()=>bl,collectComments:()=>_l,collectEnums:()=>wl,collectPolicies:()=>Sl,collectSchema:()=>El,collectTableConstraints:()=>Tl,collectVariables:()=>xl});function bl(){Un.clear();}function wl(e){let t=new Map;for(let n of e.stmts??[]){if(!n.stmt||!("CreateEnumStmt"in n.stmt))continue;let r=n.stmt.CreateEnumStmt,i=gt(r.typeName??[]).join(".");if(!i||!r.vals)continue;let s=gt(r.vals);t.set(i.toLowerCase(),s);}return t}function xl(e){let t=new Map;for(let n of e.stmts??[]){if(!n.stmt||!("VariableSetStmt"in n.stmt))continue;let r=n.stmt.VariableSetStmt,i=r.name,s=ti(r.args?.[0]??{});t.set(i,{value:s,local:r.is_local});}return t}function di(e){let t=[],n=false;for(let r of e??[])if("RoleSpec"in r){let i=r.RoleSpec;i.roletype==="ROLESPEC_PUBLIC"?i.location===-1&&(n=true):i.roletype==="ROLESPEC_CSTRING"&&i.rolename&&t.push(i.rolename);}return {roles:t,implicitPublic:n}}function hi(e,t){return e&&e.length>0?e:t}function Dn(e,t,n){return e.findIndex(r=>r.data.name===t.name&&r.data.table===t.table&&hi(r.data.schema,n)===hi(t.schema,n))}function jn(e,t){return new Error(`policy "${e}" for table "${t}" does not exist`)}function Sl(e,t={}){let n=t.defaultSchema||"public",r=t.validateMutations===true,i=new Ue,s=new Set,o=[];for(let a of e.stmts??[])if(a.stmt){if("CreatePolicyStmt"in a.stmt){let l=a.stmt.CreatePolicyStmt,c=l.table?.relname??"",u=l.table?.schemaname,p={select:"SELECT",insert:"INSERT",update:"UPDATE",delete:"DELETE"},h=l.cmd_name?p[l.cmd_name]??"ALL":"ALL",y=l.permissive===true,{roles:g,implicitPublic:E}=di(l.roles),_=l.qual?i.deparse(l.qual):void 0,q=l.with_check?i.deparse(l.with_check):void 0;if(E){let M=u?`${u}.${c}`:c,W=l.policy_name??"",O=`${M}::${W}`;if(!Un.has(O)){Un.add(O);let N=JSON.stringify(_)+JSON.stringify(q);/\{\{auth\.(uid|jwt|role)/i.test(N)||console.warn(`[supalite] policy "${W}" on "${M}" has no TO clause \u2014 applies to all roles (PUBLIC). For clarity, prefer an explicit \`TO <role>\` clause (e.g. \`TO authenticated\`).`);}}let S=new vt({name:l.policy_name??"",table:c,schema:u,command:h,permissive:y,roles:g,using:_,withCheck:q});o.push(S);}if("DropStmt"in a.stmt&&a.stmt.DropStmt.removeType==="OBJECT_POLICY"){let l=a.stmt.DropStmt,c=l.objects?.[0];if(c&&"List"in c){let u=gt(c.List.items??[]),p=u[u.length-1],h=u[u.length-2],y=u.length>=3?u[u.length-3]:void 0;if(p&&h){let g=Dn(o,{name:p,table:h,schema:y},n);if(g!==-1)o.splice(g,1);else if(r&&!l.missing_ok)throw jn(p,h)}}}if("AlterPolicyStmt"in a.stmt){let l=a.stmt.AlterPolicyStmt,c=l.policy_name??"",u=l.table?.relname??"",p=l.table?.schemaname,h=Dn(o,{name:c,table:u,schema:p},n);if(h===-1){if(r)throw jn(c,u);continue}let y=o[h].data,g=l.roles?di(l.roles).roles:y.roles,E=l.qual?i.deparse(l.qual):y.using,_=l.with_check?i.deparse(l.with_check):y.withCheck;o[h]=new vt({...y,roles:g,using:E,withCheck:_});}if("RenameStmt"in a.stmt&&a.stmt.RenameStmt.renameType==="OBJECT_POLICY"){let l=a.stmt.RenameStmt,c=l.subname??"",u=l.relation?.relname??"",p=l.relation?.schemaname,h=Dn(o,{name:c,table:u,schema:p},n);if(h===-1){if(r)throw jn(c,u);continue}l.newname&&(o[h]=new vt({...o[h].data,name:l.newname}));}if("AlterTableStmt"in a.stmt){let l=a.stmt.AlterTableStmt;if((l.cmds??[]).some(p=>"AlterTableCmd"in p&&(p.AlterTableCmd.subtype==="AT_EnableRowSecurity"||p.AlterTableCmd.subtype==="AT_ForceRowSecurity"))){let p=l.relation?.relname??"";s.add(p);}}}return {policies:o,tables:s}}function El(e,t){let n=new Map;for(let r of e.stmts??[]){if(!r.stmt||!("CreateStmt"in r.stmt))continue;let i=r.stmt.CreateStmt,s=i.relation?.relname??"",o=i.relation?.schemaname??"public";if(!s)continue;let a=new pe(s,o);for(let l of i.tableElts??[]){if(!("ColumnDef"in l))continue;let c=l.ColumnDef,u=c.colname;if(!u)continue;let p=c.typeName?.names?.map(x=>x.String?.sval||x.String?.str).filter(Boolean),h=p&&(p.length===2&&p[0]==="pg_catalog"?p[1]:p[0]);if(!h)continue;let y=!!c.typeName?.arrayBounds?.length,g=Array.isArray(c.typeName?.typmods)?c.typeName.typmods:[],E=x=>g[x]?.A_Const?.ival?.ival??g[x]?.A_Const?.val?.ival?.ival,_={isArray:y};if(ni(h)&&g.length>0){let x=E(0);typeof x=="number"&&x>0&&(_.lengthConstraint=x);}if(ri(h)&&g.length>=2){let x=E(0),L=E(1);typeof x=="number"&&typeof L=="number"&&x>0&&L>=0&&(_.numericPrecision={precision:x,scale:L});}let q=t.get(h.toLowerCase());q&&(_.enumValues=q);let S=Array.isArray(c.constraints)?c.constraints:[],M=S.some(x=>x.Constraint?.contype==="CONSTR_PRIMARY"),W=ei(h)||S.some(x=>x.Constraint?.contype==="CONSTR_IDENTITY"),O=S.some(x=>x.Constraint?.contype==="CONSTR_NOTNULL"),N=S.find(x=>x.Constraint?.contype==="CONSTR_UNIQUE"),v=S.find(x=>x.Constraint?.contype==="CONSTR_GENERATED"),T=S.find(x=>x.Constraint?.contype==="CONSTR_FOREIGN"),C=S.find(x=>x.Constraint?.contype==="CONSTR_CHECK"),m;if(T){let x=T.Constraint,L=x.pktable?.relname,d=x.pktable?.schemaname,f=x.pk_attrs?.[0]?.String?.sval;L&&f&&(m={refSchema:d,refTable:L,refColumn:f,constraintName:x.conname||void 0});}let z={schema:o,table:s,column:u,pgTypeName:h,nullable:!O&&!M,defaultValue:null,defaultFn:null,isPrimaryKey:M,isUnique:!!N,isSerial:W,isGenerated:!!v,fkRef:m,hasCheck:!!C,checkConstraintName:C?.Constraint?.conname||void 0,uniqueConstraintName:N?.Constraint?.conname||void 0};a.set(u,fe(z,_));}n.set(`${o}.${s}`,a);}return n}function Tl(e){let t=[];for(let n of e.stmts??[]){if(!n.stmt||!("CreateStmt"in n.stmt))continue;let r=n.stmt.CreateStmt,i=r.relation?.relname??"",s=r.relation?.schemaname??"public";if(i)for(let o of r.tableElts??[]){if("ColumnDef"in o)continue;let a=o;if(!a.Constraint)continue;let l=a.Constraint,c=l.contype;if(c==="CONSTR_UNIQUE"){let u=(l.keys??[]).map(p=>p.String?.sval??p.String?.str).filter(Boolean);if(u.length===0)continue;t.push({schema:s,table:i,kind:"unique",name:l.conname||void 0,columns:u});}else if(c==="CONSTR_CHECK")t.push({schema:s,table:i,kind:"check",name:l.conname||void 0,columns:[]});else if(c==="CONSTR_FOREIGN"){let u=(l.fk_attrs??[]).map(y=>y.String?.sval??y.String?.str).filter(Boolean),p=(l.pk_attrs??[]).map(y=>y.String?.sval??y.String?.str).filter(Boolean),h=l.pktable?.relname;if(!h)continue;t.push({schema:s,table:i,kind:"foreign_key",name:l.conname||void 0,columns:u,refSchema:l.pktable?.schemaname,refTable:h,refColumns:p});}}}return t}function _l(e){let t=[];for(let n of e.stmts??[]){if(!n.stmt||!("CommentStmt"in n.stmt))continue;let r=n.stmt.CommentStmt,i=r.comment??"";if(!i)continue;let s=r.objtype,o=(r.object?.List?.items??r.object?.items??[]).map(a=>a.String?.sval??a.String?.str).filter(Boolean);if(o.length!==0){if(s==="OBJECT_TABLE"||s==="OBJECT_VIEW"){let[a,l]=o.length>=2?o:["public",o[0]];t.push({schema:a,table:l,text:i});}else if(s==="OBJECT_COLUMN"){let a="public",l,c;o.length>=3?[a,l,c]=o:[l,c]=o,t.push({schema:a,table:l,column:c,text:i});}}}return t}var Un,yi=F(()=>{ii();De();si();mi();Sn();Un=new Set;});process.stdin.isTTY?null:(async()=>{let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8")})();function et(e,t){ge.existsSync(e)||(ge.mkdirSync(e,{recursive:true}),t?.());}function wt(e,t,n){ge.existsSync(e)||(ge.writeFileSync(e,t),n?.());}var ut=class e{root;constructor(t,n){let r=n??e.projectDir();this.root=at__default.join(r,t??"");}ensureRoot(){et(this.root);}static homeDir(){return at__default.join(Ui.homedir(),".lite")}static projectDir(){return at__default.join(process.cwd(),"supabase")}deleteAll(t=false){try{ge.rmSync(this.root,{recursive:!0});}catch(n){if(!t)throw n}this.ensureRoot();}delete(t,n=false){try{ge.unlinkSync(at__default.join(this.root,t));}catch(r){if(!n)throw r}}write(t,n,r=false){try{this.ensureRoot(),ge.writeFileSync(at__default.join(this.root,t),n);}catch(i){if(!r)throw i}}read(t,n=false){try{return ge.readFileSync(at__default.join(this.root,t),"utf8")}catch(r){if(!n)throw r}}relativePath(t){return t?at__default.relative(process.cwd(),at__default.join(this.root,t)):this.root}path(t){return t?at__default.join(this.root,t):this.root}};var Pt=process.env.LITE_CLOUD_URL??(process.env.LOCAL?"http://localhost:2001":"https://api.lite.dev"),be=process.env.LITE_CLOUD_PROJECTS_URL??(process.env.LOCAL?"http://supalite.local":"https://lite.black");var xe=class{root;constructor(t){this.root=t??at__default.join(Ui.homedir(),".lite","auth"),et(this.root);}async getItem(t){try{return ge.readFileSync(at__default.join(this.root,t+".json"),"utf8")}catch{return null}}async setItem(t,n){ge.writeFileSync(at__default.join(this.root,t+".json"),n);}async removeItem(t){try{ge.unlinkSync(at__default.join(this.root,t+".json"));}catch{return}}};var _t=class{constructor(t){this.config=t;this.tempFs=new ut(".temp",this.config.root),this.projectFs=new ut("supabase",this.config.root),this.schemaFs=new ut("schemas",this.config.root),this.authStorage=this.config.authStorage??new xe(at__default.join(ut.homeDir(),"auth")),this._client=this.config.withSupabaseClient!==false?this.config.client??createClient(this.config.host??Pt,process.env.LITE_CLOUD_ANON_KEY??"...",{auth:{storage:this.authStorage}}):void 0;}tempFs;projectFs;schemaFs;_client;authStorage;async fetch(t,n){if(!this.config.token)throw new Error("Not authenticated, sign in first.");let r=t instanceof URL?t:new URL(t,this.config.host??Pt);return await fetch(r,{...n,headers:{...n?.headers,Authorization:`Bearer ${this.config.token}`}})}};var At=class extends _t{constructor(n){super(n);this.config=n;}get client(){if(!this._client)throw new Error("Supabase client not initialized");return this._client}projectRef(){return this.tempFs.read("project-ref",true)}projectUrl(n){let r=new URL(this.config.projectsHost??be),i=r.hostname.replace(/^www\./,"");return `${r.protocol}//${n}.${i}${r.port?`:${r.port}`:""}`}};var ot={config_dir:"supabase",default_db_url:"file:supabase/.temp/data.db",default_db_dir:"supabase/.temp/data"};var Mt=Lt(Ot());function Xi(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return [n.length,n.pop().length+1]}function Wi(e,t,n){let r=e.split(/\r\n|\n|\r/g),i="",s=(Math.log10(t+1)|0)+1;for(let o=t-1;o<=t+1;o++){let a=r[o-1];a&&(i+=o.toString().padEnd(s," "),i+=": ",i+=a,i+=`
13
- `,o===t&&(i+=" ".repeat(s+n+2),i+=`^
14
- `));}return i}var A=class extends Error{line;column;codeblock;constructor(t,n){let[r,i]=Xi(n.toml,n.ptr),s=Wi(n.toml,r,i);super(`Invalid TOML document: ${t}
12
+ var Qi=Object.create;var Xt=Object.defineProperty;var Zi=Object.getOwnPropertyDescriptor;var es=Object.getOwnPropertyNames;var ts=Object.getPrototypeOf,ns=Object.prototype.hasOwnProperty;var F=(t,e)=>()=>(t&&(e=t(t=0)),e);var Se=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),rs=(t,e)=>{for(var n in e)Xt(t,n,{get:e[n],enumerable:true});},is=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of es(e))!ns.call(t,i)&&i!==n&&Xt(t,i,{get:()=>e[i],enumerable:!(r=Zi(e,i))||r.enumerable});return t};var Pe=(t,e,n)=>(n=t!=null?Qi(ts(t)):{},is(Xt(n,"default",{value:t,enumerable:true}),t));var Fe=Se((tu,zt)=>{var Rt=process||{},nr=Rt.argv||[],Ct=Rt.env||{},us=!(Ct.NO_COLOR||nr.includes("--no-color"))&&(!!Ct.FORCE_COLOR||nr.includes("--color")||Rt.platform==="win32"||(Rt.stdout||{}).isTTY&&Ct.TERM!=="dumb"||!!Ct.CI),fs=(t,e,n=t)=>r=>{let i=""+r,s=i.indexOf(e,t.length);return ~s?t+ps(i,e,n,s)+e:t+i+e},ps=(t,e,n,r)=>{let i="",s=0;do i+=t.substring(s,r)+n,s=r+e.length,r=t.indexOf(e,s);while(~r);return i+t.substring(s)},rr=(t=us)=>{let e=t?fs:()=>String;return {isColorSupported:t,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};zt.exports=rr();zt.exports.createColors=rr;});var Ke=Se((hp,Or)=>{var kr="[^\\\\/]",Yo="(?=.)",Nr="[^/]",hn="(?:\\/|$)",Lr="(?:^|\\/)",gn=`\\.{1,2}${hn}`,Qo="(?!\\.)",Zo=`(?!${Lr}${gn})`,ea=`(?!\\.{0,1}${hn})`,ta=`(?!${gn})`,na="[^.\\/]",ra=`${Nr}*?`,ia="/",Pr={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:Yo,QMARK:Nr,END_ANCHOR:hn,DOTS_SLASH:gn,NO_DOT:Qo,NO_DOTS:Zo,NO_DOT_SLASH:ea,NO_DOTS_SLASH:ta,QMARK_NO_DOT:na,STAR:ra,START_ANCHOR:Lr,SEP:ia},sa={...Pr,SLASH_LITERAL:"[\\\\/]",QMARK:kr,STAR:`${kr}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},oa={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};Or.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:oa,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(t){return {"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(t){return t===true?sa:Pr}};});var Xe=Se(J=>{var{REGEX_BACKSLASH:aa,REGEX_REMOVE_BACKSLASH:la,REGEX_SPECIAL_CHARS:ca,REGEX_SPECIAL_CHARS_GLOBAL:ua}=Ke();J.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);J.hasRegexChars=t=>ca.test(t);J.isRegexChar=t=>t.length===1&&J.hasRegexChars(t);J.escapeRegex=t=>t.replace(ua,"\\$1");J.toPosixSlashes=t=>t.replace(aa,"/");J.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let t=navigator.platform.toLowerCase();return t==="win32"||t==="windows"}return typeof process<"u"&&process.platform?process.platform==="win32":false};J.removeBackslashes=t=>t.replace(la,e=>e==="\\"?"":e);J.escapeLast=(t,e,n)=>{let r=t.lastIndexOf(e,n);return r===-1?t:t[r-1]==="\\"?J.escapeLast(t,e,r-1):`${t.slice(0,r)}\\${t.slice(r)}`};J.removePrefix=(t,e={})=>{let n=t;return n.startsWith("./")&&(n=n.slice(2),e.prefix="./"),n};J.wrapOutput=(t,e={},n={})=>{let r=n.contains?"":"^",i=n.contains?"":"$",s=`${r}(?:${t})${i}`;return e.negated===true&&(s=`(?:^(?!${s}).*$)`),s};J.basename=(t,{windows:e}={})=>{let n=t.split(e?/[\\/]/:"/"),r=n[n.length-1];return r===""?n[n.length-2]:r};});var Mr=Se((yp,Hr)=>{var Fr=Xe(),{CHAR_ASTERISK:yn,CHAR_AT:fa,CHAR_BACKWARD_SLASH:We,CHAR_COMMA:pa,CHAR_DOT:bn,CHAR_EXCLAMATION_MARK:wn,CHAR_FORWARD_SLASH:Br,CHAR_LEFT_CURLY_BRACE:Sn,CHAR_LEFT_PARENTHESES:xn,CHAR_LEFT_SQUARE_BRACKET:ma,CHAR_PLUS:da,CHAR_QUESTION_MARK:Ir,CHAR_RIGHT_CURLY_BRACE:ha,CHAR_RIGHT_PARENTHESES:Dr,CHAR_RIGHT_SQUARE_BRACKET:ga}=Ke(),jr=t=>t===Br||t===We,Ur=t=>{t.isPrefix!==true&&(t.depth=t.isGlobstar?1/0:1);},ya=(t,e)=>{let n=e||{},r=t.length-1,i=n.parts===true||n.scanToEnd===true,s=[],o=[],a=[],l=t,c=-1,u=0,f=0,h=false,y=false,g=false,E=false,A=false,q=false,x=false,H=false,X=false,O=false,$=0,k,T,C={value:"",depth:0,isGlob:false},m=()=>c>=r,W=()=>l.charCodeAt(c+1),S=()=>(k=T,l.charCodeAt(++c));for(;c<r;){T=S();let P;if(T===We){x=C.backslashes=true,T=S(),T===Sn&&(q=true);continue}if(q===true||T===Sn){for($++;m()!==true&&(T=S());){if(T===We){x=C.backslashes=true,S();continue}if(T===Sn){$++;continue}if(q!==true&&T===bn&&(T=S())===bn){if(h=C.isBrace=true,g=C.isGlob=true,O=true,i===true)continue;break}if(q!==true&&T===pa){if(h=C.isBrace=true,g=C.isGlob=true,O=true,i===true)continue;break}if(T===ha&&($--,$===0)){q=false,h=C.isBrace=true,O=true;break}}if(i===true)continue;break}if(T===Br){if(s.push(c),o.push(C),C={value:"",depth:0,isGlob:false},O===true)continue;if(k===bn&&c===u+1){u+=2;continue}f=c+1;continue}if(n.noext!==true&&(T===da||T===fa||T===yn||T===Ir||T===wn)===true&&W()===xn){if(g=C.isGlob=true,E=C.isExtglob=true,O=true,T===wn&&c===u&&(X=true),i===true){for(;m()!==true&&(T=S());){if(T===We){x=C.backslashes=true,T=S();continue}if(T===Dr){g=C.isGlob=true,O=true;break}}continue}break}if(T===yn){if(k===yn&&(A=C.isGlobstar=true),g=C.isGlob=true,O=true,i===true)continue;break}if(T===Ir){if(g=C.isGlob=true,O=true,i===true)continue;break}if(T===ma){for(;m()!==true&&(P=S());){if(P===We){x=C.backslashes=true,S();continue}if(P===ga){y=C.isBracket=true,g=C.isGlob=true,O=true;break}}if(i===true)continue;break}if(n.nonegate!==true&&T===wn&&c===u){H=C.negated=true,u++;continue}if(n.noparen!==true&&T===xn){if(g=C.isGlob=true,i===true){for(;m()!==true&&(T=S());){if(T===xn){x=C.backslashes=true,T=S();continue}if(T===Dr){O=true;break}}continue}break}if(g===true){if(O=true,i===true)continue;break}}n.noext===true&&(E=false,g=false);let L=l,d="",p="";u>0&&(d=l.slice(0,u),l=l.slice(u),f-=u),L&&g===true&&f>0?(L=l.slice(0,f),p=l.slice(f)):g===true?(L="",p=l):L=l,L&&L!==""&&L!=="/"&&L!==l&&jr(L.charCodeAt(L.length-1))&&(L=L.slice(0,-1)),n.unescape===true&&(p&&(p=Fr.removeBackslashes(p)),L&&x===true&&(L=Fr.removeBackslashes(L)));let Z={prefix:d,input:t,start:u,base:L,glob:p,isBrace:h,isBracket:y,isGlob:g,isExtglob:E,isGlobstar:A,negated:H,negatedExtglob:X};if(n.tokens===true&&(Z.maxDepth=0,jr(T)||o.push(C),Z.tokens=o),n.parts===true||n.tokens===true){let P;for(let U=0;U<s.length;U++){let ue=P?P+1:u,ee=s[U],he=t.slice(ue,ee);n.tokens&&(U===0&&u!==0?(o[U].isPrefix=true,o[U].value=d):o[U].value=he,Ur(o[U]),Z.maxDepth+=o[U].depth),(U!==0||he!=="")&&a.push(he),P=ee;}if(P&&P+1<t.length){let U=t.slice(P+1);a.push(U),n.tokens&&(o[o.length-1].value=U,Ur(o[o.length-1]),Z.maxDepth+=o[o.length-1].depth);}Z.slashes=s,Z.parts=a;}return Z};Hr.exports=ya;});var Xr=Se((bp,Kr)=>{var ze=Ke(),Q=Xe(),{MAX_LENGTH:Bt,POSIX_REGEX_SOURCE:ba,REGEX_NON_SPECIAL_CHARS:wa,REGEX_SPECIAL_CHARS_BACKREF:Sa,REPLACEMENTS:qr}=ze,xa=(t,e)=>{if(typeof e.expandRange=="function")return e.expandRange(...t,e);t.sort();let n=`[${t.join("-")}]`;try{new RegExp(n);}catch{return t.map(i=>Q.escapeRegex(i)).join("..")}return n},ke=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,Vr=t=>{let e=[],n=0,r=0,i=0,s="",o=false;for(let a of t){if(o===true){s+=a,o=false;continue}if(a==="\\"){s+=a,o=true;continue}if(a==='"'){i=i===1?0:1,s+=a;continue}if(i===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")r++;else if(a===")"&&r>0)r--;else if(a==="|"&&r===0){e.push(s),s="";continue}}}s+=a;}return e.push(s),e},Ea=t=>{let e=false;for(let n of t){if(e===true){e=false;continue}if(n==="\\"){e=true;continue}if(/[?*+@!()[\]{}]/.test(n))return false}return true},Gr=t=>{let e=t.trim(),n=true;for(;n===true;)n=false,/^@\([^\\()[\]{}|]+\)$/.test(e)&&(e=e.slice(2,-1),n=true);if(Ea(e))return e.replace(/\\(.)/g,"$1")},Ta=t=>{let e=t.map(Gr).filter(Boolean);for(let n=0;n<e.length;n++)for(let r=n+1;r<e.length;r++){let i=e[n],s=e[r],o=i[0];if(!(!o||i!==o.repeat(i.length)||s!==o.repeat(s.length))&&(i===s||i.startsWith(s)||s.startsWith(i)))return true}return false},En=(t,e=true)=>{if(t[0]!=="+"&&t[0]!=="*"||t[1]!=="(")return;let n=0,r=0,i=0,s=false;for(let o=1;o<t.length;o++){let a=t[o];if(s===true){s=false;continue}if(a==="\\"){s=true;continue}if(a==='"'){i=i===1?0:1;continue}if(i!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){r++;continue}if(a===")"&&(r--,r===0))return e===true&&o!==t.length-1?void 0:{type:t[0],body:t.slice(2,o),end:o}}}}},Aa=t=>{let e=0,n=[];for(;e<t.length;){let i=En(t.slice(e),false);if(!i||i.type!=="*")return;let s=Vr(i.body).map(a=>a.trim());if(s.length!==1)return;let o=Gr(s[0]);if(!o||o.length!==1)return;n.push(o),e+=i.end+1;}return n.length<1?void 0:`${n.length===1?Q.escapeRegex(n[0]):`[${n.map(i=>Q.escapeRegex(i)).join("")}]`}*`},_a=t=>{let e=0,n=t.trim(),r=En(n);for(;r;)e++,n=r.body.trim(),r=En(n);return e},Ca=(t,e)=>{if(e.maxExtglobRecursion===false)return {risky:false};let n=typeof e.maxExtglobRecursion=="number"?e.maxExtglobRecursion:ze.DEFAULT_MAX_EXTGLOB_RECURSION,r=Vr(t).map(i=>i.trim());if(r.length>1&&(r.some(i=>i==="")||r.some(i=>/^[*?]+$/.test(i))||Ta(r)))return {risky:true};for(let i of r){let s=Aa(i);if(s)return {risky:true,safeOutput:s};if(_a(i)>n)return {risky:true}}return {risky:false}},Tn=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=qr[t]||t;let n={...e},r=typeof n.maxLength=="number"?Math.min(Bt,n.maxLength):Bt,i=t.length;if(i>r)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},o=[s],a=n.capture?"":"?:",l=ze.globChars(n.windows),c=ze.extglobChars(l),{DOT_LITERAL:u,PLUS_LITERAL:f,SLASH_LITERAL:h,ONE_CHAR:y,DOTS_SLASH:g,NO_DOT:E,NO_DOT_SLASH:A,NO_DOTS_SLASH:q,QMARK:x,QMARK_NO_DOT:H,STAR:X,START_ANCHOR:O}=l,$=w=>`(${a}(?:(?!${O}${w.dot?g:u}).)*?)`,k=n.dot?"":E,T=n.dot?x:H,C=n.bash===true?$(n):X;n.capture&&(C=`(${C})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let m={input:t,index:-1,start:0,dot:n.dot===true,consumed:"",output:"",prefix:"",backtrack:false,negated:false,brackets:0,braces:0,parens:0,quotes:0,globstar:false,tokens:o};t=Q.removePrefix(t,m),i=t.length;let W=[],S=[],L=[],d=s,p,Z=()=>m.index===i-1,P=m.peek=(w=1)=>t[m.index+w],U=m.advance=()=>t[++m.index]||"",ue=()=>t.slice(m.index+1),ee=(w="",j=0)=>{m.consumed+=w,m.index+=j;},he=w=>{m.output+=w.output!=null?w.output:w.value,ee(w.value);},Ji=()=>{let w=1;for(;P()==="!"&&(P(2)!=="("||P(3)==="?");)U(),m.start++,w++;return w%2===0?false:(m.negated=true,m.start++,true)},wt=w=>{m[w]++,L.push(w);},ge=w=>{m[w]--,L.pop();},R=w=>{if(d.type==="globstar"){let j=m.braces>0&&(w.type==="comma"||w.type==="brace"),b=w.extglob===true||W.length&&(w.type==="pipe"||w.type==="paren");w.type!=="slash"&&w.type!=="paren"&&!j&&!b&&(m.output=m.output.slice(0,-d.output.length),d.type="star",d.value="*",d.output=C,m.output+=d.output);}if(W.length&&w.type!=="paren"&&(W[W.length-1].inner+=w.value),(w.value||w.output)&&he(w),d&&d.type==="text"&&w.type==="text"){d.output=(d.output||d.value)+w.value,d.value+=w.value;return}w.prev=d,o.push(w),d=w;},St=(w,j)=>{let b={...c[j],conditions:1,inner:""};b.prev=d,b.parens=m.parens,b.output=m.output,b.startIndex=m.index,b.tokensIndex=o.length;let v=(n.capture?"(":"")+b.open;wt("parens"),R({type:w,value:j,output:m.output?"":y}),R({type:"paren",extglob:true,value:U(),output:v}),W.push(b);},Yi=w=>{let j=t.slice(w.startIndex,m.index+1),b=t.slice(w.startIndex+2,m.index),v=Ca(b,n);if((w.type==="plus"||w.type==="star")&&v.risky){let I=v.safeOutput?(w.output?"":y)+(n.capture?`(${v.safeOutput})`:v.safeOutput):void 0,ae=o[w.tokensIndex];ae.type="text",ae.value=j,ae.output=I||Q.escapeRegex(j);for(let le=w.tokensIndex+1;le<o.length;le++)o[le].value="",o[le].output="",delete o[le].suffix;m.output=w.output+ae.output,m.backtrack=true,R({type:"paren",extglob:true,value:p,output:""}),ge("parens");return}let D=w.close+(n.capture?")":""),G;if(w.type==="negate"){let I=C;if(w.inner&&w.inner.length>1&&w.inner.includes("/")&&(I=$(n)),(I!==C||Z()||/^\)+$/.test(ue()))&&(D=w.close=`)$))${I}`),w.inner.includes("*")&&(G=ue())&&/^\.[^\\/.]+$/.test(G)){let ae=Tn(G,{...e,fastpaths:false}).output;D=w.close=`)${ae})${I})`;}w.prev.type==="bos"&&(m.negatedExtglob=true);}R({type:"paren",extglob:true,value:p,output:D}),ge("parens");};if(n.fastpaths!==false&&!/(^[*!]|[/()[\]{}"])/.test(t)){let w=false,j=t.replace(Sa,(b,v,D,G,I,ae)=>G==="\\"?(w=true,b):G==="?"?v?v+G+(I?x.repeat(I.length):""):ae===0?T+(I?x.repeat(I.length):""):x.repeat(D.length):G==="."?u.repeat(D.length):G==="*"?v?v+G+(I?C:""):C:v?b:`\\${b}`);return w===true&&(n.unescape===true?j=j.replace(/\\/g,""):j=j.replace(/\\+/g,b=>b.length%2===0?"\\\\":b?"\\":"")),j===t&&n.contains===true?(m.output=t,m):(m.output=Q.wrapOutput(j,m,e),m)}for(;!Z();){if(p=U(),p==="\0")continue;if(p==="\\"){let b=P();if(b==="/"&&n.bash!==true||b==="."||b===";")continue;if(!b){p+="\\",R({type:"text",value:p});continue}let v=/^\\+/.exec(ue()),D=0;if(v&&v[0].length>2&&(D=v[0].length,m.index+=D,D%2!==0&&(p+="\\")),n.unescape===true?p=U():p+=U(),m.brackets===0){R({type:"text",value:p});continue}}if(m.brackets>0&&(p!=="]"||d.value==="["||d.value==="[^")){if(n.posix!==false&&p===":"){let b=d.value.slice(1);if(b.includes("[")&&(d.posix=true,b.includes(":"))){let v=d.value.lastIndexOf("["),D=d.value.slice(0,v),G=d.value.slice(v+2),I=ba[G];if(I){d.value=D+I,m.backtrack=true,U(),!s.output&&o.indexOf(d)===1&&(s.output=y);continue}}}(p==="["&&P()!==":"||p==="-"&&P()==="]")&&(p=`\\${p}`),p==="]"&&(d.value==="["||d.value==="[^")&&(p=`\\${p}`),n.posix===true&&p==="!"&&d.value==="["&&(p="^"),d.value+=p,he({value:p});continue}if(m.quotes===1&&p!=='"'){p=Q.escapeRegex(p),d.value+=p,he({value:p});continue}if(p==='"'){m.quotes=m.quotes===1?0:1,n.keepQuotes===true&&R({type:"text",value:p});continue}if(p==="("){wt("parens"),R({type:"paren",value:p});continue}if(p===")"){if(m.parens===0&&n.strictBrackets===true)throw new SyntaxError(ke("opening","("));let b=W[W.length-1];if(b&&m.parens===b.parens+1){Yi(W.pop());continue}R({type:"paren",value:p,output:m.parens?")":"\\)"}),ge("parens");continue}if(p==="["){if(n.nobracket===true||!ue().includes("]")){if(n.nobracket!==true&&n.strictBrackets===true)throw new SyntaxError(ke("closing","]"));p=`\\${p}`;}else wt("brackets");R({type:"bracket",value:p});continue}if(p==="]"){if(n.nobracket===true||d&&d.type==="bracket"&&d.value.length===1){R({type:"text",value:p,output:`\\${p}`});continue}if(m.brackets===0){if(n.strictBrackets===true)throw new SyntaxError(ke("opening","["));R({type:"text",value:p,output:`\\${p}`});continue}ge("brackets");let b=d.value.slice(1);if(d.posix!==true&&b[0]==="^"&&!b.includes("/")&&(p=`/${p}`),d.value+=p,he({value:p}),n.literalBrackets===false||Q.hasRegexChars(b))continue;let v=Q.escapeRegex(d.value);if(m.output=m.output.slice(0,-d.value.length),n.literalBrackets===true){m.output+=v,d.value=v;continue}d.value=`(${a}${v}|${d.value})`,m.output+=d.value;continue}if(p==="{"&&n.nobrace!==true){wt("braces");let b={type:"brace",value:p,output:"(",outputIndex:m.output.length,tokensIndex:m.tokens.length};S.push(b),R(b);continue}if(p==="}"){let b=S[S.length-1];if(n.nobrace===true||!b){R({type:"text",value:p,output:p});continue}let v=")";if(b.dots===true){let D=o.slice(),G=[];for(let I=D.length-1;I>=0&&(o.pop(),D[I].type!=="brace");I--)D[I].type!=="dots"&&G.unshift(D[I].value);v=xa(G,n),m.backtrack=true;}if(b.comma!==true&&b.dots!==true){let D=m.output.slice(0,b.outputIndex),G=m.tokens.slice(b.tokensIndex);b.value=b.output="\\{",p=v="\\}",m.output=D;for(let I of G)m.output+=I.output||I.value;}R({type:"brace",value:p,output:v}),ge("braces"),S.pop();continue}if(p==="|"){W.length>0&&W[W.length-1].conditions++,R({type:"text",value:p});continue}if(p===","){let b=p,v=S[S.length-1];v&&L[L.length-1]==="braces"&&(v.comma=true,b="|"),R({type:"comma",value:p,output:b});continue}if(p==="/"){if(d.type==="dot"&&m.index===m.start+1){m.start=m.index+1,m.consumed="",m.output="",o.pop(),d=s;continue}R({type:"slash",value:p,output:h});continue}if(p==="."){if(m.braces>0&&d.type==="dot"){d.value==="."&&(d.output=u);let b=S[S.length-1];d.type="dots",d.output+=p,d.value+=p,b.dots=true;continue}if(m.braces+m.parens===0&&d.type!=="bos"&&d.type!=="slash"){R({type:"text",value:p,output:u});continue}R({type:"dot",value:p,output:u});continue}if(p==="?"){if(!(d&&d.value==="(")&&n.noextglob!==true&&P()==="("&&P(2)!=="?"){St("qmark",p);continue}if(d&&d.type==="paren"){let v=P(),D=p;(d.value==="("&&!/[!=<:]/.test(v)||v==="<"&&!/<([!=]|\w+>)/.test(ue()))&&(D=`\\${p}`),R({type:"text",value:p,output:D});continue}if(n.dot!==true&&(d.type==="slash"||d.type==="bos")){R({type:"qmark",value:p,output:H});continue}R({type:"qmark",value:p,output:x});continue}if(p==="!"){if(n.noextglob!==true&&P()==="("&&(P(2)!=="?"||!/[!=<:]/.test(P(3)))){St("negate",p);continue}if(n.nonegate!==true&&m.index===0){Ji();continue}}if(p==="+"){if(n.noextglob!==true&&P()==="("&&P(2)!=="?"){St("plus",p);continue}if(d&&d.value==="("||n.regex===false){R({type:"plus",value:p,output:f});continue}if(d&&(d.type==="bracket"||d.type==="paren"||d.type==="brace")||m.parens>0){R({type:"plus",value:p});continue}R({type:"plus",value:f});continue}if(p==="@"){if(n.noextglob!==true&&P()==="("&&P(2)!=="?"){R({type:"at",extglob:true,value:p,output:""});continue}R({type:"text",value:p});continue}if(p!=="*"){(p==="$"||p==="^")&&(p=`\\${p}`);let b=wa.exec(ue());b&&(p+=b[0],m.index+=b[0].length),R({type:"text",value:p});continue}if(d&&(d.type==="globstar"||d.star===true)){d.type="star",d.star=true,d.value+=p,d.output=C,m.backtrack=true,m.globstar=true,ee(p);continue}let w=ue();if(n.noextglob!==true&&/^\([^?]/.test(w)){St("star",p);continue}if(d.type==="star"){if(n.noglobstar===true){ee(p);continue}let b=d.prev,v=b.prev,D=b.type==="slash"||b.type==="bos",G=v&&(v.type==="star"||v.type==="globstar");if(n.bash===true&&(!D||w[0]&&w[0]!=="/")){R({type:"star",value:p,output:""});continue}let I=m.braces>0&&(b.type==="comma"||b.type==="brace"),ae=W.length&&(b.type==="pipe"||b.type==="paren");if(!D&&b.type!=="paren"&&!I&&!ae){R({type:"star",value:p,output:""});continue}for(;w.slice(0,3)==="/**";){let le=t[m.index+4];if(le&&le!=="/")break;w=w.slice(3),ee("/**",3);}if(b.type==="bos"&&Z()){d.type="globstar",d.value+=p,d.output=$(n),m.output=d.output,m.globstar=true,ee(p);continue}if(b.type==="slash"&&b.prev.type!=="bos"&&!G&&Z()){m.output=m.output.slice(0,-(b.output+d.output).length),b.output=`(?:${b.output}`,d.type="globstar",d.output=$(n)+(n.strictSlashes?")":"|$)"),d.value+=p,m.globstar=true,m.output+=b.output+d.output,ee(p);continue}if(b.type==="slash"&&b.prev.type!=="bos"&&w[0]==="/"){let le=w[1]!==void 0?"|$":"";m.output=m.output.slice(0,-(b.output+d.output).length),b.output=`(?:${b.output}`,d.type="globstar",d.output=`${$(n)}${h}|${h}${le})`,d.value+=p,m.output+=b.output+d.output,m.globstar=true,ee(p+U()),R({type:"slash",value:"/",output:""});continue}if(b.type==="bos"&&w[0]==="/"){d.type="globstar",d.value+=p,d.output=`(?:^|${h}|${$(n)}${h})`,m.output=d.output,m.globstar=true,ee(p+U()),R({type:"slash",value:"/",output:""});continue}m.output=m.output.slice(0,-d.output.length),d.type="globstar",d.output=$(n),d.value+=p,m.output+=d.output,m.globstar=true,ee(p);continue}let j={type:"star",value:p,output:C};if(n.bash===true){j.output=".*?",(d.type==="bos"||d.type==="slash")&&(j.output=k+j.output),R(j);continue}if(d&&(d.type==="bracket"||d.type==="paren")&&n.regex===true){j.output=p,R(j);continue}(m.index===m.start||d.type==="slash"||d.type==="dot")&&(d.type==="dot"?(m.output+=A,d.output+=A):n.dot===true?(m.output+=q,d.output+=q):(m.output+=k,d.output+=k),P()!=="*"&&(m.output+=y,d.output+=y)),R(j);}for(;m.brackets>0;){if(n.strictBrackets===true)throw new SyntaxError(ke("closing","]"));m.output=Q.escapeLast(m.output,"["),ge("brackets");}for(;m.parens>0;){if(n.strictBrackets===true)throw new SyntaxError(ke("closing",")"));m.output=Q.escapeLast(m.output,"("),ge("parens");}for(;m.braces>0;){if(n.strictBrackets===true)throw new SyntaxError(ke("closing","}"));m.output=Q.escapeLast(m.output,"{"),ge("braces");}if(n.strictSlashes!==true&&(d.type==="star"||d.type==="bracket")&&R({type:"maybe_slash",value:"",output:`${h}?`}),m.backtrack===true){m.output="";for(let w of m.tokens)m.output+=w.output!=null?w.output:w.value,w.suffix&&(m.output+=w.suffix);}return m};Tn.fastpaths=(t,e)=>{let n={...e},r=typeof n.maxLength=="number"?Math.min(Bt,n.maxLength):Bt,i=t.length;if(i>r)throw new SyntaxError(`Input length: ${i}, exceeds maximum allowed length: ${r}`);t=qr[t]||t;let{DOT_LITERAL:s,SLASH_LITERAL:o,ONE_CHAR:a,DOTS_SLASH:l,NO_DOT:c,NO_DOTS:u,NO_DOTS_SLASH:f,STAR:h,START_ANCHOR:y}=ze.globChars(n.windows),g=n.dot?u:c,E=n.dot?f:c,A=n.capture?"":"?:",q={negated:false,prefix:""},x=n.bash===true?".*?":h;n.capture&&(x=`(${x})`);let H=k=>k.noglobstar===true?x:`(${A}(?:(?!${y}${k.dot?l:s}).)*?)`,X=k=>{switch(k){case "*":return `${g}${a}${x}`;case ".*":return `${s}${a}${x}`;case "*.*":return `${g}${x}${s}${a}${x}`;case "*/*":return `${g}${x}${o}${a}${E}${x}`;case "**":return g+H(n);case "**/*":return `(?:${g}${H(n)}${o})?${E}${a}${x}`;case "**/*.*":return `(?:${g}${H(n)}${o})?${E}${x}${s}${a}${x}`;case "**/.*":return `(?:${g}${H(n)}${o})?${s}${a}${x}`;default:{let T=/^(.*?)\.(\w+)$/.exec(k);if(!T)return;let C=X(T[1]);return C?C+s+T[2]:void 0}}},O=Q.removePrefix(t,q),$=X(O);return $&&n.strictSlashes!==true&&($+=`${o}?`),$};Kr.exports=Tn;});var Jr=Se((wp,zr)=>{var Ra=Mr(),An=Xr(),Wr=Xe(),va=Ke(),$a=t=>t&&typeof t=="object"&&!Array.isArray(t),M=(t,e,n=false)=>{if(Array.isArray(t)){let u=t.map(h=>M(h,e,n));return h=>{for(let y of u){let g=y(h);if(g)return g}return false}}let r=$a(t)&&t.tokens&&t.input;if(t===""||typeof t!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let i=e||{},s=i.windows,o=r?M.compileRe(t,e):M.makeRe(t,e,false,true),a=o.state;delete o.state;let l=()=>false;if(i.ignore){let u={...e,ignore:null,onMatch:null,onResult:null};l=M(i.ignore,u,n);}let c=(u,f=false)=>{let{isMatch:h,match:y,output:g}=M.test(u,o,e,{glob:t,posix:s}),E={glob:t,state:a,regex:o,posix:s,input:u,output:g,match:y,isMatch:h};return typeof i.onResult=="function"&&i.onResult(E),h===false?(E.isMatch=false,f?E:false):l(u)?(typeof i.onIgnore=="function"&&i.onIgnore(E),E.isMatch=false,f?E:false):(typeof i.onMatch=="function"&&i.onMatch(E),f?E:true)};return n&&(c.state=a),c};M.test=(t,e,n,{glob:r,posix:i}={})=>{if(typeof t!="string")throw new TypeError("Expected input to be a string");if(t==="")return {isMatch:false,output:""};let s=n||{},o=s.format||(i?Wr.toPosixSlashes:null),a=t===r,l=a&&o?o(t):t;return a===false&&(l=o?o(t):t,a=l===r),(a===false||s.capture===true)&&(s.matchBase===true||s.basename===true?a=M.matchBase(t,e,n,i):a=e.exec(l)),{isMatch:!!a,match:a,output:l}};M.matchBase=(t,e,n)=>(e instanceof RegExp?e:M.makeRe(e,n)).test(Wr.basename(t));M.isMatch=(t,e,n)=>M(e,n)(t);M.parse=(t,e)=>Array.isArray(t)?t.map(n=>M.parse(n,e)):An(t,{...e,fastpaths:false});M.scan=(t,e)=>Ra(t,e);M.compileRe=(t,e,n=false,r=false)=>{if(n===true)return t.output;let i=e||{},s=i.contains?"":"^",o=i.contains?"":"$",a=`${s}(?:${t.output})${o}`;t&&t.negated===true&&(a=`^(?!${a}).*$`);let l=M.toRegex(a,e);return r===true&&(l.state=t),l};M.makeRe=(t,e={},n=false,r=false)=>{if(!t||typeof t!="string")throw new TypeError("Expected a non-empty string");let i={negated:false,fastpaths:true};return e.fastpaths!==false&&(t[0]==="."||t[0]==="*")&&(i.output=An.fastpaths(t,e)),i.output||(i=An(t,e)),M.compileRe(i,e,n,r)};M.toRegex=(t,e)=>{try{let n=e||{};return new RegExp(t,n.flags||(n.nocase?"i":""))}catch(n){if(e&&e.debug===true)throw n;return /$^/}};M.constants=va;zr.exports=M;});var ei=Se((Sp,Zr)=>{var Yr=Jr(),ka=Xe();function Qr(t,e,n=false){return e&&(e.windows===null||e.windows===void 0)&&(e={...e,windows:ka.isWindows()}),Yr(t,e,n)}Object.assign(Qr,Yr);Zr.exports=Qr;});function tt(t){if("String"in t)return t.String.sval}function me(t){return t.map(tt).filter(e=>e!=null)}function Si(t){return Object.keys(t)[0]}function xi(t){if("A_Const"in t){if(t.A_Const.ival)return t.A_Const.ival.ival;if(t.A_Const.fval)return t.A_Const.fval.fval;if(t.A_Const.sval)return t.A_Const.sval.sval;if(t.A_Const.boolval)return t.A_Const.boolval.boolval;if(t.A_Const.isnull)return null}}var Mt=F(()=>{});function Ei(t){let e=t.toLowerCase();return ["serial","serial4","bigserial","serial8","smallserial","serial2"].includes(e)}function Ti(t){let e=t.toLowerCase();return ["varchar","character varying","char","character","bpchar"].includes(e)}function Ai(t){let e=t.toLowerCase();return ["numeric","decimal"].includes(e)}var Nn,qt,Cl,Ln=F(()=>{Mt();Nn=class extends Error{},qt=class extends Nn{constructor(n,r){super(r??`Unsupported node type: ${Si(n)}`);this.node=n;}};Cl={CreateEnumStmt:{react:"ignore"},CreateDomainStmt:{react:"warn"},CreateSeqStmt:{react:"ignore"},AlterSeqStmt:{react:"ignore"},CreateSchemaStmt:{react:"warn"},CreatePolicyStmt:{react:"ignore"},AlterPolicyStmt:{react:"ignore"},PartitionElem:{react:"error"},PartitionCmd:{react:"error"},VariableSetStmt:{react:"ignore"},CompositeTypeStmt:{react:"error"},AlterEnumStmt:{react:"error"},AlterObjectSchemaStmt:{react:"error"},AlterOwnerStmt:{react:"error"},AlterTypeStmt:{react:"error"},AlterFunctionStmt:{react:"error"},AlterDefaultPrivilegesStmt:{react:"error"},GrantStmt:{react:"error"},GrantRoleStmt:{react:"error"},CopyStmt:{react:"error"},CreateCastStmt:{react:"error"},AlterOpFamilyStmt:{react:"error"},AlterOperatorStmt:{react:"error"},TruncateStmt:{react:"error"},A_Indirection:{react:"error"},XmlExpr:{react:"error"},XmlSerialize:{react:"error"},RangeTableSample:{react:"error"},GroupingSet:{react:"error"}},new Map(Object.entries(Cl));});var ne,Vt,_i=F(()=>{Mt();Ln();ne=class extends qt{constructor(e,n){super(e,`Unsupported expression: ${n}`);}},Vt=class{deparse(e){if("A_Const"in e){let i=e.A_Const;if(i.boolval!==void 0)return i.boolval.boolval?{}:{$always:false}}let n=Object.keys(e)[0],r=this[n];if(!r)throw new ne({[n]:e},`Unsupported expression: ${n}`);return r.call(this,e[n])}deparseValue(e){if("A_Const"in e)return this.A_Const(e.A_Const);if("ColumnRef"in e)return this.ColumnRef(e.ColumnRef);if("FuncCall"in e)return this.FuncCall(e.FuncCall);if("SubLink"in e)return this.SubLink(e.SubLink);if("TypeCast"in e)return this.TypeCast(e.TypeCast);if("A_Expr"in e){let r=this.isJwtAccessor(e.A_Expr);return r||this.A_Expr(e.A_Expr)}if("BoolExpr"in e)return this.BoolExpr(e.BoolExpr);let n=Object.keys(e)[0];throw new ne({[n]:e},`deparseValue: ${n}`)}A_Expr(e){if(e.kind==="AEXPR_OP"){let n=e.name?.[0],r=n?tt(n):void 0;if(!r)throw new ne({A_Expr:e},"A_Expr missing operator");let i=this.isJwtAccessor(e);if(i)return {[i]:{}};let s=e.lexpr?this.deparseValue(e.lexpr):void 0,o=e.rexpr?this.deparseValue(e.rexpr):void 0,a=this.mapOperator(r);if(!a)throw new ne({A_Expr:e},`Unsupported operator: ${r}`);let l=e.rexpr!=null&&"ColumnRef"in e.rexpr;if(typeof s=="string"&&s.startsWith("{{")&&l)return {[o]:{[a]:s}};let c=l&&typeof o=="string"?{$ref:o}:o;return {[s]:{[a]:c}}}if(e.kind==="AEXPR_LIKE"||e.kind==="AEXPR_ILIKE"){let n=e.lexpr?this.deparseValue(e.lexpr):void 0,r=e.rexpr?this.deparseValue(e.rexpr):void 0,s=(e.name?.[0]?tt(e.name[0]):"~~")==="!~~"?"$notLike":"$like";return {[n]:{[s]:r}}}if(e.kind==="AEXPR_IN"){let n=e.lexpr?this.deparseValue(e.lexpr):void 0,r=e.rexpr&&"List"in e.rexpr&&e.rexpr.List.items?e.rexpr.List.items.map(i=>this.deparseValue(i)):[];return {[n]:{$in:r}}}throw new ne({A_Expr:e},`A_Expr kind: ${e.kind}`)}BoolExpr(e){let n=e.args??[];switch(e.boolop){case "AND_EXPR":return {$and:n.map(r=>this.deparse(r))};case "OR_EXPR":return {$or:n.map(r=>this.deparse(r))};case "NOT_EXPR":return {$not:this.deparse(n[0])};default:throw new ne({BoolExpr:e},`BoolExpr op: ${e.boolop}`)}}NullTest(e){let n=e.arg?this.deparseValue(e.arg):void 0;return e.nulltesttype==="IS_NULL"?{[n]:{$is:null}}:{[n]:{$isNot:null}}}SubLink(e){if(e.subLinkType==="ANY_SUBLINK"){let n=e.testexpr?this.deparseValue(e.testexpr):void 0,r=e.subselect?this.SelectStmt(e.subselect.SelectStmt):void 0;return {[n]:{$in:r}}}if(e.subLinkType==="EXISTS_SUBLINK")return {$exists:e.subselect?this.SelectStmt(e.subselect.SelectStmt):void 0};if(e.subLinkType==="EXPR_SUBLINK"){let n=e.subselect?e.subselect.SelectStmt:void 0;if(n?.fromClause?.length)return this.SelectStmt(n);if(n?.targetList?.[0]){let r=n.targetList[0],i="ResTarget"in r?r.ResTarget:void 0;if(i?.val){let s=this.deparseValue(i.val);return s}}}throw new ne({SubLink:e},`SubLink type: ${e.subLinkType}`)}SelectStmt(e){let{from:n,schema:r,join:i}=this.deparseFromClause(e.fromClause??[]),s=[];for(let h of e.targetList??[]){let y="ResTarget"in h?h.ResTarget:void 0;if(y?.val){let g=this.deparseValue(y.val);Array.isArray(g)?s.push(...g.map(String)):g!=null&&g!==""&&s.push(String(g));}}let o=e.whereClause?this.deparse(e.whereClause):void 0,a=this.deparseSortClause(e.sortClause),l=this.deparseLimit(e.limitCount),c=this.deparseLimit(e.limitOffset),u=this.deparseGroupClause(e.groupClause),f={type:"query",from:n,select:s};return r&&(f.schema=r),Object.keys(i).length>0&&(f.join=i),o&&(f.where=o),a.length>0&&(f.order=a),l!==void 0&&(f.limit=l),c!==void 0&&(f.offset=c),u.length>0&&(f.group=u),f}FuncCall(e){let n=this.isAuthFunc(e.funcname??[]);if(n)return n;throw new ne({FuncCall:e},`FuncCall: ${me(e.funcname??[]).join(".")}`)}ColumnRef(e){let n=me(e.fields??[]);return n.length===1?n[0]:n.join(".")}A_Const(e){if(e.boolval!==void 0)return e.boolval.boolval;if(e.ival!==void 0)return e.ival.ival??0;if(e.fval!==void 0)return parseFloat(e.fval.fval??"0");if(e.sval!==void 0)return e.sval.sval??"";if(e.isnull)return null;throw new ne({A_Const:e},"A_Const: unknown variant")}TypeCast(e){if(!e.arg)throw new ne({TypeCast:e},"TypeCast: missing arg");return this.deparseValue(e.arg)}BooleanTest(e){let n=e.arg?this.deparseValue(e.arg):void 0;return e.booltesttype==="IS_TRUE"?{[n]:{$eq:true}}:{[n]:{$eq:false}}}deparseFromClause(e){let n={};if(e.length===0)return {from:"",join:n};let r=e[0];if("RangeVar"in r){let i=r.RangeVar;return {from:i.relname??"",schema:i.schemaname,join:n}}if("JoinExpr"in r){let{from:i,schema:s}=this.walkJoinExpr(r.JoinExpr,n);return {from:i,schema:s,join:n}}return {from:"",join:n}}walkJoinExpr(e,n){let r={from:""};if(e.larg)if("RangeVar"in e.larg){let i=e.larg.RangeVar;r={from:i.relname??"",schema:i.schemaname};}else "JoinExpr"in e.larg&&(r=this.walkJoinExpr(e.larg.JoinExpr,n));if(e.rarg&&"RangeVar"in e.rarg){let i=e.rarg.RangeVar,s=i.relname??"",o=i.alias?.aliasname??s,a=e.jointype==="JOIN_LEFT"?"left":"inner",l={from:s,type:a};e.quals&&(l.on=this.deparse(e.quals));let c=o;if(c in n){let u=2;for(;`${c}_${u}`in n;)u++;c=`${c}_${u}`;}n[c]=l;}return r}deparseSortClause(e){if(!e)return [];let n=[];for(let r of e){if(!("SortBy"in r))continue;let i=r.SortBy;if(!i.node)continue;let s=String(this.deparseValue(i.node)),o=i.sortby_dir==="SORTBY_DESC"?"desc":"asc",a={column:s,direction:o};i.sortby_nulls==="SORTBY_NULLS_FIRST"?a.nullsFirst=true:i.sortby_nulls==="SORTBY_NULLS_LAST"&&(a.nullsFirst=false),n.push(a);}return n}deparseLimit(e){if(!e)return;let n=this.deparseValue(e);return typeof n=="number"?n:Number(n)}deparseGroupClause(e){return e?e.map(n=>String(this.deparseValue(n))):[]}isAuthFunc(e){let n=me(e);if(n.length===2&&n[0]==="auth"){if(n[1]==="uid")return "{{auth.uid}}";if(n[1]==="jwt")return "{{auth.jwt}}";if(n[1]==="role")return "{{auth.role}}";throw new Error(`Unsupported auth function: "${n.slice(1).join(".")}"`)}return null}isJwtAccessor(e){if(e.kind!=="AEXPR_OP")return null;let n=e.name?.[0]?tt(e.name[0]):void 0;if(n!=="->"&&n!=="->>")return null;let r=e.rexpr&&"A_Const"in e.rexpr?e.rexpr.A_Const.sval?.sval:void 0;if(r===void 0)return null;if(e.lexpr&&"FuncCall"in e.lexpr)return this.isAuthFunc(e.lexpr.FuncCall.funcname??[])==="{{auth.jwt}}"?`{{auth.jwt.${r}}}`:null;if(e.lexpr&&"A_Expr"in e.lexpr){let i=this.isJwtAccessor(e.lexpr.A_Expr);if(i)return `${i.slice(0,-2)}.${r}}}`}return null}mapOperator(e){switch(e){case "=":return "$eq";case "<>":case "!=":return "$neq";case ">":return "$gt";case ">=":return "$gte";case "<":return "$lt";case "<=":return "$lte";case "~~":return "$like";case "!~~":return "$notLike";default:return}}};});var _e,Ci=F(()=>{_e=class t{constructor(e){this.data=e;}appliesTo(e){return this.data.command==="ALL"||this.data.command===e}appliesToRole(e){return this.data.roles.length===0||this.data.roles.includes(e)}toJSON(){return this.data}static fromJSON(e){return new t(e)}};});var nt,Pn=F(()=>{nt=class extends Error{constructor(n,r,i,s){super(`check constraint "${i}" violated for ${n}.${r}`);this.table=n;this.column=r;this.constraint=i;this.value=s;this.name="CheckConstraintError";}};});var K,de=F(()=>{Pn();K=class{context;factoryExtra;constructor(e){this.context=e;}get isShimBacked(){return false}checkConstraint(){return null}serialize(e){return e}deserialize(e){return e}validateStorage(e){return {status:"pass",message:null}}validationFail(e,n){return {status:"fail",message:e,action:n}}validationPass(){return {status:"pass",message:null}}isNullish(e){return e==null}toColumnDDL(e){let{includeNullable:n=true}=e??{},r=[],i=this.context.column;r.push(this.quoteIfNeeded(i)),r.push(this.sqliteType),this.context.isPrimaryKey&&r.push("PRIMARY KEY"),this.context.isSerial&&this.context.isPrimaryKey&&r.push("AUTOINCREMENT"),n&&!this.context.nullable&&!this.context.isPrimaryKey&&r.push("NOT NULL"),this.context.isUnique&&!this.context.isPrimaryKey&&r.push("UNIQUE"),this.context.defaultValue!==null&&r.push(`DEFAULT ${this.context.defaultValue}`);let s=this.checkConstraint();return s&&r.push(`CHECK (${s})`),r.join(" ")}checkError(e,n){return new nt(this.context.table,this.context.column,e,n)}quoteIfNeeded(e){return /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)?e:`"${e}"`}};});var Ce,Gt=F(()=>{de();Ce=class extends K{get sqliteType(){return "INTEGER"}};});var rt,On=F(()=>{Gt();rt=class extends Ce{constructor(e){super({...e,isSerial:true});}};});function Rl(t,e){let{precision:n,scale:r}=e,i=10**r,s=10**(n-r);return Math.abs(Math.round(t*i)-t*i)<1e-4&&Math.abs(t)<s}var it,Fn=F(()=>{de();it=class extends K{numericPrecision;constructor(e,n){super(e),this.numericPrecision=n;}get isShimBacked(){return this.numericPrecision!==void 0}get sqliteType(){return "REAL"}checkConstraint(){if(this.numericPrecision){let{precision:e,scale:n}=this.numericPrecision,r=this.context.column,i=10**n,s=10**(e-n);return `ABS(ROUND(${r} * ${i}) - ${r} * ${i}) < 0.0001 AND ABS(${r}) < ${s}`}return null}validateStorage(e){if(this.isNullish(e))return this.validationPass();if(typeof e!="number"||!Number.isFinite(e))return this.validationFail("Expected finite number.","Patch rows with finite numbers.");if(this.numericPrecision){let{precision:n,scale:r}=this.numericPrecision;if(!Rl(e,this.numericPrecision))return this.validationFail(`Does not fit numeric(${n}, ${r}).`,"Patch rows within numeric precision.")}return this.validationPass()}};});var B,se=F(()=>{de();B=class extends K{lengthConstraint;constructor(e,n){super(e),this.lengthConstraint=n;}get isShimBacked(){return this.lengthConstraint!==void 0}get sqliteType(){return "TEXT"}checkConstraint(){return this.lengthConstraint!==void 0?`length(${this.context.column}) <= ${this.lengthConstraint}`:null}validateStorage(e){return this.isNullish(e)?this.validationPass():typeof e!="string"?this.validationFail("Expected text.","Patch rows with text values."):this.lengthConstraint!==void 0&&Array.from(e).length>this.lengthConstraint?this.validationFail(`Exceeds length ${this.lengthConstraint}.`,"Patch rows with shorter text."):this.validationPass()}};});var st,In=F(()=>{de();st=class extends K{get sqliteType(){return "BLOB"}};});var ot,Dn=F(()=>{de();ot=class extends K{get isShimBacked(){return true}get sqliteType(){return "INTEGER"}checkConstraint(){return `${this.context.column} IN (0, 1)`}serialize(e){if(this.isNullish(e))return e;if(e===true||e===1)return 1;if(e===false||e===0)return 0;throw this.checkError("boolean_range",e)}deserialize(e){if(this.isNullish(e)||e===true||e===false)return e;if(typeof e=="number"&&Number.isFinite(e)){if(e===1)return true;if(e===0)return false}return e===1n?true:e===0n?false:e==="1"||e==="true"?true:e==="0"||e==="false"?false:e}validateStorage(e){return this.isNullish(e)?this.validationPass():e===1||e===0?this.validationPass():this.validationFail("Expected 0 or 1.","Patch rows with boolean values.")}};});function Ri(t){try{return {ok:!0,value:JSON.parse(t)}}catch{return {ok:false}}}var at,jn=F(()=>{de();at=class extends K{get isShimBacked(){return true}get sqliteType(){return "TEXT"}checkConstraint(){let e=this.context.column;return `${e} IS NULL OR json_valid(${e})`}serialize(e){if(this.isNullish(e))return e;try{return JSON.stringify(e)}catch{throw this.checkError("json_valid",e)}}deserialize(e){if(this.isNullish(e))return e;if(typeof e=="string"){let n=Ri(e);return n.ok?n.value:e}return e}validateStorage(e){return this.isNullish(e)?this.validationPass():typeof e!="string"?this.validationFail("Expected JSON text.","Patch rows with JSON values."):Ri(e).ok?this.validationPass():this.validationFail("Invalid JSON text.","Patch rows with valid JSON.")}};});function vl(t){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return false;let e=new Date(`${t}T00:00:00.000Z`);return !Number.isNaN(e.getTime())&&e.toISOString().slice(0,10)===t}var lt,Un=F(()=>{se();lt=class extends B{get isShimBacked(){return true}checkConstraint(){let e=this.context.column;return `${e} IS NULL OR date(${e}) IS NOT NULL`}validateStorage(e){return this.isNullish(e)?this.validationPass():typeof e!="string"||!vl(e)?this.validationFail("Invalid date.","Patch rows with YYYY-MM-DD dates."):this.validationPass()}};});function $l(t){let e=t.match(/^(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,6})?)?([+-](\d{2}):?(\d{2}))?$/);if(!e)return false;let n=Number(e[1]),r=Number(e[2]),i=e[3]===void 0?0:Number(e[3]),s=e[5]===void 0?null:Number(e[5]),o=e[6]===void 0?null:Number(e[6]),a=s===null||o!==null&&s<=15&&o<=59;return n<=24&&r<=59&&i<=59&&(n!==24||r===0&&i===0)&&a}var ct,Bn=F(()=>{se();ct=class extends B{get isShimBacked(){return true}checkConstraint(){let e=this.context.column;return `${e} IS NULL OR time(${e}) IS NOT NULL`}validateStorage(e){return this.isNullish(e)?this.validationPass():typeof e!="string"||!$l(e)?this.validationFail("Invalid time.","Patch rows with HH:MM[:SS] times."):this.validationPass()}};});function kl(t){let e=t.match(/^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,6})?)?(?:Z|([+-](\d{2}):?(\d{2})))?$/);if(!e)return false;let n=Number(e[1]),r=Number(e[2]),i=Number(e[3]),s=Number(e[4]),o=Number(e[5]),a=e[6]===void 0?0:Number(e[6]),l=e[8]===void 0?null:Number(e[8]),c=e[9]===void 0?null:Number(e[9]),u=new Date(Date.UTC(n,r-1,i)),f=u.getUTCFullYear()===n&&u.getUTCMonth()===r-1&&u.getUTCDate()===i,h=s<=24&&o<=59&&a<=59&&(s!==24||o===0&&a===0),y=l===null||c!==null&&l<=15&&c<=59;return f&&h&&y}var ut,Hn=F(()=>{se();ut=class extends B{get isShimBacked(){return true}checkConstraint(){let e=this.context.column;return `${e} IS NULL OR datetime(${e}) IS NOT NULL`}validateStorage(e){return this.isNullish(e)?this.validationPass():typeof e!="string"||!kl(e)?this.validationFail("Invalid timestamp.","Patch rows with ISO timestamps."):this.validationPass()}};});var ft,Mn=F(()=>{se();ft=class extends B{get isShimBacked(){return true}validateStorage(e){return this.isNullish(e)?this.validationPass():typeof e!="string"||e.trim().length===0?this.validationFail("Expected interval text.","Patch rows with interval strings."):/^-?\d+(?:\.\d+)?$/.test(e.trim())?this.validationFail("Ambiguous numeric interval.","Patch rows with explicit interval strings."):this.validationPass()}};});var pt,qn=F(()=>{se();pt=class extends B{enumValues;constructor(e,n){super(e),this.enumValues=n;}get isShimBacked(){return true}checkConstraint(){let e=this.context.column,n=this.enumValues.map(r=>`'${r.replace(/'/g,"''")}'`).join(", ");return `${e} IN (${n})`}serialize(e){if(this.isNullish(e))return e;if(typeof e!="string"||!this.enumValues.includes(e))throw this.checkError("enum_membership",e);return e}validateStorage(e){return this.isNullish(e)?this.validationPass():typeof e!="string"||!this.enumValues.includes(e)?this.validationFail("Invalid enum value.","Patch rows with declared enum values."):this.validationPass()}};});function vi(t){try{return {ok:!0,value:JSON.parse(t)}}catch{return {ok:false}}}var Le,Vn=F(()=>{de();Le=class extends K{elementField;constructor(e,n){super(e),this.elementField=n;}get sqliteType(){return "TEXT"}get isShimBacked(){return true}checkConstraint(){let e=this.context.column;return `${e} IS NULL OR (json_valid(${e}) AND json_type(${e}) = 'array')`}serialize(e){if(this.isNullish(e))return e;if(!Array.isArray(e))throw this.checkError("array_type",e);return this.elementField?JSON.stringify(e.map(n=>this.elementField.serialize(n))):JSON.stringify(e)}deserialize(e){if(this.isNullish(e))return e;if(typeof e=="string"){let n=vi(e);if(n.ok&&Array.isArray(n.value))return this.elementField?n.value.map(r=>this.elementField.deserialize(r)):n.value}return e}validateStorage(e){if(this.isNullish(e))return this.validationPass();if(typeof e!="string")return this.validationFail("Expected JSON array text.","Patch rows with array values.");let n=vi(e);if(!n.ok)return this.validationFail("Invalid JSON array text.","Patch rows with array values.");if(!Array.isArray(n.value))return this.validationFail("Expected JSON array.","Patch rows with array values.");if(this.elementField)for(let r of n.value){let i=this.elementField.validateStorage(r);if(i.status==="fail")return this.validationFail(`Invalid ${this.elementField.context.pgTypeName} array element.`,i.action??"Patch rows with valid array elements.")}return this.validationPass()}};});function $i(t){return Ll.test(t.toLowerCase())}var Nl,Ll,mt,Gn=F(()=>{se();Nl="????????-????-????-????-????????????",Ll=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;mt=class extends B{get isShimBacked(){return true}checkConstraint(){let e=this.quoteIfNeeded(this.context.column);return `${e} IS NULL OR ${e} GLOB '${Nl}'`}serialize(e){if(this.isNullish(e))return e;if(typeof e!="string")throw this.checkError("uuid_format",e);let n=e.toLowerCase();if(!$i(n))throw this.checkError("uuid_format",e);return n}validateStorage(e){return this.isNullish(e)?this.validationPass():typeof e!="string"||!$i(e)?this.validationFail("Invalid UUID.","Patch rows with valid UUIDs."):this.validationPass()}};});function Pl(t){let e=t.split("/");if(e.length>2)return null;let n=e[0];if(!n)return null;if(e.length===1)return {address:n,prefix:null};let r=e[1];return !r||!/^\d+$/.test(r)?null:{address:n,prefix:Number(r)}}function Ol(t){let e=t.split(".");return e.length!==4?false:e.every(n=>{if(!/^\d+$/.test(n))return false;let r=Number(n);return r>=0&&r<=255})}function Fl(t){if(!t.includes(":"))return false;try{return new URL(`http://[${t}]/`),!0}catch{return false}}function ki(t){let e=Pl(t);return e?Ol(e.address)?e.prefix===null||e.prefix>=0&&e.prefix<=32:Fl(e.address)?e.prefix===null||e.prefix>=0&&e.prefix<=128:false:false}var dt,Kn=F(()=>{se();dt=class extends B{get isShimBacked(){return true}checkConstraint(){let e=this.quoteIfNeeded(this.context.column);return `${e} IS NULL OR (length(${e}) BETWEEN 3 AND 49 AND (instr(${e}, '.') > 0 OR instr(${e}, ':') > 0))`}serialize(e){if(this.isNullish(e))return e;if(typeof e!="string")throw this.checkError("inet_format",e);let n=e.trim();if(!ki(n))throw this.checkError("inet_format",e);return n}validateStorage(e){return this.isNullish(e)?this.validationPass():typeof e!="string"||!ki(e.trim())?this.validationFail("Invalid inet address.","Patch rows with valid inet strings."):this.validationPass()}};});var ht,Xn=F(()=>{se();ht=class extends B{serialize(e){throw new Error(`Unsupported type "${this.context.pgTypeName}" for ${this.context.table}.${this.context.column}`)}deserialize(e){throw new Error(`Unsupported type "${this.context.pgTypeName}" for ${this.context.table}.${this.context.column}`)}toColumnDDL(){throw new Error(`Unsupported type "${this.context.pgTypeName}" for ${this.context.table}.${this.context.column}`)}};});function gt(t,e){let n=Jl(t,e);if(e){let{enumValues:r,...i}=e;n.factoryExtra=i;}return n}function Jl(t,e){if(e?.isArray){let r=gt(t,{...e,isArray:false});return new Le(t,r)}if(e?.enumValues)return new pt(t,e.enumValues);let n=t.pgTypeName.toLowerCase().trim();if(n.startsWith("_")||n.endsWith("[]")){let r=n.startsWith("_")?n.slice(1):n.slice(0,-2),i={...t,pgTypeName:r},s=gt(i);return new Le(t,s)}return Dl.has(n)?new rt(t):Il.has(n)?new Ce(t):Hl.has(n)?new ot(t):Ml.has(n)?new at(t):Kl.has(n)?new lt(t):Xl.has(n)?new ct(t):Wl.has(n)?new ut(t):zl.has(n)?new ft(t):Bl.has(n)?new st(t):jl.has(n)?new it(t,e?.numericPrecision):ql.has(n)?new mt(t):Vl.has(n)?new B(t,63):Gl.has(n)?new dt(t):Ul.has(n)?new B(t,e?.lengthConstraint):new ht(t)}var Il,Dl,jl,Ul,Bl,Hl,Ml,ql,Vl,Gl,Kl,Xl,Wl,zl,Ni=F(()=>{Gt();On();Fn();se();In();Dn();jn();Un();Bn();Hn();Mn();qn();Vn();Gn();Kn();Xn();Il=new Set(["int2","smallint","int4","integer","int","int8","bigint"]),Dl=new Set(["serial","serial4","bigserial","serial8","smallserial","serial2"]),jl=new Set(["float4","real","float8","double precision","numeric","decimal"]),Ul=new Set(["text","varchar","character varying","char","character","bpchar"]),Bl=new Set(["bytea"]),Hl=new Set(["bool","boolean"]),Ml=new Set(["json","jsonb"]),ql=new Set(["uuid"]),Vl=new Set(["name"]),Gl=new Set(["inet"]),Kl=new Set(["date"]),Xl=new Set(["time","timetz","time without time zone","time with time zone"]),Wl=new Set(["timestamp","timestamptz","timestamp without time zone","timestamp with time zone"]),zl=new Set(["interval"]);});var Li=F(()=>{});var yt,Pi=F(()=>{yt=class{table;schema;fields;constructor(e,n="public",r=new Map){this.table=e,this.schema=n,this.fields=r;}get(e){return this.fields.get(e)}has(e){return this.fields.has(e)}set(e,n){this.fields.set(e,n);}columns(){return Array.from(this.fields.keys())}all(){return Array.from(this.fields.values())}serializeRow(e){let n={};for(let[r,i]of Object.entries(e)){let s=this.fields.get(r);n[r]=s?s.serialize(i):i;}return n}deserializeRow(e){let n={};for(let[r,i]of Object.entries(e)){let s=this.fields.get(r);n[r]=s?s.deserialize(i):i;}return n}applyDefaults(e){let n={...e};for(let[r,i]of this.fields)!(r in n)&&i.context.defaultFn&&(n[r]=i.context.defaultFn());return n}};});var Oi=F(()=>{de();Pn();Gt();On();Fn();se();In();Dn();jn();Un();Bn();Hn();Mn();qn();Vn();Gn();Kn();Xn();Ni();Li();Pi();});var Di={};rs(Di,{_resetWarnedMissingToClauseForTests:()=>Yl,collectComments:()=>rc,collectEnums:()=>Ql,collectPolicies:()=>ec,collectSchema:()=>tc,collectTableConstraints:()=>nc,collectVariables:()=>Zl});function Yl(){Jn.clear();}function Ql(t){let e=new Map;for(let n of t.stmts??[]){if(!n.stmt||!("CreateEnumStmt"in n.stmt))continue;let r=n.stmt.CreateEnumStmt,i=me(r.typeName??[]).join(".");if(!i||!r.vals)continue;let s=me(r.vals);e.set(i.toLowerCase(),s);}return e}function Zl(t){let e=new Map;for(let n of t.stmts??[]){if(!n.stmt||!("VariableSetStmt"in n.stmt))continue;let r=n.stmt.VariableSetStmt,i=r.name,s=xi(r.args?.[0]??{});e.set(i,{value:s,local:r.is_local});}return e}function Fi(t){let e=[],n=false;for(let r of t??[])if("RoleSpec"in r){let i=r.RoleSpec;i.roletype==="ROLESPEC_PUBLIC"?i.location===-1&&(n=true):i.roletype==="ROLESPEC_CSTRING"&&i.rolename&&e.push(i.rolename);}return {roles:e,implicitPublic:n}}function Kt(t,e){return t&&t.length>0?t:e}function Wn(t,e,n){return t.findIndex(r=>r.data.name===e.name&&r.data.table===e.table&&Kt(r.data.schema,n)===Kt(e.schema,n))}function zn(t,e){return new Error(`policy "${t}" for table "${e}" does not exist`)}function Ii(t,e,n,r){return t.data.table===e&&Kt(t.data.schema,r)===Kt(n,r)}function ec(t,e={}){let n=e.defaultSchema||"public",r=e.validateMutations===true,i=new Vt,s=new Set,o=[];for(let a of t.stmts??[])if(a.stmt){if("CreatePolicyStmt"in a.stmt){let l=a.stmt.CreatePolicyStmt,c=l.table?.relname??"",u=l.table?.schemaname,f={select:"SELECT",insert:"INSERT",update:"UPDATE",delete:"DELETE"},h=l.cmd_name?f[l.cmd_name]??"ALL":"ALL",y=l.permissive===true,{roles:g,implicitPublic:E}=Fi(l.roles),A=l.qual?i.deparse(l.qual):void 0,q=l.with_check?i.deparse(l.with_check):void 0;if(E){let H=u?`${u}.${c}`:c,X=l.policy_name??"",O=`${H}::${X}`;if(!Jn.has(O)){Jn.add(O);let $=JSON.stringify(A)+JSON.stringify(q);/\{\{auth\.(uid|jwt|role)/i.test($)||console.warn(`[supalite] policy "${X}" on "${H}" has no TO clause \u2014 applies to all roles (PUBLIC). For clarity, prefer an explicit \`TO <role>\` clause (e.g. \`TO authenticated\`).`);}}let x=new _e({name:l.policy_name??"",table:c,schema:u,command:h,permissive:y,roles:g,using:A,withCheck:q});o.push(x);}if("DropStmt"in a.stmt&&a.stmt.DropStmt.removeType==="OBJECT_POLICY"){let l=a.stmt.DropStmt,c=l.objects?.[0];if(c&&"List"in c){let u=me(c.List.items??[]),f=u[u.length-1],h=u[u.length-2],y=u.length>=3?u[u.length-3]:void 0;if(f&&h){let g=Wn(o,{name:f,table:h,schema:y},n);if(g!==-1)o.splice(g,1);else if(r&&!l.missing_ok)throw zn(f,h)}}}if("AlterPolicyStmt"in a.stmt){let l=a.stmt.AlterPolicyStmt,c=l.policy_name??"",u=l.table?.relname??"",f=l.table?.schemaname,h=Wn(o,{name:c,table:u,schema:f},n);if(h===-1){if(r)throw zn(c,u);continue}let y=o[h].data,g=l.roles?Fi(l.roles).roles:y.roles,E=l.qual?i.deparse(l.qual):y.using,A=l.with_check?i.deparse(l.with_check):y.withCheck;o[h]=new _e({...y,roles:g,using:E,withCheck:A});}if("RenameStmt"in a.stmt&&a.stmt.RenameStmt.renameType==="OBJECT_POLICY"){let l=a.stmt.RenameStmt,c=l.subname??"",u=l.relation?.relname??"",f=l.relation?.schemaname,h=Wn(o,{name:c,table:u,schema:f},n);if(h===-1){if(r)throw zn(c,u);continue}l.newname&&(o[h]=new _e({...o[h].data,name:l.newname}));}if("RenameStmt"in a.stmt&&a.stmt.RenameStmt.renameType==="OBJECT_TABLE"){let l=a.stmt.RenameStmt,c=l.relation?.relname??"",u=l.newname??"",f=l.relation?.schemaname;if(c&&u&&c!==u){s.delete(c)&&s.add(u);for(let h=0;h<o.length;h++)Ii(o[h],c,f,n)&&(o[h]=new _e({...o[h].data,table:u}));}}if("DropStmt"in a.stmt&&a.stmt.DropStmt.removeType==="OBJECT_TABLE")for(let l of a.stmt.DropStmt.objects??[]){if(!("List"in l))continue;let c=me(l.List.items??[]),u=c[c.length-1],f=c.length>=2?c[c.length-2]:void 0;if(u){s.delete(u);for(let h=o.length-1;h>=0;h--)Ii(o[h],u,f,n)&&o.splice(h,1);}}if("AlterTableStmt"in a.stmt){let l=a.stmt.AlterTableStmt,c=l.relation?.relname??"";for(let u of l.cmds??[]){if(!("AlterTableCmd"in u))continue;let f=u.AlterTableCmd.subtype;f==="AT_EnableRowSecurity"?s.add(c):f==="AT_DisableRowSecurity"&&s.delete(c);}}}return {policies:o,tables:s}}function tc(t,e){let n=new Map;for(let r of t.stmts??[]){if(!r.stmt||!("CreateStmt"in r.stmt))continue;let i=r.stmt.CreateStmt,s=i.relation?.relname??"",o=i.relation?.schemaname??"public";if(!s)continue;let a=new yt(s,o);for(let l of i.tableElts??[]){if(!("ColumnDef"in l))continue;let c=l.ColumnDef,u=c.colname;if(!u)continue;let f=c.typeName?.names?.map(S=>S.String?.sval||S.String?.str).filter(Boolean),h=f&&(f.length===2&&f[0]==="pg_catalog"?f[1]:f[0]);if(!h)continue;let y=!!c.typeName?.arrayBounds?.length,g=Array.isArray(c.typeName?.typmods)?c.typeName.typmods:[],E=S=>g[S]?.A_Const?.ival?.ival??g[S]?.A_Const?.val?.ival?.ival,A={isArray:y};if(Ti(h)&&g.length>0){let S=E(0);typeof S=="number"&&S>0&&(A.lengthConstraint=S);}if(Ai(h)&&g.length>=2){let S=E(0),L=E(1);typeof S=="number"&&typeof L=="number"&&S>0&&L>=0&&(A.numericPrecision={precision:S,scale:L});}let q=e.get(h.toLowerCase());q&&(A.enumValues=q);let x=Array.isArray(c.constraints)?c.constraints:[],H=x.some(S=>S.Constraint?.contype==="CONSTR_PRIMARY"),X=Ei(h)||x.some(S=>S.Constraint?.contype==="CONSTR_IDENTITY"),O=x.some(S=>S.Constraint?.contype==="CONSTR_NOTNULL"),$=x.find(S=>S.Constraint?.contype==="CONSTR_UNIQUE"),k=x.find(S=>S.Constraint?.contype==="CONSTR_GENERATED"),T=x.find(S=>S.Constraint?.contype==="CONSTR_FOREIGN"),C=x.find(S=>S.Constraint?.contype==="CONSTR_CHECK"),m;if(T){let S=T.Constraint,L=S.pktable?.relname,d=S.pktable?.schemaname,p=S.pk_attrs?.[0]?.String?.sval;L&&p&&(m={refSchema:d,refTable:L,refColumn:p,constraintName:S.conname||void 0});}let W={schema:o,table:s,column:u,pgTypeName:h,nullable:!O&&!H,defaultValue:null,defaultFn:null,isPrimaryKey:H,isUnique:!!$,isSerial:X,isGenerated:!!k,fkRef:m,hasCheck:!!C,checkConstraintName:C?.Constraint?.conname||void 0,uniqueConstraintName:$?.Constraint?.conname||void 0};a.set(u,gt(W,A));}n.set(`${o}.${s}`,a);}return n}function nc(t){let e=[];for(let n of t.stmts??[]){if(!n.stmt||!("CreateStmt"in n.stmt))continue;let r=n.stmt.CreateStmt,i=r.relation?.relname??"",s=r.relation?.schemaname??"public";if(i)for(let o of r.tableElts??[]){if("ColumnDef"in o)continue;let a=o;if(!a.Constraint)continue;let l=a.Constraint,c=l.contype;if(c==="CONSTR_UNIQUE"){let u=(l.keys??[]).map(f=>f.String?.sval??f.String?.str).filter(Boolean);if(u.length===0)continue;e.push({schema:s,table:i,kind:"unique",name:l.conname||void 0,columns:u});}else if(c==="CONSTR_CHECK")e.push({schema:s,table:i,kind:"check",name:l.conname||void 0,columns:[]});else if(c==="CONSTR_FOREIGN"){let u=(l.fk_attrs??[]).map(y=>y.String?.sval??y.String?.str).filter(Boolean),f=(l.pk_attrs??[]).map(y=>y.String?.sval??y.String?.str).filter(Boolean),h=l.pktable?.relname;if(!h)continue;e.push({schema:s,table:i,kind:"foreign_key",name:l.conname||void 0,columns:u,refSchema:l.pktable?.schemaname,refTable:h,refColumns:f});}}}return e}function rc(t){let e=[];for(let n of t.stmts??[]){if(!n.stmt||!("CommentStmt"in n.stmt))continue;let r=n.stmt.CommentStmt,i=r.comment??"";if(!i)continue;let s=r.objtype,o=(r.object?.List?.items??r.object?.items??[]).map(a=>a.String?.sval??a.String?.str).filter(Boolean);if(o.length!==0){if(s==="OBJECT_TABLE"||s==="OBJECT_VIEW"){let[a,l]=o.length>=2?o:["public",o[0]];e.push({schema:a,table:l,text:i});}else if(s==="OBJECT_COLUMN"){let a="public",l,c;o.length>=3?[a,l,c]=o:[l,c]=o,e.push({schema:a,table:l,column:c,text:i});}}}return e}var Jn,ji=F(()=>{_i();Mt();Ci();Oi();Ln();Jn=new Set;});process.stdin.isTTY?null:(async()=>{let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")})();function re(t,e){xt.existsSync(t)||(xt.mkdirSync(t,{recursive:true}),e?.());}function xe(t,e,n){xt.existsSync(t)||(xt.writeFileSync(t,e),n?.());}var pe=class t{root;constructor(e,n){let r=n??t.projectDir();this.root=ie__default.join(r,e??"");}ensureRoot(){re(this.root);}static homeDir(){return ie__default.join(os.homedir(),".lite")}static projectDir(){return ie__default.join(process.cwd(),"supabase")}deleteAll(e=false){try{xt.rmSync(this.root,{recursive:!0});}catch(n){if(!e)throw n}this.ensureRoot();}delete(e,n=false){try{xt.unlinkSync(ie__default.join(this.root,e));}catch(r){if(!n)throw r}}write(e,n,r=false){try{this.ensureRoot(),xt.writeFileSync(ie__default.join(this.root,e),n);}catch(i){if(!r)throw i}}read(e,n=false){try{return xt.readFileSync(ie__default.join(this.root,e),"utf8")}catch(r){if(!n)throw r}}relativePath(e){return e?ie__default.relative(process.cwd(),ie__default.join(this.root,e)):this.root}path(e){return e?ie__default.join(this.root,e):this.root}};var Oe=process.env.LITE_CLOUD_URL??(process.env.LOCAL?"http://localhost:2001":"https://api.lite.dev"),Tt=process.env.LITE_CLOUD_PROJECTS_URL??(process.env.LOCAL?"http://supalite.local":"https://lite.black");var _t=class{root;constructor(e){this.root=e??ie__default.join(os.homedir(),".lite","auth"),re(this.root);}async getItem(e){try{return xt.readFileSync(ie__default.join(this.root,e+".json"),"utf8")}catch{return null}}async setItem(e,n){xt.writeFileSync(ie__default.join(this.root,e+".json"),n);}async removeItem(e){try{xt.unlinkSync(ie__default.join(this.root,e+".json"));}catch{return}}};var Re=class{constructor(e){this.config=e;this.tempFs=new pe(".temp",this.config.root),this.projectFs=new pe("supabase",this.config.root),this.schemaFs=new pe("schemas",this.config.root),this.authStorage=this.config.authStorage??new _t(ie__default.join(pe.homeDir(),"auth")),this._client=this.config.withSupabaseClient!==false?this.config.client??createClient(this.config.host??Oe,process.env.LITE_CLOUD_ANON_KEY??"...",{auth:{storage:this.authStorage}}):void 0;}tempFs;projectFs;schemaFs;_client;authStorage;async fetch(e,n){if(!this.config.token)throw new Error("Not authenticated, sign in first.");let r=e instanceof URL?e:new URL(e,this.config.host??Oe);return await fetch(r,{...n,headers:{...n?.headers,Authorization:`Bearer ${this.config.token}`}})}};var ve=class extends Re{constructor(n){super(n);this.config=n;}get client(){if(!this._client)throw new Error("Supabase client not initialized");return this._client}projectRef(){return this.tempFs.read("project-ref",true)}projectUrl(n){let r=new URL(this.config.projectsHost??Tt),i=r.hostname.replace(/^www\./,"");return `${r.protocol}//${n}.${i}${r.port?`:${r.port}`:""}`}};var Y={config_dir:"supabase",default_db_url:"file:supabase/.temp/data.db",default_db_dir:"supabase/.temp/data"};var Ve=Pe(Fe());function ms(t,e){let n=t.slice(0,e).split(/\r\n|\n|\r/g);return [n.length,n.pop().length+1]}function ds(t,e,n){let r=t.split(/\r\n|\n|\r/g),i="",s=(Math.log10(e+1)|0)+1;for(let o=e-1;o<=e+1;o++){let a=r[o-1];a&&(i+=o.toString().padEnd(s," "),i+=": ",i+=a,i+=`
13
+ `,o===e&&(i+=" ".repeat(s+n+2),i+=`^
14
+ `));}return i}var _=class extends Error{line;column;codeblock;constructor(e,n){let[r,i]=ms(n.toml,n.ptr),s=ds(n.toml,r,i);super(`Invalid TOML document: ${e}
15
15
 
16
- ${s}`,n),this.line=r,this.column=i,this.codeblock=s;}};function zi(e,t){let n=0;for(;e[t-++n]==="\\";);return --n&&n%2}function Te(e,t=0,n=e.length){let r=e.indexOf(`
17
- `,t);return e[r-1]==="\r"&&r--,r<=n?r:-1}function Ct(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
18
- `)return n;if(r==="\r"&&e[n+1]===`
19
- `)return n+1;if(r<" "&&r!==" "||r==="\x7F")throw new A("control characters are not allowed in comments",{toml:e,ptr:t})}return e.length}function K(e,t,n,r){let i;for(;(i=e[t])===" "||i===" "||!n&&(i===`
20
- `||i==="\r"&&e[t+1]===`
21
- `);)t++;return r||i!=="#"?t:K(e,Ct(e,t),n)}function Wn(e,t,n,r,i=false){if(!r)return t=Te(e,t),t<0?e.length:t;for(let s=t;s<e.length;s++){let o=e[s];if(o==="#")s=Te(e,s);else {if(o===n)return s+1;if(o===r||i&&(o===`
22
- `||o==="\r"&&e[s+1]===`
23
- `))return s}}throw new A("cannot find end of structure",{toml:e,ptr:t})}function _e(e,t){let n=e[t],r=n===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):n;t+=r.length-1;do t=e.indexOf(r,++t);while(t>-1&&n!=="'"&&zi(e,t));return t>-1&&(t+=r.length,r.length>1&&(e[t]===n&&t++,e[t]===n&&t++)),t}var Ki=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i,Ft=class e extends Date{#e=false;#n=false;#t=null;constructor(t){let n=true,r=true,i="Z";if(typeof t=="string"){let s=t.match(Ki);s?(s[1]||(n=false,t=`0000-01-01T${t}`),r=!!s[2],r&&t[10]===" "&&(t=t.replace(" ","T")),s[2]&&+s[2]>23?t="":(i=s[3]||null,t=t.toUpperCase(),!i&&r&&(t+="Z"))):t="";}super(t),isNaN(this.getTime())||(this.#e=n,this.#n=r,this.#t=i);}isDateTime(){return this.#e&&this.#n}isLocal(){return !this.#e||!this.#n||!this.#t}isDate(){return this.#e&&!this.#n}isTime(){return this.#n&&!this.#e}isValid(){return this.#e||this.#n}toISOString(){let t=super.toISOString();if(this.isDate())return t.slice(0,10);if(this.isTime())return t.slice(11,23);if(this.#t===null)return t.slice(0,-1);if(this.#t==="Z")return t;let n=+this.#t.slice(1,3)*60+ +this.#t.slice(4,6);return n=this.#t[0]==="-"?n:-n,new Date(this.getTime()-n*6e4).toISOString().slice(0,-1)+this.#t}static wrapAsOffsetDateTime(t,n="Z"){let r=new e(t);return r.#t=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#t=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#n=false,n.#t=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=false,n.#t=null,n}};var Ji=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,Yi=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,Qi=/^[+-]?0[0-9_]/,Zi=/^[0-9a-f]{2,8}$/i,zn={b:"\b",t:" ",n:`
24
- `,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function Ae(e,t=0,n=e.length){let r=e[t]==="'",i=e[t++]===e[t]&&e[t]===e[t+1];i&&(n-=2,e[t+=2]==="\r"&&t++,e[t]===`
25
- `&&t++);let s=0,o,a="",l=t;for(;t<n-1;){let c=e[t++];if(c===`
26
- `||c==="\r"&&e[t]===`
27
- `){if(!i)throw new A("newlines are not allowed in strings",{toml:e,ptr:t-1})}else if(c<" "&&c!==" "||c==="\x7F")throw new A("control characters are not allowed in strings",{toml:e,ptr:t-1});if(o){if(o=false,c==="x"||c==="u"||c==="U"){let u=e.slice(t,t+=c==="x"?2:c==="u"?4:8);if(!Zi.test(u))throw new A("invalid unicode escape",{toml:e,ptr:s});try{a+=String.fromCodePoint(parseInt(u,16));}catch{throw new A("invalid unicode escape",{toml:e,ptr:s})}}else if(i&&(c===`
28
- `||c===" "||c===" "||c==="\r")){if(t=K(e,t-1,true),e[t]!==`
29
- `&&e[t]!=="\r")throw new A("invalid escape: only line-ending whitespace may be escaped",{toml:e,ptr:s});t=K(e,t);}else if(c in zn)a+=zn[c];else throw new A("unrecognized escape sequence",{toml:e,ptr:s});l=t;}else !r&&c==="\\"&&(s=t-1,o=true,a+=e.slice(l,s));}return a+e.slice(l,n-1)}function Kn(e,t,n,r){if(e==="true")return true;if(e==="false")return false;if(e==="-inf")return -1/0;if(e==="inf"||e==="+inf")return 1/0;if(e==="nan"||e==="+nan"||e==="-nan")return NaN;if(e==="-0")return r?0n:0;let i=Ji.test(e);if(i||Yi.test(e)){if(Qi.test(e))throw new A("leading zeroes are not allowed",{toml:t,ptr:n});e=e.replace(/_/g,"");let o=+e;if(isNaN(o))throw new A("invalid number",{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(o))&&!r)throw new A("integer value cannot be represented losslessly",{toml:t,ptr:n});(i||r===true)&&(o=BigInt(e));}return o}let s=new Ft(e);if(!s.isValid())throw new A("invalid value",{toml:t,ptr:n});return s}function ts(e,t,n){let r=e.slice(t,n),i=r.indexOf("#");return i>-1&&(Ct(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function It(e,t,n,r,i){if(r===0)throw new A("document contains excessively nested structures. aborting.",{toml:e,ptr:t});let s=e[t];if(s==="["||s==="{"){let[l,c]=s==="["?Yn(e,t,r,i):Jn(e,t,r,i);if(n){if(c=K(e,c),e[c]===",")c++;else if(e[c]!==n)throw new A("expected comma or end of structure",{toml:e,ptr:c})}return [l,c]}let o;if(s==='"'||s==="'"){o=_e(e,t);let l=Ae(e,t,o);if(n){if(o=K(e,o),e[o]&&e[o]!==","&&e[o]!==n&&e[o]!==`
30
- `&&e[o]!=="\r")throw new A("unexpected character encountered",{toml:e,ptr:o});o+=+(e[o]===",");}return [l,o]}o=Wn(e,t,",",n);let a=ts(e,t,o-+(e[o-1]===","));if(!a[0])throw new A("incomplete key-value declaration: no value specified",{toml:e,ptr:t});return n&&a[1]>-1&&(o=K(e,t+a[1]),o+=+(e[o]===",")),[Kn(a[0],e,t,i),o]}var es=/^[a-zA-Z0-9-_]+[ \t]*$/;function Ce(e,t,n="="){let r=t-1,i=[],s=e.indexOf(n,t);if(s<0)throw new A("incomplete key-value: cannot find end of key",{toml:e,ptr:t});do{let o=e[t=++r];if(o!==" "&&o!==" ")if(o==='"'||o==="'"){if(o===e[t+1]&&o===e[t+2])throw new A("multiline strings are not allowed in keys",{toml:e,ptr:t});let a=_e(e,t);if(a<0)throw new A("unfinished string encountered",{toml:e,ptr:t});r=e.indexOf(".",a);let l=e.slice(a,r<0||r>s?s:r),c=Te(l);if(c>-1)throw new A("newlines are not allowed in keys",{toml:e,ptr:t+r+c});if(l.trimStart())throw new A("found extra tokens after the string part",{toml:e,ptr:a});if(s<a&&(s=e.indexOf(n,a),s<0))throw new A("incomplete key-value: cannot find end of key",{toml:e,ptr:t});i.push(Ae(e,t,a));}else {r=e.indexOf(".",t);let a=e.slice(t,r<0||r>s?s:r);if(!es.test(a))throw new A("only letter, numbers, dashes and underscores are allowed in keys",{toml:e,ptr:t});i.push(a.trimEnd());}}while(r+1&&r<s);return [i,K(e,s+1,true,true)]}function Jn(e,t,n,r){let i={},s=new Set,o;for(t++;(o=e[t++])!=="}"&&o;){if(o===",")throw new A("expected value, found comma",{toml:e,ptr:t-1});if(o==="#")t=Ct(e,t);else if(o!==" "&&o!==" "&&o!==`
31
- `&&o!=="\r"){let a,l=i,c=false,[u,p]=Ce(e,t-1);for(let g=0;g<u.length;g++){if(g&&(l=c?l[a]:l[a]={}),a=u[g],(c=Object.hasOwn(l,a))&&(typeof l[a]!="object"||s.has(l[a])))throw new A("trying to redefine an already defined value",{toml:e,ptr:t});!c&&a==="__proto__"&&Object.defineProperty(l,a,{enumerable:true,configurable:true,writable:true});}if(c)throw new A("trying to redefine an already defined value",{toml:e,ptr:t});let[h,y]=It(e,p,"}",n-1,r);s.add(h),l[a]=h,t=y;}}if(!o)throw new A("unfinished table encountered",{toml:e,ptr:t});return [i,t]}function Yn(e,t,n,r){let i=[],s;for(t++;(s=e[t++])!=="]"&&s;){if(s===",")throw new A("expected value, found comma",{toml:e,ptr:t-1});if(s==="#")t=Ct(e,t);else if(s!==" "&&s!==" "&&s!==`
32
- `&&s!=="\r"){let o=It(e,t-1,"]",n-1,r);i.push(o[0]),t=o[1];}}if(!s)throw new A("unfinished array encountered",{toml:e,ptr:t});return [i,t]}function Qn(e,t,n,r){let i=t,s=n,o,a=false,l;for(let c=0;c<e.length;c++){if(c){if(i=a?i[o]:i[o]={},s=(l=s[o]).c,r===0&&(l.t===1||l.t===2))return null;if(l.t===2){let u=i.length-1;i=i[u],s=s[u].c;}}if(o=e[c],(a=Object.hasOwn(i,o))&&s[o]?.t===0&&s[o]?.d)return null;a||(o==="__proto__"&&(Object.defineProperty(i,o,{enumerable:true,configurable:true,writable:true}),Object.defineProperty(s,o,{enumerable:true,configurable:true,writable:true})),s[o]={t:c<e.length-1&&r===2?3:r,d:false,i:0,c:{}});}if(l=s[o],l.t!==r&&!(r===1&&l.t===3)||(r===2&&(l.d||(l.d=true,i[o]=[]),i[o].push(i={}),l.c[l.i++]=l={t:1,d:false,i:0,c:{}}),l.d))return null;if(l.d=true,r===1)i=a?i[o]:i[o]={};else if(r===0&&a)return null;return [o,i,l.c]}function Dt(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},s=r,o=i;for(let a=K(e,0);a<e.length;){if(e[a]==="["){let l=e[++a]==="[",c=Ce(e,a+=+l,"]");if(l){if(e[c[1]-1]!=="]")throw new A("expected end of table declaration",{toml:e,ptr:c[1]-1});c[1]++;}let u=Qn(c[0],r,i,l?2:1);if(!u)throw new A("trying to redefine an already defined table or value",{toml:e,ptr:a});o=u[2],s=u[1],a=c[1];}else {let l=Ce(e,a),c=Qn(l[0],s,o,0);if(!c)throw new A("trying to redefine an already defined table or value",{toml:e,ptr:a});let u=It(e,l[1],void 0,t,n);c[1][c[0]]=u[0],a=u[1];}if(a=K(e,a,true),e[a]&&e[a]!==`
33
- `&&e[a]!=="\r")throw new A("each key-value declaration must be followed by an end-of-line",{toml:e,ptr:a});a=K(e,a);}return r}var Zn=/^[a-z0-9-_]+$/i;function jt(e){let t=typeof e;if(t==="object"){if(Array.isArray(e))return "array";if(e instanceof Date)return "date"}return t}function ns(e){for(let t=0;t<e.length;t++)if(jt(e[t])!=="object")return false;return e.length!=0}function Ve(e){return JSON.stringify(e).replace(/\x7f/g,"\\u007f")}function Ge(e,t,n,r){if(n===0)throw new Error("Could not stringify the object: maximum object depth exceeded");if(t==="number")return isNaN(e)?"nan":e===1/0?"inf":e===-1/0?"-inf":r&&Number.isInteger(e)?e.toFixed(1):e.toString();if(t==="bigint"||t==="boolean")return e.toString();if(t==="string")return Ve(e);if(t==="date"){if(isNaN(e.getTime()))throw new TypeError("cannot serialize invalid date");return e.toISOString()}if(t==="object")return rs(e,n,r);if(t==="array")return is(e,n,r)}function rs(e,t,n){let r=Object.keys(e);if(r.length===0)return "{}";let i="{ ";for(let s=0;s<r.length;s++){let o=r[s];s&&(i+=", "),i+=Zn.test(o)?o:Ve(o),i+=" = ",i+=Ge(e[o],jt(e[o]),t-1,n);}return i+" }"}function is(e,t,n){if(e.length===0)return "[]";let r="[ ";for(let i=0;i<e.length;i++){if(i&&(r+=", "),e[i]===null||e[i]===void 0)throw new TypeError("arrays cannot contain null or undefined values");r+=Ge(e[i],jt(e[i]),t-1,n);}return r+" ]"}function ss(e,t,n,r){if(n===0)throw new Error("Could not stringify the object: maximum object depth exceeded");let i="";for(let s=0;s<e.length;s++)i+=`${i&&`
34
- `}[[${t}]]
35
- `,i+=Xe(0,e[s],t,n,r);return i}function Xe(e,t,n,r,i){if(r===0)throw new Error("Could not stringify the object: maximum object depth exceeded");let s="",o="",a=Object.keys(t);for(let l=0;l<a.length;l++){let c=a[l];if(t[c]!==null&&t[c]!==void 0){let u=jt(t[c]);if(u==="symbol"||u==="function")throw new TypeError(`cannot serialize values of type '${u}'`);let p=Zn.test(c)?c:Ve(c);if(u==="array"&&ns(t[c]))o+=(o&&`
36
- `)+ss(t[c],n?`${n}.${p}`:p,r-1,i);else if(u==="object"){let h=n?`${n}.${p}`:p;o+=(o&&`
37
- `)+Xe(h,t[c],h,r-1,i);}else s+=p,s+=" = ",s+=Ge(t[c],u,r,i),s+=`
38
- `;}}return e&&(s||!o)&&(s=s?`[${e}]
39
- ${s}`:`[${e}]`),s&&o?`${s}
40
- ${o}`:s||o}function We(e,{maxDepth:t=1e3,numbersAsFloat:n=false}={}){if(jt(e)!=="object")throw new TypeError("stringify can only be called with an object");let r=Xe(0,e,"",t,n);return r[r.length-1]!==`
16
+ ${s}`,n),this.line=r,this.column=i,this.codeblock=s;}};function hs(t,e){let n=0;for(;t[e-++n]==="\\";);return --n&&n%2}function vt(t,e=0,n=t.length){let r=t.indexOf(`
17
+ `,e);return t[r-1]==="\r"&&r--,r<=n?r:-1}function $e(t,e){for(let n=e;n<t.length;n++){let r=t[n];if(r===`
18
+ `)return n;if(r==="\r"&&t[n+1]===`
19
+ `)return n+1;if(r<" "&&r!==" "||r==="\x7F")throw new _("control characters are not allowed in comments",{toml:t,ptr:e})}return t.length}function z(t,e,n,r){let i;for(;(i=t[e])===" "||i===" "||!n&&(i===`
20
+ `||i==="\r"&&t[e+1]===`
21
+ `);)e++;return r||i!=="#"?e:z(t,$e(t,e),n)}function ir(t,e,n,r,i=false){if(!r)return e=vt(t,e),e<0?t.length:e;for(let s=e;s<t.length;s++){let o=t[s];if(o==="#")s=vt(t,s);else {if(o===n)return s+1;if(o===r||i&&(o===`
22
+ `||o==="\r"&&t[s+1]===`
23
+ `))return s}}throw new _("cannot find end of structure",{toml:t,ptr:e})}function $t(t,e){let n=t[e],r=n===t[e+1]&&t[e+1]===t[e+2]?t.slice(e,e+3):n;e+=r.length-1;do e=t.indexOf(r,++e);while(e>-1&&n!=="'"&&hs(t,e));return e>-1&&(e+=r.length,r.length>1&&(t[e]===n&&e++,t[e]===n&&e++)),e}var gs=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i,Ie=class t extends Date{#t=false;#n=false;#e=null;constructor(e){let n=true,r=true,i="Z";if(typeof e=="string"){let s=e.match(gs);s?(s[1]||(n=false,e=`0000-01-01T${e}`),r=!!s[2],r&&e[10]===" "&&(e=e.replace(" ","T")),s[2]&&+s[2]>23?e="":(i=s[3]||null,e=e.toUpperCase(),!i&&r&&(e+="Z"))):e="";}super(e),isNaN(this.getTime())||(this.#t=n,this.#n=r,this.#e=i);}isDateTime(){return this.#t&&this.#n}isLocal(){return !this.#t||!this.#n||!this.#e}isDate(){return this.#t&&!this.#n}isTime(){return this.#n&&!this.#t}isValid(){return this.#t||this.#n}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#e===null)return e.slice(0,-1);if(this.#e==="Z")return e;let n=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return n=this.#e[0]==="-"?n:-n,new Date(this.getTime()-n*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(e,n="Z"){let r=new t(e);return r.#e=n,r}static wrapAsLocalDateTime(e){let n=new t(e);return n.#e=null,n}static wrapAsLocalDate(e){let n=new t(e);return n.#n=false,n.#e=null,n}static wrapAsLocalTime(e){let n=new t(e);return n.#t=false,n.#e=null,n}};var ys=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,bs=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,ws=/^[+-]?0[0-9_]/,Ss=/^[0-9a-f]{2,8}$/i,sr={b:"\b",t:" ",n:`
24
+ `,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function kt(t,e=0,n=t.length){let r=t[e]==="'",i=t[e++]===t[e]&&t[e]===t[e+1];i&&(n-=2,t[e+=2]==="\r"&&e++,t[e]===`
25
+ `&&e++);let s=0,o,a="",l=e;for(;e<n-1;){let c=t[e++];if(c===`
26
+ `||c==="\r"&&t[e]===`
27
+ `){if(!i)throw new _("newlines are not allowed in strings",{toml:t,ptr:e-1})}else if(c<" "&&c!==" "||c==="\x7F")throw new _("control characters are not allowed in strings",{toml:t,ptr:e-1});if(o){if(o=false,c==="x"||c==="u"||c==="U"){let u=t.slice(e,e+=c==="x"?2:c==="u"?4:8);if(!Ss.test(u))throw new _("invalid unicode escape",{toml:t,ptr:s});try{a+=String.fromCodePoint(parseInt(u,16));}catch{throw new _("invalid unicode escape",{toml:t,ptr:s})}}else if(i&&(c===`
28
+ `||c===" "||c===" "||c==="\r")){if(e=z(t,e-1,true),t[e]!==`
29
+ `&&t[e]!=="\r")throw new _("invalid escape: only line-ending whitespace may be escaped",{toml:t,ptr:s});e=z(t,e);}else if(c in sr)a+=sr[c];else throw new _("unrecognized escape sequence",{toml:t,ptr:s});l=e;}else !r&&c==="\\"&&(s=e-1,o=true,a+=t.slice(l,s));}return a+t.slice(l,n-1)}function or(t,e,n,r){if(t==="true")return true;if(t==="false")return false;if(t==="-inf")return -1/0;if(t==="inf"||t==="+inf")return 1/0;if(t==="nan"||t==="+nan"||t==="-nan")return NaN;if(t==="-0")return r?0n:0;let i=ys.test(t);if(i||bs.test(t)){if(ws.test(t))throw new _("leading zeroes are not allowed",{toml:e,ptr:n});t=t.replace(/_/g,"");let o=+t;if(isNaN(o))throw new _("invalid number",{toml:e,ptr:n});if(i){if((i=!Number.isSafeInteger(o))&&!r)throw new _("integer value cannot be represented losslessly",{toml:e,ptr:n});(i||r===true)&&(o=BigInt(t));}return o}let s=new Ie(t);if(!s.isValid())throw new _("invalid value",{toml:e,ptr:n});return s}function xs(t,e,n){let r=t.slice(e,n),i=r.indexOf("#");return i>-1&&($e(t,i),r=r.slice(0,i)),[r.trimEnd(),i]}function De(t,e,n,r,i){if(r===0)throw new _("document contains excessively nested structures. aborting.",{toml:t,ptr:e});let s=t[e];if(s==="["||s==="{"){let[l,c]=s==="["?lr(t,e,r,i):ar(t,e,r,i);if(n){if(c=z(t,c),t[c]===",")c++;else if(t[c]!==n)throw new _("expected comma or end of structure",{toml:t,ptr:c})}return [l,c]}let o;if(s==='"'||s==="'"){o=$t(t,e);let l=kt(t,e,o);if(n){if(o=z(t,o),t[o]&&t[o]!==","&&t[o]!==n&&t[o]!==`
30
+ `&&t[o]!=="\r")throw new _("unexpected character encountered",{toml:t,ptr:o});o+=+(t[o]===",");}return [l,o]}o=ir(t,e,",",n);let a=xs(t,e,o-+(t[o-1]===","));if(!a[0])throw new _("incomplete key-value declaration: no value specified",{toml:t,ptr:e});return n&&a[1]>-1&&(o=z(t,e+a[1]),o+=+(t[o]===",")),[or(a[0],t,e,i),o]}var Es=/^[a-zA-Z0-9-_]+[ \t]*$/;function Nt(t,e,n="="){let r=e-1,i=[],s=t.indexOf(n,e);if(s<0)throw new _("incomplete key-value: cannot find end of key",{toml:t,ptr:e});do{let o=t[e=++r];if(o!==" "&&o!==" ")if(o==='"'||o==="'"){if(o===t[e+1]&&o===t[e+2])throw new _("multiline strings are not allowed in keys",{toml:t,ptr:e});let a=$t(t,e);if(a<0)throw new _("unfinished string encountered",{toml:t,ptr:e});r=t.indexOf(".",a);let l=t.slice(a,r<0||r>s?s:r),c=vt(l);if(c>-1)throw new _("newlines are not allowed in keys",{toml:t,ptr:e+r+c});if(l.trimStart())throw new _("found extra tokens after the string part",{toml:t,ptr:a});if(s<a&&(s=t.indexOf(n,a),s<0))throw new _("incomplete key-value: cannot find end of key",{toml:t,ptr:e});i.push(kt(t,e,a));}else {r=t.indexOf(".",e);let a=t.slice(e,r<0||r>s?s:r);if(!Es.test(a))throw new _("only letter, numbers, dashes and underscores are allowed in keys",{toml:t,ptr:e});i.push(a.trimEnd());}}while(r+1&&r<s);return [i,z(t,s+1,true,true)]}function ar(t,e,n,r){let i={},s=new Set,o;for(e++;(o=t[e++])!=="}"&&o;){if(o===",")throw new _("expected value, found comma",{toml:t,ptr:e-1});if(o==="#")e=$e(t,e);else if(o!==" "&&o!==" "&&o!==`
31
+ `&&o!=="\r"){let a,l=i,c=false,[u,f]=Nt(t,e-1);for(let g=0;g<u.length;g++){if(g&&(l=c?l[a]:l[a]={}),a=u[g],(c=Object.hasOwn(l,a))&&(typeof l[a]!="object"||s.has(l[a])))throw new _("trying to redefine an already defined value",{toml:t,ptr:e});!c&&a==="__proto__"&&Object.defineProperty(l,a,{enumerable:true,configurable:true,writable:true});}if(c)throw new _("trying to redefine an already defined value",{toml:t,ptr:e});let[h,y]=De(t,f,"}",n-1,r);s.add(h),l[a]=h,e=y;}}if(!o)throw new _("unfinished table encountered",{toml:t,ptr:e});return [i,e]}function lr(t,e,n,r){let i=[],s;for(e++;(s=t[e++])!=="]"&&s;){if(s===",")throw new _("expected value, found comma",{toml:t,ptr:e-1});if(s==="#")e=$e(t,e);else if(s!==" "&&s!==" "&&s!==`
32
+ `&&s!=="\r"){let o=De(t,e-1,"]",n-1,r);i.push(o[0]),e=o[1];}}if(!s)throw new _("unfinished array encountered",{toml:t,ptr:e});return [i,e]}function cr(t,e,n,r){let i=e,s=n,o,a=false,l;for(let c=0;c<t.length;c++){if(c){if(i=a?i[o]:i[o]={},s=(l=s[o]).c,r===0&&(l.t===1||l.t===2))return null;if(l.t===2){let u=i.length-1;i=i[u],s=s[u].c;}}if(o=t[c],(a=Object.hasOwn(i,o))&&s[o]?.t===0&&s[o]?.d)return null;a||(o==="__proto__"&&(Object.defineProperty(i,o,{enumerable:true,configurable:true,writable:true}),Object.defineProperty(s,o,{enumerable:true,configurable:true,writable:true})),s[o]={t:c<t.length-1&&r===2?3:r,d:false,i:0,c:{}});}if(l=s[o],l.t!==r&&!(r===1&&l.t===3)||(r===2&&(l.d||(l.d=true,i[o]=[]),i[o].push(i={}),l.c[l.i++]=l={t:1,d:false,i:0,c:{}}),l.d))return null;if(l.d=true,r===1)i=a?i[o]:i[o]={};else if(r===0&&a)return null;return [o,i,l.c]}function je(t,{maxDepth:e=1e3,integersAsBigInt:n}={}){let r={},i={},s=r,o=i;for(let a=z(t,0);a<t.length;){if(t[a]==="["){let l=t[++a]==="[",c=Nt(t,a+=+l,"]");if(l){if(t[c[1]-1]!=="]")throw new _("expected end of table declaration",{toml:t,ptr:c[1]-1});c[1]++;}let u=cr(c[0],r,i,l?2:1);if(!u)throw new _("trying to redefine an already defined table or value",{toml:t,ptr:a});o=u[2],s=u[1],a=c[1];}else {let l=Nt(t,a),c=cr(l[0],s,o,0);if(!c)throw new _("trying to redefine an already defined table or value",{toml:t,ptr:a});let u=De(t,l[1],void 0,e,n);c[1][c[0]]=u[0],a=u[1];}if(a=z(t,a,true),t[a]&&t[a]!==`
33
+ `&&t[a]!=="\r")throw new _("each key-value declaration must be followed by an end-of-line",{toml:t,ptr:a});a=z(t,a);}return r}var ur=/^[a-z0-9-_]+$/i;function Ue(t){let e=typeof t;if(e==="object"){if(Array.isArray(t))return "array";if(t instanceof Date)return "date"}return e}function Ts(t){for(let e=0;e<t.length;e++)if(Ue(t[e])!=="object")return false;return t.length!=0}function Jt(t){return JSON.stringify(t).replace(/\x7f/g,"\\u007f")}function Yt(t,e,n,r){if(n===0)throw new Error("Could not stringify the object: maximum object depth exceeded");if(e==="number")return isNaN(t)?"nan":t===1/0?"inf":t===-1/0?"-inf":r&&Number.isInteger(t)?t.toFixed(1):t.toString();if(e==="bigint"||e==="boolean")return t.toString();if(e==="string")return Jt(t);if(e==="date"){if(isNaN(t.getTime()))throw new TypeError("cannot serialize invalid date");return t.toISOString()}if(e==="object")return As(t,n,r);if(e==="array")return _s(t,n,r)}function As(t,e,n){let r=Object.keys(t);if(r.length===0)return "{}";let i="{ ";for(let s=0;s<r.length;s++){let o=r[s];s&&(i+=", "),i+=ur.test(o)?o:Jt(o),i+=" = ",i+=Yt(t[o],Ue(t[o]),e-1,n);}return i+" }"}function _s(t,e,n){if(t.length===0)return "[]";let r="[ ";for(let i=0;i<t.length;i++){if(i&&(r+=", "),t[i]===null||t[i]===void 0)throw new TypeError("arrays cannot contain null or undefined values");r+=Yt(t[i],Ue(t[i]),e-1,n);}return r+" ]"}function Cs(t,e,n,r){if(n===0)throw new Error("Could not stringify the object: maximum object depth exceeded");let i="";for(let s=0;s<t.length;s++)i+=`${i&&`
34
+ `}[[${e}]]
35
+ `,i+=Qt(0,t[s],e,n,r);return i}function Qt(t,e,n,r,i){if(r===0)throw new Error("Could not stringify the object: maximum object depth exceeded");let s="",o="",a=Object.keys(e);for(let l=0;l<a.length;l++){let c=a[l];if(e[c]!==null&&e[c]!==void 0){let u=Ue(e[c]);if(u==="symbol"||u==="function")throw new TypeError(`cannot serialize values of type '${u}'`);let f=ur.test(c)?c:Jt(c);if(u==="array"&&Ts(e[c]))o+=(o&&`
36
+ `)+Cs(e[c],n?`${n}.${f}`:f,r-1,i);else if(u==="object"){let h=n?`${n}.${f}`:f;o+=(o&&`
37
+ `)+Qt(h,e[c],h,r-1,i);}else s+=f,s+=" = ",s+=Yt(e[c],u,r,i),s+=`
38
+ `;}}return t&&(s||!o)&&(s=s?`[${t}]
39
+ ${s}`:`[${t}]`),s&&o?`${s}
40
+ ${o}`:s||o}function Zt(t,{maxDepth:e=1e3,numbersAsFloat:n=false}={}){if(Ue(t)!=="object")throw new TypeError("stringify can only be called with an object");let r=Qt(0,t,"",e,n);return r[r.length-1]!==`
41
41
  `?r+`
42
- `:r}var os={storage:"EXPERIMENTAL_STORAGE",cloud:"EXPERIMENTAL_CLOUD"},as=["storage","cloud"];Object.fromEntries(as.map(e=>[e,ls(e)]));function ls(e){let t=typeof process<"u"&&process.env||void 0;return t?t.NODE_ENV==="test"?true:t[os[e]]==="1":false}function ze(e){let t=[],n="",r=0,i=e.length,s=false,o=false,a=0,l=/^create(\s+or\s+replace)?(\s+temp(orary)?)?$/i,c=p=>{er(p).length>0&&t.push(p.trim());},u=()=>{s=false,o=false,a=0;};for(;r<i;){let p=e[r],h=e[r+1];if(p==="-"&&h==="-"){for(;r<i&&e[r]!==`
43
- `;)n+=e[r],r++;continue}if(p==="/"&&h==="*"){for(n+="/*",r+=2;r<i&&!(e[r]==="*"&&e[r+1]==="/");)n+=e[r],r++;r<i&&(n+="*/",r+=2);continue}if(p==="'"){for(n+=p,r++;r<i;){if(e[r]==="'"&&e[r+1]==="'"){n+="''",r+=2;continue}if(n+=e[r],e[r]==="'"){r++;break}r++;}continue}if(p==='"'){for(n+=p,r++;r<i;){if(e[r]==='"'&&e[r+1]==='"'){n+='""',r+=2;continue}if(n+=e[r],e[r]==='"'){r++;break}r++;}continue}if(p==="$"){let y=e.indexOf("$",r+1);if(y!==-1){let g=e.slice(r,y+1);if(/^\$[A-Za-z_][A-Za-z0-9_]*\$$|^\$\$$/.test(g)){n+=g,r=y+1;let _=e.indexOf(g,r);_===-1?(n+=e.slice(r),r=i):(n+=e.slice(r,_+g.length),r=_+g.length);continue}}}if(/[A-Za-z_]/.test(p)){let y=r;for(;y<i&&/[A-Za-z0-9_]/.test(e[y]);)y++;let g=e.slice(r,y),E=g.toLowerCase();if(E==="trigger"&&l.test(er(n))?s=true:s&&E==="begin"?(o=true,a++):s&&o&&E==="case"?a++:s&&o&&E==="end"&&a>0&&a--,n+=g,r=y,s&&o&&a===0){let _=r;for(;_<i&&/\s/.test(e[_]);)_++;e[_]===";"&&(r=_+1),c(n),n="",u();}continue}if(p===";"){if(s&&o&&a>0){n+=p,r++;continue}c(n),n="",u(),r++;continue}n+=p,r++;}return c(n),t}function er(e){let t="",n=0,r=e.length;for(;n<r;){let i=e[n],s=e[n+1];if(i==="-"&&s==="-"){for(;n<r&&e[n]!==`
44
- `;)n++;continue}if(i==="/"&&s==="*"){for(n+=2;n<r&&!(e[n]==="*"&&e[n+1]==="/");)n++;n+=2;continue}t+=i,n++;}return t.trim()}function Ke(e){return typeof e=="number"?e:Number.parseInt(String(e),10)}var $e=class{driver=V;basePath;constructor(t){this.basePath=at.resolve(t.basePath);}filePath(t,n){return at.join(this.basePath,t,n)}async ensureDir(t){await V.mkdir(at.dirname(t),{recursive:true});}async getObject(t,n,r,i){let s=this.filePath(t,n),o=await V.stat(s),a=`"${createHash("md5").update(`${s}:${o.mtimeMs}`).digest("hex")}"`;if(i?.ifNoneMatch===a)return {httpStatusCode:304,metadata:this.buildMetadata(o,a,n)};if(i?.ifModifiedSince){let h=new Date(i.ifModifiedSince);if(o.mtime<=h)return {httpStatusCode:304,metadata:this.buildMetadata(o,a,n)}}let l,c,u=o.size,p=200;if(i?.range){let h=i.range.match(/^bytes=(\d+)-(\d*)$/);if(h){let y=Number.parseInt(h[1],10),g=h[2]?Number.parseInt(h[2],10):o.size-1;u=g-y+1,c=`bytes ${y}-${g}/${o.size}`,p=206,l=(await V.open(s,"r")).readableWebStream();}else l=(await V.open(s,"r")).readableWebStream();}else l=(await V.open(s,"r")).readableWebStream();return {httpStatusCode:p,metadata:{...this.buildMetadata(o,a,n),contentLength:u,contentRange:c},body:l}}async uploadObject(t,n,r,i,s,o){let a=this.filePath(t,n);await this.ensureDir(a);let l;if(i instanceof Uint8Array||Buffer.isBuffer(i))l=i;else {let p=[],h=i.getReader();for(;;){let{done:y,value:g}=await h.read();if(y)break;p.push(g);}l=Buffer.concat(p);}await V.writeFile(a,l);let c=await V.stat(a),u=`"${createHash("md5").update(l).digest("hex")}"`;return {cacheControl:o,contentLength:c.size,size:c.size,mimetype:s,lastModified:c.mtime,eTag:u}}async deleteObject(t,n,r){let i=this.filePath(t,n);await V.unlink(i).catch(s=>{if(s.code!=="ENOENT")throw s});}async deleteObjects(t,n){for(let r of n)await this.deleteObject(t,r,void 0);}async copyObject(t,n,r,i,s){let o=this.filePath(t,n),a=this.filePath(t,i);await this.ensureDir(a),await V.copyFile(o,a);let l=await V.stat(a),c=await V.readFile(a);return {httpStatusCode:200,eTag:`"${createHash("md5").update(c).digest("hex")}"`,lastModified:l.mtime}}async headObject(t,n,r){let i=this.filePath(t,n),s=await V.stat(i),o=`"${createHash("md5").update(`${i}:${s.mtimeMs}`).digest("hex")}"`;return this.buildMetadata(s,o,n)}async privateAssetUrl(t,n,r){return `file://${this.filePath(t,n)}`}buildMetadata(t,n,r){return {cacheControl:"no-cache",contentLength:Ke(t.size),size:Ke(t.size),mimetype:us(r),lastModified:t.mtime,eTag:n}}};function us(e){let t=at.extname(e).toLowerCase();return {".html":"text/html",".css":"text/css",".js":"application/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".avif":"image/avif",".pdf":"application/pdf",".txt":"text/plain",".xml":"application/xml",".zip":"application/zip",".mp4":"video/mp4",".webm":"video/webm",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2"}[t]??"application/octet-stream"}var fs=new Function("spec","return import(spec)");async function Je(e,t,n){try{return await fs(e)}catch(r){throw r?.code==="ERR_MODULE_NOT_FOUND"||/Cannot find package/.test(String(r?.message))?new Error(`Driver '${t}' selected but '${n}' is not installed. Run: bun add ${n}`):r}}function Ne(e,t={}){let n=at__default.resolve(t.cwd??process.cwd()),r=t.env??process.env,i=process.env.SUPABASE_ENV||"development",s=[`.env.${i}.local`,i==="test"?null:".env.local",`.env.${i}`,".env"].filter(a=>a!==null),o=ds(at__default.resolve(e),n);for(let a of o)for(let l of s){let c=at__default.join(a,l),u;try{u=ge.readFileSync(c,"utf-8");}catch{continue}let p;try{p=parse(u);}catch(h){throw new Error(`Failed to parse ${c}: ${h.message}`)}for(let[h,y]of Object.entries(p))r[h]===void 0&&(r[h]=y);}}function ds(e,t){let n=[],r=e,i=at__default.parse(r).root;for(;n.push(r),!(r===t||r===i);){let s=at__default.dirname(r);if(s===r)break;r=s;}return n}var hs=/^env\((\w+)\)$/;function ve(e,t=process.env){return Ye(e,t)}function Ye(e,t){if(typeof e=="string"){let n=e.match(hs);return n?t[n[1]]??"":e}if(Array.isArray(e))return e.map(n=>Ye(n,t));if(e&&typeof e=="object"){let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)return e;let r={};for(let[i,s]of Object.entries(e))r[i]=Ye(s,t);return r}return e}var gs=process.env.LITE_VERBOSE==="1";function Bt(...e){gs&&console.error(...e);}var bs=["toml","json","ts","mts","js","mjs","cjs"],ke=class extends At{ref(){return this.projectRef()}setRef(t){return this.tempFs.write("project-ref",t),this}link(t){return this.setRef(t.id),t}unlink(){return this.tempFs.delete("project-ref"),this}url(){let t=this.ref();if(!t)throw new Error("No project linked");return this.projectUrl(t)}async getConfigPath(t){let n=at__default.relative(process.cwd(),ot.config_dir);if(!t)for(let r of bs){let i=at__default.join(n,`config.${r}`);if(await V__default.access(i).then(()=>true).catch(()=>false)){t=i;break}}return t}async readConfig(t){let n=await this.getConfigPath(t);if(!n)return {};Bt(Mt.default.dim(`Using config file: ${Mt.default.cyan(`./${n}`)}`));let r=at__default.dirname(at__default.resolve(n));Ne(r);let i=n.split(".").pop(),s;switch(i){case "toml":s=Dt(await V__default.readFile(n,"utf-8"));break;case "json":s=JSON.parse(await V__default.readFile(n,"utf-8"));break;case "ts":case "mts":case "js":case "mjs":case "cjs":try{s=(await import(at__default.join(process.cwd(),n))).default;break}catch(o){throw console.error("Failed to import config file",o),o}default:throw new Error(`Unsupported config file type: ${n}`)}return ve(s)}async createConnection(){throw new Error("Not implemented")}async getConfig(t){let n=await this.readConfig(t);if("connection"in n)return {...n,connection:await n.connection};let r,i;switch(n.db?.driver){case "sqlite":i=n.db?.url??ot.default_db_url,r=await createConnection({url:i,ddlDialect:"sqlite"});break;case "pglite":{i=n.db?.url??at__default.join(process.cwd(),ot.default_db_dir);let{createPgliteConnection:s}=await Je("@supabase/lite/pglite","pglite","@electric-sql/pglite");r=await s({url:i});break}case "postgres":{i=n.db?.url??"";let{createPostgresConnection:s}=await Je("@supabase/lite/postgres","postgres","postgres");r=await s({url:i});break}default:i=n.db?.url??ot.default_db_url,r=await createConnection({url:i,ddlDialect:"postgres"});break}if(!r)throw new Error("Failed to create connection");return Bt(Mt.default.green(" \u279C"),"Database located at",Mt.default.cyan(i??"in-memory")),{...n,connection:r}}async createApp(t){let n=await this.getConfig(t),r=new App(n);return r.config.storage?.enabled&&process.env.EXPERIMENTAL_STORAGE==="1"&&!r._storageAdapter&&(r._storageAdapter=new $e({basePath:at__default.join(process.cwd(),ot.config_dir,".temp/storage")})),await r.init()}};var Le=class extends At{url(t){return this.projectUrl(t)}async ping(){return (await this.fetch("/v1/system/ping")).ok}async list(){let t=await this.fetch("/v1/projects");if(!t.ok)throw new Error("Failed to list projects");let n=await t.json();if(!Array.isArray(n))throw new Error("Failed to list projects");return n}async get(t){if(t=t??this.projectRef(),!t)throw new Error("No project ref found");let n=await this.fetch(`/v1/projects/${t}`);if(!n.ok)throw new Error(`Failed to get project: ${n.status} ${n.statusText}`);let r=await n.json();if(!r||!r.id)throw new Error("Failed to get project");return r}async create(t){if(!t.name)throw new Error("Project name is required");let n=await this.fetch("/v1/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){let i=await n.text().catch(()=>"");throw new Error(`Failed to create project: ${n.status} ${n.statusText}${i?` \u2014 ${i}`:""}`)}let r=await n.json();if(!r||!r.id)throw new Error("Failed to create project");return r}async getConfig(t){let n=await this.fetch(`/v1/projects/${t}/config`);if(!n.ok)throw new Error(`Failed to get project config: ${n.status} ${n.statusText}`);let r=await n.json();if(!r)throw new Error("Failed to get project config");return r}async setConfig(t,n){let r=await this.fetch(`/v1/projects/${t}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`Failed to set project config: ${r.status} ${r.statusText}`);return true}async createApp(t){if(!this.config.host)throw new Error("No host specified");let{data:n,error:r}=await this.client.auth.getSession();if(r)throw r;if(!n?.session?.access_token)throw new Error("Not authenticated, sign in first.");let i=await this.getConfig(t);return await new App({...i.config,connection:cloud({projectRef:t,token:n.session.access_token,host:this.config.host})}).init()}};var Pe=class extends _t{project;get client(){if(!this._client)throw new Error("Supabase client not initialized");return this._client}async getSession(){return await this.client.auth.getSession()}async getAccessToken(){let{data:t,error:n}=await this.getSession();if(n)throw n;return t?.session?.access_token}async requireSession(){let t=await this.getAccessToken();if(!t)throw new Error("Not authenticated, sign in first.");return t}async init(){let t={...this.config};return this.config.withSupabaseClient!==false&&(t.client=this.client,t.token=await this.getAccessToken()),this.project={local:new ke(t),remote:new Le(t)},this}};async function Ss(e={}){return await new Pe({host:Pt,projectsHost:be,root:ut.projectDir(),...e}).init()}var nn=Lt(Ot());var tn=Lt(Ot());var Es=["toml","json","ts","mts","js","mjs","cjs"];async function Oe(e){let t=at__default.relative(process.cwd(),ot.config_dir);if(!e)for(let n of Es){let r=at__default.join(t,`config.${n}`);if(await V__default.access(r).then(()=>true).catch(()=>false)){e=r;break}}return e}async function Ts(e){let t=await Oe(e);if(!t)return {};switch(Bt(tn.default.dim(`Using config file: ${tn.default.cyan(`./${t}`)}`)),t.split(".").pop()){case "toml":return Dt(await V__default.readFile(t,"utf-8"));case "json":return JSON.parse(await V__default.readFile(t,"utf-8"));case "ts":case "mts":case "js":case "mjs":case "cjs":try{return (await import(at__default.join(process.cwd(),t))).default}catch(r){throw console.error("Failed to import config file",r),r}default:throw new Error(`Unsupported config file type: ${t}`)}}function _s(e){if(!e||e===":memory:")return;let t=e;if(t.startsWith("file://")?t=t.slice(7):t.startsWith("file:")&&(t=t.slice(5)),!(!t||t===":memory:"))return at__default.resolve(process.cwd(),t)}async function rr(e){let t=await Oe(e);t&&Ne(at__default.dirname(at__default.resolve(t)));let n=ve(await Ts(e));if("connection"in n)return;let r=n?.db?.driver;if(r==="postgres")return;let i=n?.db?.url??(r==="pglite"?ot.default_db_dir:ot.default_db_url);return _s(i)}async function As(e={}){let t=process.cwd();if(e.recreate){console.log(nn.default.dim("Recreating database..."));try{let r=await rr();r&&ge.existsSync(r)&&(ge.rmSync(r,{recursive:!0,force:!0}),console.log(nn.default.dim(` \u279C removed ${at__default.relative(t,r)}`)));}catch{}try{ge.rmSync(at__default.join(t,"supabase",".temp"),{recursive:!0,force:!0});}catch{}}if(et(at__default.join(t,"supabase")),!await Oe()){let r={api:{port:54321},db:{driver:"sqlite-postgres",url:"file:./supabase/.temp/data.db",migrations:{schema_paths:["./schemas/schema.sql"]},seed:{sql_paths:["./seed.sql"]}},auth:{enabled:true,jwt_secret:"dev-secret-change-me",jwt_expiry:3600,enable_signup:true,email:{enable_confirmations:false}}};e.driver==="pglite"&&(r.db.driver="pglite",r.db.url=at__default.relative(process.cwd(),at__default.join(t,"supabase",".temp","data")));let i=e.configFormat??"toml",s=at__default.join(t,"supabase",`config.${i}`);i==="json"?wt(s,JSON.stringify(r)):wt(s,We(r));}et(at__default.join(t,"supabase",".temp")),et(at__default.join(t,"supabase","schemas"),()=>{wt(at__default.join(t,"supabase","schemas","schema.sql"),e.template?Cs:`-- This is a schema file for the database
45
- `);}),wt(at__default.join(t,"supabase","seed.sql"),e.template?Rs:`-- This is a seed file for the database
46
- `);}var Cs=`
42
+ `:r}var Rs={storage:"EXPERIMENTAL_STORAGE",cloud:"EXPERIMENTAL_CLOUD"},vs=["storage","cloud"];Object.fromEntries(vs.map(t=>[t,$s(t)]));function $s(t){let e=typeof process<"u"&&process.env||void 0;return e?e.NODE_ENV==="test"?true:e[Rs[t]]==="1":false}function en(t){let e=[],n="",r=0,i=t.length,s=false,o=false,a=0,l=/^create(\s+or\s+replace)?(\s+temp(orary)?)?$/i,c=f=>{pr(f).length>0&&e.push(f.trim());},u=()=>{s=false,o=false,a=0;};for(;r<i;){let f=t[r],h=t[r+1];if(f==="-"&&h==="-"){for(;r<i&&t[r]!==`
43
+ `;)n+=t[r],r++;continue}if(f==="/"&&h==="*"){for(n+="/*",r+=2;r<i&&!(t[r]==="*"&&t[r+1]==="/");)n+=t[r],r++;r<i&&(n+="*/",r+=2);continue}if(f==="'"){for(n+=f,r++;r<i;){if(t[r]==="'"&&t[r+1]==="'"){n+="''",r+=2;continue}if(n+=t[r],t[r]==="'"){r++;break}r++;}continue}if(f==='"'){for(n+=f,r++;r<i;){if(t[r]==='"'&&t[r+1]==='"'){n+='""',r+=2;continue}if(n+=t[r],t[r]==='"'){r++;break}r++;}continue}if(f==="$"){let y=t.indexOf("$",r+1);if(y!==-1){let g=t.slice(r,y+1);if(/^\$[A-Za-z_][A-Za-z0-9_]*\$$|^\$\$$/.test(g)){n+=g,r=y+1;let A=t.indexOf(g,r);A===-1?(n+=t.slice(r),r=i):(n+=t.slice(r,A+g.length),r=A+g.length);continue}}}if(/[A-Za-z_]/.test(f)){let y=r;for(;y<i&&/[A-Za-z0-9_]/.test(t[y]);)y++;let g=t.slice(r,y),E=g.toLowerCase();if(E==="trigger"&&l.test(pr(n))?s=true:s&&E==="begin"?(o=true,a++):s&&o&&E==="case"?a++:s&&o&&E==="end"&&a>0&&a--,n+=g,r=y,s&&o&&a===0){let A=r;for(;A<i&&/\s/.test(t[A]);)A++;t[A]===";"&&(r=A+1),c(n),n="",u();}continue}if(f===";"){if(s&&o&&a>0){n+=f,r++;continue}c(n),n="",u(),r++;continue}n+=f,r++;}return c(n),e}function pr(t){let e="",n=0,r=t.length;for(;n<r;){let i=t[n],s=t[n+1];if(i==="-"&&s==="-"){for(;n<r&&t[n]!==`
44
+ `;)n++;continue}if(i==="/"&&s==="*"){for(n+=2;n<r&&!(t[n]==="*"&&t[n+1]==="/");)n++;n+=2;continue}e+=i,n++;}return e.trim()}function tn(t){return typeof t=="number"?t:Number.parseInt(String(t),10)}var Pt=class{driver=V;basePath;constructor(e){this.basePath=ie.resolve(e.basePath);}filePath(e,n){return ie.join(this.basePath,e,n)}async ensureDir(e){await V.mkdir(ie.dirname(e),{recursive:true});}async getObject(e,n,r,i){let s=this.filePath(e,n),o=await V.stat(s),a=`"${createHash("md5").update(`${s}:${o.mtimeMs}`).digest("hex")}"`;if(i?.ifNoneMatch===a)return {httpStatusCode:304,metadata:this.buildMetadata(o,a,n)};if(i?.ifModifiedSince){let h=new Date(i.ifModifiedSince);if(o.mtime<=h)return {httpStatusCode:304,metadata:this.buildMetadata(o,a,n)}}let l,c,u=o.size,f=200;if(i?.range){let h=i.range.match(/^bytes=(\d+)-(\d*)$/);if(h){let y=Number.parseInt(h[1],10),g=h[2]?Number.parseInt(h[2],10):o.size-1;u=g-y+1,c=`bytes ${y}-${g}/${o.size}`,f=206,l=(await V.open(s,"r")).readableWebStream();}else l=(await V.open(s,"r")).readableWebStream();}else l=(await V.open(s,"r")).readableWebStream();return {httpStatusCode:f,metadata:{...this.buildMetadata(o,a,n),contentLength:u,contentRange:c},body:l}}async uploadObject(e,n,r,i,s,o){let a=this.filePath(e,n);await this.ensureDir(a);let l;if(i instanceof Uint8Array||Buffer.isBuffer(i))l=i;else {let f=[],h=i.getReader();for(;;){let{done:y,value:g}=await h.read();if(y)break;f.push(g);}l=Buffer.concat(f);}await V.writeFile(a,l);let c=await V.stat(a),u=`"${createHash("md5").update(l).digest("hex")}"`;return {cacheControl:o,contentLength:c.size,size:c.size,mimetype:s,lastModified:c.mtime,eTag:u}}async deleteObject(e,n,r){let i=this.filePath(e,n);await V.unlink(i).catch(s=>{if(s.code!=="ENOENT")throw s});}async deleteObjects(e,n){for(let r of n)await this.deleteObject(e,r,void 0);}async copyObject(e,n,r,i,s){let o=this.filePath(e,n),a=this.filePath(e,i);await this.ensureDir(a),await V.copyFile(o,a);let l=await V.stat(a),c=await V.readFile(a);return {httpStatusCode:200,eTag:`"${createHash("md5").update(c).digest("hex")}"`,lastModified:l.mtime}}async headObject(e,n,r){let i=this.filePath(e,n),s=await V.stat(i),o=`"${createHash("md5").update(`${i}:${s.mtimeMs}`).digest("hex")}"`;return this.buildMetadata(s,o,n)}async privateAssetUrl(e,n,r){return `file://${this.filePath(e,n)}`}buildMetadata(e,n,r){return {cacheControl:"no-cache",contentLength:tn(e.size),size:tn(e.size),mimetype:Ns(r),lastModified:e.mtime,eTag:n}}};function Ns(t){let e=ie.extname(t).toLowerCase();return {".html":"text/html",".css":"text/css",".js":"application/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".webp":"image/webp",".avif":"image/avif",".pdf":"application/pdf",".txt":"text/plain",".xml":"application/xml",".zip":"application/zip",".mp4":"video/mp4",".webm":"video/webm",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2"}[e]??"application/octet-stream"}var Ls=new Function("spec","return import(spec)");async function nn(t,e,n){try{return await Ls(t)}catch(r){throw r?.code==="ERR_MODULE_NOT_FOUND"||/Cannot find package/.test(String(r?.message))?new Error(`Driver '${e}' selected but '${n}' is not installed. Run: bun add ${n}`):r}}function He(t,e={}){let n=ie__default.resolve(e.cwd??process.cwd()),r=e.env??process.env,i=process.env.SUPABASE_ENV||"development",s=[`.env.${i}.local`,i==="test"?null:".env.local",`.env.${i}`,".env"].filter(a=>a!==null),o=Fs(ie__default.resolve(t),n);for(let a of o)for(let l of s){let c=ie__default.join(a,l),u;try{u=xt.readFileSync(c,"utf-8");}catch{continue}let f;try{f=parse(u);}catch(h){throw new Error(`Failed to parse ${c}: ${h.message}`)}for(let[h,y]of Object.entries(f))r[h]===void 0&&(r[h]=y);}}function Fs(t,e){let n=[],r=t,i=ie__default.parse(r).root;for(;n.push(r),!(r===e||r===i);){let s=ie__default.dirname(r);if(s===r)break;r=s;}return n}var Is=/^env\((\w+)\)$/;function Me(t,e=process.env){return rn(t,e)}function rn(t,e){if(typeof t=="string"){let n=t.match(Is);return n?e[n[1]]??"":t}if(Array.isArray(t))return t.map(n=>rn(n,e));if(t&&typeof t=="object"){let n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)return t;let r={};for(let[i,s]of Object.entries(t))r[i]=rn(s,e);return r}return t}var Ds=process.env.LITE_VERBOSE==="1";function qe(...t){Ds&&console.error(...t);}var Us=["toml","json","ts","mts","js","mjs","cjs"],Ot=class extends ve{ref(){return this.projectRef()}setRef(e){return this.tempFs.write("project-ref",e),this}link(e){return this.setRef(e.id),e}unlink(){return this.tempFs.delete("project-ref"),this}url(){let e=this.ref();if(!e)throw new Error("No project linked");return this.projectUrl(e)}async getConfigPath(e){let n=ie__default.relative(process.cwd(),Y.config_dir);if(!e)for(let r of Us){let i=ie__default.join(n,`config.${r}`);if(await V__default.access(i).then(()=>true).catch(()=>false)){e=i;break}}return e}async readConfig(e){let n=await this.getConfigPath(e);if(!n)return {};qe(Ve.default.dim(`Using config file: ${Ve.default.cyan(`./${n}`)}`));let r=ie__default.dirname(ie__default.resolve(n));He(r);let i=n.split(".").pop(),s;switch(i){case "toml":s=je(await V__default.readFile(n,"utf-8"));break;case "json":s=JSON.parse(await V__default.readFile(n,"utf-8"));break;case "ts":case "mts":case "js":case "mjs":case "cjs":try{s=(await import(ie__default.join(process.cwd(),n))).default;break}catch(o){throw console.error("Failed to import config file",o),o}default:throw new Error(`Unsupported config file type: ${n}`)}return Me(s)}async createConnection(){throw new Error("Not implemented")}async getConfig(e){let n=await this.readConfig(e);if("connection"in n)return {...n,connection:await n.connection};let r,i;switch(n.db?.driver){case "sqlite":i=n.db?.url??Y.default_db_url,r=await createConnection({url:i,ddlDialect:"sqlite"});break;case "pglite":{i=n.db?.url??ie__default.join(process.cwd(),Y.default_db_dir);let{createPgliteConnection:s}=await nn("@supabase/lite/pglite","pglite","@electric-sql/pglite");r=await s({url:i});break}case "postgres":{i=n.db?.url??"";let{createPostgresConnection:s}=await nn("@supabase/lite/postgres","postgres","postgres");r=await s({url:i});break}default:i=n.db?.url??Y.default_db_url,r=await createConnection({url:i,ddlDialect:"postgres"});break}if(!r)throw new Error("Failed to create connection");return qe(Ve.default.green(" \u279C"),"Database located at",Ve.default.cyan(i??"in-memory")),{...n,connection:r}}async createApp(e,n){let r=await this.getConfig(e),i=new App({...r,options:{...r.options,server:{...r.options?.server,admin:n?.admin??r.options?.server?.admin??n?.adminDefault}}});return i.config.storage?.enabled&&process.env.EXPERIMENTAL_STORAGE==="1"&&!i._storageAdapter&&(i._storageAdapter=new Pt({basePath:ie__default.join(process.cwd(),Y.config_dir,".temp/storage")})),await i.init()}};var Ft=class extends ve{url(e){return this.projectUrl(e)}async ping(){return (await this.fetch("/v1/system/ping")).ok}async list(){let e=await this.fetch("/v1/projects");if(!e.ok)throw new Error("Failed to list projects");let n=await e.json();if(!Array.isArray(n))throw new Error("Failed to list projects");return n}async get(e){if(e=e??this.projectRef(),!e)throw new Error("No project ref found");let n=await this.fetch(`/v1/projects/${e}`);if(!n.ok)throw new Error(`Failed to get project: ${n.status} ${n.statusText}`);let r=await n.json();if(!r||!r.id)throw new Error("Failed to get project");return r}async create(e){if(!e.name)throw new Error("Project name is required");let n=await this.fetch("/v1/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){let i=await n.text().catch(()=>"");throw new Error(`Failed to create project: ${n.status} ${n.statusText}${i?` \u2014 ${i}`:""}`)}let r=await n.json();if(!r||!r.id)throw new Error("Failed to create project");return r}async getConfig(e){let n=await this.fetch(`/v1/projects/${e}/config`);if(!n.ok)throw new Error(`Failed to get project config: ${n.status} ${n.statusText}`);let r=await n.json();if(!r)throw new Error("Failed to get project config");return r}async setConfig(e,n){let r=await this.fetch(`/v1/projects/${e}/config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error(`Failed to set project config: ${r.status} ${r.statusText}`);return true}async createApp(e){if(!this.config.host)throw new Error("No host specified");let{data:n,error:r}=await this.client.auth.getSession();if(r)throw r;if(!n?.session?.access_token)throw new Error("Not authenticated, sign in first.");let i=await this.getConfig(e);return await new App({...i.config,connection:cloud({projectRef:e,token:n.session.access_token,host:this.config.host})}).init()}};var It=class extends Re{project;get client(){if(!this._client)throw new Error("Supabase client not initialized");return this._client}async getSession(){return await this.client.auth.getSession()}async getAccessToken(){let{data:e,error:n}=await this.getSession();if(n)throw n;return e?.session?.access_token}async requireSession(){let e=await this.getAccessToken();if(!e)throw new Error("Not authenticated, sign in first.");return e}async init(){let e={...this.config};return this.config.withSupabaseClient!==false&&(e.client=this.client,e.token=await this.getAccessToken()),this.project={local:new Ot(e),remote:new Ft(e)},this}};async function Ms(t={}){return await new It({host:Oe,projectsHost:Tt,root:pe.projectDir(),...t}).init()}var pn=Pe(Fe());var an=Pe(Fe());var qs=["toml","json","ts","mts","js","mjs","cjs"];async function Ge(t){let e=ie__default.relative(process.cwd(),Y.config_dir);if(!t)for(let n of qs){let r=ie__default.join(e,`config.${n}`);if(await V__default.access(r).then(()=>true).catch(()=>false)){t=r;break}}return t}async function dr(t){let e=await Ge(t);if(!e)return {};switch(qe(an.default.dim(`Using config file: ${an.default.cyan(`./${e}`)}`)),e.split(".").pop()){case "toml":return je(await V__default.readFile(e,"utf-8"));case "json":return JSON.parse(await V__default.readFile(e,"utf-8"));case "ts":case "mts":case "js":case "mjs":case "cjs":try{return (await import(ie__default.join(process.cwd(),e))).default}catch(r){throw console.error("Failed to import config file",r),r}default:throw new Error(`Unsupported config file type: ${e}`)}}async function Vs(t,e=process.env){try{let n=await Ge(t);if(!n)return;He(ie__default.dirname(ie__default.resolve(n)),{env:e});let i=Me(await dr(t),e)?.auth?.publishable_key;return typeof i=="string"&&i.length>0?i:void 0}catch{return}}function Gs(t){if(!t||t===":memory:")return;let e=t;if(e.startsWith("file://")?e=e.slice(7):e.startsWith("file:")&&(e=e.slice(5)),!(!e||e===":memory:"))return ie__default.resolve(process.cwd(),e)}async function hr(t){let e=await Ge(t);e&&He(ie__default.dirname(ie__default.resolve(e)));let n=Me(await dr(t));if("connection"in n)return;let r=n?.db?.driver;if(r==="postgres")return;let i=n?.db?.url??(r==="pglite"?Y.default_db_dir:Y.default_db_url);return Gs(i)}var Ks="supabase-self-hosted";function ln(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function gr(t){let e=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",e);return new Uint8Array(n)}async function cn(t,e=Ks,n){let r=crypto.getRandomValues(new Uint8Array(17)),i=`sb_${t}_`,s=i+ln(r).slice(0,22),o=ln(await gr(`${e}|${s}`)).slice(0,8),a=`${s}_${o}`,l=await Xs(a),c=a.slice(0,i.length+5);return {key:a,hash:l,prefix:c,type:t}}async function Xs(t){return ln(await gr(t))}function yr(t,e){let n="";try{n=xt.readFileSync(t,"utf-8");}catch{n="";}let r=n.length>0?n.split(`
45
+ `):[];r.length>0&&r[r.length-1]===""&&r.pop();let i=r.filter(s=>{let o=s.match(/^([A-Za-z_][A-Za-z0-9_]*)=/);return !(o&&o[1]in e)});for(let[s,o]of Object.entries(e))i.push(`${s}=${o}`);xt.writeFileSync(t,i.join(`
46
+ `)+`
47
+ `);}function br(t,e){let n;try{n=xt.readFileSync(t,"utf-8");}catch{return [...e]}return e.filter(r=>!n.match(new RegExp(`^${r}=(.+)$`,"m"))?.[1]?.replace(/^"(.*)"$|^'(.*)'$/,(o,a,l)=>a??l??"")?.trim())}var Dt="SUPABASE_PUBLISHABLE_KEY",jt="SUPABASE_SECRET_KEY";async function Ws(t={}){let e=process.cwd();if(t.recreate){console.log(pn.default.dim("Recreating database..."));try{let o=await hr();o&&xt.existsSync(o)&&(xt.rmSync(o,{recursive:!0,force:!0}),console.log(pn.default.dim(` \u279C removed ${ie__default.relative(e,o)}`)));}catch{}try{xt.rmSync(ie__default.join(e,"supabase",".temp"),{recursive:!0,force:!0});}catch{}}if(re(ie__default.join(e,"supabase")),!await Ge()){let o={api:{port:54321},db:{driver:"sqlite-postgres",url:"file:./supabase/.temp/data.db",migrations:{schema_paths:["./schemas/schema.sql"]},seed:{sql_paths:["./seed.sql"]}},auth:{enabled:true,jwt_secret:"dev-secret-change-me",jwt_expiry:3600,enable_signup:true,publishable_key:`env(${Dt})`,secret_key:`env(${jt})`,email:{enable_confirmations:false}}};t.driver==="pglite"&&(o.db.driver="pglite",o.db.url=ie__default.relative(process.cwd(),ie__default.join(e,"supabase",".temp","data")));let a=t.configFormat??"toml",l=ie__default.join(e,"supabase",`config.${a}`);a==="json"?xe(l,JSON.stringify(o)):xe(l,Zt(o));}re(ie__default.join(e,"supabase",".temp")),re(ie__default.join(e,"supabase","schemas"),()=>{xe(ie__default.join(e,"supabase","schemas","schema.sql"),t.template?zs:`-- This is a schema file for the database
48
+ `);}),xe(ie__default.join(e,"supabase","seed.sql"),t.template?Js:`-- This is a seed file for the database
49
+ `);let r=ie__default.join(e,".env"),i=br(r,[Dt,jt]),s;if(i.length>0){let o={};if(s={},i.includes(Dt)){let a=await cn("publishable");o[Dt]=a.key,s.publishable=a.key;}if(i.includes(jt)){let a=await cn("secret");o[jt]=a.key,s.secret=a.key;}yr(r,o);}return {generatedKeys:s}}var zs=`
47
50
  create table todos (
48
51
  id serial primary key,
49
52
  title text not null,
@@ -56,7 +59,7 @@ create table todos (
56
59
  create table test (
57
60
  id serial primary key,
58
61
  name text not null
59
- )`,Rs="insert into todos (`id`, `title`, `description`, `completed`) values (1, 'test', 'test', false);\ninsert into todos (`id`, `title`, `description`, `completed`) values (2, 'test2', 'test2', true);\ninsert into test (`id`, `name`) values (1, 'test');\n";var ir=createRequire(import.meta.url);function Os(e){let t=normalize(e);return t.length>1&&t[t.length-1]===sep&&(t=t.substring(0,t.length-1)),t}var Fs=/[\\/]/g;function ar(e,t){return e.replace(Fs,t)}var Is=/^[a-z]:[\\/]$/i;function Ds(e){return e==="/"||Is.test(e)}function rn(e,t){let{resolvePaths:n,normalizePath:r,pathSeparator:i}=t,s=process.platform==="win32"&&e.includes("/")||e.startsWith(".");if(n&&(e=resolve(e)),(r||s)&&(e=Os(e)),e===".")return "";let o=e[e.length-1]!==i;return ar(o?e+i:e,i)}function lr(e,t){return t+e}function js(e,t){return function(n,r){return r.startsWith(e)?r.slice(e.length)+n:ar(relative(e,r),t.pathSeparator)+t.pathSeparator+n}}function Us(e){return e}function Bs(e,t,n){return t+e+n}function Ms(e,t){let{relativePaths:n,includeBasePath:r}=t;return n&&e?js(e,t):r?lr:Us}function Hs(e){return function(t,n){n.push(t.substring(e.length)||".");}}function qs(e){return function(t,n,r){let i=t.substring(e.length)||".";r.every(s=>s(i,true))&&n.push(i);}}var Vs=(e,t)=>{t.push(e||".");},Gs=(e,t,n)=>{let r=e||".";n.every(i=>i(r,true))&&t.push(r);},Xs=()=>{};function Ws(e,t){let{includeDirs:n,filters:r,relativePaths:i}=t;return n?i?r&&r.length?qs(e):Hs(e):r&&r.length?Gs:Vs:Xs}var zs=(e,t,n,r)=>{r.every(i=>i(e,false))&&n.files++;},Ks=(e,t,n,r)=>{r.every(i=>i(e,false))&&t.push(e);},Js=(e,t,n,r)=>{n.files++;},Ys=(e,t)=>{t.push(e);},Qs=()=>{};function Zs(e){let{excludeFiles:t,filters:n,onlyCounts:r}=e;return t?Qs:n&&n.length?r?zs:Ks:r?Js:Ys}var to=e=>e,eo=()=>[""].slice(0,0);function no(e){return e.group?eo:to}var ro=(e,t,n)=>{e.push({directory:t,files:n,dir:t});},io=()=>{};function so(e){return e.group?ro:io}var oo=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:s}}=t;r.enqueue(),i.realpath(e,(o,a)=>{if(o)return r.dequeue(s?null:o,t);i.stat(a,(l,c)=>{if(l)return r.dequeue(s?null:l,t);if(c.isDirectory()&&cr(e,a,t))return r.dequeue(null,t);n(c,a),r.dequeue(null,t);});});},ao=function(e,t,n){let{queue:r,fs:i,options:{suppressErrors:s}}=t;r.enqueue();try{let o=i.realpathSync(e),a=i.statSync(o);if(a.isDirectory()&&cr(e,o,t))return;n(a,o);}catch(o){if(!s)throw o}};function lo(e,t){return !e.resolveSymlinks||e.excludeSymlinks?null:t?ao:oo}function cr(e,t,n){if(n.options.useRealPaths)return co(t,n);let r=dirname(e),i=1;for(;r!==n.root&&i<2;){let s=n.symlinks.get(r);!!s&&(s===t||s.startsWith(t)||t.startsWith(s))?i++:r=dirname(r);}return n.symlinks.set(e,t),i>1}function co(e,t){return t.visited.includes(e+t.options.pathSeparator)}var uo=e=>e.counts,fo=e=>e.groups,po=e=>e.paths,mo=e=>e.paths.slice(0,e.options.maxFiles),ho=(e,t,n)=>(Fe(t,n,e.counts,e.options.suppressErrors),null),go=(e,t,n)=>(Fe(t,n,e.paths,e.options.suppressErrors),null),yo=(e,t,n)=>(Fe(t,n,e.paths.slice(0,e.options.maxFiles),e.options.suppressErrors),null),bo=(e,t,n)=>(Fe(t,n,e.groups,e.options.suppressErrors),null);function Fe(e,t,n,r){t(e&&!r?e:null,n);}function wo(e,t){let{onlyCounts:n,group:r,maxFiles:i}=e;return n?t?uo:ho:r?t?fo:bo:i?t?mo:yo:t?po:go}var ur={withFileTypes:true},xo=(e,t,n,r,i)=>{if(e.queue.enqueue(),r<0)return e.queue.dequeue(null,e);let{fs:s}=e;e.visited.push(t),e.counts.directories++,s.readdir(t||".",ur,(o,a=[])=>{i(a,n,r),e.queue.dequeue(e.options.suppressErrors?null:o,e);});},So=(e,t,n,r,i)=>{let{fs:s}=e;if(r<0)return;e.visited.push(t),e.counts.directories++;let o=[];try{o=s.readdirSync(t||".",ur);}catch(a){if(!e.options.suppressErrors)throw a}i(o,n,r);};function Eo(e){return e?So:xo}var To=class{count=0;constructor(e){this.onQueueEmpty=e;}enqueue(){return this.count++,this.count}dequeue(e,t){this.onQueueEmpty&&(--this.count<=0||e)&&(this.onQueueEmpty(e,t),e&&(t.controller.abort(),this.onQueueEmpty=void 0));}},_o=class{_files=0;_directories=0;set files(e){this._files=e;}get files(){return this._files}set directories(e){this._directories=e;}get directories(){return this._directories}get dirs(){return this._directories}},Ao=class{aborted=false;abort(){this.aborted=true;}},fr=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(e,t,n){this.isSynchronous=!n,this.callbackInvoker=wo(t,this.isSynchronous),this.root=rn(e,t),this.state={root:Ds(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new _o,options:t,queue:new To((r,i)=>this.callbackInvoker(i,r,n)),symlinks:new Map,visited:[""].slice(0,0),controller:new Ao,fs:t.fs||Ps},this.joinPath=Ms(this.root,t),this.pushDirectory=Ws(this.root,t),this.pushFile=Zs(t),this.getArray=no(t),this.groupFiles=so(t),this.resolveSymlink=lo(t,this.isSynchronous),this.walkDirectory=Eo(this.isSynchronous);}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(e,t,n)=>{let{paths:r,options:{filters:i,resolveSymlinks:s,excludeSymlinks:o,exclude:a,maxFiles:l,signal:c,useRealPaths:u,pathSeparator:p},controller:h}=this.state;if(h.aborted||c&&c.aborted||l&&r.length>l)return;let y=this.getArray(this.state.paths);for(let g=0;g<e.length;++g){let E=e[g];if(E.isFile()||E.isSymbolicLink()&&!s&&!o){let _=this.joinPath(E.name,t);this.pushFile(_,y,this.state.counts,i);}else if(E.isDirectory()){let _=Bs(E.name,t,this.state.options.pathSeparator);if(a&&a(E.name,_))continue;this.pushDirectory(_,r,i),this.walkDirectory(this.state,_,_,n-1,this.walk);}else if(this.resolveSymlink&&E.isSymbolicLink()){let _=lr(E.name,t);this.resolveSymlink(_,this.state,(q,S)=>{if(q.isDirectory()){if(S=rn(S,this.state.options),a&&a(E.name,u?S:_+p))return;this.walkDirectory(this.state,S,u?S:_+p,n-1,this.walk);}else {S=u?S:_;let M=basename(S),W=rn(dirname(S),this.state.options);S=this.joinPath(M,W),this.pushFile(S,y,this.state.counts,i);}});}}this.groupFiles(this.state.groups,t,y);}};function Co(e,t){return new Promise((n,r)=>{pr(e,t,(i,s)=>{if(i)return r(i);n(s);});})}function pr(e,t,n){new fr(e,t,n).start();}function Ro(e,t){return new fr(e,t).start()}var sr=class{constructor(e,t){this.root=e,this.options=t;}withPromise(){return Co(this.root,this.options)}withCallback(e){pr(this.root,this.options,e);}sync(){return Ro(this.root,this.options)}},mr=null;try{ir.resolve("picomatch"),mr=ir("picomatch");}catch{}var dr=class{globCache={};options={maxDepth:1/0,suppressErrors:true,pathSeparator:sep,filters:[]};globFunction;constructor(e){this.options={...this.options,...e},this.globFunction=this.options.globFunction;}group(){return this.options.group=true,this}withPathSeparator(e){return this.options.pathSeparator=e,this}withBasePath(){return this.options.includeBasePath=true,this}withRelativePaths(){return this.options.relativePaths=true,this}withDirs(){return this.options.includeDirs=true,this}withMaxDepth(e){return this.options.maxDepth=e,this}withMaxFiles(e){return this.options.maxFiles=e,this}withFullPaths(){return this.options.resolvePaths=true,this.options.includeBasePath=true,this}withErrors(){return this.options.suppressErrors=false,this}withSymlinks({resolvePaths:e=true}={}){return this.options.resolveSymlinks=true,this.options.useRealPaths=e,this.withFullPaths()}withAbortSignal(e){return this.options.signal=e,this}normalize(){return this.options.normalizePath=true,this}filter(e){return this.options.filters.push(e),this}onlyDirs(){return this.options.excludeFiles=true,this.options.includeDirs=true,this}exclude(e){return this.options.exclude=e,this}onlyCounts(){return this.options.onlyCounts=true,this}crawl(e){return new sr(e||".",this.options)}withGlobFunction(e){return this.globFunction=e,this}crawlWithOptions(e,t){return this.options={...this.options,...t},new sr(e||".",this.options)}glob(...e){return this.globFunction?this.globWithOptions(e):this.globWithOptions(e,{dot:true})}globWithOptions(e,...t){let n=this.globFunction||mr;if(!n)throw new Error("Please specify a glob function to use glob matching.");var r=this.globCache[e.join("\0")];return r||(r=n(e,...t),this.globCache[e.join("\0")]=r),this.options.filters.push(i=>r(i)),this}};var Nt=Lt(Ur()),ya=Array.isArray,qr=/\\/g,ba=/^[A-Za-z]:$/,Vr=process.platform==="win32",wa=/^(\/?\.\.)+$/;function xa(e,t={}){let n=e.length,r=Array(n),i=Array(n),s,o;for(s=0;s<n;s++){let a=Gr(e[s]);r[s]=a;let l=a.length,c=Array(l);for(o=0;o<l;o++)c[o]=(0, Nt.default)(a[o],t);i[s]=c;}return a=>{let l=a.split("/");if(l[0]===".."&&wa.test(a))return true;for(s=0;s<n;s++){let c=r[s],u=i[s],p=l.length,h=Math.min(p,c.length);for(o=0;o<h;){let y=c[o];if(y.includes("/"))return true;if(!u[o](l[o]))break;if(!t.noglobstar&&y==="**")return true;o++;}if(o===p)return true}return false}}var Sa=/^[A-Z]:\/$/i,Ea=Vr?e=>Sa.test(e):e=>e==="/";function Br(e,t,n){if(e===t||t.startsWith(`${e}/`)){if(n){let i=e.length+ +!Ea(e);return (s,o)=>s.slice(i,o?-1:void 0)||"."}let r=t.slice(e.length+1);return r?(i,s)=>{if(i===".")return r;let o=`${r}/${i}`;return s?o.slice(0,-1):o}:(i,s)=>s&&i!=="."?i.slice(0,-1):i}return n?r=>posix.relative(e,r)||".":r=>posix.relative(e,`${t}/${r}`)||"."}function Ta(e,t){if(t.startsWith(`${e}/`)){let n=t.slice(e.length+1);return r=>`${n}/${r}`}return n=>{let r=posix.relative(e,`${t}/${n}`);return n[n.length-1]==="/"&&r!==""?`${r}/`:r||"."}}function Mr(e){return e.replace(ba,t=>`${t}/`)}var _a={parts:true};function Gr(e){var t;let n=Nt.default.scan(e,_a);return !((t=n.parts)===null||t===void 0)&&t.length?n.parts:[e]}var Aa=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,Ca=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,Ra=e=>e.replace(Aa,"\\$&"),$a=e=>e.replace(Ca,"\\$&"),Na=Vr?$a:Ra;function va(e,t){let n=Nt.default.scan(e);return n.isGlob||n.negated}function Xt(...e){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...e);}function Xr(e){return typeof e=="string"?[e]:e??[]}var ka=/^(\/?\.\.)+/,La=/\\(?=[()[\]{}!*+?@|])/g;function gn(e,t,n,r){var i;let s=t.cwd,o=e;e[e.length-1]==="/"&&(o=e.slice(0,-1)),o[o.length-1]!=="*"&&t.expandDirectories&&(o+="/**");let a=Na(s);o=isAbsolute(o.replace(La,""))?posix.relative(a,o):posix.normalize(o);let l=(i=ka.exec(o))===null||i===void 0?void 0:i[0],c=Gr(o);if(l){let p=(l.length+1)/3,h=0,y=a.split("/");for(;h<p&&c[h+p]===y[y.length+h-p];)o=o.slice(0,(p-h-1)*3)+o.slice((p-h)*3+c[h+p].length+1)||".",h++;let g=posix.join(s,l.slice(h*3));g[0]!=="."&&n.root.length>g.length&&(n.root=Mr(g),n.depthOffset=-p+h);}if(!r&&n.depthOffset>=0){var u;(u=n.commonPath)!==null&&u!==void 0||(n.commonPath=c);let p=[],h=Math.min(n.commonPath.length,c.length);for(let y=0;y<h;y++){let g=c[y];if(g==="**"&&!c[y+1]){p.pop();break}if(y===c.length-1||g!==n.commonPath[y]||va(g))break;p.push(g);}n.depthOffset=p.length,n.commonPath=p,n.root=Mr(p.length>0?posix.join(s,...p):s);}return o}function Pa(e,t,n){let r=[],i=[];for(let s of e.ignore)s&&(s[0]!=="!"||s[1]==="(")&&i.push(gn(s,e,n,true));for(let s of t)s&&(s[0]!=="!"||s[1]==="("?r.push(gn(s,e,n,false)):(s[1]!=="!"||s[2]==="(")&&i.push(gn(s.slice(1),e,n,true)));return {match:r,ignore:i}}function Oa(e,t){let n=e.cwd,r={root:n,depthOffset:0},i=Pa(e,t,r);e.debug&&Xt("internal processing patterns:",i);let{absolute:s,caseSensitiveMatch:o,debug:a,dot:l,followSymbolicLinks:c,onlyDirectories:u}=e,p=r.root.replace(qr,""),h={dot:l,nobrace:e.braceExpansion===false,nocase:!o,noextglob:e.extglob===false,noglobstar:e.globstar===false,posix:true},y=(0, Nt.default)(i.match,h),g=(0, Nt.default)(i.ignore,h),E=xa(i.match,h),_=Br(n,p,s),q=s?_:Br(n,p,true),S=(O,N)=>{let v=q(N,true);return v!=="."&&!E(v)||g(v)},M;e.deep!==void 0&&(M=Math.round(e.deep-r.depthOffset));let W=new dr({filters:[a?(O,N)=>{let v=_(O,N),T=y(v)&&!g(v);return T&&Xt(`matched ${v}`),T}:(O,N)=>{let v=_(O,N);return y(v)&&!g(v)}],exclude:a?(O,N)=>{let v=S(O,N);return Xt(`${v?"skipped":"crawling"} ${N}`),v}:S,fs:e.fs,pathSeparator:"/",relativePaths:!s,resolvePaths:s,includeBasePath:s,resolveSymlinks:c,excludeSymlinks:!c,excludeFiles:u,includeDirs:u||!e.onlyFiles,maxDepth:M,signal:e.signal}).crawl(p);return e.debug&&Xt("internal properties:",{...r,root:p}),[W,n!==p&&!s&&Ta(n,p)]}function Fa(e,t){if(t)for(let n=e.length-1;n>=0;n--)e[n]=t(e[n]);return e}var Hr={caseSensitiveMatch:true,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:true,followSymbolicLinks:true,onlyFiles:true};function Ia(e){let t=Object.assign({},e);for(let n in Hr)t[n]===void 0&&Object.assign(t,{[n]:Hr[n]});return t.cwd=(t.cwd instanceof URL?fileURLToPath(t.cwd):resolve(t.cwd||process.cwd())).replace(qr,"/"),t.ignore=Xr(t.ignore),t.fs&&(t.fs={readdir:t.fs.readdir||readdir,readdirSync:t.fs.readdirSync||readdirSync,realpath:t.fs.realpath||realpath,realpathSync:t.fs.realpathSync||realpathSync,stat:t.fs.stat||stat,statSync:t.fs.statSync||statSync}),t.debug&&Xt("globbing with options:",t),t}function Da(e,t={}){var n;if(e&&t?.patterns)throw new Error("Cannot pass patterns as both an argument and an option");let r=ya(e)||typeof e=="string",i=Xr((n=r?e:e.patterns)!==null&&n!==void 0?n:"**/*"),s=Ia(r?t:e);return i.length>0?Oa(s,i):[]}async function Wt(e,t){let[n,r]=Da(e,t);return n?Fa(await n.withPromise(),r):[]}var k=Lt(Ot());function ft(e){return e.dialect==="postgres"?"pg":e.config?.ddlDialect==="sqlite"?"sqlite":"pg-flat"}function Et(e){return e==="sqlite"?{schema_migrations:"migrations",seed_files:"seed_files"}:e==="pg-flat"?{schema_migrations:'"supabase_migrations.schema_migrations"',seed_files:'"supabase_migrations.seed_files"'}:{schema_migrations:"supabase_migrations.schema_migrations",seed_files:"supabase_migrations.seed_files"}}function zt(e){return `'${e.replace(/'/g,"''")}'`}function ja(e){return `'${`{${e.map(r=>`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`).join(",")}}`.replace(/'/g,"''")}'`}function Wr(e,t){return t==null?"NULL":e==="pg"?ja(t):zt(JSON.stringify(t))}function yn(e){return e==null?"NULL":zt(e)}var Ua=[{name:"created_by",pgType:"text",sqliteType:"TEXT"},{name:"idempotency_key",pgType:"text",sqliteType:"TEXT"},{name:"rollback",pgType:"text[]",sqliteType:"TEXT"}];function Ba(e){let{schema_migrations:t,seed_files:n}=Et(e);return e==="pg"?["CREATE SCHEMA IF NOT EXISTS supabase_migrations",`CREATE TABLE IF NOT EXISTS ${t} (
62
+ )`,Js="insert into todos (`id`, `title`, `description`, `completed`) values (1, 'test', 'test', false);\ninsert into todos (`id`, `title`, `description`, `completed`) values (2, 'test2', 'test2', true);\ninsert into test (`id`, `name`) values (1, 'test');\n";var wr=createRequire(import.meta.url);function ro(t){let e=normalize(t);return e.length>1&&e[e.length-1]===sep&&(e=e.substring(0,e.length-1)),e}var io=/[\\/]/g;function Er(t,e){return t.replace(io,e)}var so=/^[a-z]:[\\/]$/i;function oo(t){return t==="/"||so.test(t)}function mn(t,e){let{resolvePaths:n,normalizePath:r,pathSeparator:i}=e,s=process.platform==="win32"&&t.includes("/")||t.startsWith(".");if(n&&(t=resolve(t)),(r||s)&&(t=ro(t)),t===".")return "";let o=t[t.length-1]!==i;return Er(o?t+i:t,i)}function Tr(t,e){return e+t}function ao(t,e){return function(n,r){return r.startsWith(t)?r.slice(t.length)+n:Er(relative(t,r),e.pathSeparator)+e.pathSeparator+n}}function lo(t){return t}function co(t,e,n){return e+t+n}function uo(t,e){let{relativePaths:n,includeBasePath:r}=e;return n&&t?ao(t,e):r?Tr:lo}function fo(t){return function(e,n){n.push(e.substring(t.length)||".");}}function po(t){return function(e,n,r){let i=e.substring(t.length)||".";r.every(s=>s(i,true))&&n.push(i);}}var mo=(t,e)=>{e.push(t||".");},ho=(t,e,n)=>{let r=t||".";n.every(i=>i(r,true))&&e.push(r);},go=()=>{};function yo(t,e){let{includeDirs:n,filters:r,relativePaths:i}=e;return n?i?r&&r.length?po(t):fo(t):r&&r.length?ho:mo:go}var bo=(t,e,n,r)=>{r.every(i=>i(t,false))&&n.files++;},wo=(t,e,n,r)=>{r.every(i=>i(t,false))&&e.push(t);},So=(t,e,n,r)=>{n.files++;},xo=(t,e)=>{e.push(t);},Eo=()=>{};function To(t){let{excludeFiles:e,filters:n,onlyCounts:r}=t;return e?Eo:n&&n.length?r?bo:wo:r?So:xo}var Ao=t=>t,_o=()=>[""].slice(0,0);function Co(t){return t.group?_o:Ao}var Ro=(t,e,n)=>{t.push({directory:e,files:n,dir:e});},vo=()=>{};function $o(t){return t.group?Ro:vo}var ko=function(t,e,n){let{queue:r,fs:i,options:{suppressErrors:s}}=e;r.enqueue(),i.realpath(t,(o,a)=>{if(o)return r.dequeue(s?null:o,e);i.stat(a,(l,c)=>{if(l)return r.dequeue(s?null:l,e);if(c.isDirectory()&&Ar(t,a,e))return r.dequeue(null,e);n(c,a),r.dequeue(null,e);});});},No=function(t,e,n){let{queue:r,fs:i,options:{suppressErrors:s}}=e;r.enqueue();try{let o=i.realpathSync(t),a=i.statSync(o);if(a.isDirectory()&&Ar(t,o,e))return;n(a,o);}catch(o){if(!s)throw o}};function Lo(t,e){return !t.resolveSymlinks||t.excludeSymlinks?null:e?No:ko}function Ar(t,e,n){if(n.options.useRealPaths)return Po(e,n);let r=dirname(t),i=1;for(;r!==n.root&&i<2;){let s=n.symlinks.get(r);!!s&&(s===e||s.startsWith(e)||e.startsWith(s))?i++:r=dirname(r);}return n.symlinks.set(t,e),i>1}function Po(t,e){return e.visited.includes(t+e.options.pathSeparator)}var Oo=t=>t.counts,Fo=t=>t.groups,Io=t=>t.paths,Do=t=>t.paths.slice(0,t.options.maxFiles),jo=(t,e,n)=>(Ut(e,n,t.counts,t.options.suppressErrors),null),Uo=(t,e,n)=>(Ut(e,n,t.paths,t.options.suppressErrors),null),Bo=(t,e,n)=>(Ut(e,n,t.paths.slice(0,t.options.maxFiles),t.options.suppressErrors),null),Ho=(t,e,n)=>(Ut(e,n,t.groups,t.options.suppressErrors),null);function Ut(t,e,n,r){e(t&&!r?t:null,n);}function Mo(t,e){let{onlyCounts:n,group:r,maxFiles:i}=t;return n?e?Oo:jo:r?e?Fo:Ho:i?e?Do:Bo:e?Io:Uo}var _r={withFileTypes:true},qo=(t,e,n,r,i)=>{if(t.queue.enqueue(),r<0)return t.queue.dequeue(null,t);let{fs:s}=t;t.visited.push(e),t.counts.directories++,s.readdir(e||".",_r,(o,a=[])=>{i(a,n,r),t.queue.dequeue(t.options.suppressErrors?null:o,t);});},Vo=(t,e,n,r,i)=>{let{fs:s}=t;if(r<0)return;t.visited.push(e),t.counts.directories++;let o=[];try{o=s.readdirSync(e||".",_r);}catch(a){if(!t.options.suppressErrors)throw a}i(o,n,r);};function Go(t){return t?Vo:qo}var Ko=class{count=0;constructor(t){this.onQueueEmpty=t;}enqueue(){return this.count++,this.count}dequeue(t,e){this.onQueueEmpty&&(--this.count<=0||t)&&(this.onQueueEmpty(t,e),t&&(e.controller.abort(),this.onQueueEmpty=void 0));}},Xo=class{_files=0;_directories=0;set files(t){this._files=t;}get files(){return this._files}set directories(t){this._directories=t;}get directories(){return this._directories}get dirs(){return this._directories}},Wo=class{aborted=false;abort(){this.aborted=true;}},Cr=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(t,e,n){this.isSynchronous=!n,this.callbackInvoker=Mo(e,this.isSynchronous),this.root=mn(t,e),this.state={root:oo(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new Xo,options:e,queue:new Ko((r,i)=>this.callbackInvoker(i,r,n)),symlinks:new Map,visited:[""].slice(0,0),controller:new Wo,fs:e.fs||no},this.joinPath=uo(this.root,e),this.pushDirectory=yo(this.root,e),this.pushFile=To(e),this.getArray=Co(e),this.groupFiles=$o(e),this.resolveSymlink=Lo(e,this.isSynchronous),this.walkDirectory=Go(this.isSynchronous);}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(t,e,n)=>{let{paths:r,options:{filters:i,resolveSymlinks:s,excludeSymlinks:o,exclude:a,maxFiles:l,signal:c,useRealPaths:u,pathSeparator:f},controller:h}=this.state;if(h.aborted||c&&c.aborted||l&&r.length>l)return;let y=this.getArray(this.state.paths);for(let g=0;g<t.length;++g){let E=t[g];if(E.isFile()||E.isSymbolicLink()&&!s&&!o){let A=this.joinPath(E.name,e);this.pushFile(A,y,this.state.counts,i);}else if(E.isDirectory()){let A=co(E.name,e,this.state.options.pathSeparator);if(a&&a(E.name,A))continue;this.pushDirectory(A,r,i),this.walkDirectory(this.state,A,A,n-1,this.walk);}else if(this.resolveSymlink&&E.isSymbolicLink()){let A=Tr(E.name,e);this.resolveSymlink(A,this.state,(q,x)=>{if(q.isDirectory()){if(x=mn(x,this.state.options),a&&a(E.name,u?x:A+f))return;this.walkDirectory(this.state,x,u?x:A+f,n-1,this.walk);}else {x=u?x:A;let H=basename(x),X=mn(dirname(x),this.state.options);x=this.joinPath(H,X),this.pushFile(x,y,this.state.counts,i);}});}}this.groupFiles(this.state.groups,e,y);}};function zo(t,e){return new Promise((n,r)=>{Rr(t,e,(i,s)=>{if(i)return r(i);n(s);});})}function Rr(t,e,n){new Cr(t,e,n).start();}function Jo(t,e){return new Cr(t,e).start()}var Sr=class{constructor(t,e){this.root=t,this.options=e;}withPromise(){return zo(this.root,this.options)}withCallback(t){Rr(this.root,this.options,t);}sync(){return Jo(this.root,this.options)}},vr=null;try{wr.resolve("picomatch"),vr=wr("picomatch");}catch{}var $r=class{globCache={};options={maxDepth:1/0,suppressErrors:true,pathSeparator:sep,filters:[]};globFunction;constructor(t){this.options={...this.options,...t},this.globFunction=this.options.globFunction;}group(){return this.options.group=true,this}withPathSeparator(t){return this.options.pathSeparator=t,this}withBasePath(){return this.options.includeBasePath=true,this}withRelativePaths(){return this.options.relativePaths=true,this}withDirs(){return this.options.includeDirs=true,this}withMaxDepth(t){return this.options.maxDepth=t,this}withMaxFiles(t){return this.options.maxFiles=t,this}withFullPaths(){return this.options.resolvePaths=true,this.options.includeBasePath=true,this}withErrors(){return this.options.suppressErrors=false,this}withSymlinks({resolvePaths:t=true}={}){return this.options.resolveSymlinks=true,this.options.useRealPaths=t,this.withFullPaths()}withAbortSignal(t){return this.options.signal=t,this}normalize(){return this.options.normalizePath=true,this}filter(t){return this.options.filters.push(t),this}onlyDirs(){return this.options.excludeFiles=true,this.options.includeDirs=true,this}exclude(t){return this.options.exclude=t,this}onlyCounts(){return this.options.onlyCounts=true,this}crawl(t){return new Sr(t||".",this.options)}withGlobFunction(t){return this.globFunction=t,this}crawlWithOptions(t,e){return this.options={...this.options,...e},new Sr(t||".",this.options)}glob(...t){return this.globFunction?this.globWithOptions(t):this.globWithOptions(t,{dot:true})}globWithOptions(t,...e){let n=this.globFunction||vr;if(!n)throw new Error("Please specify a glob function to use glob matching.");var r=this.globCache[t.join("\0")];return r||(r=n(t,...e),this.globCache[t.join("\0")]=r),this.options.filters.push(i=>r(i)),this}};var Ne=Pe(ei()),Ba=Array.isArray,ii=/\\/g,Ha=/^[A-Za-z]:$/,si=process.platform==="win32",Ma=/^(\/?\.\.)+$/;function qa(t,e={}){let n=t.length,r=Array(n),i=Array(n),s,o;for(s=0;s<n;s++){let a=oi(t[s]);r[s]=a;let l=a.length,c=Array(l);for(o=0;o<l;o++)c[o]=(0, Ne.default)(a[o],e);i[s]=c;}return a=>{let l=a.split("/");if(l[0]===".."&&Ma.test(a))return true;for(s=0;s<n;s++){let c=r[s],u=i[s],f=l.length,h=Math.min(f,c.length);for(o=0;o<h;){let y=c[o];if(y.includes("/"))return true;if(!u[o](l[o]))break;if(!e.noglobstar&&y==="**")return true;o++;}if(o===f)return true}return false}}var Va=/^[A-Z]:\/$/i,Ga=si?t=>Va.test(t):t=>t==="/";function ti(t,e,n){if(t===e||e.startsWith(`${t}/`)){if(n){let i=t.length+ +!Ga(t);return (s,o)=>s.slice(i,o?-1:void 0)||"."}let r=e.slice(t.length+1);return r?(i,s)=>{if(i===".")return r;let o=`${r}/${i}`;return s?o.slice(0,-1):o}:(i,s)=>s&&i!=="."?i.slice(0,-1):i}return n?r=>posix.relative(t,r)||".":r=>posix.relative(t,`${e}/${r}`)||"."}function Ka(t,e){if(e.startsWith(`${t}/`)){let n=e.slice(t.length+1);return r=>`${n}/${r}`}return n=>{let r=posix.relative(t,`${e}/${n}`);return n[n.length-1]==="/"&&r!==""?`${r}/`:r||"."}}function ni(t){return t.replace(Ha,e=>`${e}/`)}var Xa={parts:true};function oi(t){var e;let n=Ne.default.scan(t,Xa);return !((e=n.parts)===null||e===void 0)&&e.length?n.parts:[t]}var Wa=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,za=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,Ja=t=>t.replace(Wa,"\\$&"),Ya=t=>t.replace(za,"\\$&"),Qa=si?Ya:Ja;function Za(t,e){let n=Ne.default.scan(t);return n.isGlob||n.negated}function Je(...t){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...t);}function ai(t){return typeof t=="string"?[t]:t??[]}var el=/^(\/?\.\.)+/,tl=/\\(?=[()[\]{}!*+?@|])/g;function _n(t,e,n,r){var i;let s=e.cwd,o=t;t[t.length-1]==="/"&&(o=t.slice(0,-1)),o[o.length-1]!=="*"&&e.expandDirectories&&(o+="/**");let a=Qa(s);o=isAbsolute(o.replace(tl,""))?posix.relative(a,o):posix.normalize(o);let l=(i=el.exec(o))===null||i===void 0?void 0:i[0],c=oi(o);if(l){let f=(l.length+1)/3,h=0,y=a.split("/");for(;h<f&&c[h+f]===y[y.length+h-f];)o=o.slice(0,(f-h-1)*3)+o.slice((f-h)*3+c[h+f].length+1)||".",h++;let g=posix.join(s,l.slice(h*3));g[0]!=="."&&n.root.length>g.length&&(n.root=ni(g),n.depthOffset=-f+h);}if(!r&&n.depthOffset>=0){var u;(u=n.commonPath)!==null&&u!==void 0||(n.commonPath=c);let f=[],h=Math.min(n.commonPath.length,c.length);for(let y=0;y<h;y++){let g=c[y];if(g==="**"&&!c[y+1]){f.pop();break}if(y===c.length-1||g!==n.commonPath[y]||Za(g))break;f.push(g);}n.depthOffset=f.length,n.commonPath=f,n.root=ni(f.length>0?posix.join(s,...f):s);}return o}function nl(t,e,n){let r=[],i=[];for(let s of t.ignore)s&&(s[0]!=="!"||s[1]==="(")&&i.push(_n(s,t,n,true));for(let s of e)s&&(s[0]!=="!"||s[1]==="("?r.push(_n(s,t,n,false)):(s[1]!=="!"||s[2]==="(")&&i.push(_n(s.slice(1),t,n,true)));return {match:r,ignore:i}}function rl(t,e){let n=t.cwd,r={root:n,depthOffset:0},i=nl(t,e,r);t.debug&&Je("internal processing patterns:",i);let{absolute:s,caseSensitiveMatch:o,debug:a,dot:l,followSymbolicLinks:c,onlyDirectories:u}=t,f=r.root.replace(ii,""),h={dot:l,nobrace:t.braceExpansion===false,nocase:!o,noextglob:t.extglob===false,noglobstar:t.globstar===false,posix:true},y=(0, Ne.default)(i.match,h),g=(0, Ne.default)(i.ignore,h),E=qa(i.match,h),A=ti(n,f,s),q=s?A:ti(n,f,true),x=(O,$)=>{let k=q($,true);return k!=="."&&!E(k)||g(k)},H;t.deep!==void 0&&(H=Math.round(t.deep-r.depthOffset));let X=new $r({filters:[a?(O,$)=>{let k=A(O,$),T=y(k)&&!g(k);return T&&Je(`matched ${k}`),T}:(O,$)=>{let k=A(O,$);return y(k)&&!g(k)}],exclude:a?(O,$)=>{let k=x(O,$);return Je(`${k?"skipped":"crawling"} ${$}`),k}:x,fs:t.fs,pathSeparator:"/",relativePaths:!s,resolvePaths:s,includeBasePath:s,resolveSymlinks:c,excludeSymlinks:!c,excludeFiles:u,includeDirs:u||!t.onlyFiles,maxDepth:H,signal:t.signal}).crawl(f);return t.debug&&Je("internal properties:",{...r,root:f}),[X,n!==f&&!s&&Ka(n,f)]}function il(t,e){if(e)for(let n=t.length-1;n>=0;n--)t[n]=e(t[n]);return t}var ri={caseSensitiveMatch:true,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:true,followSymbolicLinks:true,onlyFiles:true};function sl(t){let e=Object.assign({},t);for(let n in ri)e[n]===void 0&&Object.assign(e,{[n]:ri[n]});return e.cwd=(e.cwd instanceof URL?fileURLToPath(e.cwd):resolve(e.cwd||process.cwd())).replace(ii,"/"),e.ignore=ai(e.ignore),e.fs&&(e.fs={readdir:e.fs.readdir||readdir,readdirSync:e.fs.readdirSync||readdirSync,realpath:e.fs.realpath||realpath,realpathSync:e.fs.realpathSync||realpathSync,stat:e.fs.stat||stat,statSync:e.fs.statSync||statSync}),e.debug&&Je("globbing with options:",e),e}function ol(t,e={}){var n;if(t&&e?.patterns)throw new Error("Cannot pass patterns as both an argument and an option");let r=Ba(t)||typeof t=="string",i=ai((n=r?t:t.patterns)!==null&&n!==void 0?n:"**/*"),s=sl(r?e:t);return i.length>0?rl(s,i):[]}async function Ye(t,e){let[n,r]=ol(t,e);return n?il(await n.withPromise(),r):[]}var N=Pe(Fe());function te(t){return t.dialect==="postgres"?"pg":t.config?.ddlDialect==="sqlite"?"sqlite":"pg-flat"}function we(t){return t==="sqlite"?{schema_migrations:"migrations",seed_files:"seed_files"}:t==="pg-flat"?{schema_migrations:'"supabase_migrations.schema_migrations"',seed_files:'"supabase_migrations.seed_files"'}:{schema_migrations:"supabase_migrations.schema_migrations",seed_files:"supabase_migrations.seed_files"}}function Qe(t){return `'${t.replace(/'/g,"''")}'`}function al(t){return `'${`{${t.map(r=>`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`).join(",")}}`.replace(/'/g,"''")}'`}function li(t,e){return e==null?"NULL":t==="pg"?al(e):Qe(JSON.stringify(e))}function Cn(t){return t==null?"NULL":Qe(t)}function ci(t){if(t==null)return [];if(Array.isArray(t))return t;if(typeof t=="string"){let e=t.trim();if(e==="")return [];try{let n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return []}}return []}function ll(t){return {version:String(t.version),name:t.name??null,statements:ci(t.statements),rollback:ci(t.rollback),created_by:t.created_by??null,idempotency_key:t.idempotency_key??null}}var cl=[{name:"created_by",pgType:"text",sqliteType:"TEXT"},{name:"idempotency_key",pgType:"text",sqliteType:"TEXT"},{name:"rollback",pgType:"text[]",sqliteType:"TEXT"}];function ul(t){let{schema_migrations:e,seed_files:n}=we(t);return t==="pg"?["CREATE SCHEMA IF NOT EXISTS supabase_migrations",`CREATE TABLE IF NOT EXISTS ${e} (
60
63
  version text NOT NULL PRIMARY KEY,
61
64
  statements text[],
62
65
  name text,
@@ -66,7 +69,7 @@ create table test (
66
69
  )`,`CREATE TABLE IF NOT EXISTS ${n} (
67
70
  path text NOT NULL PRIMARY KEY,
68
71
  hash text NOT NULL
69
- )`]:[`CREATE TABLE IF NOT EXISTS ${t} (
72
+ )`]:[`CREATE TABLE IF NOT EXISTS ${e} (
70
73
  version TEXT NOT NULL PRIMARY KEY,
71
74
  statements TEXT,
72
75
  name TEXT,
@@ -76,20 +79,20 @@ create table test (
76
79
  )`,`CREATE TABLE IF NOT EXISTS ${n} (
77
80
  path TEXT NOT NULL PRIMARY KEY,
78
81
  hash TEXT NOT NULL
79
- )`]}function Ma(e){let{schema_migrations:t}=Et(e);return [`CREATE UNIQUE INDEX IF NOT EXISTS ${e==="sqlite"?"migrations_idempotency_key_idx":"schema_migrations_idempotency_key_idx"} ON ${t} (idempotency_key)`]}function zr(e,t){let{schema_migrations:n}=Et(e);return `INSERT INTO ${n} (version, name, statements, rollback, created_by, idempotency_key) VALUES (${zt(t.version)}, ${yn(t.name)}, ${Wr(e,t.statements)}, ${Wr(e,t.rollback??null)}, ${yn(t.created_by??null)}, ${yn(t.idempotency_key??null)}) ON CONFLICT (idempotency_key) DO UPDATE SET version = EXCLUDED.version, name = EXCLUDED.name, statements = EXCLUDED.statements, rollback = EXCLUDED.rollback, created_by = EXCLUDED.created_by`}function Ha(e){let{schema_migrations:t}=Et(e);return `SELECT version FROM ${t} ORDER BY version ASC`}function qa(e){let{seed_files:t}=Et(e);return t?`SELECT path, hash FROM ${t}`:null}function Kr(e,t){let{seed_files:n}=Et(e);return n?`INSERT INTO ${n} (path, hash) VALUES (${zt(t.path)}, ${zt(t.hash)}) ON CONFLICT (path) DO UPDATE SET hash = EXCLUDED.hash`:null}async function Va(e,t){let{schema_migrations:n}=Et(t);for(let r of Ua){let i=t==="pg"?r.pgType:r.sqliteType;if(t==="pg")await e.exec(`ALTER TABLE ${n} ADD COLUMN IF NOT EXISTS ${r.name} ${i}`);else try{await e.exec(`ALTER TABLE ${n} ADD COLUMN ${r.name} ${i}`);}catch{}}}async function bn(e){let t=ft(e);for(let n of Ba(t))await e.exec(n);await Va(e,t);for(let n of Ma(t))await e.exec(n);}async function Jr(e){let t=ft(e);return ((await e.exec(Ha(t)))?.rows??[]).map(r=>r.version)}async function Yr(e){let t=ft(e),n=qa(t);return n?((await e.exec(n))?.rows??[]).map(i=>({path:i.path,hash:i.hash})):[]}var Xa=/^(\d{14})(?:_([^.]+))?\.sql$/;function Qr(e){return ft(e.connection)==="sqlite"?"./sqlite-migrations/*.sql":"./migrations/*.sql"}function Wa(e){return at__default.posix.dirname(Qr(e))}async function Kt(e){let t=at__default.join(process.cwd(),"supabase"),n=await Wt([Qr(e)],{cwd:t,absolute:true}),r=[];for(let i of n){let s=at__default.basename(i),o=Xa.exec(s);if(!o)continue;let a=await V__default.readFile(i,"utf-8");r.push({version:o[1],name:o[2]??null,filename:s,path:i,sql:a});}return r.sort((i,s)=>i.version.localeCompare(s.version))}var xi="supabase/.temp/.translation-cache.json",Si=2;async function Rl(e,t){let n=await e.connection.introspect(),r=Bn(n);await Ei(e,{...t,dbHasTables:n.tables.length>0,dbFingerprint:r}),await kl(e);let i=await e.connection.introspect();_i(i,e);}async function $l(e){return Wt(e.config.db?.seed?.sql_paths??["./seed.sql"],{cwd:at__default.join(process.cwd(),"supabase"),absolute:true})}async function Nl(e){let t=await $l(e);return Promise.all(t.map(async n=>{let r=await V__default.readFile(n,"utf-8"),i=createHash("sha256").update(r).digest("hex");return {path:at__default.relative(process.cwd(),n),hash:i,statements:splitSqlStatements(r)}}))}async function vl(e,t){if(e.config.db?.seed?.enabled===false)return 0;let r=(await Nl(e)).filter(l=>l.statements.length>0);if(r.length===0)return 0;await bn(e.connection);let i=ft(e.connection),s=new Map((await Yr(e.connection)).map(l=>[l.path,l.hash])),o=r.filter(l=>s.get(l.path)!==l.hash);if(o.length===0)return 0;console.log(k.default.dim("Seeding database..."));let a=[];for(let l of o){a.push(...l.statements);let c=Kr(i,{path:l.path,hash:l.hash});c&&a.push(c);}try{await e.connection.transaction(a);}catch(l){let c="Fix `supabase/seed.sql`, then re-run `lite dev` to reapply the schema and reseed.";throw new Error(`Seed failed and was rolled back: ${String(l.message??l)}
80
- ${c}`)}return o.reduce((l,c)=>l+c.statements.length,0)}async function kl(e){await vl(e);}async function Ll(e){let t=await Wt(e.config?.db?.migrations?.schema_paths??["./schemas/*.sql"],{cwd:at__default.join(process.cwd(),"supabase"),absolute:true}),n=await Promise.all(t.map(async r=>await V__default.readFile(r,"utf-8"))).then(r=>r.map(i=>i.split(`
82
+ )`]}function fl(t){let{schema_migrations:e}=we(t);return [`CREATE UNIQUE INDEX IF NOT EXISTS ${t==="sqlite"?"migrations_idempotency_key_idx":"schema_migrations_idempotency_key_idx"} ON ${e} (idempotency_key)`]}function ui(t,e){let{schema_migrations:n}=we(t);return `INSERT INTO ${n} (version, name, statements, rollback, created_by, idempotency_key) VALUES (${Qe(e.version)}, ${Cn(e.name)}, ${li(t,e.statements)}, ${li(t,e.rollback??null)}, ${Cn(e.created_by??null)}, ${Cn(e.idempotency_key??null)}) ON CONFLICT (idempotency_key) DO UPDATE SET version = EXCLUDED.version, name = EXCLUDED.name, statements = EXCLUDED.statements, rollback = EXCLUDED.rollback, created_by = EXCLUDED.created_by`}function pl(t){let{schema_migrations:e}=we(t);return `SELECT version FROM ${e} ORDER BY version ASC`}var ml="version, name, statements, rollback, created_by, idempotency_key";function dl(t){let{schema_migrations:e}=we(t);return `SELECT ${ml} FROM ${e} ORDER BY version ASC`}function hl(t){let{seed_files:e}=we(t);return e?`SELECT path, hash FROM ${e}`:null}function fi(t,e){let{seed_files:n}=we(t);return n?`INSERT INTO ${n} (path, hash) VALUES (${Qe(e.path)}, ${Qe(e.hash)}) ON CONFLICT (path) DO UPDATE SET hash = EXCLUDED.hash`:null}async function gl(t,e){let{schema_migrations:n}=we(e);for(let r of cl){let i=e==="pg"?r.pgType:r.sqliteType;if(e==="pg")await t.exec(`ALTER TABLE ${n} ADD COLUMN IF NOT EXISTS ${r.name} ${i}`);else try{await t.exec(`ALTER TABLE ${n} ADD COLUMN ${r.name} ${i}`);}catch{}}}async function Rn(t){let e=te(t);for(let n of ul(e))await t.exec(n);await gl(t,e);for(let n of fl(e))await t.exec(n);}async function pi(t){let e=te(t);return ((await t.exec(pl(e)))?.rows??[]).map(r=>r.version)}async function mi(t){let e=te(t);return ((await t.exec(dl(e)))?.rows??[]).map(ll)}async function di(t){let e=te(t),n=hl(e);return n?((await t.exec(n))?.rows??[]).map(i=>({path:i.path,hash:i.hash})):[]}var bl=/^(\d{14})(?:_([^.]+))?\.sql$/;function hi(t){return te(t.connection)==="sqlite"?"./sqlite-migrations/*.sql":"./migrations/*.sql"}function wl(t){return ie__default.posix.dirname(hi(t))}async function Ze(t){let e=ie__default.join(process.cwd(),"supabase"),n=await Ye([hi(t)],{cwd:e,absolute:true}),r=[];for(let i of n){let s=ie__default.basename(i),o=bl.exec(s);if(!o)continue;let a=await V__default.readFile(i,"utf-8");r.push({version:o[1],name:o[2]??null,filename:s,path:i,sql:a});}return r.sort((i,s)=>i.version.localeCompare(s.version))}async function gi(t){let e=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n)).map(r=>r.toString(16).padStart(2,"0")).join("")}async function yi(t){let e=[...t].sort((r,i)=>r.version.localeCompare(i.version)),n=await Promise.all(e.map(async r=>{let i=await gi((r.statements??[]).join(";"));return [r.version,i]}));return gi(JSON.stringify(n))}var xl="supabase/.temp/.deparse-cache.json",El=1;function Tl(t){return te(t.connection)==="pg-flat"}function Al(){return ie__default.join(process.cwd(),xl)}async function _l(t){let e=[];try{e=await mi(t.connection);}catch(n){if(!String(n).includes("no such table"))throw n}return yi(e)}async function Ae(t){if(Tl(t))try{let e=t.connection,n=SqliteConnection.serializeDeparseInfo(e.config?.translation?.deparse),[r,i]=await Promise.all([_l(t),Ht(t,await et(t))]),s={v:El,fingerprint:r,schemaHash:i,deparse:n},o=Al();await V__default.mkdir(ie__default.dirname(o),{recursive:!0}),await V__default.writeFile(o,JSON.stringify(s),"utf-8");}catch{}}var Hi=["./schemas/*.sql"],Mi="supabase/.temp/.translation-cache.json",qi=2;async function oc(t,e){let n=await t.connection.introspect(),r=Yn(n);await Vi(t,{...e,dbHasTables:n.tables.length>0,dbFingerprint:r}),await uc(t);let i=await t.connection.introspect();Gi(i,t);}async function ac(t){return Ye(t.config.db?.seed?.sql_paths??["./seed.sql"],{cwd:ie__default.join(process.cwd(),"supabase"),absolute:true})}async function lc(t){let e=await ac(t);return Promise.all(e.map(async n=>{let r=await V__default.readFile(n,"utf-8"),i=createHash("sha256").update(r).digest("hex");return {path:ie__default.relative(process.cwd(),n),hash:i,statements:splitSqlStatements(r)}}))}async function cc(t,e){if(t.config.db?.seed?.enabled===false)return 0;let r=(await lc(t)).filter(l=>l.statements.length>0);if(r.length===0)return 0;await Rn(t.connection);let i=te(t.connection),s=new Map((await di(t.connection)).map(l=>[l.path,l.hash])),o=r.filter(l=>s.get(l.path)!==l.hash);if(o.length===0)return 0;console.log(N.default.dim("Seeding database..."));let a=[];for(let l of o){a.push(...l.statements);let c=fi(i,{path:l.path,hash:l.hash});c&&a.push(c);}try{await t.connection.transaction(a);}catch(l){let c="Fix `supabase/seed.sql`, then re-run `lite dev` to reapply the schema and reseed.";throw new Error(`Seed failed and was rolled back: ${String(l.message??l)}
83
+ ${c}`)}return o.reduce((l,c)=>l+c.statements.length,0)}async function uc(t){await cc(t);}async function et(t){let e=await Ye(t.config?.db?.migrations?.schema_paths??Hi,{cwd:ie__default.join(process.cwd(),Y.config_dir),absolute:true}),n=await Promise.all(e.map(async r=>await V__default.readFile(r,"utf-8"))).then(r=>r.map(i=>i.split(`
81
84
  `).filter(s=>s.trim().length>0&&!s.trim().startsWith("--")).join(`
82
85
  `)).join(`
83
- `));return n||""}async function Ei(e,t){let n=await Ll(e);if(!(!n&&(await Kt(e)).length>0)&&!(!n&&!e.connection.config.baseSchema)){if(t?.dbHasTables&&await Ol(e,n,t.dbFingerprint)){console.log(k.default.dim("Schema unchanged \u2014 skipping translation."));return}try{let r=e.connection.createMigrator(n),i=await r.diff(),s=r.translationResult?.ast,o=await e.connection.introspect(),a=Bn(o);if(i.plan.steps.length===0){await wi(e,n,s,a);return}await r.migratePlan(i.plan,{force:t?.force??!1}),jl(i);let l=await e.connection.introspect();return await wi(e,n,s,Bn(l)),console.log(""),Ul(i),i}catch(r){if(String(r).includes("likely empty"))console.log(k.default.dim("Nothing to migrate."));else {console.error("Migration error: "+String(r));try{await e.connection.exec("rollback");}catch{}}}}}function Pl(e){return e.connection.config?.baseSchema??""}function Ti(e,t){let n=createHash("sha256");return n.update(JSON.stringify([Pl(e),t??""])),n.digest("hex")}function Bn(e){let t=(r,i)=>[...r].sort((s,o)=>i(s).localeCompare(i(o))),n={tables:t(e.tables??[],r=>`${r.schema??""}.${r.name}`).map(r=>({schema:r.schema,name:r.name,type:r.type,sql:r.sql})),columns:t(e.columns??[],r=>`${r.schema??""}.${r.table}.${r.name}`).map(r=>({schema:r.schema,table:r.table,name:r.name,type:r.type,nullable:r.nullable,default_value:r.default_value,is_primary_key:r.is_primary_key})),indexes:t(e.indexes??[],r=>`${r.schema??""}.${r.table}.${r.name}`).map(r=>({schema:r.schema,table:r.table,name:r.name,unique:r.unique,columns:r.columns})),foreign_keys:t(e.foreign_keys??[],r=>`${r.schema??""}.${r.table}.${r.column}->${r.ref_table}.${r.ref_column}`).map(r=>({schema:r.schema,table:r.table,column:r.column,ref_schema:r.ref_schema,ref_table:r.ref_table,ref_column:r.ref_column})),primary_keys:t(e.primary_keys??[],r=>`${r.schema??""}.${r.table}`).map(r=>({schema:r.schema,table:r.table,columns:r.columns})),check_constraints:t(e.check_constraints??[],r=>`${r.schema??""}.${r.table}.${r.name??""}.${r.column??""}`).map(r=>({schema:r.schema,table:r.table,name:r.name,column:r.column,expression:r.expression})),unique_constraints:t(e.unique_constraints??[],r=>`${r.schema??""}.${r.table}.${r.name}`).map(r=>({schema:r.schema,table:r.table,name:r.name,columns:r.columns})),views:t(e.views??[],r=>`${r.schema??""}.${r.name}`).map(r=>({schema:r.schema,name:r.name,sql:r.sql})),triggers:t(e.triggers??[],r=>`${r.schema??""}.${r.table}.${r.name}`).map(r=>({schema:r.schema,table:r.table,name:r.name,sql:r.sql})),custom_types:t(e.custom_types??[],r=>`${r.schema??""}.${r.type}`).map(r=>({schema:r.schema,type:r.type,kind:r.kind,values:r.values,fields:r.fields}))};return createHash("sha256").update(JSON.stringify(n)).digest("hex")}async function Ol(e,t,n){let r=e.connection;if(typeof r.updateDeparseInfo!="function")return false;let i=at__default.join(process.cwd(),xi),s;try{s=await V__default.readFile(i,"utf-8");}catch{return false}let o;try{o=JSON.parse(s);}catch{return false}if(o.v!==Si||o.hash!==Ti(e,t)||!n||o.dbFingerprint!==n||!o.ast||typeof o.ast!="object")return false;try{let a=await Promise.resolve().then(()=>(yi(),gi)),l=o.ast,c=a.collectEnums(l),u=a.collectSchema(l,c),p=a.collectVariables(l),h=a.collectTableConstraints(l),y=a.collectComments(l),g=r.config?.translation?.schemas?.defaultSchema,{policies:E,tables:_}=a.collectPolicies(l,{defaultSchema:g});return r.updateDeparseInfo({enums:c,rls:{tables:_,policies:E},schema:u,vars:p,tableConstraints:h,comments:y}),!0}catch{return false}}async function wi(e,t,n,r){if(!n||typeof n!="object")return;let i={v:Si,hash:Ti(e,t),dbFingerprint:r,ast:n},s=at__default.join(process.cwd(),xi);try{await V__default.mkdir(at__default.dirname(s),{recursive:!0}),await V__default.writeFile(s,JSON.stringify(i),"utf-8");}catch{}}function _i(e,t){console.log();let n=(i,s)=>{let o=l=>{let c=k.default.dim;return typeof l=="number"&&(l>=0&&(c=l>0?k.default.green:k.default.dim),l<0&&(c=k.default.red)),typeof l=="boolean"?l?k.default.green("\u2713"):k.default.red("\u2717"):c(String(l))},a=Object.entries(s).map(([l,c])=>`${l}: ${o(c)}`).join(k.default.dim(" / "));console.log(`${k.default.dim("[")} ${i} ${k.default.dim("]")} ${a}`);};n(k.default.green("DATA"),{tables:e.tables.length,columns:e.columns.length,indexes:e.indexes.length});let r=t.config.rls??t.connection.config.translation?.deparse?.rls??{tables:new Set([]),policies:[]};n(k.default.green("AUTH"),{enabled:!!t.config.auth?.enabled,tables:ensureVar.Set(r.tables).size,policies:ensureVar.Array(r.policies).length});}function Fl(e,t){setTimeout(()=>{console.log(k.default.dim("Watching for changes...")),Cl.watch("./supabase/schemas").on("change",async r=>{console.log(),console.log(k.default.dim(`Schema changed: ${r}`)),await Ei(e,t);let i=await e.connection.introspect();_i(i,e);});},200);}function Il(e,t){let n=r=>r;return e.plan.steps.flatMap(r=>[r.description?n(`-- ${r.description}`):"",r.sql+`
86
+ `));return n||""}async function Vi(t,e){let n=await et(t);if(!(!n&&(await Ze(t)).length>0)&&!(!n&&!t.connection.config.baseSchema)){if(e?.dbHasTables&&await pc(t,n,e.dbFingerprint)){console.log(N.default.dim("Schema unchanged \u2014 skipping translation.")),await Ae(t);return}try{let r=t.connection.createMigrator(n),i=await r.diff(),s=r.translationResult?.ast,o=await t.connection.introspect(),a=Yn(o);if(i.plan.steps.length===0){await Bi(t,n,s,a),await Ae(t);return}await r.migratePlan(i.plan,{force:e?.force??!1}),yc(i);let l=await t.connection.introspect();return await Bi(t,n,s,Yn(l)),await Ae(t),console.log(""),bc(i),i}catch(r){if(String(r).includes("likely empty"))console.log(N.default.dim("Nothing to migrate."));else {console.error("Migration error: "+String(r));try{await t.connection.exec("rollback");}catch{}}}}}function fc(t){return t.connection.config?.baseSchema??""}function Ht(t,e){let n=createHash("sha256");return n.update(JSON.stringify([fc(t),e??""])),n.digest("hex")}function Yn(t){let e=(r,i)=>[...r].sort((s,o)=>i(s).localeCompare(i(o))),n={tables:e(t.tables??[],r=>`${r.schema??""}.${r.name}`).map(r=>({schema:r.schema,name:r.name,type:r.type,sql:r.sql})),columns:e(t.columns??[],r=>`${r.schema??""}.${r.table}.${r.name}`).map(r=>({schema:r.schema,table:r.table,name:r.name,type:r.type,nullable:r.nullable,default_value:r.default_value,is_primary_key:r.is_primary_key})),indexes:e(t.indexes??[],r=>`${r.schema??""}.${r.table}.${r.name}`).map(r=>({schema:r.schema,table:r.table,name:r.name,unique:r.unique,columns:r.columns})),foreign_keys:e(t.foreign_keys??[],r=>`${r.schema??""}.${r.table}.${r.column}->${r.ref_table}.${r.ref_column}`).map(r=>({schema:r.schema,table:r.table,column:r.column,ref_schema:r.ref_schema,ref_table:r.ref_table,ref_column:r.ref_column})),primary_keys:e(t.primary_keys??[],r=>`${r.schema??""}.${r.table}`).map(r=>({schema:r.schema,table:r.table,columns:r.columns})),check_constraints:e(t.check_constraints??[],r=>`${r.schema??""}.${r.table}.${r.name??""}.${r.column??""}`).map(r=>({schema:r.schema,table:r.table,name:r.name,column:r.column,expression:r.expression})),unique_constraints:e(t.unique_constraints??[],r=>`${r.schema??""}.${r.table}.${r.name}`).map(r=>({schema:r.schema,table:r.table,name:r.name,columns:r.columns})),views:e(t.views??[],r=>`${r.schema??""}.${r.name}`).map(r=>({schema:r.schema,name:r.name,sql:r.sql})),triggers:e(t.triggers??[],r=>`${r.schema??""}.${r.table}.${r.name}`).map(r=>({schema:r.schema,table:r.table,name:r.name,sql:r.sql})),custom_types:e(t.custom_types??[],r=>`${r.schema??""}.${r.type}`).map(r=>({schema:r.schema,type:r.type,kind:r.kind,values:r.values,fields:r.fields}))};return createHash("sha256").update(JSON.stringify(n)).digest("hex")}async function pc(t,e,n){let r=t.connection;if(typeof r.updateDeparseInfo!="function")return false;let i=ie__default.join(process.cwd(),Mi),s;try{s=await V__default.readFile(i,"utf-8");}catch{return false}let o;try{o=JSON.parse(s);}catch{return false}if(o.v!==qi||o.hash!==Ht(t,e)||!n||o.dbFingerprint!==n||!o.ast||typeof o.ast!="object")return false;try{let a=await Promise.resolve().then(()=>(ji(),Di)),l=o.ast,c=a.collectEnums(l),u=a.collectSchema(l,c),f=a.collectVariables(l),h=a.collectTableConstraints(l),y=a.collectComments(l),g=r.config?.translation?.schemas?.defaultSchema,{policies:E,tables:A}=a.collectPolicies(l,{defaultSchema:g});return r.updateDeparseInfo({enums:c,rls:{tables:A,policies:E},schema:u,vars:f,tableConstraints:h,comments:y}),!0}catch{return false}}async function Bi(t,e,n,r){if(!n||typeof n!="object")return;let i={v:qi,hash:Ht(t,e),dbFingerprint:r,ast:n},s=ie__default.join(process.cwd(),Mi);try{await V__default.mkdir(ie__default.dirname(s),{recursive:!0}),await V__default.writeFile(s,JSON.stringify(i),"utf-8");}catch{}}function Gi(t,e){console.log();let n=(i,s)=>{let o=l=>{let c=N.default.dim;return typeof l=="number"&&(l>=0&&(c=l>0?N.default.green:N.default.dim),l<0&&(c=N.default.red)),typeof l=="boolean"?l?N.default.green("\u2713"):N.default.red("\u2717"):c(String(l))},a=Object.entries(s).map(([l,c])=>`${l}: ${o(c)}`).join(N.default.dim(" / "));console.log(`${N.default.dim("[")} ${i} ${N.default.dim("]")} ${a}`);};n(N.default.green("DATA"),{tables:t.tables.length,columns:t.columns.length,indexes:t.indexes.length});let r=e.config.rls??e.connection.config.translation?.deparse?.rls??{tables:new Set([]),policies:[]};n(N.default.green("AUTH"),{enabled:!!e.config.auth?.enabled,tables:ensureVar.Set(r.tables).size,policies:ensureVar.Array(r.policies).length});}function mc(t){let e=ie__default.join(process.cwd(),Y.config_dir),r=(t.config?.db?.migrations?.schema_paths??Hi).map(i=>{let s=i.split("/"),o=s.findIndex(l=>/[*?[{]/.test(l)),a=(o===-1?s.slice(0,-1):s.slice(0,o)).join("/");return ie__default.resolve(e,a||".")});return [...new Set(r)]}function dc(t,e){let n,r=setTimeout(()=>{console.log(N.default.dim("Watching for changes...")),n=sc.watch(mc(t),{ignoreInitial:true});let i=async s=>{if(!s.endsWith(".sql"))return;console.log(),console.log(N.default.dim(`Schema changed: ${s}`)),await Vi(t,e);let o=await t.connection.introspect();Gi(o,t);};n.on("change",i),n.on("add",i);},200);return async()=>{clearTimeout(r),await n?.close();}}function hc(t,e){let n=r=>r;return t.plan.steps.flatMap(r=>[r.description?n(`-- ${r.description}`):"",r.sql+`
84
87
  `]).filter(r=>r.trim().length>0).join(`
85
- `)}function Dl(e){let t=new Date;return `${t.getFullYear().toString()+(t.getMonth()+1).toString().padStart(2,"0")+t.getDate().toString().padStart(2,"0")+t.getHours().toString().padStart(2,"0")+t.getMinutes().toString().padStart(2,"0")+t.getSeconds().toString().padStart(2,"0")}.sql`}function jl(e,t){let n="./supabase/.temp/migrations";et(n);let r=Dl(),i=Il(e);wt(at__default.join(n,r),i),console.log(k.default.dim(`Migration written to ${k.default.cyan(at__default.join(n,r))}`));}function Ul({diff:e}){if(typeof e=="string"){console.log(k.default.cyan(e));return}if(!e.has_changes)return;console.log(k.default.bgWhite(k.default.black(" Schema Diff "))),console.log();let t={added:{color:k.default.green,symbol:"+"},removed:{color:k.default.red,symbol:"-"},modified:{color:k.default.yellow,symbol:"~"}};if(e.tables.length>0){console.log(k.default.dim("Tables:"));for(let n of e.tables){let{color:r,symbol:i}=t[n.type];console.log(r(`${i} ${n.name}`));}console.log();}if(e.columns.length>0){console.log(k.default.dim("Columns:"));for(let n of e.columns){let{color:r,symbol:i}=t[n.type],s="";n.changes&&(s=Object.entries(n.changes).map(([o,a])=>`${o}: ${a.from} \u2192 ${a.to}`).join(", ")),console.log(r(`${i} ${n.table}.${n.name}${s?` (${s})`:""}`));}console.log();}if(e.indexes.length>0){console.log(k.default.dim("Indexes:"));for(let n of e.indexes){let{color:r,symbol:i}=t[n.type];console.log(r(`${i} ${n.name} on ${n.table}`));}console.log();}if(e.foreign_keys.length>0){console.log(k.default.dim("Foreign Keys:"));for(let n of e.foreign_keys){let{color:r,symbol:i}=t[n.type];console.log(r(`${i} ${n.table}.${n.column} \u2192 ${n.ref_table}.${n.ref_column}`));}console.log();}}var qn=["anon","authenticated","service_role"];function Bl(e){return e==="service_role"?"NOLOGIN BYPASSRLS":"NOLOGIN"}function Vn(e){return e.size===0?"":`DO $$ BEGIN${[...e].map(n=>`
88
+ `)}function gc(t){let e=new Date;return `${e.getFullYear().toString()+(e.getMonth()+1).toString().padStart(2,"0")+e.getDate().toString().padStart(2,"0")+e.getHours().toString().padStart(2,"0")+e.getMinutes().toString().padStart(2,"0")+e.getSeconds().toString().padStart(2,"0")}.sql`}function yc(t,e){let n="./supabase/.temp/migrations";re(n);let r=gc(),i=hc(t);xe(ie__default.join(n,r),i),console.log(N.default.dim(`Migration written to ${N.default.cyan(ie__default.join(n,r))}`));}function bc({diff:t}){if(typeof t=="string"){console.log(N.default.cyan(t));return}if(!t.has_changes)return;console.log(N.default.bgWhite(N.default.black(" Schema Diff "))),console.log();let e={added:{color:N.default.green,symbol:"+"},removed:{color:N.default.red,symbol:"-"},modified:{color:N.default.yellow,symbol:"~"}};if(t.tables.length>0){console.log(N.default.dim("Tables:"));for(let n of t.tables){let{color:r,symbol:i}=e[n.type];console.log(r(`${i} ${n.name}`));}console.log();}if(t.columns.length>0){console.log(N.default.dim("Columns:"));for(let n of t.columns){let{color:r,symbol:i}=e[n.type],s="";n.changes&&(s=Object.entries(n.changes).map(([o,a])=>`${o}: ${a.from} \u2192 ${a.to}`).join(", ")),console.log(r(`${i} ${n.table}.${n.name}${s?` (${s})`:""}`));}console.log();}if(t.indexes.length>0){console.log(N.default.dim("Indexes:"));for(let n of t.indexes){let{color:r,symbol:i}=e[n.type];console.log(r(`${i} ${n.name} on ${n.table}`));}console.log();}if(t.foreign_keys.length>0){console.log(N.default.dim("Foreign Keys:"));for(let n of t.foreign_keys){let{color:r,symbol:i}=e[n.type];console.log(r(`${i} ${n.table}.${n.column} \u2192 ${n.ref_table}.${n.ref_column}`));}console.log();}}var er=["anon","authenticated","service_role"];function wc(t){return t==="service_role"?"NOLOGIN BYPASSRLS":"NOLOGIN"}function tr(t){return t.size===0?"":`DO $$ BEGIN${[...t].map(n=>`
86
89
  IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '${n}') THEN
87
- CREATE ROLE ${n} ${Bl(n)};
90
+ CREATE ROLE ${n} ${wc(n)};
88
91
  END IF;`).join("")}
89
92
  END $$;
90
- `}Vn(new Set(qn));function Ci(e,t){return e?e.quoted?e.value===t:e.value.toLowerCase()===t:false}function rt(e){return e?.quoted?e.value:e?.value.toLowerCase()}function Ml(e,t){let n="",r=t+1;for(;r<e.length;){if(e[r]==='"'&&e[r+1]==='"'){n+='"',r+=2;continue}if(e[r]==='"')return {token:{value:n,quoted:true},end:r+1};n+=e[r],r++;}return {token:{value:n,quoted:true},end:r}}function Hl(e,t){let n=t+1;for(;n<e.length;){if(e[n]==="'"&&e[n+1]==="'"){n+=2;continue}if(e[n]==="'")return n+1;n++;}return n}function ql(e,t){let n=/^\$[A-Za-z_][A-Za-z0-9_]*\$|^\$\$/.exec(e.slice(t))?.[0];if(!n)return;let r=t+n.length,i=e.indexOf(n,r);return i===-1?e.length:i+n.length}function Ri(e){let t=[],n=0;for(;n<e.length;){let r=e[n],i=e[n+1];if(/\s/.test(r)){n++;continue}if(r==="-"&&i==="-"){for(n+=2;n<e.length&&e[n]!==`
91
- `;)n++;continue}if(r==="/"&&i==="*"){for(n+=2;n<e.length&&!(e[n]==="*"&&e[n+1]==="/");)n++;n=n<e.length?n+2:n;continue}if(r==="'"){n=Hl(e,n);continue}if(r==="$"){let s=ql(e,n);if(s!==void 0){n=s;continue}}if(r==='"'){let{token:s,end:o}=Ml(e,n);t.push(s),n=o;continue}if(r===","||r===";"){t.push({value:r,quoted:false}),n++;continue}if(/[A-Za-z_]/.test(r)){let s=n;for(n++;n<e.length&&/[A-Za-z0-9_$]/.test(e[n]);)n++;t.push({value:e.slice(s,n).toLowerCase(),quoted:false});continue}n++;}return t}function Vl(e,t){let n=rt(e[t]),r=rt(e[t+1]);if((n==="create"||n==="alter")&&(r==="role"||r==="user"||r==="group"))return e[t+2]}function Gl(e){let t=new Set,n=Ri(e);for(let r=0;r<n.length;r++){if(rt(n[r])!=="create")continue;let i=Vl(n,r);for(let s of qn)Ci(i,s)&&t.add(s);}return t}function Hn(e,t,n){let r=new Set([";","as","by","check","for","granted","in","on","option","using","where","with"]);for(let i=t;i<e.length;i++){let s=rt(e[i]);if(!s||r.has(s))return;for(let o of qn)Ci(e[i],o)&&n.add(o);}}function Xl(e){let t=[],n=[];for(let r of e){if(rt(r)===";"){n.length>0&&t.push(n),n=[];continue}n.push(r);}return n.length>0&&t.push(n),t}function Ai(e,t){return e.some(n=>rt(n)===t)}function Wl(e){let t=new Set,n=Xl(Ri(e));for(let r of n){let i=rt(r[0]);for(let a=0;a<r.length;a++){let l=rt(r[a]);l==="to"&&(Ai(r,"grant")||Ai(r,"policy")||rt(r[a-1])==="owner")&&Hn(r,a+1,t),l==="from"&&i==="revoke"&&Hn(r,a+1,t);}let s=r.findIndex(a=>rt(a)==="to"),o=r.findIndex(a=>rt(a)==="on");i==="grant"&&s>1&&(o===-1||s<o)&&Hn(r,1,t);}return t}function $i(e){let t=Gl(e);return new Set([...Wl(e)].filter(n=>!t.has(n)))}async function zl(e){await e.ensureSystemSchema();let t=new Set(await Jr(e.connection)),n=await Kt(e),r=ft(e.connection),i=[],s=[];for(let o of n){if(t.has(o.version)){s.push(o);continue}let a=ze(o.sql),l;if(r==="pg-flat"){let u=await e.connection.translateDdl(o.sql),p=typeof u=="string"?u:u.ddl??"";l=ze(p);}else l=a;let c=zr(r,{version:o.version,name:o.name,statements:a});if(r==="pg"){let u=Vn($i(o.sql));u&&await e.connection.exec(u);}await e.connection.transaction([...l,c],{intent:"migration"}),i.push(o);}return n.length>0&&r!=="sqlite"&&await Kl(e,n),{applied:i,skipped:s}}async function Kl(e,t){let n=t.map(o=>o.sql).join(`
92
- `);if(!n.trim())return;let r=e.connection;if(typeof r.translateDdl!="function"||typeof r.updateDeparseInfo!="function")return;let i=await r.translateDdl(n),s=r.config?.translation?.deparse??{};r.updateDeparseInfo({...s,...i});}/*! Bundled license information:
93
+ `}tr(new Set(er));function Xi(t,e){return t?t.quoted?t.value===e:t.value.toLowerCase()===e:false}function oe(t){return t?.quoted?t.value:t?.value.toLowerCase()}function Sc(t,e){let n="",r=e+1;for(;r<t.length;){if(t[r]==='"'&&t[r+1]==='"'){n+='"',r+=2;continue}if(t[r]==='"')return {token:{value:n,quoted:true},end:r+1};n+=t[r],r++;}return {token:{value:n,quoted:true},end:r}}function xc(t,e){let n=e+1;for(;n<t.length;){if(t[n]==="'"&&t[n+1]==="'"){n+=2;continue}if(t[n]==="'")return n+1;n++;}return n}function Ec(t,e){let n=/^\$[A-Za-z_][A-Za-z0-9_]*\$|^\$\$/.exec(t.slice(e))?.[0];if(!n)return;let r=e+n.length,i=t.indexOf(n,r);return i===-1?t.length:i+n.length}function Wi(t){let e=[],n=0;for(;n<t.length;){let r=t[n],i=t[n+1];if(/\s/.test(r)){n++;continue}if(r==="-"&&i==="-"){for(n+=2;n<t.length&&t[n]!==`
94
+ `;)n++;continue}if(r==="/"&&i==="*"){for(n+=2;n<t.length&&!(t[n]==="*"&&t[n+1]==="/");)n++;n=n<t.length?n+2:n;continue}if(r==="'"){n=xc(t,n);continue}if(r==="$"){let s=Ec(t,n);if(s!==void 0){n=s;continue}}if(r==='"'){let{token:s,end:o}=Sc(t,n);e.push(s),n=o;continue}if(r===","||r===";"){e.push({value:r,quoted:false}),n++;continue}if(/[A-Za-z_]/.test(r)){let s=n;for(n++;n<t.length&&/[A-Za-z0-9_$]/.test(t[n]);)n++;e.push({value:t.slice(s,n).toLowerCase(),quoted:false});continue}n++;}return e}function Tc(t,e){let n=oe(t[e]),r=oe(t[e+1]);if((n==="create"||n==="alter")&&(r==="role"||r==="user"||r==="group"))return t[e+2]}function Ac(t){let e=new Set,n=Wi(t);for(let r=0;r<n.length;r++){if(oe(n[r])!=="create")continue;let i=Tc(n,r);for(let s of er)Xi(i,s)&&e.add(s);}return e}function Zn(t,e,n){let r=new Set([";","as","by","check","for","granted","in","on","option","using","where","with"]);for(let i=e;i<t.length;i++){let s=oe(t[i]);if(!s||r.has(s))return;for(let o of er)Xi(t[i],o)&&n.add(o);}}function _c(t){let e=[],n=[];for(let r of t){if(oe(r)===";"){n.length>0&&e.push(n),n=[];continue}n.push(r);}return n.length>0&&e.push(n),e}function Ki(t,e){return t.some(n=>oe(n)===e)}function Cc(t){let e=new Set,n=_c(Wi(t));for(let r of n){let i=oe(r[0]);for(let a=0;a<r.length;a++){let l=oe(r[a]);l==="to"&&(Ki(r,"grant")||Ki(r,"policy")||oe(r[a-1])==="owner")&&Zn(r,a+1,e),l==="from"&&i==="revoke"&&Zn(r,a+1,e);}let s=r.findIndex(a=>oe(a)==="to"),o=r.findIndex(a=>oe(a)==="on");i==="grant"&&s>1&&(o===-1||s<o)&&Zn(r,1,e);}return e}function zi(t){let e=Ac(t);return new Set([...Cc(t)].filter(n=>!e.has(n)))}async function Rc(t,e={}){await t.ensureSystemSchema();let n=new Set(await pi(t.connection)),r=await Ze(t),i=te(t.connection),s=[],o=[];for(let l of r){if(n.has(l.version)){o.push(l);continue}let c=en(l.sql),u;if(i==="pg-flat"){let h=await t.connection.translateDdl(l.sql),y=typeof h=="string"?h:h.ddl??"";u=en(y);}else u=c;let f=ui(i,{version:l.version,name:l.name,statements:c});if(i==="pg"){let h=tr(zi(l.sql));h&&await t.connection.exec(h);}await t.connection.transaction([...u,f],{intent:"migration"}),s.push(l);}let a=true;return i==="pg-flat"&&!e.persistWithDeclarative&&(await et(t)).trim()&&(a=false),i!=="sqlite"&&(r.length>0?await vc(t,r,{persist:a}):i==="pg-flat"&&a&&await Ae(t)),{applied:s,skipped:o}}async function vc(t,e,n){let r=e.map(a=>a.sql).join(`
95
+ `);if(!r.trim())return;let i=t.connection;if(typeof i.translateDdl!="function"||typeof i.updateDeparseInfo!="function")return;let s=await i.translateDdl(r),o=i.config?.translation?.deparse??{};i.updateDeparseInfo({...o,...s}),n?.persist!==false&&await Ae(t);}/*! Bundled license information:
93
96
 
94
97
  smol-toml/dist/error.js:
95
98
  smol-toml/dist/util.js:
@@ -127,4 +130,4 @@ smol-toml/dist/index.js:
127
130
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
128
131
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
129
132
  *)
130
- */export{zl as applyPendingMigrations,Ss as createApi,As as ensureInitialStructure,Rl as ensureSchema,Kt as listMigrationFiles,Wa as migrationsDir,Fl as watchSchema};
133
+ */export{Rc as applyPendingMigrations,Ms as createApi,Ws as ensureInitialStructure,oc as ensureSchema,Ze as listMigrationFiles,wl as migrationsDir,Vs as resolveConfiguredPublishableKey,dc as watchSchema};