@observablehq/stdlib
Advanced tools
Comparing version 3.19.6 to 3.19.7
@@ -1,2 +0,2 @@ | ||
// @observablehq/stdlib v3.19.6 Copyright 2022 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 o(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 a(e,t){var n=e+"",r=n.length;return r<t?new Array(t-r+1).join(0)+n:n}function i(e){var t,n=e.getUTCHours(),r=e.getUTCMinutes(),o=e.getUTCSeconds(),i=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":((t=e.getUTCFullYear())<0?"-"+a(-t,6):t>9999?"+"+a(t,6):a(t,4))+"-"+a(e.getUTCMonth()+1,2)+"-"+a(e.getUTCDate(),2)+(i?"T"+a(n,2)+":"+a(r,2)+":"+a(o,2)+"."+a(i,3)+"Z":o?"T"+a(n,2)+":"+a(r,2)+":"+a(o,2)+"Z":r||n?"T"+a(n,2)+":"+a(r,2)+"Z":"")}function s(e){var a=new RegExp('["'+e+"\n\r]"),s=e.charCodeAt(0);function c(e,r){var o,a=[],i=e.length,c=0,l=0,u=i<=0,f=!1;function d(){if(u)return n;if(f)return f=!1,t;var r,o,a=c;if(34===e.charCodeAt(a)){for(;c++<i&&34!==e.charCodeAt(c)||34===e.charCodeAt(++c););return(r=c)>=i?u=!0:10===(o=e.charCodeAt(c++))?f=!0:13===o&&(f=!0,10===e.charCodeAt(c)&&++c),e.slice(a+1,r-1).replace(/""/g,'"')}for(;c<i;){if(10===(o=e.charCodeAt(r=c++)))f=!0;else if(13===o)f=!0,10===e.charCodeAt(c)&&++c;else if(o!==s)continue;return e.slice(a,r)}return u=!0,e.slice(a,i)}for(10===e.charCodeAt(i-1)&&--i,13===e.charCodeAt(i-1)&&--i;(o=d())!==n;){for(var h=[];o!==t&&o!==n;)h.push(o),o=d();r&&null==(h=r(h,l++))||a.push(h)}return a}function l(t,n){return t.map((function(t){return n.map((function(e){return f(t[e])})).join(e)}))}function u(t){return t.map(f).join(e)}function f(e){return null==e?"":e instanceof Date?i(e):a.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,o,a=c(e,(function(e,a){if(n)return n(e,a-1);o=e,n=t?function(e,t){var n=r(e);return function(r,o){return t(n(r),o,e)}}(e,t):r(e)}));return a.columns=o||[],a},parseRows:c,format:function(t,n){return null==n&&(n=o(t)),[n.map(f).join(e)].concat(l(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=o(e)),l(e,t).join("\n")},formatRows:function(e){return e.map(u).join("\n")},formatRow:u,formatValue:f}}var c=s(","),l=c.parse,u=c.parseRows,f=s("\t"),d=f.parse,h=f.parseRows;function m(e){for(var t in e){var n,r,o=e[t].trim();if(o)if("true"===o)o=!0;else if("false"===o)o=!1;else if("NaN"===o)o=NaN;else if(isNaN(n=+o)){if(!(r=o.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)))continue;p&&r[4]&&!r[7]&&(o=o.replace(/-/g,"/").replace(/T/," ")),o=new Date(o)}else o=n;else o=null;e[t]=o}return e}const p=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 v=b("d3","7.6.1","dist/d3.min.js"),w=b("@observablehq/inputs","0.10.4","dist/inputs.min.js"),y=b("@observablehq/plot","0.5.2","dist/plot.umd.min.js"),g=b("@observablehq/graphviz","0.2.1","dist/graphviz.min.js"),x=b("@observablehq/highlight.js","2.0.0","highlight.min.js"),j=b("@observablehq/katex","0.11.1","dist/katex.min.js"),E=b("lodash","4.17.21","lodash.min.js"),N=b("htl","0.3.1","dist/htl.min.js"),A=b("jszip","3.10.0","dist/jszip.min.js"),C=b("marked","0.3.12","marked.min.js"),T=b("sql.js","1.7.0","dist/sql-wasm.js"),O=b("vega","5.22.1","build/vega.min.js"),L=b("vega-lite","5.2.0","build/vega-lite.min.js"),P=b("vega-lite-api","5.0.0","build/vega-lite-api.min.js"),R=b("apache-arrow","4.0.1","Arrow.es2015.min.js"),$=b("arquero","4.8.8","dist/arquero.min.js"),M=b("topojson-client","3.1.0","dist/topojson-client.min.js"),k=b("exceljs","4.3.0","dist/exceljs.min.js"),q=b("mermaid","9.1.1","dist/mermaid.min.js"),U=b("leaflet","1.8.0","dist/leaflet.js"),S=new Map,_=[],D=_.map,I=_.some,F=_.hasOwnProperty,B=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,z=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,H=/(?:\.[^/]*|\/)$/;class RequireError extends Error{constructor(e){super(e)}}function W(e){const t=B.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function V(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=S.get(n);return r||S.set(n,r=fetch(n).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!S.has(e.url)&&S.set(e.url,r),e.json()}))),r}return async function(r,o){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==o?location:o).href;if(!r.length||/^[\s._]/.test(r)||/\s$/.test(r))throw new RequireError("illegal name");const a=W(r);if(!a)return`${e}${r}`;if(!a.version&&null!=o&&o.startsWith(e)){const t=await n(W(o.substring(e.length)));a.version=t.dependencies&&t.dependencies[a.name]||t.peerDependencies&&t.peerDependencies[a.name]}if(a.path&&!H.test(a.path)&&(a.path+=".js"),a.path&&a.version&&z.test(a.version))return`${e}${a.name}@${a.version}/${a.path}`;const i=await n(a);return`${e}${i.name}@${i.version}/${a.path||function(e){for(const n of t){let t=e[n];if("string"==typeof t)return t.startsWith("./")&&(t=t.slice(2)),H.test(t)?t:`${t}.js`}}(i)||"index.js"}`}}RequireError.prototype.name=RequireError.name;var Z=G(V());function G(e){const t=new Map,n=o(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(_.pop()(o(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=J,document.head.appendChild(r)}))),n}function o(t){return n=>Promise.resolve(e(n,t)).then(r)}function a(e){return arguments.length>1?Promise.all(D.call(arguments,n)).then(Y):n(e)}return a.alias=function(t){return G(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},a.resolve=e,a}function Y(e){const t={};for(const n of e)for(const e in n)F.call(n,e)&&(null==n[e]?Object.defineProperty(t,e,{get:Q(n,e)}):t[e]=n[e]);return t}function Q(e,t){return()=>e[t]}function X(e){return"exports"===(e+="")||"module"===e}function J(e,t,n){const r=arguments.length;r<2?(n=e,t=[]):r<3&&(n=t,t="string"==typeof e?[]:e),_.push(I.call(t,X)?e=>{const r={},o={exports:r};return Promise.all(D.call(t,(t=>"exports"===(t+="")?r:"module"===t?o:e(t)))).then((e=>(n.apply(null,e),o.exports)))}:e=>Promise.all(D.call(t,e)).then((e=>"function"==typeof n?n.apply(null,e):n)))}J.amd={};let K=Z;async function ee(e){const[t,n]=await Promise.all([e(T.resolve()),e.resolve(T.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([ee(K),Promise.resolve(e).then(ne)]);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:o,values:a}=r,i=a.map((e=>Object.fromEntries(e.map(((e,t)=>[o[t],e])))));return i.columns=o,i}(this._db,e,t)}async queryRow(e,t){return(await this.query(e,t))[0]||null}async explain(e,t){return re("pre",{className:"observablehq--inspect"},[oe((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_%'`,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:te(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 re("table",{value:t},[re("thead",[re("tr",n.map((e=>re("th",[oe(e)]))))]),re("tbody",t.map((e=>re("tr",n.map((t=>re("td",[oe(e[t])])))))))])}async sql(){return this.query(...this.queryTag.apply(this,arguments))}queryTag(e,...t){return[e.join("?"),t]}}function te(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 ne(e){return"string"==typeof e?fetch(e).then(ne):e instanceof Response||e instanceof Blob?e.arrayBuffer().then(ne):e instanceof ArrayBuffer?new Uint8Array(e):e}function re(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 oe(e){return document.createTextNode(e)}Object.defineProperty(SQLiteDatabaseClient.prototype,"dialect",{value:"sqlite"});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,o],[a,i]]=function(e=":",{columnCount:t,rowCount:n}){if(!(e+="").match(/^[A-Z]*\d*:[A-Z]*\d*$/))throw new Error("Malformed range specifier");const[[r=0,o=0],[a=t-1,i=n-1]]=e.split(":").map(ce);return[[r,o],[a,i]]}(t,e);const s=n?e._rows[o++]:null;let c=new Set(["#"]);for(let e=r;e<=a;e++){const t=s?ae(s.findCell(e+1)):null;let n=t&&t+""||se(e);for(;c.has(n);)n+="_";c.add(n)}c=new Array(r).concat(Array.from(c));const l=new Array(i-o+1);for(let t=o;t<=i;t++){const n=l[t-o]=Object.create(null,{"#":{value:t+1}}),i=e.getRow(t+1);if(i.hasValues)for(let e=r;e<=a;e++){const t=ae(i.findCell(e+1));null!=t&&(n[c[e+1]]=t)}}return l.columns=c.filter((()=>!0)),l}(this._.getWorksheet(n),t)}}function ae(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 ie(t);if(t.text){let{text:e}=t;return e.richText&&(e=ie(e)),t.hyperlink&&t.hyperlink!==e?`${t.hyperlink} ${e}`:e}return t}return t}function ie(e){return e.richText.map((e=>e.text)).join("")}function se(e){let t="";e++;do{t=String.fromCharCode(64+(e%26||26))+t}while(e=Math.floor((e-1)/26));return t}function ce(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 le(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function ue(e,t,{array:n=!1,typed:r=!1}={}){const o=await e.text();return("\t"===t?n?h:d:n?u:l)(o,r&&m)}class fe{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 le(this)).blob()}async arrayBuffer(){return(await le(this)).arrayBuffer()}async text(){return(await le(this)).text()}async json(){return(await le(this)).json()}async stream(){return(await le(this)).body}async csv(e){return ue(this,",",e)}async tsv(e){return ue(this,"\t",e)}async image(e){const t=await this.url();return new Promise(((n,r)=>{const o=new Image;new URL(t,document.baseURI).origin!==new URL(location).origin&&(o.crossOrigin="anonymous"),Object.assign(o,e),o.onload=()=>n(o),o.onerror=()=>r(new Error(`Unable to load file: ${this.name}`)),o.src=t}))}async arrow(){const[e,t]=await Promise.all([K(R.resolve()),le(this)]);return e.Table.from(t)}async sqlite(){return SQLiteDatabaseClient.open(le(this))}async zip(){const[e,t]=await Promise.all([K(A.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([K(k.resolve()),this.arrayBuffer()]);return new Workbook(await(new e.Workbook).xlsx.load(t))}}class FileAttachment extends fe{constructor(e,t,n){super(t,n),Object.defineProperty(this,"_url",{value:e})}async url(){return await this._url+""}}function de(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 fe{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 he={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 me=0;function pe(e){return new be("O-"+(null==e?"":e+"-")+ ++me)}function be(e){this.id=e,this.href=new URL(`#${e}`,location)+""}be.prototype.toString=function(){return"url("+this.href+")"};var ve={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 o=r.getContext("2d");return o.scale(n,n),o},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),o=r.appendChild(document.createElement("button"));async function a(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),o.textContent=n,o.disabled=!1}return o.textContent=n,r.download=t,r.onclick=async t=>{if(o.disabled=!0,r.href)return a();o.textContent="Saving…";try{const t=await("function"==typeof e?e():e);o.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){o.textContent=n}if(t.eventPhase)return a();o.disabled=!1},r},element:function(e,t){var n,r=e+="",o=r.indexOf(":");o>=0&&"xmlns"!==(r=e.slice(0,o))&&(e=e.slice(o+1));var a=he.hasOwnProperty(r)?document.createElementNS(he[r],e):document.createElement(e);if(t)for(var i in t)o=(r=i).indexOf(":"),n=t[i],o>=0&&"xmlns"!==(r=i.slice(0,o))&&(i=i.slice(o+1)),he.hasOwnProperty(r)?a.setAttributeNS(he[r],i,n):a.setAttribute(i,n);return a},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:pe};var we={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 ye(){return this}function ge(e,t){let n=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:ye,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function xe(e){let t,n,r=!1;const o=e((function(e){n?(n(e),n=null):r=!0;return t=e}));if(null!=o&&"function"!=typeof o)throw new Error("function"==typeof o.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:ye,throw:()=>({done:!0}),return:()=>(null!=o&&o(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise((e=>n=e))}}}}function je(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 Ee={disposable:ge,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return xe((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=je(e);function o(){t(je(e))}return e.addEventListener(n,o),void 0!==r&&t(r),function(){e.removeEventListener(n,o)}}))},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:xe,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]:ye,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=(o=arguments.length)<2?(t=e,e=0,1):o<3?1:+n;for(var r=-1,o=0|Math.max(0,Math.ceil((t-e)/n));++r<o;)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 ge(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}};function Ne(e,t){return function(n){var r,o,a,i,s,c,l,u,f=n[0],d=[],h=null,m=-1;for(s=1,c=arguments.length;s<c;++s){if((r=arguments[s])instanceof Node)d[++m]=r,f+="\x3c!--o:"+m+"--\x3e";else if(Array.isArray(r)){for(l=0,u=r.length;l<u;++l)(o=r[l])instanceof Node?(null===h&&(d[++m]=h=document.createDocumentFragment(),f+="\x3c!--o:"+m+"--\x3e"),h.appendChild(o)):(h=null,f+=o);h=null}else f+=r;f+=n[s]}if(h=e(f),++m>0){for(a=new Array(m),i=document.createTreeWalker(h,NodeFilter.SHOW_COMMENT,null,!1);i.nextNode();)o=i.currentNode,/^o:/.test(o.nodeValue)&&(a[+o.nodeValue.slice(2)]=o);for(s=0;s<m;++s)(o=a[s])&&o.parentNode.replaceChild(d[s],o)}return 1===h.childNodes.length?h.removeChild(h.firstChild):11===h.nodeType?((o=t()).appendChild(h),o):h}}var Ae=Ne((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));function Ce(e){let t;Object.defineProperties(this,{generator:{value:xe((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*Te(){for(;;)yield Date.now()}var Oe=new Map;function Le(e,t){var n;return(n=Oe.get(e=+e))?n.then((()=>t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise((function(n){Oe.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 Oe.set(t,n),n}(n,e).then((()=>t))}var Pe={delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return Le(Math.ceil((Date.now()+1)/e)*e,t)},when:Le};function Re(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}var $e=Ne((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")})),Me=String.raw;function ke(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 qe(){return xe((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)}}))}var Ue=Object.assign(Object.defineProperties((function(e){const t=function(e){return null==e?K:G(e)}(e);var n;Object.defineProperties(this,(n={FileAttachment:()=>de,Mutable:()=>Ce,now:Te,width:qe,dot:()=>t(g.resolve()),htl:()=>t(N.resolve()),html:()=>Ae,md:()=>function(e){return e(C.resolve()).then((function(t){return Ne((function(n){var r=document.createElement("div");r.innerHTML=t(n,{langPrefix:""}).trim();var o=r.querySelectorAll("pre code[class]");return o.length>0&&e(x.resolve()).then((function(t){o.forEach((function(n){function r(){t.highlightBlock(n),n.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(n.className)?r():e(x.resolve("async-languages/index.js")).then((r=>{if(r.has(n.className))return e(x.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:()=>$e,tex:()=>function(e){return Promise.all([e(j.resolve()),e.resolve(j.resolve("dist/katex.min.css")).then(ke)]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(Me.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}))}(t),_:()=>t(E.resolve()),aq:()=>t.alias({"apache-arrow":R.resolve()})($.resolve()),Arrow:()=>t(R.resolve()),d3:()=>t(v.resolve()),Inputs:()=>t(w.resolve()).then((e=>({...e,file:e.fileOf(fe)}))),L:()=>async function(e){const t=await e(U.resolve());if(!t._style){const n=document.createElement("link");n.rel="stylesheet",n.href=await e.resolve(U.resolve("dist/leaflet.css")),t._style=document.head.appendChild(n)}return t}(t),mermaid:()=>async function(e){const t=await e(q.resolve());return t.initialize({securityLevel:"loose",theme:"neutral"}),function(){const e=document.createElement("div");return e.innerHTML=t.render(pe().id,String.raw.apply(String,arguments)),e.removeChild(e.firstChild)}}(t),Plot:()=>t(y.resolve()),require:()=>t,resolve:()=>Re,SQLite:()=>ee(t),SQLiteDatabaseClient:()=>SQLiteDatabaseClient,topojson:()=>t(M.resolve()),vl:()=>async function(e){const[t,n,r]=await Promise.all([O,L,P].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:ve,Files:we,Generators:Ee,Promises:Pe},Object.fromEntries(Object.entries(n).map(Se))))}),{resolve:{get:()=>K.resolve,enumerable:!0,configurable:!0},require:{get:()=>K,set:function(e){K=e},enumerable:!0,configurable:!0}}),{resolveFrom:V,requireFrom:G});function Se([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}e.AbstractFile=fe,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=Ue,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
// @observablehq/stdlib v3.19.7 Copyright 2022 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 o(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 a(e,t){var n=e+"",r=n.length;return r<t?new Array(t-r+1).join(0)+n:n}function i(e){var t,n=e.getUTCHours(),r=e.getUTCMinutes(),o=e.getUTCSeconds(),i=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":((t=e.getUTCFullYear())<0?"-"+a(-t,6):t>9999?"+"+a(t,6):a(t,4))+"-"+a(e.getUTCMonth()+1,2)+"-"+a(e.getUTCDate(),2)+(i?"T"+a(n,2)+":"+a(r,2)+":"+a(o,2)+"."+a(i,3)+"Z":o?"T"+a(n,2)+":"+a(r,2)+":"+a(o,2)+"Z":r||n?"T"+a(n,2)+":"+a(r,2)+"Z":"")}function s(e){var a=new RegExp('["'+e+"\n\r]"),s=e.charCodeAt(0);function c(e,r){var o,a=[],i=e.length,c=0,l=0,u=i<=0,f=!1;function d(){if(u)return n;if(f)return f=!1,t;var r,o,a=c;if(34===e.charCodeAt(a)){for(;c++<i&&34!==e.charCodeAt(c)||34===e.charCodeAt(++c););return(r=c)>=i?u=!0:10===(o=e.charCodeAt(c++))?f=!0:13===o&&(f=!0,10===e.charCodeAt(c)&&++c),e.slice(a+1,r-1).replace(/""/g,'"')}for(;c<i;){if(10===(o=e.charCodeAt(r=c++)))f=!0;else if(13===o)f=!0,10===e.charCodeAt(c)&&++c;else if(o!==s)continue;return e.slice(a,r)}return u=!0,e.slice(a,i)}for(10===e.charCodeAt(i-1)&&--i,13===e.charCodeAt(i-1)&&--i;(o=d())!==n;){for(var h=[];o!==t&&o!==n;)h.push(o),o=d();r&&null==(h=r(h,l++))||a.push(h)}return a}function l(t,n){return t.map((function(t){return n.map((function(e){return f(t[e])})).join(e)}))}function u(t){return t.map(f).join(e)}function f(e){return null==e?"":e instanceof Date?i(e):a.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,o,a=c(e,(function(e,a){if(n)return n(e,a-1);o=e,n=t?function(e,t){var n=r(e);return function(r,o){return t(n(r),o,e)}}(e,t):r(e)}));return a.columns=o||[],a},parseRows:c,format:function(t,n){return null==n&&(n=o(t)),[n.map(f).join(e)].concat(l(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=o(e)),l(e,t).join("\n")},formatRows:function(e){return e.map(u).join("\n")},formatRow:u,formatValue:f}}var c=s(","),l=c.parse,u=c.parseRows,f=s("\t"),d=f.parse,h=f.parseRows;function m(e){for(var t in e){var n,r,o=e[t].trim();if(o)if("true"===o)o=!0;else if("false"===o)o=!1;else if("NaN"===o)o=NaN;else if(isNaN(n=+o)){if(!(r=o.match(/^([-+]\d{2})?\d{4}(-\d{2}(-\d{2})?)?(T\d{2}:\d{2}(:\d{2}(\.\d{3})?)?(Z|[-+]\d{2}:\d{2})?)?$/)))continue;p&&r[4]&&!r[7]&&(o=o.replace(/-/g,"/").replace(/T/," ")),o=new Date(o)}else o=n;else o=null;e[t]=o}return e}const p=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.6.1","dist/d3.min.js"),v=b("@observablehq/inputs","0.10.4","dist/inputs.min.js"),y=b("@observablehq/plot","0.5.2","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"),x=b("@observablehq/katex","0.11.1","dist/katex.min.js"),j=b("lodash","4.17.21","lodash.min.js"),N=b("htl","0.3.1","dist/htl.min.js"),T=b("jszip","3.10.0","dist/jszip.min.js"),A=b("marked","0.3.12","marked.min.js"),C=b("sql.js","1.7.0","dist/sql-wasm.js"),L=b("vega","5.22.1","build/vega.min.js"),O=b("vega-lite","5.2.0","build/vega-lite.min.js"),R=b("vega-lite-api","5.0.0","build/vega-lite-api.min.js"),P=b("apache-arrow","4.0.1","Arrow.es2015.min.js"),q=b("arquero","4.8.8","dist/arquero.min.js"),$=b("topojson-client","3.1.0","dist/topojson-client.min.js"),k=b("exceljs","4.3.0","dist/exceljs.min.js"),I=b("mermaid","9.1.1","dist/mermaid.min.js"),S=b("leaflet","1.8.0","dist/leaflet.js"),M=new Map,U=[],_=U.map,D=U.some,F=U.hasOwnProperty,B=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,H=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,W=/(?:\.[^/]*|\/)$/;class RequireError extends Error{constructor(e){super(e)}}function z(e){const t=B.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function V(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=M.get(n);return r||M.set(n,r=fetch(n).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!M.has(e.url)&&M.set(e.url,r),e.json()}))),r}return async function(r,o){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==o?location:o).href;if(!r.length||/^[\s._]/.test(r)||/\s$/.test(r))throw new RequireError("illegal name");const a=z(r);if(!a)return`${e}${r}`;if(!a.version&&null!=o&&o.startsWith(e)){const t=await n(z(o.substring(e.length)));a.version=t.dependencies&&t.dependencies[a.name]||t.peerDependencies&&t.peerDependencies[a.name]}if(a.path&&!W.test(a.path)&&(a.path+=".js"),a.path&&a.version&&H.test(a.version))return`${e}${a.name}@${a.version}/${a.path}`;const i=await n(a);return`${e}${i.name}@${i.version}/${a.path||function(e){for(const n of t){let t=e[n];if("string"==typeof t)return t.startsWith("./")&&(t=t.slice(2)),W.test(t)?t:`${t}.js`}}(i)||"index.js"}`}}RequireError.prototype.name=RequireError.name;var Z=G(V());function G(e){const t=new Map,n=o(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(U.pop()(o(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=X,document.head.appendChild(r)}))),n}function o(t){return n=>Promise.resolve(e(n,t)).then(r)}function a(e){return arguments.length>1?Promise.all(_.call(arguments,n)).then(Y):n(e)}return a.alias=function(t){return G(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},a.resolve=e,a}function Y(e){const t={};for(const n of e)for(const e in n)F.call(n,e)&&(null==n[e]?Object.defineProperty(t,e,{get:Q(n,e)}):t[e]=n[e]);return t}function Q(e,t){return()=>e[t]}function K(e){return"exports"===(e+="")||"module"===e}function X(e,t,n){const r=arguments.length;r<2?(n=e,t=[]):r<3&&(n=t,t="string"==typeof e?[]:e),U.push(D.call(t,K)?e=>{const r={},o={exports:r};return Promise.all(_.call(t,(t=>"exports"===(t+="")?r:"module"===t?o:e(t)))).then((e=>(n.apply(null,e),o.exports)))}:e=>Promise.all(_.call(t,e)).then((e=>"function"==typeof n?n.apply(null,e):n)))}X.amd={};let J=Z;async function ee(e){const[t,n]=await Promise.all([e(C.resolve()),e.resolve(C.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([ee(J),Promise.resolve(e).then(ne)]);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:o,values:a}=r,i=a.map((e=>Object.fromEntries(e.map(((e,t)=>[o[t],e])))));return i.columns=o,i}(this._db,e,t)}async queryRow(e,t){return(await this.query(e,t))[0]||null}async explain(e,t){return re("pre",{className:"observablehq--inspect"},[oe((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_%'`,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:te(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 re("table",{value:t},[re("thead",[re("tr",n.map((e=>re("th",[oe(e)]))))]),re("tbody",t.map((e=>re("tr",n.map((t=>re("td",[oe(e[t])])))))))])}async sql(){return this.query(...this.queryTag.apply(this,arguments))}queryTag(e,...t){return[e.join("?"),t]}}function te(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 ne(e){return"string"==typeof e?fetch(e).then(ne):e instanceof Response||e instanceof Blob?e.arrayBuffer().then(ne):e instanceof ArrayBuffer?new Uint8Array(e):e}function re(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 oe(e){return document.createTextNode(e)}Object.defineProperty(SQLiteDatabaseClient.prototype,"dialect",{value:"sqlite"});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,o],[a,i]]=function(e=":",{columnCount:t,rowCount:n}){if(!(e+="").match(/^[A-Z]*\d*:[A-Z]*\d*$/))throw new Error("Malformed range specifier");const[[r=0,o=0],[a=t-1,i=n-1]]=e.split(":").map(ce);return[[r,o],[a,i]]}(t,e);const s=n?e._rows[o++]:null;let c=new Set(["#"]);for(let e=r;e<=a;e++){const t=s?ae(s.findCell(e+1)):null;let n=t&&t+""||se(e);for(;c.has(n);)n+="_";c.add(n)}c=new Array(r).concat(Array.from(c));const l=new Array(i-o+1);for(let t=o;t<=i;t++){const n=l[t-o]=Object.create(null,{"#":{value:t+1}}),i=e.getRow(t+1);if(i.hasValues)for(let e=r;e<=a;e++){const t=ae(i.findCell(e+1));null!=t&&(n[c[e+1]]=t)}}return l.columns=c.filter((()=>!0)),l}(this._.getWorksheet(n),t)}}function ae(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 ie(t);if(t.text){let{text:e}=t;return e.richText&&(e=ie(e)),t.hyperlink&&t.hyperlink!==e?`${t.hyperlink} ${e}`:e}return t}return t}function ie(e){return e.richText.map((e=>e.text)).join("")}function se(e){let t="";e++;do{t=String.fromCharCode(64+(e%26||26))+t}while(e=Math.floor((e-1)/26));return t}function ce(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 le(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function ue(e,t,{array:n=!1,typed:r=!1}={}){const o=await e.text();return("\t"===t?n?h:d:n?u:l)(o,r&&m)}class fe{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 le(this)).blob()}async arrayBuffer(){return(await le(this)).arrayBuffer()}async text(){return(await le(this)).text()}async json(){return(await le(this)).json()}async stream(){return(await le(this)).body}async csv(e){return ue(this,",",e)}async tsv(e){return ue(this,"\t",e)}async image(e){const t=await this.url();return new Promise(((n,r)=>{const o=new Image;new URL(t,document.baseURI).origin!==new URL(location).origin&&(o.crossOrigin="anonymous"),Object.assign(o,e),o.onload=()=>n(o),o.onerror=()=>r(new Error(`Unable to load file: ${this.name}`)),o.src=t}))}async arrow(){const[e,t]=await Promise.all([J(P.resolve()),le(this)]);return e.Table.from(t)}async sqlite(){return SQLiteDatabaseClient.open(le(this))}async zip(){const[e,t]=await Promise.all([J(T.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([J(k.resolve()),this.arrayBuffer()]);return new Workbook(await(new e.Workbook).xlsx.load(t))}}class FileAttachment extends fe{constructor(e,t,n){super(t,n),Object.defineProperty(this,"_url",{value:e})}async url(){return await this._url+""}}function de(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 fe{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 he={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 me=0;function pe(e){return new be("O-"+(null==e?"":e+"-")+ ++me)}function be(e){this.id=e,this.href=new URL(`#${e}`,location)+""}be.prototype.toString=function(){return"url("+this.href+")"};var we={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 o=r.getContext("2d");return o.scale(n,n),o},download:function(e,t="untitled",n="Save"){const r=document.createElement("a"),o=r.appendChild(document.createElement("button"));async function a(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(r.href),r.removeAttribute("href"),o.textContent=n,o.disabled=!1}return o.textContent=n,r.download=t,r.onclick=async t=>{if(o.disabled=!0,r.href)return a();o.textContent="Saving…";try{const t=await("function"==typeof e?e():e);o.textContent="Download",r.href=URL.createObjectURL(t)}catch(e){o.textContent=n}if(t.eventPhase)return a();o.disabled=!1},r},element:function(e,t){var n,r=e+="",o=r.indexOf(":");o>=0&&"xmlns"!==(r=e.slice(0,o))&&(e=e.slice(o+1));var a=he.hasOwnProperty(r)?document.createElementNS(he[r],e):document.createElement(e);if(t)for(var i in t)o=(r=i).indexOf(":"),n=t[i],o>=0&&"xmlns"!==(r=i.slice(0,o))&&(i=i.slice(o+1)),he.hasOwnProperty(r)?a.setAttributeNS(he[r],i,n):a.setAttribute(i,n);return a},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:pe};var ve={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 ye(){return this}function ge(e,t){let n=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:ye,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function Ee(e){let t,n,r=!1;const o=e((function(e){n?(n(e),n=null):r=!0;return t=e}));if(null!=o&&"function"!=typeof o)throw new Error("function"==typeof o.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:ye,throw:()=>({done:!0}),return:()=>(null!=o&&o(),{done:!0}),next:function(){return{done:!1,value:r?(r=!1,Promise.resolve(t)):new Promise((e=>n=e))}}}}function xe(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 je={disposable:ge,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return Ee((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=xe(e);function o(){t(xe(e))}return e.addEventListener(n,o),void 0!==r&&t(r),function(){e.removeEventListener(n,o)}}))},map:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)yield t(n.value,++r)},observe:Ee,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]:ye,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=(o=arguments.length)<2?(t=e,e=0,1):o<3?1:+n;for(var r=-1,o=0|Math.max(0,Math.ceil((t-e)/n));++r<o;)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 ge(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}};function Ne(e,t){return function(n){var r,o,a,i,s,c,l,u,f=n[0],d=[],h=null,m=-1;for(s=1,c=arguments.length;s<c;++s){if((r=arguments[s])instanceof Node)d[++m]=r,f+="\x3c!--o:"+m+"--\x3e";else if(Array.isArray(r)){for(l=0,u=r.length;l<u;++l)(o=r[l])instanceof Node?(null===h&&(d[++m]=h=document.createDocumentFragment(),f+="\x3c!--o:"+m+"--\x3e"),h.appendChild(o)):(h=null,f+=o);h=null}else f+=r;f+=n[s]}if(h=e(f),++m>0){for(a=new Array(m),i=document.createTreeWalker(h,NodeFilter.SHOW_COMMENT,null,!1);i.nextNode();)o=i.currentNode,/^o:/.test(o.nodeValue)&&(a[+o.nodeValue.slice(2)]=o);for(s=0;s<m;++s)(o=a[s])&&o.parentNode.replaceChild(d[s],o)}return 1===h.childNodes.length?h.removeChild(h.firstChild):11===h.nodeType?((o=t()).appendChild(h),o):h}}var Te=Ne((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));function Ae(e){let t;Object.defineProperties(this,{generator:{value:Ee((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*Ce(){for(;;)yield Date.now()}var Le=new Map;function Oe(e,t){var n;return(n=Le.get(e=+e))?n.then((()=>t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise((function(n){Le.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 Le.set(t,n),n}(n,e).then((()=>t))}var Re={delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return Oe(Math.ceil((Date.now()+1)/e)*e,t)},when:Oe};function Pe(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}var qe=Ne((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")})),$e=String.raw;function ke(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 Ie(){return Ee((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 Se=Object.assign((async(e,t,n)=>{const r=Ue(t,await e);return r?Me(await e,r,n):null}),{sql:(e,t)=>async function(){return Me(e,arguments,t)}});async function Me(e,t,n){if(e){if("function"==typeof e.queryTag){const r=new AbortController,o={signal:r.signal};if(n.then((()=>r.abort("invalidated"))),"function"==typeof e.queryStream)return async function*(e){const t=await e,n=[];n.done=!1,n.error=null,n.schema=t.schema;try{const e=t.readRows();do{const t=await e.next();if(t.done)n.done=!0;else for(const e of t.value)n.push(e);yield n}while(!n.done)}catch(e){n.error=e,yield n}}(e.queryStream(...e.queryTag.apply(e,t),o));if("function"==typeof e.query)return e.query(...e.queryTag.apply(e,t),o)}if("function"==typeof e.sql)return e.sql.apply(e,t);throw new Error("source does not implement query, queryStream, or sql")}}function Ue(e,t){const n=t&&"function"==typeof t.escape?t.escape:e=>e,{select:r,from:o,filter:a,sort:i,slice:s}=e;if(null===o.table||null===r.columns||0===r.columns?.length)return;const c=[[`SELECT ${r.columns.map((e=>`t.${n(e)}`))} FROM ${_e(o.table,n)} t`]];for(let e=0;e<a.length;++e)De(e?"\nAND ":"\nWHERE ",c),Be(a[e],c);for(let e=0;e<i.length;++e)De(e?", ":"\nORDER BY ",c),Fe(i[e],c);return null===s.to&&null===s.from||De("\nLIMIT "+(null!==s.to?s.to-(s.from??0):1e9),c),null!==s.from&&De(` OFFSET ${s.from}`,c),c}function _e(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 e}function De(e,t){const n=t[0];n[n.length-1]+=e}function Fe({column:e,direction:t},n){De(`t.${e} ${t.toUpperCase()}`,n)}function Be({type:e,operands:t},n){if(t.length<1)throw new Error("Invalid operand length");if(1===t.length)switch(He(t[0],n),e){case"n":return void De(" IS NULL",n);case"nn":return void De(" IS NOT NULL",n);default:throw new Error("Invalid filter operation")}if(2!==t.length||["in","nin"].includes(e)){var r;switch(He(t[0],n),e){case"in":De(" IN (",n);break;case"nin":De(" 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:De(",",t),t.push(r.value),t[0].push("")}(t.slice(1),n),De(")",n)}else{if(["c","nc"].includes(e)){switch(He(t[0],n),e){case"c":De(" LIKE ",n);break;case"nc":De(" NOT LIKE ",n)}return void He((r=t[1],{...r,value:`%${r.value}%`}),n)}switch(He(t[0],n),e){case"eq":De(" = ",n);break;case"ne":De(" <> ",n);break;case"gt":De(" > ",n);break;case"lt":De(" < ",n);break;case"gte":De(" >= ",n);break;case"lte":De(" <= ",n);break;default:throw new Error("Invalid filter operation")}He(t[1],n)}}function He(e,t){"column"===e.type?De(`t.${e.value}`,t):(t.push(e.value),t[0].push(""))}var We=Object.assign(Object.defineProperties((function(e){const t=function(e){return null==e?J:G(e)}(e);var n;Object.defineProperties(this,(n={FileAttachment:()=>de,Mutable:()=>Ae,now:Ce,width:Ie,dot:()=>t(g.resolve()),htl:()=>t(N.resolve()),html:()=>Te,md:()=>function(e){return e(A.resolve()).then((function(t){return Ne((function(n){var r=document.createElement("div");r.innerHTML=t(n,{langPrefix:""}).trim();var o=r.querySelectorAll("pre code[class]");return o.length>0&&e(E.resolve()).then((function(t){o.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:()=>qe,tex:()=>function(e){return Promise.all([e(x.resolve()),e.resolve(x.resolve("dist/katex.min.css")).then(ke)]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render($e.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}))}(t),_:()=>t(j.resolve()),aq:()=>t.alias({"apache-arrow":P.resolve()})(q.resolve()),Arrow:()=>t(P.resolve()),d3:()=>t(w.resolve()),Inputs:()=>t(v.resolve()).then((e=>({...e,file:e.fileOf(fe)}))),L:()=>async function(e){const t=await e(S.resolve());if(!t._style){const n=document.createElement("link");n.rel="stylesheet",n.href=await e.resolve(S.resolve("dist/leaflet.css")),t._style=document.head.appendChild(n)}return t}(t),mermaid:()=>async function(e){const t=await e(I.resolve());return t.initialize({securityLevel:"loose",theme:"neutral"}),function(){const e=document.createElement("div");return e.innerHTML=t.render(pe().id,String.raw.apply(String,arguments)),e.removeChild(e.firstChild)}}(t),Plot:()=>t(y.resolve()),__query:()=>Se,require:()=>t,resolve:()=>Pe,SQLite:()=>ee(t),SQLiteDatabaseClient:()=>SQLiteDatabaseClient,topojson:()=>t($.resolve()),vl:()=>async function(e){const[t,n,r]=await Promise.all([L,O,R].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:we,Files:ve,Generators:je,Promises:Re},Object.fromEntries(Object.entries(n).map(ze))))}),{resolve:{get:()=>J.resolve,enumerable:!0,configurable:!0},require:{get:()=>J,set:function(e){J=e},enumerable:!0,configurable:!0}}),{resolveFrom:V,requireFrom:G});function ze([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}e.AbstractFile=fe,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=We,e.makeQueryTemplate=Ue,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@observablehq/stdlib", | ||
"version": "3.19.6", | ||
"version": "3.19.7", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "main": "dist/stdlib.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
122267
55
1388
5