Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@observablehq/stdlib

Package Overview
Dependencies
Maintainers
7
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@observablehq/stdlib - npm Package Compare versions

Comparing version 5.7.6 to 5.7.7

4

dist/stdlib.js

@@ -1,2 +0,2 @@

// @observablehq/stdlib v5.7.6 Copyright 2023 Observable, Inc.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).observablehq=e.observablehq||{})}(this,(function(e){"use strict";var t={},n={};function r(e){return new Function("d","return {"+e.map((function(e,t){return JSON.stringify(e)+": d["+t+'] || ""'})).join(",")+"}")}function a(e){var t=Object.create(null),n=[];return e.forEach((function(e){for(var r in e)r in t||n.push(t[r]=r)})),n}function o(e,t){var n=e+"",r=n.length;return r<t?new Array(t-r+1).join(0)+n:n}function s(e){var t,n=e.getUTCHours(),r=e.getUTCMinutes(),a=e.getUTCSeconds(),s=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":((t=e.getUTCFullYear())<0?"-"+o(-t,6):t>9999?"+"+o(t,6):o(t,4))+"-"+o(e.getUTCMonth()+1,2)+"-"+o(e.getUTCDate(),2)+(s?"T"+o(n,2)+":"+o(r,2)+":"+o(a,2)+"."+o(s,3)+"Z":a?"T"+o(n,2)+":"+o(r,2)+":"+o(a,2)+"Z":r||n?"T"+o(n,2)+":"+o(r,2)+"Z":"")}function i(e){var o=new RegExp('["'+e+"\n\r]"),i=e.charCodeAt(0);function c(e,r){var a,o=[],s=e.length,c=0,u=0,l=s<=0,f=!1;function d(){if(l)return n;if(f)return f=!1,t;var r,a,o=c;if(34===e.charCodeAt(o)){for(;c++<s&&34!==e.charCodeAt(c)||34===e.charCodeAt(++c););return(r=c)>=s?l=!0:10===(a=e.charCodeAt(c++))?f=!0:13===a&&(f=!0,10===e.charCodeAt(c)&&++c),e.slice(o+1,r-1).replace(/""/g,'"')}for(;c<s;){if(10===(a=e.charCodeAt(r=c++)))f=!0;else if(13===a)f=!0,10===e.charCodeAt(c)&&++c;else if(a!==i)continue;return e.slice(o,r)}return l=!0,e.slice(o,s)}for(10===e.charCodeAt(s-1)&&--s,13===e.charCodeAt(s-1)&&--s;(a=d())!==n;){for(var m=[];a!==t&&a!==n;)m.push(a),a=d();r&&null==(m=r(m,u++))||o.push(m)}return o}function u(t,n){return t.map((function(t){return n.map((function(e){return f(t[e])})).join(e)}))}function l(t){return t.map(f).join(e)}function f(e){return null==e?"":e instanceof Date?s(e):o.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,a,o=c(e,(function(e,o){if(n)return n(e,o-1);a=e,n=t?function(e,t){var n=r(e);return function(r,a){return t(n(r),a,e)}}(e,t):r(e)}));return o.columns=a||[],o},parseRows:c,format:function(t,n){return null==n&&(n=a(t)),[n.map(f).join(e)].concat(u(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=a(e)),u(e,t).join("\n")},formatRows:function(e){return e.map(l).join("\n")},formatRow:l,formatValue:f}}var c=i(","),u=c.parse,l=c.parseRows,f=i("\t"),d=f.parse,m=f.parseRows;function p(e){for(var t in e){var n,r,a=e[t].trim();if(a)if("true"===a)a=!0;else if("false"===a)a=!1;else if("NaN"===a)a=NaN;else if(isNaN(n=+a)){if(!(r=a.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)))continue;h&&r[4]&&!r[7]&&(a=a.replace(/-/g,"/").replace(/T/," ")),a=new Date(a)}else a=n;else a=null;e[t]=a}return e}const h=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours();function b(e,t,n){return{resolve:(r=n)=>`${e}@${t}/${r}`}}const w=b("d3","7.8.5","dist/d3.min.js"),y=b("@observablehq/inputs","0.10.5","dist/inputs.min.js"),v=b("@observablehq/plot","0.6.8","dist/plot.umd.min.js"),g=b("@observablehq/graphviz","0.2.1","dist/graphviz.min.js"),E=b("@observablehq/highlight.js","2.0.0","highlight.min.js"),A=b("@observablehq/katex","0.11.1","dist/katex.min.js"),T=b("lodash","4.17.21","lodash.min.js"),N=b("htl","0.3.1","dist/htl.min.js"),j=b("jszip","3.10.1","dist/jszip.min.js"),x=b("marked","0.3.12","marked.min.js"),O=b("sql.js","1.8.0","dist/sql-wasm.js"),$=b("vega","5.22.1","build/vega.min.js"),C=b("vega-lite","5.6.0","build/vega-lite.min.js"),q=b("vega-lite-api","5.0.0","build/vega-lite-api.min.js"),R=b("apache-arrow","4.0.1","Arrow.es2015.min.js"),k=b("apache-arrow","9.0.0","+esm"),L=b("apache-arrow","11.0.0","+esm"),I=b("arquero","4.8.8","dist/arquero.min.js"),S=b("topojson-client","3.1.0","dist/topojson-client.min.js"),M=b("exceljs","4.3.0","dist/exceljs.min.js"),P=b("mermaid","9.2.2","dist/mermaid.min.js"),_=b("leaflet","1.9.3","dist/leaflet.js"),D=b("@duckdb/duckdb-wasm","1.24.0","+esm"),U=new Map,F=[],B=F.map,W=F.some,H=F.hasOwnProperty,z=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,V=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,G=/(?:\.[^/]*|\/)$/;class RequireError extends Error{constructor(e){super(e)}}function Y(e){const t=z.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function Z(e="https://cdn.jsdelivr.net/npm/",t=["unpkg","jsdelivr","browser","main"]){if(!/\/$/.test(e))throw new Error("origin lacks trailing slash");function n(t){const n=`${e}${t.name}${t.version?`@${t.version}`:""}/package.json`;let r=U.get(n);return r||U.set(n,r=fetch(n).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!U.has(e.url)&&U.set(e.url,r),e.json()}))),r}return async function(r,a){if(r.startsWith(e)&&(r=r.substring(e.length)),/^(\w+:)|\/\//i.test(r))return r;if(/^[.]{0,2}\//i.test(r))return new URL(r,null==a?location:a).href;if(!r.length||/^[\s._]/.test(r)||/\s$/.test(r))throw new RequireError("illegal name");const o=Y(r);if(!o)return`${e}${r}`;if(!o.version&&null!=a&&a.startsWith(e)){const t=await n(Y(a.substring(e.length)));o.version=t.dependencies&&t.dependencies[o.name]||t.peerDependencies&&t.peerDependencies[o.name]}if(o.path&&!G.test(o.path)&&(o.path+=".js"),o.path&&o.version&&V.test(o.version))return`${e}${o.name}@${o.version}/${o.path}`;const s=await n(o);return`${e}${s.name}@${s.version}/${o.path||function(e){for(const n of t){let t=e[n];if("string"==typeof t)return t.startsWith("./")&&(t=t.slice(2)),G.test(t)?t:`${t}.js`}}(s)||"index.js"}`}}RequireError.prototype.name=RequireError.name;var J=Q(Z());function Q(e){const t=new Map,n=a(null);function r(e){if("string"!=typeof e)return e;let n=t.get(e);return n||t.set(e,n=new Promise(((t,n)=>{const r=document.createElement("script");r.onload=()=>{try{t(F.pop()(a(e)))}catch(e){n(new RequireError("invalid module"))}r.remove()},r.onerror=()=>{n(new RequireError("unable to load module")),r.remove()},r.async=!0,r.src=e,window.define=te,document.head.appendChild(r)}))),n}function a(t){return n=>Promise.resolve(e(n,t)).then(r)}function o(e){return arguments.length>1?Promise.all(B.call(arguments,n)).then(X):n(e)}return o.alias=function(t){return Q(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},o.resolve=e,o}function X(e){const t={};for(const n of e)for(const e in n)H.call(n,e)&&(null==n[e]?Object.defineProperty(t,e,{get:K(n,e)}):t[e]=n[e]);return t}function K(e,t){return()=>e[t]}function ee(e){return"exports"===(e+="")||"module"===e}function te(e,t,n){const r=arguments.length;r<2?(n=e,t=[]):r<3&&(n=t,t="string"==typeof e?[]:e),F.push(W.call(t,ee)?e=>{const r={},a={exports:r};return Promise.all(B.call(t,(t=>"exports"===(t+="")?r:"module"===t?a:e(t)))).then((e=>(n.apply(null,e),a.exports)))}:e=>Promise.all(B.call(t,e)).then((e=>"function"==typeof n?n.apply(null,e):n)))}te.amd={};const ne="https://cdn.observableusercontent.com/npm/";let re,ae=J;async function oe(e){const[t,n]=await Promise.all([e(O.resolve()),e.resolve(O.resolve("dist/"))]);return t({locateFile:e=>`${n}${e}`})}class SQLiteDatabaseClient{constructor(e){Object.defineProperties(this,{_db:{value:e}})}static async open(e){const[t,n]=await Promise.all([oe(ae),Promise.resolve(e).then(ie)]);return new SQLiteDatabaseClient(new t.Database(n))}async query(e,t){return await async function(e,t,n){const[r]=await e.exec(t,n);if(!r)return[];const{columns:a,values:o}=r,s=o.map((e=>Object.fromEntries(e.map(((e,t)=>[a[t],e])))));return s.columns=a,s}(this._db,e,t)}async queryRow(e,t){return(await this.query(e,t))[0]||null}async explain(e,t){return ce("pre",{className:"observablehq--inspect"},[ue((await this.query(`EXPLAIN QUERY PLAN ${e}`,t)).map((e=>e.detail)).join("\n"))])}async describeTables({schema:e}={}){return this.query(`SELECT NULLIF(schema, 'main') AS schema, name FROM pragma_table_list() WHERE type = 'table'${null==e?"":" AND schema = ?"} AND name NOT LIKE 'sqlite_%' ORDER BY schema, name`,null==e?[]:[e])}async describeColumns({schema:e,table:t}={}){if(null==t)throw new Error("missing table");const n=await this.query(`SELECT name, type, "notnull" FROM pragma_table_info(?${null==e?"":", ?"}) ORDER BY cid`,null==e?[t]:[t,e]);if(!n.length)throw new Error(`table not found: ${t}`);return n.map((({name:e,type:t,notnull:n})=>({name:e,type:se(t),databaseType:t,nullable:!n})))}async describe(e){const t=await(void 0===e?this.query("SELECT name FROM sqlite_master WHERE type = 'table'"):this.query("SELECT * FROM pragma_table_info(?)",[e]));if(!t.length)throw new Error("Not found");const{columns:n}=t;return ce("table",{value:t},[ce("thead",[ce("tr",n.map((e=>ce("th",[ue(e)]))))]),ce("tbody",t.map((e=>ce("tr",n.map((t=>ce("td",[ue(e[t])])))))))])}async sql(){return this.query(...this.queryTag.apply(this,arguments))}queryTag(e,...t){return[e.join("?"),t]}}function se(e){switch(e){case"NULL":return"null";case"INT":case"INTEGER":case"TINYINT":case"SMALLINT":case"MEDIUMINT":case"BIGINT":case"UNSIGNED BIG INT":case"INT2":case"INT8":return"integer";case"TEXT":case"CLOB":case"DATE":case"DATETIME":return"string";case"REAL":case"DOUBLE":case"DOUBLE PRECISION":case"FLOAT":case"NUMERIC":return"number";case"BLOB":return"buffer";default:return/^(?:(?:(?:VARYING|NATIVE) )?CHARACTER|(?:N|VAR|NVAR)CHAR)\(/.test(e)?"string":/^(?:DECIMAL|NUMERIC)\(/.test(e)?"number":"other"}}function ie(e){return"string"==typeof e?fetch(e).then(ie):e instanceof Response||e instanceof Blob?e.arrayBuffer().then(ie):e instanceof ArrayBuffer?new Uint8Array(e):e}function ce(e,t,n){2===arguments.length&&(n=t,t=void 0);const r=document.createElement(e);if(void 0!==t)for(const e in t)r[e]=t[e];if(void 0!==n)for(const e of n)r.appendChild(e);return r}function ue(e){return document.createTextNode(e)}function le(e,t){return null==e||null==t?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function fe(e,t=le){let n,r=!1;if(1===t.length){let a;for(const o of e){const e=t(o);(r?le(e,a)>0:0===le(e,e))&&(n=o,a=e,r=!0)}}else for(const a of e)(r?t(a,n)>0:0===t(a,a))&&(n=a,r=!0);return n}function de(e){return e&&"function"==typeof e.toArrowBuffer}function me(e){return e&&"function"==typeof e.getChild&&"function"==typeof e.toArray&&e.schema&&Array.isArray(e.schema.fields)}function pe(e){return e.schema.fields.map(he)}function he(e){return{name:e.name,type:be(e.type),nullable:e.nullable,databaseType:String(e.type)}}function be(e){switch(e.typeId){case 2:return"integer";case 3:case 7:return"number";case 4:case 15:return"buffer";case 5:return"string";case 6:return"boolean";case 8:case 9:case 10:return"date";case 12:case 16:return"array";case 13:case 14:return"object";default:return"other"}}async function we(){return await import(`${ne}${L.resolve()}`)}Object.defineProperty(SQLiteDatabaseClient.prototype,"dialect",{value:"sqlite"});class DuckDBClient{constructor(e){Object.defineProperties(this,{_db:{value:e}})}async queryStream(e,t){const n=await this._db.connect();let r,a;try{if(t?.length>0){const a=await n.prepare(e);r=await a.send(...t)}else r=await n.send(e);if(a=await r.next(),a.done)throw new Error("missing first batch")}catch(e){throw await n.close(),e}return{schema:pe(a.value),async*readRows(){try{for(;!a.done;)yield a.value.toArray(),a=await r.next()}finally{await n.close()}}}}async query(e,t){const n=await this.queryStream(e,t),r=[];for await(const e of n.readRows())for(const t of e)r.push(t);return r.schema=n.schema,r}async queryRow(e,t){const n=(await this.queryStream(e,t)).readRows();try{const{done:e,value:t}=await n.next();return e||!t.length?null:t[0]}finally{await n.return()}}async sql(e,...t){return await this.query(e.join("?"),t)}queryTag(e,...t){return[e.join("?"),t]}escape(e){return`"${e}"`}async describeTables(){return(await this.query("SHOW TABLES")).map((({name:e})=>({name:e})))}async describeColumns({table:e}={}){return(await this.query(`DESCRIBE ${this.escape(e)}`)).map((({column_name:e,column_type:t,null:n})=>({name:e,type:Ee(t),nullable:"NO"!==n,databaseType:t})))}static async of(e={},t={}){const n=await async function(){void 0===re&&(re=async function(){const e=await import(`${ne}${D.resolve()}`),t=await e.selectBundle({mvp:{mainModule:`${ne}${D.resolve("dist/duckdb-mvp.wasm")}`,mainWorker:`${ne}${D.resolve("dist/duckdb-browser-mvp.worker.js")}`},eh:{mainModule:`${ne}${D.resolve("dist/duckdb-eh.wasm")}`,mainWorker:`${ne}${D.resolve("dist/duckdb-browser-eh.worker.js")}`}}),n=new e.ConsoleLogger;return{module:e,bundle:t,logger:n}}());const{module:e,bundle:t,logger:n}=await re,r=await e.createWorker(t.mainWorker),a=new e.AsyncDuckDB(n,r);return await a.instantiate(t.mainModule),a}();return void 0===t.query?.castTimestampToDate&&(t={...t,query:{...t.query,castTimestampToDate:!0}}),void 0===t.query?.castBigIntToDouble&&(t={...t,query:{...t.query,castBigIntToDouble:!0}}),await n.open(t),await Promise.all(Object.entries(e).map((async([e,t])=>{if(t instanceof FileAttachment)await ye(n,e,t);else if(me(t))await ve(n,e,t);else if(Array.isArray(t))await ge(n,e,t);else if(de(t))await async function(e,t,n){const r=(await we()).tableFromIPC(n.toArrowBuffer());return await ve(e,t,r)}(n,e,t);else if("data"in t){const{data:r,...a}=t;me(r)?await ve(n,e,r,a):await ge(n,e,r,a)}else{if(!("file"in t))throw new Error(`invalid source: ${t}`);{const{file:r,...a}=t;await ye(n,e,r,a)}}}))),new DuckDBClient(n)}}async function ye(e,t,n,r){const a=await n.url();if(a.startsWith("blob:")){const t=await n.arrayBuffer();await e.registerFileBuffer(n.name,new Uint8Array(t))}else await e.registerFileURL(n.name,a,4);const o=await e.connect();try{switch(n.mimeType){case"text/csv":case"text/tab-separated-values":return await o.insertCSVFromPath(n.name,{name:t,schema:"main",...r}).catch((async e=>{if(e.toString().includes("Could not convert"))return await async function(e,t,n){const r=await e.prepare(`CREATE TABLE '${n}' AS SELECT * FROM read_csv_auto(?, ALL_VARCHAR=TRUE)`);return await r.send(t.name)}(o,n,t);throw e}));case"application/json":return await o.insertJSONFromPath(n.name,{name:t,schema:"main",...r});default:if(/\.arrow$/i.test(n.name)){const e=new Uint8Array(await n.arrayBuffer());return await o.insertArrowFromIPCStream(e,{name:t,schema:"main",...r})}if(/\.parquet$/i.test(n.name))return await o.query(`CREATE VIEW '${t}' AS SELECT * FROM parquet_scan('${n.name}')`);throw new Error(`unknown file type: ${n.mimeType}`)}}finally{await o.close()}}async function ve(e,t,n,r){const a=await e.connect();try{await a.insertArrowTable(n,{name:t,schema:"main",...r})}finally{await a.close()}}async function ge(e,t,n,r){const a=(await we()).tableFromJSON(n);return await ve(e,t,a,r)}function Ee(e){switch(e){case"BIGINT":case"HUGEINT":case"UBIGINT":return"bigint";case"DOUBLE":case"REAL":case"FLOAT":return"number";case"INTEGER":case"SMALLINT":case"TINYINT":case"USMALLINT":case"UINTEGER":case"UTINYINT":return"integer";case"BOOLEAN":return"boolean";case"DATE":case"TIMESTAMP":case"TIMESTAMP WITH TIME ZONE":return"date";case"VARCHAR":case"UUID":return"string";default:return/^DECIMAL\(/.test(e)?"integer":"other"}}Object.defineProperty(DuckDBClient.prototype,"dialect",{value:"duckdb"});function Ae(e,t){return e&&("function"==typeof e.sql||"function"==typeof e.queryTag&&("function"==typeof e.query||"function"==typeof e.queryStream))&&("table"!==t||"function"==typeof e.describeColumns)&&e!==Re}function Te(e){return Array.isArray(e)&&(Ne(e.schema)||je(e.columns)||function(e){const t=Math.min(20,e.length);for(let n=0;n<t;++n){const t=e[n];if(null===t||"object"!=typeof t)return!1}return t>0&&function(e){for(const t in e)return!0;return!1}(e[0])}(e)||$e(e)||Ce(e))||qe(e)}function Ne(e){return Array.isArray(e)&&e.every(xe)}function je(e){return Array.isArray(e)&&e.every((e=>"string"==typeof e))}function xe(e){return e&&"string"==typeof e.name&&"string"==typeof e.type}function Oe(e){return qe(e)||$e(e)||Ce(e)}function $e(e){const t=Math.min(20,e.length);if(!(t>0))return!1;let n,r=!1;for(let a=0;a<t;++a){const t=e[a];if(null==t)continue;const o=typeof t;if(void 0===n)switch(o){case"number":case"boolean":case"string":case"bigint":n=o;break;default:return!1}else if(o!==n)return!1;r=!0}return r}function Ce(e){const t=Math.min(20,e.length);if(!(t>0))return!1;let n=!1;for(let r=0;r<t;++r){const t=e[r];if(null!=t){if(!(t instanceof Date))return!1;n=!0}}return n}function qe(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}const Re=Object.assign((async(e,t,n,r)=>{if(Ae(e=await Ie(await e,r)))return Pe(e,_e(t,e),n);if(Te(e))return ut(e,t);if(!e)throw new Error("missing data source");throw new Error("invalid data source")}),{sql:(e,t,n)=>async function(){return Pe(await Se(await e,n),arguments,t)}});function ke(e){const t=new WeakMap;return(n,r)=>{if(!n||"object"!=typeof n)throw new Error("invalid data source");let a=t.get(n);return(!a||Te(n)&&n.length!==a._numRows)&&(a=e(n,r),a._numRows=n.length,t.set(n,a)),a}}const Le=ke((async e=>{if(e instanceof FileAttachment){switch(e.mimeType){case"text/csv":return e.csv({typed:"auto"});case"text/tab-separated-values":return e.tsv({typed:"auto"});case"application/json":return e.json()}throw new Error(`unsupported file type: ${e.mimeType}`)}return e})),Ie=ke((async(e,t)=>{if(e instanceof FileAttachment){switch(e.mimeType){case"text/csv":return e.csv();case"text/tab-separated-values":return e.tsv();case"application/json":return e.json();case"application/x-sqlite3":return e.sqlite()}if(/\.(arrow|parquet)$/i.test(e.name))return Me(e,t);throw new Error(`unsupported file type: ${e.mimeType}`)}return me(e)||de(e)?Me(e,t):Te(e)&&Oe(e)?Array.from(e,(e=>({value:e}))):e})),Se=ke((async(e,t)=>{if(e instanceof FileAttachment){switch(e.mimeType){case"text/csv":case"text/tab-separated-values":case"application/json":return Me(e,t);case"application/x-sqlite3":return e.sqlite()}if(/\.(arrow|parquet)$/i.test(e.name))return Me(e,t);throw new Error(`unsupported file type: ${e.mimeType}`)}return Te(e)?Me(await async function(e,t){const n=await we();return Oe(e)?n.tableFromArrays({[t]:e}):n.tableFromJSON(e)}(e,t),t):me(e)||de(e)?Me(e,t):e}));function Me(e,t=(e instanceof FileAttachment?function(e){return e.name.replace(/@\d+(?=\.|$)/,"").replace(/\.\w+$/,"")}(e):"__table")){return DuckDBClient.of({[t]:e})}async function Pe(e,t,n){if(!e)throw new Error("missing data source");if("function"==typeof e.queryTag){const r=new AbortController,a={signal:r.signal};if(n.then((()=>r.abort("invalidated"))),"function"==typeof e.queryStream)return async function*(e){let t=performance.now();const n=await e,r=[];r.done=!1,r.error=null,r.schema=n.schema;try{for await(const e of n.readRows()){performance.now()-t>150&&r.length>0&&(yield r,t=performance.now());for(const t of e)r.push(t)}r.done=!0,yield r}catch(e){r.error=e,yield r}}(e.queryStream(...e.queryTag.apply(e,t),a));if("function"==typeof e.query)return e.query(...e.queryTag.apply(e,t),a)}if("function"==typeof e.sql)return e.sql.apply(e,t);throw new Error("source does not implement query, queryStream, or sql")}function _e(e,t){const n="function"==typeof t.escape?t.escape:e=>e,{select:r,from:a,filter:o,sort:s,slice:i}=e;if(!a.table)throw new Error("missing from table");if(r.columns&&0===r.columns.length)throw new Error("at least one column must be selected");const c=new Map(e.names?.map((({column:e,name:t})=>[e,t]))),u=[[`SELECT ${r.columns?r.columns.map((e=>{const t=c.get(e);return t?`${n(e)} AS ${n(t)}`:n(e)})).join(", "):"*"} FROM ${De(a.table,n)}`]];for(let e=0;e<o.length;++e)Ue(e?"\nAND ":"\nWHERE ",u),Be(o[e],u,n);for(let e=0;e<s.length;++e)Ue(e?", ":"\nORDER BY ",u),Fe(s[e],u,n);if("mssql"===t.dialect||"oracle"===t.dialect){if(null!==i.to||null!==i.from){if(!s.length){if(!r.columns)throw new Error("at least one column must be explicitly specified. Received '*'.");Ue("\nORDER BY ",u),Fe({column:r.columns[0],direction:"ASC"},u,n)}Ue(`\nOFFSET ${i.from||0} ROWS`,u),Ue(`\nFETCH NEXT ${null!==i.to?i.to-(i.from||0):1e9} ROWS ONLY`,u)}}else null===i.to&&null===i.from||Ue("\nLIMIT "+(null!==i.to?i.to-(i.from||0):1e9),u),null!==i.from&&Ue(` OFFSET ${i.from}`,u);return u}function De(e,t){if("object"==typeof e){let n="";return null!=e.database&&(n+=t(e.database)+"."),null!=e.schema&&(n+=t(e.schema)+"."),n+=t(e.table),n}return t(e)}function Ue(e,t){const n=t[0];n[n.length-1]+=e}function Fe({column:e,direction:t},n,r){Ue(`${r(e)} ${t.toUpperCase()}`,n)}function Be({type:e,operands:t},n,r){if(t.length<1)throw new Error("Invalid operand length");if(1===t.length||"v"===e||"nv"===e)switch(We(t[0],n,r),e){case"n":case"nv":return void Ue(" IS NULL",n);case"nn":case"v":return void Ue(" IS NOT NULL",n);default:throw new Error("Invalid filter operation")}if(2!==t.length||["in","nin"].includes(e)){var a;switch(We(t[0],n,r),e){case"in":Ue(" IN (",n);break;case"nin":Ue(" NOT IN (",n);break;default:throw new Error("Invalid filter operation")}!function(e,t){let n=!0;for(const r of e)n?n=!1:Ue(",",t),t.push(r.value),t[0].push("")}(t.slice(1),n),Ue(")",n)}else{if(["c","nc"].includes(e)){switch(We(t[0],n,r),e){case"c":Ue(" LIKE ",n);break;case"nc":Ue(" NOT LIKE ",n)}return void We((a=t[1],{...a,value:`%${a.value}%`}),n,r)}switch(We(t[0],n,r),e){case"eq":Ue(" = ",n);break;case"ne":Ue(" <> ",n);break;case"gt":Ue(" > ",n);break;case"lt":Ue(" < ",n);break;case"gte":Ue(" >= ",n);break;case"lte":Ue(" <= ",n);break;default:throw new Error("Invalid filter operation")}We(t[1],n,r)}}function We(e,t,n){"column"===e.type?Ue(n(e.value),t):(t.push(e.value),t[0].push(""))}function He(e,t){return(null==e||!(e>=e))-(null==t||!(t>=t))}function ze(e,t){return He(e,t)||(e<t?-1:e>t?1:0)}function Ve(e,t){return He(e,t)||(e>t?-1:e<t?1:0)}const Ge=e=>"number"==typeof e&&!Number.isNaN(e),Ye=e=>Number.isInteger(e)&&!Number.isNaN(e),Ze=e=>"string"==typeof e,Je=e=>"boolean"==typeof e,Qe=e=>"bigint"==typeof e,Xe=e=>e instanceof Date&&!isNaN(e),Ke=e=>e instanceof ArrayBuffer,et=e=>Array.isArray(e),tt=e=>"object"==typeof e&&null!==e,nt=e=>null!=e;function rt(e){switch(e){case"string":return Ze;case"bigint":return Qe;case"boolean":return Je;case"number":return Ge;case"integer":return Ye;case"date":return Xe;case"buffer":return Ke;case"array":return et;case"object":return tt;default:return nt}}const at=/^(([-+]\d{2})?\d{4}(-\d{2}(-\d{2}))|(\d{1,2})\/(\d{1,2})\/(\d{2,4}))([T ]\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/;function ot(e,t){switch(t){case"string":return"string"==typeof e||null==e?e:String(e);case"boolean":if("string"==typeof e){const t=e.trim().toLowerCase();return"true"===t||"false"!==t&&null}return"boolean"==typeof e||null==e?e:Boolean(e);case"bigint":return"bigint"==typeof e||null==e?e:Number.isInteger("string"!=typeof e||e.trim()?+e:NaN)?BigInt(e):void 0;case"integer":case"number":return"number"==typeof e?e:null==e||"string"==typeof e&&!e.trim()?NaN:Number(e);case"date":{if(e instanceof Date||null==e)return e;if("number"==typeof e)return new Date(e);const t=String(e).trim();return"string"!=typeof e||t?new Date(at.test(t)?t:NaN):null}case"array":case"object":case"buffer":case"other":return e;default:throw new Error(`Unable to coerce to type: ${t}`)}}function st(e){const{columns:t}=e;let{schema:n}=e;return Ne(n)?{schema:n,inferred:!1}:(n=dt(e,je(t)?t:void 0),{schema:n,inferred:!0})}function it(e,t){const n=e;let{schema:r,inferred:a}=st(e);const o=new Map(r.map((({name:e,type:t})=>[e,t])));if(t.types){for(const{name:e,type:a}of t.types){o.set(e,a),r===n.schema&&(r=r.slice());const t=r.findIndex((t=>t.name===e));t>-1&&(r[t]={...r[t],type:a})}e=e.map((e=>lt(e,o,r)))}else a&&(e=e.map((e=>lt(e,o,r))));return{source:e,schema:r}}function ct(e,t){if(!t.names)return e;const n=new Map(t.names.map((e=>[e.column,e])));return e.map((e=>Object.fromEntries(Object.keys(e).map((t=>[n.get(t)?.name??t,e[t]])))))}function ut(e,t){const n=new Map,r=e,a=it(e,t);e=a.source;let o=a.schema;if(t.derive){const r=[];t.derive.map((({name:a,value:o})=>{let s=[];ct(e,t).map(((e,t)=>{let n;try{n=o(e)}catch(e){s.push({index:t,error:e}),n=void 0}r[t]?r[t]={...r[t],[a]:n}:r.push({[a]:n})})),s.length&&n.set(a,s)}));const a=it(r,t);e=e.map(((e,t)=>({...e,...a.source[t]}))),o=[...o,...a.schema]}for(const{type:n,operands:r}of t.filter){const[{value:t}]=r,a=r.slice(1).map((({value:e})=>e));switch(n){case"v":{const[n]=a,r=rt(n);e=e.filter((e=>r(e[t])));break}case"nv":{const[n]=a,r=rt(n);e=e.filter((e=>!r(e[t])));break}case"eq":{const[n]=a;if(n instanceof Date){const r=+n;e=e.filter((e=>+e[t]===r))}else e=e.filter((e=>e[t]===n));break}case"ne":{const[n]=a;e=e.filter((e=>e[t]!==n));break}case"c":{const[n]=a;e=e.filter((e=>"string"==typeof e[t]&&e[t].includes(n)));break}case"nc":{const[n]=a;e=e.filter((e=>"string"==typeof e[t]&&!e[t].includes(n)));break}case"in":{const n=new Set(a);e=e.filter((e=>n.has(e[t])));break}case"nin":{const n=new Set(a);e=e.filter((e=>!n.has(e[t])));break}case"n":e=e.filter((e=>null==e[t]));break;case"nn":e=e.filter((e=>null!=e[t]));break;case"lt":{const[n]=a;e=e.filter((e=>e[t]<n));break}case"lte":{const[n]=a;e=e.filter((e=>e[t]<=n));break}case"gt":{const[n]=a;e=e.filter((e=>e[t]>n));break}case"gte":{const[n]=a;e=e.filter((e=>e[t]>=n));break}default:throw new Error(`unknown filter type: ${n}`)}}for(const{column:n,direction:a}of function(e){if("function"!=typeof e[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(e).reverse()}(t.sort)){const t="desc"===a?Ve:ze;e===r&&(e=e.slice()),e.sort(((e,r)=>t(e[n],r[n])))}let{from:s,to:i}=t.slice;s=null==s?0:Math.max(0,s),i=null==i?1/0:Math.max(0,i),(s>0||i<1/0)&&(e=e.slice(Math.max(0,s),Math.max(0,i)));let c=o.slice();if(t.select.columns){if(o){const e=new Map(o.map((e=>[e.name,e])));o=t.select.columns.map((t=>e.get(t)))}e=e.map((e=>Object.fromEntries(t.select.columns.map((t=>[t,e[t]])))))}if(t.names){const n=new Map(t.names.map((e=>[e.column,e])));o&&(o=o.map((e=>{const t=n.get(e.name);return{...e,...t?{name:t.name}:null}}))),c&&(c=c.map((e=>{const t=n.get(e.name);return{...e,...t?{name:t.name}:null}}))),e=ct(e,t)}return e!==r&&o&&(e.schema=o),e.fullSchema=c,e.errors=n,e}function lt(e,t,n){const r={};for(const a of n){const n=t.get(a.name),o=e[a.name];r[a.name]="raw"===n?o:ot(o,n)}return r}const ft=["boolean","integer","number","date","bigint","array","object","buffer"];function dt(e,t=function(e){const t=new Set;for(const n of e)if(n)for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.add(e);return Array.from(t)}(e)){const n=[],r=e.slice(0,100);for(const e of t){const t={boolean:0,integer:0,number:0,date:0,string:0,array:0,object:0,bigint:0,buffer:0,defined:0};for(const n of r){let r=n[e];if(null==r)continue;const a=typeof r;if("string"!==a)++t.defined,Array.isArray(r)?++t.array:r instanceof Date?++t.date:r instanceof ArrayBuffer?++t.buffer:"number"===a?(++t.number,Number.isInteger(r)&&++t.integer):a in t&&++t[a];else{if(r=r.trim(),!r)continue;++t.defined,++t.string,/^(true|false)$/i.test(r)?++t.boolean:r&&!isNaN(r)?(++t.number,Number.isInteger(+r)&&++t.integer):at.test(r)&&++t.date}}const a=Math.max(1,.9*t.defined),o=fe(ft,(e=>t[e]>=a?t[e]:NaN))??(t.string>=a?"string":"other");n.push({name:e,type:o,inferred:o})}return n}class Workbook{constructor(e){Object.defineProperties(this,{_:{value:e},sheetNames:{value:e.worksheets.map((e=>e.name)),enumerable:!0}})}sheet(e,t){const n="number"==typeof e?this.sheetNames[e]:this.sheetNames.includes(e+="")?e:null;if(null==n)throw new Error(`Sheet not found: ${e}`);return function(e,{range:t,headers:n}={}){let[[r,a],[o,s]]=function(e=":",{columnCount:t,rowCount:n}){if(!(e+="").match(/^[A-Z]*\d*:[A-Z]*\d*$/))throw new Error("Malformed range specifier");const[[r=0,a=0],[o=t-1,s=n-1]]=e.split(":").map(bt);return[[r,a],[o,s]]}(t,e);const i=n?e._rows[a++]:null;let c=new Set(["#"]);for(let e=r;e<=o;e++){const t=i?mt(i.findCell(e+1)):null;let n=t&&t+""||ht(e);for(;c.has(n);)n+="_";c.add(n)}c=new Array(r).concat(Array.from(c));const u=new Array(s-a+1);for(let t=a;t<=s;t++){const n=u[t-a]=Object.create(null,{"#":{value:t+1}}),s=e.getRow(t+1);if(s.hasValues)for(let e=r;e<=o;e++){const t=mt(s.findCell(e+1));null!=t&&(n[c[e+1]]=t)}}return u.columns=c.filter((()=>!0)),u}(this._.getWorksheet(n),t)}}function mt(e){if(!e)return;const{value:t}=e;if(t&&"object"==typeof t&&!(t instanceof Date)){if(t.formula||t.sharedFormula)return t.result&&t.result.error?NaN:t.result;if(t.richText)return pt(t);if(t.text){let{text:e}=t;return e.richText&&(e=pt(e)),t.hyperlink&&t.hyperlink!==e?`${t.hyperlink} ${e}`:e}return t}return t}function pt(e){return e.richText.map((e=>e.text)).join("")}function ht(e){let t="";e++;do{t=String.fromCharCode(64+(e%26||26))+t}while(e=Math.floor((e-1)/26));return t}function bt(e){const[,t,n]=e.match(/^([A-Z]*)(\d*)$/);let r=0;if(t)for(let e=0;e<t.length;e++)r+=Math.pow(26,t.length-e-1)*(t.charCodeAt(e)-64);return[r?r-1:void 0,n?+n-1:void 0]}async function wt(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function yt(e,t,{array:n=!1,typed:r=!1}={}){const a=await e.text(),o="\t"===t?n?m:d:n?l:u;if("auto"===r&&!n){const e=o(a);return function(e,t){const n=new Map(t.map((({name:e,type:t})=>[e,t])));return Object.assign(e.map((e=>lt(e,n,t))),{schema:t})}(e,dt(e,e.columns))}return o(a,r&&p)}class vt{constructor(e,t){Object.defineProperty(this,"name",{value:e,enumerable:!0}),void 0!==t&&Object.defineProperty(this,"mimeType",{value:t+"",enumerable:!0})}async blob(){return(await wt(this)).blob()}async arrayBuffer(){return(await wt(this)).arrayBuffer()}async text(){return(await wt(this)).text()}async json(){return(await wt(this)).json()}async stream(){return(await wt(this)).body}async csv(e){return yt(this,",",e)}async tsv(e){return yt(this,"\t",e)}async image(e){const t=await this.url();return new Promise(((n,r)=>{const a=new Image;new URL(t,document.baseURI).origin!==new URL(location).origin&&(a.crossOrigin="anonymous"),Object.assign(a,e),a.onload=()=>n(a),a.onerror=()=>r(new Error(`Unable to load file: ${this.name}`)),a.src=t}))}async arrow({version:e=4}={}){switch(e){case 4:{const[e,t]=await Promise.all([ae(R.resolve()),wt(this)]);return e.Table.from(t)}case 9:{const[e,t]=await Promise.all([import(`${ne}${k.resolve()}`),wt(this)]);return e.tableFromIPC(t)}case 11:{const[e,t]=await Promise.all([import(`${ne}${L.resolve()}`),wt(this)]);return e.tableFromIPC(t)}default:throw new Error(`unsupported arrow version: ${e}`)}}async sqlite(){return SQLiteDatabaseClient.open(wt(this))}async zip(){const[e,t]=await Promise.all([ae(j.resolve()),this.arrayBuffer()]);return new ZipArchive(await e.loadAsync(t))}async xml(e="application/xml"){return(new DOMParser).parseFromString(await this.text(),e)}async html(){return this.xml("text/html")}async xlsx(){const[e,t]=await Promise.all([ae(M.resolve()),this.arrayBuffer()]);return new Workbook(await(new e.Workbook).xlsx.load(t))}}class FileAttachment extends vt{constructor(e,t,n){super(t,n),Object.defineProperty(this,"_url",{value:e})}async url(){return await this._url+""}}function gt(e){throw new Error(`File not found: ${e}`)}class ZipArchive{constructor(e){Object.defineProperty(this,"_",{value:e}),this.filenames=Object.keys(e.files).filter((t=>!e.files[t].dir))}file(e){const t=this._.file(e+="");if(!t||t.dir)throw new Error(`file not found: ${e}`);return new ZipArchiveEntry(t)}}class ZipArchiveEntry extends vt{constructor(e){super(e.name),Object.defineProperty(this,"_",{value:e}),Object.defineProperty(this,"_url",{writable:!0})}async url(){return this._url||(this._url=this.blob().then(URL.createObjectURL))}async blob(){return this._.async("blob")}async arrayBuffer(){return this._.async("arraybuffer")}async text(){return this._.async("text")}async json(){return JSON.parse(await this.text())}}var Et={math:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};var At=0;function Tt(e){return new Nt("O-"+(null==e?"":e+"-")+ ++At)}function Nt(e){this.id=e,this.href=new URL(`#${e}`,location)+""}Nt.prototype.toString=function(){return"url("+this.href+")"};var jt=Object.freeze({__proto__:null,canvas:function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n},context2d:function(e,t,n){null==n&&(n=devicePixelRatio);var r=document.createElement("canvas");r.width=e*n,r.height=t*n,r.style.width=e+"px";var a=r.getContext("2d");return a.scale(n,n),a},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),a=r.appendChild(document.createElement("button"));async function o(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),a.textContent=n,a.disabled=!1}return a.textContent=n,r.download=t,r.onclick=async t=>{if(a.disabled=!0,r.href)return o();a.textContent="Saving…";try{const t=await("function"==typeof e?e():e);a.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){a.textContent=n}if(t.eventPhase)return o();a.disabled=!1},r},element:function(e,t){var n,r=e+="",a=r.indexOf(":");a>=0&&"xmlns"!==(r=e.slice(0,a))&&(e=e.slice(a+1));var o=Et.hasOwnProperty(r)?document.createElementNS(Et[r],e):document.createElement(e);if(t)for(var s in t)a=(r=s).indexOf(":"),n=t[s],a>=0&&"xmlns"!==(r=s.slice(0,a))&&(s=s.slice(a+1)),Et.hasOwnProperty(r)?o.setAttributeNS(Et[r],s,n):o.setAttribute(s,n);return o},input:function(e){var t=document.createElement("input");return null!=e&&(t.type=e),t},range:function(e,t,n){1===arguments.length&&(t=e,e=null);var r=document.createElement("input");return r.min=e=null==e?0:+e,r.max=t=null==t?1:+t,r.step=null==n?"any":n=+n,r.type="range",r},select:function(e){var t=document.createElement("select");return Array.prototype.forEach.call(e,(function(e){var n=document.createElement("option");n.value=n.textContent=e,t.appendChild(n)})),t},svg:function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox",[0,0,e,t]),n.setAttribute("width",e),n.setAttribute("height",t),n},text:function(e){return document.createTextNode(e)},uid:Tt});var xt=Object.freeze({__proto__:null,buffer:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsArrayBuffer(e)}))},text:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsText(e)}))},url:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsDataURL(e)}))}});function Ot(){return this}function $t(e,t){let n=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:Ot,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function Ct(e){let t,n,r=!1;const a=e((function(e){n?(n(e),n=null):r=!0;return t=e}));if(null!=a&&"function"!=typeof a)throw new Error("function"==typeof a.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:Ot,throw:()=>({done:!0}),return:()=>(null!=a&&a(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise((e=>n=e))}}}}function qt(e){switch(e.type){case"range":case"number":return e.valueAsNumber;case"date":return e.valueAsDate;case"checkbox":return e.checked;case"file":return e.multiple?e.files:e.files[0];case"select-multiple":return Array.from(e.selectedOptions,(e=>e.value));default:return e.value}}var Rt=Object.freeze({__proto__:null,disposable:$t,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return Ct((function(t){var n=function(e){switch(e.type){case"button":case"submit":case"checkbox":return"click";case"file":return"change";default:return"input"}}(e),r=qt(e);function a(){t(qt(e))}return e.addEventListener(n,a),void 0!==r&&t(r),function(){e.removeEventListener(n,a)}}))},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:Ct,queue:function(e){let t;const n=[],r=e((function(e){n.push(e),t&&(t(n.shift()),t=null);return e}));if(null!=r&&"function"!=typeof r)throw new Error("function"==typeof r.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:Ot,throw:()=>({done:!0}),return:()=>(null!=r&&r(),{done:!0}),next:function(){return{done:!1,value:n.length?Promise.resolve(n.shift()):new Promise((e=>t=e))}}}},range:function*(e,t,n){e=+e,t=+t,n=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+n;for(var r=-1,a=0|Math.max(0,Math.ceil((t-e)/n));++r<a;)yield e+r*n},valueAt:function(e,t){if(!(!isFinite(t=+t)||t<0||t!=t|0))for(var n,r=-1;!(n=e.next()).done;)if(++r===t)return n.value},worker:function(e){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"})),n=new Worker(t);return $t(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}});function kt(e,t){return function(n){var r,a,o,s,i,c,u,l,f=n[0],d=[],m=null,p=-1;for(i=1,c=arguments.length;i<c;++i){if((r=arguments[i])instanceof Node)d[++p]=r,f+="\x3c!--o:"+p+"--\x3e";else if(Array.isArray(r)){for(u=0,l=r.length;u<l;++u)(a=r[u])instanceof Node?(null===m&&(d[++p]=m=document.createDocumentFragment(),f+="\x3c!--o:"+p+"--\x3e"),m.appendChild(a)):(m=null,f+=a);m=null}else f+=r;f+=n[i]}if(m=e(f),++p>0){for(o=new Array(p),s=document.createTreeWalker(m,NodeFilter.SHOW_COMMENT,null,!1);s.nextNode();)a=s.currentNode,/^o:/.test(a.nodeValue)&&(o[+a.nodeValue.slice(2)]=a);for(i=0;i<p;++i)(a=o[i])&&a.parentNode.replaceChild(d[i],a)}return 1===m.childNodes.length?m.removeChild(m.firstChild):11===m.nodeType?((a=t()).appendChild(m),a):m}}const Lt=kt((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));function It(e){let t;Object.defineProperties(this,{generator:{value:Ct((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*St(){for(;;)yield Date.now()}var Mt=new Map;function Pt(e,t){var n;return(n=Mt.get(e=+e))?n.then((()=>t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise((function(n){Mt.delete(t);var r=t-e;if(!(r>0))throw new Error("invalid time");if(r>2147483647)throw new Error("too long to wait");setTimeout(n,r)}));return Mt.set(t,n),n}(n,e).then((()=>t))}var _t=Object.freeze({__proto__:null,delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return Pt(Math.ceil((Date.now()+1)/e)*e,t)},when:Pt});function Dt(e,t){if(/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new Error("illegal name");return"https://unpkg.com/"+e}const Ut=kt((function(e){var t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.innerHTML=e.trim(),t}),(function(){return document.createElementNS("http://www.w3.org/2000/svg","g")}));var Ft=String.raw;function Bt(e){return new Promise((function(t,n){var r=document.createElement("link");r.rel="stylesheet",r.href=e,r.onerror=n,r.onload=t,document.head.appendChild(r)}))}function Wt(){return Ct((function(e){var t=e(document.body.clientWidth);function n(){var n=document.body.clientWidth;n!==t&&e(t=n)}return window.addEventListener("resize",n),function(){window.removeEventListener("resize",n)}}))}const Ht=Object.assign(Object.defineProperties((function(e){const t=function(e){return null==e?ae:Q(e)}(e);var n;Object.defineProperties(this,(n={FileAttachment:()=>gt,Mutable:()=>It,now:St,width:Wt,dot:()=>t(g.resolve()),htl:()=>t(N.resolve()),html:()=>Lt,md:()=>function(e){return e(x.resolve()).then((function(t){return kt((function(n){var r=document.createElement("div");r.innerHTML=t(n,{langPrefix:""}).trim();var a=r.querySelectorAll("pre code[class]");return a.length>0&&e(E.resolve()).then((function(t){a.forEach((function(n){function r(){t.highlightBlock(n),n.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(n.className)?r():e(E.resolve("async-languages/index.js")).then((r=>{if(r.has(n.className))return e(E.resolve("async-languages/"+r.get(n.className))).then((e=>{t.registerLanguage(n.className,e)}))})).then(r,r)}))})),r}),(function(){return document.createElement("div")}))}))}(t),svg:()=>Ut,tex:()=>function(e){return Promise.all([e(A.resolve()),e.resolve(A.resolve("dist/katex.min.css")).then(Bt)]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(Ft.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}))}(t),_:()=>t(T.resolve()),aq:()=>t.alias({"apache-arrow":R.resolve()})(I.resolve()),Arrow:()=>t(R.resolve()),d3:()=>t(w.resolve()),DuckDBClient:()=>DuckDBClient,Inputs:()=>t(y.resolve()).then((e=>({...e,file:e.fileOf(vt)}))),L:()=>async function(e){const t=await e(_.resolve());if(!t._style){const n=document.createElement("link");n.rel="stylesheet",n.href=await e.resolve(_.resolve("dist/leaflet.css")),t._style=document.head.appendChild(n)}return t}(t),mermaid:()=>async function(e){const t=await e(P.resolve());return t.initialize({securityLevel:"loose",theme:"neutral"}),function(){const e=document.createElement("div");return e.innerHTML=t.render(Tt().id,String.raw.apply(String,arguments)),e.removeChild(e.firstChild)}}(t),Plot:()=>t(v.resolve()),__query:()=>Re,require:()=>t,resolve:()=>Dt,SQLite:()=>oe(t),SQLiteDatabaseClient:()=>SQLiteDatabaseClient,topojson:()=>t(S.resolve()),vl:()=>async function(e){const[t,n,r]=await Promise.all([$,C,q].map((t=>e(t.resolve()))));return r.register(t,n)}(t),aapl:()=>new FileAttachment("https://static.observableusercontent.com/files/3ccff97fd2d93da734e76829b2b066eafdaac6a1fafdec0faf6ebc443271cfc109d29e80dd217468fcb2aff1e6bffdc73f356cc48feb657f35378e6abbbb63b9").csv({typed:!0}),alphabet:()=>new FileAttachment("https://static.observableusercontent.com/files/75d52e6c3130b1cae83cda89305e17b50f33e7420ef205587a135e8562bcfd22e483cf4fa2fb5df6dff66f9c5d19740be1cfaf47406286e2eb6574b49ffc685d").csv({typed:!0}),cars:()=>new FileAttachment("https://static.observableusercontent.com/files/048ec3dfd528110c0665dfa363dd28bc516ffb7247231f3ab25005036717f5c4c232a5efc7bb74bc03037155cb72b1abe85a33d86eb9f1a336196030443be4f6").csv({typed:!0}),citywages:()=>new FileAttachment("https://static.observableusercontent.com/files/39837ec5121fcc163131dbc2fe8c1a2e0b3423a5d1e96b5ce371e2ac2e20a290d78b71a4fb08b9fa6a0107776e17fb78af313b8ea70f4cc6648fad68ddf06f7a").csv({typed:!0}),diamonds:()=>new FileAttachment("https://static.observableusercontent.com/files/87942b1f5d061a21fa4bb8f2162db44e3ef0f7391301f867ab5ba718b225a63091af20675f0bfe7f922db097b217b377135203a7eab34651e21a8d09f4e37252").csv({typed:!0}),flare:()=>new FileAttachment("https://static.observableusercontent.com/files/a6b0d94a7f5828fd133765a934f4c9746d2010e2f342d335923991f31b14120de96b5cb4f160d509d8dc627f0107d7f5b5070d2516f01e4c862b5b4867533000").csv({typed:!0}),industries:()=>new FileAttachment("https://static.observableusercontent.com/files/76f13741128340cc88798c0a0b7fa5a2df8370f57554000774ab8ee9ae785ffa2903010cad670d4939af3e9c17e5e18e7e05ed2b38b848ac2fc1a0066aa0005f").csv({typed:!0}),miserables:()=>new FileAttachment("https://static.observableusercontent.com/files/31d904f6e21d42d4963ece9c8cc4fbd75efcbdc404bf511bc79906f0a1be68b5a01e935f65123670ed04e35ca8cae3c2b943f82bf8db49c5a67c85cbb58db052").json(),olympians:()=>new FileAttachment("https://static.observableusercontent.com/files/31ca24545a0603dce099d10ee89ee5ae72d29fa55e8fc7c9ffb5ded87ac83060d80f1d9e21f4ae8eb04c1e8940b7287d179fe8060d887fb1f055f430e210007c").csv({typed:!0}),penguins:()=>new FileAttachment("https://static.observableusercontent.com/files/715db1223e067f00500780077febc6cebbdd90c151d3d78317c802732252052ab0e367039872ab9c77d6ef99e5f55a0724b35ddc898a1c99cb14c31a379af80a").csv({typed:!0}),weather:()=>new FileAttachment("https://static.observableusercontent.com/files/693a46b22b33db0f042728700e0c73e836fa13d55446df89120682d55339c6db7cc9e574d3d73f24ecc9bc7eb9ac9a1e7e104a1ee52c00aab1e77eb102913c1f").csv({typed:!0}),DOM:jt,Files:xt,Generators:Rt,Promises:_t},Object.fromEntries(Object.entries(n).map(zt))))}),{resolve:{get:()=>ae.resolve,enumerable:!0,configurable:!0},require:{get:()=>ae,set:function(e){ae=e},enumerable:!0,configurable:!0}}),{resolveFrom:Z,requireFrom:Q});function zt([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}e.AbstractFile=vt,e.FileAttachments=function(e){return Object.assign((t=>{const n=e(t+="");if(null==n)throw new Error(`File not found: ${t}`);if("object"==typeof n&&"url"in n){const{url:e,mimeType:r}=n;return new FileAttachment(e,t,r)}return new FileAttachment(n,t)}),{prototype:FileAttachment.prototype})},e.Library=Ht,e.applyDataTableOperations=ut,e.arrayIsPrimitive=Oe,e.getArrowTableSchema=pe,e.getSchema=st,e.getTypeValidator=rt,e.inferSchema=dt,e.isArqueroTable=de,e.isArrowTable=me,e.isDataArray=Te,e.isDatabaseClient=Ae,e.loadDataSource=async function(e,t,n){switch(t){case"chart":return Le(e);case"table":return Ie(e,n);case"sql":return Se(e,n)}return e},e.makeQueryTemplate=_e,e.observe=Ct}));
// @observablehq/stdlib v5.7.7 Copyright 2023 Observable, Inc.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).observablehq=e.observablehq||{})}(this,(function(e){"use strict";var t={},n={};function r(e){return new Function("d","return {"+e.map((function(e,t){return JSON.stringify(e)+": d["+t+'] || ""'})).join(",")+"}")}function a(e){var t=Object.create(null),n=[];return e.forEach((function(e){for(var r in e)r in t||n.push(t[r]=r)})),n}function o(e,t){var n=e+"",r=n.length;return r<t?new Array(t-r+1).join(0)+n:n}function s(e){var t,n=e.getUTCHours(),r=e.getUTCMinutes(),a=e.getUTCSeconds(),s=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":((t=e.getUTCFullYear())<0?"-"+o(-t,6):t>9999?"+"+o(t,6):o(t,4))+"-"+o(e.getUTCMonth()+1,2)+"-"+o(e.getUTCDate(),2)+(s?"T"+o(n,2)+":"+o(r,2)+":"+o(a,2)+"."+o(s,3)+"Z":a?"T"+o(n,2)+":"+o(r,2)+":"+o(a,2)+"Z":r||n?"T"+o(n,2)+":"+o(r,2)+"Z":"")}function i(e){var o=new RegExp('["'+e+"\n\r]"),i=e.charCodeAt(0);function c(e,r){var a,o=[],s=e.length,c=0,u=0,l=s<=0,f=!1;function d(){if(l)return n;if(f)return f=!1,t;var r,a,o=c;if(34===e.charCodeAt(o)){for(;c++<s&&34!==e.charCodeAt(c)||34===e.charCodeAt(++c););return(r=c)>=s?l=!0:10===(a=e.charCodeAt(c++))?f=!0:13===a&&(f=!0,10===e.charCodeAt(c)&&++c),e.slice(o+1,r-1).replace(/""/g,'"')}for(;c<s;){if(10===(a=e.charCodeAt(r=c++)))f=!0;else if(13===a)f=!0,10===e.charCodeAt(c)&&++c;else if(a!==i)continue;return e.slice(o,r)}return l=!0,e.slice(o,s)}for(10===e.charCodeAt(s-1)&&--s,13===e.charCodeAt(s-1)&&--s;(a=d())!==n;){for(var m=[];a!==t&&a!==n;)m.push(a),a=d();r&&null==(m=r(m,u++))||o.push(m)}return o}function u(t,n){return t.map((function(t){return n.map((function(e){return f(t[e])})).join(e)}))}function l(t){return t.map(f).join(e)}function f(e){return null==e?"":e instanceof Date?s(e):o.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,a,o=c(e,(function(e,o){if(n)return n(e,o-1);a=e,n=t?function(e,t){var n=r(e);return function(r,a){return t(n(r),a,e)}}(e,t):r(e)}));return o.columns=a||[],o},parseRows:c,format:function(t,n){return null==n&&(n=a(t)),[n.map(f).join(e)].concat(u(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=a(e)),u(e,t).join("\n")},formatRows:function(e){return e.map(l).join("\n")},formatRow:l,formatValue:f}}var c=i(","),u=c.parse,l=c.parseRows,f=i("\t"),d=f.parse,m=f.parseRows;function p(e){for(var t in e){var n,r,a=e[t].trim();if(a)if("true"===a)a=!0;else if("false"===a)a=!1;else if("NaN"===a)a=NaN;else if(isNaN(n=+a)){if(!(r=a.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)))continue;h&&r[4]&&!r[7]&&(a=a.replace(/-/g,"/").replace(/T/," ")),a=new Date(a)}else a=n;else a=null;e[t]=a}return e}const h=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours();function b(e,t,n){return{resolve:(r=n)=>`${e}@${t}/${r}`}}const w=b("d3","7.8.5","dist/d3.min.js"),y=b("@observablehq/inputs","0.10.5","dist/inputs.min.js"),v=b("@observablehq/plot","0.6.9","dist/plot.umd.min.js"),g=b("@observablehq/graphviz","0.2.1","dist/graphviz.min.js"),E=b("@observablehq/highlight.js","2.0.0","highlight.min.js"),A=b("@observablehq/katex","0.11.1","dist/katex.min.js"),T=b("lodash","4.17.21","lodash.min.js"),N=b("htl","0.3.1","dist/htl.min.js"),j=b("jszip","3.10.1","dist/jszip.min.js"),x=b("marked","0.3.12","marked.min.js"),O=b("sql.js","1.8.0","dist/sql-wasm.js"),$=b("vega","5.22.1","build/vega.min.js"),C=b("vega-lite","5.6.0","build/vega-lite.min.js"),q=b("vega-lite-api","5.0.0","build/vega-lite-api.min.js"),R=b("apache-arrow","4.0.1","Arrow.es2015.min.js"),k=b("apache-arrow","9.0.0","+esm"),L=b("apache-arrow","11.0.0","+esm"),I=b("arquero","4.8.8","dist/arquero.min.js"),S=b("topojson-client","3.1.0","dist/topojson-client.min.js"),M=b("exceljs","4.3.0","dist/exceljs.min.js"),P=b("mermaid","9.2.2","dist/mermaid.min.js"),_=b("leaflet","1.9.3","dist/leaflet.js"),D=b("@duckdb/duckdb-wasm","1.24.0","+esm"),U=new Map,F=[],B=F.map,W=F.some,H=F.hasOwnProperty,z=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,V=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,G=/(?:\.[^/]*|\/)$/;class RequireError extends Error{constructor(e){super(e)}}function Y(e){const t=z.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function Z(e="https://cdn.jsdelivr.net/npm/",t=["unpkg","jsdelivr","browser","main"]){if(!/\/$/.test(e))throw new Error("origin lacks trailing slash");function n(t){const n=`${e}${t.name}${t.version?`@${t.version}`:""}/package.json`;let r=U.get(n);return r||U.set(n,r=fetch(n).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!U.has(e.url)&&U.set(e.url,r),e.json()}))),r}return async function(r,a){if(r.startsWith(e)&&(r=r.substring(e.length)),/^(\w+:)|\/\//i.test(r))return r;if(/^[.]{0,2}\//i.test(r))return new URL(r,null==a?location:a).href;if(!r.length||/^[\s._]/.test(r)||/\s$/.test(r))throw new RequireError("illegal name");const o=Y(r);if(!o)return`${e}${r}`;if(!o.version&&null!=a&&a.startsWith(e)){const t=await n(Y(a.substring(e.length)));o.version=t.dependencies&&t.dependencies[o.name]||t.peerDependencies&&t.peerDependencies[o.name]}if(o.path&&!G.test(o.path)&&(o.path+=".js"),o.path&&o.version&&V.test(o.version))return`${e}${o.name}@${o.version}/${o.path}`;const s=await n(o);return`${e}${s.name}@${s.version}/${o.path||function(e){for(const n of t){let t=e[n];if("string"==typeof t)return t.startsWith("./")&&(t=t.slice(2)),G.test(t)?t:`${t}.js`}}(s)||"index.js"}`}}RequireError.prototype.name=RequireError.name;var J=Q(Z());function Q(e){const t=new Map,n=a(null);function r(e){if("string"!=typeof e)return e;let n=t.get(e);return n||t.set(e,n=new Promise(((t,n)=>{const r=document.createElement("script");r.onload=()=>{try{t(F.pop()(a(e)))}catch(e){n(new RequireError("invalid module"))}r.remove()},r.onerror=()=>{n(new RequireError("unable to load module")),r.remove()},r.async=!0,r.src=e,window.define=te,document.head.appendChild(r)}))),n}function a(t){return n=>Promise.resolve(e(n,t)).then(r)}function o(e){return arguments.length>1?Promise.all(B.call(arguments,n)).then(X):n(e)}return o.alias=function(t){return Q(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},o.resolve=e,o}function X(e){const t={};for(const n of e)for(const e in n)H.call(n,e)&&(null==n[e]?Object.defineProperty(t,e,{get:K(n,e)}):t[e]=n[e]);return t}function K(e,t){return()=>e[t]}function ee(e){return"exports"===(e+="")||"module"===e}function te(e,t,n){const r=arguments.length;r<2?(n=e,t=[]):r<3&&(n=t,t="string"==typeof e?[]:e),F.push(W.call(t,ee)?e=>{const r={},a={exports:r};return Promise.all(B.call(t,(t=>"exports"===(t+="")?r:"module"===t?a:e(t)))).then((e=>(n.apply(null,e),a.exports)))}:e=>Promise.all(B.call(t,e)).then((e=>"function"==typeof n?n.apply(null,e):n)))}te.amd={};const ne="https://cdn.observableusercontent.com/npm/";let re,ae=J;async function oe(e){const[t,n]=await Promise.all([e(O.resolve()),e.resolve(O.resolve("dist/"))]);return t({locateFile:e=>`${n}${e}`})}class SQLiteDatabaseClient{constructor(e){Object.defineProperties(this,{_db:{value:e}})}static async open(e){const[t,n]=await Promise.all([oe(ae),Promise.resolve(e).then(ie)]);return new SQLiteDatabaseClient(new t.Database(n))}async query(e,t){return await async function(e,t,n){const[r]=await e.exec(t,n);if(!r)return[];const{columns:a,values:o}=r,s=o.map((e=>Object.fromEntries(e.map(((e,t)=>[a[t],e])))));return s.columns=a,s}(this._db,e,t)}async queryRow(e,t){return(await this.query(e,t))[0]||null}async explain(e,t){return ce("pre",{className:"observablehq--inspect"},[ue((await this.query(`EXPLAIN QUERY PLAN ${e}`,t)).map((e=>e.detail)).join("\n"))])}async describeTables({schema:e}={}){return this.query(`SELECT NULLIF(schema, 'main') AS schema, name FROM pragma_table_list() WHERE type = 'table'${null==e?"":" AND schema = ?"} AND name NOT LIKE 'sqlite_%' ORDER BY schema, name`,null==e?[]:[e])}async describeColumns({schema:e,table:t}={}){if(null==t)throw new Error("missing table");const n=await this.query(`SELECT name, type, "notnull" FROM pragma_table_info(?${null==e?"":", ?"}) ORDER BY cid`,null==e?[t]:[t,e]);if(!n.length)throw new Error(`table not found: ${t}`);return n.map((({name:e,type:t,notnull:n})=>({name:e,type:se(t),databaseType:t,nullable:!n})))}async describe(e){const t=await(void 0===e?this.query("SELECT name FROM sqlite_master WHERE type = 'table'"):this.query("SELECT * FROM pragma_table_info(?)",[e]));if(!t.length)throw new Error("Not found");const{columns:n}=t;return ce("table",{value:t},[ce("thead",[ce("tr",n.map((e=>ce("th",[ue(e)]))))]),ce("tbody",t.map((e=>ce("tr",n.map((t=>ce("td",[ue(e[t])])))))))])}async sql(){return this.query(...this.queryTag.apply(this,arguments))}queryTag(e,...t){return[e.join("?"),t]}}function se(e){switch(e){case"NULL":return"null";case"INT":case"INTEGER":case"TINYINT":case"SMALLINT":case"MEDIUMINT":case"BIGINT":case"UNSIGNED BIG INT":case"INT2":case"INT8":return"integer";case"TEXT":case"CLOB":case"DATE":case"DATETIME":return"string";case"REAL":case"DOUBLE":case"DOUBLE PRECISION":case"FLOAT":case"NUMERIC":return"number";case"BLOB":return"buffer";default:return/^(?:(?:(?:VARYING|NATIVE) )?CHARACTER|(?:N|VAR|NVAR)CHAR)\(/.test(e)?"string":/^(?:DECIMAL|NUMERIC)\(/.test(e)?"number":"other"}}function ie(e){return"string"==typeof e?fetch(e).then(ie):e instanceof Response||e instanceof Blob?e.arrayBuffer().then(ie):e instanceof ArrayBuffer?new Uint8Array(e):e}function ce(e,t,n){2===arguments.length&&(n=t,t=void 0);const r=document.createElement(e);if(void 0!==t)for(const e in t)r[e]=t[e];if(void 0!==n)for(const e of n)r.appendChild(e);return r}function ue(e){return document.createTextNode(e)}function le(e,t){return null==e||null==t?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function fe(e,t=le){let n,r=!1;if(1===t.length){let a;for(const o of e){const e=t(o);(r?le(e,a)>0:0===le(e,e))&&(n=o,a=e,r=!0)}}else for(const a of e)(r?t(a,n)>0:0===t(a,a))&&(n=a,r=!0);return n}function de(e){return e&&"function"==typeof e.toArrowBuffer}function me(e){return e&&"function"==typeof e.getChild&&"function"==typeof e.toArray&&e.schema&&Array.isArray(e.schema.fields)}function pe(e){return e.schema.fields.map(he)}function he(e){return{name:e.name,type:be(e.type),nullable:e.nullable,databaseType:String(e.type)}}function be(e){switch(e.typeId){case 2:return"integer";case 3:case 7:return"number";case 4:case 15:return"buffer";case 5:return"string";case 6:return"boolean";case 8:case 9:case 10:return"date";case 12:case 16:return"array";case 13:case 14:return"object";default:return"other"}}async function we(){return await import(`${ne}${L.resolve()}`)}Object.defineProperty(SQLiteDatabaseClient.prototype,"dialect",{value:"sqlite"});class DuckDBClient{constructor(e){Object.defineProperties(this,{_db:{value:e}})}async queryStream(e,t){const n=await this._db.connect();let r,a;try{if(t?.length>0){const a=await n.prepare(e);r=await a.send(...t)}else r=await n.send(e);if(a=await r.next(),a.done)throw new Error("missing first batch")}catch(e){throw await n.close(),e}return{schema:pe(a.value),async*readRows(){try{for(;!a.done;)yield a.value.toArray(),a=await r.next()}finally{await n.close()}}}}async query(e,t){const n=await this.queryStream(e,t),r=[];for await(const e of n.readRows())for(const t of e)r.push(t);return r.schema=n.schema,r}async queryRow(e,t){const n=(await this.queryStream(e,t)).readRows();try{const{done:e,value:t}=await n.next();return e||!t.length?null:t[0]}finally{await n.return()}}async sql(e,...t){return await this.query(e.join("?"),t)}queryTag(e,...t){return[e.join("?"),t]}escape(e){return`"${e}"`}async describeTables(){return(await this.query("SHOW TABLES")).map((({name:e})=>({name:e})))}async describeColumns({table:e}={}){return(await this.query(`DESCRIBE ${this.escape(e)}`)).map((({column_name:e,column_type:t,null:n})=>({name:e,type:Ee(t),nullable:"NO"!==n,databaseType:t})))}static async of(e={},t={}){const n=await async function(){void 0===re&&(re=async function(){const e=await import(`${ne}${D.resolve()}`),t=await e.selectBundle({mvp:{mainModule:`${ne}${D.resolve("dist/duckdb-mvp.wasm")}`,mainWorker:`${ne}${D.resolve("dist/duckdb-browser-mvp.worker.js")}`},eh:{mainModule:`${ne}${D.resolve("dist/duckdb-eh.wasm")}`,mainWorker:`${ne}${D.resolve("dist/duckdb-browser-eh.worker.js")}`}}),n=new e.ConsoleLogger;return{module:e,bundle:t,logger:n}}());const{module:e,bundle:t,logger:n}=await re,r=await e.createWorker(t.mainWorker),a=new e.AsyncDuckDB(n,r);return await a.instantiate(t.mainModule),a}();return void 0===t.query?.castTimestampToDate&&(t={...t,query:{...t.query,castTimestampToDate:!0}}),void 0===t.query?.castBigIntToDouble&&(t={...t,query:{...t.query,castBigIntToDouble:!0}}),await n.open(t),await Promise.all(Object.entries(e).map((async([e,t])=>{if(t instanceof FileAttachment)await ye(n,e,t);else if(me(t))await ve(n,e,t);else if(Array.isArray(t))await ge(n,e,t);else if(de(t))await async function(e,t,n){const r=(await we()).tableFromIPC(n.toArrowBuffer());return await ve(e,t,r)}(n,e,t);else if("data"in t){const{data:r,...a}=t;me(r)?await ve(n,e,r,a):await ge(n,e,r,a)}else{if(!("file"in t))throw new Error(`invalid source: ${t}`);{const{file:r,...a}=t;await ye(n,e,r,a)}}}))),new DuckDBClient(n)}}async function ye(e,t,n,r){const a=await n.url();if(a.startsWith("blob:")){const t=await n.arrayBuffer();await e.registerFileBuffer(n.name,new Uint8Array(t))}else await e.registerFileURL(n.name,a,4);const o=await e.connect();try{switch(n.mimeType){case"text/csv":case"text/tab-separated-values":return await o.insertCSVFromPath(n.name,{name:t,schema:"main",...r}).catch((async e=>{if(e.toString().includes("Could not convert"))return await async function(e,t,n){const r=await e.prepare(`CREATE TABLE '${n}' AS SELECT * FROM read_csv_auto(?, ALL_VARCHAR=TRUE)`);return await r.send(t.name)}(o,n,t);throw e}));case"application/json":return await o.insertJSONFromPath(n.name,{name:t,schema:"main",...r});default:if(/\.arrow$/i.test(n.name)){const e=new Uint8Array(await n.arrayBuffer());return await o.insertArrowFromIPCStream(e,{name:t,schema:"main",...r})}if(/\.parquet$/i.test(n.name))return await o.query(`CREATE VIEW '${t}' AS SELECT * FROM parquet_scan('${n.name}')`);throw new Error(`unknown file type: ${n.mimeType}`)}}finally{await o.close()}}async function ve(e,t,n,r){const a=await e.connect();try{await a.insertArrowTable(n,{name:t,schema:"main",...r})}finally{await a.close()}}async function ge(e,t,n,r){const a=(await we()).tableFromJSON(n);return await ve(e,t,a,r)}function Ee(e){switch(e){case"BIGINT":case"HUGEINT":case"UBIGINT":return"bigint";case"DOUBLE":case"REAL":case"FLOAT":return"number";case"INTEGER":case"SMALLINT":case"TINYINT":case"USMALLINT":case"UINTEGER":case"UTINYINT":return"integer";case"BOOLEAN":return"boolean";case"DATE":case"TIMESTAMP":case"TIMESTAMP WITH TIME ZONE":return"date";case"VARCHAR":case"UUID":return"string";default:return/^DECIMAL\(/.test(e)?"integer":"other"}}Object.defineProperty(DuckDBClient.prototype,"dialect",{value:"duckdb"});function Ae(e,t){return e&&("function"==typeof e.sql||"function"==typeof e.queryTag&&("function"==typeof e.query||"function"==typeof e.queryStream))&&("table"!==t||"function"==typeof e.describeColumns)&&e!==Re}function Te(e){return Array.isArray(e)&&(Ne(e.schema)||je(e.columns)||function(e){const t=Math.min(20,e.length);for(let n=0;n<t;++n){const t=e[n];if(null===t||"object"!=typeof t)return!1}return t>0&&function(e){for(const t in e)return!0;return!1}(e[0])}(e)||$e(e)||Ce(e))||qe(e)}function Ne(e){return Array.isArray(e)&&e.every(xe)}function je(e){return Array.isArray(e)&&e.every((e=>"string"==typeof e))}function xe(e){return e&&"string"==typeof e.name&&"string"==typeof e.type}function Oe(e){return qe(e)||$e(e)||Ce(e)}function $e(e){const t=Math.min(20,e.length);if(!(t>0))return!1;let n,r=!1;for(let a=0;a<t;++a){const t=e[a];if(null==t)continue;const o=typeof t;if(void 0===n)switch(o){case"number":case"boolean":case"string":case"bigint":n=o;break;default:return!1}else if(o!==n)return!1;r=!0}return r}function Ce(e){const t=Math.min(20,e.length);if(!(t>0))return!1;let n=!1;for(let r=0;r<t;++r){const t=e[r];if(null!=t){if(!(t instanceof Date))return!1;n=!0}}return n}function qe(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}const Re=Object.assign((async(e,t,n,r)=>{if(Ae(e=await Ie(await e,r)))return Pe(e,_e(t,e),n);if(Te(e))return ut(e,t);if(!e)throw new Error("missing data source");throw new Error("invalid data source")}),{sql:(e,t,n)=>async function(){return Pe(await Se(await e,n),arguments,t)}});function ke(e){const t=new WeakMap;return(n,r)=>{if(!n||"object"!=typeof n)throw new Error("invalid data source");let a=t.get(n);return(!a||Te(n)&&n.length!==a._numRows)&&(a=e(n,r),a._numRows=n.length,t.set(n,a)),a}}const Le=ke((async e=>{if(e instanceof FileAttachment){switch(e.mimeType){case"text/csv":return e.csv({typed:"auto"});case"text/tab-separated-values":return e.tsv({typed:"auto"});case"application/json":return e.json()}throw new Error(`unsupported file type: ${e.mimeType}`)}return e})),Ie=ke((async(e,t)=>{if(e instanceof FileAttachment){switch(e.mimeType){case"text/csv":return e.csv();case"text/tab-separated-values":return e.tsv();case"application/json":return e.json();case"application/x-sqlite3":return e.sqlite()}if(/\.(arrow|parquet)$/i.test(e.name))return Me(e,t);throw new Error(`unsupported file type: ${e.mimeType}`)}return me(e)||de(e)?Me(e,t):Te(e)&&Oe(e)?Array.from(e,(e=>({value:e}))):e})),Se=ke((async(e,t)=>{if(e instanceof FileAttachment){switch(e.mimeType){case"text/csv":case"text/tab-separated-values":case"application/json":return Me(e,t);case"application/x-sqlite3":return e.sqlite()}if(/\.(arrow|parquet)$/i.test(e.name))return Me(e,t);throw new Error(`unsupported file type: ${e.mimeType}`)}return Te(e)?Me(await async function(e,t){const n=await we();return Oe(e)?n.tableFromArrays({[t]:e}):n.tableFromJSON(e)}(e,t),t):me(e)||de(e)?Me(e,t):e}));function Me(e,t=(e instanceof FileAttachment?function(e){return e.name.replace(/@\d+(?=\.|$)/,"").replace(/\.\w+$/,"")}(e):"__table")){return DuckDBClient.of({[t]:e})}async function Pe(e,t,n){if(!e)throw new Error("missing data source");if("function"==typeof e.queryTag){const r=new AbortController,a={signal:r.signal};if(n.then((()=>r.abort("invalidated"))),"function"==typeof e.queryStream)return async function*(e){let t=performance.now();const n=await e,r=[];r.done=!1,r.error=null,r.schema=n.schema;try{for await(const e of n.readRows()){performance.now()-t>150&&r.length>0&&(yield r,t=performance.now());for(const t of e)r.push(t)}r.done=!0,yield r}catch(e){r.error=e,yield r}}(e.queryStream(...e.queryTag.apply(e,t),a));if("function"==typeof e.query)return e.query(...e.queryTag.apply(e,t),a)}if("function"==typeof e.sql)return e.sql.apply(e,t);throw new Error("source does not implement query, queryStream, or sql")}function _e(e,t){const n="function"==typeof t.escape?t.escape:e=>e,{select:r,from:a,filter:o,sort:s,slice:i}=e;if(!a.table)throw new Error("missing from table");if(r.columns&&0===r.columns.length)throw new Error("at least one column must be selected");const c=new Map(e.names?.map((({column:e,name:t})=>[e,t]))),u=[[`SELECT ${r.columns?r.columns.map((e=>{const t=c.get(e);return t?`${n(e)} AS ${n(t)}`:n(e)})).join(", "):"*"} FROM ${De(a.table,n)}`]];for(let e=0;e<o.length;++e)Ue(e?"\nAND ":"\nWHERE ",u),Be(o[e],u,n);for(let e=0;e<s.length;++e)Ue(e?", ":"\nORDER BY ",u),Fe(s[e],u,n);if("mssql"===t.dialect||"oracle"===t.dialect){if(null!==i.to||null!==i.from){if(!s.length){if(!r.columns)throw new Error("at least one column must be explicitly specified. Received '*'.");Ue("\nORDER BY ",u),Fe({column:r.columns[0],direction:"ASC"},u,n)}Ue(`\nOFFSET ${i.from||0} ROWS`,u),Ue(`\nFETCH NEXT ${null!==i.to?i.to-(i.from||0):1e9} ROWS ONLY`,u)}}else null===i.to&&null===i.from||Ue("\nLIMIT "+(null!==i.to?i.to-(i.from||0):1e9),u),null!==i.from&&Ue(` OFFSET ${i.from}`,u);return u}function De(e,t){if("object"==typeof e){let n="";return null!=e.database&&(n+=t(e.database)+"."),null!=e.schema&&(n+=t(e.schema)+"."),n+=t(e.table),n}return t(e)}function Ue(e,t){const n=t[0];n[n.length-1]+=e}function Fe({column:e,direction:t},n,r){Ue(`${r(e)} ${t.toUpperCase()}`,n)}function Be({type:e,operands:t},n,r){if(t.length<1)throw new Error("Invalid operand length");if(1===t.length||"v"===e||"nv"===e)switch(We(t[0],n,r),e){case"n":case"nv":return void Ue(" IS NULL",n);case"nn":case"v":return void Ue(" IS NOT NULL",n);default:throw new Error("Invalid filter operation")}if(2!==t.length||["in","nin"].includes(e)){var a;switch(We(t[0],n,r),e){case"in":Ue(" IN (",n);break;case"nin":Ue(" NOT IN (",n);break;default:throw new Error("Invalid filter operation")}!function(e,t){let n=!0;for(const r of e)n?n=!1:Ue(",",t),t.push(r.value),t[0].push("")}(t.slice(1),n),Ue(")",n)}else{if(["c","nc"].includes(e)){switch(We(t[0],n,r),e){case"c":Ue(" LIKE ",n);break;case"nc":Ue(" NOT LIKE ",n)}return void We((a=t[1],{...a,value:`%${a.value}%`}),n,r)}switch(We(t[0],n,r),e){case"eq":Ue(" = ",n);break;case"ne":Ue(" <> ",n);break;case"gt":Ue(" > ",n);break;case"lt":Ue(" < ",n);break;case"gte":Ue(" >= ",n);break;case"lte":Ue(" <= ",n);break;default:throw new Error("Invalid filter operation")}We(t[1],n,r)}}function We(e,t,n){"column"===e.type?Ue(n(e.value),t):(t.push(e.value),t[0].push(""))}function He(e,t){return(null==e||!(e>=e))-(null==t||!(t>=t))}function ze(e,t){return He(e,t)||(e<t?-1:e>t?1:0)}function Ve(e,t){return He(e,t)||(e>t?-1:e<t?1:0)}const Ge=e=>"number"==typeof e&&!Number.isNaN(e),Ye=e=>Number.isInteger(e)&&!Number.isNaN(e),Ze=e=>"string"==typeof e,Je=e=>"boolean"==typeof e,Qe=e=>"bigint"==typeof e,Xe=e=>e instanceof Date&&!isNaN(e),Ke=e=>e instanceof ArrayBuffer,et=e=>Array.isArray(e),tt=e=>"object"==typeof e&&null!==e,nt=e=>null!=e;function rt(e){switch(e){case"string":return Ze;case"bigint":return Qe;case"boolean":return Je;case"number":return Ge;case"integer":return Ye;case"date":return Xe;case"buffer":return Ke;case"array":return et;case"object":return tt;default:return nt}}const at=/^(([-+]\d{2})?\d{4}(-\d{2}(-\d{2}))|(\d{1,2})\/(\d{1,2})\/(\d{2,4}))([T ]\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/;function ot(e,t){switch(t){case"string":return"string"==typeof e||null==e?e:String(e);case"boolean":if("string"==typeof e){const t=e.trim().toLowerCase();return"true"===t||"false"!==t&&null}return"boolean"==typeof e||null==e?e:Boolean(e);case"bigint":return"bigint"==typeof e||null==e?e:Number.isInteger("string"!=typeof e||e.trim()?+e:NaN)?BigInt(e):void 0;case"integer":case"number":return"number"==typeof e?e:null==e||"string"==typeof e&&!e.trim()?NaN:Number(e);case"date":{if(e instanceof Date||null==e)return e;if("number"==typeof e)return new Date(e);const t=String(e).trim();return"string"!=typeof e||t?new Date(at.test(t)?t:NaN):null}case"array":case"object":case"buffer":case"other":return e;default:throw new Error(`Unable to coerce to type: ${t}`)}}function st(e){const{columns:t}=e;let{schema:n}=e;return Ne(n)?{schema:n,inferred:!1}:(n=dt(e,je(t)?t:void 0),{schema:n,inferred:!0})}function it(e,t){const n=e;let{schema:r,inferred:a}=st(e);const o=new Map(r.map((({name:e,type:t})=>[e,t])));if(t.types){for(const{name:e,type:a}of t.types){o.set(e,a),r===n.schema&&(r=r.slice());const t=r.findIndex((t=>t.name===e));t>-1&&(r[t]={...r[t],type:a})}e=e.map((e=>lt(e,o,r)))}else a&&(e=e.map((e=>lt(e,o,r))));return{source:e,schema:r}}function ct(e,t){if(!t.names)return e;const n=new Map(t.names.map((e=>[e.column,e])));return e.map((e=>Object.fromEntries(Object.keys(e).map((t=>[n.get(t)?.name??t,e[t]])))))}function ut(e,t){const n=new Map,r=e,a=it(e,t);e=a.source;let o=a.schema;if(t.derive){const r=[];t.derive.map((({name:a,value:o})=>{let s=[];ct(e,t).map(((e,t)=>{let n;try{n=o(e)}catch(e){s.push({index:t,error:e}),n=void 0}r[t]?r[t]={...r[t],[a]:n}:r.push({[a]:n})})),s.length&&n.set(a,s)}));const a=it(r,t);e=e.map(((e,t)=>({...e,...a.source[t]}))),o=[...o,...a.schema]}for(const{type:n,operands:r}of t.filter){const[{value:t}]=r,a=r.slice(1).map((({value:e})=>e));switch(n){case"v":{const[n]=a,r=rt(n);e=e.filter((e=>r(e[t])));break}case"nv":{const[n]=a,r=rt(n);e=e.filter((e=>!r(e[t])));break}case"eq":{const[n]=a;if(n instanceof Date){const r=+n;e=e.filter((e=>+e[t]===r))}else e=e.filter((e=>e[t]===n));break}case"ne":{const[n]=a;e=e.filter((e=>e[t]!==n));break}case"c":{const[n]=a;e=e.filter((e=>"string"==typeof e[t]&&e[t].includes(n)));break}case"nc":{const[n]=a;e=e.filter((e=>"string"==typeof e[t]&&!e[t].includes(n)));break}case"in":{const n=new Set(a);e=e.filter((e=>n.has(e[t])));break}case"nin":{const n=new Set(a);e=e.filter((e=>!n.has(e[t])));break}case"n":e=e.filter((e=>null==e[t]));break;case"nn":e=e.filter((e=>null!=e[t]));break;case"lt":{const[n]=a;e=e.filter((e=>e[t]<n));break}case"lte":{const[n]=a;e=e.filter((e=>e[t]<=n));break}case"gt":{const[n]=a;e=e.filter((e=>e[t]>n));break}case"gte":{const[n]=a;e=e.filter((e=>e[t]>=n));break}default:throw new Error(`unknown filter type: ${n}`)}}for(const{column:n,direction:a}of function(e){if("function"!=typeof e[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(e).reverse()}(t.sort)){const t="desc"===a?Ve:ze;e===r&&(e=e.slice()),e.sort(((e,r)=>t(e[n],r[n])))}let{from:s,to:i}=t.slice;s=null==s?0:Math.max(0,s),i=null==i?1/0:Math.max(0,i),(s>0||i<1/0)&&(e=e.slice(Math.max(0,s),Math.max(0,i)));let c=o.slice();if(t.select.columns){if(o){const e=new Map(o.map((e=>[e.name,e])));o=t.select.columns.map((t=>e.get(t)))}e=e.map((e=>Object.fromEntries(t.select.columns.map((t=>[t,e[t]])))))}if(t.names){const n=new Map(t.names.map((e=>[e.column,e])));o&&(o=o.map((e=>{const t=n.get(e.name);return{...e,...t?{name:t.name}:null}}))),c&&(c=c.map((e=>{const t=n.get(e.name);return{...e,...t?{name:t.name}:null}}))),e=ct(e,t)}return e!==r&&o&&(e.schema=o),e.fullSchema=c,e.errors=n,e}function lt(e,t,n){const r={};for(const a of n){const n=t.get(a.name),o=e[a.name];r[a.name]="raw"===n?o:ot(o,n)}return r}const ft=["boolean","integer","number","date","bigint","array","object","buffer"];function dt(e,t=function(e){const t=new Set;for(const n of e)if(n)for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&t.add(e);return Array.from(t)}(e)){const n=[],r=e.slice(0,100);for(const e of t){const t={boolean:0,integer:0,number:0,date:0,string:0,array:0,object:0,bigint:0,buffer:0,defined:0};for(const n of r){let r=n[e];if(null==r)continue;const a=typeof r;if("string"!==a)++t.defined,Array.isArray(r)?++t.array:r instanceof Date?++t.date:r instanceof ArrayBuffer?++t.buffer:"number"===a?(++t.number,Number.isInteger(r)&&++t.integer):a in t&&++t[a];else{if(r=r.trim(),!r)continue;++t.defined,++t.string,/^(true|false)$/i.test(r)?++t.boolean:r&&!isNaN(r)?(++t.number,Number.isInteger(+r)&&++t.integer):at.test(r)&&++t.date}}const a=Math.max(1,.9*t.defined),o=fe(ft,(e=>t[e]>=a?t[e]:NaN))??(t.string>=a?"string":"other");n.push({name:e,type:o,inferred:o})}return n}class Workbook{constructor(e){Object.defineProperties(this,{_:{value:e},sheetNames:{value:e.worksheets.map((e=>e.name)),enumerable:!0}})}sheet(e,t){const n="number"==typeof e?this.sheetNames[e]:this.sheetNames.includes(e+="")?e:null;if(null==n)throw new Error(`Sheet not found: ${e}`);return function(e,{range:t,headers:n}={}){let[[r,a],[o,s]]=function(e=":",{columnCount:t,rowCount:n}){if(!(e+="").match(/^[A-Z]*\d*:[A-Z]*\d*$/))throw new Error("Malformed range specifier");const[[r=0,a=0],[o=t-1,s=n-1]]=e.split(":").map(bt);return[[r,a],[o,s]]}(t,e);const i=n?e._rows[a++]:null;let c=new Set(["#"]);for(let e=r;e<=o;e++){const t=i?mt(i.findCell(e+1)):null;let n=t&&t+""||ht(e);for(;c.has(n);)n+="_";c.add(n)}c=new Array(r).concat(Array.from(c));const u=new Array(s-a+1);for(let t=a;t<=s;t++){const n=u[t-a]=Object.create(null,{"#":{value:t+1}}),s=e.getRow(t+1);if(s.hasValues)for(let e=r;e<=o;e++){const t=mt(s.findCell(e+1));null!=t&&(n[c[e+1]]=t)}}return u.columns=c.filter((()=>!0)),u}(this._.getWorksheet(n),t)}}function mt(e){if(!e)return;const{value:t}=e;if(t&&"object"==typeof t&&!(t instanceof Date)){if(t.formula||t.sharedFormula)return t.result&&t.result.error?NaN:t.result;if(t.richText)return pt(t);if(t.text){let{text:e}=t;return e.richText&&(e=pt(e)),t.hyperlink&&t.hyperlink!==e?`${t.hyperlink} ${e}`:e}return t}return t}function pt(e){return e.richText.map((e=>e.text)).join("")}function ht(e){let t="";e++;do{t=String.fromCharCode(64+(e%26||26))+t}while(e=Math.floor((e-1)/26));return t}function bt(e){const[,t,n]=e.match(/^([A-Z]*)(\d*)$/);let r=0;if(t)for(let e=0;e<t.length;e++)r+=Math.pow(26,t.length-e-1)*(t.charCodeAt(e)-64);return[r?r-1:void 0,n?+n-1:void 0]}async function wt(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function yt(e,t,{array:n=!1,typed:r=!1}={}){const a=await e.text(),o="\t"===t?n?m:d:n?l:u;if("auto"===r&&!n){const e=o(a);return function(e,t){const n=new Map(t.map((({name:e,type:t})=>[e,t])));return Object.assign(e.map((e=>lt(e,n,t))),{schema:t})}(e,dt(e,e.columns))}return o(a,r&&p)}class vt{constructor(e,t){Object.defineProperty(this,"name",{value:e,enumerable:!0}),void 0!==t&&Object.defineProperty(this,"mimeType",{value:t+"",enumerable:!0})}async blob(){return(await wt(this)).blob()}async arrayBuffer(){return(await wt(this)).arrayBuffer()}async text(){return(await wt(this)).text()}async json(){return(await wt(this)).json()}async stream(){return(await wt(this)).body}async csv(e){return yt(this,",",e)}async tsv(e){return yt(this,"\t",e)}async image(e){const t=await this.url();return new Promise(((n,r)=>{const a=new Image;new URL(t,document.baseURI).origin!==new URL(location).origin&&(a.crossOrigin="anonymous"),Object.assign(a,e),a.onload=()=>n(a),a.onerror=()=>r(new Error(`Unable to load file: ${this.name}`)),a.src=t}))}async arrow({version:e=4}={}){switch(e){case 4:{const[e,t]=await Promise.all([ae(R.resolve()),wt(this)]);return e.Table.from(t)}case 9:{const[e,t]=await Promise.all([import(`${ne}${k.resolve()}`),wt(this)]);return e.tableFromIPC(t)}case 11:{const[e,t]=await Promise.all([import(`${ne}${L.resolve()}`),wt(this)]);return e.tableFromIPC(t)}default:throw new Error(`unsupported arrow version: ${e}`)}}async sqlite(){return SQLiteDatabaseClient.open(wt(this))}async zip(){const[e,t]=await Promise.all([ae(j.resolve()),this.arrayBuffer()]);return new ZipArchive(await e.loadAsync(t))}async xml(e="application/xml"){return(new DOMParser).parseFromString(await this.text(),e)}async html(){return this.xml("text/html")}async xlsx(){const[e,t]=await Promise.all([ae(M.resolve()),this.arrayBuffer()]);return new Workbook(await(new e.Workbook).xlsx.load(t))}}class FileAttachment extends vt{constructor(e,t,n){super(t,n),Object.defineProperty(this,"_url",{value:e})}async url(){return await this._url+""}}function gt(e){throw new Error(`File not found: ${e}`)}class ZipArchive{constructor(e){Object.defineProperty(this,"_",{value:e}),this.filenames=Object.keys(e.files).filter((t=>!e.files[t].dir))}file(e){const t=this._.file(e+="");if(!t||t.dir)throw new Error(`file not found: ${e}`);return new ZipArchiveEntry(t)}}class ZipArchiveEntry extends vt{constructor(e){super(e.name),Object.defineProperty(this,"_",{value:e}),Object.defineProperty(this,"_url",{writable:!0})}async url(){return this._url||(this._url=this.blob().then(URL.createObjectURL))}async blob(){return this._.async("blob")}async arrayBuffer(){return this._.async("arraybuffer")}async text(){return this._.async("text")}async json(){return JSON.parse(await this.text())}}var Et={math:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};var At=0;function Tt(e){return new Nt("O-"+(null==e?"":e+"-")+ ++At)}function Nt(e){this.id=e,this.href=new URL(`#${e}`,location)+""}Nt.prototype.toString=function(){return"url("+this.href+")"};var jt=Object.freeze({__proto__:null,canvas:function(e,t){var n=document.createElement("canvas");return n.width=e,n.height=t,n},context2d:function(e,t,n){null==n&&(n=devicePixelRatio);var r=document.createElement("canvas");r.width=e*n,r.height=t*n,r.style.width=e+"px";var a=r.getContext("2d");return a.scale(n,n),a},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),a=r.appendChild(document.createElement("button"));async function o(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),a.textContent=n,a.disabled=!1}return a.textContent=n,r.download=t,r.onclick=async t=>{if(a.disabled=!0,r.href)return o();a.textContent="Saving…";try{const t=await("function"==typeof e?e():e);a.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){a.textContent=n}if(t.eventPhase)return o();a.disabled=!1},r},element:function(e,t){var n,r=e+="",a=r.indexOf(":");a>=0&&"xmlns"!==(r=e.slice(0,a))&&(e=e.slice(a+1));var o=Et.hasOwnProperty(r)?document.createElementNS(Et[r],e):document.createElement(e);if(t)for(var s in t)a=(r=s).indexOf(":"),n=t[s],a>=0&&"xmlns"!==(r=s.slice(0,a))&&(s=s.slice(a+1)),Et.hasOwnProperty(r)?o.setAttributeNS(Et[r],s,n):o.setAttribute(s,n);return o},input:function(e){var t=document.createElement("input");return null!=e&&(t.type=e),t},range:function(e,t,n){1===arguments.length&&(t=e,e=null);var r=document.createElement("input");return r.min=e=null==e?0:+e,r.max=t=null==t?1:+t,r.step=null==n?"any":n=+n,r.type="range",r},select:function(e){var t=document.createElement("select");return Array.prototype.forEach.call(e,(function(e){var n=document.createElement("option");n.value=n.textContent=e,t.appendChild(n)})),t},svg:function(e,t){var n=document.createElementNS("http://www.w3.org/2000/svg","svg");return n.setAttribute("viewBox",[0,0,e,t]),n.setAttribute("width",e),n.setAttribute("height",t),n},text:function(e){return document.createTextNode(e)},uid:Tt});var xt=Object.freeze({__proto__:null,buffer:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsArrayBuffer(e)}))},text:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsText(e)}))},url:function(e){return new Promise((function(t,n){var r=new FileReader;r.onload=function(){t(r.result)},r.onerror=n,r.readAsDataURL(e)}))}});function Ot(){return this}function $t(e,t){let n=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:Ot,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function Ct(e){let t,n,r=!1;const a=e((function(e){n?(n(e),n=null):r=!0;return t=e}));if(null!=a&&"function"!=typeof a)throw new Error("function"==typeof a.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:Ot,throw:()=>({done:!0}),return:()=>(null!=a&&a(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise((e=>n=e))}}}}function qt(e){switch(e.type){case"range":case"number":return e.valueAsNumber;case"date":return e.valueAsDate;case"checkbox":return e.checked;case"file":return e.multiple?e.files:e.files[0];case"select-multiple":return Array.from(e.selectedOptions,(e=>e.value));default:return e.value}}var Rt=Object.freeze({__proto__:null,disposable:$t,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return Ct((function(t){var n=function(e){switch(e.type){case"button":case"submit":case"checkbox":return"click";case"file":return"change";default:return"input"}}(e),r=qt(e);function a(){t(qt(e))}return e.addEventListener(n,a),void 0!==r&&t(r),function(){e.removeEventListener(n,a)}}))},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:Ct,queue:function(e){let t;const n=[],r=e((function(e){n.push(e),t&&(t(n.shift()),t=null);return e}));if(null!=r&&"function"!=typeof r)throw new Error("function"==typeof r.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:Ot,throw:()=>({done:!0}),return:()=>(null!=r&&r(),{done:!0}),next:function(){return{done:!1,value:n.length?Promise.resolve(n.shift()):new Promise((e=>t=e))}}}},range:function*(e,t,n){e=+e,t=+t,n=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+n;for(var r=-1,a=0|Math.max(0,Math.ceil((t-e)/n));++r<a;)yield e+r*n},valueAt:function(e,t){if(!(!isFinite(t=+t)||t<0||t!=t|0))for(var n,r=-1;!(n=e.next()).done;)if(++r===t)return n.value},worker:function(e){const t=URL.createObjectURL(new Blob([e],{type:"text/javascript"})),n=new Worker(t);return $t(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}});function kt(e,t){return function(n){var r,a,o,s,i,c,u,l,f=n[0],d=[],m=null,p=-1;for(i=1,c=arguments.length;i<c;++i){if((r=arguments[i])instanceof Node)d[++p]=r,f+="\x3c!--o:"+p+"--\x3e";else if(Array.isArray(r)){for(u=0,l=r.length;u<l;++u)(a=r[u])instanceof Node?(null===m&&(d[++p]=m=document.createDocumentFragment(),f+="\x3c!--o:"+p+"--\x3e"),m.appendChild(a)):(m=null,f+=a);m=null}else f+=r;f+=n[i]}if(m=e(f),++p>0){for(o=new Array(p),s=document.createTreeWalker(m,NodeFilter.SHOW_COMMENT,null,!1);s.nextNode();)a=s.currentNode,/^o:/.test(a.nodeValue)&&(o[+a.nodeValue.slice(2)]=a);for(i=0;i<p;++i)(a=o[i])&&a.parentNode.replaceChild(d[i],a)}return 1===m.childNodes.length?m.removeChild(m.firstChild):11===m.nodeType?((a=t()).appendChild(m),a):m}}const Lt=kt((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));function It(e){let t;Object.defineProperties(this,{generator:{value:Ct((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*St(){for(;;)yield Date.now()}var Mt=new Map;function Pt(e,t){var n;return(n=Mt.get(e=+e))?n.then((()=>t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise((function(n){Mt.delete(t);var r=t-e;if(!(r>0))throw new Error("invalid time");if(r>2147483647)throw new Error("too long to wait");setTimeout(n,r)}));return Mt.set(t,n),n}(n,e).then((()=>t))}var _t=Object.freeze({__proto__:null,delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return Pt(Math.ceil((Date.now()+1)/e)*e,t)},when:Pt});function Dt(e,t){if(/^(\w+:)|\/\//i.test(e))return e;if(/^[.]{0,2}\//i.test(e))return new URL(e,null==t?location:t).href;if(!e.length||/^[\s._]/.test(e)||/\s$/.test(e))throw new Error("illegal name");return"https://unpkg.com/"+e}const Ut=kt((function(e){var t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.innerHTML=e.trim(),t}),(function(){return document.createElementNS("http://www.w3.org/2000/svg","g")}));var Ft=String.raw;function Bt(e){return new Promise((function(t,n){var r=document.createElement("link");r.rel="stylesheet",r.href=e,r.onerror=n,r.onload=t,document.head.appendChild(r)}))}function Wt(){return Ct((function(e){var t=e(document.body.clientWidth);function n(){var n=document.body.clientWidth;n!==t&&e(t=n)}return window.addEventListener("resize",n),function(){window.removeEventListener("resize",n)}}))}const Ht=Object.assign(Object.defineProperties((function(e){const t=function(e){return null==e?ae:Q(e)}(e);var n;Object.defineProperties(this,(n={FileAttachment:()=>gt,Mutable:()=>It,now:St,width:Wt,dot:()=>t(g.resolve()),htl:()=>t(N.resolve()),html:()=>Lt,md:()=>function(e){return e(x.resolve()).then((function(t){return kt((function(n){var r=document.createElement("div");r.innerHTML=t(n,{langPrefix:""}).trim();var a=r.querySelectorAll("pre code[class]");return a.length>0&&e(E.resolve()).then((function(t){a.forEach((function(n){function r(){t.highlightBlock(n),n.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(n.className)?r():e(E.resolve("async-languages/index.js")).then((r=>{if(r.has(n.className))return e(E.resolve("async-languages/"+r.get(n.className))).then((e=>{t.registerLanguage(n.className,e)}))})).then(r,r)}))})),r}),(function(){return document.createElement("div")}))}))}(t),svg:()=>Ut,tex:()=>function(e){return Promise.all([e(A.resolve()),e.resolve(A.resolve("dist/katex.min.css")).then(Bt)]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(Ft.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}))}(t),_:()=>t(T.resolve()),aq:()=>t.alias({"apache-arrow":R.resolve()})(I.resolve()),Arrow:()=>t(R.resolve()),d3:()=>t(w.resolve()),DuckDBClient:()=>DuckDBClient,Inputs:()=>t(y.resolve()).then((e=>({...e,file:e.fileOf(vt)}))),L:()=>async function(e){const t=await e(_.resolve());if(!t._style){const n=document.createElement("link");n.rel="stylesheet",n.href=await e.resolve(_.resolve("dist/leaflet.css")),t._style=document.head.appendChild(n)}return t}(t),mermaid:()=>async function(e){const t=await e(P.resolve());return t.initialize({securityLevel:"loose",theme:"neutral"}),function(){const e=document.createElement("div");return e.innerHTML=t.render(Tt().id,String.raw.apply(String,arguments)),e.removeChild(e.firstChild)}}(t),Plot:()=>t(v.resolve()),__query:()=>Re,require:()=>t,resolve:()=>Dt,SQLite:()=>oe(t),SQLiteDatabaseClient:()=>SQLiteDatabaseClient,topojson:()=>t(S.resolve()),vl:()=>async function(e){const[t,n,r]=await Promise.all([$,C,q].map((t=>e(t.resolve()))));return r.register(t,n)}(t),aapl:()=>new FileAttachment("https://static.observableusercontent.com/files/3ccff97fd2d93da734e76829b2b066eafdaac6a1fafdec0faf6ebc443271cfc109d29e80dd217468fcb2aff1e6bffdc73f356cc48feb657f35378e6abbbb63b9").csv({typed:!0}),alphabet:()=>new FileAttachment("https://static.observableusercontent.com/files/75d52e6c3130b1cae83cda89305e17b50f33e7420ef205587a135e8562bcfd22e483cf4fa2fb5df6dff66f9c5d19740be1cfaf47406286e2eb6574b49ffc685d").csv({typed:!0}),cars:()=>new FileAttachment("https://static.observableusercontent.com/files/048ec3dfd528110c0665dfa363dd28bc516ffb7247231f3ab25005036717f5c4c232a5efc7bb74bc03037155cb72b1abe85a33d86eb9f1a336196030443be4f6").csv({typed:!0}),citywages:()=>new FileAttachment("https://static.observableusercontent.com/files/39837ec5121fcc163131dbc2fe8c1a2e0b3423a5d1e96b5ce371e2ac2e20a290d78b71a4fb08b9fa6a0107776e17fb78af313b8ea70f4cc6648fad68ddf06f7a").csv({typed:!0}),diamonds:()=>new FileAttachment("https://static.observableusercontent.com/files/87942b1f5d061a21fa4bb8f2162db44e3ef0f7391301f867ab5ba718b225a63091af20675f0bfe7f922db097b217b377135203a7eab34651e21a8d09f4e37252").csv({typed:!0}),flare:()=>new FileAttachment("https://static.observableusercontent.com/files/a6b0d94a7f5828fd133765a934f4c9746d2010e2f342d335923991f31b14120de96b5cb4f160d509d8dc627f0107d7f5b5070d2516f01e4c862b5b4867533000").csv({typed:!0}),industries:()=>new FileAttachment("https://static.observableusercontent.com/files/76f13741128340cc88798c0a0b7fa5a2df8370f57554000774ab8ee9ae785ffa2903010cad670d4939af3e9c17e5e18e7e05ed2b38b848ac2fc1a0066aa0005f").csv({typed:!0}),miserables:()=>new FileAttachment("https://static.observableusercontent.com/files/31d904f6e21d42d4963ece9c8cc4fbd75efcbdc404bf511bc79906f0a1be68b5a01e935f65123670ed04e35ca8cae3c2b943f82bf8db49c5a67c85cbb58db052").json(),olympians:()=>new FileAttachment("https://static.observableusercontent.com/files/31ca24545a0603dce099d10ee89ee5ae72d29fa55e8fc7c9ffb5ded87ac83060d80f1d9e21f4ae8eb04c1e8940b7287d179fe8060d887fb1f055f430e210007c").csv({typed:!0}),penguins:()=>new FileAttachment("https://static.observableusercontent.com/files/715db1223e067f00500780077febc6cebbdd90c151d3d78317c802732252052ab0e367039872ab9c77d6ef99e5f55a0724b35ddc898a1c99cb14c31a379af80a").csv({typed:!0}),weather:()=>new FileAttachment("https://static.observableusercontent.com/files/693a46b22b33db0f042728700e0c73e836fa13d55446df89120682d55339c6db7cc9e574d3d73f24ecc9bc7eb9ac9a1e7e104a1ee52c00aab1e77eb102913c1f").csv({typed:!0}),DOM:jt,Files:xt,Generators:Rt,Promises:_t},Object.fromEntries(Object.entries(n).map(zt))))}),{resolve:{get:()=>ae.resolve,enumerable:!0,configurable:!0},require:{get:()=>ae,set:function(e){ae=e},enumerable:!0,configurable:!0}}),{resolveFrom:Z,requireFrom:Q});function zt([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}e.AbstractFile=vt,e.FileAttachments=function(e){return Object.assign((t=>{const n=e(t+="");if(null==n)throw new Error(`File not found: ${t}`);if("object"==typeof n&&"url"in n){const{url:e,mimeType:r}=n;return new FileAttachment(e,t,r)}return new FileAttachment(n,t)}),{prototype:FileAttachment.prototype})},e.Library=Ht,e.applyDataTableOperations=ut,e.arrayIsPrimitive=Oe,e.getArrowTableSchema=pe,e.getSchema=st,e.getTypeValidator=rt,e.inferSchema=dt,e.isArqueroTable=de,e.isArrowTable=me,e.isDataArray=Te,e.isDatabaseClient=Ae,e.loadDataSource=async function(e,t,n){switch(t){case"chart":return Le(e);case"table":return Ie(e,n);case"sql":return Se(e,n)}return e},e.makeQueryTemplate=_e,e.observe=Ct}));
{
"name": "@observablehq/stdlib",
"version": "5.7.6",
"version": "5.7.7",
"author": {

@@ -5,0 +5,0 @@ "name": "Observable, Inc.",

import {dependency} from "./dependency.js";
export const d3 = dependency("d3", "7.8.5", "dist/d3.min.js");
export const inputs = dependency("@observablehq/inputs", "0.10.5", "dist/inputs.min.js");
export const plot = dependency("@observablehq/plot", "0.6.8", "dist/plot.umd.min.js");
export const plot = dependency("@observablehq/plot", "0.6.9", "dist/plot.umd.min.js");
export const graphviz = dependency("@observablehq/graphviz", "0.2.1", "dist/graphviz.min.js");

@@ -6,0 +6,0 @@ export const highlight = dependency("@observablehq/highlight.js", "2.0.0", "highlight.min.js");

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc