diff --git a/src/execute/ojs/compile.ts b/src/execute/ojs/compile.ts index 0e85261792..6d2bbd63fc 100644 --- a/src/execute/ojs/compile.ts +++ b/src/execute/ojs/compile.ts @@ -81,6 +81,8 @@ import { getDivAttributes } from "../../core/handlers/base.ts"; import { pathWithForwardSlashes } from "../../core/path.ts"; import { executeInlineCodeHandlerMapped } from "../../core/execute-inline.ts"; +import { encodeBase64 } from "encoding/base64.ts"; + export interface OjsCompileOptions { source: string; format: Format; @@ -816,7 +818,7 @@ export async function ojsCompile( // script to append const afterBody = [ ``, `")) doc.blocks:insert(div) end diff --git a/src/resources/formats/html/ojs/quarto-ojs-runtime.js b/src/resources/formats/html/ojs/quarto-ojs-runtime.js index 3998bd783e..0145e3de7e 100644 --- a/src/resources/formats/html/ojs/quarto-ojs-runtime.js +++ b/src/resources/formats/html/ojs/quarto-ojs-runtime.js @@ -19202,6 +19202,17 @@ class ModuleParser extends CellParser { /* Fork changes end here */ +// https://developer.mozilla.org/en-US/docs/Glossary/Base64 + +function base64ToBytes(base64) { + const binString = atob(base64); + return Uint8Array.from(binString, (m) => m.codePointAt(0)); +} + +function base64ToStr(base64) { + return new TextDecoder().decode(base64ToBytes(base64)); +} + /*global Shiny, $, DOMParser, MutationObserver, URL * * ojs-connector.js @@ -19500,18 +19511,19 @@ function importPathResolver(paths, localResolverMap) { }; } + function createOjsModuleFromHTMLSrc(text) { const parser = new DOMParser(); const doc = parser.parseFromString(text, "text/html"); const staticDefns = []; for (const el of doc.querySelectorAll('script[type="ojs-define"]')) { - staticDefns.push(el.text); + staticDefns.push(base64ToStr(el.text)); } const ojsSource = []; for ( const content of doc.querySelectorAll('script[type="ojs-module-contents"]') ) { - for (const cell of JSON.parse(content.text).contents) { + for (const cell of JSON.parse(base64ToStr(content.text)).contents) { ojsSource.push(cell.source); } } @@ -22922,7 +22934,7 @@ function displayOJSWarning(warning) for ( const content of document.querySelectorAll('script[type="ojs-module-contents"]') ) { - for (const cellJson of JSON.parse(content.text).contents) { + for (const cellJson of JSON.parse(base64ToStr(content.text)).contents) { let cell = document.getElementById(cellJson.cellName) || document.getElementById(`${cellJson.cellName}-1`); if (!cell) { // give up @@ -23932,7 +23944,7 @@ function createRuntime() { for (const el of document.querySelectorAll( "script[type='ojs-module-contents']" )) { - for (const call of JSON.parse(el.text).contents) { + for (const call of JSON.parse(base64ToStr(el.text)).contents) { let source = window._ojs.isDashboard ? autosizeOJSPlot(call.source, call.cellName) : call.source; switch (call.methodName) { case "interpret": diff --git a/src/resources/formats/html/ojs/quarto-ojs-runtime.min.js b/src/resources/formats/html/ojs/quarto-ojs-runtime.min.js index ea7e42fc24..8921bcb7b9 100644 --- a/src/resources/formats/html/ojs/quarto-ojs-runtime.min.js +++ b/src/resources/formats/html/ojs/quarto-ojs-runtime.min.js @@ -1,6 +1,6 @@ var e={},t={};function i(e){return new Function("d","return {"+e.map((function(e,t){return JSON.stringify(e)+": d["+t+'] || ""'})).join(",")+"}")}function n(e){var t=Object.create(null),i=[];return e.forEach((function(e){for(var n in e)n in t||i.push(t[n]=n)})),i}function s(e,t){var i=e+"",n=i.length;return n9999?"+"+s(t,6):s(t,4))+"-"+s(e.getUTCMonth()+1,2)+"-"+s(e.getUTCDate(),2)+(a?"T"+s(i,2)+":"+s(n,2)+":"+s(r,2)+"."+s(a,3)+"Z":r?"T"+s(i,2)+":"+s(n,2)+":"+s(r,2)+"Z":n||i?"T"+s(i,2)+":"+s(n,2)+"Z":"")}function a(s){var a=new RegExp('["'+s+"\n\r]"),o=s.charCodeAt(0);function u(i,n){var s,r=[],a=i.length,u=0,c=0,p=a<=0,l=!1;function h(){if(p)return t;if(l)return l=!1,e;var n,s,r=u;if(34===i.charCodeAt(r)){for(;u++=a?p=!0:10===(s=i.charCodeAt(u++))?l=!0:13===s&&(l=!0,10===i.charCodeAt(u)&&++u),i.slice(r+1,n-1).replace(/""/g,'"')}for(;u`${e}@${t}/${n}`}}const g=m("d3","7.8.5","dist/d3.min.js"),v=m("@observablehq/inputs","0.10.6","dist/inputs.min.js"),x=m("@observablehq/plot","0.6.11","dist/plot.umd.min.js"),y=m("@observablehq/graphviz","0.2.1","dist/graphviz.min.js"),b=m("@observablehq/highlight.js","2.0.0","highlight.min.js"),E=m("@observablehq/katex","0.11.1","dist/katex.min.js"),C=m("lodash","4.17.21","lodash.min.js"),D=m("htl","0.3.1","dist/htl.min.js"),A=m("jszip","3.10.1","dist/jszip.min.js"),w=m("marked","0.3.12","marked.min.js"),F=m("sql.js","1.8.0","dist/sql-wasm.js"),k=m("vega","5.22.1","build/vega.min.js"),S=m("vega-lite","5.6.0","build/vega-lite.min.js"),_=m("vega-lite-api","5.0.0","build/vega-lite-api.min.js"),B=m("apache-arrow","4.0.1","Arrow.es2015.min.js"),I=m("apache-arrow","9.0.0","+esm"),P=m("apache-arrow","11.0.0","+esm"),N=m("arquero","4.8.8","dist/arquero.min.js"),T=m("topojson-client","3.1.0","dist/topojson-client.min.js"),L=m("exceljs","4.3.0","dist/exceljs.min.js"),V=m("mermaid","9.2.2","dist/mermaid.min.js"),R=m("leaflet","1.9.3","dist/leaflet.js"),O=m("@duckdb/duckdb-wasm","1.24.0","+esm"),M=new Map,j=[],q=j.map,U=j.some,z=j.hasOwnProperty,W=/^((?:@[^/@]+\/)?[^/@]+)(?:@([^/]+))?(?:\/(.*))?$/,H=/^\d+\.\d+\.\d+(-[\w-.+]+)?$/,G=/(?:\.[^/]*|\/)$/;class RequireError extends Error{constructor(e){super(e)}}function Q(e){const t=W.exec(e);return t&&{name:t[1],version:t[2],path:t[3]}}function K(e="https://cdn.jsdelivr.net/npm/",t=["unpkg","jsdelivr","browser","main"]){if(!/\/$/.test(e))throw new Error("origin lacks trailing slash");function i(t){const i=`${e}${t.name}${t.version?`@${t.version}`:""}/package.json`;let n=M.get(i);return n||M.set(i,n=fetch(i).then((e=>{if(!e.ok)throw new RequireError("unable to load package.json");return e.redirected&&!M.has(e.url)&&M.set(e.url,n),e.json()}))),n}return async function(n,s){if(n.startsWith(e)&&(n=n.substring(e.length)),/^(\w+:)|\/\//i.test(n))return n;if(/^[.]{0,2}\//i.test(n))return new URL(n,null==s?location:s).href;if(!n.length||/^[\s._]/.test(n)||/\s$/.test(n))throw new RequireError("illegal name");const r=Q(n);if(!r)return`${e}${n}`;if(!r.version&&null!=s&&s.startsWith(e)){const t=await i(Q(s.substring(e.length)));r.version=t.dependencies&&t.dependencies[r.name]||t.peerDependencies&&t.peerDependencies[r.name]}if(r.path&&!G.test(r.path)&&(r.path+=".js"),r.path&&r.version&&H.test(r.version))return`${e}${r.name}@${r.version}/${r.path}`;const a=await i(r);return`${e}${a.name}@${a.version}/${r.path||function(e){for(const i of t){let t=e[i];if("string"==typeof t)return t.startsWith("./")&&(t=t.slice(2)),G.test(t)?t:`${t}.js`}}(a)||"index.js"}`}}RequireError.prototype.name=RequireError.name;var Y=Z(K());let J,X=0;function Z(e){const t=new Map,i=s(null);function n(e){if("string"!=typeof e)return e;let i=t.get(e);return i||t.set(e,i=new Promise(((t,i)=>{const n=document.createElement("script");n.onload=()=>{try{t(j.pop()(s(e)))}catch(e){i(new RequireError("invalid module"))}n.remove(),X--,0===X&&(window.define=J)},n.onerror=()=>{i(new RequireError("unable to load module")),n.remove(),X--,0===X&&(window.define=J)},n.async=!0,n.src=e,0===X&&(J=window.define,window.define=ne),X++,document.head.appendChild(n)}))),i}function s(t){return i=>Promise.resolve(e(i,t)).then(n)}function r(e){return arguments.length>1?Promise.all(q.call(arguments,i)).then(ee):i(e)}return r.alias=function(t){return Z(((i,n)=>i in t&&(n=null,"string"!=typeof(i=t[i]))?i:e(i,n)))},r.resolve=e,r}function ee(e){const t={};for(const i of e)for(const e in i)z.call(i,e)&&(null==i[e]?Object.defineProperty(t,e,{get:te(i,e)}):t[e]=i[e]);return t}function te(e,t){return()=>e[t]}function ie(e){return"exports"===(e+="")||"module"===e}function ne(e,t,i){const n=arguments.length;n<2?(i=e,t=[]):n<3&&(i=t,t="string"==typeof e?[]:e),j.push(U.call(t,ie)?e=>{const n={},s={exports:n};return Promise.all(q.call(t,(t=>"exports"===(t+="")?n:"module"===t?s:e(t)))).then((e=>(i.apply(null,e),s.exports)))}:e=>Promise.all(q.call(t,e)).then((e=>"function"==typeof i?i.apply(null,e):i)))}ne.amd={};const se="https://cdn.observableusercontent.com/npm/";let re,ae=Y;async function oe(e){const[t,i]=await Promise.all([e(F.resolve()),e.resolve(F.resolve("dist/"))]);return t({locateFile:e=>`${i}${e}`})}class ue{constructor(e){Object.defineProperties(this,{_db:{value:e}})}static async open(e){const[t,i]=await Promise.all([oe(ae),Promise.resolve(e).then(pe)]);return new ue(new t.Database(i))}async query(e,t){return await async function(e,t,i){const[n]=await e.exec(t,i);if(!n)return[];const{columns:s,values:r}=n,a=r.map((e=>function(e){const t={};for(const[i,n]of e)t[i]=n;return t}(e.map(((e,t)=>[s[t],e])))));return a.columns=s,a}(this._db,e,t)}async queryRow(e,t){return(await this.query(e,t))[0]||null}async explain(e,t){return le("pre",{className:"observablehq--inspect"},[he((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 i=await this.query(`SELECT name, type, "notnull" FROM pragma_table_info(?${null==e?"":", ?"}) ORDER BY cid`,null==e?[t]:[t,e]);if(!i.length)throw new Error(`table not found: ${t}`);return i.map((({name:e,type:t,notnull:i})=>({name:e,type:ce(t),databaseType:t,nullable:!i})))}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:i}=t;return le("table",{value:t},[le("thead",[le("tr",i.map((e=>le("th",[he(e)]))))]),le("tbody",t.map((e=>le("tr",i.map((t=>le("td",[he(e[t])])))))))])}async sql(){return this.query(...this.queryTag.apply(this,arguments))}queryTag(e,...t){return[e.join("?"),t]}}function ce(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 pe(e){return"string"==typeof e?fetch(e).then(pe):e instanceof Response||e instanceof Blob?e.arrayBuffer().then(pe):e instanceof ArrayBuffer?new Uint8Array(e):e}function le(e,t,i){2===arguments.length&&(i=t,t=void 0);const n=document.createElement(e);if(void 0!==t)for(const e in t)n[e]=t[e];if(void 0!==i)for(const e of i)n.appendChild(e);return n}function he(e){return document.createTextNode(e)}function de(e,t){return null==e||null==t?NaN:et?1:e>=t?0:NaN}function fe(e,t){return null==e||null==t?NaN:te?1:t>=e?0:NaN}function me(e){let t,i,n;function s(e,n,s=0,r=e.length){if(s>>1;i(e[t],n)<0?s=t+1:r=t}while(sde(e(t),i),n=(t,i)=>e(t)-i):(t=e===de||e===fe?e:ge,i=e,n=e),{left:s,center:function(e,t,i=0,r=e.length){const a=s(e,t,i,r-1);return a>i&&n(e[a-1],t)>-n(e[a],t)?a-1:a},right:function(e,n,s=0,r=e.length){if(s>>1;i(e[t],n)<=0?s=t+1:r=t}while(s0:0===de(e,e))&&(i=r,s=e,n=!0)}}else for(const s of e)(n?t(s,i)>0:0===t(s,s))&&(i=s,n=!0);return i}function xe(e){return e&&"function"==typeof e.toArrowBuffer}function ye(e){return e&&"function"==typeof e.getChild&&"function"==typeof e.toArray&&e.schema&&Array.isArray(e.schema.fields)}function be(e){return{name:e.name,type:Ee(e.type),nullable:e.nullable,databaseType:String(e.type)}}function Ee(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 Ce(){return await import(`${se}${P.resolve()}`)}Object.defineProperty(ue.prototype,"dialect",{value:"sqlite"}),me(de),me((function(e){return null===e?NaN:+e})).center;class De{constructor(e){Object.defineProperties(this,{_db:{value:e}})}async queryStream(e,t){const i=await this._db.connect();let n,s;try{if(t?.length>0){const s=await i.prepare(e);n=await s.send(...t)}else n=await i.send(e);if(s=await n.next(),s.done)throw new Error("missing first batch")}catch(e){throw await i.close(),e}return{schema:(r=s.value,r.schema.fields.map(be)),async*readRows(){try{for(;!s.done;)yield s.value.toArray(),s=await n.next()}finally{await i.close()}}};var r}async query(e,t){const i=await this.queryStream(e,t),n=[];for await(const e of i.readRows())for(const t of e)n.push(t);return n.schema=i.schema,n}async queryRow(e,t){const i=(await this.queryStream(e,t)).readRows();try{const{done:e,value:t}=await i.next();return e||!t.length?null:t[0]}finally{await i.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:i})=>({name:e,type:ke(t),nullable:"NO"!==i,databaseType:t})))}static async of(e={},t={}){const i=await async function(){void 0===re&&(re=async function(){const e=await import(`${se}${O.resolve()}`),t=await e.selectBundle({mvp:{mainModule:`${se}${O.resolve("dist/duckdb-mvp.wasm")}`,mainWorker:`${se}${O.resolve("dist/duckdb-browser-mvp.worker.js")}`},eh:{mainModule:`${se}${O.resolve("dist/duckdb-eh.wasm")}`,mainWorker:`${se}${O.resolve("dist/duckdb-browser-eh.worker.js")}`}}),i=new e.ConsoleLogger;return{module:e,bundle:t,logger:i}}());const{module:e,bundle:t,logger:i}=await re,n=await e.createWorker(t.mainWorker),s=new e.AsyncDuckDB(i,n);return await s.instantiate(t.mainModule),s}();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 i.open(t),await Promise.all(Object.entries(e).map((async([e,t])=>{if(t instanceof Ct)await Ae(i,e,t);else if(ye(t))await we(i,e,t);else if(Array.isArray(t))await Fe(i,e,t);else if(xe(t))await async function(e,t,i){const n=(await Ce()).tableFromIPC(i.toArrowBuffer());return await we(e,t,n)}(i,e,t);else if("data"in t){const{data:n,...s}=t;ye(n)?await we(i,e,n,s):await Fe(i,e,n,s)}else{if(!("file"in t))throw new Error(`invalid source: ${t}`);{const{file:n,...s}=t;await Ae(i,e,n,s)}}}))),new De(i)}}async function Ae(e,t,i,n){const s=await i.url();if(s.startsWith("blob:")){const t=await i.arrayBuffer();await e.registerFileBuffer(i.name,new Uint8Array(t))}else await e.registerFileURL(i.name,s,4);const r=await e.connect();try{switch(i.mimeType){case"text/csv":case"text/tab-separated-values":return await r.insertCSVFromPath(i.name,{name:t,schema:"main",...n}).catch((async e=>{if(e.toString().includes("Could not convert"))return await async function(e,t,i){const n=await e.prepare(`CREATE TABLE '${i}' AS SELECT * FROM read_csv_auto(?, ALL_VARCHAR=TRUE)`);return await n.send(t.name)}(r,i,t);throw e}));case"application/json":return await r.insertJSONFromPath(i.name,{name:t,schema:"main",...n});default:if(/\.arrow$/i.test(i.name)){const e=new Uint8Array(await i.arrayBuffer());return await r.insertArrowFromIPCStream(e,{name:t,schema:"main",...n})}if(/\.parquet$/i.test(i.name))return await r.query(`CREATE VIEW '${t}' AS SELECT * FROM parquet_scan('${i.name}')`);throw new Error(`unknown file type: ${i.mimeType}`)}}finally{await r.close()}}async function we(e,t,i,n){const s=await e.connect();try{await s.insertArrowTable(i,{name:t,schema:"main",...n})}finally{await s.close()}}async function Fe(e,t,i,n){const s=(await Ce()).tableFromJSON(i);return await we(e,t,s,n)}function ke(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(De.prototype,"dialect",{value:"duckdb"});function Se(e){return Array.isArray(e)&&(_e(e.schema)||Be(e.columns)||function(e){const t=Math.min(20,e.length);for(let i=0;i0&&function(e){for(const t in e)return!0;return!1}(e[0])}(e)||Ne(e)||Te(e))||Le(e)}function _e(e){return Array.isArray(e)&&e.every(Ie)}function Be(e){return Array.isArray(e)&&e.every((e=>"string"==typeof e))}function Ie(e){return e&&"string"==typeof e.name&&"string"==typeof e.type}function Pe(e){return Le(e)||Ne(e)||Te(e)}function Ne(e){const t=Math.min(20,e.length);if(!(t>0))return!1;let i,n=!1;for(let s=0;s0))return!1;let i=!1;for(let n=0;n{if(e=await Oe(await e,n),(s=e)&&("function"==typeof s.sql||"function"==typeof s.queryTag&&("function"==typeof s.query||"function"==typeof s.queryStream))&&("table"!==r||"function"==typeof s.describeColumns)&&s!==Ve)return qe(e,function(e,t){const i="function"==typeof t.escape?t.escape:e=>e,{select:n,from:s,filter:r,sort:a,slice:o}=e;if(!s.table)throw new Error("missing from table");if(n.columns&&0===n.columns.length)throw new Error("at least one column must be selected");const u=new Map(e.names?.map((({column:e,name:t})=>[e,t]))),c=n.columns?n.columns.map((e=>{const t=u.get(e);return t?`${i(e)} AS ${i(t)}`:i(e)})).join(", "):"*",p=[[`SELECT ${c} FROM ${$e(s.table,i)}`]];for(let e=0;e{let a=[];pt(e,t).map(((e,t)=>{let i;try{i=r(e)}catch(e){a.push({index:t,error:e}),i=void 0}n[t]?n[t]={...n[t],[s]:i}:n.push({[s]:i})})),a.length&&i.set(s,a)}));const s=ct(n,t);e=e.map(((e,t)=>({...e,...s.source[t]}))),r=[...r,...s.schema]}for(const{type:i,operands:n}of t.filter){const[{value:t}]=n,s=n.slice(1).map((({value:e})=>e));switch(i){case"v":{const[i]=s,n=at(i);e=e.filter((e=>n(e[t])));break}case"nv":{const[i]=s,n=at(i);e=e.filter((e=>!n(e[t])));break}case"eq":{const[i]=s;if(i instanceof Date){const n=+i;e=e.filter((e=>+e[t]===n))}else e=e.filter((e=>e[t]===i));break}case"ne":{const[i]=s;e=e.filter((e=>e[t]!==i));break}case"c":{const[i]=s;e=e.filter((e=>"string"==typeof e[t]&&e[t].includes(i)));break}case"nc":{const[i]=s;e=e.filter((e=>"string"==typeof e[t]&&!e[t].includes(i)));break}case"in":{const i=new Set(s);e=e.filter((e=>i.has(e[t])));break}case"nin":{const i=new Set(s);e=e.filter((e=>!i.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[i]=s;e=e.filter((e=>e[t]e[t]<=i));break}case"gt":{const[i]=s;e=e.filter((e=>e[t]>i));break}case"gte":{const[i]=s;e=e.filter((e=>e[t]>=i));break}default:throw new Error(`unknown filter type: ${i}`)}}for(const{column:i,direction:s}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"===s?Ke:Qe;e===n&&(e=e.slice()),e.sort(((e,n)=>t(e[i],n[i])))}let{from:a,to:o}=t.slice;a=null==a?0:Math.max(0,a),o=null==o?1/0:Math.max(0,o),(a>0||o<1/0)&&(e=e.slice(Math.max(0,a),Math.max(0,o)));let u=r.slice();if(t.select.columns){if(r){const e=new Map(r.map((e=>[e.name,e])));r=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 i=new Map(t.names.map((e=>[e.column,e])));r&&(r=r.map((e=>{const t=i.get(e.name);return{...e,...t?{name:t.name}:null}}))),u&&(u=u.map((e=>{const t=i.get(e.name);return{...e,...t?{name:t.name}:null}}))),e=pt(e,t)}e!==n&&r&&(e.schema=r);return e.fullSchema=u,e.errors=i,e}(e,t);if(!e)throw new Error("missing data source");throw new Error("invalid data source")}),{sql:(e,t,i)=>async function(){return qe(await Me(await e,i),arguments,t)}});function Re(e){const t=new WeakMap;return(i,n)=>{if(!i||"object"!=typeof i)throw new Error("invalid data source");let s=t.get(i);return(!s||Se(i)&&i.length!==s._numRows)&&(s=e(i,n),s._numRows=i.length,t.set(i,s)),s}}const Oe=Re((async(e,t)=>{if(e instanceof Ct){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 je(e,t);throw new Error(`unsupported file type: ${e.mimeType}`)}return ye(e)||xe(e)?je(e,t):Se(e)&&Pe(e)?Array.from(e,(e=>({value:e}))):e})),Me=Re((async(e,t)=>{if(e instanceof Ct){switch(e.mimeType){case"text/csv":case"text/tab-separated-values":case"application/json":return je(e,t);case"application/x-sqlite3":return e.sqlite()}if(/\.(arrow|parquet)$/i.test(e.name))return je(e,t);throw new Error(`unsupported file type: ${e.mimeType}`)}return Se(e)?je(await async function(e,t){const i=await Ce();return Pe(e)?i.tableFromArrays({[t]:e}):i.tableFromJSON(e)}(e,t),t):ye(e)||xe(e)?je(e,t):e}));function je(e,t=(e instanceof Ct?function(e){return e.name.replace(/@\d+(?=\.|$)/,"").replace(/\.\w+$/,"")}(e):"__table")){return De.of({[t]:e})}async function qe(e,t,i){if(!e)throw new Error("missing data source");if("function"==typeof e.queryTag){const n=new AbortController,s={signal:n.signal};if(i.then((()=>n.abort("invalidated"))),"function"==typeof e.queryStream)return async function*(e){let t=performance.now();const i=await e,n=[];n.done=!1,n.error=null,n.schema=i.schema;try{for await(const e of i.readRows()){performance.now()-t>150&&n.length>0&&(yield n,t=performance.now());for(const t of e)n.push(t)}n.done=!0,yield n}catch(e){n.error=e,yield n}}(e.queryStream(...e.queryTag.apply(e,t),s));if("function"==typeof e.query)return e.query(...e.queryTag.apply(e,t),s)}if("function"==typeof e.sql)return e.sql.apply(e,t);throw new Error("source does not implement query, queryStream, or sql")}function $e(e,t){if("object"==typeof e){let i="";return null!=e.database&&(i+=t(e.database)+"."),null!=e.schema&&(i+=t(e.schema)+"."),i+=t(e.table),i}return t(e)}function Ue(e,t){const i=t[0];i[i.length-1]+=e}function ze({column:e,direction:t},i,n){Ue(`${n(e)} ${t.toUpperCase()}`,i)}function We({type:e,operands:t},i,n){if(t.length<1)throw new Error("Invalid operand length");if(1===t.length||"v"===e||"nv"===e)switch(He(t[0],i,n),e){case"n":case"nv":return void Ue(" IS NULL",i);case"nn":case"v":return void Ue(" IS NOT NULL",i);default:throw new Error("Invalid filter operation")}if(2!==t.length||["in","nin"].includes(e)){var s;switch(He(t[0],i,n),e){case"in":Ue(" IN (",i);break;case"nin":Ue(" NOT IN (",i);break;default:throw new Error("Invalid filter operation")}!function(e,t){let i=!0;for(const n of e)i?i=!1:Ue(",",t),t.push(n.value),t[0].push("")}(t.slice(1),i),Ue(")",i)}else{if(["c","nc"].includes(e)){switch(He(t[0],i,n),e){case"c":Ue(" LIKE ",i);break;case"nc":Ue(" NOT LIKE ",i)}return void He((s=t[1],{...s,value:`%${s.value}%`}),i,n)}switch(He(t[0],i,n),e){case"eq":Ue(" = ",i);break;case"ne":Ue(" <> ",i);break;case"gt":Ue(" > ",i);break;case"lt":Ue(" < ",i);break;case"gte":Ue(" >= ",i);break;case"lte":Ue(" <= ",i);break;default:throw new Error("Invalid filter operation")}He(t[1],i,n)}}function He(e,t,i){"column"===e.type?Ue(i(e.value),t):(t.push(e.value),t[0].push(""))}function Ge(e,t){return(null==e||!(e>=e))-(null==t||!(t>=t))}function Qe(e,t){return Ge(e,t)||(et?1:0)}function Ke(e,t){return Ge(e,t)||(e>t?-1:e"number"==typeof e&&!Number.isNaN(e),Je=e=>Number.isInteger(e)&&!Number.isNaN(e),Xe=e=>"string"==typeof e,Ze=e=>"boolean"==typeof e,et=e=>"bigint"==typeof e,tt=e=>e instanceof Date&&!isNaN(e),it=e=>e instanceof ArrayBuffer,nt=e=>Array.isArray(e),st=e=>"object"==typeof e&&null!==e,rt=e=>null!=e;function at(e){switch(e){case"string":return Xe;case"bigint":return et;case"boolean":return Ze;case"number":return Ye;case"integer":return Je;case"date":return tt;case"buffer":return it;case"array":return nt;case"object":return st;default:return rt}}const ot=/^(([-+]\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 ut(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(ot.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 ct(e,t){const i=e;let{schema:n,inferred:s}=function(e){const{columns:t}=e;let{schema:i}=e;return _e(i)?{schema:i,inferred:!1}:(i=dt(e,Be(t)?t:void 0),{schema:i,inferred:!0})}(e);const r=new Map(n.map((({name:e,type:t})=>[e,t])));if(t.types){for(const{name:e,type:s}of t.types){r.set(e,s),n===i.schema&&(n=n.slice());const t=n.findIndex((t=>t.name===e));t>-1&&(n[t]={...n[t],type:s})}e=e.map((e=>lt(e,r,n)))}else s&&(e=e.map((e=>lt(e,r,n))));return{source:e,schema:n}}function pt(e,t){if(!t.names)return e;const i=new Map(t.names.map((e=>[e.column,e])));return e.map((e=>Object.fromEntries(Object.keys(e).map((t=>[i.get(t)?.name??t,e[t]])))))}function lt(e,t,i){const n={};for(const s of i){const i=t.get(s.name),r=e[s.name];n[s.name]="raw"===i?r:ut(r,i)}return n}const ht=["boolean","integer","number","date","bigint","array","object","buffer"];function dt(e,t=function(e){const t=new Set;for(const i of e)if(i)for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&t.add(e);return Array.from(t)}(e)){const i=[],n=e.slice(0,100);for(const e of t){const t={boolean:0,integer:0,number:0,date:0,string:0,array:0,object:0,bigint:0,buffer:0,defined:0};for(const i of n){let n=i[e];if(null==n)continue;const s=typeof n;if("string"!==s)++t.defined,Array.isArray(n)?++t.array:n instanceof Date?++t.date:n instanceof ArrayBuffer?++t.buffer:"number"===s?(++t.number,Number.isInteger(n)&&++t.integer):s in t&&++t[s];else{if(n=n.trim(),!n)continue;++t.defined,++t.string,/^(true|false)$/i.test(n)?++t.boolean:n&&!isNaN(n)?(++t.number,Number.isInteger(+n)&&++t.integer):ot.test(n)&&++t.date}}const s=Math.max(1,.9*t.defined),r=ve(ht,(e=>t[e]>=s?t[e]:NaN))??(t.string>=s?"string":"other");i.push({name:e,type:r,inferred:r})}return i}class ft{constructor(e){Object.defineProperties(this,{_:{value:e},sheetNames:{value:e.worksheets.map((e=>e.name)),enumerable:!0}})}sheet(e,t){const i="number"==typeof e?this.sheetNames[e]:this.sheetNames.includes(e+="")?e:null;if(null==i)throw new Error(`Sheet not found: ${e}`);return function(e,{range:t,headers:i}={}){let[[n,s],[r,a]]=function(e=":",{columnCount:t,rowCount:i}){if(!(e+="").match(/^[A-Z]*\d*:[A-Z]*\d*$/))throw new Error("Malformed range specifier");const[[n=0,s=0],[r=t-1,a=i-1]]=e.split(":").map(xt);return[[n,s],[r,a]]}(t,e);const o=i?e._rows[s++]:null;let u=new Set(["#"]);for(let e=n;e<=r;e++){const t=o?mt(o.findCell(e+1)):null;let i=t&&t+""||vt(e);for(;u.has(i);)i+="_";u.add(i)}u=new Array(n).concat(Array.from(u));const c=new Array(a-s+1);for(let t=s;t<=a;t++){const i=c[t-s]=Object.create(null,{"#":{value:t+1}}),a=e.getRow(t+1);if(a.hasValues)for(let e=n;e<=r;e++){const t=mt(a.findCell(e+1));null!=t&&(i[u[e+1]]=t)}}return c.columns=u.filter((()=>!0)),c}(this._.getWorksheet(i),t)}}function mt(e){if(!e)return;const{value:t}=e;if(t&&"object"==typeof t&&!(t instanceof Date)){if(t.formula||t.sharedFormula)return t.result&&t.result.error?NaN:t.result;if(t.richText)return gt(t);if(t.text){let{text:e}=t;return e.richText&&(e=gt(e)),t.hyperlink&&t.hyperlink!==e?`${t.hyperlink} ${e}`:e}return t}return t}function gt(e){return e.richText.map((e=>e.text)).join("")}function vt(e){let t="";e++;do{t=String.fromCharCode(64+(e%26||26))+t}while(e=Math.floor((e-1)/26));return t}function xt(e){const[,t,i]=e.match(/^([A-Z]*)(\d*)$/);let n=0;if(t)for(let e=0;e[e,t])));return Object.assign(e.map((e=>lt(e,i,t))),{schema:t})}(e,dt(e,e.columns))}return r(s,n&&d)}class Et{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 yt(this)).blob()}async arrayBuffer(){return(await yt(this)).arrayBuffer()}async text(){return(await yt(this)).text()}async json(){return(await yt(this)).json()}async stream(){return(await yt(this)).body}async csv(e){return bt(this,",",e)}async tsv(e){return bt(this,"\t",e)}async image(e){const t=await this.url();return new Promise(((i,n)=>{const s=new Image;new URL(t,document.baseURI).origin!==new URL(location).origin&&(s.crossOrigin="anonymous"),Object.assign(s,e),s.onload=()=>i(s),s.onerror=()=>n(new Error(`Unable to load file: ${this.name}`)),s.src=t}))}async arrow({version:e=4}={}){switch(e){case 4:{const[e,t]=await Promise.all([ae(B.resolve()),yt(this)]);return e.Table.from(t)}case 9:{const[e,t]=await Promise.all([import(`${se}${I.resolve()}`),yt(this)]);return e.tableFromIPC(t)}case 11:{const[e,t]=await Promise.all([import(`${se}${P.resolve()}`),yt(this)]);return e.tableFromIPC(t)}default:throw new Error(`unsupported arrow version: ${e}`)}}async sqlite(){return ue.open(yt(this))}async zip(){const[e,t]=await Promise.all([ae(A.resolve()),this.arrayBuffer()]);return new wt(await e.loadAsync(t))}async xml(e="application/xml"){return(new DOMParser).parseFromString(await this.text(),e)}async html(){return this.xml("text/html")}async xlsx(){const[e,t]=await Promise.all([ae(L.resolve()),this.arrayBuffer()]);return new ft(await(new e.Workbook).xlsx.load(t))}}class Ct extends Et{constructor(e,t,i){super(t,i),Object.defineProperty(this,"_url",{value:e})}async url(){return await this._url+""}}function Dt(e){throw new Error(`File not found: ${e}`)}function At(e){return Object.assign((t=>{const i=e(t+="");if(null==i)throw new Error(`File not found: ${t}`);if("object"==typeof i&&"url"in i){const{url:e,mimeType:n}=i;return new Ct(e,t,n)}return new Ct(i,t)}),{prototype:Ct.prototype})}class wt{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 Ft(t)}}class Ft extends Et{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 kt={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 St=0;function _t(e){return new Bt("O-"+(null==e?"":e+"-")+ ++St)}function Bt(e){this.id=e,this.href=new URL(`#${e}`,location)+""}Bt.prototype.toString=function(){return"url("+this.href+")"};var It=Object.freeze({__proto__:null,canvas:function(e,t){var i=document.createElement("canvas");return i.width=e,i.height=t,i},context2d:function(e,t,i){null==i&&(i=devicePixelRatio);var n=document.createElement("canvas");n.width=e*i,n.height=t*i,n.style.width=e+"px";var s=n.getContext("2d");return s.scale(i,i),s},download:function(e,t="untitled",i="Save"){const n=document.createElement("a"),s=n.appendChild(document.createElement("button"));async function r(){await new Promise(requestAnimationFrame),URL.revokeObjectURL(n.href),n.removeAttribute("href"),s.textContent=i,s.disabled=!1}return s.textContent=i,n.download=t,n.onclick=async t=>{if(s.disabled=!0,n.href)return r();s.textContent="Saving…";try{const t=await("function"==typeof e?e():e);s.textContent="Download",n.href=URL.createObjectURL(t)}catch(e){s.textContent=i}if(t.eventPhase)return r();s.disabled=!1},n},element:function(e,t){var i,n=e+="",s=n.indexOf(":");s>=0&&"xmlns"!==(n=e.slice(0,s))&&(e=e.slice(s+1));var r=kt.hasOwnProperty(n)?document.createElementNS(kt[n],e):document.createElement(e);if(t)for(var a in t)s=(n=a).indexOf(":"),i=t[a],s>=0&&"xmlns"!==(n=a.slice(0,s))&&(a=a.slice(s+1)),kt.hasOwnProperty(n)?r.setAttributeNS(kt[n],a,i):r.setAttribute(a,i);return r},input:function(e){var t=document.createElement("input");return null!=e&&(t.type=e),t},range:function(e,t,i){1===arguments.length&&(t=e,e=null);var n=document.createElement("input");return n.min=e=null==e?0:+e,n.max=t=null==t?1:+t,n.step=null==i?"any":i=+i,n.type="range",n},select:function(e){var t=document.createElement("select");return Array.prototype.forEach.call(e,(function(e){var i=document.createElement("option");i.value=i.textContent=e,t.appendChild(i)})),t},svg:function(e,t){var i=document.createElementNS("http://www.w3.org/2000/svg","svg");return i.setAttribute("viewBox",[0,0,e,t]),i.setAttribute("width",e),i.setAttribute("height",t),i},text:function(e){return document.createTextNode(e)},uid:_t});var Pt=Object.freeze({__proto__:null,buffer:function(e){return new Promise((function(t,i){var n=new FileReader;n.onload=function(){t(n.result)},n.onerror=i,n.readAsArrayBuffer(e)}))},text:function(e){return new Promise((function(t,i){var n=new FileReader;n.onload=function(){t(n.result)},n.onerror=i,n.readAsText(e)}))},url:function(e){return new Promise((function(t,i){var n=new FileReader;n.onload=function(){t(n.result)},n.onerror=i,n.readAsDataURL(e)}))}});function Nt(){return this}function Tt(e,t){let i=!1;if("function"!=typeof t)throw new Error("dispose is not a function");return{[Symbol.iterator]:Nt,next:()=>i?{done:!0}:(i=!0,{done:!1,value:e}),return:()=>(i=!0,t(e),{done:!0}),throw:()=>({done:i=!0})}}function Lt(e){let t,i,n=!1;const s=e((function(e){i?(i(e),i=null):n=!0;return t=e}));if(null!=s&&"function"!=typeof s)throw new Error("function"==typeof s.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:Nt,throw:()=>({done:!0}),return:()=>(null!=s&&s(),{done:!0}),next:function(){return{done:!1,value:n?(n=!1,Promise.resolve(t)):new Promise((e=>i=e))}}}}function Vt(e){switch(e.type){case"range":case"number":return e.valueAsNumber;case"date":return e.valueAsDate;case"checkbox":return e.checked;case"file":return e.multiple?e.files:e.files[0];case"select-multiple":return Array.from(e.selectedOptions,(e=>e.value));default:return e.value}}var Rt=Object.freeze({__proto__:null,disposable:Tt,filter:function*(e,t){for(var i,n=-1;!(i=e.next()).done;)t(i.value,++n)&&(yield i.value)},input:function(e){return Lt((function(t){var i=function(e){switch(e.type){case"button":case"submit":case"checkbox":return"click";case"file":return"change";default:return"input"}}(e),n=Vt(e);function s(){t(Vt(e))}return e.addEventListener(i,s),void 0!==n&&t(n),function(){e.removeEventListener(i,s)}}))},map:function*(e,t){for(var i,n=-1;!(i=e.next()).done;)yield t(i.value,++n)},observe:Lt,queue:function(e){let t;const i=[],n=e((function(e){i.push(e),t&&(t(i.shift()),t=null);return e}));if(null!=n&&"function"!=typeof n)throw new Error("function"==typeof n.then?"async initializers are not supported":"initializer returned something, but not a dispose function");return{[Symbol.iterator]:Nt,throw:()=>({done:!0}),return:()=>(null!=n&&n(),{done:!0}),next:function(){return{done:!1,value:i.length?Promise.resolve(i.shift()):new Promise((e=>t=e))}}}},range:function*(e,t,i){e=+e,t=+t,i=(s=arguments.length)<2?(t=e,e=0,1):s<3?1:+i;for(var n=-1,s=0|Math.max(0,Math.ceil((t-e)/i));++n{i.terminate(),URL.revokeObjectURL(t)}))}});function Ot(e,t){return function(i){var n,s,r,a,o,u,c,p,l=i[0],h=[],d=null,f=-1;for(o=1,u=arguments.length;o0){for(r=new Array(f),a=document.createTreeWalker(d,NodeFilter.SHOW_COMMENT,null,!1);a.nextNode();)s=a.currentNode,/^o:/.test(s.nodeValue)&&(r[+s.nodeValue.slice(2)]=s);for(o=0;o{t=e}))},value:{get:()=>e,set:i=>t(e=i)}}),void 0!==e&&t(e)}function*qt(){for(;;)yield Date.now()}var $t=new Map;function Ut(e,t){var i;return(i=$t.get(e=+e))?i.then((()=>t)):(i=Date.now())>=e?Promise.resolve(t):function(e,t){var i=new Promise((function(i){$t.delete(t);var n=t-e;if(!(n>0))throw new Error("invalid time");if(n>2147483647)throw new Error("too long to wait");setTimeout(i,n)}));return $t.set(t,i),i}(i,e).then((()=>t))}var zt=Object.freeze({__proto__:null,delay:function(e,t){return new Promise((function(i){setTimeout((function(){i(t)}),e)}))},tick:function(e,t){return Ut(Math.ceil((Date.now()+1)/e)*e,t)},when:Ut});function Wt(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 Ht=Ot((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 Gt=String.raw;function Qt(e){return new Promise((function(t,i){var n=document.createElement("link");n.rel="stylesheet",n.href=e,n.onerror=i,n.onload=t,document.head.appendChild(n)}))}function Kt(){return Lt((function(e){var t=e(document.body.clientWidth);function i(){var i=document.body.clientWidth;i!==t&&e(t=i)}return window.addEventListener("resize",i),function(){window.removeEventListener("resize",i)}}))}const Yt=Object.assign(Object.defineProperties((function(e){const t=function(e){return null==e?ae:Z(e)}(e);var i;Object.defineProperties(this,(i={FileAttachment:()=>Dt,Mutable:()=>jt,now:qt,width:Kt,dot:()=>t(y.resolve()),htl:()=>t(D.resolve()),html:()=>Mt,md:()=>function(e){return e(w.resolve()).then((function(t){return Ot((function(i){var n=document.createElement("div");n.innerHTML=t(i,{langPrefix:""}).trim();var s=n.querySelectorAll("pre code[class]");return s.length>0&&e(b.resolve()).then((function(t){s.forEach((function(i){function n(){t.highlightBlock(i),i.parentNode.classList.add("observablehq--md-pre")}t.getLanguage(i.className)?n():e(b.resolve("async-languages/index.js")).then((n=>{if(n.has(i.className))return e(b.resolve("async-languages/"+n.get(i.className))).then((e=>{t.registerLanguage(i.className,e)}))})).then(n,n)}))})),n}),(function(){return document.createElement("div")}))}))}(t),svg:()=>Ht,tex:()=>function(e){return Promise.all([e(E.resolve()),e.resolve(E.resolve("dist/katex.min.css")).then(Qt)]).then((function(e){var t=e[0],i=n();function n(e){return function(){var i=document.createElement("div");return t.render(Gt.apply(String,arguments),i,e),i.removeChild(i.firstChild)}}return i.options=n,i.block=n({displayMode:!0}),i}))}(t),_:()=>t(C.resolve()),aq:()=>t.alias({"apache-arrow":B.resolve()})(N.resolve()),Arrow:()=>t(B.resolve()),d3:()=>t(g.resolve()),DuckDBClient:()=>De,Inputs:()=>t(v.resolve()).then((e=>({...e,file:e.fileOf(Et)}))),L:()=>async function(e){const t=await e(R.resolve());if(!t._style){const i=document.createElement("link");i.rel="stylesheet",i.href=await e.resolve(R.resolve("dist/leaflet.css")),t._style=document.head.appendChild(i)}return t}(t),mermaid:()=>async function(e){const t=await e(V.resolve());return t.initialize({securityLevel:"loose",theme:"neutral"}),function(){const e=document.createElement("div");return e.innerHTML=t.render(_t().id,String.raw.apply(String,arguments)),e.removeChild(e.firstChild)}}(t),Plot:()=>t(x.resolve()),__query:()=>Ve,require:()=>t,resolve:()=>Wt,SQLite:()=>oe(t),SQLiteDatabaseClient:()=>ue,topojson:()=>t(T.resolve()),vl:()=>async function(e){const[t,i,n]=await Promise.all([k,S,_].map((t=>e(t.resolve()))));return n.register(t,i)}(t),aapl:()=>new Ct("https://static.observableusercontent.com/files/3ccff97fd2d93da734e76829b2b066eafdaac6a1fafdec0faf6ebc443271cfc109d29e80dd217468fcb2aff1e6bffdc73f356cc48feb657f35378e6abbbb63b9").csv({typed:!0}),alphabet:()=>new Ct("https://static.observableusercontent.com/files/75d52e6c3130b1cae83cda89305e17b50f33e7420ef205587a135e8562bcfd22e483cf4fa2fb5df6dff66f9c5d19740be1cfaf47406286e2eb6574b49ffc685d").csv({typed:!0}),cars:()=>new Ct("https://static.observableusercontent.com/files/048ec3dfd528110c0665dfa363dd28bc516ffb7247231f3ab25005036717f5c4c232a5efc7bb74bc03037155cb72b1abe85a33d86eb9f1a336196030443be4f6").csv({typed:!0}),citywages:()=>new Ct("https://static.observableusercontent.com/files/39837ec5121fcc163131dbc2fe8c1a2e0b3423a5d1e96b5ce371e2ac2e20a290d78b71a4fb08b9fa6a0107776e17fb78af313b8ea70f4cc6648fad68ddf06f7a").csv({typed:!0}),diamonds:()=>new Ct("https://static.observableusercontent.com/files/87942b1f5d061a21fa4bb8f2162db44e3ef0f7391301f867ab5ba718b225a63091af20675f0bfe7f922db097b217b377135203a7eab34651e21a8d09f4e37252").csv({typed:!0}),flare:()=>new Ct("https://static.observableusercontent.com/files/a6b0d94a7f5828fd133765a934f4c9746d2010e2f342d335923991f31b14120de96b5cb4f160d509d8dc627f0107d7f5b5070d2516f01e4c862b5b4867533000").csv({typed:!0}),industries:()=>new Ct("https://static.observableusercontent.com/files/76f13741128340cc88798c0a0b7fa5a2df8370f57554000774ab8ee9ae785ffa2903010cad670d4939af3e9c17e5e18e7e05ed2b38b848ac2fc1a0066aa0005f").csv({typed:!0}),miserables:()=>new Ct("https://static.observableusercontent.com/files/31d904f6e21d42d4963ece9c8cc4fbd75efcbdc404bf511bc79906f0a1be68b5a01e935f65123670ed04e35ca8cae3c2b943f82bf8db49c5a67c85cbb58db052").json(),olympians:()=>new Ct("https://static.observableusercontent.com/files/31ca24545a0603dce099d10ee89ee5ae72d29fa55e8fc7c9ffb5ded87ac83060d80f1d9e21f4ae8eb04c1e8940b7287d179fe8060d887fb1f055f430e210007c").csv({typed:!0}),penguins:()=>new Ct("https://static.observableusercontent.com/files/715db1223e067f00500780077febc6cebbdd90c151d3d78317c802732252052ab0e367039872ab9c77d6ef99e5f55a0724b35ddc898a1c99cb14c31a379af80a").csv({typed:!0}),pizza:()=>new Ct("https://static.observableusercontent.com/files/c653108ab176088cacbb338eaf2344c4f5781681702bd6afb55697a3f91b511c6686ff469f3e3a27c75400001a2334dbd39a4499fe46b50a8b3c278b7d2f7fb5").csv({typed:!0}),weather:()=>new Ct("https://static.observableusercontent.com/files/693a46b22b33db0f042728700e0c73e836fa13d55446df89120682d55339c6db7cc9e574d3d73f24ecc9bc7eb9ac9a1e7e104a1ee52c00aab1e77eb102913c1f").csv({typed:!0}),DOM:It,Files:Pt,Generators:Rt,Promises:zt},Object.fromEntries(Object.entries(i).map(Jt))))}),{resolve:{get:()=>ae.resolve,enumerable:!0,configurable:!0},require:{get:()=>ae,set:function(e){ae=e},enumerable:!0,configurable:!0}}),{resolveFrom:K,requireFrom:Z});function Jt([e,t]){return[e,{value:t,writable:!0,enumerable:!0}]}class Xt{constructor(e){this._node=e,this._spans=[],this.normalizeCodeRange(),this.initializeEntryPoints()}normalizeCodeRange(){const e=this._node.querySelectorAll("code > span");for(const t of e)Array.from(t.childNodes).filter((e=>e.nodeType===e.TEXT_NODE)).forEach((e=>{const t=document.createElement("span");t.textContent=e.wholeText,e.replaceWith(t)}))}initializeEntryPoints(){const e=this._node.querySelectorAll("code > span");let t=[],i=this._node.parentElement.dataset.sourceOffset&&-Number(this._node.parentElement.dataset.sourceOffset)||0;for(const n of e){let e=Number(n.id.split("-").pop()),s=1;Array.from(n.childNodes).filter((e=>e.nodeType===e.ELEMENT_NODE&&"SPAN"===e.nodeName)).forEach((n=>{t.push({offset:i,line:e,column:s,node:n}),i+=n.textContent.length,s+=n.textContent.length})),i+=1}this._elementEntryPoints=t}locateEntry(e){let t;if(e!==1/0){for(let i=0;ie)return{entry:t,index:i-1};t=n}return e{const i=document.createElement("span");for(const t of e.node.classList)i.classList.add(t);const n=e.node.textContent.slice(0,t-e.offset),s=e.node.textContent.slice(t-e.offset);e.node.textContent=n,i.textContent=s,e.node.after(i),this._elementEntryPoints.push({column:e.column+t-e.offset,line:e.line,node:i,offset:t}),this._elementEntryPoints.sort(((e,t)=>e.offset-t.offset))},n=this.locateEntry(e);void 0!==n&&void 0!==n.entry&&n.entry.offset!=e&&i(n.entry,e);const s=this.locateEntry(t);void 0!==s&&void 0!==n.entry&&s.entry.offset!==t&&i(s.entry,t)}clearSpan(e,t,i){this.ensureExactSpan(e,t);const n=this.locateEntry(e),s=this.locateEntry(t);if(void 0===n)return;const r=n.index,a=s&&s.index||this._elementEntryPoints.length;for(let e=r;e!0===e[t]));if(!t.length)return;const i=t.find((e=>!e.modifier)),n="Map"===i.name&&t.find((e=>e.modifier&&e.prefix)),s=t.some((e=>e.arrayish)),r=t.some((e=>e.setish));return{name:`${n?n.name:""}${i.name}`,symbols:t,arrayish:s&&!r,setish:r}}catch(e){return null}}const{getPrototypeOf:mi,getOwnPropertyDescriptors:gi}=Object,vi=mi({});function xi(e,t,i,n){let s,r,a,o,u=ei(e);e instanceof Map?e instanceof e.constructor?(s=`Map(${e.size})`,r=yi):(s="Map()",r=wi):e instanceof Set?e instanceof e.constructor?(s=`Set(${e.size})`,r=bi):(s="Set()",r=wi):u?(s=`${e.constructor.name}(${e.length})`,r=Ci):(o=fi(e))?(s=`Immutable.${o.name}${"Record"===o.name?"":`(${e.size})`}`,u=o.arrayish,r=o.arrayish?Di:o.setish?Ei:Fi):n?(s=li(e),r=Ai):(s=li(e),r=wi);const c=document.createElement("span");c.className="observablehq--expanded",i&&c.appendChild(ii(i));const p=c.appendChild(document.createElement("a"));p.innerHTML="\n \n ",p.appendChild(document.createTextNode(`${s}${u?" [":" {"}`)),p.addEventListener("mouseup",(function(t){t.stopPropagation(),an(c,Pi(e,null,i,n))})),r=r(e);for(let e=0;!(a=r.next()).done&&e<20;++e)c.appendChild(a.value);if(!a.done){const e=c.appendChild(document.createElement("a"));e.className="observablehq--field",e.style.display="block",e.appendChild(document.createTextNode(" … more")),e.addEventListener("mouseup",(function(e){e.stopPropagation(),c.insertBefore(a.value,c.lastChild.previousSibling);for(let e=0;!(a=r.next()).done&&e<19;++e)c.insertBefore(a.value,c.lastChild.previousSibling);a.done&&c.removeChild(c.lastChild.previousSibling),Zt(c,"load")}))}return c.appendChild(document.createTextNode(u?"]":"}")),c}function*yi(e){for(const[t,i]of e)yield _i(t,i);yield*wi(e)}function*bi(e){for(const t of e)yield Bi(t);yield*wi(e)}function*Ei(e){for(const t of e)yield Bi(t)}function*Ci(e){for(let t=0,i=e.length;t ")),i.appendChild(rn(t)),i}function Bi(e){const t=document.createElement("div");return t.className="observablehq--field",t.appendChild(document.createTextNode(" ")),t.appendChild(rn(e)),t}function Ii(e){const t=window.getSelection();return"Range"===t.type&&(t.containsNode(e,!0)||t.anchorNode.isSelfOrDescendant(e)||t.focusNode.isSelfOrDescendant(e))}function Pi(e,t,i,n){let s,r,a,o,u=ei(e);if(e instanceof Map?e instanceof e.constructor?(s=`Map(${e.size})`,r=Ni):(s="Map()",r=Oi):e instanceof Set?e instanceof e.constructor?(s=`Set(${e.size})`,r=Ti):(s="Set()",r=Oi):u?(s=`${e.constructor.name}(${e.length})`,r=Ri):(o=fi(e))?(s=`Immutable.${o.name}${"Record"===o.name?"":`(${e.size})`}`,u=o.arrayish,r=o.arrayish?Vi:o.setish?Li:Mi):(s=li(e),r=Oi),t){const t=document.createElement("span");return t.className="observablehq--shallow",i&&t.appendChild(ii(i)),t.appendChild(document.createTextNode(s)),t.addEventListener("mouseup",(function(i){Ii(t)||(i.stopPropagation(),an(t,Pi(e)))})),t}const c=document.createElement("span");c.className="observablehq--collapsed",i&&c.appendChild(ii(i));const p=c.appendChild(document.createElement("a"));p.innerHTML="\n \n ",p.appendChild(document.createTextNode(`${s}${u?" [":" {"}`)),c.addEventListener("mouseup",(function(t){Ii(c)||(t.stopPropagation(),an(c,xi(e,0,i,n)))}),!0),r=r(e);for(let e=0;!(a=r.next()).done&&e<20;++e)e>0&&c.appendChild(document.createTextNode(", ")),c.appendChild(a.value);return a.done||c.appendChild(document.createTextNode(", …")),c.appendChild(document.createTextNode(u?"]":"}")),c}function*Ni(e){for(const[t,i]of e)yield $i(t,i);yield*Oi(e)}function*Ti(e){for(const t of e)yield rn(t,!0);yield*Oi(e)}function*Li(e){for(const t of e)yield rn(t,!0)}function*Vi(e){let t=-1,i=0;for(const n=e.size;it+1&&(yield ji(i-t-1)),yield rn(e.get(i),!0),t=i;i>t+1&&(yield ji(i-t-1))}function*Ri(e){let t=-1,i=0;for(const n=e.length;it+1&&(yield ji(i-t-1)),yield rn(hi(e,i),!0),t=i);i>t+1&&(yield ji(i-t-1));for(const t in e)!ti(t)&&pi(e,t)&&(yield qi(t,hi(e,t),"observablehq--key"));for(const t of ci(e))yield qi(si(t),hi(e,t),"observablehq--symbol")}function*Oi(e){for(const t in e)pi(e,t)&&(yield qi(t,hi(e,t),"observablehq--key"));for(const t of ci(e))yield qi(si(t),hi(e,t),"observablehq--symbol")}function*Mi(e){for(const[t,i]of e)yield qi(t,i,"observablehq--key")}function ji(e){const t=document.createElement("span");return t.className="observablehq--empty",t.textContent=1===e?"empty":`empty × ${e}`,t}function qi(e,t,i){const n=document.createDocumentFragment(),s=n.appendChild(document.createElement("span"));return s.className=i,s.textContent=e,n.appendChild(document.createTextNode(": ")),n.appendChild(rn(t,!0)),n}function $i(e,t){const i=document.createDocumentFragment();return i.appendChild(rn(e,!0)),i.appendChild(document.createTextNode(" => ")),i.appendChild(rn(t,!0)),i}function Ui(e,t){if(e instanceof Date||(e=new Date(+e)),isNaN(e))return"function"==typeof t?t(e):t;const i=e.getUTCHours(),n=e.getUTCMinutes(),s=e.getUTCSeconds(),r=e.getUTCMilliseconds();return`${a=e.getUTCFullYear(),a<0?`-${zi(-a,6)}`:a>9999?`+${zi(a,6)}`:zi(a,4)}-${zi(e.getUTCMonth()+1,2)}-${zi(e.getUTCDate(),2)}${i||n||s||r?`T${zi(i,2)}:${zi(n,2)}${s||r?`:${zi(s,2)}${r?`.${zi(r,3)}`:""}`:""}Z`:""}`;var a}function zi(e,t){return`${e}`.padStart(t,"0")}var Wi=Error.prototype.toString;var Hi=RegExp.prototype.toString;function Gi(e){return e.replace(/[\\`\x00-\x09\x0b-\x19]|\${/g,Qi)}function Qi(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 Ki(e,t){for(var i=0;t.exec(e);)++i;return i}var Yi=Function.prototype.toString,Ji={prefix:"async ƒ"},Xi={prefix:"async ƒ*"},Zi={prefix:"class"},en={prefix:"ƒ"},tn={prefix:"ƒ*"};function nn(e,t,i){var n=document.createElement("span");n.className="observablehq--function",i&&n.appendChild(ii(i));var s=n.appendChild(document.createElement("span"));return s.className="observablehq--keyword",s.textContent=e.prefix,n.appendChild(document.createTextNode(t)),n}const{prototype:{toString:sn}}=Object;function rn(e,t,i,n,s){let r=typeof e;switch(r){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=si(e);break;case"function":return function(e,t){var i,n,s=Yi.call(e);switch(e.constructor&&e.constructor.name){case"AsyncFunction":i=Ji;break;case"AsyncGeneratorFunction":i=Xi;break;case"GeneratorFunction":i=tn;break;default:i=/^class\b/.test(s)?Zi:en}return i===Zi?nn(i,"",t):(n=/^(?:async\s*)?(\w+)\s*=>/.exec(s))?nn(i,"("+n[1]+")",t):(n=/^(?:async\s*)?\(\s*(\w+(?:\s*,\s*\w+)*)?\s*\)/.exec(s))||(n=/^(?:async\s*)?function(?:\s*\*)?(?:\s*\w+)?\s*\(\s*(\w+(?:\s*,\s*\w+)*)?\s*\)/.exec(s))?nn(i,n[1]?"("+n[1].replace(/\s*,\s*/g,", ")+")":"()",t):nn(i,"(…)",t)}(e,n);case"string":return function(e,t,i,n){if(!1===t){if(Ki(e,/["\n]/g)<=Ki(e,/`|\${/g)){const t=document.createElement("span");n&&t.appendChild(ii(n));const i=t.appendChild(document.createElement("span"));return i.className="observablehq--string",i.textContent=JSON.stringify(e),t}const s=e.split("\n");if(s.length>20&&!i){const i=document.createElement("div");n&&i.appendChild(ii(n));const r=i.appendChild(document.createElement("span"));r.className="observablehq--string",r.textContent="`"+Gi(s.slice(0,20).join("\n"));const a=i.appendChild(document.createElement("span")),o=s.length-20;return a.textContent=`Show ${o} truncated line${o>1?"s":""}`,a.className="observablehq--string-expand",a.addEventListener("mouseup",(function(s){s.stopPropagation(),an(i,rn(e,t,!0,n))})),i}const r=document.createElement("span");n&&r.appendChild(ii(n));const a=r.appendChild(document.createElement("span"));return a.className="observablehq--string"+(i?" observablehq--expanded":""),a.textContent="`"+Gi(e)+"`",r}const s=document.createElement("span");n&&s.appendChild(ii(n));const r=s.appendChild(document.createElement("span"));return r.className="observablehq--string",r.textContent=JSON.stringify(e.length>100?`${e.slice(0,50)}…${e.slice(-49)}`:e),s}(e,t,i,n);default:if(null===e){r=null,e="null";break}if(e instanceof Date){r="date",e=Ui(e,"Invalid Date");break}if(e===ui){r="forbidden",e="[forbidden]";break}switch(sn.call(e)){case"[object RegExp]":r="regexp",e=function(e){return Hi.call(e)}(e);break;case"[object Error]":case"[object DOMException]":r="error",e=function(e){return e.stack||Wi.call(e)}(e);break;default:return(i?xi:Pi)(e,t,n,s)}}const a=document.createElement("span");n&&a.appendChild(ii(n));const o=a.appendChild(document.createElement("span"));return o.className=`observablehq--${r}`,o.textContent=e,a}function an(e,t){e.classList.contains("observablehq--inspect")&&t.classList.add("observablehq--inspect"),e.parentNode.replaceChild(t,e),Zt(t,"load")}const on=/\s+\(\d+:\d+\)$/m;class un{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(e,t){const{_node:i}=this;if((!function(e){return(e instanceof Element||e instanceof Text)&&e instanceof e.constructor}(e)||e.parentNode&&e.parentNode!==i)&&(e=rn(e,!1,i.firstChild&&i.firstChild.classList&&i.firstChild.classList.contains("observablehq--expanded"),t)).classList.add("observablehq--inspect"),i.classList.remove("observablehq--running","observablehq--error"),i.firstChild!==e)if(i.firstChild){for(;i.lastChild!==i.firstChild;)i.removeChild(i.lastChild);i.replaceChild(e,i.firstChild)}else i.appendChild(e);Zt(i,"update")}rejected(e,t){const{_node:i}=this;for(i.classList.remove("observablehq--running"),i.classList.add("observablehq--error");i.lastChild;)i.removeChild(i.lastChild);var n=document.createElement("div");n.className="observablehq--inspect",t&&n.appendChild(ii(t)),n.appendChild(document.createTextNode((e+"").replace(on,""))),i.appendChild(n),Zt(i,"error",{error:e})}}un.into=function(e){if("string"==typeof e&&null==(e=document.querySelector(e)))throw new Error("container not found");return function(){return new un(e.appendChild(document.createElement("div")))}};class cn extends Error{constructor(e,t){super(e),this.input=t}}function pn(e){return()=>e}function ln(e){return e}cn.prototype.name="RuntimeError";const hn=Array.prototype.map;function dn(){}const fn=Symbol("no-observer");function mn(e,t,i,n){var s;i||(i=fn),Object.defineProperties(this,{_observer:{value:i,writable:!0},_definition:{value:yn,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:dn,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:i!==fn,writable:!0},_rejector:{value:(s=this,e=>{if(e===bn)throw e;if(e===yn)throw new cn(`${s._name} is not defined`,s._name);if(e instanceof Error&&e.message)throw new cn(e.message,s._name);throw new cn(`${s._name} could not be resolved`,s._name)})},_shadow:{value:gn(t,n)},_type:{value:e},_value:{value:void 0,writable:!0},_version:{value:0,writable:!0}})}function gn(e,t){return t?.shadow?new Map(Object.entries(t.shadow).map((([t,i])=>[t,new mn(2,e).define([],i)]))):null}function vn(e){e._module._runtime._dirty.add(e),e._outputs.add(this)}function xn(e){e._module._runtime._dirty.add(e),e._outputs.delete(this)}function yn(){throw yn}function bn(){throw bn}function En(e){return()=>{throw new cn(`${e} is defined more than once`)}}function Cn(e,t,i){const n=this._module._scope,s=this._module._runtime;if(this._inputs.forEach(xn,this),t.forEach(vn,this),this._inputs=t,this._definition=i,this._value=void 0,i===dn?s._variables.delete(this):s._variables.add(this),e!==this._name||n.get(e)!==this){let t,r;if(this._name)if(this._outputs.size)n.delete(this._name),r=this._module._resolve(this._name),r._outputs=this._outputs,this._outputs=new Set,r._outputs.forEach((function(e){e._inputs[e._inputs.indexOf(this)]=r}),this),r._outputs.forEach(s._updates.add,s._updates),s._dirty.add(r).add(this),n.set(this._name,r);else if((r=n.get(this._name))===this)n.delete(this._name);else{if(3!==r._type)throw new Error;r._duplicates.delete(this),this._duplicate=void 0,1===r._duplicates.size&&(r=r._duplicates.keys().next().value,t=n.get(this._name),r._outputs=t._outputs,t._outputs=new Set,r._outputs.forEach((function(e){e._inputs[e._inputs.indexOf(t)]=r})),r._definition=r._duplicate,r._duplicate=void 0,s._dirty.add(t).add(r),s._updates.add(r),n.set(this._name,r))}if(this._outputs.size)throw new Error;e&&((r=n.get(e))?3===r._type?(this._definition=En(e),this._duplicate=i,r._duplicates.add(this)):2===r._type?(this._outputs=r._outputs,r._outputs=new Set,this._outputs.forEach((function(e){e._inputs[e._inputs.indexOf(r)]=this}),this),s._dirty.add(r).add(this),n.set(e,this)):(r._duplicate=r._definition,this._duplicate=i,t=new mn(3,this._module),t._name=e,t._definition=this._definition=r._definition=En(e),t._outputs=r._outputs,r._outputs=new Set,t._outputs.forEach((function(e){e._inputs[e._inputs.indexOf(r)]=t})),t._duplicates=new Set([this,r]),s._dirty.add(r).add(t),s._updates.add(r).add(t),n.set(e,t)):n.set(e,this)),this._name=e}return this._version>0&&++this._version,s._updates.add(this),s._compute(),this}Object.defineProperties(mn.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,i){switch(arguments.length){case 1:i=e,e=t=null;break;case 2:i=t,"string"==typeof e?t=null:(t=e,e=null)}return Cn.call(this,null==e?null:String(e),null==t?[]:hn.call(t,this._resolve,this),"function"==typeof i?i:pn(i))},writable:!0,configurable:!0},delete:{value:function(){return Cn.call(this,null,[],dn)},writable:!0,configurable:!0},import:{value:function(e,t,i){arguments.length<3&&(i=t,t=e);return Cn.call(this,String(t),[i._resolve(String(e))],ln)},writable:!0,configurable:!0}});const Dn=Symbol("variable"),An=Symbol("invalidation"),wn=Symbol("visibility");function Fn(e,t=[]){Object.defineProperties(this,{_runtime:{value:e},_scope:{value:new Map},_builtins:{value:new Map([["@variable",Dn],["invalidation",An],["visibility",wn],...t])},_source:{value:null,writable:!0}})}async function kn(e,t){await e._compute();try{return await t._promise}catch(i){if(i===bn)return kn(e,t);throw i}}function Sn(e){return e._name}Object.defineProperties(Fn.prototype,{_resolve:{value:function(e){let t,i=this._scope.get(e);if(!i)if(i=new mn(2,this),this._builtins.has(e))i.define(e,pn(this._builtins.get(e)));else if(this._runtime._builtin._scope.has(e))i.import(e,this._runtime._builtin);else{try{t=this._runtime._global(e)}catch(t){return i.define(e,function(e){return()=>{throw e}}(t))}void 0===t?this._scope.set(i._name=e,i):i.define(e,pn(t))}return i},writable:!0,configurable:!0},redefine:{value:function(e){const t=this._scope.get(e);if(!t)throw new cn(`${e} is not defined`);if(3===t._type)throw new cn(`${e} is defined more than once`);return t.define.apply(t,arguments)},writable:!0,configurable:!0},define:{value:function(){const e=new mn(1,this);return e.define.apply(e,arguments)},writable:!0,configurable:!0},derive:{value:function(e,t){const i=new Map,n=new Set,s=[];function r(e){let t=i.get(e);return t||(t=new Fn(e._runtime,e._builtins),t._source=e,i.set(e,t),s.push([t,e]),n.add(e),t)}const a=r(this);for(const i of e){const{alias:e,name:n}="object"==typeof i?i:{name:i};a.import(n,null==e?n:e,t)}for(const e of n)for(const[t,i]of e._scope)if(i._definition===ln){if(e===this&&a._scope.has(t))continue;const n=i._inputs[0]._module;n._source&&r(n)}for(const[e,t]of s)for(const[n,s]of t._scope){const t=e._scope.get(n);if(!t||2===t._type)if(s._definition===ln){const t=s._inputs[0],r=t._module;e.import(t._name,n,i.get(r)||r)}else e.define(n,s._inputs.map(Sn),s._definition)}return a},writable:!0,configurable:!0},import:{value:function(){const e=new mn(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 cn(`${e} is not defined`);if(t._observer!==fn)return kn(this._runtime,t);t=this.variable(!0).define([e],ln);try{return await kn(this._runtime,t)}finally{t.delete()}},writable:!0,configurable:!0},variable:{value:function(e,t){return new mn(1,this,e,t)},writable:!0,configurable:!0},builtin:{value:function(e,t){this._builtins.set(e,t)},writable:!0,configurable:!0}});const _n="function"==typeof requestAnimationFrame?requestAnimationFrame:"function"==typeof setImmediate?setImmediate:e=>setTimeout(e,0);function Bn(e=new Yt,t=Mn){const i=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:i},_global:{value:t}}),e)for(const t in e)new mn(2,i).define(t,[],e[t])}function In(e){const t=new Set(e._inputs);for(const i of t){if(i===e)return!0;i._inputs.forEach(t.add,t)}return!1}function Pn(e){++e._indegree}function Nn(e){--e._indegree}function Tn(e){return e._promise.catch(e._rejector)}function Ln(e){return new Promise((function(t){e._invalidate=t}))}function Vn(e,t){let i,n,s="function"==typeof IntersectionObserver&&t._observer&&t._observer._node,r=!s,a=dn,o=dn;return s&&(n=new IntersectionObserver((([e])=>(r=e.isIntersecting)&&(i=null,a()))),n.observe(s),e.then((()=>(n.disconnect(),n=null,o())))),function(e){return r?Promise.resolve(e):n?(i||(i=new Promise(((e,t)=>(a=e,o=t)))),i.then((()=>e))):Promise.reject()}}function Rn(e){e._invalidate(),e._invalidate=dn,e._pending();const t=e._value,i=++e._version;let n=null;const s=e._promise=(e._inputs.length?Promise.all(e._inputs.map(Tn)).then((function(s){if(e._version!==i)throw bn;for(let t=0,i=s.length;ti(e._definition.call(t))))).then((function(t){if(e._version!==i)throw bn;if(function(e){return e&&"function"==typeof e.next&&"function"==typeof e.return}(t))return(n||Ln(e)).then((s=t,function(){s.return()})),function(e,t,i){const n=e._module._runtime;let s;function r(e){return new Promise((e=>e(i.next(s)))).then((({done:t,value:i})=>t?void 0:Promise.resolve(i).then(e)))}function a(){const i=r((r=>{if(e._version!==t)throw bn;return s=r,o(r,i).then((()=>n._precompute(a))),e._fulfilled(r),r}));i.catch((n=>{n!==bn&&e._version===t&&(o(void 0,i),e._rejected(n))}))}function o(t,i){return e._value=t,e._promise=i,e._outputs.forEach(n._updates.add,n._updates),n._compute()}return r((i=>{if(e._version!==t)throw bn;return s=i,n._precompute(a),i}))}(e,i,t);var s;return t}));s.then((t=>{e._value=t,e._fulfilled(t)}),(t=>{t!==bn&&e._version===i&&(e._value=void 0,e._rejected(t))}))}function On(e,t){e._invalidate(),e._invalidate=dn,e._pending(),++e._version,e._indegree=NaN,(e._promise=Promise.reject(t)).catch(dn),e._value=void 0,e._rejected(t)}function Mn(e){return globalThis[e]}function jn(e){const t=document.createElement("template");return t.innerHTML=e,document.importNode(t.content,!0)}function qn(e){const t=document.createElementNS("http://www.w3.org/2000/svg","g");return t.innerHTML=e,t}Object.defineProperties(Bn.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(_n).then((()=>this._disposed?void 0:this._computeNow()))},writable:!0,configurable:!0},_computeNow:{value:async function(){let e,t,i=[],n=this._precomputes;if(n.length){this._precomputes=[];for(const e of n)e();await function(e=0){let t=Promise.resolve();for(let i=0;i{}));return t}(3)}e=new Set(this._dirty),e.forEach((function(t){t._inputs.forEach(e.add,e);const i=function(e){if(e._observer!==fn)return!0;const t=new Set(e._outputs);for(const e of t){if(e._observer!==fn)return!0;e._outputs.forEach(t.add,t)}return!1}(t);i>t._reachable?this._updates.add(t):i{e._invalidate(),e._version=NaN}))},writable:!0,configurable:!0},module:{value:function(e,t=dn){let i;if(void 0===e)return(i=this._init)?(this._init=null,i):new Fn(this);if(i=this._modules.get(e),i)return i;this._init=i=new Fn(this),this._modules.set(e,i);try{e(this,t)}finally{this._init=null}return i},writable:!0,configurable:!0},fileAttachments:{value:At,writable:!0,configurable:!0},load:{value:function(e,t,i){if("function"==typeof t&&(i=t,t=null),"function"!=typeof i)throw new Error("invalid observer");null==t&&(t=new Yt);const{modules:n,id:s}=e,r=new Map,a=new Bn(t),o=u(s);function u(e){let t=r.get(e);return t||r.set(e,t=a.module()),t}for(const e of n){const t=u(e.id);let n=0;for(const s of e.variables)s.from?t.import(s.remote,s.name,u(s.from)):t===o?t.variable(i(s,n,e.variables)).define(s.name,s.inputs,s.value):t.define(s.name,s.inputs,s.value),++n}return a},writable:!0,configurable:!0}});const $n=Object.assign(ps(jn,(e=>{if(null===e.firstChild)return null;if(e.firstChild===e.lastChild)return e.removeChild(e.firstChild);const t=document.createElement("span");return t.appendChild(e),t})),{fragment:ps(jn,(e=>e))});Object.assign(ps(qn,(e=>null===e.firstChild?null:e.firstChild===e.lastChild?e.removeChild(e.firstChild):e)),{fragment:ps(qn,(e=>{const t=document.createDocumentFragment();for(;e.firstChild;)t.appendChild(e.firstChild);return t}))});const Un=60,zn=62,Wn=47,Hn=45,Gn=33,Qn=61,Kn=10,Yn=11,Jn=12,Xn=13,Zn=14,es=17,ts=22,is=23,ns=26,ss="http://www.w3.org/2000/svg",rs="http://www.w3.org/1999/xlink",as="http://www.w3.org/XML/1998/namespace",os="http://www.w3.org/2000/xmlns/",us=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map((e=>[e.toLowerCase(),e]))),cs=new Map([["xlink:actuate",rs],["xlink:arcrole",rs],["xlink:href",rs],["xlink:role",rs],["xlink:show",rs],["xlink:title",rs],["xlink:type",rs],["xml:lang",as],["xml:space",as],["xmlns",os],["xmlns:xlink",os]]);function ps(e,t){return function({raw:i}){let n,s,r,a,o=1,u="",c=0;for(let e=0,t=arguments.length;e0){const n=arguments[e];switch(o){case ns:if(null!=n){const e=`${n}`;if(gs(s))u+=e.replace(/[<]/g,ls);else{if(new RegExp(`/]`,"i").test(u.slice(-s.length-2)+e))throw new Error("unsafe raw text");u+=e}}break;case 1:null==n||(n instanceof Node||"string"!=typeof n&&n[Symbol.iterator]||/(?:^|>)$/.test(i[e-1])&&/^(?:<|$)/.test(t)?(u+="\x3c!--::"+e+"--\x3e",c|=128):u+=`${n}`.replace(/[<&]/g,ls));break;case 9:{let s;if(o=Jn,/^[\s>]/.test(t)){if(null==n||!1===n){u=u.slice(0,r-i[e-1].length);break}if(!0===n||""==(s=`${n}`)){u+="''";break}if("style"===i[e-1].slice(r,a)&&fs(n)||"function"==typeof n){u+="::"+e,c|=1;break}}if(void 0===s&&(s=`${n}`),""===s)throw new Error("unsafe unquoted empty string");u+=s.replace(/^['"]|[\s>&]/g,ls);break}case Jn:u+=`${n}`.replace(/[\s>&]/g,ls);break;case Yn:u+=`${n}`.replace(/['&]/g,ls);break;case Kn:u+=`${n}`.replace(/["&]/g,ls);break;case 6:if(fs(n)){u+="::"+e+"=''",c|=1;break}throw new Error("invalid binding");case es:break;default:throw new Error("invalid binding")}}for(let e=0,i=t.length;e=0;--n)s=t.insertBefore(i[n],s);else for(const n of i)null!=n&&t.insertBefore(n instanceof Node?n:document.createTextNode(n),e);else t.insertBefore(document.createTextNode(i),e);h.push(e)}}}for(const e of h)e.parentNode.removeChild(e);return t(p)}}function ls(e){return`&#${e.charCodeAt(0).toString()};`}function hs(e){return 65<=e&&e<=90||97<=e&&e<=122}function ds(e){return 9===e||10===e||12===e||32===e||13===e}function fs(e){return e&&e.toString===Object.prototype.toString}function ms(e){return"script"===e||"style"===e||gs(e)}function gs(e){return"textarea"===e||"title"===e}function vs(e,t,i){return e.slice(t,i).toLowerCase()}function xs(e,t,i){e.namespaceURI===ss&&(t=t.toLowerCase(),t=us.get(t)||t,cs.has(t))?e.setAttributeNS(cs.get(t),t,i):e.setAttribute(t,i)}function ys(e,t){e.namespaceURI===ss&&(t=t.toLowerCase(),t=us.get(t)||t,cs.has(t))?e.removeAttributeNS(cs.get(t),t):e.removeAttribute(t)}function bs(e,t){for(const i in t){const n=t[i];i.startsWith("--")?e.setProperty(i,n):e[i]=n}}const Es={bubbles:!0};function Cs(e){e.preventDefault()}function Ds(e){return e}let As=0;function ws(e,t){if(e)return e=$n`