"use strict";(globalThis.webpackChunknotion_next=globalThis.webpackChunknotion_next||[]).push([["41270"],{777109(e,t,n){let r;function i(e,t){for(let n of t)e.push(n)}n.d(t,{F4:()=>g}),n(16280),n(581454),n(944114),n(378347),n(517642),n(658004),n(733853),n(845876),n(432475),n(515024),n(731698),n(898992),n(803949);let a=Symbol("QueryArg");class s{constructor(e){this.value=e}}let l=new Set(["IS NULL","IS NOT NULL","IS TRUE","IS FALSE","=","!=","<","<=",">",">=","IS","IN","NOT IN","LIKE","NOT LIKE","MATCH"]);function o(e){if(l.has(e))return e;throw Error(`Not a SQL operator: "${e}"`)}class p{chunks=[];args=[];static TagName="sql";appendTemplate(e,...t){if(!Array.isArray(e)||!Array.isArray(e.raw))throw Error("sql`` can only be used as a template literal tag");for(let n of e)if(this.appendRaw_DANGEROUS(n),t.length){let e=t.shift();if(e instanceof s){this.appendIdentifier(e);continue}if(e instanceof p){this.append(e);continue}this.appendArg(e)}return this}append(e){return i(this.chunks,e.chunks),i(this.args,e.args),this}appendArg(e){return this.chunks.push(a),this.args.push(e),this}appendRaw_DANGEROUS(e){return this.chunks.push(e),this}appendIdentifier(e){let t=e instanceof s?e.value:e;return this.appendRaw_DANGEROUS(this.escapeIdentifier(t))}escapeIdentifier(e){if(/^[\w]+$/.test(e))return`"${e}"`;throw Error(`Unexpected SQL identifier format: ${e}`)}sql(){let e=0;return this.chunks.map(t=>t===a?`$${++e}`:t).join("")}toString(){let e=JSON.stringify(this.args),t=this.constructor,n=t===p?"Sql":t.name||t.TagName;return`${n}(\`${this.sql()}\`, ${e})`}DEBUG_ONLY_getInterpolatedQuery(){let e=0;return this.chunks.map(t=>{if(t===a){let t=this.args[e];return e++,function(e){if(Array.isArray(e)){let t=!1,n=e.map(e=>"string"==typeof e?d(e):("number"==typeof e||(t=!0),e));if(!t)return`ARRAY[${n.join(",")}]`}if(null==e)return"NULL";switch(typeof e){case"string":case"symbol":return d(String(e));case"number":case"bigint":case"boolean":return String(e);case"function":case"object":case"undefined":return d(JSON.stringify(e))}}(t)}return t}).join("")}}function u(e,t){if(t instanceof p)return t;if("string"==typeof t){if(!/^[ \t]*$/.test(t))throw Error(`Unexpected indent format ${t}`);return e.raw_DANGEROUS(t)}if(t<0)return;let n=" ".repeat(t);return e`\n`.appendRaw_DANGEROUS(`${n}`)}function c(e,t,n){let r=e``;return t.forEach((e,i)=>{r.append(e),i!==t.length-1&&r.append(n)}),r}"u"e),l=function(e){try{return r?r.highlight(e):e}catch{return e}}(n),o=l.split("\n"),p=[a?s(`(${a}) `,"undefined"):"",s(i??"sql","special"),s("`","string")];return o.length>2?(n.startsWith("\n")||p.push("\n"),p.push(o.map(e=>` ${e}`).join("\n")),n.endsWith("\n")||p.push("\n")):p.push(l),p.push(s("`","string")),p.join("")}({sql:this.DEBUG_ONLY_getInterpolatedQuery(),tagName:this.constructor.TagName||"sql",className:this.constructor===p?void 0:this.constructor.name},t)});let f=new p().appendRaw_DANGEROUS(" "),h=new p;function d(e){let t=!1,n="'";for(let r=0;rnew t().appendTemplate(e,...n));function i(t,n){if(n&&t){let r=new e;return r.appendIdentifier(t),r.appendRaw_DANGEROUS("."),r.appendIdentifier(n),r}return n?new e().appendIdentifier(n):new e().appendIdentifier(String(t))}return r.raw_DANGEROUS=t=>new e().appendRaw_DANGEROUS(t),r.chooseRaw=(t,n)=>{if(Object.hasOwn(t,n))return new e().appendRaw_DANGEROUS(t[n]);throw Error(`Invalid SQL literal: ${String(n)} not in ${Object.keys(t).join(", ")}`)},r.ident=t=>new e().appendIdentifier(t),r.idents=e=>r.comma(e.map(r.ident)),r.col=(e,t)=>t?i(e,t):i(e),r.cols=t=>{var r;let i,a,s,l,o,p,u;return null!=t&&t.prefix?i=t.prefix:null!=t&&t.table&&(i="string"==typeof t.table?new e().appendIdentifier(t.table):new e().append(t.table)).appendRaw_DANGEROUS("."),r={dialect:e,prefix:i,iterable:null==t?void 0:t.allowed},a=Object.create(null),s=r.dialect,l=r.prefix,o=r.iterable?new Set(r.iterable):void 0,p=e=>{let t=new s;return l&&t.append(l),t.appendIdentifier(e)},u=e=>{if("string"==typeof e)return!o||!!o.has(e);return!1},o&&(a[Symbol.iterator]=()=>n(331653).jY.map(o,p)[Symbol.iterator]()),new Proxy(a,{get:(e,t,n)=>u(t)?p(t):Reflect.get(e,t,n),has:(e,t)=>u(t)||Reflect.has(e,t),ownKeys(e){let t=Object.keys(e);return o?Array.from(o).concat(t):t}})},r.op=t=>new e().appendRaw_DANGEROUS(o(t)),r.expr=(t,n,r)=>{let i=new e;if("string"==typeof t){let e=t.split(".");for(let t=0;tc(r,e,t),r.and=(e,t)=>(function(e,t,n=-1){if(0===t.length)return e`TRUE`;if(1===t.length)return e`(${t[0]})`;let r=u(e,n),i=c(e,t,e`${r??f}AND `);return e`(${r??h}${i})`})(r,e,t),r.or=(e,t)=>(function(e,t,n=-1){if(0===t.length)return e`FALSE`;if(1===t.length)return e`(${t[0]})`;let r=u(e,n),i=c(e,t,e`${r??f}OR `);return e`(${r??h}${i})`})(r,e,t),r.comma=(e,t)=>(function(e,t,n=-1){return c(e,t,e`,${u(e,n)??f}`)})(r,e,t),r.newline=e=>u(r,e??0)??r`\n`,r.comment=t=>new e().appendRaw_DANGEROUS(`/* ${t.replace(/\/(?=\*)|\*(?=\/)/g,"$& ")} */`),r}(class extends p{static TagName="sqlite";static fromColumnType(e){if(!(0,n(446130).tx)(e))throw Error(`Not a valid Sqlite column type: "${e}"`);return g.raw_DANGEROUS(e)}sql(){return this.chunks.map(e=>e===a?"?":e).join("")}asRead(){return{sql:this.sql(),args:this.args,getData:!0}}asWrite(){return{sql:this.sql(),args:this.args}}async all(e,t){return(0,n(911822).qU)({connection:e,sql:this.sql(),args:this.args,queryName:t})}async first(e){return(await this.all(e))[0]}async run(e){return(0,n(911822).kx)({connection:e,sql:this.sql(),args:this.args})}})},446130(e,t,n){function r(e){switch(e){case"TEXT":case"NUMERIC":case"INTEGER":case"REAL":case"BLOB":return!0;default:return!1}}function i(e){return"Error"===e.type||"ErrorBefore"===e.type||"PreconditionFailed"===e.type||"OutOfSpace"===e.type||"SharedWorkerFailedToDelegate"===e.type}function a(e){return e}n.d(t,{Ll:()=>i,Xb:()=>a,tx:()=>r})}}]);