"use strict";(globalThis.webpackChunknotion_next=globalThis.webpackChunknotion_next||[]).push([[47384],{161179:(e,t,n)=>{n.d(t,{A:()=>r});n(16280);function r(e){if(e instanceof Error)return e;if("string"==typeof e)try{e=JSON.parse(e)}catch{}return"object"==typeof e&&null!==e?Object.assign(new Error("Expected error, but caught non-error object"),e):"string"==typeof e?Object.assign(new Error(e),{cause:e}):Object.assign(new Error(`Expected error, but caught \`${String(e)}\` (${typeof e})`),{cause:e})}},446130:(e,t,n)=>{n.d(t,{Ll:()=>s,Xb:()=>i,tx:()=>r});function r(e){switch(e){case"TEXT":case"NUMERIC":case"INTEGER":case"REAL":case"BLOB":return!0;default:return!1}}function s(e){return"Error"===e.type||"ErrorBefore"===e.type||"PreconditionFailed"===e.type||"OutOfSpace"===e.type||"SharedWorkerFailedToDelegate"===e.type}function i(e){return e}},573146:(e,t,n)=>{n.d(t,{F4:()=>y});n(16280),n(581454),n(944114),n(517642),n(658004),n(733853),n(845876),n(432475),n(515024),n(731698),n(898992),n(803949);function r(e,t){for(const n of t)e.push(n)}const s=Symbol("QueryArg");class i{constructor(e){this.value=e}}const a=new Set(["IS NULL","IS NOT NULL","IS TRUE","IS FALSE","=","!=","<","<=",">",">=","IS","IN","NOT IN","LIKE","NOT LIKE","MATCH"]);function o(e){if(a.has(e))return e;throw new Error(`Not a SQL operator: "${e}"`)}const c={createForDialect:e=>(t,...n)=>(new e).appendTemplate(t,...n)};class u{constructor(){this.chunks=[],this.args=[]}appendTemplate(e,...t){if(!Array.isArray(e)||!Array.isArray(e.raw))throw new Error("sql`` can only be used as a template literal tag");for(const n of e)if(this.appendRaw_DANGEROUS(n),t.length){const e=t.shift();if(e instanceof i){this.appendIdentifier(e);continue}if(e instanceof u){this.append(e);continue}this.appendArg(e)}return this}append(e){return r(this.chunks,e.chunks),r(this.args,e.args),this}appendArg(e){return this.chunks.push(s),this.args.push(e),this}appendRaw_DANGEROUS(e){return this.chunks.push(e),this}appendIdentifier(e){const t=e instanceof i?e.value:e;return this.appendRaw_DANGEROUS(this.escapeIdentifier(t))}escapeIdentifier(e){if(/^[\w]+$/.test(e))return`"${e}"`;throw new Error(`Unexpected SQL identifier format: ${e}`)}sql(){let e=0;return this.chunks.map(t=>t===s?"$"+ ++e:t).join("")}toString(){const e=JSON.stringify(this.args),t=this.constructor;return`${t===u?"Sql":t.name||t.TagName}(\`${this.sql()}\`, ${e})`}DEBUG_ONLY_getInterpolatedQuery(){let e=0;return this.chunks.map(t=>{if(t===s){const t=this.args[e];return e++,function(e){if(Array.isArray(e)){let t=!1;const 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("")}}if(u.TagName="sql","undefined"==typeof window){u.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(e,t,n){return function(e,t){const{sql:n,tagName:r,className:s}=e,i=(null==t?void 0:t.stylize)??(e=>e),a=function(e){try{return e}catch{return e}}(n),o=a.split("\n"),c=[s?i(`(${s}) `,"undefined"):"",i(r??"sql","special"),i("`","string")];return o.length>2?(n.startsWith("\n")||c.push("\n"),c.push(o.map(e=>` ${e}`).join("\n")),n.endsWith("\n")||c.push("\n")):c.push(a),c.push(i("`","string")),c.join("")}({sql:this.DEBUG_ONLY_getInterpolatedQuery(),tagName:this.constructor.TagName||"sql",className:this.constructor===u?void 0:this.constructor.name},t)}}function p(e,t){if(t instanceof u)return t;if("string"==typeof t){if(!/^[ \t]*$/.test(t))throw new Error(`Unexpected indent format ${t}`);return e.raw_DANGEROUS(t)}if(t<0)return;const n=" ".repeat(t);return e`\n`.appendRaw_DANGEROUS(`${n}`)}function l(e,t,n){const r=e``;return t.forEach((e,s)=>{r.append(e),s!==t.length-1&&r.append(n)}),r}const f=(new u).appendRaw_DANGEROUS(" "),h=new u;function d(e){let t=!1,n="'";for(let r=0;rn(911822);class w extends u{static fromColumnType(e){if(!(0,n(446130).tx)(e))throw new Error(`Not a valid Sqlite column type: "${e}"`);return y.raw_DANGEROUS(e)}sql(){return this.chunks.map(e=>e===s?"?":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,g().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,g().kx)({connection:e,sql:this.sql(),args:this.args})}}w.TagName="sqlite";const y=function(e){const t=c.createForDialect(e),r=t;return r.raw_DANGEROUS=t=>(new e).appendRaw_DANGEROUS(t),r.ident=t=>(new e).appendIdentifier(t),r.col=(t,n)=>{const r=new e;return n?(r.appendIdentifier(t),r.appendRaw_DANGEROUS("."),r.appendIdentifier(n)):r.appendIdentifier(t),r},r.cols=t=>{let r;return null!=t&&t.prefix?r=t.prefix:null!=t&&t.table&&(r="string"==typeof t.table?(new e).appendIdentifier(t.table):(new e).append(t.table),r.appendRaw_DANGEROUS(".")),function(e){const t=Object.create(null),r=e.dialect,s=e.prefix,i=e.iterable?new Set(e.iterable):void 0,a=e=>{const t=new r;return s&&t.append(s),t.appendIdentifier(e)},o=e=>"string"==typeof e&&(!i||!!i.has(e));if(i){const e=()=>n(331653).jY.map(i,a)[Symbol.iterator]();t[Symbol.iterator]=e}return new Proxy(t,{get:(e,t,n)=>o(t)?a(t):Reflect.get(e,t,n),has:(e,t)=>o(t)||Reflect.has(e,t),ownKeys(e){const t=Object.keys(e);return i?Array.from(i).concat(t):t}})}({dialect:e,prefix:r,iterable:null==t?void 0:t.allowed})},r.op=t=>(new e).appendRaw_DANGEROUS(o(t)),r.expr=(t,n,r)=>{const s=new e;if("string"==typeof t){const e=t.split(".");for(let t=0;tl(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]})`;const r=p(e,n),s=l(e,t,e`${r??f}AND `);return e`(${r??h}${s})`}(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]})`;const r=p(e,n),s=l(e,t,e`${r??f}OR `);return e`(${r??h}${s})`}(r,e,t),r.comma=(e,t)=>function(e,t,n=-1){return l(e,t,e`,${p(e,n)??f}`)}(r,e,t),r.newline=e=>p(r,e??0)??t`\n`,r.comment=t=>(new e).appendRaw_DANGEROUS(`/* ${t.replace(/\/(?=\*)|\*(?=\/)/g,"$& ")} */`),r}(w)}}]);