generated from barionleg/ci_temp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker-d1e48427.js
2 lines (2 loc) · 124 KB
/
worker-d1e48427.js
1
2
/* Copyright 2024 Observable, Inc. */
function e(e,t,n){n=n||{};var r=e.ownerDocument,a=r.defaultView.CustomEvent;"function"==typeof a?a=new a(t,{detail:n}):((a=r.createEvent("Event")).initEvent(t,!1,!1),a.detail=n),e.dispatchEvent(a)}function t(e){return Array.isArray(e)||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}function n(e){return e===(0|e)+""}function r(e){const t=document.createElement("span");return t.className="observablehq--cellname",t.textContent=`${e} = `,t}const a=Symbol.prototype.toString;function o(e){return a.call(e)}const{getOwnPropertySymbols:i,prototype:{hasOwnProperty:s}}=Object,{toStringTag:c}=Symbol,l={},u=i;function f(e,t){return s.call(e,t)}function d(e){return e[c]||e.constructor&&e.constructor.name||"Object"}function m(e,t){try{const n=e[t];return n&&n.constructor,n}catch(e){return l}}const h=[{symbol:"@@__IMMUTABLE_INDEXED__@@",name:"Indexed",modifier:!0},{symbol:"@@__IMMUTABLE_KEYED__@@",name:"Keyed",modifier:!0},{symbol:"@@__IMMUTABLE_LIST__@@",name:"List",arrayish:!0},{symbol:"@@__IMMUTABLE_MAP__@@",name:"Map"},{symbol:"@@__IMMUTABLE_ORDERED__@@",name:"Ordered",modifier:!0,prefix:!0},{symbol:"@@__IMMUTABLE_RECORD__@@",name:"Record"},{symbol:"@@__IMMUTABLE_SET__@@",name:"Set",arrayish:!0,setish:!0},{symbol:"@@__IMMUTABLE_STACK__@@",name:"Stack",arrayish:!0}];function p(e){try{let t=h.filter((({symbol:t})=>!0===e[t]));if(!t.length)return;const n=t.find((e=>!e.modifier)),r="Map"===n.name&&t.find((e=>e.modifier&&e.prefix)),a=t.some((e=>e.arrayish)),o=t.some((e=>e.setish));return{name:`${r?r.name:""}${n.name}`,symbols:t,arrayish:a&&!o,setish:o}}catch(e){return null}}const{getPrototypeOf:b,getOwnPropertyDescriptors:y}=Object,w=b({});function v(n,a,o,i){let s,c,l,u,f=t(n);n instanceof Map?n instanceof n.constructor?(s=`Map(${n.size})`,c=g):(s="Map()",c=N):n instanceof Set?n instanceof n.constructor?(s=`Set(${n.size})`,c=_):(s="Set()",c=N):f?(s=`${n.constructor.name}(${n.length})`,c=T):(u=p(n))?(s=`Immutable.${u.name}${"Record"===u.name?"":`(${n.size})`}`,f=u.arrayish,c=u.arrayish?C:u.setish?E:S):i?(s=d(n),c=A):(s=d(n),c=N);const m=document.createElement("span");m.className="observablehq--expanded",o&&m.appendChild(r(o));const h=m.appendChild(document.createElement("a"));h.innerHTML="<svg width=8 height=8 class='observablehq--caret'>\n <path d='M4 7L0 1h8z' fill='currentColor' />\n </svg>",h.appendChild(document.createTextNode(`${s}${f?" [":" {"}`)),h.addEventListener("mouseup",(function(e){e.stopPropagation(),se(m,k(n,null,o,i))})),c=c(n);for(let e=0;!(l=c.next()).done&&e<20;++e)m.appendChild(l.value);if(!l.done){const t=m.appendChild(document.createElement("a"));t.className="observablehq--field",t.style.display="block",t.appendChild(document.createTextNode(" … more")),t.addEventListener("mouseup",(function(t){t.stopPropagation(),m.insertBefore(l.value,m.lastChild.previousSibling);for(let e=0;!(l=c.next()).done&&e<19;++e)m.insertBefore(l.value,m.lastChild.previousSibling);l.done&&m.removeChild(m.lastChild.previousSibling),e(m,"load")}))}return m.appendChild(document.createTextNode(f?"]":"}")),m}function*g(e){for(const[t,n]of e)yield O(t,n);yield*N(e)}function*_(e){for(const t of e)yield $(t);yield*N(e)}function*E(e){for(const t of e)yield $(t)}function*T(e){for(let t=0,n=e.length;t<n;++t)t in e&&(yield M(t,m(e,t),"observablehq--index"));for(const t in e)!n(t)&&f(e,t)&&(yield M(t,m(e,t),"observablehq--key"));for(const t of u(e))yield M(o(t),m(e,t),"observablehq--symbol")}function*C(e){let t=0;for(const n=e.size;t<n;++t)yield M(t,e.get(t),!0)}function*A(e){for(const t in y(e))yield M(t,m(e,t),"observablehq--key");for(const t of u(e))yield M(o(t),m(e,t),"observablehq--symbol");const t=b(e);t&&t!==w&&(yield x(t))}function*N(e){for(const t in e)f(e,t)&&(yield M(t,m(e,t),"observablehq--key"));for(const t of u(e))yield M(o(t),m(e,t),"observablehq--symbol");const t=b(e);t&&t!==w&&(yield x(t))}function*S(e){for(const[t,n]of e)yield M(t,n,"observablehq--key")}function x(e){const t=document.createElement("div"),n=t.appendChild(document.createElement("span"));return t.className="observablehq--field",n.className="observablehq--prototype-key",n.textContent=" <prototype>",t.appendChild(document.createTextNode(": ")),t.appendChild(ie(e,void 0,void 0,void 0,!0)),t}function M(e,t,n){const r=document.createElement("div"),a=r.appendChild(document.createElement("span"));return r.className="observablehq--field",a.className=n,a.textContent=` ${e}`,r.appendChild(document.createTextNode(": ")),r.appendChild(ie(t)),r}function O(e,t){const n=document.createElement("div");return n.className="observablehq--field",n.appendChild(document.createTextNode(" ")),n.appendChild(ie(e)),n.appendChild(document.createTextNode(" => ")),n.appendChild(ie(t)),n}function $(e){const t=document.createElement("div");return t.className="observablehq--field",t.appendChild(document.createTextNode(" ")),t.appendChild(ie(e)),t}function j(e){const t=window.getSelection();return"Range"===t.type&&(t.containsNode(e,!0)||e.contains(t.anchorNode)||e.contains(t.focusNode))}function k(e,n,a,o){let i,s,c,l,u=t(e);if(e instanceof Map?e instanceof e.constructor?(i=`Map(${e.size})`,s=q):(i="Map()",s=P):e instanceof Set?e instanceof e.constructor?(i=`Set(${e.size})`,s=L):(i="Set()",s=P):u?(i=`${e.constructor.name}(${e.length})`,s=U):(l=p(e))?(i=`Immutable.${l.name}${"Record"===l.name?"":`(${e.size})`}`,u=l.arrayish,s=l.arrayish?D:l.setish?R:I):(i=d(e),s=P),n){const t=document.createElement("span");return t.className="observablehq--shallow",a&&t.appendChild(r(a)),t.appendChild(document.createTextNode(i)),t.addEventListener("mouseup",(function(n){j(t)||(n.stopPropagation(),se(t,k(e)))})),t}const f=document.createElement("span");f.className="observablehq--collapsed",a&&f.appendChild(r(a));const m=f.appendChild(document.createElement("a"));m.innerHTML="<svg width=8 height=8 class='observablehq--caret'>\n <path d='M7 4L1 8V0z' fill='currentColor' />\n </svg>",m.appendChild(document.createTextNode(`${i}${u?" [":" {"}`)),f.addEventListener("mouseup",(function(t){j(f)||(t.stopPropagation(),se(f,v(e,0,a,o)))}),!0),s=s(e);for(let e=0;!(c=s.next()).done&&e<20;++e)e>0&&f.appendChild(document.createTextNode(", ")),f.appendChild(c.value);return c.done||f.appendChild(document.createTextNode(", …")),f.appendChild(document.createTextNode(u?"]":"}")),f}function*q(e){for(const[t,n]of e)yield z(t,n);yield*P(e)}function*L(e){for(const t of e)yield ie(t,!0);yield*P(e)}function*R(e){for(const t of e)yield ie(t,!0)}function*D(e){let t=-1,n=0;for(const r=e.size;n<r;++n)n>t+1&&(yield F(n-t-1)),yield ie(e.get(n),!0),t=n;n>t+1&&(yield F(n-t-1))}function*U(e){let t=-1,r=0;for(const n=e.length;r<n;++r)r in e&&(r>t+1&&(yield F(r-t-1)),yield ie(m(e,r),!0),t=r);r>t+1&&(yield F(r-t-1));for(const t in e)!n(t)&&f(e,t)&&(yield B(t,m(e,t),"observablehq--key"));for(const t of u(e))yield B(o(t),m(e,t),"observablehq--symbol")}function*P(e){for(const t in e)f(e,t)&&(yield B(t,m(e,t),"observablehq--key"));for(const t of u(e))yield B(o(t),m(e,t),"observablehq--symbol")}function*I(e){for(const[t,n]of e)yield B(t,n,"observablehq--key")}function F(e){const t=document.createElement("span");return t.className="observablehq--empty",t.textContent=1===e?"empty":`empty × ${e}`,t}function B(e,t,n){const r=document.createDocumentFragment(),a=r.appendChild(document.createElement("span"));return a.className=n,a.textContent=e,r.appendChild(document.createTextNode(": ")),r.appendChild(ie(t,!0)),r}function z(e,t){const n=document.createDocumentFragment();return n.appendChild(ie(e,!0)),n.appendChild(document.createTextNode(" => ")),n.appendChild(ie(t,!0)),n}function H(e,t){if(e instanceof Date||(e=new Date(+e)),isNaN(e))return"function"==typeof t?t(e):t;const n=e.getUTCHours(),r=e.getUTCMinutes(),a=e.getUTCSeconds(),o=e.getUTCMilliseconds();return`${function(e){return e<0?`-${Y(-e,6)}`:e>9999?`+${Y(e,6)}`:Y(e,4)}(e.getUTCFullYear())}-${Y(e.getUTCMonth()+1,2)}-${Y(e.getUTCDate(),2)}${n||r||a||o?`T${Y(n,2)}:${Y(r,2)}${a||o?`:${Y(a,2)}${o?`.${Y(o,3)}`:""}`:""}Z`:""}`}function Y(e,t){return`${e}`.padStart(t,"0")}var W=Error.prototype.toString;var V=RegExp.prototype.toString;const J=20;function G(e){return e.replace(/[\\`\x00-\x09\x0b-\x19]|\${/g,K)}function K(e){var t=e.charCodeAt(0);switch(t){case 8:return"\\b";case 9:return"\\t";case 11:return"\\v";case 12:return"\\f";case 13:return"\\r"}return t<16?"\\x0"+t.toString(16):t<32?"\\x"+t.toString(16):"\\"+e}function Z(e,t){for(var n=0;t.exec(e);)++n;return n}var X=Function.prototype.toString,Q={prefix:"async ƒ"},ee={prefix:"async ƒ*"},te={prefix:"class"},ne={prefix:"ƒ"},re={prefix:"ƒ*"};function ae(e,t,n){var a=document.createElement("span");a.className="observablehq--function",n&&a.appendChild(r(n));var o=a.appendChild(document.createElement("span"));return o.className="observablehq--keyword",o.textContent=e.prefix,a.appendChild(document.createTextNode(t)),a}const{prototype:{toString:oe}}=Object;function ie(e,t,n,a,i){let s=typeof e;switch(s){case"boolean":case"undefined":e+="";break;case"number":e=0===e&&1/e<0?"-0":e+"";break;case"bigint":e+="n";break;case"symbol":e=o(e);break;case"function":return function(e,t){var n,r,a=X.call(e);switch(e.constructor&&e.constructor.name){case"AsyncFunction":n=Q;break;case"AsyncGeneratorFunction":n=ee;break;case"GeneratorFunction":n=re;break;default:n=/^class\b/.test(a)?te:ne}return n===te?ae(n,"",t):(r=/^(?:async\s*)?(\w+)\s*=>/.exec(a))?ae(n,"("+r[1]+")",t):(r=/^(?:async\s*)?\(\s*(\w+(?:\s*,\s*\w+)*)?\s*\)/.exec(a))||(r=/^(?:async\s*)?function(?:\s*\*)?(?:\s*\w+)?\s*\(\s*(\w+(?:\s*,\s*\w+)*)?\s*\)/.exec(a))?ae(n,r[1]?"("+r[1].replace(/\s*,\s*/g,", ")+")":"()",t):ae(n,"(…)",t)}(e,a);case"string":return function(e,t,n,a){if(!1===t){if(Z(e,/["\n]/g)<=Z(e,/`|\${/g)){const t=document.createElement("span");a&&t.appendChild(r(a));const n=t.appendChild(document.createElement("span"));return n.className="observablehq--string",n.textContent=JSON.stringify(e),t}const o=e.split("\n");if(o.length>J&&!n){const n=document.createElement("div");a&&n.appendChild(r(a));const i=n.appendChild(document.createElement("span"));i.className="observablehq--string",i.textContent="`"+G(o.slice(0,J).join("\n"));const s=n.appendChild(document.createElement("span")),c=o.length-J;return s.textContent=`Show ${c} truncated line${c>1?"s":""}`,s.className="observablehq--string-expand",s.addEventListener("mouseup",(function(r){r.stopPropagation(),se(n,ie(e,t,!0,a))})),n}const i=document.createElement("span");a&&i.appendChild(r(a));const s=i.appendChild(document.createElement("span"));return s.className="observablehq--string"+(n?" observablehq--expanded":""),s.textContent="`"+G(e)+"`",i}const o=document.createElement("span");a&&o.appendChild(r(a));const i=o.appendChild(document.createElement("span"));return i.className="observablehq--string",i.textContent=JSON.stringify(e.length>100?`${e.slice(0,50)}…${e.slice(-49)}`:e),o}(e,t,n,a);default:if(null===e){s=null,e="null";break}if(e instanceof Date){s="date",e=function(e){return H(e,"Invalid Date")}(e);break}if(e===l){s="forbidden",e="[forbidden]";break}switch(oe.call(e)){case"[object RegExp]":s="regexp",e=function(e){return V.call(e)}(e);break;case"[object Error]":case"[object DOMException]":s="error",e=function(e){return e.stack||W.call(e)}(e);break;default:return(n?v:k)(e,t,a,i)}}const c=document.createElement("span");a&&c.appendChild(r(a));const u=c.appendChild(document.createElement("span"));return u.className=`observablehq--${s}`,u.textContent=e,c}function se(t,n){t.classList.contains("observablehq--inspect")&&n.classList.add("observablehq--inspect"),t.parentNode.replaceChild(n,t),e(n,"load")}const ce=/\s+\(\d+:\d+\)$/m;class le{constructor(e){if(!e)throw new Error("invalid node");this._node=e,e.classList.add("observablehq")}pending(){const{_node:e}=this;e.classList.remove("observablehq--error"),e.classList.add("observablehq--running")}fulfilled(t,n){const{_node:r}=this;if((!function(e){return(e instanceof Element||e instanceof Text)&&e instanceof e.constructor}(t)||t.parentNode&&t.parentNode!==r)&&(t=ie(t,!1,r.firstChild&&r.firstChild.classList&&r.firstChild.classList.contains("observablehq--expanded"),n)).classList.add("observablehq--inspect"),r.classList.remove("observablehq--running","observablehq--error"),r.firstChild!==t)if(r.firstChild){for(;r.lastChild!==r.firstChild;)r.removeChild(r.lastChild);r.replaceChild(t,r.firstChild)}else r.appendChild(t);e(r,"update")}rejected(t,n){const{_node:a}=this;for(a.classList.remove("observablehq--running"),a.classList.add("observablehq--error");a.lastChild;)a.removeChild(a.lastChild);var o=document.createElement("div");o.className="observablehq--inspect",n&&o.appendChild(r(n)),o.appendChild(document.createTextNode((t+"").replace(ce,""))),a.appendChild(o),e(a,"error",{error:t})}}le.into=function(e){if("string"==typeof e&&null==(e=document.querySelector(e)))throw new Error("container not found");return function(){return new le(e.appendChild(document.createElement("div")))}};var ue={},fe={};function de(e){return new Function("d","return {"+e.map((function(e,t){return JSON.stringify(e)+": d["+t+'] || ""'})).join(",")+"}")}function me(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 he(e,t){var n=e+"",r=n.length;return r<t?new Array(t-r+1).join(0)+n:n}function pe(e){var t=e.getUTCHours(),n=e.getUTCMinutes(),r=e.getUTCSeconds(),a=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":function(e){return e<0?"-"+he(-e,6):e>9999?"+"+he(e,6):he(e,4)}(e.getUTCFullYear())+"-"+he(e.getUTCMonth()+1,2)+"-"+he(e.getUTCDate(),2)+(a?"T"+he(t,2)+":"+he(n,2)+":"+he(r,2)+"."+he(a,3)+"Z":r?"T"+he(t,2)+":"+he(n,2)+":"+he(r,2)+"Z":n||t?"T"+he(t,2)+":"+he(n,2)+"Z":"")}function be(e){var t=new RegExp('["'+e+"\n\r]"),n=e.charCodeAt(0);function r(e,t){var r,a=[],o=e.length,i=0,s=0,c=o<=0,l=!1;function u(){if(c)return fe;if(l)return l=!1,ue;var t,r,a=i;if(34===e.charCodeAt(a)){for(;i++<o&&34!==e.charCodeAt(i)||34===e.charCodeAt(++i););return(t=i)>=o?c=!0:10===(r=e.charCodeAt(i++))?l=!0:13===r&&(l=!0,10===e.charCodeAt(i)&&++i),e.slice(a+1,t-1).replace(/""/g,'"')}for(;i<o;){if(10===(r=e.charCodeAt(t=i++)))l=!0;else if(13===r)l=!0,10===e.charCodeAt(i)&&++i;else if(r!==n)continue;return e.slice(a,t)}return c=!0,e.slice(a,o)}for(10===e.charCodeAt(o-1)&&--o,13===e.charCodeAt(o-1)&&--o;(r=u())!==fe;){for(var f=[];r!==ue&&r!==fe;)f.push(r),r=u();t&&null==(f=t(f,s++))||a.push(f)}return a}function a(t,n){return t.map((function(t){return n.map((function(e){return i(t[e])})).join(e)}))}function o(t){return t.map(i).join(e)}function i(e){return null==e?"":e instanceof Date?pe(e):t.test(e+="")?'"'+e.replace(/"/g,'""')+'"':e}return{parse:function(e,t){var n,a,o=r(e,(function(e,r){if(n)return n(e,r-1);a=e,n=t?function(e,t){var n=de(e);return function(r,a){return t(n(r),a,e)}}(e,t):de(e)}));return o.columns=a||[],o},parseRows:r,format:function(t,n){return null==n&&(n=me(t)),[n.map(i).join(e)].concat(a(t,n)).join("\n")},formatBody:function(e,t){return null==t&&(t=me(e)),a(e,t).join("\n")},formatRows:function(e){return e.map(o).join("\n")},formatRow:o,formatValue:i}}var ye=be(","),we=ye.parse,ve=ye.parseRows,ge=ye.format,_e=ye.formatRows,Ee=be("\t"),Te=Ee.parse,Ce=Ee.parseRows;function Ae(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;Ne&&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 Ne=new Date("2019-01-01T00:00").getHours()||new Date("2019-07-01T00:00").getHours();function Se(e,t,n){return{resolve:(r=n)=>`${e}@${t}/${r}`}}const xe=Se("d3","7.9.0","dist/d3.min.js"),Me=Se("@observablehq/inputs","0.11.0","dist/inputs.min.js"),Oe=Se("@observablehq/plot","0.6.16","dist/plot.umd.min.js"),$e=Se("@observablehq/graphviz","0.2.1","dist/graphviz.min.js"),je=Se("@observablehq/highlight.js","2.0.0","highlight.min.js"),ke=Se("@observablehq/katex","0.11.1","dist/katex.min.js"),qe=Se("lodash","4.17.21","lodash.min.js"),Le=Se("htl","0.3.1","dist/htl.min.js"),Re=Se("jszip","3.10.1","dist/jszip.min.js"),De=Se("marked","0.3.12","marked.min.js"),Ue=Se("sql.js","1.8.0","dist/sql-wasm.js"),Pe=Se("vega","5.22.1","build/vega.min.js"),Ie=Se("vega-lite","5.6.0","build/vega-lite.min.js"),Fe=Se("vega-lite-api","5.0.0","build/vega-lite-api.min.js"),Be=Se("apache-arrow","4.0.1","Arrow.es2015.min.js"),ze=Se("apache-arrow","9.0.0","+esm"),He=Se("apache-arrow","11.0.0","+esm"),Ye=Se("arquero","4.8.8","dist/arquero.min.js"),We=Se("topojson-client","3.1.0","dist/topojson-client.min.js"),Ve=Se("exceljs","4.3.0","dist/exceljs.min.js"),Je=Se("mermaid","9.2.2","dist/mermaid.min.js"),Ge=Se("leaflet","1.9.3","dist/leaflet.js"),Ke=Se("@duckdb/duckdb-wasm","1.24.0","+esm"),Ze=new Map,Xe=[],Qe=Xe.map,et=Xe.some,tt=Xe.hasOwnProperty,nt=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,rt=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,at=/(?:\.[^/]*|\/)$/;class RequireError extends Error{constructor(e){super(e)}}function ot(e){const t=nt.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function it(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=Ze.get(n);return r||Ze.set(n,r=fetch(n).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!Ze.has(e.url)&&Ze.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=ot(r);if(!o)return`${e}${r}`;if(!o.version&&null!=a&&a.startsWith(e)){const t=await n(ot(a.substring(e.length)));o.version=t.dependencies&&t.dependencies[o.name]||t.peerDependencies&&t.peerDependencies[o.name]}if(o.path&&!at.test(o.path)&&(o.path+=".js"),o.path&&o.version&&rt.test(o.version))return`${e}${o.name}@${o.version}/${o.path}`;const i=await n(o);return`${e}${i.name}@${i.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)),at.test(t)?t:`${t}.js`}}(i)||"index.js"}`}}RequireError.prototype.name=RequireError.name;var st=ct(it());function ct(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(Xe.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=dt,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(Qe.call(arguments,n)).then(lt):n(e)}return o.alias=function(t){return ct(((n,r)=>n in t&&(r=null,"string"!=typeof(n=t[n]))?n:e(n,r)))},o.resolve=e,o}function lt(e){const t={};for(const n of e)for(const e in n)tt.call(n,e)&&(null==n[e]?Object.defineProperty(t,e,{get:ut(n,e)}):t[e]=n[e]);return t}function ut(e,t){return()=>e[t]}function ft(e){return"exports"===(e+="")||"module"===e}function dt(e,t,n){const r=arguments.length;r<2?(n=e,t=[]):r<3&&(n=t,t="string"==typeof e?[]:e),Xe.push(et.call(t,ft)?e=>{const r={},a={exports:r};return Promise.all(Qe.call(t,(t=>"exports"===(t+="")?r:"module"===t?a:e(t)))).then((e=>(n.apply(null,e),a.exports)))}:e=>Promise.all(Qe.call(t,e)).then((e=>"function"==typeof n?n.apply(null,e):n)))}dt.amd={};const mt="https://cdn.observableusercontent.com/npm/";let ht=st;async function pt(e){const[t,n]=await Promise.all([e(Ue.resolve()),e.resolve(Ue.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([pt(ht),Promise.resolve(e).then(yt)]);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,i=o.map((e=>Object.fromEntries(e.map(((e,t)=>[a[t],e])))));return i.columns=a,i}(this._db,e,t)}async queryRow(e,t){return(await this.query(e,t))[0]||null}async explain(e,t){return wt("pre",{className:"observablehq--inspect"},[vt((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:bt(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 wt("table",{value:t},[wt("thead",[wt("tr",n.map((e=>wt("th",[vt(e)]))))]),wt("tbody",t.map((e=>wt("tr",n.map((t=>wt("td",[vt(e[t])])))))))])}async sql(){return this.query(...this.queryTag.apply(this,arguments))}queryTag(e,...t){return[e.join("?"),t]}}function bt(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 yt(e){return"string"==typeof e?fetch(e).then(yt):e instanceof Response||e instanceof Blob?e.arrayBuffer().then(yt):e instanceof ArrayBuffer?new Uint8Array(e):e}function wt(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 vt(e){return document.createTextNode(e)}function gt(e,t){return null==e||null==t?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function _t(e,t){return null==e||null==t?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Et(e){let t,n,r;function a(e,r,a=0,o=e.length){if(a<o){if(0!==t(r,r))return o;do{const t=a+o>>>1;n(e[t],r)<0?a=t+1:o=t}while(a<o)}return a}return 2!==e.length?(t=gt,n=(t,n)=>gt(e(t),n),r=(t,n)=>e(t)-n):(t=e===gt||e===_t?e:Tt,n=e,r=e),{left:a,center:function(e,t,n=0,o=e.length){const i=a(e,t,n,o-1);return i>n&&r(e[i-1],t)>-r(e[i],t)?i-1:i},right:function(e,r,a=0,o=e.length){if(a<o){if(0!==t(r,r))return o;do{const t=a+o>>>1;n(e[t],r)<=0?a=t+1:o=t}while(a<o)}return a}}}function Tt(){return 0}Object.defineProperty(SQLiteDatabaseClient.prototype,"dialect",{value:"sqlite"});const Ct=Et(gt).right;Et((function(e){return null===e?NaN:+e})).center;var At=Ct;function Nt(e,t){let n,r;if(void 0===t)for(const t of e)null!=t&&(void 0===n?t>=t&&(n=r=t):(n>t&&(n=t),r<t&&(r=t)));else{let a=-1;for(let o of e)null!=(o=t(o,++a,e))&&(void 0===n?o>=o&&(n=r=o):(n>o&&(n=o),r<o&&(r=o)))}return[n,r]}function St(e){return e}var xt=Array.prototype.slice;function Mt(e){return()=>e}const Ot=Math.sqrt(50),$t=Math.sqrt(10),jt=Math.sqrt(2);function kt(e,t,n){const r=(t-e)/Math.max(0,n),a=Math.floor(Math.log10(r)),o=r/Math.pow(10,a),i=o>=Ot?10:o>=$t?5:o>=jt?2:1;let s,c,l;return a<0?(l=Math.pow(10,-a)/i,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=Math.pow(10,a)*i,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?kt(e,t,2*n):[s,c,l]}function qt(e,t,n){return kt(e=+e,t=+t,n=+n)[2]}function Lt(e,t,n){n=+n;const r=(t=+t)<(e=+e),a=r?qt(t,e,n):qt(e,t,n);return(r?-1:1)*(a<0?1/-a:a)}function Rt(e){return Math.max(1,Math.ceil(Math.log(function(e,t){let n=0;if(void 0===t)for(let t of e)null!=t&&(t=+t)>=t&&++n;else{let r=-1;for(let a of e)null!=(a=t(a,++r,e))&&(a=+a)>=a&&++n}return n}(e))/Math.LN2)+1)}function Dt(){var e=St,t=Nt,n=Rt;function r(r){Array.isArray(r)||(r=Array.from(r));var a,o,i,s=r.length,c=new Array(s);for(a=0;a<s;++a)c[a]=e(r[a],a,r);var l=t(c),u=l[0],f=l[1],d=n(c,u,f);if(!Array.isArray(d)){const e=f,n=+d;if(t===Nt&&([u,f]=function(e,t,n){let r;for(;;){const a=qt(e,t,n);if(a===r||0===a||!isFinite(a))return[e,t];a>0?(e=Math.floor(e/a)*a,t=Math.ceil(t/a)*a):a<0&&(e=Math.ceil(e*a)/a,t=Math.floor(t*a)/a),r=a}}(u,f,n)),d=function(e,t,n){if(!((n=+n)>0))return[];if((e=+e)==(t=+t))return[e];const r=t<e,[a,o,i]=r?kt(t,e,n):kt(e,t,n);if(!(o>=a))return[];const s=o-a+1,c=new Array(s);if(r)if(i<0)for(let e=0;e<s;++e)c[e]=(o-e)/-i;else for(let e=0;e<s;++e)c[e]=(o-e)*i;else if(i<0)for(let e=0;e<s;++e)c[e]=(a+e)/-i;else for(let e=0;e<s;++e)c[e]=(a+e)*i;return c}(u,f,n),d[0]<=u&&(i=qt(u,f,n)),d[d.length-1]>=f)if(e>=f&&t===Nt){const e=qt(u,f,n);isFinite(e)&&(e>0?f=(Math.floor(f/e)+1)*e:e<0&&(f=(Math.ceil(f*-e)+1)/-e))}else d.pop()}for(var m=d.length,h=0,p=m;d[h]<=u;)++h;for(;d[p-1]>f;)--p;(h||p<m)&&(d=d.slice(h,p),m=p-h);var b,y=new Array(m+1);for(a=0;a<=m;++a)(b=y[a]=[]).x0=a>0?d[a-1]:u,b.x1=a<m?d[a]:f;if(isFinite(i)){if(i>0)for(a=0;a<s;++a)null!=(o=c[a])&&u<=o&&o<=f&&y[Math.min(m,Math.floor((o-u)/i))].push(r[a]);else if(i<0)for(a=0;a<s;++a)if(null!=(o=c[a])&&u<=o&&o<=f){const e=Math.floor((u-o)*i);y[Math.min(m,e+(d[e]<=o))].push(r[a])}}else for(a=0;a<s;++a)null!=(o=c[a])&&u<=o&&o<=f&&y[At(d,o,0,m)].push(r[a]);return y}return r.value=function(t){return arguments.length?(e="function"==typeof t?t:Mt(t),r):e},r.domain=function(e){return arguments.length?(t="function"==typeof e?e:Mt([e[0],e[1]]),r):t},r.thresholds=function(e){return arguments.length?(n="function"==typeof e?e:Mt(Array.isArray(e)?xt.call(e):e),r):n},r}function Ut(e,t=gt){let n,r=!1;if(1===t.length){let a;for(const o of e){const e=t(o);(r?gt(e,a)>0:0===gt(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 Pt(e){return e&&"function"==typeof e.toArrowBuffer}function It(e){return e&&"function"==typeof e.getChild&&"function"==typeof e.toArray&&e.schema&&Array.isArray(e.schema.fields)}function Ft(e){return e.schema.fields.map(Bt)}function Bt(e){return{name:e.name,type:zt(e.type),nullable:e.nullable,databaseType:String(e.type)}}function zt(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 Ht(){return await import(`${mt}${He.resolve()}`)}let Yt;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:Ft(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:Gt(t),nullable:"NO"!==n,databaseType:t})))}static async of(e={},t={}){const n=await async function(){void 0===Yt&&(Yt=async function(){const e=await import(`${mt}${Ke.resolve()}`),t=await e.selectBundle({mvp:{mainModule:`${mt}${Ke.resolve("dist/duckdb-mvp.wasm")}`,mainWorker:`${mt}${Ke.resolve("dist/duckdb-browser-mvp.worker.js")}`},eh:{mainModule:`${mt}${Ke.resolve("dist/duckdb-eh.wasm")}`,mainWorker:`${mt}${Ke.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 Yt,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 Wt(n,e,t);else if(It(t))await Vt(n,e,t);else if(Array.isArray(t))await Jt(n,e,t);else if(Pt(t))await async function(e,t,n){const r=(await Ht()).tableFromIPC(n.toArrowBuffer());return await Vt(e,t,r)}(n,e,t);else if("data"in t){const{data:r,...a}=t;It(r)?await Vt(n,e,r,a):await Jt(n,e,r,a)}else{if(!("file"in t))throw new Error(`invalid source: ${t}`);{const{file:r,...a}=t;await Wt(n,e,r,a)}}}))),new DuckDBClient(n)}}async function Wt(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,new URL(a,location).href,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 Vt(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 Jt(e,t,n,r){const a=(await Ht()).tableFromJSON(n);return await Vt(e,t,a,r)}function Gt(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"});const Kt=20;function Zt(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!==sn}function Xt(e){return Array.isArray(e)&&(Qt(e.schema)||en(e.columns)||function(e){const t=Math.min(Kt,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)||rn(e)||an(e))||on(e)}function Qt(e){return Array.isArray(e)&&e.every(tn)}function en(e){return Array.isArray(e)&&e.every((e=>"string"==typeof e))}function tn(e){return e&&"string"==typeof e.name&&"string"==typeof e.type}function nn(e){return on(e)||rn(e)||an(e)}function rn(e){const t=Math.min(Kt,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 an(e){const t=Math.min(Kt,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 on(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 sn=Object.assign((async(e,t,n,r)=>{if(Zt(e=await un(await e,r)))return mn(e,hn(t,e),n);if(Xt(e))return Pn(e,t);if(!e)throw new Error("missing data source");throw new Error("invalid data source")}),{sql:(e,t,n)=>async function(){return mn(await fn(await e,n),arguments,t)}});function cn(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||Xt(n)&&n.length!==a._numRows)&&(a=e(n,r),a._numRows=n.length,t.set(n,a)),a}}const ln=cn((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})),un=cn((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 dn(e,t);throw new Error(`unsupported file type: ${e.mimeType}`)}return It(e)||Pt(e)?dn(e,t):Xt(e)&&nn(e)?Array.from(e,(e=>({value:e}))):e})),fn=cn((async(e,t)=>{if(e instanceof FileAttachment){switch(e.mimeType){case"text/csv":case"text/tab-separated-values":case"application/json":return dn(e,t);case"application/x-sqlite3":return e.sqlite()}if(/\.(arrow|parquet)$/i.test(e.name))return dn(e,t);throw new Error(`unsupported file type: ${e.mimeType}`)}return Xt(e)?dn(await async function(e,t){const n=await Ht();return nn(e)?n.tableFromArrays({[t]:e}):n.tableFromJSON(e)}(e,t),t):It(e)||Pt(e)?dn(e,t):e}));function dn(e,t=(e instanceof FileAttachment?function(e){return e.name.replace(/@\d+(?=\.|$)/,"").replace(/\.\w+$/,"")}(e):"__table")){return DuckDBClient.of({[t]:e})}async function mn(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 hn(e,t){const n="function"==typeof t.escape?t.escape:e=>e,{select:r,from:a,filter:o,sort:i,slice:s}=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]))),l=[[`SELECT ${r.columns?r.columns.map((e=>{const t=c.get(e);return t?`${n(e)} AS ${n(t)}`:n(e)})).join(", "):"*"} FROM ${pn(a.table,n)}`]];for(let e=0;e<o.length;++e)bn(e?"\nAND ":"\nWHERE ",l),wn(o[e],l,n);for(let e=0;e<i.length;++e)bn(e?", ":"\nORDER BY ",l),yn(i[e],l,n);if("mssql"===t.dialect||"oracle"===t.dialect){if(null!==s.to||null!==s.from){if(!i.length){if(!r.columns)throw new Error("at least one column must be explicitly specified. Received '*'.");bn("\nORDER BY ",l),yn({column:r.columns[0],direction:"ASC"},l,n)}bn(`\nOFFSET ${s.from||0} ROWS`,l),bn(`\nFETCH NEXT ${null!==s.to?s.to-(s.from||0):1e9} ROWS ONLY`,l)}}else null===s.to&&null===s.from||bn("\nLIMIT "+(null!==s.to?s.to-(s.from||0):1e9),l),null!==s.from&&bn(` OFFSET ${s.from}`,l);return l}function pn(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 bn(e,t){const n=t[0];n[n.length-1]+=e}function yn({column:e,direction:t},n,r){bn(`${r(e)} ${t.toUpperCase()}`,n)}function wn({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(vn(t[0],n,r),e){case"n":case"nv":return void bn(" IS NULL",n);case"nn":case"v":return void bn(" IS NOT NULL",n);default:throw new Error("Invalid filter operation")}if(2!==t.length||["in","nin"].includes(e)){switch(vn(t[0],n,r),e){case"in":bn(" IN (",n);break;case"nin":bn(" 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:bn(",",t),t.push(r.value),t[0].push("")}(t.slice(1),n),bn(")",n)}else{if(["c","nc"].includes(e)){switch(vn(t[0],n,r),e){case"c":bn(" LIKE ",n);break;case"nc":bn(" NOT LIKE ",n)}return void vn(function(e){return{...e,value:`%${e.value}%`}}(t[1]),n,r)}switch(vn(t[0],n,r),e){case"eq":bn(" = ",n);break;case"ne":bn(" <> ",n);break;case"gt":bn(" > ",n);break;case"lt":bn(" < ",n);break;case"gte":bn(" >= ",n);break;case"lte":bn(" <= ",n);break;default:throw new Error("Invalid filter operation")}vn(t[1],n,r)}}function vn(e,t,n){"column"===e.type?bn(n(e.value),t):(t.push(e.value),t[0].push(""))}function gn(e,t){return(null==e||!(e>=e))-(null==t||!(t>=t))}function _n(e,t){return gn(e,t)||(e<t?-1:e>t?1:0)}function En(e,t){return gn(e,t)||(e>t?-1:e<t?1:0)}const Tn=e=>"number"==typeof e&&!Number.isNaN(e),Cn=e=>Number.isInteger(e)&&!Number.isNaN(e),An=e=>"string"==typeof e,Nn=e=>"boolean"==typeof e,Sn=e=>"bigint"==typeof e,xn=e=>e instanceof Date&&!isNaN(e),Mn=e=>e instanceof ArrayBuffer,On=e=>Array.isArray(e),$n=e=>"object"==typeof e&&null!==e,jn=e=>null!=e;function kn(e){switch(e){case"string":return An;case"bigint":return Sn;case"boolean":return Nn;case"number":return Tn;case"integer":return Cn;case"date":return xn;case"buffer":return Mn;case"array":return On;case"object":return $n;default:return jn}}const qn=/^(([-+]\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 Ln(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(qn.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 Rn(e){const{columns:t}=e;let{schema:n}=e;return Qt(n)?{schema:n,inferred:!1}:(n=zn(e,en(t)?t:void 0),{schema:n,inferred:!0})}function Dn(e,t){const n=e;let{schema:r,inferred:a}=Rn(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=>In(e,o,r)))}else a&&(e=e.map((e=>In(e,o,r))));return{source:e,schema:r}}function Un(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=>{const r=n.get(t);return[r?.name??t,e[t]]})))))}function Pn(e,t){const n=new Map,r=e,a=Dn(e,t);e=a.source;let o=a.schema;if(t.derive){const r=[];t.derive.map((({name:a,value:o})=>{let i=[];Un(e,t).map(((e,t)=>{let n;try{n=o(e)}catch(e){i.push({index:t,error:e}),n=void 0}r[t]?r[t]={...r[t],[a]:n}:r.push({[a]:n})})),i.length&&n.set(a,i)}));const a=Dn(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=kn(n);e=e.filter((e=>r(e[t])));break}case"nv":{const[n]=a,r=kn(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?En:_n;e===r&&(e=e.slice()),e.sort(((e,r)=>t(e[n],r[n])))}let{from:i,to:s}=t.slice;i=null==i?0:Math.max(0,i),s=null==s?1/0:Math.max(0,s),(i>0||s<1/0)&&(e=e.slice(Math.max(0,i),Math.max(0,s)));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=Un(e,t)}return e!==r&&o&&(e.schema=o),e.fullSchema=c,e.errors=n,e}function In(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:Ln(o,n)}return r}function Fn(){return{boolean:0,integer:0,number:0,date:0,string:0,array:0,object:0,bigint:0,buffer:0,defined:0}}const Bn=["boolean","integer","number","date","bigint","array","object","buffer"];function zn(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),a={};for(const e of t){const t=a[e]=Fn();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):qn.test(r)&&++t.date}}const o=Math.max(1,.9*t.defined),i=Ut(Bn,(e=>t[e]>=o?t[e]:NaN))??(t.string>=o?"string":"other");n.push({name:e,type:i,inferred:i})}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,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,a=0],[o=t-1,i=n-1]]=e.split(":").map(Vn);return[[r,a],[o,i]]}(t,e);const s=n?e._rows[a++]:null;let c=new Set(["#"]);for(let e=r;e<=o;e++){const t=s?Hn(s.findCell(e+1)):null;let n=t&&t+""||Wn(e);for(;c.has(n);)n+="_";c.add(n)}c=new Array(r).concat(Array.from(c));const l=new Array(i-a+1);for(let t=a;t<=i;t++){const n=l[t-a]=Object.create(null,{"#":{value:t+1}}),i=e.getRow(t+1);if(i.hasValues)for(let e=r;e<=o;e++){const t=Hn(i.findCell(e+1));null!=t&&(n[c[e+1]]=t)}}return l.columns=c.filter((()=>!0)),l}(this._.getWorksheet(n),t)}}function Hn(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 Yn(t);if(t.text){let{text:e}=t;return e.richText&&(e=Yn(e)),t.hyperlink&&t.hyperlink!==e?`${t.hyperlink} ${e}`:e}return t}return t}function Yn(e){return e.richText.map((e=>e.text)).join("")}function Wn(e){let t="";e++;do{t=String.fromCharCode(64+(e%26||26))+t}while(e=Math.floor((e-1)/26));return t}function Vn(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 Jn(e){const t=await fetch(await e.url());if(!t.ok)throw new Error(`Unable to load file: ${e.name}`);return t}async function Gn(e,t,{array:n=!1,typed:r=!1}={}){const a=await e.text(),o="\t"===t?n?Ce:Te:n?ve:we;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=>In(e,n,t))),{schema:t})}(e,zn(e,e.columns))}return o(a,r&&Ae)}class Kn{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 Jn(this)).blob()}async arrayBuffer(){return(await Jn(this)).arrayBuffer()}async text(){return(await Jn(this)).text()}async json(){return(await Jn(this)).json()}async stream(){return(await Jn(this)).body}async csv(e){return Gn(this,",",e)}async tsv(e){return Gn(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([ht(Be.resolve()),Jn(this)]);return e.Table.from(t)}case 9:{const[e,t]=await Promise.all([import(`${mt}${ze.resolve()}`),Jn(this)]);return e.tableFromIPC(t)}case 11:{const[e,t]=await Promise.all([import(`${mt}${He.resolve()}`),Jn(this)]);return e.tableFromIPC(t)}default:throw new Error(`unsupported arrow version: ${e}`)}}async sqlite(){return SQLiteDatabaseClient.open(Jn(this))}async zip(){const[e,t]=await Promise.all([ht(Re.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([ht(Ve.resolve()),this.arrayBuffer()]);return new Workbook(await(new e.Workbook).xlsx.load(t))}}class FileAttachment extends Kn{constructor(e,t,n){super(t,n),Object.defineProperty(this,"_url",{value:e})}async url(){return await this._url+""}}function Zn(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 Kn{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 Xn={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 Qn=0;function er(e){return new tr("O-"+(null==e?"":e+"-")+ ++Qn)}function tr(e){this.id=e,this.href=new URL(`#${e}`,location)+""}tr.prototype.toString=function(){return"url("+this.href+")"};var nr=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=Xn.hasOwnProperty(r)?document.createElementNS(Xn[r],e):document.createElement(e);if(t)for(var i in t)a=(r=i).indexOf(":"),n=t[i],a>=0&&"xmlns"!==(r=i.slice(0,a))&&(i=i.slice(a+1)),Xn.hasOwnProperty(r)?o.setAttributeNS(Xn[r],i,n):o.setAttribute(i,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:er});var rr=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 ar(){return this}function or(e,t){let n=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:ar,next:()=>n?{done:!0}:(n=!0,{done:!1,value:e}),return:()=>(n=!0,t(e),{done:!0}),throw:()=>({done:n=!0})}}function ir(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]:ar,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 sr(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 cr=Object.freeze({__proto__:null,disposable:or,filter:function*(e,t){for(var n,r=-1;!(n=e.next()).done;)t(n.value,++r)&&(yield n.value)},input:function(e){return ir((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=sr(e);function a(){t(sr(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:ir,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]:ar,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 or(n,(()=>{n.terminate(),URL.revokeObjectURL(t)}))}});function lr(e,t){return function(n){var r,a,o,i,s,c,l,u,f=n[0],d=[],m=null,h=-1;for(s=1,c=arguments.length;s<c;++s){if((r=arguments[s])instanceof Node)d[++h]=r,f+="\x3c!--o:"+h+"--\x3e";else if(Array.isArray(r)){for(l=0,u=r.length;l<u;++l)(a=r[l])instanceof Node?(null===m&&(d[++h]=m=document.createDocumentFragment(),f+="\x3c!--o:"+h+"--\x3e"),m.appendChild(a)):(m=null,f+=a);m=null}else f+=r;f+=n[s]}if(m=e(f),++h>0){for(o=new Array(h),i=document.createTreeWalker(m,NodeFilter.SHOW_COMMENT,null,!1);i.nextNode();)a=i.currentNode,/^o:/.test(a.nodeValue)&&(o[+a.nodeValue.slice(2)]=a);for(s=0;s<h;++s)(a=o[s])&&a.parentNode.replaceChild(d[s],a)}return 1===m.childNodes.length?m.removeChild(m.firstChild):11===m.nodeType?((a=t()).appendChild(m),a):m}}const ur=lr((function(e){var t=document.createElement("template");return t.innerHTML=e.trim(),document.importNode(t.content,!0)}),(function(){return document.createElement("span")}));function fr(e){let t;Object.defineProperties(this,{generator:{value:ir((e=>{t=e}))},value:{get:()=>e,set:n=>t(e=n)}}),void 0!==e&&t(e)}function*dr(){for(;;)yield Date.now()}var mr=new Map;function hr(e,t){var n;return(n=mr.get(e=+e))?n.then((()=>t)):(n=Date.now())>=e?Promise.resolve(t):function(e,t){var n=new Promise((function(n){mr.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 mr.set(t,n),n}(n,e).then((()=>t))}var pr=Object.freeze({__proto__:null,delay:function(e,t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))},tick:function(e,t){return hr(Math.ceil((Date.now()+1)/e)*e,t)},when:hr});function br(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 yr=lr((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 wr=String.raw;function vr(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 gr(){return ir((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 _r=Object.assign(Object.defineProperties((function(e){const t=function(e){return null==e?ht:ct(e)}(e);Object.defineProperties(this,function(e){return Object.fromEntries(Object.entries(e).map(Er))}({FileAttachment:()=>Zn,Mutable:()=>fr,now:dr,width:gr,dot:()=>t($e.resolve()),htl:()=>t(Le.resolve()),html:()=>ur,md:()=>function(e){return e(De.resolve()).then((function(t){return lr((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(je.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(je.resolve("async-languages/index.js")).then((r=>{if(r.has(n.className))return e(je.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:()=>yr,tex:()=>function(e){return Promise.all([e(ke.resolve()),e.resolve(ke.resolve("dist/katex.min.css")).then(vr)]).then((function(e){var t=e[0],n=r();function r(e){return function(){var n=document.createElement("div");return t.render(wr.apply(String,arguments),n,e),n.removeChild(n.firstChild)}}return n.options=r,n.block=r({displayMode:!0}),n}))}(t),_:()=>t(qe.resolve()),aq:()=>t.alias({"apache-arrow":Be.resolve()})(Ye.resolve()),Arrow:()=>t(Be.resolve()),d3:()=>t(xe.resolve()),DuckDBClient:()=>DuckDBClient,Inputs:()=>t(Me.resolve()).then((e=>({...e,file:e.fileOf(Kn)}))),L:()=>async function(e){const t=await e(Ge.resolve());if(!t._style){const n=document.createElement("link");n.rel="stylesheet",n.href=await e.resolve(Ge.resolve("dist/leaflet.css")),t._style=document.head.appendChild(n)}return t}(t),mermaid:()=>async function(e){const t=await e(Je.resolve());return t.initialize({securityLevel:"loose",theme:"neutral"}),function(){const e=document.createElement("div");return e.innerHTML=t.render(er().id,String.raw.apply(String,arguments)),e.removeChild(e.firstChild)}}(t),Plot:()=>t(Oe.resolve()),__query:()=>sn,require:()=>t,resolve:()=>br,SQLite:()=>pt(t),SQLiteDatabaseClient:()=>SQLiteDatabaseClient,topojson:()=>t(We.resolve()),vl:()=>async function(e){const[t,n,r]=await Promise.all([Pe,Ie,Fe].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}),pizza:()=>new FileAttachment("https://static.observableusercontent.com/files/c653108ab176088cacbb338eaf2344c4f5781681702bd6afb55697a3f91b511c6686ff469f3e3a27c75400001a2334dbd39a4499fe46b50a8b3c278b7d2f7fb5").csv({typed:!0}),weather:()=>new FileAttachment("https://static.observableusercontent.com/files/693a46b22b33db0f042728700e0c73e836fa13d55446df89120682d55339c6db7cc9e574d3d73f24ecc9bc7eb9ac9a1e7e104a1ee52c00aab1e77eb102913c1f").csv({typed:!0}),DOM:nr,Files:rr,Generators:cr,Promises:pr}))}),{resolve:{get:()=>ht.resolve,enumerable:!0,configurable:!0},require:{get:()=>ht,set:function(e){ht=e},enumerable:!0,configurable:!0}}),{resolveFrom:it,requireFrom:ct});function Er([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}class Tr extends Error{constructor(e,t){super(e),this.input=t}}function Cr(e){return()=>e}function Ar(e){return e}Tr.prototype.name="RuntimeError";const Nr=Array.prototype.map;function Sr(){}const xr=2,Mr=3,Or=Symbol("no-observer");function $r(e,t,n,r){n||(n=Or),Object.defineProperties(this,{_observer:{value:n,writable:!0},_definition:{value:Lr,writable:!0},_duplicate:{value:void 0,writable:!0},_duplicates:{value:void 0,writable:!0},_indegree:{value:NaN,writable:!0},_inputs:{value:[],writable:!0},_invalidate:{value:Sr,writable:!0},_module:{value:t},_name:{value:null,writable:!0},_outputs:{value:new Set,writable:!0},_promise:{value:Promise.resolve(void 0),writable:!0},_reachable:{value:n!==Or,writable:!0},_rejector:{value:Dr(this)},_shadow:{value:jr(t,r)},_type:{value:e},_value:{value:void 0,writable:!0},_version:{value:0,writable:!0}})}function jr(e,t){return t?.shadow?new Map(Object.entries(t.shadow).map((([t,n])=>[t,new $r(xr,e).define([],n)]))):null}function kr(e){e._module._runtime._dirty.add(e),e._outputs.add(this)}function qr(e){e._module._runtime._dirty.add(e),e._outputs.delete(this)}function Lr(){throw Lr}function Rr(){throw Rr}function Dr(e){return t=>{if(t===Rr)throw t;if(t===Lr)throw new Tr(`${e._name} is not defined`,e._name);if(t instanceof Error&&t.message)throw new Tr(t.message,e._name);throw new Tr(`${e._name} could not be resolved`,e._name)}}function Ur(e){return()=>{throw new Tr(`${e} is defined more than once`)}}function Pr(e,t,n){const r=this._module._scope,a=this._module._runtime;if(this._inputs.forEach(qr,this),t.forEach(kr,this),this._inputs=t,this._definition=n,this._value=void 0,n===Sr?a._variables.delete(this):a._variables.add(this),e!==this._name||r.get(e)!==this){let t,o;if(this._name)if(this._outputs.size)r.delete(this._name),o=this._module._resolve(this._name),o._outputs=this._outputs,this._outputs=new Set,o._outputs.forEach((function(e){e._inputs[e._inputs.indexOf(this)]=o}),this),o._outputs.forEach(a._updates.add,a._updates),a._dirty.add(o).add(this),r.set(this._name,o);else if((o=r.get(this._name))===this)r.delete(this._name);else{if(o._type!==Mr)throw new Error;o._duplicates.delete(this),this._duplicate=void 0,1===o._duplicates.size&&(o=o._duplicates.keys().next().value,t=r.get(this._name),o._outputs=t._outputs,t._outputs=new Set,o._outputs.forEach((function(e){e._inputs[e._inputs.indexOf(t)]=o})),o._definition=o._duplicate,o._duplicate=void 0,a._dirty.add(t).add(o),a._updates.add(o),r.set(this._name,o))}if(this._outputs.size)throw new Error;e&&((o=r.get(e))?o._type===Mr?(this._definition=Ur(e),this._duplicate=n,o._duplicates.add(this)):o._type===xr?(this._outputs=o._outputs,o._outputs=new Set,this._outputs.forEach((function(e){e._inputs[e._inputs.indexOf(o)]=this}),this),a._dirty.add(o).add(this),r.set(e,this)):(o._duplicate=o._definition,this._duplicate=n,t=new $r(Mr,this._module),t._name=e,t._definition=this._definition=o._definition=Ur(e),t._outputs=o._outputs,o._outputs=new Set,t._outputs.forEach((function(e){e._inputs[e._inputs.indexOf(o)]=t})),t._duplicates=new Set([this,o]),a._dirty.add(o).add(t),a._updates.add(o).add(t),r.set(e,t)):r.set(e,this)),this._name=e}return this._version>0&&++this._version,a._updates.add(this),a._compute(),this}Object.defineProperties($r.prototype,{_pending:{value:function(){this._observer.pending&&this._observer.pending()},writable:!0,configurable:!0},_fulfilled:{value:function(e){this._observer.fulfilled&&this._observer.fulfilled(e,this._name)},writable:!0,configurable:!0},_rejected:{value:function(e){this._observer.rejected&&this._observer.rejected(e,this._name)},writable:!0,configurable:!0},_resolve:{value:function(e){return this._shadow?.get(e)??this._module._resolve(e)},writable:!0,configurable:!0},define:{value:function(e,t,n){switch(arguments.length){case 1:n=e,e=t=null;break;case 2:n=t,"string"==typeof e?t=null:(t=e,e=null)}return Pr.call(this,null==e?null:String(e),null==t?[]:Nr.call(t,this._resolve,this),"function"==typeof n?n:Cr(n))},writable:!0,configurable:!0},delete:{value:function(){return Pr.call(this,null,[],Sr)},writable:!0,configurable:!0},import:{value:function(e,t,n){arguments.length<3&&(n=t,t=e);return Pr.call(this,String(t),[n._resolve(String(e))],Ar)},writable:!0,configurable:!0}});const Ir=Symbol("variable"),Fr=Symbol("invalidation"),Br=Symbol("visibility");function zr(e,t=[]){Object.defineProperties(this,{_runtime:{value:e},_scope:{value:new Map},_builtins:{value:new Map([["@variable",Ir],["invalidation",Fr],["visibility",Br],...t])},_source:{value:null,writable:!0}})}async function Hr(e,t){await e._compute();try{return await t._promise}catch(n){if(n===Rr)return Hr(e,t);throw n}}function Yr(e){return e._name}Object.defineProperties(zr.prototype,{_resolve:{value:function(e){let t,n=this._scope.get(e);if(!n)if(n=new $r(xr,this),this._builtins.has(e))n.define(e,Cr(this._builtins.get(e)));else if(this._runtime._builtin._scope.has(e))n.import(e,this._runtime._builtin);else{try{t=this._runtime._global(e)}catch(t){return n.define(e,function(e){return()=>{throw e}}(t))}void 0===t?this._scope.set(n._name=e,n):n.define(e,Cr(t))}return n},writable:!0,configurable:!0},redefine:{value:function(e){const t=this._scope.get(e);if(!t)throw new Tr(`${e} is not defined`);if(t._type===Mr)throw new Tr(`${e} is defined more than once`);return t.define.apply(t,arguments)},writable:!0,configurable:!0},define:{value:function(){const e=new $r(1,this);return e.define.apply(e,arguments)},writable:!0,configurable:!0},derive:{value:function(e,t){const n=new Map,r=new Set,a=[];function o(e){let t=n.get(e);return t||(t=new zr(e._runtime,e._builtins),t._source=e,n.set(e,t),a.push([t,e]),r.add(e),t)}const i=o(this);for(const n of e){const{alias:e,name:r}="object"==typeof n?n:{name:n};i.import(r,null==e?r:e,t)}for(const e of r)for(const[t,n]of e._scope)if(n._definition===Ar){if(e===this&&i._scope.has(t))continue;const r=n._inputs[0]._module;r._source&&o(r)}for(const[e,t]of a)for(const[r,a]of t._scope){const t=e._scope.get(r);if(!t||t._type===xr)if(a._definition===Ar){const t=a._inputs[0],o=t._module;e.import(t._name,r,n.get(o)||o)}else e.define(r,a._inputs.map(Yr),a._definition)}return i},writable:!0,configurable:!0},import:{value:function(){const e=new $r(1,this);return e.import.apply(e,arguments)},writable:!0,configurable:!0},value:{value:async function(e){let t=this._scope.get(e);if(!t)throw new Tr(`${e} is not defined`);if(t._observer!==Or)return Hr(this._runtime,t);t=this.variable(!0).define([e],Ar);try{return await Hr(this._runtime,t)}finally{t.delete()}},writable:!0,configurable:!0},variable:{value:function(e,t){return new $r(1,this,e,t)},writable:!0,configurable:!0},builtin:{value:function(e,t){this._builtins.set(e,t)},writable:!0,configurable:!0}});const Wr="function"==typeof requestAnimationFrame?requestAnimationFrame:"function"==typeof setImmediate?setImmediate:e=>setTimeout(e,0);function Vr(e=new _r,t=na){const n=this.module();if(Object.defineProperties(this,{_dirty:{value:new Set},_updates:{value:new Set},_precomputes:{value:[],writable:!0},_computing:{value:null,writable:!0},_init:{value:null,writable:!0},_modules:{value:new Map},_variables:{value:new Set},_disposed:{value:!1,writable:!0},_builtin:{value:n},_global:{value:t}}),e)for(const t in e)new $r(xr,n).define(t,[],e[t])}function Jr(e){const t=new Set(e._inputs);for(const n of t){if(n===e)return!0;n._inputs.forEach(t.add,t)}return!1}function Gr(e){++e._indegree}function Kr(e){--e._indegree}function Zr(e){return e._promise.catch(e._rejector)}function Xr(e){return new Promise((function(t){e._invalidate=t}))}function Qr(e,t){let n,r,a="function"==typeof IntersectionObserver&&t._observer&&t._observer._node,o=!a,i=Sr,s=Sr;return a&&(r=new IntersectionObserver((([e])=>(o=e.isIntersecting)&&(n=null,i()))),r.observe(a),e.then((()=>(r.disconnect(),r=null,s())))),function(e){return o?Promise.resolve(e):r?(n||(n=new Promise(((e,t)=>(i=e,s=t)))),n.then((()=>e))):Promise.reject()}}function ea(e){e._invalidate(),e._invalidate=Sr,e._pending();const t=e._value,n=++e._version;let r=null;const a=e._promise=(e._inputs.length?Promise.all(e._inputs.map(Zr)).then((function(a){if(e._version!==n)throw Rr;for(let t=0,n=a.length;t<n;++t)switch(a[t]){case Fr:a[t]=r=Xr(e);break;case Br:r||(r=Xr(e)),a[t]=Qr(r,e);break;case Ir:a[t]=e}return e._definition.apply(t,a)})):new Promise((n=>n(e._definition.call(t))))).then((function(t){if(e._version!==n)throw Rr;if(function(e){return e&&"function"==typeof e.next&&"function"==typeof e.return}(t))return(r||Xr(e)).then(function(e){return function(){e.return()}}(t)),function(e,t,n){const r=e._module._runtime;let a;function o(e){return new Promise((e=>e(n.next(a)))).then((({done:t,value:n})=>t?void 0:Promise.resolve(n).then(e)))}function i(){const n=o((o=>{if(e._version!==t)throw Rr;return a=o,s(o,n).then((()=>r._precompute(i))),e._fulfilled(o),o}));n.catch((r=>{r!==Rr&&e._version===t&&(s(void 0,n),e._rejected(r))}))}function s(t,n){return e._value=t,e._promise=n,e._outputs.forEach(r._updates.add,r._updates),r._compute()}return o((n=>{if(e._version!==t)throw Rr;return a=n,r._precompute(i),n}))}(e,n,t);return t}));a.then((t=>{e._value=t,e._fulfilled(t)}),(t=>{t!==Rr&&e._version===n&&(e._value=void 0,e._rejected(t))}))}function ta(e,t){e._invalidate(),e._invalidate=Sr,e._pending(),++e._version,e._indegree=NaN,(e._promise=Promise.reject(t)).catch(Sr),e._value=void 0,e._rejected(t)}function na(e){return globalThis[e]}function ra(e,t){try{return(0,eval)(`"use strict";(\n${e}\n)\n//# sourceURL=observablehq-${t}`)}catch(e){return function(e){return()=>{throw e}}(e)}}function aa(e,t){switch(t){case"map":return function(e){const t=document.createElement("DIV");return t.style.height="400px",Qi.L().then((n=>{n.Icon.Default.imagePath=`${Xi}leaflet@${n.version}/dist/images/`;const r=n.map(t),a=ca(e)?e:function(e){return Array.isArray(e)?{type:"MultiPoint",coordinates:e.map(ia)}:{type:"Point",coordinates:ia(e)}}(e),o=n.geoJSON(a).addTo(r).getBounds();r.fitBounds(o,{maxZoom:void 0!==e.zoom?e.zoom:oa(o)?void 0:9}),n.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:"© <a href=https://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors"}).addTo(r)})).catch((e=>{t.textContent=e.toString(),console.error(e)})),t}(e);case"none":case"table":return document.createTextNode(" ");default:return e}}function oa(e){return e.getWest()<e.getEast()||e.getSouth()<e.getNorth()}function ia(e){return e.coords?[e.coords.longitude,e.coords.latitude]:[e.longitude,e.latitude]}function sa(e){return Xt(e)}function ca(e){return e&&"object"==typeof e&&(function(e){return"Feature"===e.type&&"object"==typeof e.properties&&(null===e.geometry||la(e.geometry))}(e)||function(e){return"FeatureCollection"===e.type&&Array.isArray(e.features)}(e)||la(e)||function(e){return"GeometryCollection"===e.type&&Array.isArray(e.geometries)}(e))}function la(e){return("Point"===e.type||"MultiPoint"===e.type||"LineString"===e.type||"MultiLineString"===e.type||"Polygon"===e.type||"MultiPolygon"===e.type)&&Array.isArray(e.coordinates)}Object.defineProperties(Vr.prototype,{_precompute:{value:function(e){this._precomputes.push(e),this._compute()},writable:!0,configurable:!0},_compute:{value:function(){return this._computing||(this._computing=this._computeSoon())},writable:!0,configurable:!0},_computeSoon:{value:function(){return new Promise(Wr).then((()=>this._disposed?void 0:this._computeNow()))},writable:!0,configurable:!0},_computeNow:{value:async function(){let e,t,n=[],r=this._precomputes;if(r.length){this._precomputes=[];for(const e of r)e();await function(e=0){let t=Promise.resolve();for(let n=0;n<e;++n)t=t.then((()=>{}));return t}(3)}e=new Set(this._dirty),e.forEach((function(t){t._inputs.forEach(e.add,e);const n=function(e){if(e._observer!==Or)return!0;const t=new Set(e._outputs);for(const e of t){if(e._observer!==Or)return!0;e._outputs.forEach(t.add,t)}return!1}(t);n>t._reachable?this._updates.add(t):n<t._reachable&&t._invalidate(),t._reachable=n}),this),e=new Set(this._updates),e.forEach((function(t){t._reachable?(t._indegree=0,t._outputs.forEach(e.add,e)):(t._indegree=NaN,e.delete(t))})),this._computing=null,this._updates.clear(),this._dirty.clear(),e.forEach((function(e){e._outputs.forEach(Gr)}));do{for(e.forEach((function(e){0===e._indegree&&n.push(e)}));t=n.pop();)ea(t),t._outputs.forEach(a),e.delete(t);e.forEach((function(t){Jr(t)&&(ta(t,new Tr("circular definition")),t._outputs.forEach(Kr),e.delete(t))}))}while(e.size);function a(e){0==--e._indegree&&n.push(e)}},writable:!0,configurable:!0},dispose:{value:function(){this._computing=Promise.resolve(),this._disposed=!0,this._variables.forEach((e=>{e._invalidate(),e._version=NaN}))},writable:!0,configurable:!0},module:{value:function(e,t=Sr){let n;if(void 0===e)return(n=this._init)?(this._init=null,n):new zr(this);if(n=this._modules.get(e),n)return n;this._init=n=new zr(this),this._modules.set(e,n);try{e(this,t)}finally{this._init=null}return n},writable:!0,configurable:!0},fileAttachments:{value: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})},writable:!0,configurable:!0}});const ua=new Map,fa=new Map;const da="https://observablehq.com",ma=window.parent,ha=`w-${Math.random().toString(36).slice(2,8).padStart(6,"0")}`;let pa=0;function ba(e){ma.postMessage({id:`${ha}-${++pa}`,...e},da)}let ya;let wa;const va={};class ga{constructor(e){this.id=e,this._variable=ts.variable(va),this._secondaries=[],this.mode=void 0,this.fileAttachments=new Set,this._empty=void 0,this._generation=0}define(e,t,n){Ea.call(this,e,t,n)}dispose(){Ta.call(this)}run(){es._updates.add(this._variable),es._compute()}}class _a extends le{constructor(e){const t=document.createElement("DIV");super(t),this.id=e,this.node=t,t.setAttribute("dir","auto"),t.addEventListener("mouseenter",(()=>{ba({type:"hover",node_id:this.id})})),this.mode=void 0,this.preferredDisplay=void 0,this.currentDisplayMode=void 0,this.fileAttachments=new Set,this.currentChartSpec=void 0,this._variable=ts.variable(this),this._resized=()=>{this._resize(Math.max(0,this.node.nextSibling.offsetTop-this.node.offsetTop-this._offset-17))},this._resizer=new ResizeObserver(this._resized),this._resizer.observe(t),this._secondaries=[],this._offset=0,this._height=0,this._empty=void 0,this._generation=0,this._error=void 0,this._setDisplayMode("none")}define(e,t,n){Ea.call(this,e,t,n)}_hasWorkerDisplay(){return!function(e){return"none"===e||"table"===e}(this.currentDisplayMode)||0===this._offset}offset(e=this._offset){this._offset=e;const t=this.node,n=17+e,r=this._hasWorkerDisplay();t.classList.toggle("observablehq--worker",r),t.style.marginBottom=r?`${n}px`:`calc(${n}px - 1.5rem)`,this._resizer.unobserve(t),this._resizer.observe(t)}run(){es._updates.add(this._variable),es._compute()}async resolve(){await es._computing,await this._variable._promise}value(){return this._variable._value}error(){return this._error}valueAsView(){const e=this._variable._value;return e instanceof EventTarget?e.value:void 0}preferDisplay(e){this.preferredDisplay=e?.display,this._error||this._updateDisplay(this.value(),this._variable._name)}_updateDisplay(e,t){const n=this._getCurrentDisplayMode(e);this._setDisplayMode(n),super.fulfilled(aa(e,n),t)}_getSuggestions(e){const t=[];return this._empty||(sa(e)&&("table"!==this.mode&&t.push("table"),t.push("chart")),function(e){return ca(e)}(e)&&t.push("map")),t}_getCurrentDisplayMode(e){return this._empty||"none"===this.preferredDisplay?.mode?"none":"table"!==this.mode&&"sql"!==this.mode||!sa(e)?"value":"table"}_setDisplayMode(e){ba({type:"display",node_id:this.id,mode:e}),e!==this.currentDisplayMode&&(this.currentDisplayMode=e,this.offset())}fulfilled(e,t){if(!this.node)return;const{classList:n}=this.node;this._updateDisplay(e,t),this._hasWorkerDisplay()&&(n.add("observablehq--changed"),function(e){ya||(ya=new Set,setTimeout(xa,150));ya.add(e)}(n)),void 0!==this._error&&(this._error=void 0,Ma(this.id,null)),ba({type:"fulfilled",node_id:this.id,suggestions:this._getSuggestions(e),chartSpec:this.currentChartSpec})}rejected(e,t){"table"===this.mode?this._setDisplayMode("table"):this._setDisplayMode("value"),this._hasWorkerDisplay()&&super.rejected(e,t),e&&(this._error=e,Ma(this.id,e)),ba({type:"rejected",node_id:this.id,suggestions:[],chartSpec:this.currentChartSpec=null})}pending(){super.pending(),ba({type:"pending",node_id:this.id})}_resize(e){this._height!==e&&(this._height=e,ba({type:"resize",node_id:this.id,height:e}))}dispose(){this._resizer.disconnect(),this._resize(0),Ta.call(this),this.node=void 0}}function Ea(e,t=this.mode,n){const{type:r,fileAttachments:a=new Set}=e,o=++this._generation;for(const e of this._secondaries)e.delete();switch(this._secondaries.length=0,this._empty=!1,this.fileAttachments=a,void 0!==n&&(this.preferredDisplay=n?.display),this.mode=t,r){case"empty":this._empty=!0,this._variable.delete(),this.currentChartSpec=null;break;case"import":{const{module:t,specifier:n,specifiers:r,injections:a}=e,i=async function(e,t){if("string"!=typeof e){const t=ua.get(e);if(t){const[n,r]=t;if(void 0!==r)throw r;e=n}else{let t=fa.get(e);t||(t=new Promise(((t,n)=>{fa.set(e,[t,n])}))),e=await t}}return import(e).catch((()=>{throw new TypeError(`Notebook '${t}' failed to load`)}))}(t,n).then((({default:e})=>{if(this._generation!==o)throw new Error("redefined");const t=es.module(e);return a?t.derive(Array.from(Sa(a)),ts):t}));for(const e of Sa(r))this._secondaries.push(ts.define(e.alias,["@variable"],(async t=>t.import(e.name,e.alias,await i))));this._variable.define((async()=>function({specifier:e,specifiers:t,notebook:n},r){const a=document.createElement("span");a.className="observablehq--inspect observablehq--import",a.appendChild(document.createTextNode("import {"));let o=!1;for(const{imported:e,local:i}of t){o?a.appendChild(document.createTextNode(", ")):o=!0;const t=document.createElement("a");r._scope.has(e)?n&&(t.href=new URL(`#${e}`,n)):t.className="observablehq--unknown",t.textContent=e,a.appendChild(t),e!==i&&a.appendChild(document.createTextNode(` as ${i}`))}if(a.appendChild(document.createTextNode("}")),n){a.appendChild(document.createTextNode(" from "));const t=a.appendChild(document.createElement("a"));t.href=new URL(n),t.textContent=`"${e}"`}return a}(e,await i)));break}case"viewof":{const{name:t,inputs:n,body:r}=e,a=`viewof ${t}`;this._variable.define(a,n,ra(r,this.id)),this._secondaries.push(ts.define(t,["Generators",a],Ca));break}case"mutable":{const{name:t,inputs:n,body:r}=e,a=`initial ${t}`,o=`mutable ${t}`;this._secondaries.push(ts.define(a,n,ra(r,this.id)),ts.define(o,["Mutable",a],Aa)),this._variable.define(t,[o],Na);break}default:{const{name:t,inputs:n,body:r}=e;this._variable.define(t,n,ra(r,this.id));break}}}function Ta(){for(const e of this._secondaries)e.delete();this._secondaries.length=0,this._variable.delete(),this.fileAttachments=new Set,this.mode=void 0}function Ca(e,t){return e.input(t)}function Aa(e,t){return new e(t)}function Na(e){return e.generator}function*Sa(e){for(const t of e)yield{name:t.imported,alias:t.local},t.view?yield{name:`viewof ${t.imported}`,alias:`viewof ${t.local}`}:t.mutable&&(yield{name:`mutable ${t.imported}`,alias:`mutable ${t.local}`})}function xa(){for(const e of ya)e.remove("observablehq--changed");ya=void 0}function Ma(e,t){wa||(wa=new Map,setTimeout(Oa,50)),wa.set(e,t?function({message:e,stack:t,input:n,name:r}){return{message:e,stack:t,input:n,name:r}}(t):null)}function Oa(){ba({type:"errors",errors:wa}),wa=void 0}let $a;function ja({currentUser:e}){$a&&$a(e)}const ka={number:[/^(small)int(\(|$)/,/^(small|big)?serial(\(|$)/,"integer","decimal","numeric","real","double precision","number"],string:[/^(var)?char(\(|$)/,"character","text","bigint"],boolean:["boolean"],date:["time","interval","date"],array:["array"]},qa={number:[/^(tiny|small|medium)?int(\(|$)/,"integer","decimal","numeric","float","double"],string:[/^(var)?char(\(|$)/,/^(tiny|medium|long)?text(\(|$)/,"enum","bigint"],boolean:[/^bool(ean)?(\(|$)/],date:["date","time","year"]},La={number:[/^(small|tiny)?int(\(|$)/,"float","numeric","decimal","real"],string:[/^(var|nvar|n)?char(\(|$)/,/^(n)?text(\(|$)/,"character","text","bigint"],date:[/^(small)?date(timeoffset|time2|time)?/],boolean:["bit"],array:[]},Ra={number:[/^(small|tiny)?int(\(|$)/,"float","number","decimal","real"],string:[/^(var|nvar|n)?char(\d|\(|$)/,/^(n)?text(\(|$)/,"character","text","bigint"],date:[/^(small)?date(timeoffset|time2|time)?/,/^timestamp*.+/],boolean:[],array:[]},Da={number:[/^(small|tiny)?int(\(|$)/,"float","double","decimal","numeric","exact numeric","integral numeric","binary floating point"],string:["string","bigint"],boolean:["boolean"],date:["date","timestamp","date-time","interval"],array:["array"]},Ua={number:[/^number(\(|$)/,"decimal","numeric",/^(big|small|tiny|byte)?int$/,"float","float4","float8","double","double precision","real"],string:["varchar","char","character","nchar","string","text","nvarchar","nvarchar2","char varying","nchar varying"],boolean:["boolean"],date:["date","datetime","time","timestamp","timestamp_ltz","timestamp_ntz","timestamp_tz"],array:["array"]};function Pa(e,t){let n;switch(t){case"databricks":n=Object.entries(Da);break;case"mongosql":case"mysql":n=Object.entries(qa);break;case"mssql":n=Object.entries(La);break;case"oracle":n=Object.entries(Ra);break;case"postgres":case"bigquery":n=Object.entries(ka);break;case"snowflake":n=Object.entries(Ua);break;default:return"other"}e=e.toLowerCase();for(const[t,r]of n)for(const n of r)if(new RegExp(n).test(e))return t;return"other"}const Ia=new Date,Fa=new Date;function Ba(e,t,n,r){function a(t){return e(t=0===arguments.length?new Date:new Date(+t)),t}return a.floor=t=>(e(t=new Date(+t)),t),a.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),a.round=e=>{const t=a(e),n=a.ceil(e);return e-t<n-e?t:n},a.offset=(e,n)=>(t(e=new Date(+e),null==n?1:Math.floor(n)),e),a.range=(n,r,o)=>{const i=[];if(n=a.ceil(n),o=null==o?1:Math.floor(o),!(n<r&&o>0))return i;let s;do{i.push(s=new Date(+n)),t(n,o),e(n)}while(s<n&&n<r);return i},a.filter=n=>Ba((t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)}),((e,r)=>{if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););})),n&&(a.count=(t,r)=>(Ia.setTime(+t),Fa.setTime(+r),e(Ia),e(Fa),Math.floor(n(Ia,Fa))),a.every=e=>(e=Math.floor(e),isFinite(e)&&e>0?e>1?a.filter(r?t=>r(t)%e==0:t=>a.count(0,t)%e==0):a:null)),a}const za=Ba((()=>{}),((e,t)=>{e.setTime(+e+t)}),((e,t)=>t-e));za.every=e=>(e=Math.floor(e),isFinite(e)&&e>0?e>1?Ba((t=>{t.setTime(Math.floor(t/e)*e)}),((t,n)=>{t.setTime(+t+n*e)}),((t,n)=>(n-t)/e)):za:null);const Ha=1e3,Ya=6e4,Wa=36e5,Va=864e5,Ja=6048e5,Ga=2592e6,Ka=31536e6,Za=Ba((e=>{e.setTime(e-e.getMilliseconds())}),((e,t)=>{e.setTime(+e+t*Ha)}),((e,t)=>(t-e)/Ha),(e=>e.getUTCSeconds())),Xa=Ba((e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Ha)}),((e,t)=>{e.setTime(+e+t*Ya)}),((e,t)=>(t-e)/Ya),(e=>e.getMinutes())),Qa=Ba((e=>{e.setUTCSeconds(0,0)}),((e,t)=>{e.setTime(+e+t*Ya)}),((e,t)=>(t-e)/Ya),(e=>e.getUTCMinutes())),eo=Ba((e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Ha-e.getMinutes()*Ya)}),((e,t)=>{e.setTime(+e+t*Wa)}),((e,t)=>(t-e)/Wa),(e=>e.getHours())),to=Ba((e=>{e.setUTCMinutes(0,0,0)}),((e,t)=>{e.setTime(+e+t*Wa)}),((e,t)=>(t-e)/Wa),(e=>e.getUTCHours())),no=Ba((e=>e.setHours(0,0,0,0)),((e,t)=>e.setDate(e.getDate()+t)),((e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Ya)/Va),(e=>e.getDate()-1));Ba((e=>{e.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCDate(e.getUTCDate()+t)}),((e,t)=>(t-e)/Va),(e=>e.getUTCDate()-1));const ro=Ba((e=>{e.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCDate(e.getUTCDate()+t)}),((e,t)=>(t-e)/Va),(e=>Math.floor(e/Va)));function ao(e){return Ba((t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)}),((e,t)=>{e.setDate(e.getDate()+7*t)}),((e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Ya)/Ja))}const oo=ao(0);function io(e){return Ba((t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCDate(e.getUTCDate()+7*t)}),((e,t)=>(t-e)/Ja))}ao(1),ao(2),ao(3),ao(4),ao(5),ao(6);const so=io(0);io(1),io(2),io(3),io(4),io(5),io(6);const co=Ba((e=>{e.setDate(1),e.setHours(0,0,0,0)}),((e,t)=>{e.setMonth(e.getMonth()+t)}),((e,t)=>t.getMonth()-e.getMonth()+12*(t.getFullYear()-e.getFullYear())),(e=>e.getMonth())),lo=Ba((e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)}),((e,t)=>t.getUTCMonth()-e.getUTCMonth()+12*(t.getUTCFullYear()-e.getUTCFullYear())),(e=>e.getUTCMonth())),uo=Ba((e=>{e.setMonth(0,1),e.setHours(0,0,0,0)}),((e,t)=>{e.setFullYear(e.getFullYear()+t)}),((e,t)=>t.getFullYear()-e.getFullYear()),(e=>e.getFullYear()));uo.every=e=>isFinite(e=Math.floor(e))&&e>0?Ba((t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)}),((t,n)=>{t.setFullYear(t.getFullYear()+n*e)})):null;const fo=Ba((e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)}),((e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)}),((e,t)=>t.getUTCFullYear()-e.getUTCFullYear()),(e=>e.getUTCFullYear()));function mo(e,t,n,r,a,o){const i=[[Za,1,Ha],[Za,5,5e3],[Za,15,15e3],[Za,30,3e4],[o,1,Ya],[o,5,3e5],[o,15,9e5],[o,30,18e5],[a,1,Wa],[a,3,108e5],[a,6,216e5],[a,12,432e5],[r,1,Va],[r,2,1728e5],[n,1,Ja],[t,1,Ga],[t,3,7776e6],[e,1,Ka]];function s(t,n,r){const a=Math.abs(n-t)/r,o=Et((([,,e])=>e)).right(i,a);if(o===i.length)return e.every(Lt(t/Ka,n/Ka,r));if(0===o)return za.every(Math.max(Lt(t,n,r),1));const[s,c]=i[a/i[o-1][2]<i[o][2]/a?o-1:o];return s.every(c)}return[function(e,t,n){const r=t<e;r&&([e,t]=[t,e]);const a=n&&"function"==typeof n.range?n:s(e,t,n),o=a?a.range(e,+t+1):[];return r?o.reverse():o},s]}fo.every=e=>isFinite(e=Math.floor(e))&&e>0?Ba((t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),((t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)})):null;const[ho,po]=mo(fo,lo,so,ro,to,Qa);mo(uo,co,oo,no,eo,Xa);var bo=function e(t){function n(e,n){return arguments.length<2&&(n=e,e=0),e=Math.floor(e),n=Math.floor(n)-e,function(){return Math.floor(t()*n+e)}}return n.source=e,n}(Math.random);const yo=1664525,wo=1013904223,vo=1/4294967296;const go=0,_o=1,Eo=2;function To(e,t){return new Map(Co(e).map((n=>[n.name,{...n,...Oo(e,n.name,!!t,t&&t.get(n.name)?t.get(n.name).type:n.type,t&&t.get(n.name)?.bins)}])))}function Co(e){return Rn(e).schema.map((({name:e,type:t,databaseType:n,nullable:r,inferred:a})=>({name:e,type:t,databaseType:n,nullable:r,inferred:a})))}const Ao=100,No=20,So=.7;function xo(e,t,n,r){if(e.length<No)return e.map((e=>e[t]?.length)).sort(((e,t)=>t-e))[Math.floor(e.length*So)];const a=bo.source(function(e=Math.random()){let t=0|(0<=e&&e<1?e/vo:Math.abs(e));return()=>(t=yo*t+wo|0,vo*(t>>>0))}(.04032017))(No,e.length);let o=e.slice(0,No).map((e=>e[t]?.length));for(let i=0;i<Math.min(n,e.length-No);i++){const n="date"===r?H(e[Math.floor(a())][t])?.length:e[Math.floor(a())][t]?.length;o.push(n||0)}return o.sort(((e,t)=>t-e))[Math.floor(o.length*So)]}const Mo=new WeakMap;function Oo(e,t,n,r,a){const o=!e||"boolean"!=typeof e.done||e.done;Mo.has(e)||Mo.set(e,new Map);const i=Mo.get(e),s=kn(r);switch(r){case"date":case"integer":case"number":case"bigint":{let{nRows:c,min:l,max:u,missing:f,values:d,histogram:m}=i.get(t)??{nRows:0,min:1/0,max:-1/0,missing:0,values:[],histogram:void 0},h=!m;for(let n=c;n<e.length;++n){const a=e[n][t];if(s(a,r)){if(d.push(Number(a)),a<l&&(l=a),a>u&&(u=a),!h){const e=m?.find((({x1:e,x2:t})=>e<=a&&t>a));void 0===e?h=!0:e.count++}}else f++}if(h){const e=Dt();if(a?.length>0)e.domain([a[0],a[a.length-1]]),e.thresholds((()=>a));else{const t="date"===r?10:15,n=d.length<t?d.length:t;if("date"===r&&l!==u){const t=po(l,u,n);if(t?.range){const n=t.floor(l),r=t.ceil(new Date(+u+1)),a=t.range(n,r).map((e=>+e));e.thresholds(a).domain([+n,+r])}else e.thresholds(n)}else e.thresholds(n)}m=e(d).map((e=>({x1:e.x0,x2:e.x1,count:e.length}))).filter((e=>void 0!==e.x1))}i.set(t,{nRows:e.length,min:l,max:u,missing:f,values:d,histogram:m});const p=[...m];let b;return o&&n&&"date"===r&&(b=xo(e,t,Ao,r)),{data:p,min:p.length?p[0].x1:l,max:p.length?p[p.length-1].x2:u,numMissing:f,type:r,nRows:e.length,summaryType:"continuous",...b?{maxLength:b}:{}}}default:{const{counted:a,single:c,nRows:l}=i.get(t)??{counted:new Map([[_o,0]]),single:new Set,nRows:0};for(let n=l;n<e.length;++n){const o=e[n][t],i=["object","buffer","array","other"].includes(r)?s(o,r)?r:_o:"raw"===r?"raw":s(o,r)?o:_o;a.has(i)?a.set(i,a.get(i)+1):c.has(i)?(a.set(i,2),c.delete(i)):c.add(i)}i.set(t,{counted:a,single:c,nRows:e.length});const u=[];for(const[e,t]of a)e!==_o&&u.push({value:e,count:t});u.sort(((e,t)=>t.count-e.count||gt(e.value,t.value))),c.size>0&&u.push({value:1===c.size?c.values().next().value:Eo,count:c.size}),a.get(_o)>0&&u.push({value:_o,count:a.get(_o)});let f=0;const d=u.map((({value:t,count:n})=>({label:t===_o?`invalid ${r}`:t===Eo?`${c.size.toLocaleString("en-US")} unique value${1===c.size?"":"s"}`:t,categoryType:t===_o||t===Eo?t:go,count:n,x1:f/e.length,x2:(f+=n)/e.length}))),m=c.size+a.size-(0===a.get(_o)?1:0);let h;return o&&n&&(h=xo(e,t,Ao)),{data:d,numCategories:m,isUnique:c.size===e.length,type:r,nRows:e.length,summaryType:"categorical",...h?{maxLength:h}:{}}}}}function $o(e,t){return"string"===e&&"date"===t||"object"===e&&"buffer"===t?t:e}function jo(e){return"array"!==e?.type||"object"!==e.items?.type||void 0===e.items.properties?[]:Object.entries(e.items.properties).map((([e,{type:t,...n}])=>{const{type:r,nullable:a}=function(e){let t,n;return Array.isArray(e)?(t=e.find((e=>"null"!==e))??"other",n=e.some((e=>"null"===e))):(t=e,n=!1),{type:t,nullable:n}}(t);let o;for(const e in n)if(!0===n[e]){o=e;break}return{name:e,type:$o(r,o),nullable:a,...o&&{databaseType:o}}}))}function ko(e){return new RegExp(`(?:^|[^\\p{L}-])${function(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}(e)}`,"iug")}let qo="";const Lo=new WeakMap;async function Ro({id:e,node_id:t,operations:n,start:r,end:a,search:o}){const i=us(t),s=i.error();if(void 0!==s)return void ba({id:e,value:{rows:[],searchInfo:null,error:`${s.name}: ${s.message}`}});const c=i.value(),l=Po(c),u=Array.from(l.summaries.keys()),{filter:f,sort:d}=n;let m=Pn(c,{filter:f??[],sort:d??[],slice:{from:null,to:null},select:{columns:u}}),h={};if(o){if(h=o===qo?Lo.get(m):void 0,void 0===h){const e=[],t=function(e,t){return n=>{const r=`${n}`.split(/\s+/g).filter((e=>e)).map(ko);return(n,a)=>{const o=new Map;for(const t of r){const r=new Map;for(const a of e){if("string"!=typeof n[a])continue;let e;for(;null!=(e=t.exec(n[a]));){const n=r.get(a)??[];r.set(a,[...n,[e.index,t.lastIndex]])}}if(0===r.size)return!1;for(const[e,t]of r){const n=o.get(e)??[];o.set(e,[...n,...t])}}return t.push({index:a,matches:Array.from(o.entries())}),!0}}}(u,e);h={rows:m.filter(t(o)),info:e},Lo.set(m,h),qo=o}m=h.rows}m=m.slice(r,a);try{ba({id:e,value:{rows:Io(m,l.summaries),searchInfo:h.info,error:c.error?`${c.error.name}: ${c.error.message}`:void 0}})}catch(s){ba({id:e,error:s.message})}}async function Do({id:e,node_id:t,filters:n}){const r=us(t).value();try{const t=function(e,t){const n=Po(e);if(!t)return n;const r=Pn(e,{filter:t,slice:{from:null,to:null},select:{columns:null},sort:[]}),a=new Map(Array.from(n.summaries).map((([e,t])=>[e,{type:t.type,..."continuous"===t.summaryType&&{bins:t.data.map((e=>e.x1)).concat(t.data[t.data.length-1]?.x2)}}])));return{summaries:To(r,a),nRows:r.length,ready:n.ready}}(r,n);ba({id:e,value:{columns:t.summaries,nRows:t.nRows,ready:t.ready}})}catch(t){ba({id:e,error:t.message})}}const Uo=new WeakMap;function Po(e){if(!Xt(e))throw new Error("invalid table data");let t=Uo.get(e);if(void 0===t||t.nRows!=e.length){t={summaries:To(e),nRows:e.length,ready:!e||"boolean"!=typeof e.done||e.done},Uo.set(e,t)}return t}function Io(e,t){return e.map((e=>Object.fromEntries(Array.from(t.keys(),(t=>[t,Fo(e,t)])))))}function Fo(e,t){try{let n=e[t];switch(typeof n){case"boolean":case"undefined":case"number":case"bigint":case"string":return n;case"function":case"symbol":return String(n)}return null===n||n instanceof Date?n:(n instanceof ArrayBuffer&&(n=new Uint8Array(n)),n instanceof Array||"function"==typeof n[Symbol.iterator]&&(n=[...n]),JSON.stringify(n))}catch{return new Error}}const Bo=new Map,zo=new Map,Ho=1e4;async function Yo(e){if(!e)throw new Error("Database not found");const t=zo.get(e);if(t){if(t.exp>=Date.now()+Ho)return t;zo.delete(e)}const n=Bo.get(e);if(n)return n.promise;let r,a;const o=new Promise(((e,t)=>(r=e,a=t)));return Bo.set(e,{promise:o,resolve:r,reject:a}),ba({type:"request_database_token",name:e}),o}function Wo(e,t){zo.get(e)===t&&zo.delete(e)}function DatabaseClient(e){if(void 0===new.target)return Yo(e+="").then((({type:t})=>{switch(t){case"bigquery":t=BigQueryDatabaseClient;break;case"databricks":t=DatabricksDatabaseClient;break;case"mongosql":t=MongoSQLDatabaseClient;break;case"mysql":t=MySQLDatabaseClient;break;case"mssql":t=MsSQLDatabaseClient;break;case"oracle":t=OracleDatabaseClient;break;case"postgres":t=PostgreSQLDatabaseClient;break;case"snowflake":t=SnowflakeDatabaseClient;break;default:throw new Error("Unsupported database type")}return new t(e)}));if(new.target===DatabaseClient)throw new TypeError("DatabaseClient is not a constructor");Object.defineProperties(this,{name:{value:e,enumerable:!0}})}Object.defineProperties(DatabaseClient.prototype,{query:{value:async function(e,t,{signal:n}={}){const r=await Yo(this.name),a=await fetch(`${r.origin}/query`,{method:"POST",headers:{Authorization:`Bearer ${r.token}`,"Content-Type":"application/json"},body:JSON.stringify({sql:e,params:t}),signal:n});if(!a.ok){if(401===a.status)throw Wo(this.name,r),new Error("Unauthorized: invalid or expired token. Try again?");const e=a.headers.get("content-type");throw new Error(e&&e.startsWith("application/json")?(await a.json()).message:await a.text())}const{data:o,schema:i}=await a.json(),s=jo(i);s&&(!function(e,t){ri(e)(t)}(s,o),Object.defineProperty(o,"schema",{value:s,writable:!0}));return o},writable:!0,configurable:!0},queryStream:{value:async function(e,t,{signal:n}={}){const r=await Yo(this.name);try{const a=await fetch(`${r.origin}/query-stream`,{method:"POST",headers:{Authorization:`Bearer ${r.token}`,"Content-Type":"application/json"},body:JSON.stringify({sql:e,params:t}),signal:n});if(!a.ok){if(401===a.status)throw Wo(this.name,r),new Error("Unauthorized: invalid or expired token. Try again?");const e=a.headers.get("content-type");throw new Error(e&&e.startsWith("application/json")?(await a.json()).message:await a.text())}const o=async function*(e){const t=e.body.getReader(),n=new TextDecoder("utf-8");let r="",a=0,o=Vo;for(;;){const{value:e,done:i}=await t.read(),s=Date.now();if(e){if(r+=n.decode(e,{stream:!0}),r.length<o&&s<a)continue;a=s+Ko,o<Go&&(o*=Jo)}if(r){const e=r.split("\n");r=e.pop(),yield e.filter(Boolean).map(JSON.parse)}if(i)break}if(r)return JSON.parse(r)}(a);let i=await o.next();for(;!i.done&&0===i.value.length;)i=await o.next();if("schema"in i.value&&"data"in i.value){const e=jo(i.value.schema);return{schema:e,async*readRows(){const t=ri(e);yield t(i.value.data)}}}const{value:[s,...c]}=i,l=jo(s);return{schema:l,async*readRows(){const e=ri(l);c.length&&(yield e(c));for await(const t of o)yield e(t)}}}catch(e){if(n?.aborted)return{schema:void 0,async*readRows(){throw e}};throw e}},writable:!0,configurable:!0},queryTag:{value:function(e,...t){return[e.join("?"),t]},writable:!0,configurable:!0},queryRow:{value:async function(...e){return(await this.query(...e))[0]||null},writable:!0,configurable:!0},sql:{value:async function(){return this.query(...this.queryTag.apply(this,arguments))},writable:!0,configurable:!0},escape:{value:function(e){return`"${e.replaceAll('"','""')}"`},writable:!0}});const Vo=65536,Jo=1.5,Go=1048576,Ko=15e3;class BigQueryDatabaseClient extends DatabaseClient{async describeColumns({database:e,schema:t,table:n}={}){if(!n)throw new Error("BigQuery: table name must be specified in describeColumns");let r="";if(null!=e&&(r=`${this.escape(e)}.`),null!=t&&(r+=this.escape(t)),!r)throw new Error("BigQuery: either the database (project id) or schema (dataset id) must be specified in describeColumns");return(await this.query(`SELECT c.column_name, c.data_type, c.is_nullable\nFROM ${r}.INFORMATION_SCHEMA.COLUMNS c\nWHERE c.table_name = ?\nORDER BY c.ordinal_position`,[n])).map((({column_name:e,data_type:t,is_nullable:n})=>({name:e,type:Pa(t,this.dialect),databaseType:t,nullable:"YES"===n})))}escape(e){return`\`${e.replaceAll("`","``")}\``}}Object.defineProperty(BigQueryDatabaseClient.prototype,"dialect",{value:"bigquery"});class DatabricksDatabaseClient extends DatabaseClient{async query(e,t,n){const r=await this.queryStream(e,t,n),a=[];a.schema=r.schema;for await(const e of r.readRows())for(const t of e)a.push(t);return a}async describeTables(){const e=await Yo(this.name),t=await fetch(`${e.origin}/describe-tables`,{method:"POST",headers:{Authorization:`Bearer ${e.token}`,"Content-Type":"application/json"}});if(!t.ok){if(401===t.status)throw Wo(this.name,e),new Error("Unauthorized: invalid or expired token. Try again?");const n=t.headers.get("content-type");throw new Error(n&&n.startsWith("application/json")?(await t.json()).message:await t.text())}const n=await t.json();if(n)return Object.values(n).map((e=>({name:e.TABLE_NAME,schema:e.TABLE_SCHEM}))).sort(((e,t)=>{const n=`${e.schema}.${e.name}`.toUpperCase(),r=`${t.schema}.${t.name}`.toUpperCase();return n<r?-1:n>r?1:0}))}async describeColumns({table:e,schema:t}={}){if(null==e)throw new Error("missing table name");const n=await Yo(this.name),r=await fetch(`${n.origin}/describe-columns`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`,"Content-Type":"application/json"},body:JSON.stringify({table:e,schema:t})});if(!r.ok){if(401===r.status)throw Wo(this.name,n),new Error("Unauthorized: invalid or expired token. Try again?");const e=r.headers.get("content-type");throw new Error(e&&e.startsWith("application/json")?(await r.json()).message:await r.text())}const a=await r.json();if(a)return Object.values(a).map((e=>({name:e.COLUMN_NAME,type:Pa(e.TYPE_NAME,this.dialect),databaseType:e.TYPE_NAME,nullable:"YES"===e.IS_NULLABLE})))}escape(e){return`\`${e.replaceAll("`","``")}\``}queryTag(e,...t){return[e.reduce(((e,t,n)=>`${e}:${n}${t}`)),t]}}Object.defineProperty(DatabricksDatabaseClient.prototype,"dialect",{value:"databricks"});class PostgreSQLDatabaseClient extends DatabaseClient{async describe(e){return ai(await Zo.call(this,e))}async explain(e,t,n){return function(e){const t=document.createElement("pre");return t.className="observablehq--inspect",t.appendChild(document.createTextNode(e)),t}((await this.query(`EXPLAIN ANALYZE ${e}`,t,n)).map((e=>e["QUERY PLAN"])).join("\n"))}async describeTables({schema:e}={}){return await this.query(`SELECT\nNULLIF(table_schema, current_schema()) AS schema,\ntable_name AS name\nFROM information_schema.tables\nWHERE table_schema NOT IN ('pg_catalog', 'information_schema')\n${void 0===e?"":`AND table_schema = ${null===e?"current_schema()":"$1"}\n`}ORDER BY table_schema = current_schema() DESC, 1, 2`,null!=e?[e]:[])}async describeColumns({schema:e,table:t}={}){if(null==t)throw new Error("missing table name");return(await this.query(`SELECT c.column_name, c.data_type, c.is_nullable\nFROM information_schema.columns c\nWHERE c.table_name = $1\nAND c.table_schema = ${null!=e?"$2":"current_schema()"}\nORDER BY c.ordinal_position`,null!=e?[t,e]:[t])).map((({column_name:e,data_type:t,is_nullable:n})=>({name:e,type:Pa(t,this.dialect),databaseType:t,nullable:"YES"===n})))}queryTag(e,...t){return[e.reduce(((e,t,n)=>`${e}$${n}${t}`)),t]}}async function Zo(e){return await(void 0===e?this.query("SELECT table_schema, table_name\nFROM information_schema.tables\nWHERE table_schema NOT IN ('pg_catalog', 'information_schema')\nORDER BY 1, 2"):this.query("SELECT c.column_name, c.data_type, e.data_type AS element_type, c.column_default, c.is_nullable\nFROM information_schema.columns c\nLEFT JOIN information_schema.element_types e\n ON ((c.table_catalog, c.table_schema, c.table_name, 'TABLE', c.dtd_identifier)\n = (e.object_catalog, e.object_schema, e.object_name, e.object_type, e.collection_type_identifier))\nWHERE c.table_name = $1\nORDER BY c.ordinal_position",[e]))}Object.defineProperties(PostgreSQLDatabaseClient.prototype,{dialect:{value:"postgres",writable:!0,configurable:!0}});class MySQLDatabaseClient extends DatabaseClient{async describe(e){return ai(await Xo.call(this,e))}async describeTables(){return(await this.query("SHOW TABLES")).map((e=>({name:Object.values(e)[0]})))}async describeColumns({table:e}={}){if(null==e)throw new Error("missing table name");return(await this.query(`SHOW FULL COLUMNS FROM ${e}`)).map((({Field:e,Type:t,Null:n})=>({name:e,type:Pa(t,this.dialect),databaseType:t,nullable:"YES"===n})))}escape(e){return`\`${e.replaceAll("`","``")}\``}}async function Xo(e){return await this.query(void 0===e?"SHOW TABLES":`SHOW FULL COLUMNS FROM ${e}`)}Object.defineProperty(MySQLDatabaseClient.prototype,"dialect",{value:"mysql"});class MongoSQLDatabaseClient extends MySQLDatabaseClient{}Object.defineProperty(MongoSQLDatabaseClient.prototype,"dialect",{value:"mongosql"});class MsSQLDatabaseClient extends DatabaseClient{async query(e,t,n){const r=await this.queryStream(e,t,n),a=[];a.schema=r.schema;for await(const e of r.readRows())for(const t of e)a.push(t);return a}async describeTables({schema:e}={}){return await this.query(`SELECT\nNULLIF(TABLE_SCHEMA, SCHEMA_NAME()) AS "schema",\nTABLE_NAME AS name\nFROM INFORMATION_SCHEMA.TABLES\nWHERE TABLE_SCHEMA != 'dbo'\n${void 0===e?"":`AND TABLE_SCHEMA = ${null===e?"SCHEMA_NAME()":"@1"}\n`}ORDER BY 1, 2`,null!=e?[e]:[])}async describeColumns({schema:e,table:t}={}){if(null==t)throw new Error("missing table name");return(await this.query(`SELECT c.column_name, c.data_type, c.is_nullable\nFROM information_schema.columns c\nWHERE c.column_name != 'rowguid'\nAND c.table_name = @1\nAND c.table_schema = ${null!=e?"@2":"SCHEMA_NAME()"}\nORDER BY c.ordinal_position`,null!=e?[t,e]:[t])).map((({column_name:e,data_type:t,is_nullable:n})=>({name:e,type:Pa(t,this.dialect),databaseType:t,nullable:"YES"===n})))}queryTag(e,...t){return[e.reduce(((e,t,n)=>`${e}@${n}${t}`)),t]}}Object.defineProperty(MsSQLDatabaseClient.prototype,"dialect",{value:"mssql"});class SnowflakeDatabaseClient extends DatabaseClient{async describe(e){return ai(await this.query(void 0===e?"SHOW TABLES":`DESCRIBE TABLE ${e}`))}async describeTables({schema:e}={}){return await this.query(`SELECT\nNULLIF(table_schema, current_schema()) AS "schema",\ntable_name AS "name"\nFROM INFORMATION_SCHEMA.TABLES\nWHERE table_schema != 'INFORMATION_SCHEMA'\n${void 0===e?"":`AND table_schema = ${null===e?"current_schema()":"?"}\n`}ORDER BY table_schema = current_schema() DESC, 1, 2`,null!=e?[e]:[])}async describeColumns({schema:e,table:t}={}){if(null==t)throw new Error("missing table name");return(await this.query(`SELECT column_name, data_type, is_nullable\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE table_name = ?\nAND table_schema = ${null!=e?"?":"current_schema()"}\nORDER BY ordinal_position`,null!=e?[t,e]:[t])).map((({COLUMN_NAME:e,DATA_TYPE:t,IS_NULLABLE:n})=>({name:e,databaseType:t,type:Pa(t,this.dialect),nullable:"YES"===n})))}async explain(e,t){return ai(await this.query(`EXPLAIN ${e}`,t))}}Object.defineProperty(SnowflakeDatabaseClient.prototype,"dialect",{value:"snowflake"});class OracleDatabaseClient extends DatabaseClient{async query(e,t,n){const r=await this.queryStream(e,t,n),a=[];a.schema=r.schema;for await(const e of r.readRows())for(const t of e)a.push(t);return a}async describeTables({schema:e}={}){return await this.query(`SELECT\nNULLIF(OWNER, sys_context('USERENV', 'CURRENT_SCHEMA')) AS "schema",\nTABLE_NAME AS "name"\nFROM ALL_TABLES\nWHERE TABLESPACE_NAME NOT IN ('SYSAUX', 'SYSTEM', 'UNDOTBS1', 'TEMP')\n${void 0===e?"":`AND OWNER = ${null===e?"sys_context('USERENV', 'CURRENT_SCHEMA')":":schema"}\n`}\nORDER BY CASE WHEN "schema" IS NULL THEN 0 ELSE 1 END, 1, 2`,null!=e?[e]:[])}async describeColumns({schema:e,table:t}={}){if(null==t)throw new Error("missing table name");return(await this.query(`SELECT COLUMN_NAME, DATA_TYPE, NULLABLE\nFROM ALL_TAB_COLUMNS\nWHERE OWNER = ${null!=e?":0":"sys_context('USERENV', 'CURRENT_SCHEMA')"}\nAND TABLE_NAME = :${null!=e?"1":"0"}\nORDER BY COLUMN_ID`,null!=e?[e,t]:[t])).map((({COLUMN_NAME:e,DATA_TYPE:t,NULLABLE:n})=>({name:e,databaseType:t,type:Pa(t,this.dialect),nullable:"Y"===n})))}queryTag(e,...t){return[e.reduce(((e,t,n)=>`${e}:${n}${t}`)),t]}}function Qo(e){return Uint8Array.from(e.data).buffer}function ei(e){return new Date(e)}function ti(e){return BigInt(e)}function ni(e){return+e}function ri(e){const t=e.map((({name:e,type:t})=>{switch(t){case"buffer":return[e,Qo];case"date":return[e,ei];case"bigint":return[e,ti];case"integer":case"number":return[e,ni]}})).filter((e=>e));return e=>{for(const[n,r]of t)for(const t of e)null!=t[n]&&(t[n]=r(t[n]));return e}}function ai(e){if(!e.length)throw new Error("Not found");const t=document.createElement("table"),n=t.appendChild(document.createElement("thead")).appendChild(document.createElement("tr"));for(const{name:t}of e.schema)n.appendChild(document.createElement("th")).appendChild(document.createTextNode(t));const r=t.appendChild(document.createElement("tbody"));for(const t of e){const e=r.appendChild(document.createElement("tr"));for(const n of Object.values(t))e.appendChild(document.createElement("td")).appendChild(document.createTextNode(n))}return t.value=e,t}Object.defineProperty(OracleDatabaseClient.prototype,"dialect",{value:"oracle"});const oi="http://www.w3.org/2000/xmlns/",ii="http://www.w3.org/1999/xlink",si="http://www.w3.org/2000/svg",ci=.75,li=50;let ui=0;const fi=50;function di(e){if(++ui>fi)return!1;const t=typeof e,n=null==e||"number"===t||"string"===t||"boolean"===t||"toJSON"in e||hi(e)||mi(e);return--ui,n}function mi(e){if(null==e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);if(t!==Object.prototype&&null!==t&&"[object Row]"!==Object.prototype.toString.call(e))return!1;let n=0;for(const t of Object.values(e)){if("function"===typeof t)return!1;if(!di(t))return!1;if(++n>=li)break}return!0}function hi(e){if(!Array.isArray(e))return!1;let t=0;for(const n of e){if(!di(n))return!1;if(++t>=li)break}return!0}function pi(e){try{return null==e?void 0:yi(e)?{type:"svg"}:e instanceof HTMLCanvasElement?{type:"canvas"}:e instanceof HTMLStyleElement?{type:"css"}:e instanceof HTMLElement?{type:"html"}:e instanceof Blob?{type:"blob",mime:e.type}:function(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)?{type:"typedarray"}:function(e){if(!Array.isArray(e))return!1;let t=0;for(const n of e){let e=null;if(Array.isArray(n))e=n;else{if(!mi(n))return!1;e=Object.values(n)}let r=0;for(const t of e){const e=typeof t;if(null!=t&&"string"!==e&&"number"!==e&&"boolean"!==e&&!(t instanceof Date))return!1;if(++r>=li)break}if(++t>=li)break}return!0}(e)?{type:"csv"}:hi(e)?{type:"array"}:mi(e)?{type:"object"}:function(e){if(e instanceof Map){let t=0;for(const n of e.keys()){const r=typeof n;if("number"!==r&&"string"!==r)return!1;if(!di(e.get(n)))return!1;if(++t>=li)break}return!0}return!1}(e)?{type:"map"}:function(e){if(e instanceof Set){let t=0;for(const n of e.values()){if(!di(n))return!1;if(++t>=li)break}return!0}return!1}(e)?{type:"set"}:"string"==typeof e?{type:"string"}:void 0}catch{}finally{ui=0}}function bi(e,t){const n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return r.width/n.width>=ci||r.height/n.height>=ci}function yi(e){if(e instanceof SVGSVGElement)return e;if(e instanceof Element)for(const t of e.querySelectorAll("svg"))if(bi(e,t))return t;return null}async function wi(e,t,n){let r;switch(t){case"svg":return"svg"===n?async function(e){e=e.cloneNode(!0);const t=location.href+"#",n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;n.nextNode();){const e=n.currentNode;for(const n of e.attributes)n.value.includes(t)&&(n.value=n.value.replace(t,"#"))}e.setAttributeNS(oi,"xmlns",si),e.setAttributeNS(oi,"xmlns:xlink",ii);const r=(new XMLSerializer).serializeToString(e);return new Blob([r],{type:"image/svg+xml"})}(yi(e)):vi(e);case"canvas":return gi(e);case"html":return vi(e);case"blob":return e;case"css":return new Blob([e.textContent.trim()],{type:"text/css"});case"string":return new Blob([e],{type:"text/plain"});case"csv":if("csv"===n){const t=Array.isArray(e[0])?_e(e):ge(e);return new Blob([t],{type:"text/csv"})}r=e;break;case"map":case"set":case"typedarray":r=Array.from(e);break;case"array":case"object":r=e}return new Blob([JSON.stringify(r)],{type:"application/json"})}async function vi(e){return"IMG"===e.nodeName?async function(e){await e.decode();const t=await fetch(e.currentSrc);if(!t.ok)throw new Error("unable to load image");return t.blob()}(e):gi(await async function(e){if("CANVAS"===e.nodeName)return e;const{toCanvas:t}=await import("https://cdn.observableusercontent.com/npm/[email protected]/+esm");let n;"static"===getComputedStyle(e).position&&(n=e.style.cssText,"svg"!==e.nodeName&&(e.style.maxWidth="max-content",e.style.maxHeight="fit-content"),e.style.margin=0,e.style.display="block",e.style.padding="16px",e.style.overflow="hidden");try{return await t(e,{pixelRatio:2,fontEmbedCSS:"",backgroundColor:_i(e)})}finally{void 0!==n&&(e.style=n)}}(e))}async function gi(e){return new Promise((t=>e.toBlob(t)))}function _i(e){do{const{backgroundColor:t}=getComputedStyle(e);if("rgba(0, 0, 0, 0)"!==t)return t}while(e=e.parentElement);return"#fff"}const Ei=["slack","email"],Ti=new Map,Ci=new Set;let Ai=0;const Ni=[],Si=new Map;function xi(e,t,n){if(Ni.filter((e=>e>Date.now()-6e4)).length>20)throw new Error("too many notification requests");Ni.push(Date.now());const r=++Ai,a=Si.get(r);if(a)return a.promise;let o,i;const s=new Promise(((e,t)=>(o=e,i=t)));return Si.set(r,{promise:s,resolve:o,reject:i}),ba({type:"request_notification",requestId:r,provider:e,address:t,content:n}),s}function Mi(e){return 1===e.length&&Object.getPrototypeOf(e[0])===Object.prototype}class SlackNotificationClient{constructor(e){if(!e)throw new Error("must specify address: 'slack:#random'");this.address=e}async send(...e){if(Mi(e)){const t=e[0];if(!t.items?.length&&!t.blocks?.length)throw new Error("Options object must have either items or blocks array. To send object as JSON attachment, wrap it as {items: [object]}");e=t.blocks?t.blocks.map((e=>({type:"slackBlock",block:e}))):await $i(t.items)}else e=await $i(e);return xi("slack",this.address,e)}}class EmailNotificationClient{constructor(e){if(!e)throw new Error("must specify address: 'email:[email protected]'");this.addresses=e.split(",")}async send(...e){if(Mi(e)){const t=e[0];if(!t.items?.length)throw new Error("Options object must have items array. To send object as JSON attachment, wrap it as {items: [object]}");e=t.items}if(e=(await $i(e)).map((e=>{if("text"===e.type)return e;const{blob:t,...n}=e;return n})),new Blob([JSON.stringify(e)]).size>1e6)throw new Error("email contents must be less than 1 MB");return xi("email",this.addresses.join(","),e)}}const Oi=["svg","canvas","css","html","blob","typedarray","csv","array","object","map","set"];async function $i(e,t=Oi){if(!e.length||e.every((e=>""===e||void 0===e)))throw new Error("content is empty");return Promise.all(e.map((async(e,n)=>{const{type:r,mime:a=""}=pi(e)||{};if(t.includes(r)){const t="svg"===r?"png":"csv"===r?"csv":a,o="blob"===r?e:await async function(e,t,n){const r=e instanceof Node&&!e.isConnected;try{return r&&document.body.append(e),await wi(e,t,n)}finally{r&&e.remove()}}(e,r,t);return{type:"attachment",blob:o,mimeType:o.type,name:`file${n}.${ki(o.type)}`,url:await ji(o)}}return{type:"text",text:"string"===r?e:JSON.stringify(e,null," ")}})))}async function ji(e){return new Promise((t=>{const n=new FileReader;n.onloadend=()=>t(n.result),n.readAsDataURL(e)}))}function ki(e){switch(e){case"image/png":return"png";case"image/jpeg":return"jpg";case"image/gif":return"gif";case"image/bmp":return"bmp";case"application/json":return"json";case"application/x-sqlite3":return"db";case"application/zip":return"zip";case"text/css":return"css";case"text/csv":return"csv";case"text/plain":return"txt";case"text/html":return"html";case"text/javascript":return"js";case"audio/mpeg":return"mp3";case"video/mp4":return"mp4";case"text/tab-separated-values":return"tsv"}return""}const qi=new Map,Li=new Map,Ri=new Set,Di=new Map,Ui=new Set,Pi=new Set;function Ii(e){const{name:t,cloud:n,privateBucketId:r}=e;if(qi.has(t))throw new Error("duplicate file");Bi(e),n&&Ui.add(t),r&&Pi.add(t)}function Fi(e){const{name:t}=e;if(!qi.has(t))throw new Error("unknown file");Bi(e)}function Bi(e){let{name:t,blob:n,url:r,mimeType:a}=e;void 0!==n&&(r=URL.createObjectURL(n),Ri.add(r)),zi(t,r),Li.set(t,a)}function zi(e,t){if(qi.set(e,t),void 0!==t){const n=Di.get(e);n&&(n.resolve(t),Di.delete(e))}}function Hi({name:e}){if(!qi.has(e))throw new Error("unknown file");const t=qi.get(e);Ri.has(t)&&URL.revokeObjectURL(t),qi.delete(e),Ui.delete(e),Li.delete(e);const n=Di.get(e);n&&(n.reject(new Error(`File not found: ${e}`)),Di.delete(e))}var Yi=Vr.prototype.fileAttachments((e=>{if(e+="",!qi.has(e))return;const t=qi.get(e),n=Li.get(e);if(void 0!==t&&!Pi.has(e))return{url:t,mimeType:n};let r;const a=Di.get(e);if(a)r=a.promise;else{let t,n;r=new Promise(((e,r)=>(t=e,n=r))),Di.set(e,{promise:r,resolve:t,reject:n}),Ui.has(e)&&ba({type:"request_cloud_file",name:e}),Pi.has(e)&&ba({type:"request_private_file",name:e})}return{url:r,mimeType:n}}));let Wi,Vi;function Ji(e){if(new.target===Ji)throw new TypeError("Secret is not a constructor");if(void 0===Wi)throw new Error("Secrets are only available in private notebooks");if(!Wi.has(e+=""))throw new Error("Secret not found");return Wi.get(e)}function Gi({delay:e}){void 0===Wi&&(Wi=new Map);const t=es._builtin._scope.get("Secret"),n=e?new Promise((e=>Vi=e)):Promise.resolve(Ji);t._promise=n,t._definition=()=>n,ts._scope.delete("Secret")}const Ki=document.createElement("div");Ki.className="observablehq-root",document.body.appendChild(Ki);const Zi=document.createElement("div");Zi.className="observablehq-end",Ki.appendChild(Zi);const Xi="https://cdn.observableusercontent.com/npm/";_r.require=_r.requireFrom(_r.resolveFrom(Xi));const Qi=new _r,es=new Vr(Object.assign(Qi,{currentUser:function(){const e=new Promise((e=>$a=e));return ba({type:"current_user"}),e.then((e=>{if(void 0===e)throw new Error("currentUser is only available in unpublished team notebooks");return e}))},__chart:Promise.resolve((function(e,t,n,r,a){const{markOptions:{...o},...i}=e.autoSpec(n,r);ws(o.x)&&(o.x=i.x.value);ws(o.y)&&(o.y=i.y.value);ws(o.r)&&(o.r=i.size.value);ws(o[i.colorMode])&&(o[i.colorMode]=i.color.value||i.color.color);const s={...i,markOptions:o};return ns.get(t).currentChartSpec=s,e.auto(n,s).plot(a)})),Secret:Promise.resolve(Ji),DatabaseClient:Promise.resolve(DatabaseClient),NotificationClient:Promise.resolve((async function NotificationClient(e){const[t,n]=e.split(":");if(!Ei.includes(t))throw new Error(`Unsupported provider: ${t}`);try{await async function(e){if(!e)throw new Error("Notification specifier not found");if(Ci.has(e))return!0;const t=Ti.get(e);if(t)return t.promise;let n,r;const a=new Promise(((e,t)=>(n=e,r=t)));return Ti.set(e,{promise:a,resolve:n,reject:r}),ba({type:"request_notification_client",specifier:e}),a}(e)}catch(e){throw new Error(e.message)}if(void 0===new.target)switch(t){case"slack":return new SlackNotificationClient(n);case"email":return new EmailNotificationClient(n)}else if(new.target===NotificationClient)throw new TypeError("NotificationClient is not a constructor")}))})),ts=es.module(),ns=new Map;function rs({node_id:e,new_node_value:t,new_next_node_id:n,new_node_mode:r,new_node_data:a,hidden:o}){if(ns.has(e))throw new Error("duplicate node");const i=new(o?ga:_a)(e);ns.set(e,i),o||is({node_id:e,new_next_node_id:n}),i.define(t,r,a)}function as({node_id:e,new_node_value:t,new_node_mode:n,new_node_data:r}){us(e).define(t,n,r)}function os({node_id:e,new_node_data:t}){us(e).preferDisplay(t)}function is({node_id:e,new_next_node_id:t}){const n=us(e);if(null===t)Ki.insertBefore(n.node,Zi);else{const e=us(t);Ki.insertBefore(n.node,e.node)}}function ss({node_id:e}){const t=us(e),n=t.node;t.dispose(),ns.delete(e),Ki.removeChild(n)}function cs({node_id:e,height:t}){const n=ns.get(e);if(n)n.offset(t);else if(0!==t)throw new Error("node not found")}function ls({name:e}){for(const t of ns.values())t.fileAttachments.has(e)&&t.run()}function us(e){const t=ns.get(e);if(!t)throw new Error("node not found");return t}ts.builtin("FileAttachment",Yi);const fs=500,ds=3e4;function ms(e=fs){let t;return[new Promise(((n,r)=>{t=setTimeout((()=>r(new Error("timeout"))),e)})),()=>clearTimeout(t)]}async function hs(e,t){if(e._name&&(void 0===e._value||!e._reachable||isNaN(e._indegree))){let n;void 0===t&&([t,n]=ms());try{return await Promise.race([ts.value(e._name),t])}catch(e){return}finally{n?.()}}return e._value}async function ps({name:e,type:t}){switch(t){case"cell":{const t=ts._scope.get(e);if(!t)throw new Error(`${e} is not defined`);const[n,r]=ms(ds);try{return await hs(t,n)}finally{r()}}case"FileAttachment":return Yi(e);case"database":case"DatabaseClient":return DatabaseClient(e)}throw new Error(`invalid data source type: ${t}`)}async function bs(e,t){const n="cell"===e.type?e.name:void 0;return await async function(e,t,n){switch(t){case"chart":return ln(e);case"table":return un(e,n);case"sql":return fn(e,n)}return e}(await ps(e),t,n)}function ys({name:e,mimeType:t}){switch(t){case"application/x-sqlite3":return"sqlite";case"text/csv":return"csv";case"text/tab-separated-values":return"tsv";case"application/json":return"json";default:if(/\.arrow$/i.test(e))return"arrow";if(/\.parquet$/i.test(e))return"parquet"}}function ws(e){return null!=e&&"object"==typeof e}const vs=new Set(Object.getOwnPropertyNames(Object.prototype));async function gs({variable:e,paths:t}){if("Plot"===e||"d3"===e)return[];let n=await hs(ts._resolve(e));if(null==n)return[];for(let e=t.length-1;e>=0;e--){const r=t[e],a=Object.getOwnPropertyDescriptor(n,r)||Object.getOwnPropertyDescriptor(Object.getPrototypeOf(n),r);if(!a||a.get)return[];n=n[r]}return function(e){const t=new Set;for(;null!==e;){for(const n of Object.getOwnPropertyNames(e))/^[a-z]/i.test(n)&&!vs.has(n)&&t.add(n);e=Object.getPrototypeOf(e)}return t}(n)}const _s=Symbol();function Es({pathname:e,search:t,hash:n}){document.querySelector("base").href=`${da}${e}${t}${n}`;const r=location.hash;history.replaceState({},"",new URL(t+n,location)),r!==n&&dispatchEvent(new HashChangeEvent("hashchange"))}function Ts(e){if(!e.isTrusted||e.defaultPrevented||e.button&&0!==e.button||e.ctrlKey||e.metaKey||e.altKey||e.shiftKey)return;const t=e.target.closest("a[href]");if(!t)return;let n;if(t[_s]&&(n=t.getAttribute("href"),t.setAttribute("href",t[_s]),delete t[_s]),function(e){if(!e.hash&&"#"!==e.href.slice(-1))return!1;const t=new URL(document.baseURI);return e.pathname===t.pathname&&e.search===t.search}(t)){let e=new URLSearchParams(location.search);return e.delete("key"),ba({type:"page_url",pathname:location.pathname,search:e.toString(),hash:t.hash}),void(n&&setTimeout((()=>{t[_s]=t.getAttribute("href"),t.setAttribute("href",n)}),10))}if("https:"!==t.protocol||t.origin!==da||"classic"===new URLSearchParams(t.search).get("ui")||t.target&&"_top"!==t.target||t.hasAttribute("download"))return;let r=t.pathname;e.preventDefault(),ba({type:"navigate",pathname:r,search:t.search,hash:t.hash})}addEventListener("keydown",(function(e){"Escape"!==e.key||e.altKey||e.metaKey||e.ctrlKey||ba({type:"escape"})}),!0),addEventListener("message",(function(e){if(!e.isTrusted||e.origin!==da||e.source!==ma)return;e.stopImmediatePropagation();const t=e.data;if("bundle"!==t.type)switch(t.type){case"autocomplete":!async function({id:e,variable:t,paths:n}){ba({id:e,value:await gs({variable:t,paths:n})})}(t);break;case"blur":!function(){getSelection()?.removeAllRanges()}();break;case"extract_title":!async function({id:e,node_id:t}){const n=us(t);await n.resolve();const r=n.node.querySelector("h1");ba({id:e,value:r?r.textContent:""})}(t);break;case"resolve_import":!function({id:e,module:t,error:n}){ua.set(e,[t,n]);const r=fa.get(e);if(!r)return;fa.delete(e);const[a,o]=r;void 0===n?a(t):o(new TypeError(n))}(t);break;case"current_user":ja(t);break;case"resolve_secrets":!function({secrets:e}){for(const[t,n]of e)Wi.set(t,n);Vi&&Vi(Ji)}(t);break;case"resolve_database_token":!function({error:e,name:t,token:n}){const{resolve:r,reject:a}=Bo.get(t);Bo.delete(t),void 0===e?(n={origin:"https://connector.observableusercontent.com",...JSON.parse(atob(n.split(".")[0])),token:n},zo.set(t,n),r(n)):a(new Error(e))}(t);break;case"resolve_cloud_file":!function({name:e,url:t,error:n}){if(!qi.has(e))throw new Error("unknown file");if(void 0!==n){const t=Di.get(e);t&&t.reject(new Error(n))}else zi(e,t)}(t);break;case"resolve_private_file":!function({name:e,error:t}){const n=Di.get(e);if(void 0!==t)n&&n.reject(new Error(t));else{const t=qi.get(e);if(!t&&n)n.reject(new Error("Unable to access file"));else if(!t)throw new Error("Unable to access file");zi(e,t)}}(t);break;case"resolve_notification_client":!function({error:e,specifier:t}){const{resolve:n,reject:r}=Ti.get(t);Ti.delete(t),void 0===e?(Ci.add(t),n(!0)):r(new Error(e))}(t);break;case"resolve_notification":!function({requestId:e,error:t,status:n}){const{resolve:r,reject:a}=Si.get(e);Si.delete(e),void 0===t?r(n):a(new Error(t))}(t);break;case"request_download_type":!function({id:e,node_id:t}){const n=us(t);ba({id:e,value:{type:pi(n.value()),typeAsView:pi(n.valueAsView())}})}(t);break;case"request_download":!async function({id:e,node_id:t,as_view:n,download_type:r,format:a}){try{const o=us(t),i=n?o.valueAsView():o.value();ba({id:e,value:await wi(i,r,a)})}catch(t){console.error(t),ba({id:e,error:t.message})}}(t);break;case"request_data_sources":!async function({id:e,mode:t}){const[n,r]=ms(ds);await Promise.allSettled(Array.from(ts._scope).filter((([,e])=>1===e._type)).map((async([r,a])=>[r,await hs(a,n).then((n=>{"sql"!==t&&"table"!==t||!Zt(n,t)?!Xt(n)||"chart"===t&&nn(n)?"chart"!==t&&It(n)?ba({id:e,value:{name:r,dialect:"arrow"}}):"chart"!==t&&Pt(n)&&ba({id:e,value:{name:r,dialect:"arquero"}}):ba({id:e,value:{name:r,dialect:"array"}}):ba({id:e,value:{name:r,dialect:n.dialect}})}))]))),r(),ba({id:e,done:!0})}(t);break;case"request_database_tables":!async function({id:e,source:t,schema:n}){try{const r=await bs(t,"sql");if(!Zt(r))throw new Error("invalid data source");ba({id:e,value:await r.describeTables(n)})}catch(t){ba({id:e,error:String(t)})}}(t);break;case"request_table_schema":!async function({id:e,source:t,table:n,mode:r,node_id:a,derive:o}){try{const i=await bs(t,r);if(Zt(i))ba({id:e,value:await i.describeColumns(n)});else{if(!Xt(i))throw new Error("invalid data source");{const t=void 0!==a?us(a).value():void 0;let n;n=t&&t.fullSchema?t.fullSchema:Co(i).concat(o?.map((({name:e})=>({name:e,type:"other"})))??[]),ba({id:e,value:n})}}}catch(t){ba({id:e,error:String(t)})}}(t);break;case"request_database_query":!async function({id:e,source:t,operations:n}){try{const r=await bs(t,"sql");ba({id:e,value:await hn(n,r)})}catch(t){ba({id:e,error:String(t)})}}(t);break;case"request_database_info":!async function({id:e,source:t}){try{const n=await ps(t);if(n instanceof Yi){const t=ys(n);if(!t)throw new Error(`unsupported file type: ${n.mimeType}`);ba({id:e,value:{hasDescribeTables:!0,hasDescribeColumns:!0,dialect:t}})}else if(It(n))ba({id:e,value:{hasDescribeTables:!0,hasDescribeColumns:!0,dialect:"arrow"}});else if(Xt(n))ba({id:e,value:{hasDescribeTables:!0,hasDescribeColumns:!0,dialect:"array"}});else if(Pt(n))ba({id:e,value:{hasDescribeTables:!0,hasDescribeColumns:!0,dialect:"arquero"}});else{if(!Zt(n))throw new Error("invalid data source");ba({id:e,value:{hasDescribeTables:"function"==typeof n.describeTables,hasDescribeColumns:"function"==typeof n.describeColumns,dialect:n.dialect}})}}catch(t){ba({id:e,error:String(t)})}}(t);break;case"request_data_source_info":!async function({id:e,source:t}){try{const n=await ps(t);ba(n instanceof Yi?{id:e,value:{dialect:ys(n)}}:{id:e,value:{dialect:Xt(n)?"array":It(n)?"arrow":Pt(n)?"arquero":n.dialect}})}catch(t){ba({id:e,error:String(t)})}}(t);break;case"request_value":!async function({id:e,node_id:t}){const n=us(t);try{ba({id:e,value:n.value()})}catch(t){ba({id:e,error:t.message})}}(t);break;case"request_table_rows":Ro(t);break;case"request_table_summary":Do(t);break;case"allow_internal_navigation":addEventListener("click",Ts);break;default:console.warn("unknown message",t)}else{const{events:e}=t;for(const t of e)switch(t.type){case"insert_node":rs(t);break;case"mode_node":case"modify_node":case"modify_data":case"modify_name":as(t);break;case"modify_display":os(t);break;case"move_node":is(t);break;case"remove_node":ss(t);break;case"offset_node":cs(t);break;case"insert_file":Ii(t),ls(t);break;case"modify_file":Fi(t);break;case"remove_file":Hi(t),ls(t);break;case"reset_secret":Gi(t);break;case"current_user":ja(t);break;case"navigate":Es(t);break;default:console.warn("unknown event",t)}}}),!0),ba({type:"hello"});