@malloy-publisher/sdk 0.12.6 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- "use strict";const $=require("react/jsx-runtime"),se=require("@mui/material"),w=require("react"),u=require("./useCompiledDocument-BpP4Clt3.cjs.js"),X=require("./ServerProvider-CqL6xzta.cjs.js"),v=u.reportClasses.drillCell;function he(e,t){const r=new Set;let a;try{a=e.getMetadata()?.getAllFields()??[]}catch{return r}const o=new Set;for(const n of a)!n||t(n)||n.tag?.tag("hidden")===void 0&&o.add(n.tag?.text("label")??n.name);for(const n of a){if(!n||!t(n))continue;const l=n.tag?.text("label")??n.name;o.has(l)||r.add(l)}return r}function j(e){const t=/^\s*(\d+)/.exec(e.style?.gridColumn??"");return t?t[1]:void 0}function me(e,t){if(t.size!==0)for(const r of e.querySelectorAll(".malloy-table")){const a=l=>l.closest(".malloy-table")===r,o=new Set;for(const l of r.querySelectorAll(".column-cell.th")){if(!a(l))continue;const i=(l.textContent??"").replace(/\u200b/g,"").trim(),m=j(l);m&&t.has(i)&&o.add(m)}if(o.size===0)continue;const n=new Set;for(const l of r.querySelectorAll(`.${v}[tabindex="0"]`)){if(!a(l))continue;const i=j(l);i&&(n.has(i)?l.tabIndex=-1:n.add(i))}for(const l of r.querySelectorAll(".column-cell.td")){if(!a(l))continue;const i=j(l),m=!l.querySelector(".value-null")&&(l.textContent??"").trim()!=="";if(i&&m&&o.has(i)&&!l.querySelector(".malloy-table")){if(l.classList.add(v),l.tabIndex===0)n.add(i);else{const p=n.has(i);p||n.add(i),l.tabIndex=p?-1:0}l.setAttribute("role","button")}}}}function ke(e){const t=e.closest(".malloy-table"),r=j(e);return!t||!r?[]:Array.from(t.querySelectorAll(`.${v}`)).filter(a=>a.closest(".malloy-table")===t&&j(a)===r)}function de(e,t){const r=ke(e),a=r.indexOf(e);if(a===-1)return;const o=t==="first"?r[0]:t==="last"?r[r.length-1]:r[Math.min(Math.max(a+t,0),r.length-1)];if(o){for(const n of r)n.tabIndex=n===o?0:-1;return o}}function be(e){return{background:e.dashboardRoot,tableBackground:e.tableBackground,tableHeaderColor:e.tableHeader,tableBodyColor:e.tableBody,tableBorder:e.border,tablePinnedBackground:e.tableHeaderBackground,tablePinnedBorder:e.pinnedBorder,tableFontSize:`${e.font.size}px`,fontFamily:e.font.family,mapColor:e.mapColor}}function fe(e){const{foreground:t,axisFaint:r,gridline:a,font:o}=e,n={background:e.background,font:o.family,title:{color:t,font:o.family},axis:{labelColor:t,titleColor:t,domainColor:r,tickColor:r,gridColor:a,labelFont:o.family,titleFont:o.family},legend:{labelColor:t,titleColor:t,labelFont:o.family,titleFont:o.family},header:{labelColor:t,titleColor:t},range:{category:e.series}},l={...n,legend:{...n.legend,orient:"bottom"}};return i=>i==="shape_map"?l:n}function ye(e){if(!e)return;const t=e.tag("theme");if(!t)return;const r={},a=t.tag("palette");if(a){const n={},l=a.textArray("series");l&&l.length>0&&(n.series=l);for(const i of X.PER_MODE_COLOR_KEYS){const m=a.tag(i);if(!m)continue;const p={},C=m.text("light"),x=m.text("dark");C&&(p.light=C),x&&(p.dark=x),Object.keys(p).length>0&&(n[i]=p)}Object.keys(n).length>0&&(r.palette=n)}const o=t.tag("font");if(o){const n={},l=o.text("family");l&&(n.family=l);const i=o.numeric("size");typeof i=="number"&&Number.isFinite(i)&&(n.size=i),Object.keys(n).length>0&&(r.font=n)}return Object.keys(r).length>0?r:void 0}const Z=e=>(e??[]).map(t=>t?.value).filter(t=>typeof t=="string");function xe(e){const t=e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const Ce=e=>Z(e.annotations).some(t=>{const r=t.trim();return/^#[^("]/.test(r)&&/(?:^#|[\s{])label\s*=/.test(r)}),Re=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Te=e=>e.type?.element_type?.fields??e.type?.fields;function pe(e,t){let r=!1;return{fields:e.map(o=>{const n=Te(o);if(n){const i=pe(n,u.requestsRowChart(Z(o.annotations)));if(!i.changed)return o;r=!0;const m=o.type?.element_type?{...o.type,element_type:{...o.type.element_type,fields:i.fields}}:{...o.type,fields:i.fields};return{...o,type:m}}if(!t||!o.name||Ce(o))return o;const l=xe(o.name);return l===o.name?o:(r=!0,{...o,annotations:[{value:`# label=${Re(l)}
2
- `},...o.annotations??[]]})}),changed:r}}function Ae(e){if(!e||typeof e!="object")return e;const t=e,r=t.schema?.fields;if(!Array.isArray(r))return e;const{fields:a,changed:o}=pe(r,u.requestsRowChart(Z(t.annotations)));return o?{...t,schema:{...t.schema,fields:a}}:e}const ce=320,Ee=10,Se=96,_e=4e3;function De(e,t){if(e!=="bar"&&e!=="combo"&&e!=="line"&&e!=="chart"&&e!=="scatter_chart")return;if(e!=="bar"&&e!=="combo")return ce;const r=t?.data?.array_value?.length,a=r===void 0?0:r*Ee+Se;return Math.min(Math.max(ce,a),_e)}function Oe(e){let t;return{onClick:r=>{const a={...r,...Le(r)};t=a,queueMicrotask(()=>{t===a&&(t=void 0),e(a)})},onDrill:r=>{const a=t;t=void 0,a&&r.stableDrillClauses!==void 0&&(a.drillClauses=r.stableDrillClauses)}}}function Le(e){const t=e.field;try{const r=t?.getEffectiveQueryTimezone?.();return r?{timezone:r}:{}}catch{return{}}}function ze(e){const t=r=>{let a=!1;try{a=r.isArray?.()===!0}catch{a=!1}a&&"stableDrillFilters"in r&&Object.defineProperty(r,"stableDrillFilters",{configurable:!0,get:()=>[]});for(const o of r.fields??[])t(o)};e&&t(e)}const B="data-publisher-fill",Fe=async(e,t,r)=>{if(typeof window>"u")throw new Error("MalloyRenderer can only be used in browser environment");const{MalloyRenderer:a}=await u.loadMalloyRenderer();return new a({onClick:t,...r?{onDrill:r,tableConfig:{enableDrill:!0}}:{},vegaConfigOverride:fe(e),theme:be(e),onError:n=>{console.error("Error rendering visualization:",typeof n,n)}}).createViz()};async function Ie(e){if(!e||typeof e!="object")return;const t=e,r=[...Array.isArray(t.model_annotations)?t.model_annotations:[],...Array.isArray(t.source_annotations)?t.source_annotations:[],...Array.isArray(t.annotations)?t.annotations:[]].map(o=>typeof o?.value=="string"?o.value:void 0).filter(o=>!!o);if(r.length===0)return;let a;try{({parseAnnotation:a}=await u.loadMalloyTag())}catch{return}try{const{tag:o}=a(r);return ye(o)}catch(o){console.warn("Failed to parse # theme.* annotations; chart will render with the shell theme.",{error:o,lines:r});return}}function Me(e,t,r){const a=u.buildTableCssVars(t,r);for(const[o,n]of Object.entries(a))e.style.setProperty(o,n)}const $e=`
1
+ "use strict";const $=require("react/jsx-runtime"),de=require("@mui/material"),w=require("react"),u=require("./useCompiledDocument-UADoxvYb.cjs.js"),G=require("./ServerProvider-Cvllj0GN.cjs.js"),v=u.reportClasses.drillCell;function me(e,t){const r=new Set;let a;try{a=e.getMetadata()?.getAllFields()??[]}catch{return r}const o=new Set;for(const n of a)!n||t(n)||n.tag?.tag("hidden")===void 0&&o.add(n.tag?.text("label")??n.name);for(const n of a){if(!n||!t(n))continue;const l=n.tag?.text("label")??n.name;o.has(l)||r.add(l)}return r}function j(e){const t=/^\s*(\d+)/.exec(e.style?.gridColumn??"");return t?t[1]:void 0}function be(e,t){if(t.size!==0)for(const r of e.querySelectorAll(".malloy-table")){const a=l=>l.closest(".malloy-table")===r,o=new Set;for(const l of r.querySelectorAll(".column-cell.th")){if(!a(l))continue;const i=(l.textContent??"").replace(/\u200b/g,"").trim(),m=j(l);m&&t.has(i)&&o.add(m)}if(o.size===0)continue;const n=new Set;for(const l of r.querySelectorAll(`.${v}[tabindex="0"]`)){if(!a(l))continue;const i=j(l);i&&(n.has(i)?l.tabIndex=-1:n.add(i))}for(const l of r.querySelectorAll(".column-cell.td")){if(!a(l))continue;const i=j(l),m=!l.querySelector(".value-null")&&(l.textContent??"").trim()!=="";if(i&&m&&o.has(i)&&!l.querySelector(".malloy-table")){if(l.classList.add(v),l.tabIndex===0)n.add(i);else{const p=n.has(i);p||n.add(i),l.tabIndex=p?-1:0}l.setAttribute("role","button")}}}}function Ce(e){const t=e.closest(".malloy-table"),r=j(e);return!t||!r?[]:Array.from(t.querySelectorAll(`.${v}`)).filter(a=>a.closest(".malloy-table")===t&&j(a)===r)}function ce(e,t){const r=Ce(e),a=r.indexOf(e);if(a===-1)return;const o=t==="first"?r[0]:t==="last"?r[r.length-1]:r[Math.min(Math.max(a+t,0),r.length-1)];if(o){for(const n of r)n.tabIndex=n===o?0:-1;return o}}function fe(e){return{background:e.dashboardRoot,tableBackground:e.tableBackground,tableHeaderColor:e.tableHeader,tableBodyColor:e.tableBody,tableBorder:e.border,tablePinnedBackground:e.tableHeaderBackground,tablePinnedBorder:e.pinnedBorder,tableFontSize:`${e.font.size}px`,fontFamily:e.font.family,mapColor:e.mapColor}}function ye(e){const{foreground:t,axisFaint:r,gridline:a,font:o}=e,n={background:e.background,font:o.family,title:{color:t,font:o.family},axis:{labelColor:t,titleColor:t,domainColor:r,tickColor:r,gridColor:a,labelFont:o.family,titleFont:o.family},legend:{labelColor:t,titleColor:t,labelFont:o.family,titleFont:o.family},header:{labelColor:t,titleColor:t},range:{category:e.series}},l={...n,legend:{...n.legend,orient:"bottom"}};return i=>i==="shape_map"?l:n}function pe(e){if(!e)return;const t=e.tag("theme");if(!t)return;const r={},a=t.tag("palette");if(a){const n={},l=a.textArray("series");l&&l.length>0&&(n.series=l);for(const i of G.PER_MODE_COLOR_KEYS){const m=a.tag(i);if(!m)continue;const p={},C=m.text("light"),x=m.text("dark");C&&(p.light=C),x&&(p.dark=x),Object.keys(p).length>0&&(n[i]=p)}Object.keys(n).length>0&&(r.palette=n)}const o=t.tag("font");if(o){const n={},l=o.text("family");l&&(n.family=l);const i=o.numeric("size");typeof i=="number"&&Number.isFinite(i)&&(n.size=i),Object.keys(n).length>0&&(r.font=n)}return Object.keys(r).length>0?r:void 0}const ee=e=>(e??[]).map(t=>t?.value).filter(t=>typeof t=="string");function Re(e){const t=e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const Te=e=>ee(e.annotations).some(t=>{const r=t.trim();return/^#[^("]/.test(r)&&/(?:^#|[\s{])label\s*=/.test(r)}),Ae=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`,Ee=e=>e.type?.element_type?.fields??e.type?.fields;function ge(e,t){let r=!1;return{fields:e.map(o=>{const n=Ee(o);if(n){const i=ge(n,u.requestsRowChart(ee(o.annotations)));if(!i.changed)return o;r=!0;const m=o.type?.element_type?{...o.type,element_type:{...o.type.element_type,fields:i.fields}}:{...o.type,fields:i.fields};return{...o,type:m}}if(!t||!o.name||Te(o))return o;const l=Re(o.name);return l===o.name?o:(r=!0,{...o,annotations:[{value:`# label=${Ae(l)}
2
+ `},...o.annotations??[]]})}),changed:r}}function Se(e){if(!e||typeof e!="object")return e;const t=e,r=t.schema?.fields;if(!Array.isArray(r))return e;const{fields:a,changed:o}=ge(r,u.requestsRowChart(ee(t.annotations)));return o?{...t,schema:{...t.schema,fields:a}}:e}const ue=320,_e=10,De=96,Oe=4e3;function Fe(e,t){if(e!=="bar"&&e!=="combo"&&e!=="line"&&e!=="chart"&&e!=="scatter_chart")return;if(e!=="bar"&&e!=="combo")return ue;const r=t?.data?.array_value?.length,a=r===void 0?0:r*_e+De;return Math.min(Math.max(ue,a),Oe)}function Le(e){let t;return{onClick:r=>{const a={...r,...ze(r)};t=a,queueMicrotask(()=>{t===a&&(t=void 0),e(a)})},onDrill:r=>{const a=t;t=void 0,a&&r.stableDrillClauses!==void 0&&(a.drillClauses=r.stableDrillClauses)}}}function ze(e){const t=e.field;try{const r=t?.getEffectiveQueryTimezone?.();return r?{timezone:r}:{}}catch{return{}}}function Ie(e){const t=r=>{let a=!1;try{a=r.isArray?.()===!0}catch{a=!1}a&&"stableDrillFilters"in r&&Object.defineProperty(r,"stableDrillFilters",{configurable:!0,get:()=>[]});for(const o of r.fields??[])t(o)};e&&t(e)}const B="data-publisher-fill";let X;function ve(){if(X===void 0)try{X=new Function("return true")()===!0}catch{X=!1}return X}const Me=async(e,t,r)=>{if(typeof window>"u")throw new Error("MalloyRenderer can only be used in browser environment");const{MalloyRenderer:a}=await u.loadMalloyRenderer();return new a({onClick:t,...r?{onDrill:r,tableConfig:{enableDrill:!0}}:{},vegaConfigOverride:ye(e),...ve()?{}:{useVegaInterpreter:!0},theme:fe(e),onError:n=>{console.error("Error rendering visualization:",typeof n,n)}}).createViz()};async function $e(e){if(!e||typeof e!="object")return;const t=e,r=[...Array.isArray(t.model_annotations)?t.model_annotations:[],...Array.isArray(t.source_annotations)?t.source_annotations:[],...Array.isArray(t.annotations)?t.annotations:[]].map(o=>typeof o?.value=="string"?o.value:void 0).filter(o=>!!o);if(r.length===0)return;let a;try{({parseAnnotation:a}=await u.loadMalloyTag())}catch{return}try{const{tag:o}=a(r);return pe(o)}catch(o){console.warn("Failed to parse # theme.* annotations; chart will render with the shell theme.",{error:o,lines:r});return}}function Be(e,t,r){const a=u.buildTableCssVars(t,r);for(const[o,n]of Object.entries(a))e.style.setProperty(o,n)}const je=`
3
3
  /* Card geometry, through the renderer's OWN theme vars rather than over the top
4
4
  of them. It declares --malloy-theme--dashboard-* on .malloy-render itself and
5
5
  passes each through to the --malloy-render--* the card CSS reads, so a value
@@ -176,4 +176,4 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
176
176
  .malloy-render .malloy-table .td.highlight:not(.${v}) {
177
177
  cursor: inherit;
178
178
  }
179
- `,ue="publisher-malloy-renderer-overrides";function Be(){if(typeof document>"u"||document.getElementById(ue))return;const e=document.createElement("style");e.id=ue,e.textContent=$e,document.head.appendChild(e)}function je({result:e,height:t,drill:r,onSizeChange:a,onSizing:o,fill:n}){const l=w.useRef(null),i=w.useRef(r);i.current=r;const m=w.useMemo(()=>Oe(d=>i.current?.onClick(d)),[]),p=r!==void 0,C=w.useRef(!1),x=w.useRef(null),G=w.useRef(0),{theme:N,layers:W,mode:ee}=X.usePublisherTheme(),te=w.useMemo(()=>({radius:N.ui.radius.tile,padding:`${u.DASHBOARD_CARD_PADDING_PX}px`}),[N.ui.radius.tile]);return w.useEffect(()=>()=>{G.current+=1;const d=x.current;d?.viz.remove(),d?.node.remove(),x.current=null},[]),w.useLayoutEffect(()=>{if(!l.current||!e)return;Be();const d=l.current,ve=G.current+=1;let K=!1;const U=()=>!K&&ve===G.current;let c,f,P=null,Y=0,q=null,H=null,V=null,L=null,z=null,F=null,re=null,oe=0,S=null;C.current=!1;let g,_;const J=k=>{if(K||!k.firstElementChild||u.resultSizing(g,_)==="container")return;const I=u.remeasuresAfterReady(g,_);if(C.current&&!I)return;const M=d.hasAttribute(B);M&&d.removeAttribute(B);const R=d.closest(`.${u.RESULT_SCROLLER_CLASS}`),h=R?.style.overflowY;R&&(R.style.overflowY="hidden");const D=u.measureContentHeight(k,u.contentNodeDepth(g));R&&(R.style.overflowY=h??""),M&&d.setAttribute(B,""),D>0&&(C.current=!0,a&&D!==oe&&(oe=D,a(D)));const T=u.contentNode(k,u.contentNodeDepth(g));I&&T&&re!==T&&(re=T,F?.disconnect(),F=new ResizeObserver(()=>J(k)),F.observe(T))};return(async()=>{let k;try{k=JSON.parse(e)}catch(b){console.error("Error parsing visualization result:",b);return}const I=await Ie(k),M=I?X.resolveTheme([...W,X.chartThemeLayer(W,I)],ee):N;if(!U())return;try{f=await Fe(M,m.onClick,p?m.onDrill:void 0)}catch(b){console.error("Failed to create renderer:",b);return}if(!U()){f.remove(),f=void 0;return}const R=x.current;c=document.createElement("div"),c.style.width="100%",c.style.height="100%",Me(c,M,te),d.childElementCount>0&&(d.style.position="relative",c.style.position="absolute",c.style.inset="0",c.style.visibility="hidden"),d.appendChild(c);const h=c;L=new MutationObserver(()=>{z&&clearTimeout(z),z=setTimeout(()=>{J(h),C.current&&L?.disconnect()},100)}),L.observe(c,{childList:!0,subtree:!0,attributes:!0});const D=f;let T=!1;const ae=()=>{if(!(T||!U())){T=!0,S&&(clearTimeout(S),S=null),R?.viz.remove();for(const b of Array.from(d.children))b!==h&&d.removeChild(b);h.style.position="",h.style.inset="",h.style.visibility="",d.style.position="",x.current={viz:D,node:h},J(h)}};try{f.setResult(Ae(k));try{const A=f.getMetadata(),E=A?.getRootField();p&&ze(E),g=E?.renderAs(),_=E?A?.getPluginsForField(E.key)?.[0]?.sizingStrategy:void 0}catch{g=void 0,_=void 0}o?.(u.resultSizing(g,_),g),c.dataset.malloyRenderAs=g??"unknown",c.dataset.malloySizing=u.resultSizing(g,_);const b=De(g,k);c.style.minWidth=b===void 0?"":`${b}px`,d.style.overflowX=b===void 0?"":"auto",d.style.overflowY=b===void 0?"":"hidden",f.render(c);const ne=i.current;try{if(ne){const A=he(f,ne.canDrill),E=()=>{try{me(h,A)}catch(s){console.warn("Drill affordance skipped:",s)}};E();const le=s=>{const O=s.querySelector(".cell-content")??s,Q=O.getBoundingClientRect();O.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:O.ownerDocument.defaultView,clientX:Math.round(Q.left+Q.width/2),clientY:Math.round(Q.bottom)}))},ie=s=>s.target?.closest?.(`.${v}`)??null,we=(s,y)=>{de(s,y)?.focus()};q=s=>{const y=ie(s);if(!y)return;const O=s.key==="ArrowDown"?1:s.key==="ArrowUp"?-1:s.key==="Home"?"first":s.key==="End"?"last":void 0;if(O!==void 0){s.preventDefault(),we(y,O);return}s.key==="Enter"?(s.preventDefault(),le(y)):s.key===" "&&s.preventDefault()},H=s=>{if(s.key!==" ")return;const y=ie(s);y&&(s.preventDefault(),le(y))},V=s=>{const y=s.target?.closest?.(`.${v}`);y&&de(y,0)},h.addEventListener("keydown",q),h.addEventListener("keyup",H),h.addEventListener("focusin",V),A.size>0&&typeof MutationObserver<"u"&&(P=new MutationObserver(()=>{cancelAnimationFrame(Y),Y=requestAnimationFrame(E)}),P.observe(h,{childList:!0,subtree:!0}))}}catch(A){console.warn("Drill affordance skipped:",A)}f.onReady(ae),S=setTimeout(ae,1e4)}catch(b){console.error("Error rendering visualization:",b),L?.disconnect(),F?.disconnect(),P?.disconnect(),f.remove(),f=void 0,h.parentNode===d&&d.removeChild(h)}})(),()=>{K=!0,L?.disconnect(),F?.disconnect(),z&&clearTimeout(z),S&&clearTimeout(S),c&&x.current?.node!==c&&(q&&c.removeEventListener("keydown",q),H&&c.removeEventListener("keyup",H),V&&c.removeEventListener("focusin",V),P?.disconnect(),cancelAnimationFrame(Y),f?.remove(),c.parentNode===d&&d.removeChild(c),d.style.position="")}},[e,m,p,a,o,N,W,ee,te]),$.jsx("div",{ref:l,...n?{[B]:""}:{},style:{width:"100%",height:t?`${t}px`:"400px"}})}function ge(e){return typeof window>"u"?$.jsx(se.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading..."}):$.jsx(w.Suspense,{fallback:$.jsx(se.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading visualization..."}),children:$.jsx(je,{...e})})}const Ne=Object.freeze(Object.defineProperty({__proto__:null,default:ge},Symbol.toStringTag,{value:"Module"}));exports.DRILL_CELL_CLASS=v;exports.RenderedResult=ge;exports.RenderedResult$1=Ne;exports.buildMalloyExplicitTheme=be;exports.buildVegaThemeOverride=fe;exports.drillableFieldNames=he;exports.markDrillableCells=me;exports.readChartAnnotations=ye;
179
+ `,he="publisher-malloy-renderer-overrides";function Ne(){if(typeof document>"u"||document.getElementById(he))return;const e=document.createElement("style");e.id=he,e.textContent=je,document.head.appendChild(e)}function Pe({result:e,height:t,drill:r,onSizeChange:a,onSizing:o,fill:n}){const l=w.useRef(null),i=w.useRef(r);i.current=r;const m=w.useMemo(()=>Le(d=>i.current?.onClick(d)),[]),p=r!==void 0,C=w.useRef(!1),x=w.useRef(null),W=w.useRef(0),{theme:N,layers:K,mode:te}=G.usePublisherTheme(),re=w.useMemo(()=>({radius:N.ui.radius.tile,padding:`${u.DASHBOARD_CARD_PADDING_PX}px`}),[N.ui.radius.tile]);return w.useEffect(()=>()=>{W.current+=1;const d=x.current;d?.viz.remove(),d?.node.remove(),x.current=null},[]),w.useLayoutEffect(()=>{if(!l.current||!e)return;Ne();const d=l.current,ke=W.current+=1;let U=!1;const Y=()=>!U&&ke===W.current;let c,f,P=null,J=0,q=null,H=null,V=null,F=null,L=null,z=null,oe=null,ae=0,S=null;C.current=!1;let g,_;const Q=k=>{if(U||!k.firstElementChild||u.resultSizing(g,_)==="container")return;const I=u.remeasuresAfterReady(g,_);if(C.current&&!I)return;const M=d.hasAttribute(B);M&&d.removeAttribute(B);const R=d.closest(`.${u.RESULT_SCROLLER_CLASS}`),h=R?.style.overflowY;R&&(R.style.overflowY="hidden");const D=u.measureContentHeight(k,u.contentNodeDepth(g));R&&(R.style.overflowY=h??""),M&&d.setAttribute(B,""),D>0&&(C.current=!0,a&&D!==ae&&(ae=D,a(D)));const T=u.contentNode(k,u.contentNodeDepth(g));I&&T&&oe!==T&&(oe=T,z?.disconnect(),z=new ResizeObserver(()=>Q(k)),z.observe(T))};return(async()=>{let k;try{k=JSON.parse(e)}catch(b){console.error("Error parsing visualization result:",b);return}const I=await $e(k),M=I?G.resolveTheme([...K,G.chartThemeLayer(K,I)],te):N;if(!Y())return;try{f=await Me(M,m.onClick,p?m.onDrill:void 0)}catch(b){console.error("Failed to create renderer:",b);return}if(!Y()){f.remove(),f=void 0;return}const R=x.current;c=document.createElement("div"),c.style.width="100%",c.style.height="100%",Be(c,M,re),d.childElementCount>0&&(d.style.position="relative",c.style.position="absolute",c.style.inset="0",c.style.visibility="hidden"),d.appendChild(c);const h=c;F=new MutationObserver(()=>{L&&clearTimeout(L),L=setTimeout(()=>{Q(h),C.current&&F?.disconnect()},100)}),F.observe(c,{childList:!0,subtree:!0,attributes:!0});const D=f;let T=!1;const ne=()=>{if(!(T||!Y())){T=!0,S&&(clearTimeout(S),S=null),R?.viz.remove();for(const b of Array.from(d.children))b!==h&&d.removeChild(b);h.style.position="",h.style.inset="",h.style.visibility="",d.style.position="",x.current={viz:D,node:h},Q(h)}};try{f.setResult(Se(k));try{const A=f.getMetadata(),E=A?.getRootField();p&&Ie(E),g=E?.renderAs(),_=E?A?.getPluginsForField(E.key)?.[0]?.sizingStrategy:void 0}catch{g=void 0,_=void 0}o?.(u.resultSizing(g,_),g),c.dataset.malloyRenderAs=g??"unknown",c.dataset.malloySizing=u.resultSizing(g,_);const b=Fe(g,k);c.style.minWidth=b===void 0?"":`${b}px`,d.style.overflowX=b===void 0?"":"auto",d.style.overflowY=b===void 0?"":"hidden",f.render(c);const le=i.current;try{if(le){const A=me(f,le.canDrill),E=()=>{try{be(h,A)}catch(s){console.warn("Drill affordance skipped:",s)}};E();const ie=s=>{const O=s.querySelector(".cell-content")??s,Z=O.getBoundingClientRect();O.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:O.ownerDocument.defaultView,clientX:Math.round(Z.left+Z.width/2),clientY:Math.round(Z.bottom)}))},se=s=>s.target?.closest?.(`.${v}`)??null,xe=(s,y)=>{ce(s,y)?.focus()};q=s=>{const y=se(s);if(!y)return;const O=s.key==="ArrowDown"?1:s.key==="ArrowUp"?-1:s.key==="Home"?"first":s.key==="End"?"last":void 0;if(O!==void 0){s.preventDefault(),xe(y,O);return}s.key==="Enter"?(s.preventDefault(),ie(y)):s.key===" "&&s.preventDefault()},H=s=>{if(s.key!==" ")return;const y=se(s);y&&(s.preventDefault(),ie(y))},V=s=>{const y=s.target?.closest?.(`.${v}`);y&&ce(y,0)},h.addEventListener("keydown",q),h.addEventListener("keyup",H),h.addEventListener("focusin",V),A.size>0&&typeof MutationObserver<"u"&&(P=new MutationObserver(()=>{cancelAnimationFrame(J),J=requestAnimationFrame(E)}),P.observe(h,{childList:!0,subtree:!0}))}}catch(A){console.warn("Drill affordance skipped:",A)}f.onReady(ne),S=setTimeout(ne,1e4)}catch(b){console.error("Error rendering visualization:",b),F?.disconnect(),z?.disconnect(),P?.disconnect(),f.remove(),f=void 0,h.parentNode===d&&d.removeChild(h)}})(),()=>{U=!0,F?.disconnect(),z?.disconnect(),L&&clearTimeout(L),S&&clearTimeout(S),c&&x.current?.node!==c&&(q&&c.removeEventListener("keydown",q),H&&c.removeEventListener("keyup",H),V&&c.removeEventListener("focusin",V),P?.disconnect(),cancelAnimationFrame(J),f?.remove(),c.parentNode===d&&d.removeChild(c),d.style.position="")}},[e,m,p,a,o,N,K,te,re]),$.jsx("div",{ref:l,...n?{[B]:""}:{},style:{width:"100%",height:t?`${t}px`:"400px"}})}function we(e){return typeof window>"u"?$.jsx(de.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading..."}):$.jsx(w.Suspense,{fallback:$.jsx(de.Box,{sx:{width:"100%",height:e.height?`${e.height}px`:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:"Loading visualization..."}),children:$.jsx(Pe,{...e})})}const qe=Object.freeze(Object.defineProperty({__proto__:null,default:we,pageAllowsEval:ve},Symbol.toStringTag,{value:"Module"}));exports.DRILL_CELL_CLASS=v;exports.RenderedResult=we;exports.RenderedResult$1=qe;exports.buildMalloyExplicitTheme=fe;exports.buildVegaThemeOverride=ye;exports.drillableFieldNames=me;exports.markDrillableCells=be;exports.readChartAnnotations=pe;
@@ -1,10 +1,10 @@
1
1
  import { jsx as I } from "react/jsx-runtime";
2
- import { Box as se } from "@mui/material";
3
- import { Suspense as ge, useRef as M, useMemo as de, useEffect as ve, useLayoutEffect as we } from "react";
4
- import { r as ke, a as be, D as xe, b as Q, T as V, l as Ce, c as Re, d as Ee, e as Te, R as Ae, m as Se, f as _e, g as ce } from "./useCompiledDocument-XJMCZF8O.es.js";
5
- import { bt as De, br as Oe, bu as Fe, bv as ze } from "./ServerProvider-Qd3zdOsC.es.js";
6
- const g = ke.drillCell;
7
- function Le(e, t) {
2
+ import { Box as de } from "@mui/material";
3
+ import { Suspense as we, useRef as M, useMemo as ce, useEffect as ke, useLayoutEffect as xe } from "react";
4
+ import { r as Ce, a as fe, D as Re, b as Z, T as V, l as Ee, c as Ae, d as Te, e as Se, R as _e, m as De, f as Oe, g as ue } from "./useCompiledDocument-CwMwrEXo.es.js";
5
+ import { bx as Fe, bv as ze, by as Le, bz as Me } from "./ServerProvider-8Eul_YOl.es.js";
6
+ const g = Ce.drillCell;
7
+ function Ie(e, t) {
8
8
  const r = /* @__PURE__ */ new Set();
9
9
  let a;
10
10
  try {
@@ -26,7 +26,7 @@ function B(e) {
26
26
  const t = /^\s*(\d+)/.exec(e.style?.gridColumn ?? "");
27
27
  return t ? t[1] : void 0;
28
28
  }
29
- function Me(e, t) {
29
+ function $e(e, t) {
30
30
  if (t.size !== 0)
31
31
  for (const r of e.querySelectorAll(
32
32
  ".malloy-table"
@@ -65,7 +65,7 @@ function Me(e, t) {
65
65
  }
66
66
  }
67
67
  }
68
- function Ie(e) {
68
+ function Be(e) {
69
69
  const t = e.closest(".malloy-table"), r = B(e);
70
70
  return !t || !r ? [] : Array.from(
71
71
  t.querySelectorAll(`.${g}`)
@@ -73,8 +73,8 @@ function Ie(e) {
73
73
  (a) => a.closest(".malloy-table") === t && B(a) === r
74
74
  );
75
75
  }
76
- function ue(e, t) {
77
- const r = Ie(e), a = r.indexOf(e);
76
+ function he(e, t) {
77
+ const r = Be(e), a = r.indexOf(e);
78
78
  if (a === -1) return;
79
79
  const o = t === "first" ? r[0] : t === "last" ? r[r.length - 1] : r[Math.min(Math.max(a + t, 0), r.length - 1)];
80
80
  if (o) {
@@ -82,7 +82,7 @@ function ue(e, t) {
82
82
  return o;
83
83
  }
84
84
  }
85
- function $e(e) {
85
+ function Ne(e) {
86
86
  return {
87
87
  background: e.dashboardRoot,
88
88
  tableBackground: e.tableBackground,
@@ -104,7 +104,7 @@ function $e(e) {
104
104
  mapColor: e.mapColor
105
105
  };
106
106
  }
107
- function Be(e) {
107
+ function Pe(e) {
108
108
  const { foreground: t, axisFaint: r, gridline: a, font: o } = e, n = {
109
109
  background: e.background,
110
110
  font: o.family,
@@ -132,7 +132,7 @@ function Be(e) {
132
132
  };
133
133
  return (i) => i === "shape_map" ? l : n;
134
134
  }
135
- function Ne(e) {
135
+ function je(e) {
136
136
  if (!e) return;
137
137
  const t = e.tag("theme");
138
138
  if (!t) return;
@@ -140,7 +140,7 @@ function Ne(e) {
140
140
  if (a) {
141
141
  const n = {}, l = a.textArray("series");
142
142
  l && l.length > 0 && (n.series = l);
143
- for (const i of De) {
143
+ for (const i of Fe) {
144
144
  const h = a.tag(i);
145
145
  if (!h) continue;
146
146
  const y = {}, k = h.text("light"), w = h.text("dark");
@@ -157,23 +157,23 @@ function Ne(e) {
157
157
  }
158
158
  return Object.keys(r).length > 0 ? r : void 0;
159
159
  }
160
- const Z = (e) => (e ?? []).map((t) => t?.value).filter((t) => typeof t == "string");
161
- function Pe(e) {
160
+ const ee = (e) => (e ?? []).map((t) => t?.value).filter((t) => typeof t == "string");
161
+ function He(e) {
162
162
  const t = e.replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim();
163
163
  return t.charAt(0).toUpperCase() + t.slice(1);
164
164
  }
165
- const je = (e) => Z(e.annotations).some((t) => {
165
+ const qe = (e) => ee(e.annotations).some((t) => {
166
166
  const r = t.trim();
167
167
  return /^#[^("]/.test(r) && /(?:^#|[\s{])label\s*=/.test(r);
168
- }), He = (e) => `"${e.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`, qe = (e) => e.type?.element_type?.fields ?? e.type?.fields;
169
- function fe(e, t) {
168
+ }), Ve = (e) => `"${e.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`, Xe = (e) => e.type?.element_type?.fields ?? e.type?.fields;
169
+ function ye(e, t) {
170
170
  let r = !1;
171
171
  return { fields: e.map((o) => {
172
- const n = qe(o);
172
+ const n = Xe(o);
173
173
  if (n) {
174
- const i = fe(
174
+ const i = ye(
175
175
  n,
176
- be(Z(o.annotations))
176
+ fe(ee(o.annotations))
177
177
  );
178
178
  if (!i.changed) return o;
179
179
  r = !0;
@@ -186,43 +186,43 @@ function fe(e, t) {
186
186
  } : { ...o.type, fields: i.fields };
187
187
  return { ...o, type: h };
188
188
  }
189
- if (!t || !o.name || je(o)) return o;
190
- const l = Pe(o.name);
189
+ if (!t || !o.name || qe(o)) return o;
190
+ const l = He(o.name);
191
191
  return l === o.name ? o : (r = !0, {
192
192
  ...o,
193
193
  annotations: [
194
- { value: `# label=${He(l)}
194
+ { value: `# label=${Ve(l)}
195
195
  ` },
196
196
  ...o.annotations ?? []
197
197
  ]
198
198
  });
199
199
  }), changed: r };
200
200
  }
201
- function Ve(e) {
201
+ function We(e) {
202
202
  if (!e || typeof e != "object") return e;
203
203
  const t = e, r = t.schema?.fields;
204
204
  if (!Array.isArray(r)) return e;
205
- const { fields: a, changed: o } = fe(
205
+ const { fields: a, changed: o } = ye(
206
206
  r,
207
- be(Z(t.annotations))
207
+ fe(ee(t.annotations))
208
208
  );
209
209
  return o ? { ...t, schema: { ...t.schema, fields: a } } : e;
210
210
  }
211
- const he = 320, Xe = 10, We = 96, Ke = 4e3;
212
- function Ue(e, t) {
211
+ const me = 320, Ke = 10, Ue = 96, Ye = 4e3;
212
+ function Ge(e, t) {
213
213
  if (e !== "bar" && e !== "combo" && e !== "line" && e !== "chart" && e !== "scatter_chart")
214
214
  return;
215
- if (e !== "bar" && e !== "combo") return he;
216
- const r = t?.data?.array_value?.length, a = r === void 0 ? 0 : r * Xe + We;
217
- return Math.min(Math.max(he, a), Ke);
215
+ if (e !== "bar" && e !== "combo") return me;
216
+ const r = t?.data?.array_value?.length, a = r === void 0 ? 0 : r * Ke + Ue;
217
+ return Math.min(Math.max(me, a), Ye);
218
218
  }
219
- function Ye(e) {
219
+ function Je(e) {
220
220
  let t;
221
221
  return {
222
222
  onClick: (r) => {
223
223
  const a = {
224
224
  ...r,
225
- ...Ge(r)
225
+ ...Qe(r)
226
226
  };
227
227
  t = a, queueMicrotask(() => {
228
228
  t === a && (t = void 0), e(a);
@@ -234,7 +234,7 @@ function Ye(e) {
234
234
  }
235
235
  };
236
236
  }
237
- function Ge(e) {
237
+ function Qe(e) {
238
238
  const t = e.field;
239
239
  try {
240
240
  const r = t?.getEffectiveQueryTimezone?.();
@@ -243,7 +243,7 @@ function Ge(e) {
243
243
  return {};
244
244
  }
245
245
  }
246
- function Je(e) {
246
+ function Ze(e) {
247
247
  const t = (r) => {
248
248
  let a = !1;
249
249
  try {
@@ -259,28 +259,41 @@ function Je(e) {
259
259
  };
260
260
  e && t(e);
261
261
  }
262
- const $ = "data-publisher-fill", Qe = async (e, t, r) => {
262
+ const $ = "data-publisher-fill";
263
+ let X;
264
+ function pe() {
265
+ if (X === void 0)
266
+ try {
267
+ X = new Function("return true")() === !0;
268
+ } catch {
269
+ X = !1;
270
+ }
271
+ return X;
272
+ }
273
+ const et = async (e, t, r) => {
263
274
  if (typeof window > "u")
264
275
  throw new Error("MalloyRenderer can only be used in browser environment");
265
- const { MalloyRenderer: a } = await Re();
276
+ const { MalloyRenderer: a } = await Ae();
266
277
  return new a({
267
278
  onClick: t,
268
279
  // A table cell's row reaches the host only through the renderer's drill,
269
280
  // which it reports only with `enableDrill` set; see `drillClickRelay`.
270
281
  ...r ? { onDrill: r, tableConfig: { enableDrill: !0 } } : {},
271
- vegaConfigOverride: Be(e),
282
+ vegaConfigOverride: Pe(e),
283
+ // Charts under a CSP that refuses eval; see `pageAllowsEval`.
284
+ ...pe() ? {} : { useVegaInterpreter: !0 },
272
285
  // Pass the explicit theme so table chrome and dashboard tiles
273
286
  // pick up the operator's colours directly. Without this the
274
287
  // renderer's own inline style writes `--malloy-render--*` values
275
288
  // sourced from its built-in defaults and shadows whatever we set
276
289
  // on the outer wrapper.
277
- theme: $e(e),
290
+ theme: Ne(e),
278
291
  onError: (n) => {
279
292
  console.error("Error rendering visualization:", typeof n, n);
280
293
  }
281
294
  }).createViz();
282
295
  };
283
- async function Ze(e) {
296
+ async function tt(e) {
284
297
  if (!e || typeof e != "object") return;
285
298
  const t = e, r = [
286
299
  ...Array.isArray(t.model_annotations) ? t.model_annotations : [],
@@ -290,13 +303,13 @@ async function Ze(e) {
290
303
  if (r.length === 0) return;
291
304
  let a;
292
305
  try {
293
- ({ parseAnnotation: a } = await Ce());
306
+ ({ parseAnnotation: a } = await Ee());
294
307
  } catch {
295
308
  return;
296
309
  }
297
310
  try {
298
311
  const { tag: o } = a(r);
299
- return Ne(o);
312
+ return je(o);
300
313
  } catch (o) {
301
314
  console.warn(
302
315
  "Failed to parse # theme.* annotations; chart will render with the shell theme.",
@@ -305,12 +318,12 @@ async function Ze(e) {
305
318
  return;
306
319
  }
307
320
  }
308
- function et(e, t, r) {
309
- const a = Ee(t, r);
321
+ function rt(e, t, r) {
322
+ const a = Te(t, r);
310
323
  for (const [o, n] of Object.entries(a))
311
324
  e.style.setProperty(o, n);
312
325
  }
313
- const tt = `
326
+ const ot = `
314
327
  /* Card geometry, through the renderer's OWN theme vars rather than over the top
315
328
  of them. It declares --malloy-theme--dashboard-* on .malloy-render itself and
316
329
  passes each through to the --malloy-render--* the card CSS reads, so a value
@@ -487,13 +500,13 @@ div.malloy-render .malloy-dashboard .dashboard-row-header {
487
500
  .malloy-render .malloy-table .td.highlight:not(.${g}) {
488
501
  cursor: inherit;
489
502
  }
490
- `, me = "publisher-malloy-renderer-overrides";
491
- function rt() {
492
- if (typeof document > "u" || document.getElementById(me)) return;
503
+ `, be = "publisher-malloy-renderer-overrides";
504
+ function at() {
505
+ if (typeof document > "u" || document.getElementById(be)) return;
493
506
  const e = document.createElement("style");
494
- e.id = me, e.textContent = tt, document.head.appendChild(e);
507
+ e.id = be, e.textContent = ot, document.head.appendChild(e);
495
508
  }
496
- function ot({
509
+ function nt({
497
510
  result: e,
498
511
  height: t,
499
512
  drill: r,
@@ -503,48 +516,48 @@ function ot({
503
516
  }) {
504
517
  const l = M(null), i = M(r);
505
518
  i.current = r;
506
- const h = de(
507
- () => Ye((d) => i.current?.onClick(d)),
519
+ const h = ce(
520
+ () => Je((d) => i.current?.onClick(d)),
508
521
  []
509
522
  ), y = r !== void 0, k = M(!1), w = M(
510
523
  null
511
- ), X = M(0), { theme: N, layers: W, mode: ee } = Oe(), te = de(
524
+ ), W = M(0), { theme: N, layers: K, mode: te } = ze(), re = ce(
512
525
  () => ({
513
526
  radius: N.ui.radius.tile,
514
- padding: `${xe}px`
527
+ padding: `${Re}px`
515
528
  }),
516
529
  [N.ui.radius.tile]
517
530
  );
518
- return ve(() => () => {
519
- X.current += 1;
531
+ return ke(() => () => {
532
+ W.current += 1;
520
533
  const d = w.current;
521
534
  d?.viz.remove(), d?.node.remove(), w.current = null;
522
- }, []), we(() => {
535
+ }, []), xe(() => {
523
536
  if (!l.current || !e) return;
524
- rt();
525
- const d = l.current, ye = X.current += 1;
526
- let K = !1;
527
- const U = () => !K && ye === X.current;
528
- let c, b, P = null, Y = 0, j = null, H = null, q = null, D = null, O = null, F = null, re = null, oe = 0, T = null;
537
+ at();
538
+ const d = l.current, ge = W.current += 1;
539
+ let U = !1;
540
+ const Y = () => !U && ge === W.current;
541
+ let c, b, P = null, G = 0, j = null, H = null, q = null, D = null, O = null, F = null, oe = null, ae = 0, A = null;
529
542
  k.current = !1;
530
- let p, A;
531
- const G = (v) => {
532
- if (K || !v.firstElementChild || Q(p, A) === "container") return;
533
- const z = Te(p, A);
543
+ let p, T;
544
+ const J = (v) => {
545
+ if (U || !v.firstElementChild || Z(p, T) === "container") return;
546
+ const z = Se(p, T);
534
547
  if (k.current && !z) return;
535
548
  const L = d.hasAttribute($);
536
549
  L && d.removeAttribute($);
537
550
  const x = d.closest(
538
- `.${Ae}`
551
+ `.${_e}`
539
552
  ), u = x?.style.overflowY;
540
553
  x && (x.style.overflowY = "hidden");
541
- const S = Se(
554
+ const S = De(
542
555
  v,
543
- ce(p)
556
+ ue(p)
544
557
  );
545
- x && (x.style.overflowY = u ?? ""), L && d.setAttribute($, ""), S > 0 && (k.current = !0, a && S !== oe && (oe = S, a(S)));
546
- const C = _e(v, ce(p));
547
- z && C && re !== C && (re = C, F?.disconnect(), F = new ResizeObserver(() => G(v)), F.observe(C));
558
+ x && (x.style.overflowY = u ?? ""), L && d.setAttribute($, ""), S > 0 && (k.current = !0, a && S !== ae && (ae = S, a(S)));
559
+ const C = Oe(v, ue(p));
560
+ z && C && oe !== C && (oe = C, F?.disconnect(), F = new ResizeObserver(() => J(v)), F.observe(C));
548
561
  };
549
562
  return (async () => {
550
563
  let v;
@@ -554,10 +567,10 @@ function ot({
554
567
  console.error("Error parsing visualization result:", m);
555
568
  return;
556
569
  }
557
- const z = await Ze(v), L = z ? Fe([...W, ze(W, z)], ee) : N;
558
- if (!U()) return;
570
+ const z = await tt(v), L = z ? Le([...K, Me(K, z)], te) : N;
571
+ if (!Y()) return;
559
572
  try {
560
- b = await Qe(
573
+ b = await et(
561
574
  L,
562
575
  h.onClick,
563
576
  y ? h.onDrill : void 0
@@ -566,16 +579,16 @@ function ot({
566
579
  console.error("Failed to create renderer:", m);
567
580
  return;
568
581
  }
569
- if (!U()) {
582
+ if (!Y()) {
570
583
  b.remove(), b = void 0;
571
584
  return;
572
585
  }
573
586
  const x = w.current;
574
- c = document.createElement("div"), c.style.width = "100%", c.style.height = "100%", et(c, L, te), d.childElementCount > 0 && (d.style.position = "relative", c.style.position = "absolute", c.style.inset = "0", c.style.visibility = "hidden"), d.appendChild(c);
587
+ c = document.createElement("div"), c.style.width = "100%", c.style.height = "100%", rt(c, L, re), d.childElementCount > 0 && (d.style.position = "relative", c.style.position = "absolute", c.style.inset = "0", c.style.visibility = "hidden"), d.appendChild(c);
575
588
  const u = c;
576
589
  D = new MutationObserver(() => {
577
590
  O && clearTimeout(O), O = setTimeout(() => {
578
- G(u), k.current && D?.disconnect();
591
+ J(u), k.current && D?.disconnect();
579
592
  }, 100);
580
593
  }), D.observe(c, {
581
594
  childList: !0,
@@ -584,68 +597,68 @@ function ot({
584
597
  });
585
598
  const S = b;
586
599
  let C = !1;
587
- const ae = () => {
588
- if (!(C || !U())) {
589
- C = !0, T && (clearTimeout(T), T = null), x?.viz.remove();
600
+ const ne = () => {
601
+ if (!(C || !Y())) {
602
+ C = !0, A && (clearTimeout(A), A = null), x?.viz.remove();
590
603
  for (const m of Array.from(d.children))
591
604
  m !== u && d.removeChild(m);
592
- u.style.position = "", u.style.inset = "", u.style.visibility = "", d.style.position = "", w.current = { viz: S, node: u }, G(u);
605
+ u.style.position = "", u.style.inset = "", u.style.visibility = "", d.style.position = "", w.current = { viz: S, node: u }, J(u);
593
606
  }
594
607
  };
595
608
  try {
596
- b.setResult(Ve(v));
609
+ b.setResult(We(v));
597
610
  try {
598
611
  const R = b.getMetadata(), E = R?.getRootField();
599
- y && Je(E), p = E?.renderAs(), A = E ? R?.getPluginsForField(E.key)?.[0]?.sizingStrategy : void 0;
612
+ y && Ze(E), p = E?.renderAs(), T = E ? R?.getPluginsForField(E.key)?.[0]?.sizingStrategy : void 0;
600
613
  } catch {
601
- p = void 0, A = void 0;
614
+ p = void 0, T = void 0;
602
615
  }
603
- o?.(Q(p, A), p), c.dataset.malloyRenderAs = p ?? "unknown", c.dataset.malloySizing = Q(p, A);
604
- const m = Ue(p, v);
616
+ o?.(Z(p, T), p), c.dataset.malloyRenderAs = p ?? "unknown", c.dataset.malloySizing = Z(p, T);
617
+ const m = Ge(p, v);
605
618
  c.style.minWidth = m === void 0 ? "" : `${m}px`, d.style.overflowX = m === void 0 ? "" : "auto", d.style.overflowY = m === void 0 ? "" : "hidden", b.render(c);
606
- const ne = i.current;
619
+ const le = i.current;
607
620
  try {
608
- if (ne) {
609
- const R = Le(b, ne.canDrill), E = () => {
621
+ if (le) {
622
+ const R = Ie(b, le.canDrill), E = () => {
610
623
  try {
611
- Me(u, R);
624
+ $e(u, R);
612
625
  } catch (s) {
613
626
  console.warn("Drill affordance skipped:", s);
614
627
  }
615
628
  };
616
629
  E();
617
- const le = (s) => {
618
- const _ = s.querySelector(".cell-content") ?? s, J = _.getBoundingClientRect();
630
+ const ie = (s) => {
631
+ const _ = s.querySelector(".cell-content") ?? s, Q = _.getBoundingClientRect();
619
632
  _.dispatchEvent(
620
633
  new MouseEvent("click", {
621
634
  bubbles: !0,
622
635
  cancelable: !0,
623
636
  view: _.ownerDocument.defaultView,
624
- clientX: Math.round(J.left + J.width / 2),
625
- clientY: Math.round(J.bottom)
637
+ clientX: Math.round(Q.left + Q.width / 2),
638
+ clientY: Math.round(Q.bottom)
626
639
  })
627
640
  );
628
- }, ie = (s) => s.target?.closest?.(`.${g}`) ?? null, pe = (s, f) => {
629
- ue(s, f)?.focus();
641
+ }, se = (s) => s.target?.closest?.(`.${g}`) ?? null, ve = (s, f) => {
642
+ he(s, f)?.focus();
630
643
  };
631
644
  j = (s) => {
632
- const f = ie(s);
645
+ const f = se(s);
633
646
  if (!f) return;
634
647
  const _ = s.key === "ArrowDown" ? 1 : s.key === "ArrowUp" ? -1 : s.key === "Home" ? "first" : s.key === "End" ? "last" : void 0;
635
648
  if (_ !== void 0) {
636
- s.preventDefault(), pe(f, _);
649
+ s.preventDefault(), ve(f, _);
637
650
  return;
638
651
  }
639
- s.key === "Enter" ? (s.preventDefault(), le(f)) : s.key === " " && s.preventDefault();
652
+ s.key === "Enter" ? (s.preventDefault(), ie(f)) : s.key === " " && s.preventDefault();
640
653
  }, H = (s) => {
641
654
  if (s.key !== " ") return;
642
- const f = ie(s);
643
- f && (s.preventDefault(), le(f));
655
+ const f = se(s);
656
+ f && (s.preventDefault(), ie(f));
644
657
  }, q = (s) => {
645
658
  const f = s.target?.closest?.(`.${g}`);
646
- f && ue(f, 0);
659
+ f && he(f, 0);
647
660
  }, u.addEventListener("keydown", j), u.addEventListener("keyup", H), u.addEventListener("focusin", q), R.size > 0 && typeof MutationObserver < "u" && (P = new MutationObserver(() => {
648
- cancelAnimationFrame(Y), Y = requestAnimationFrame(E);
661
+ cancelAnimationFrame(G), G = requestAnimationFrame(E);
649
662
  }), P.observe(u, {
650
663
  childList: !0,
651
664
  subtree: !0
@@ -654,12 +667,12 @@ function ot({
654
667
  } catch (R) {
655
668
  console.warn("Drill affordance skipped:", R);
656
669
  }
657
- b.onReady(ae), T = setTimeout(ae, 1e4);
670
+ b.onReady(ne), A = setTimeout(ne, 1e4);
658
671
  } catch (m) {
659
672
  console.error("Error rendering visualization:", m), D?.disconnect(), F?.disconnect(), P?.disconnect(), b.remove(), b = void 0, u.parentNode === d && d.removeChild(u);
660
673
  }
661
674
  })(), () => {
662
- K = !0, D?.disconnect(), F?.disconnect(), O && clearTimeout(O), T && clearTimeout(T), c && w.current?.node !== c && (j && c.removeEventListener("keydown", j), H && c.removeEventListener("keyup", H), q && c.removeEventListener("focusin", q), P?.disconnect(), cancelAnimationFrame(Y), b?.remove(), c.parentNode === d && d.removeChild(c), d.style.position = "");
675
+ U = !0, D?.disconnect(), F?.disconnect(), O && clearTimeout(O), A && clearTimeout(A), c && w.current?.node !== c && (j && c.removeEventListener("keydown", j), H && c.removeEventListener("keyup", H), q && c.removeEventListener("focusin", q), P?.disconnect(), cancelAnimationFrame(G), b?.remove(), c.parentNode === d && d.removeChild(c), d.style.position = "");
663
676
  };
664
677
  }, [
665
678
  e,
@@ -668,9 +681,9 @@ function ot({
668
681
  a,
669
682
  o,
670
683
  N,
671
- W,
672
- ee,
673
- te
684
+ K,
685
+ te,
686
+ re
674
687
  ]), /* @__PURE__ */ I(
675
688
  "div",
676
689
  {
@@ -683,9 +696,9 @@ function ot({
683
696
  }
684
697
  );
685
698
  }
686
- function at(e) {
699
+ function lt(e) {
687
700
  return typeof window > "u" ? /* @__PURE__ */ I(
688
- se,
701
+ de,
689
702
  {
690
703
  sx: {
691
704
  width: "100%",
@@ -698,10 +711,10 @@ function at(e) {
698
711
  children: "Loading..."
699
712
  }
700
713
  ) : /* @__PURE__ */ I(
701
- ge,
714
+ we,
702
715
  {
703
716
  fallback: /* @__PURE__ */ I(
704
- se,
717
+ de,
705
718
  {
706
719
  sx: {
707
720
  width: "100%",
@@ -714,21 +727,22 @@ function at(e) {
714
727
  children: "Loading visualization..."
715
728
  }
716
729
  ),
717
- children: /* @__PURE__ */ I(ot, { ...e })
730
+ children: /* @__PURE__ */ I(nt, { ...e })
718
731
  }
719
732
  );
720
733
  }
721
- const ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
734
+ const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
722
735
  __proto__: null,
723
- default: at
736
+ default: lt,
737
+ pageAllowsEval: pe
724
738
  }, Symbol.toStringTag, { value: "Module" }));
725
739
  export {
726
740
  g as D,
727
- at as R,
728
- Be as a,
729
- $e as b,
730
- ct as c,
731
- Le as d,
732
- Me as m,
733
- Ne as r
741
+ lt as R,
742
+ Pe as a,
743
+ Ne as b,
744
+ ht as c,
745
+ Ie as d,
746
+ $e as m,
747
+ je as r
734
748
  };