@malloy-publisher/server 0.10.1 → 0.10.2

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.
Files changed (22) hide show
  1. package/dist/app/api-doc.yaml +7 -2
  2. package/dist/app/assets/{EnvironmentPage-BU9PTvlW.js → EnvironmentPage-qOdFSQL1.js} +1 -1
  3. package/dist/app/assets/{HomePage-Cf8DI47T.js → HomePage-qPrsLgkV.js} +1 -1
  4. package/dist/app/assets/{MainPage-BlwWg0iB.js → MainPage-BfS_-PBR.js} +1 -1
  5. package/dist/app/assets/{ModelPage-DA0bb3CE.js → ModelPage-Rgt_50mg.js} +2 -2
  6. package/dist/app/assets/{PackagePage-BMsYUtRD.js → PackagePage-D6bXCeY6.js} +1 -1
  7. package/dist/app/assets/{RenderedResult-vf6tu8tf.es-CSqnbEun.js → RenderedResult-BCJC0ZVj.es-ThIM8SXj.js} +1 -1
  8. package/dist/app/assets/{RouteError-DxCqVKbo.js → RouteError-D3qvottt.js} +1 -1
  9. package/dist/app/assets/{ThemeEditorPage-380DQSoR.js → ThemeEditorPage-UAf70V3Q.js} +1 -1
  10. package/dist/app/assets/{ToggleButtonGroup-DgxU1gMN.js → ToggleButtonGroup-DnK5WHKM.js} +1 -1
  11. package/dist/app/assets/{documentRoutes-Bqj5f6iK.js → documentRoutes-CnLoYf4D.js} +1 -1
  12. package/dist/app/assets/{editPageMounted-CT7ODDUS.js → editPageMounted-po3c6RP3.js} +2 -2
  13. package/dist/app/assets/{index-Cji4XUjs.js → index-4-yQ2uF2.js} +1 -1
  14. package/dist/app/assets/{index-D8RY5NbL.js → index-CNbuoYFM.js} +1 -1
  15. package/dist/app/assets/{index-BiBw5Wni.js → index-a9NQPL4B.js} +1 -1
  16. package/dist/app/assets/{index-DYqHxLwV.js → index-iyvwQg3j.js} +4 -4
  17. package/dist/app/assets/{index.es-B10IQDf8.js → index.es-C2AyMc9a.js} +1 -1
  18. package/dist/app/index.html +1 -1
  19. package/dist/instrumentation.mjs +1 -1
  20. package/dist/server.mjs +78 -46
  21. package/package.json +1 -1
  22. package/dist/sshcrypto-cqb52edz.node +0 -0
@@ -1,4 +1,4 @@
1
- import{g as rp,b as ip,r as S,u as sp,b9 as op,l as ap,i as lp,ba as cp,n as dp,j as m,f as up,h as hp,s as ka,m as fp,v as Wl,Z as ad,U as qe,bb as cn,bc as Cs,aD as ft,ae as rt,L as Dt,K as $n,bd as nr,ak as Oe,be as Sa,bf as vi,bg as Xn,bh as pp,bi as ld,bj as rn,bk as mp,bl as gp,bm as mo,bn as vp,T as ve,as as ht,bo as xp,bp,bq as yp,O as $a,aK as wp,br as Qt,bs as kp,bt as ja,bu as Sp,bv as cd,bw as dd,bx as $p,by as jp,a0 as go,bz as Mp,bA as Ep,bB as vo,a_ as ud,B as hd,bC as nt,I as _,aJ as Xe,bD as mt,bE as Ma,Y as Bt,bF as Cp,bG as pt,bH as zl,bI as Gr,bJ as fd,bK as Tp,bL as Ea,ag as Dp,bM as Op,bN as Ap,bO as Pp,bP as Rp,bQ as Ip,bR as pd,bS as Np,bT as Wp,bU as md,bV as gd,bW as vd,bX as zp,bY as Lp,bZ as Fp,b_ as Bp,b$ as _p,c0 as qp,c1 as Hp,c2 as Up,c3 as Vp,G as Kp,c4 as Gp,c5 as Yp,c6 as xo,c7 as bo,c8 as Ll,c9 as Xp,ca as Qp,cb as Zp,cc as Qn,cd as Jp,ce as em,cf as tm,cg as nm,ch as rm,ci as xd,cj as Ca,ck as im,cl as sm,cm as bd,cn as om,co as am,cp as lm,cq as Ts,cr as ns,cs as cm,ct as dm,cu as rs,cv as um,cw as kn,cx as hm,cy as fm,cz as yd,cA as pm,cB as mm,aP as Ta,aF as Zt,cC as yo,cD as gm,cE as vm,cF as wd,W as kd,cG as xm,cH as bm,cI as Ds,cJ as ym,cK as wo,cL as wm,cM as km,cN as Sm,cO as Sd,cP as $m,X as jm,cQ as Mm,cR as Em,cS as Cm,cT as Tm,cU as Dm,cV as Om,cW as Da,cX as Am,cY as Pm,cZ as $d,c_ as Rm,c$ as Im,d0 as Nm,d1 as Oa,d2 as Wm,d3 as zm,d4 as Lm,d5 as Pn,d6 as jd,d7 as Fl,d8 as Bl,d9 as Vs,da as Fm,S as Bm,db as _m,dc as qm,dd as Hm,de as Md,df as Um,dg as Vm,aj as Km}from"./index-DYqHxLwV.js";import{dh as tk,di as nk,dj as rk,dk as ik,dl as sk,dm as ok,dn as ak,dp as lk,dq as ck,dr as dk,ds as uk}from"./index-DYqHxLwV.js";import{T as Ed,a as ko}from"./ToggleButtonGroup-DgxU1gMN.js";function Gm(e){return rp("MuiCollapse",e)}ip("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);const Ym=e=>{const{orientation:t,classes:n}=e,r={root:["root",`${t}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${t}`],wrapperInner:["wrapperInner",`${t}`]};return hp(r,Gm,n)},Xm=ka("div",{name:"MuiCollapse",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,t[n.orientation],n.state==="entered"&&t.entered,n.state==="exited"&&!n.in&&n.collapsedSize==="0px"&&t.hidden]}})(fp(({theme:e})=>({height:0,overflow:"hidden",transition:e.transitions.create("height"),variants:[{props:{orientation:"horizontal"},style:{height:"auto",width:0,transition:e.transitions.create("width")}},{props:{state:"entered"},style:{height:"auto",overflow:"visible"}},{props:{state:"entered",orientation:"horizontal"},style:{width:"auto"}},{props:({ownerState:t})=>t.state==="exited"&&!t.in&&t.collapsedSize==="0px",style:{visibility:"hidden"}}]}))),Qm=ka("div",{name:"MuiCollapse",slot:"Wrapper"})({display:"flex",width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),Zm=ka("div",{name:"MuiCollapse",slot:"WrapperInner"})({width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),So=S.forwardRef(function(t,n){const r=sp({props:t,name:"MuiCollapse"}),{addEndListener:i,children:s,className:o,collapsedSize:a="0px",component:d,easing:f,in:c,onEnter:l,onEntered:u,onEntering:p,onExit:g,onExited:v,onExiting:b,orientation:w="vertical",style:h,timeout:x=op.standard,TransitionComponent:y=ap,...k}=r,C={...r,orientation:w,collapsedSize:a},$=Ym(C),T=lp(),j=cp(),M=S.useRef(null),I=S.useRef(),N=typeof a=="number"?`${a}px`:a,A=w==="horizontal",L=A?"width":"height",B=S.useRef(null),q=dp(n,B),P=H=>ne=>{if(H){const Q=B.current;ne===void 0?H(Q):H(Q,ne)}},F=()=>M.current?M.current[A?"clientWidth":"clientHeight"]:0,E=P((H,ne)=>{M.current&&A&&(M.current.style.position="absolute"),H.style[L]=N,l&&l(H,ne)}),D=P((H,ne)=>{const Q=F();M.current&&A&&(M.current.style.position="");const{duration:ge,easing:Z}=Wl({style:h,timeout:x,easing:f},{mode:"enter"});if(x==="auto"){const Ae=T.transitions.getAutoHeightDuration(Q);H.style.transitionDuration=`${Ae}ms`,I.current=Ae}else H.style.transitionDuration=typeof ge=="string"?ge:`${ge}ms`;H.style[L]=`${Q}px`,H.style.transitionTimingFunction=Z,p&&p(H,ne)}),W=P((H,ne)=>{H.style[L]="auto",u&&u(H,ne)}),U=P(H=>{H.style[L]=`${F()}px`,g&&g(H)}),V=P(v),Y=P(H=>{const ne=F(),{duration:Q,easing:ge}=Wl({style:h,timeout:x,easing:f},{mode:"exit"});if(x==="auto"){const Z=T.transitions.getAutoHeightDuration(ne);H.style.transitionDuration=`${Z}ms`,I.current=Z}else H.style.transitionDuration=typeof Q=="string"?Q:`${Q}ms`;H.style[L]=N,H.style.transitionTimingFunction=ge,b&&b(H)}),re=H=>{x==="auto"&&j.start(I.current||0,H),i&&i(B.current,H)};return m.jsx(y,{in:c,onEnter:E,onEntered:W,onEntering:D,onExit:U,onExited:V,onExiting:Y,addEndListener:re,nodeRef:B,timeout:x==="auto"?null:x,...k,children:(H,{ownerState:ne,...Q})=>m.jsx(Xm,{as:d,className:up($.root,o,{entered:$.entered,exited:!c&&N==="0px"&&$.hidden}[H]),style:{[A?"minWidth":"minHeight"]:N,...h},ref:q,ownerState:{...C,state:H},...Q,children:m.jsx(Qm,{ownerState:{...C,state:H},className:$.wrapper,ref:M,children:m.jsx(Zm,{ownerState:{...C,state:H},className:$.wrapperInner,children:s})})})})});So&&(So.muiSupportAuto=!0);var _l={};const je=e=>e.kind==="text",le=e=>e.kind!=="text",Mr=e=>le(e)?e.label??e.name:e.name,vt=e=>e.declaration.kind==="query"?e.name:`${e.source} -> ${e.name}`,cr=e=>e.declaration.kind==="inherited"||e.declaration.kind==="query",fe=e=>je(e)?`text.${e.name}`:e.declaration.kind==="query"?`query.${e.name}`:`${e.source}.${e.name}`,ql=".malloy-big-value, .malloy-table",Jm=e=>e.querySelector(ql)!==null&&![...e.querySelectorAll(".malloy-chart")].some(t=>t.closest(ql)===null),is=(e,t)=>je(e)?cm:t&&Jm(t)?dm:rs,ii=e=>e.rowspan??Ea[je(e)?"text":"query"];function sn(e,t){if(e.row===void 0||e.col===void 0)return;const n=Math.min(e.colspan??1,t);return{row:e.row,col:Math.min(e.col,t-n+1),colspan:n,rowspan:ii(e)}}const si=(e,t)=>e.col<t.col+t.colspan&&t.col<e.col+e.colspan&&e.row<t.row+t.rowspan&&t.row<e.row+e.rowspan;function Kn(e){return e.map((t,n)=>({tile:t,index:n})).sort((t,n)=>(t.tile.row??1/0)-(n.tile.row??1/0)||(t.tile.col??1/0)-(n.tile.col??1/0)||t.index-n.index).map(({tile:t})=>t)}function Ht(e,t,n){const r=e.map(a=>({...a})),i=[],s=a=>{const d=sn(r[a],t);d&&(r[a].col=d.col,i.push(d))};n!==void 0&&s(n);const o=r.map((a,d)=>({tile:a,index:d})).filter(({index:a,tile:d})=>a!==n&&d.row!==void 0).sort((a,d)=>(a.tile.row??0)-(d.tile.row??0)||(a.tile.col??0)-(d.tile.col??0)||a.index-d.index);for(const{index:a}of o){const d=sn(r[a],t);if(d){for(;;){const f=i.filter(c=>si(d,c));if(f.length===0)break;d.row=Math.max(...f.map(c=>c.row+c.rowspan))}r[a].row=d.row,s(a)}}return r}function eg(e,t,n,r){const i=e.flatMap((d,f)=>{const c=f===t?void 0:sn(d,r);return c?[c]:[]}),s=Math.max(1,...i.map(d=>d.row+d.rowspan)),o={...e[t],...n,row:Math.min(n.row,s)},a=sn(o,r);if(a){for(;;){const d=i.filter(f=>f.row<a.row&&si(a,f));if(d.length===0)break;a.row=Math.max(...d.map(f=>f.row+f.rowspan))}o.row=a.row}return Ht(e.map((d,f)=>f===t?o:d),r,t)}const ss=(e,t)=>(e-pt*(t-1))/t,Cd=ns+pt;function Td(e,t,n,r,i){const s=Math.min(n,r),o=Math.round(e/(i+pt))+1;return{row:Math.max(1,Math.round(t/Cd)+1),col:Math.min(Math.max(o,1),r-s+1)}}function Dd(e,t,n,r){const i=e.map((s,o)=>{if(s.row!==void 0&&s.col!==void 0)return s;const a=t[o];if(!a)return s;const{break:d,...f}=s,c=s.colspan??Math.max(1,Math.round((a.width+pt)/(r+pt))),l=Td(a.left,a.top,c,n,r),u=(a.top+a.height+pt)/Cd,p=je(s)?Math.ceil(u-.02):Math.round(u);return{...f,...l,colspan:c,rowspan:s.rowspan??Math.max(is(s),p-l.row+1)}});return Ht(i,n)}function Hl(e,t,n){const r=e.flatMap((s,o)=>{const a=o===t?void 0:sn(s,n);return a?[a]:[]});if(r.length===0)return[...e];const i=Math.max(...r.map(s=>s.row+s.rowspan));return e.map((s,o)=>o===t?{...s,row:i,col:1}:s)}function Od(e,t){const n=e.map(s=>({...s})),r=[],i=n.map((s,o)=>({tile:s,index:o})).filter(({tile:s})=>s.row!==void 0&&s.col!==void 0).sort((s,o)=>(s.tile.row??0)-(o.tile.row??0)||(s.tile.col??0)-(o.tile.col??0)||s.index-o.index);for(const{index:s}of i){const o=sn(n[s],t);if(o){for(;o.row>1&&!r.some(a=>si({...o,row:o.row-1},a));)o.row-=1;n[s].row=o.row,n[s].col=o.col,r.push(o)}}return n}const tg=(e,t)=>Od(e,t).some((n,r)=>n.row!==e[r].row||n.col!==e[r].col);function ng(e){return Kn(e).map(t=>{const{row:n,col:r,...i}=t;return i})}const rg=(e,t,n)=>e.map((r,i)=>i===t?{...r,...n}:r);function Ul(e,t,n,r,i){const s=sn(e[t],i);if(!s)return[...e];const o={row:Math.max(1,s.row+n),col:Math.min(Math.max(1,s.col+r),i-s.colspan+1)};if(o.row===s.row&&o.col===s.col)return[...e];const a={...s,...o},d=e.flatMap((p,g)=>{const v=g===t?void 0:sn(p,i);return v&&si(a,v)&&!si(s,v)?[{i:g,other:v}]:[]}),f=d.length===1?d[0]:void 0;if(!f)return Ht(rg(e,t,o),i,t);const{i:c,other:l}=f,u=e.map(p=>({...p}));return n>0?(u[c].row=s.row,u[t].row=s.row+l.rowspan):n<0?(u[t].row=l.row,u[c].row=l.row+s.rowspan):r>0?(u[c].col=s.col,u[t].col=s.col+l.colspan):(u[t].col=l.col,u[c].col=l.col+s.colspan),Ht(u,i,t)}const Ad=(e,t)=>e?.col===void 0?t:Math.max(1,t-e.col+1);function ig(e){return je(e)||e.rowspan===void 0?e:Ds(e.chart)&&e.chart!=="big_value"&&e.rowspan<rs?{...e,rowspan:rs}:e}const Pd=mt(m.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),Rd=mt(m.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),sg=mt(m.jsx("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"}));function Id(e){const{theme:t}=qe(),n=t.ui,[r,i]=S.useState(null),{status:s,draftKeptAt:o,discard:a,restored:d,dismissRestored:f}=e,c=d!==void 0&&!d.pending&&s==="unsaved"?d:void 0,l=s==="saved"?"Saved":s==="saving"?"Saving…":o!==void 0?"Draft saved":"Unsaved changes",u=c?`Restored your unsaved edits from ${$o(c.savedAt)}`:void 0,p=s==="unsaved"&&o!==void 0?"Your edits are kept in this browser. Done saves them to the report.":e.saveTarget,g=a!==void 0&&s==="unsaved",v=()=>{i(null),c&&f?.()},b=x=>({display:"inline-flex",alignItems:"center",justifyContent:"flex-end",gap:.75,minWidth:132,height:n.size.control,px:1,borderRadius:n.radius.control,font:"inherit",...n.type.control,whiteSpace:"nowrap",color:s==="saved"?x.palette.text.secondary:x.palette.text.primary,transition:`color ${nt}, background-color ${nt}`,...g?{"&:hover":{bgcolor:x.palette.action.hover}}:{}}),w=m.jsxs(m.Fragment,{children:[m.jsx(_,{component:"span","aria-hidden":!0,sx:{width:16,height:16,flex:"none",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:s==="saved"?m.jsx(Ts,{sx:{fontSize:16}}):m.jsx(_,{component:"span","data-restored":c?"true":void 0,sx:x=>({width:7,height:7,borderRadius:"50%",bgcolor:c?t.accent:s==="saving"||o!==void 0?x.palette.text.disabled:x.palette.warning.main,transition:`background-color ${nt}`})})}),m.jsx(_,{component:"span","aria-hidden":!0,children:l}),m.jsx(Sa,{"aria-hidden":!0,sx:{fontSize:16,ml:-.25,visibility:g?"visible":"hidden"}})]}),h=m.jsx(_,{component:"span",role:"status","aria-live":"polite",sx:og,children:u?`${l}. ${u}.`:l});return m.jsxs(m.Fragment,{children:[h,m.jsx(Dt,{title:u??p,describeChild:!0,children:g?m.jsx(hd,{className:rt.saveStatus,"aria-label":l,...u?{"aria-description":u}:{},"aria-haspopup":"menu","aria-expanded":r!==null,onClick:x=>i(x.currentTarget),sx:b,children:w}):m.jsx(_,{component:"span",className:rt.saveStatus,sx:b,children:w})}),m.jsxs(Xn,{className:rt.menu,anchorEl:r,open:r!==null,onClose:v,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:-4,horizontal:"left"},slotProps:{paper:{sx:{minWidth:240,borderRadius:n.radius.menu,border:`1px solid ${cn(t.cardBorder)}`,boxShadow:n.shadow.menu}}},MenuListProps:{dense:!0,sx:{py:.5}},children:[(u!==void 0||o!==void 0)&&m.jsx(_,{component:"li",role:"presentation",sx:{px:1.75,pt:.75,pb:1,...n.type.caption,color:"text.secondary"},children:u??`Kept in this browser at ${$o(o)}`}),m.jsxs(Xe,{onClick:()=>{i(null),a?.()},sx:{mx:.5,borderRadius:n.radius.control,gap:1.25,color:"error.main","&.Mui-focusVisible":{outline:"none",bgcolor:"action.hover"}},children:[m.jsx(sg,{fontSize:"small"}),"Discard edits"]})]})]})}function $o(e){const t=new Date(e);return new Date().toDateString()===t.toDateString()?t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}const og={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},jo=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),Sn=jo?"⌘":"Ctrl+",Vl=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},Ks=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function ag(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e});const[n,r]=S.useState(!1);S.useEffect(()=>{n&&(r(!1),t.current.save?.())},[n]),S.useEffect(()=>{const i=s=>{const o=t.current;if(o.paused)return;const a=jo?s.metaKey:s.ctrlKey,d=s.key.toLowerCase();if(s.key==="Escape"){if(Vl(s.target)||Ks(s.target))return;o.escape();return}if(Vl(s.target)){if(a&&d==="s"){if(s.preventDefault(),!o.save||Ks(s.target))return;s.target.blur(),r(!0)}return}if(Ks(s.target)){a&&d==="s"&&s.preventDefault();return}if(a&&d==="z"){s.preventDefault(),s.shiftKey?o.redo():o.undo();return}if(!jo&&a&&d==="y"){s.preventDefault(),o.redo();return}if(a&&d==="s"){s.preventDefault(),o.save?.();return}if(o.move&&s.altKey&&!a&&!s.shiftKey){const f=s.key==="ArrowLeft"?[0,-1]:s.key==="ArrowRight"?[0,1]:s.key==="ArrowUp"?[-1,0]:s.key==="ArrowDown"?[1,0]:void 0;if(f&&o.move(f[0],f[1])){s.preventDefault();return}}o.nudge&&!a&&!s.altKey&&!s.shiftKey&&(s.key==="ArrowLeft"||s.key==="ArrowRight")&&(s.preventDefault(),o.nudge(s.key==="ArrowRight"?1:-1))};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[])}const Yr=(e,t,n=Ma)=>({height:n.size.control,minHeight:n.size.control,px:1.5,borderRadius:n.radius.control,boxShadow:"none",...n.type.control,"&:hover":{boxShadow:"none"},"& .MuiButton-startIcon":{mr:.5,"& svg":{fontSize:18}},"&.MuiButton-outlined":{borderColor:e,"&:hover":{borderColor:t}}}),oi=(e=Ma)=>({width:e.size.control,height:e.size.control,borderRadius:e.radius.control,"& svg":{fontSize:18}}),os={height:20,alignSelf:"center",mx:.5,my:0},as=(e,t=Ma)=>({height:t.size.control,boxSizing:"border-box",borderRadius:t.radius.control,border:`1px solid ${e}`,overflow:"hidden",bgcolor:"background.paper","& .MuiToggleButton-root":{border:"none",borderRadius:"0 !important",m:"0 !important",px:1.5,py:0,height:"100%",...t.type.control,color:"text.secondary","& + .MuiToggleButton-root":{borderLeft:`1px solid ${e}`},"&:hover":{bgcolor:"action.hover"},"&.Mui-selected, &.Mui-selected:hover":{bgcolor:"action.selected",color:"text.primary"}}}),Mo={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function lg({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,savesTo:a="package",saveLabel:d,saveButton:f,actions:c,onAddTile:l,arrange:u,onExit:p,saveStatus:g}){const{theme:v}=qe(),b=cn(v.cardBorder),w=Cs(v.cardBorder,v.tileTitle);return m.jsxs(ft,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[u,l&&m.jsx(Oe,{variant:"outlined",startIcon:m.jsx(vi,{}),onClick:l,"aria-label":"Add tile",sx:Yr(b,w,v.ui),children:"Tile"}),l&&m.jsx(nr,{orientation:"vertical",sx:os}),m.jsx(Dt,{title:`Undo (${Sn}Z)`,children:m.jsx("span",{children:m.jsx($n,{"aria-label":"Undo",disabled:!e,onClick:n,sx:oi(v.ui),children:m.jsx(Rd,{fontSize:"small"})})})}),m.jsx(Dt,{title:`Redo (${Sn}⇧Z)`,children:m.jsx("span",{children:m.jsx($n,{"aria-label":"Redo",disabled:!t,onClick:r,sx:oi(v.ui),children:m.jsx(Pd,{fontSize:"small"})})})}),(c||o||p)&&m.jsx(nr,{orientation:"vertical",sx:os}),c,o&&g&&m.jsx(Id,{...g}),o?m.jsx(Dt,{title:i?`Save (${Sn}S) · ${d??Mo[a]}`:d??Mo[a],children:m.jsx("span",{children:m.jsx(Oe,{ref:f,variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{...Yr(b,w,v.ui),minWidth:88},children:s?"Saving…":i?"Save":"Saved"})})}):null,o&&m.jsx(_,{component:"span","aria-live":"polite",sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},children:s?"Saving":i?"Unsaved changes":"All changes saved"}),p&&m.jsx(jm,{label:"Close",icon:m.jsx(Ts,{}),onClick:p})]})}const cg=e=>`This view has no field for the x-axis: ${e.toLowerCase()} needs a group by, such as a date or a category`,Kl={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map",combo_chart:"Bar and line"};function Nd(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this tile's details":n==="unlisted"?"Not in the model's list, so its shape is unknown":void 0,i=e?.shape,s=o=>{if(t===o)return;if(o==="big_value")return e?.aggregateOnly===!0?void 0:i&&i.groupBys>0?"This view has a group by, so it is more than one row; big numbers need a view of totals only":r??"Needs results that are only totals (no group by)";if(o==="shape_map"||o==="segment_map")return e?.chart===o?void 0:r??"Needs a map chart set in the model";if(e?.chart===o)return;if(!i)return o==="combo_chart"?r??"Needs a view with a group by and exactly two totals: the first is drawn as bars, the second as a line":void 0;const a=`A ${Kl[o].toLowerCase()} chart`;switch(Um(o,i)){case"no_x_axis":return cg(a);case"combo_totals":return`A bar and line chart needs exactly two totals, the first drawn as bars and the second as a line; this view has ${i.totals}`;case"no_y_axis":return`This view has no total for the y-axis: ${a.toLowerCase()} needs at least one aggregate`;default:return}};return[{value:"default",label:"Default",hint:"As set in the model"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map","combo_chart"].map(o=>{const a=s(o);return{value:o,label:Kl[o],...a?{disabled:!0,reason:a}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Gl(e){return e.description??qm(e.name)}const dg={bar_chart:"a bar chart",line_chart:"a line chart",scatter_chart:"a scatter chart",combo_chart:"a bar and line chart",shape_map:"a shape map",segment_map:"a segment map",big_value:"a big value",sparkline:"a sparkline"},Ci=(e,t)=>`${e}\0${t}`;function ug({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s,onAddText:o,renderPreview:a}){const{theme:d}=qe(),f=d.ui,c=cn(d.cardBorder),l=S.useMemo(()=>n?.sources??[],[n]),[u,p]=S.useState(""),[g,v]=S.useState(),[b,w]=S.useState(""),[h,x]=S.useState("default"),y=S.useRef(null),k=S.useMemo(()=>{const P=new Set(t.sources.map(F=>F.base));return[...l].sort((F,E)=>Number(P.has(E.name))-Number(P.has(F.name)))},[l,t]),C=k.filter(P=>P.views.length>0),$=k.filter(P=>P.views.length===0),T=S.useMemo(()=>new Map(C.flatMap(P=>P.views.map(F=>[Ci(P.name,F.name),{source:P,view:F,key:Ci(P.name,F.name)}]))),[C]),j=S.useMemo(()=>C.map(P=>({key:P.name,label:P.name,...P.description?{detail:P.description}:{},entries:P.views.map(F=>({key:Ci(P.name,F.name),name:F.name,title:Gl(F),...F.chart?{chart:F.chart}:{}}))})),[C]),M=g===void 0?void 0:T.get(g);S.useEffect(()=>{if(!e)return;p(""),w(""),x("default");const P=C[0]?.views[0];v(P&&C[0]?Ci(C[0].name,P.name):void 0)},[e]);const I=M?[M.source.name,M.view.name].filter(P=>!wo(P)).map(P=>`"${P}" is not a plain Malloy name, so a tile cannot be written for it.`)[0]:void 0,N=M!==void 0&&I===void 0,A=M?Gl(M.view):"",L=h!=="default"&&M?{chart:h,chartCarried:M.view.chart?[M.view.chart]:[]}:{},B=(P=M)=>{if(!P||![P.source.name,P.view.name].every(wo))return;const F=P.key===M?.key,E=Vm(Math.ceil(r/2),r);s({base:P.source.name,modelPath:P.source.modelPath,...P.source.exporters?{exporters:P.source.exporters}:{},view:P.view.name,...F&&b.trim()?{label:b.trim()}:{},...F?L:{},...E!==void 0?{colspan:E}:{}})},q=M?Nd(M.view,h).filter(P=>P.value!=="custom"&&P.disabled!==!0):[];return m.jsx(Ta,{className:`${rt.dialog} ${rt.addTileDialog}`,open:e,onClose:i,maxWidth:"md",initialFocus:y,title:"Add a tile",description:"Pick what the tile shows from the model. You can change its title and chart now or later.",actions:m.jsxs(m.Fragment,{children:[m.jsx(Oe,{onClick:o,sx:{mr:"auto"},children:"Add text instead"}),m.jsx(Oe,{onClick:i,children:"Cancel"}),m.jsx(Oe,{variant:"contained",disabled:!N,onClick:()=>B(),children:"Add tile"})]}),children:m.jsxs(_,{sx:{mx:-3,mb:-1,borderTop:`1px solid ${c}`,borderBottom:`1px solid ${c}`,display:"grid",gridTemplateColumns:{xs:"1fr",md:"320px minmax(0, 1fr)"},height:{md:460}},children:[m.jsx(_,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${c}`},maxHeight:{xs:280,md:"none"}},children:m.jsx(wm,{groups:j,query:u,onQuery:p,picked:M?.key,onPick:P=>{v(P),x("default")},onTake:P=>B(T.get(P)),searchRef:y,empty:m.jsx(ve,{variant:"body2",sx:{color:d.tileTitle,p:2},children:n?"This package's models have nothing to put on a tile yet.":"The package's sources are still loading."}),footer:$.length>0&&m.jsxs(ve,{variant:"caption",component:"p",sx:{color:"text.secondary",px:2,pt:1.5},children:["Also in this package, with no views to show:"," ",$.map(P=>P.name).join(", "),"."]})})}),m.jsx(_,{sx:P=>({p:2.5,display:"flex",flexDirection:"column",gap:2,minHeight:0,overflowY:"auto",bgcolor:`color-mix(in srgb, ${P.palette.text.primary} 3%, ${P.palette.background.paper})`}),children:M?m.jsxs(m.Fragment,{children:[m.jsx(_,{"aria-label":"Preview",role:"region",sx:P=>({height:240,flex:"none",display:"flex",position:"relative",overflow:"hidden",borderRadius:f.radius.tile,border:`1px solid ${c}`,bgcolor:P.palette.background.paper,"&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,height:40,pointerEvents:"none",background:`linear-gradient(to bottom, transparent, ${P.palette.background.paper})`}}),children:a?m.jsx(_,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:a({base:M.source.name,modelPath:M.source.modelPath,view:M.view.name,label:b.trim()||A,...h!=="default"?L:{},givens:M.source.givens})}):m.jsxs(_,{sx:P=>({flex:1,border:`1px solid ${c}`,borderRadius:f.radius.tile,bgcolor:P.palette.background.paper,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,color:"text.secondary"}),children:[m.jsx(km,{chart:M.view.chart}),m.jsxs(ve,{variant:"body2",children:[M.source.name," → ",M.view.name]})]})}),m.jsx(Zt,{size:"small",label:"Title",placeholder:A,value:b,onChange:P=>w(P.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Tile title"}}),m.jsxs(_,{children:[m.jsx(ve,{component:"div",sx:{...f.type.label,color:"text.secondary",mb:.75},children:"Chart"}),m.jsx(Ed,{size:"small",exclusive:!0,value:h,"aria-label":"Chart",onChange:(P,F)=>{F!==null&&x(F)},sx:{...as(c,f),"& .MuiToggleButton-root":{...as(c,f)["& .MuiToggleButton-root"],textTransform:"none"}},children:q.map(P=>m.jsx(ko,{value:P.value,children:P.label},P.value))}),m.jsx(ve,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:M.view.chart?`The model sets ${dg[M.view.chart]??"a chart"}.`:"The model sets no chart, so it shows as a table."})]}),I&&m.jsx(ve,{variant:"body2",color:"error",children:I})]}):m.jsx(ve,{variant:"body2",sx:{color:"text.secondary",m:"auto"},children:"Pick a view to see it here."})})]})})}function hg(e,t,{modelPath:n,textHeld:r,widths:i,insertAt:s}){t.modelPath&&!r&&(e.imports=Fm(e,t.base,t.modelPath,n,t.exporters??[t.modelPath]));const o=Wd(e,t.base),a=Eo(e,o.name,t.view);e.tiles.splice(s??e.tiles.length,0,{name:a,source:o.name,declaration:{kind:"reference",from:t.view},...i&&t.colspan!==void 0?{colspan:t.colspan}:{},...t.label?{label:t.label}:{},...t.chart?{chart:t.chart}:{},...t.chartCarried?{chartCarried:t.chartCarried}:{}})}function Wd(e,t,{unscoped:n=!1}={}){const r=e.sources.find(a=>a.base===t&&(!n||!a.scopedBy?.length));if(r)return r;const i=new Set(e.sources.map(a=>a.name));let s=`${t}_tiles`;for(let a=2;i.has(s);a++)s=`${t}_tiles_${a}`;const o={name:s,base:t};return e.sources.push(o),o}function Eo(e,t,n){const r=new Set(e.tiles.filter(le).filter(s=>s.source===t).map(s=>s.name));let i=`${n}_tile`;for(let s=2;r.has(i);s++)i=`${n}_tile_${s}`;return i}function ls(e){switch(e.declaration.kind){case"inline":return"Its query is written in this file, and the builder does not copy a query's body.";case"opaque":return`Its query is ${e.declaration.why}, which the builder does not copy.`;case"query":return"It names a query, and a copy could not be told apart from it: the builder writes nothing about such a tile but its place.";default:return e.chart==="custom"?"Its chart line is one the builder does not write, so a copy would lose it.":void 0}}function fg(e,t){const n=e.tiles[t];if(!n||!le(n)||ls(n)!==void 0)return;let r;if(n.declaration.kind==="reference"){const{break:s,...o}=structuredClone(n);r={...o,name:Eo(e,n.source,n.declaration.from)}}else{const s=e.sources.find(o=>o.name===n.source)??Wd(e,n.source,{unscoped:!0});r={name:Eo(e,s.name,n.name),source:s.name,declaration:{kind:"reference",from:n.name},...n.colspan!==void 0?{colspan:n.colspan}:{}}}const i=n.row!==void 0&&n.col!==void 0;return i&&(r={...r,row:(n.row??1)+ii(n),col:n.col,...n.rowspan!==void 0?{rowspan:n.rowspan}:{}}),e.tiles.splice(t+1,0,r),i&&(e.tiles=Ht(e.tiles,e.columns??um,t+1)),t+1}const Ti="self";function pg({open:e,document:t,source:n,givenNames:r,dashboards:i,tileLabel:s,onClose:o,onApply:a}){const{theme:d}=qe(),f=d.ui,[c,l]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(x=>x.source===n.name);l((n.dimensions??[]).map(x=>{const y=h.find(k=>k.name===x.name);return{name:x.name,expression:x.expression,to:y?.to??[],given:y?.given??""}}))},[e,n,t]);const u=(h,x)=>l(y=>y.map((k,C)=>{if(C!==h)return k;const $={...k};return x($),$})),p=[Ti,...i.filter(h=>h!==Ti)],g=h=>h===Ti?"This report":h,v=()=>{n&&(a(c.filter(h=>h.to.length>0).map(h=>({source:n.name,name:h.name,expression:h.expression,to:h.to,...h.given?{given:h.given}:{}}))),o())},b=cn(d.cardBorder),w=(h,x)=>u(h,y=>{x?y.to=y.lastTo?.length?y.lastTo:[Ti]:(y.lastTo=y.to,y.to=[])});return m.jsx(Ta,{className:`${rt.dialog} ${rt.clickableCellsDialog}`,open:e,onClose:o,title:"Clickable cells",description:m.jsxs(m.Fragment,{children:[s&&m.jsxs(_,{component:"span",sx:{fontWeight:f.type.label.fontWeight},children:[s," ·"," "]}),"A click on a table cell sets a filter to its value, on this report or on the one it opens. Bars, lines and points on a chart do not respond to a click. Clicks work in the report, not while you edit it."]}),actions:m.jsxs(m.Fragment,{children:[m.jsx(Oe,{onClick:o,children:"Cancel"}),m.jsx(Oe,{variant:"contained",onClick:v,disabled:c.length===0,children:"Apply"})]}),children:c.length===0?m.jsx(ve,{variant:"body2",sx:{color:d.tileTitle,pt:1},children:n?m.jsxs(m.Fragment,{children:[m.jsx(_,{component:"code",children:n.name})," declares no dimensions of its own in this file. A click is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",m.jsx(_,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):m.jsx(_,{role:"list","aria-label":"Dimensions",children:c.map((h,x)=>{const y=h.to.length>0;return m.jsxs(_,{role:"listitem",sx:{display:"grid",gridTemplateColumns:{xs:"auto minmax(0, 1fr)",sm:"auto minmax(0, 0.9fr) minmax(0, 1.6fr)"},alignItems:"center",columnGap:1.5,rowGap:1,py:1.25,borderTop:x===0?"none":`1px solid ${b}`},children:[m.jsx(ym,{size:"small",checked:y,onChange:k=>w(x,k.target.checked),slotProps:{input:{"aria-label":`${h.name} is clickable`}}}),m.jsxs(_,{sx:{minWidth:0},children:[m.jsx(_,{sx:{...f.type.control,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:mg(h.name)}),m.jsxs(_,{title:h.expression,sx:{...f.type.code,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[h.name," is ",h.expression]})]}),y?m.jsxs(ft,{direction:"row",sx:{gridColumn:{xs:"1 / -1",sm:"auto"},alignItems:"center",gap:1,justifyContent:"flex-end",...f.type.control},children:[m.jsx(_,{component:"span",sx:{color:"text.secondary"},children:"Opens"}),m.jsx(Zt,{select:!0,size:"small",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:k=>k.map(g).join(", ")},onChange:k=>u(x,C=>{const $=k.target.value,T=Array.isArray($)?$:String($).split(",").filter(Boolean);T.length===0&&(C.lastTo=C.to),C.to=T}),sx:{flex:"1 1 150px",minWidth:0,maxWidth:200},children:p.map(k=>m.jsxs(Xe,{value:k,children:[m.jsx(yo,{size:"small",checked:h.to.includes(k),sx:{p:0,mr:1}}),m.jsx(Bt,{primary:g(k)})]},k))}),m.jsx(_,{component:"span",sx:{color:"text.secondary"},children:"sets"}),m.jsxs(Zt,{select:!0,size:"small",value:h.given,inputProps:{"aria-label":`Control ${h.name} sets`},SelectProps:{displayEmpty:!0,renderValue:k=>k===""?h.name:String(k)},onChange:k=>u(x,C=>{C.given=k.target.value}),sx:{flex:"1 1 120px",minWidth:0,maxWidth:170},children:[m.jsx(Xe,{value:"",children:m.jsx(Bt,{primary:h.name,secondary:"Named like the dimension"})}),r.map(k=>m.jsx(Xe,{value:k,children:k},k))]})]}):m.jsx(ve,{variant:"body2",sx:{color:"text.secondary",textAlign:"right",display:{xs:"none",sm:"block"}},children:"Not clickable"})]},h.name)})})})}function mg(e){const t=e.replace(/_+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const gg=mt(m.jsx("path",{d:"M12 4c4.41 0 8 3.59 8 8s-3.59 8-8 8-8-3.59-8-8 3.59-8 8-8m0-2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 13-4-4h8z"})),vg=mt(m.jsx("path",{d:"M11 7H2v2h9zm0 8H2v2h9zm5.34-4L12.8 7.46l1.41-1.41 2.12 2.12 4.24-4.24L22 5.34zm0 8-3.54-3.54 1.41-1.41 2.12 2.12 4.24-4.24L22 13.34z"})),xg=mt(m.jsx("path",{d:"M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 16H5V10h14zm0-12H5V6h14zm-7 5h5v5h-5z"})),bg=mt(m.jsx("path",{d:"M19.5 9.5c-1.03 0-1.9.62-2.29 1.5h-2.92c-.39-.88-1.26-1.5-2.29-1.5s-1.9.62-2.29 1.5H6.79c-.39-.88-1.26-1.5-2.29-1.5C3.12 9.5 2 10.62 2 12s1.12 2.5 2.5 2.5c1.03 0 1.9-.62 2.29-1.5h2.92c.39.88 1.26 1.5 2.29 1.5s1.9-.62 2.29-1.5h2.92c.39.88 1.26 1.5 2.29 1.5 1.38 0 2.5-1.12 2.5-2.5s-1.12-2.5-2.5-2.5"})),yg=mt(m.jsx("path",{d:"M4 9h16v2H4zm0 4h10v2H4z"})),wg=mt(m.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33v-4h3.33zM19 17h-3.33v-4H19zm0-6h-8.67V7H19z"}));function kg(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of le(s)?s.filters??[]:[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],i=new Set;for(const s of e.localGivens??[])i.add(s.name),r.push({name:s.name,...s.label===void 0?{}:{label:s.label},type:s.type,...s.suggest?{field:s.suggest.dimension}:{},origin:"dashboard",local:s,boundTiles:n.get(s.name)??0});for(const s of t)i.has(s.name)||(i.add(s.name),r.push({...s,origin:"model",boundTiles:n.get(s.name)??0}));for(const[s,o]of n)i.has(s)||r.push({name:s,origin:"model",boundTiles:o});return r}function cs(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function Sg(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function Xr(e,t){const n=Sg(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const i=new Set(["date","timestamp"]);return i.has(n)?i.has(r):n===r}function Co(e){switch(e?.replace(/_type$/,"")){case"string":return"text";case"number":return"a number";case"date":return"a date";case"timestamp":return"a timestamp";case"boolean":return"true or false";default:return e??"an unknown type"}}function $g(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const jg=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function Mg(e,t){const n=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",r=/^[A-Z_]/.test(n)?n:`F_${n}`,i=Md(r)?r:`${r}_FILTER`,s=new Set(t);if(!s.has(i))return i;for(let o=2;;o++)if(!s.has(`${i}_${o}`))return`${i}_${o}`}const Eg=[{kind:"select",label:"Pick one",hint:"A dropdown of the field's values"},{kind:"multiselect",label:"Pick several",hint:"The same, taking more than one"},{kind:"text",label:"Text",hint:"A box taking Malloy filter syntax"},{kind:"number",label:"Number range",hint:"A slider over the field's values"},{kind:"date",label:"On or after a date",hint:"A date picker; tiles keep rows on or after it"}];function Dr(e){const t=e.label.trim()||e.name,n=e.field;switch(e.kind){case"select":case"multiselect":return{name:e.name,type:"filter<string>",default:"f''",label:t,control:e.kind,...e.source?{suggest:{source:e.source,dimension:n}}:{}};case"text":return{name:e.name,type:"filter<string>",default:"f''",label:t};case"number":return{name:e.name,type:"filter<number>",default:"f''",label:t,...e.range?{rangeMin:e.range.min,rangeMax:e.range.max}:{}};case"date":return{name:e.name,type:"date",default:`@${e.dateDefault??new Date().toISOString().slice(0,10)}`,label:t}}}const To=e=>le(e)&&!cr(e)&&e.declaration.kind!=="opaque";function Cg(e,t){return e.tiles.map(n=>{const r=(le(n)?n.filters??[]:[]).find(i=>i.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:cs(t.type)!==void 0?{op:cs(t.type)}:{}}})}function Tg(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!To(s))return;const o=(s.filters??[]).filter(d=>d.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?s.filters=a:delete s.filters})}function Dg(e,t){const n=(e.localGivens??[]).filter(s=>s.name!==t.name),r=(e.localGivens??[]).findIndex(s=>s.name===t.name),i=[...n];i.splice(r>=0?r:i.length,0,t),e.localGivens=i}function Og(e,t){for(const r of e.tiles){if(!le(r))continue;const i=(r.filters??[]).filter(s=>s.given!==t);i.length>0?r.filters=i:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const Do=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function Ag({open:e,document:t,control:n,available:r,takenNames:i=[],fieldsFor:s,onApply:o}){const a=S.useRef(n);e&&(a.current=n);const d=e?n:a.current,f=d!==void 0,[c,l]=S.useState({kind:"new"}),[u,p]=S.useState(""),[g,v]=S.useState("select"),[b,w]=S.useState(""),[h,x]=S.useState(""),[y,k]=S.useState([]),[C,$]=S.useState(!1),[T,j]=S.useState(!1),M=O=>t.sources.find(z=>z.name===O.source)?.base??O.source;S.useEffect(()=>{if(e)if(j(n!==void 0),n){l({kind:"existing",name:n.name}),p(n.label??"");const O=Cg(t,n);k(O);const z=O.filter(G=>G.include),K=new Set(z.map(G=>G.field));x(K.size===1?z[0].field:n.field??""),$(K.size>1)}else l({kind:"new"}),p(""),v("select"),x(""),w(new Date().toISOString().slice(0,10)),k(t.tiles.map(O=>({include:To(O),field:""}))),$(!1)},[e,n,t]);const I=S.useMemo(()=>[...(t.localGivens??[]).map(O=>O.name),...r.map(O=>O.name),...i],[t,r,i]),N=S.useMemo(()=>h.trim()?Mg(h.trim(),I):"",[h,I]),A=c.kind==="existing"?n??r.find(O=>O.name===c.name):N?{name:N,type:Dr({name:N,label:u,kind:g,field:h}).type}:void 0,L=A?.type!==void 0&&!A.type.startsWith("filter<"),B=y.find(O=>O.include)?.op??cs(A?.type),q=(O,z)=>{j(!0),k(K=>K.map((G,ke)=>ke===O?{...G,...z}:G))},P=O=>{j(!0),k(z=>z.map(K=>({...K,op:O})))},F=O=>{const z=cs(O);k(K=>K.map(({op:G,...ke})=>z?{...ke,op:z}:ke))},E=O=>{j(!0),l({kind:"existing",name:O.name}),x(O.field??""),F(O.type)},D=O=>{j(!0),v(O),F(Dr({name:"X",label:u,kind:O,field:h}).type)},W=t.tiles.map(To),U=W.filter(Boolean).length,V=y.filter((O,z)=>O.include&&W[z]).length,Y=t.tiles.filter((O,z)=>(y[z]?.include??!1)&&W[z]&&le(O)),re=Y.length>0?Y:t.tiles.filter((O,z)=>W[z]&&le(O)),H=S.useMemo(()=>{const O=new Map;let z=!1;for(const K of re){const G=s?.(K);if(G){z=!0;for(const ke of G)O.has(ke.name)||O.set(ke.name,ke)}}return z?[...O.values()]:void 0},[y,t.tiles,s]),ne=(()=>{const O=h.trim();for(const z of Y){const K=s?.(z);if(!K||K.some(G=>G.name===O))return M(z)}return Y[0]?M(Y[0]):t.sources[0]?.base})(),Q=O=>{j(!0),k(z=>z.map((K,G)=>({...K,include:O&&W[G]})))},ge=S.useMemo(()=>C?y:y.map(O=>({...O,field:h})),[C,y,h]),Z=O=>{for(const z of re){const K=s?.(z)?.find(G=>G.name===O.trim());if(K?.type)return K.type}},Ae=O=>Xr(A?.type,O.type),Pe=(O,z)=>{if(O.trim()==="")return"Pick the field this filter compares.";const K=z?s?.(z):void 0;if(!K)return;const G=K.find(ke=>ke.name===O.trim());if(!G)return`Not a field of ${z?M(z):"the tiles' source"}.`;if(G.type&&!Xr(A?.type,G.type))return`${O.trim()} is ${Co(G.type)}; this filter compares ${Co(A?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},X=O=>{if(j(!0),x(O),f||c.kind!=="new")return;const z=Z(O),K=Dr({name:"X",label:u,kind:g,field:O}).type;z&&!Xr(K,z)&&D($g(z))},we=O=>{const z=t.tiles[O];return z&&le(z)?z:void 0},ye=ge.map((O,z)=>O.include&&W[z]?Pe(O.field,we(z)):void 0),se=ye.every(O=>O===void 0),Re=T?ye:ye.map(()=>{}),Ke=T&&!C&&V>0?Y.map(O=>Pe(h,O)).find(Boolean):void 0,Ie=A!==void 0&&se&&(c.kind==="existing"||h.trim()!==""&&N!==""),Qe=()=>{if(!(!A||!Ie))if(c.kind==="new")o(A.name,ge,Dr({name:A.name,label:u.trim()||Do(A.name),kind:g,field:h.trim(),...ne?{source:ne}:{},...b?{dateDefault:b}:{}}));else if(n?.origin==="dashboard"&&n.local){const O=u.trim(),z=O!==(n.local.label??"");o(A.name,ge,z?{...n.local,...O?{label:O}:{}}:void 0)}else o(A.name,ge)},Ze=f&&d.origin==="model";return{editing:f,shown:d,fromModel:Ze,source:c,setSource:l,label:u,setLabel:p,kind:g,dateDefault:b,setDateDefault:w,field:h,rows:y,setRows:k,perTile:C,setPerTile:$,newName:N,target:A,valueTyped:L,commonOp:B,setRow:q,setCommonOp:P,pickExisting:E,pickKind:D,bindable:W,bindableCount:U,included:V,commonFields:H,setAll:Q,accepts:Ae,pickField:X,rowProblems:Re,commonProblem:Ke,canApply:Ie,apply:Qe}}function Yl({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:d,autoFocus:f,placeholder:c,inputRef:l,sx:u}){const p=S.useMemo(()=>(n??[]).filter(v=>r?.(v)??!0).map(v=>v.name),[n,r]),g=S.useMemo(()=>new Map((n??[]).map(v=>[v.name,v.type])),[n]);return m.jsx(_m,{freeSolo:!0,size:"small",options:p,inputValue:e,onInputChange:(v,b)=>t(b),value:e,onChange:(v,b)=>t(typeof b=="string"?b:""),disabled:d,disableClearable:!0,renderOption:(v,b)=>S.createElement("li",{...v,key:b},m.jsx(Ql,{type:g.get(b)}),m.jsx(ve,{variant:"body2",sx:{flex:1,ml:1},children:b})),renderInput:v=>m.jsx(Zt,{...v,label:i,placeholder:c,autoFocus:f,...l?{inputRef:l}:{},error:o,helperText:a,InputLabelProps:{...v.InputLabelProps,shrink:!0},InputProps:{...v.InputProps,startAdornment:g.get(e.trim())?m.jsx(_,{sx:{display:"flex",ml:.5,mr:-.25},children:m.jsx(Ql,{type:g.get(e.trim())})}):void 0},inputProps:{...v.inputProps,"aria-label":s}}),sx:u})}const Pg=e=>e&&le(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:e&&le(e)&&e.declaration.kind==="query"?{label:"Not bindable",reason:"It names a query, whose filters live in that query's own definition."}:{label:"From the model",reason:"Declared on its source, which this report does not write."};function Rg({open:e,document:t,control:n,available:r,takenNames:i,fieldsFor:s,onClose:o,onApply:a,onRemove:d}){const{theme:f}=qe(),c=f.ui,{editing:l,shown:u,fromModel:p,source:g,setSource:v,label:b,setLabel:w,kind:h,dateDefault:x,setDateDefault:y,field:k,rows:C,setRows:$,perTile:T,setPerTile:j,newName:M,target:I,valueTyped:N,commonOp:A,setRow:L,setCommonOp:B,pickExisting:q,pickKind:P,bindable:F,bindableCount:E,included:D,commonFields:W,setAll:U,accepts:V,pickField:Y,rowProblems:re,commonProblem:H,canApply:ne,apply:Q}=Ag({open:e,document:t,control:n,available:r,...i?{takenNames:i}:{},fieldsFor:s,onApply:a}),ge=S.useRef(null),Z=cn(f.cardBorder),Ae=Cs(f.cardBorder,f.tileTitle),[Pe,X]=S.useState(!1),[we,ye]=S.useState(!1);S.useEffect(()=>{e?ye(!0):X(!1)},[e]),S.useEffect(()=>{we&&(ye(!1),X(l&&D<E))},[we]),S.useEffect(()=>{T&&X(!0)},[T]);const se=W?.find(O=>O.name===k.trim())?.type,Re=O=>{if(!se)return;const z=Dr({name:"X",label:b,kind:O,field:k}).type;return Xr(z,se)?void 0:`${k.trim()} is ${Co(se)}, which this control cannot filter.`},Ke=b.trim()||(M?Do(M):"Filter"),Ie=h==="number"?"Any":h==="date"?x?new Date(`${x}T00:00:00`).toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"}):"Any":"All",Qe={...as(Z,c),alignSelf:"flex-start","& .MuiToggleButton-root":{...as(Z,c)["& .MuiToggleButton-root"],textTransform:"none"}},Ze=(O,z,K)=>m.jsx(Zt,{select:!0,size:"small",label:"Compares",value:O??">=",onChange:G=>z(G.target.value),inputProps:{"aria-label":K},sx:{width:130},children:jg.filter(G=>G.op!=="~").map(G=>m.jsx(Xe,{value:G.op,children:G.label},G.op))});return m.jsx(Ta,{className:`${rt.dialog} ${rt.filterDialog}`,open:e,onClose:o,...l?{}:{initialFocus:ge},title:l?u.label??u.name:"Add a filter",description:l?m.jsxs(m.Fragment,{children:[m.jsxs(_,{component:"span",sx:{fontFamily:c.font.mono},children:["$",u.name]}),p?" · declared in the model, so its label and options are set there":" · declared in this report"]}):"A filter on the page, and the tiles it filters.",actions:m.jsxs(m.Fragment,{children:[l&&m.jsx(Oe,{color:"error",startIcon:m.jsx(vm,{}),onClick:()=>d(u.name),sx:O=>({mr:"auto",color:gm(O)}),children:"Remove filter"}),m.jsx(Oe,{onClick:o,children:"Cancel"}),m.jsx(Dt,{title:ne||I===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:m.jsx("span",{children:m.jsx(Oe,{variant:"contained",onClick:Q,disabled:!ne,children:l?"Apply":"Add filter"})})})]}),children:m.jsxs(ft,{sx:{gap:2.5,pt:1},children:[!l&&r.length>0&&m.jsxs(Ed,{exclusive:!0,size:"small",value:g.kind,onChange:(O,z)=>{z==="new"?v({kind:"new"}):z==="existing"&&r[0]&&q(r[0])},"aria-label":"Where the filter comes from",sx:Qe,children:[m.jsx(ko,{value:"new",children:"New in this report"}),m.jsx(ko,{value:"existing",children:"From the model"})]}),!l&&g.kind==="existing"?m.jsx(Zt,{select:!0,size:"small",label:"Filter",value:g.name,onChange:O=>{const z=r.find(K=>K.name===O.target.value);z&&q(z)},children:r.map(O=>m.jsxs(Xe,{value:O.name,children:[O.label??O.name,m.jsxs(ve,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",O.name]})]},O.name))}):null,m.jsxs(_,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:p?"1fr":"minmax(0, 1.4fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[!T&&m.jsx(Yl,{value:k,onChange:Y,fields:W,accepts:V,label:"Field",ariaLabel:"Field to filter",placeholder:"category",inputRef:ge,error:H!==void 0,helperText:H??(!l&&M?`Declared as $${M}`:void 0)}),!p&&m.jsx(Zt,{size:"small",label:"Label",placeholder:M?Do(M):"",value:b,onChange:O=>w(O.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Filter label"}})]}),N&&!T&&Ze(A,B,"Comparison"),!l&&g.kind==="new"&&m.jsxs(_,{children:[m.jsx(Xl,{children:"Control"}),m.jsx(_,{role:"radiogroup","aria-label":"Filter kind",sx:{display:"grid",gridTemplateColumns:{xs:"repeat(3, minmax(0, 1fr))",sm:"repeat(5, minmax(0, 1fr))"},gap:1},children:Eg.map(O=>{const z=O.kind===h,K=Re(O.kind);return m.jsx(Dt,{title:K??O.hint,describeChild:!0,children:m.jsxs(hd,{role:"radio","aria-checked":z,"aria-label":O.label,"aria-disabled":K!==void 0,onClick:()=>{K===void 0&&P(O.kind)},sx:G=>({flexDirection:"column",gap:.5,px:1,py:1.25,borderRadius:c.radius.tile,border:`1px solid ${z?f.accent:Z}`,boxShadow:z?`0 0 0 1px ${f.accent}`:"none",bgcolor:z?`color-mix(in srgb, ${f.accent} 6%, ${G.palette.background.paper})`:G.palette.background.paper,color:z?f.accent:G.palette.text.secondary,opacity:K?.45:1,cursor:K?"default":"pointer",transition:`border-color ${nt}, background-color ${nt}`,"&:hover":K||z?{}:{borderColor:Ae}}),children:[m.jsx(Ng,{kind:O.kind}),m.jsx(_,{component:"span",sx:{...c.type.caption,fontWeight:z?600:500,color:z?f.accent:"text.primary",textAlign:"center"},children:Ig[O.kind]})]})},O.kind)})}),h==="date"&&m.jsx(Zt,{size:"small",type:"date",label:"Starts at",value:x,onChange:O=>y(O.target.value),InputLabelProps:{shrink:!0},sx:{mt:1.5,width:200}})]}),m.jsxs(_,{sx:{border:`1px solid ${Z}`,borderRadius:c.radius.tile,overflow:"hidden"},children:[m.jsxs(ft,{direction:"row",sx:{alignItems:"center",gap:1.25,px:1.5,py:1},children:[m.jsx(wg,{"aria-hidden":!0,sx:{fontSize:18,color:"text.secondary"}}),m.jsxs(ve,{variant:"body2",sx:{flex:1,minWidth:0},children:[m.jsx(_,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:D===E&&E>0?`Applies to all ${D} tile${D===1?"":"s"}`:`Applies to ${D} of ${E} tile${E===1?"":"s"}`}),!T&&k.trim()!==""&&D>0&&m.jsxs(_,{component:"span",sx:{color:"text.secondary"},children:[" · each filters on ",m.jsx(_,{component:"span",sx:{...c.type.code},children:k.trim()})]})]}),!T&&m.jsx(Oe,{size:"small","aria-expanded":Pe,onClick:()=>X(O=>!O),children:Pe?"Done choosing":"Choose tiles"})]}),m.jsx(So,{in:Pe,unmountOnExit:!0,children:m.jsxs(_,{sx:{borderTop:`1px solid ${Z}`,px:.5,pb:1},children:[m.jsxs(ft,{direction:"row",sx:{alignItems:"center",gap:.5,pt:.5},children:[m.jsx(yo,{size:"small",checked:E>0&&D===E,indeterminate:D>0&&D<E,disabled:E===0,onChange:O=>U(O.target.checked),inputProps:{"aria-label":"All tiles"}}),m.jsx(ve,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:"All tiles"}),m.jsx(Oe,{size:"small",onClick:()=>{T||$(O=>O.map(z=>({...z,field:k}))),j(O=>!O)},children:T?"Same field for all":"Adjust per tile"})]}),m.jsx(ft,{sx:{gap:T?1:0},children:t.tiles.map((O,z)=>{if(!le(O))return null;const K=C[z],G=O.label??O.name,ke=T?re[z]:void 0;return m.jsxs(ft,{direction:"row",sx:{gap:1,alignItems:T?"flex-start":"center",opacity:F[z]?1:.6},children:[m.jsx(yo,{size:"small",disabled:!F[z],checked:(K?.include??!1)&&F[z],inputProps:{"aria-label":`Filter ${G}`},onChange:Me=>L(z,{include:Me.target.checked})}),m.jsx(ve,{variant:"body2",sx:{flex:1,minWidth:0,pt:T?1:0},noWrap:!0,children:G}),F[z]?T&&m.jsxs(m.Fragment,{children:[N&&Ze(K?.op,Me=>L(z,{op:Me}),`Comparison for ${G}`),m.jsx(Yl,{value:K?.field??"",onChange:Me=>L(z,{field:Me}),fields:s?.(O),accepts:V,label:"Field",ariaLabel:`Field for ${G}`,disabled:!K?.include,error:ke!==void 0,helperText:ke,sx:{width:220,pr:1}})]}):m.jsx(ve,{variant:"caption",sx:{color:f.tileTitle,pr:1,maxWidth:260,textAlign:"right"},children:Pg(t.tiles[z]).reason})]},fe(O))})})]})})]}),D===0&&m.jsx(ve,{variant:"caption",sx:{color:"warning.main",display:"block",mt:-1.5},children:"No tile is ticked, so this control will not appear on the report."}),!p&&m.jsxs(_,{children:[m.jsx(Xl,{children:"Preview"}),m.jsx(_,{sx:O=>({display:"flex",alignItems:"center",gap:1,p:1.5,borderRadius:c.radius.tile,bgcolor:O.palette.action.hover}),children:m.jsxs(_,{"aria-hidden":!0,sx:O=>({display:"inline-flex",alignItems:"center",gap:.75,height:30,px:1.25,borderRadius:c.radius.control,border:`1px solid ${Z}`,bgcolor:O.palette.background.paper,...c.type.control}),children:[m.jsx(_,{component:"span",sx:{color:"text.secondary"},children:Ke}),m.jsx(_,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:Ie}),m.jsx(Sa,{sx:{fontSize:16,color:"text.secondary"}})]})})]})]})})}function Xl({children:e}){const t=qe().theme.ui;return m.jsx(ve,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}const Ig={select:"Pick one",multiselect:"Pick several",text:"Text",number:"Range",date:"Date"};function Ng({kind:e}){const t={fontSize:22};switch(e){case"select":return m.jsx(gg,{sx:t});case"multiselect":return m.jsx(vg,{sx:t});case"text":return m.jsx(yg,{sx:t});case"number":return m.jsx(bg,{sx:t});case"date":return m.jsx(xg,{sx:t})}}function Ql({type:e}){const t=e?.replace(/_type$/,""),n=t==="string"?"Abc":t==="number"?"#":t==="date"||t==="timestamp"?"Date":t==="boolean"?"T/F":void 0,r=qe().theme.ui;return n?m.jsx(_,{component:"span","aria-hidden":!0,sx:i=>({fontFamily:r.font.mono,fontSize:10,fontWeight:r.type.label.fontWeight,color:i.palette.text.secondary,bgcolor:i.palette.action.hover,borderRadius:"4px",px:.5,py:.25,minWidth:22,textAlign:"center",flex:"none"}),children:n}):null}const Zl=mt(m.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}));function zd(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:o=>s(a=>{if(a===void 0)return a;const d=structuredClone(a);return o(d),d}),apply:o=>{if(i===void 0)return;const a=structuredClone(i);o(a),s(a),JSON.stringify(a)!==JSON.stringify(e)&&n(a)},close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const Wg=e=>e&&e.length===1?`This tile's chart line (${e[0]}) is not one the builder models, so its chart cannot be changed here.`:`This tile has ${e?.length??"several"} chart lines${e?` (${e.join(" and ")})`:""}, so its chart cannot be changed here.`,zg=new Set(["bar_chart","line_chart","scatter_chart","combo_chart"]),Lg="Its chart's bars, lines and points do not respond to a click; show it as a table to click its cells.",Fg="Declared on its source, so its chart is set in the model.",Bg="It names a query, so its chart is set where that query is declared.";function _g({anchor:e,tile:t,onClose:n,onCommit:r,onDrills:i,onDuplicate:s,duplicateBlocked:o,view:a,viewStatus:d}){const{theme:f}=qe(),c=f.ui,{draft:l,apply:u,patch:p,close:g}=zd(t,e!==null,r,n),[v,b]=S.useState(void 0),w=l!==void 0&&le(l)?l:void 0,h=w!==void 0&&!cr(w),x=E=>u(D=>{le(D)&&E(D)}),y=S.useRef(void 0),k=S.useRef(null),C=e!==null;S.useEffect(()=>{C?y.current=t&&le(t)?t.chart:void 0:b(void 0)},[C]);const $=w?.chart??"default",T=Nd(a,$,d),j=w?w.declaration.kind==="query"?Bg:h?w.chart==="custom"?Wg(w.chartLines):void 0:Fg:void 0,M=E=>x(D=>{const W=y.current;E===(W??"default")?(W===void 0?delete D.chart:D.chart=W,delete D.chartCarried):(D.chart=E,a?D.chartCarried=a.chart?[a.chart]:[]:delete D.chartCarried)}),I=h?i?void 0:"Its source declares no dimension a click could filter by.":void 0,N=$==="default"?a?.chart:$,A=N!==void 0&&zg.has(N)?Lg:void 0,L=E=>D=>b({kind:E,anchor:D.currentTarget}),B=j??(N===void 0||!qg.has(N)?"Only a bar, line, scatter or bar and line chart has a color to set.":void 0),q=Array.from(new Set(f.series.map(wd).filter(E=>E!==void 0))).slice(0,8),P=E=>x(D=>{E===void 0?delete D.color:D.color=E.toLowerCase()}),F=(E,D,W)=>m.jsxs(m.Fragment,{children:[m.jsx(Bt,{primary:E,...W?{secondary:W}:{},secondaryTypographyProps:{sx:{whiteSpace:"normal",maxWidth:240}}}),D&&m.jsx(ve,{variant:"body2",sx:{color:"text.secondary",ml:2},children:D})]});return m.jsxs(m.Fragment,{children:[m.jsxs(Xn,{className:rt.menu,open:e!==null&&l!==void 0,anchorEl:e,onClose:g,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":w?vt(w):"Tile"},slotProps:{paper:{sx:{minWidth:240,mt:.5,borderRadius:c.radius.menu,border:`1px solid ${cn(f.cardBorder)}`,boxShadow:c.shadow.menu}}},children:[w&&m.jsxs(Xe,{"aria-haspopup":"menu","aria-expanded":v?.kind==="chart",disabled:j!==void 0,onClick:L("chart"),onKeyDown:E=>{E.key==="ArrowRight"&&j===void 0&&b({kind:"chart",anchor:E.currentTarget})},children:[F("Chart",j?void 0:T.find(E=>E.value===$)?.label,j),m.jsx(Zl,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),w&&j===void 0&&m.jsxs(Xe,{"aria-haspopup":"menu","aria-expanded":v?.kind==="color",disabled:B!==void 0,onClick:L("color"),onKeyDown:E=>{E.key==="ArrowRight"&&B===void 0&&b({kind:"color",anchor:E.currentTarget})},children:[F("Color",B?void 0:w.color??"Theme",B),!B&&m.jsx(Gs,{color:w.color??f.series[0],trailing:!0}),m.jsx(Zl,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),h&&m.jsx(Xe,{"aria-haspopup":"dialog",disabled:I!==void 0,onClick:()=>{g(),i?.()},children:F("Clickable cells…",void 0,I??A)}),w&&s&&m.jsx(Xe,{disabled:o!==void 0,onClick:()=>{g(),s()},children:F("Duplicate",void 0,o)}),w?.declaration.kind==="opaque"&&m.jsxs(ve,{variant:"body2",sx:{color:f.tileTitle,px:2,py:.75,maxWidth:260},children:["Its body is ",w.declaration.why,", so a filter has no single place to go."]}),w&&m.jsx(nr,{}),w&&m.jsx(_,{"aria-hidden":!0,sx:{px:2,py:.5,...c.type.code,color:"text.secondary"},children:vt(w).replace("->","→")})]}),m.jsx(Xn,{className:rt.menu,open:v?.kind==="chart",anchorEl:v?.anchor??null,onClose:()=>b(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":"Chart",onKeyDown:E=>{E.key==="ArrowLeft"&&(E.preventDefault(),b(void 0))}},children:T.filter(E=>E.value!=="custom").map(E=>m.jsxs(Xe,{role:"menuitemradio","aria-checked":E.value===$,disabled:E.disabled===!0,onClick:()=>{M(E.value),b(void 0)},children:[m.jsx(Bt,{primary:E.label,...E.reason??E.hint?{secondary:E.reason??E.hint}:{}}),E.value===$&&m.jsx(kd,{sx:{minWidth:0,ml:2},children:m.jsx(Ts,{fontSize:"small",sx:{color:f.accent}})})]},E.value))}),m.jsxs(Xn,{className:rt.menu,open:v?.kind==="color",anchorEl:v?.anchor??null,onClose:()=>b(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,"aria-label":"Color",onKeyDown:E=>{E.key==="ArrowLeft"&&(E.preventDefault(),b(void 0))}},children:[m.jsxs(Xe,{role:"menuitemradio","aria-checked":w?.color===void 0,onClick:()=>{P(void 0),b(void 0)},children:[m.jsx(Gs,{color:f.series[0]}),m.jsx(Bt,{primary:"Theme",secondary:"The page's own colors"}),w?.color===void 0&&m.jsx(Jl,{color:f.accent})]}),q.map(E=>m.jsxs(Xe,{role:"menuitemradio","aria-checked":w?.color===E.toLowerCase(),onClick:()=>{P(E),b(void 0)},children:[m.jsx(Gs,{color:E}),m.jsx(Bt,{primary:E.toLowerCase()}),w?.color===E.toLowerCase()&&m.jsx(Jl,{color:f.accent})]},E)),m.jsx(nr,{}),m.jsxs(Xe,{component:"label","aria-checked":w?.color!==void 0&&!q.some(E=>E.toLowerCase()===w.color),role:"menuitemradio",onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),k.current?.click())},children:[m.jsx("input",{ref:k,type:"color","aria-label":"Other color",value:w?.color??Hg(f.series[0]),onChange:E=>{const D=E.target.value;xm(D)&&p(W=>{le(W)&&(W.color=D.toLowerCase())})},style:{width:18,height:18,padding:0,border:"none",background:"none",marginRight:12}}),m.jsx(Bt,{primary:"Other color…"})]})]})]})}const qg=new Set(["bar_chart","line_chart","scatter_chart","combo_chart"]),Hg=e=>(e&&wd(e))??"#000000";function Gs({color:e,trailing:t=!1}){return m.jsx(_,{"aria-hidden":!0,"data-swatch":t?"trailing":"leading",sx:{width:14,height:14,borderRadius:"3px",bgcolor:e,border:"1px solid rgba(0,0,0,0.15)",...t?{ml:1}:{mr:1.5},flex:"none"}})}function Jl({color:e}){return m.jsx(kd,{sx:{minWidth:0,ml:2},children:m.jsx(Ts,{fontSize:"small",sx:{color:e}})})}const Os=e=>e.label??bm(vt(e));function Ug({editor:e,catalog:t,columns:n,dashboards:r,bindings:i,tiles:s,drillSource:o,setDrillSource:a,exitDialog:d,renderViewPreview:f,takenGivenNames:c}){const{filterDialog:l,setFilterDialog:u}=i,{menu:p,setMenu:g}=s,[v,b]=S.useState(),w=p===void 0?void 0:e.document.tiles[p.index],h=w&&le(w)?w:void 0,x=(()=>{if(!h||!t)return;const y=t.documentViews?.get(h.source??"")?.get(h.name);if(y&&e.document.sources.some($=>$.name===h.source))return y;if(h.declaration.kind==="inline"||h.declaration.kind==="opaque")return;const k=e.document.sources.find($=>$.name===h.source)?.base??h.source,C=h.declaration.kind==="reference"?h.declaration.from:h.name;return t.sources.find($=>$.name===k)?.views.find($=>$.name===C)})();return m.jsxs(m.Fragment,{children:[m.jsx(Rg,{open:l!==void 0,document:e.document,...l?.control?{control:l.control}:{},available:i.available,...c?{takenNames:c}:{},...t?{fieldsFor:i.fieldsFor}:{},onClose:()=>u(void 0),onApply:i.applyFilter,onRemove:i.dropControl}),m.jsx(_g,{anchor:p?.anchor??null,tile:p===void 0?void 0:e.document.tiles[p.index],onClose:()=>g(void 0),onCommit:y=>{const k=p?.index;if(k===void 0)return;const C=ig(y);e.update($=>{$.tiles[k]=C,C!==y&&rn($.tiles)&&($.tiles=Ht($.tiles,n,k))})},view:x,...x===void 0&&h?{viewStatus:t?"unlisted":"loading"}:{},onDuplicate:()=>{p&&s.duplicate(p.index)},...h&&ls(h)!==void 0?{duplicateBlocked:ls(h)}:{},...(e.document.sources.find(y=>y.name===h?.source)?.dimensions?.length??0)>0?{onDrills:()=>{b(h?Os(h):void 0),a(h?.source)}}:{}}),m.jsx(pg,{open:o!==void 0,document:e.document,source:e.document.sources.find(y=>y.name===o),givenNames:i.controlList.map(y=>y.name),dashboards:r??[],...v?{tileLabel:v}:{},onClose:()=>a(void 0),onApply:y=>e.update(k=>{const C=[...(k.drills??[]).filter($=>$.source!==o),...y];C.length===0?delete k.drills:k.drills=C})}),m.jsx(Dp,{...d}),m.jsx(ug,{open:s.addingTile,document:e.document,catalog:t,columns:n,onClose:s.closeAdd,onAdd:s.addTile,onAddText:s.addText,...f?{renderPreview:f}:{}})]})}var Vg=Symbol.for("preact-signals");function As(){if(_t>1)_t--;else{var e,t=!1;for((function(){var i=us;for(us=void 0;i!==void 0;){var s=i.S;if(s.v===i.v)for(var o=s.t;o!==void 0;o=o.x)o.i===i.i&&(o.i=s.i);i=i.o}})();Zr!==void 0;){var n=Zr;for(Zr=void 0,ds++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Fd(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(ds=0,_t--,t)throw e}}function De(e){if(_t>0)return e();Oo=++Kg,_t++;try{return e()}finally{As()}}var Qr,Se=void 0;function oe(e){var t=Se,n=Qr;Se=void 0,Qr=void 0;try{return e()}finally{Se=t,Qr=n}}var Zr=void 0,_t=0,ds=0,Kg=0,Oo=0,us=void 0,hs=0;function Ld(e){if(Se!==void 0){var t=e.n;if(t===void 0||t.t!==Se)return t={i:0,S:e,p:Se.s,n:void 0,t:Se,e:void 0,x:void 0,r:t},Se.s!==void 0&&(Se.s.n=t),Se.s=t,e.n=t,32&Se.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=Se.s,t.n=void 0,Se.s.n=t,Se.s=t),t}}function dt(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}dt.prototype.brand=Vg;dt.prototype.h=function(){return!0};dt.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:oe(function(){var r;(r=t.W)==null||r.call(t)}))};dt.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&oe(function(){var i;(i=t.Z)==null||i.call(t)}))}};dt.prototype.subscribe=function(e){var t=this;return $t(function(){var n=t.value;oe(function(){return e(n)})},{name:"sub"})};dt.prototype.valueOf=function(){return this.value};dt.prototype.toString=function(){return this.value+""};dt.prototype.toJSON=function(){return this.value};dt.prototype.peek=function(){var e=this;return oe(function(){return e.value})};Object.defineProperty(dt.prototype,"value",{get:function(){var e=Ld(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ds>100)throw new Error("Cycle detected");(function(n){_t!==0&&ds===0&&n.l!==Oo&&(n.l=Oo,us={S:n,v:n.v,i:n.i,o:us})})(this),this.v=e,this.i++,hs++,_t++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{As()}}}});function dr(e,t){return new dt(e,t)}function Fd(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Bd(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function _d(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function En(e,t){dt.call(this,void 0,t),this.x=e,this.s=void 0,this.g=hs-1,this.f=4}En.prototype=new dt;En.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===hs))return!0;if(this.g=hs,this.f|=1,this.i>0&&!Fd(this))return this.f&=-2,!0;var e=Se;try{Bd(this),Se=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return Se=e,_d(this),this.f&=-2,!0};En.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}dt.prototype.S.call(this,e)};En.prototype.U=function(e){if(this.t!==void 0&&(dt.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};En.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(En.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Ld(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function ec(e,t){return new En(e,t)}function qd(e){var t=e.m;if(e.m=void 0,typeof t=="function"){_t++;var n=Se;Se=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Aa(e),r}finally{Se=n,As()}}}function Aa(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,qd(e)}function Gg(e){if(Se!==this)throw new Error("Out-of-order effect");_d(this),Se=e,this.f&=-2,8&this.f&&Aa(this),As()}function ur(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Qr&&Qr.push(this)}ur.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};ur.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,qd(this),Bd(this),_t++;var e=Se;return Se=this,Gg.bind(this,e)};ur.prototype.N=function(){2&this.f||(this.f|=2,this.u=Zr,Zr=this)};ur.prototype.d=function(){this.f|=8,1&this.f||Aa(this)};ur.prototype.dispose=function(){this.d()};function $t(e,t){var n=new ur(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Yg=Object.create,Pa=Object.defineProperty,Xg=Object.defineProperties,Qg=Object.getOwnPropertyDescriptor,Zg=Object.getOwnPropertyDescriptors,tc=Object.getOwnPropertySymbols,Jg=Object.prototype.hasOwnProperty,ev=Object.prototype.propertyIsEnumerable,tv=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),hr=e=>{throw TypeError(e)},Ao=(e,t,n)=>t in e?Pa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nv=(e,t)=>{for(var n in t||(t={}))Jg.call(t,n)&&Ao(e,n,t[n]);if(tc)for(var n of tc(t))ev.call(t,n)&&Ao(e,n,t[n]);return e},rv=(e,t)=>Xg(e,Zg(t)),nc=(e,t)=>Pa(e,"name",{value:t,configurable:!0}),iv=e=>{var t;return[,,,Yg((t=void 0)!=null?t:null)]},Hd=["class","method","getter","setter","accessor","field","value","get","set"],Or=e=>e!==void 0&&typeof e!="function"?hr("Function expected"):e,sv=(e,t,n,r,i)=>({kind:Hd[e],name:t,metadata:r,addInitializer:s=>n._?hr("Already initialized"):i.push(Or(s||null))}),Ud=(e,t)=>Ao(t,tv("metadata"),e[3]),un=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},fr=(e,t,n,r,i,s)=>{var o,a,d,f,c,l=t&7,u=!!(t&8),p=!!(t&16),g=l>3?e.length+1:l?u?1:2:0,v=Hd[l+5],b=l>3&&(e[g-1]=[]),w=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&Qg(l<4?i:{get[n](){return yt(this,s)},set[n](y){return Xt(this,s,y)}},n));l?p&&l<4&&nc(s,(l>2?"set ":l>1?"get ":"")+n):nc(i,n);for(var x=r.length-1;x>=0;x--)f=sv(l,n,d={},e[3],w),l&&(f.static=u,f.private=p,c=f.access={has:p?y=>ov(i,y):y=>n in y},l^3&&(c.get=p?y=>(l^1?yt:av)(y,i,l^4?s:h.get):y=>y[n]),l>2&&(c.set=p?(y,k)=>Xt(y,i,k,l^4?s:h.set):(y,k)=>y[n]=k)),a=(0,r[x])(l?l<4?p?s:h[v]:l>4?void 0:{get:h.get,set:h.set}:i,f),d._=1,l^4||a===void 0?Or(a)&&(l>4?b.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?hr("Object expected"):(Or(o=a.get)&&(h.get=o),Or(o=a.set)&&(h.set=o),Or(o=a.init)&&b.unshift(o));return l||Ud(e,i),h&&Pa(i,n,h),p?l^4?s:h:i},Ra=(e,t,n)=>t.has(e)||hr("Cannot "+n),ov=(e,t)=>Object(t)!==t?hr('Cannot use the "in" operator on this value'):e.has(t),yt=(e,t,n)=>(Ra(e,t,"read from private field"),n?n.call(e):t.get(e)),Ar=(e,t,n)=>t.has(e)?hr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Xt=(e,t,n,r)=>(Ra(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),av=(e,t,n)=>(Ra(e,t,"access private method"),n);function Po(e,t){if(t){let n;return ec(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return ec(e)}function Ct(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((n,r)=>!Ct(n,t[r]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(i=>!Ct(e[i],t[i]))}return!1}function ae({get:e},t){return{init(n){return dr(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function ze(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Po(e.bind(this)),n.set(this,r)),r.value}}function Ys(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),i=Object.getOwnPropertyDescriptor(r,n.name);i&&Object.defineProperty(r,n.name,rv(nv({},i),{enumerable:e}))})}}function xi(...e){const t=e.map(n=>$t(n));return()=>t.forEach(n=>n())}var Vd,Kd,Gd,Yd,Xd,Qd,ot,Ia,Xs,Ro,Io,tt,Na,Qs,Zd,No,Wa,Zs,Wo,zo;Qd=[ae],Xd=[ae],Yd=[ae],Gd=[Ys()],Kd=[Ys()],Vd=[Ys()];var Cn=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,un(ot,5,this),Ar(this,tt),Ar(this,Ia,un(ot,8,this)),un(ot,11,this),Ar(this,Na,un(ot,12,this)),un(ot,15,this),Ar(this,Wa,un(ot,16,this)),un(ot,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return yt(this,tt,Wo)}get initial(){return yt(this,tt,Ro)}get previous(){return yt(this,tt,Zd)}set current(e){const t=oe(()=>yt(this,tt,Wo));e&&t&&this.equals(t,e)||De(()=>{yt(this,tt,Ro)||Xt(this,tt,e,Io),Xt(this,tt,t,No),Xt(this,tt,e,zo)})}reset(e=this.defaultValue){De(()=>{Xt(this,tt,void 0,No),Xt(this,tt,e,Io),Xt(this,tt,e,zo)})}};ot=iv();Ia=new WeakMap;tt=new WeakSet;Na=new WeakMap;Wa=new WeakMap;Xs=fr(ot,20,"#initial",Qd,tt,Ia),Ro=Xs.get,Io=Xs.set;Qs=fr(ot,20,"#previous",Xd,tt,Na),Zd=Qs.get,No=Qs.set;Zs=fr(ot,20,"#current",Yd,tt,Wa),Wo=Zs.get,zo=Zs.set;fr(ot,2,"current",Gd,Cn);fr(ot,2,"initial",Kd,Cn);fr(ot,2,"previous",Vd,Cn);Ud(ot,Cn);function Js(e){return oe(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var hn,lv=class{constructor(){Ar(this,hn,new WeakMap)}get(e,t){var n;return e?(n=yt(this,hn).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return yt(this,hn).has(e)||yt(this,hn).set(e,new Map),(r=yt(this,hn).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=yt(this,hn).get(e))==null?void 0:t.clear():void 0}};hn=new WeakMap;var cv=Object.create,Jd=Object.defineProperty,dv=Object.getOwnPropertyDescriptor,rc=Object.getOwnPropertySymbols,uv=Object.prototype.hasOwnProperty,hv=Object.prototype.propertyIsEnumerable,eu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ps=e=>{throw TypeError(e)},ic=Math.pow,Lo=(e,t,n)=>t in e?Jd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fv=(e,t)=>{for(var n in t||(t={}))uv.call(t,n)&&Lo(e,n,t[n]);if(rc)for(var n of rc(t))hv.call(t,n)&&Lo(e,n,t[n]);return e},pv=e=>{var t;return[,,,cv((t=e?.[eu("metadata")])!=null?t:null)]},tu=["class","method","getter","setter","accessor","field","value","get","set"],nu=e=>e!==void 0&&typeof e!="function"?Ps("Function expected"):e,mv=(e,t,n,r,i)=>({kind:tu[e],name:t,metadata:r,addInitializer:s=>n._?Ps("Already initialized"):i.push(nu(s||null))}),gv=(e,t)=>Lo(t,eu("metadata"),e[3]),vv=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},ru=(e,t,n,r,i,s)=>{for(var o,a,d,f,c=t&7,l=!1,u=!1,p=2,g=tu[c+5],v=e[p]||(e[p]=[]),b=(i=i.prototype,dv(i,n)),w=r.length-1;w>=0;w--)d=mv(c,n,a={},e[3],v),d.static=l,d.private=u,f=d.access={has:h=>n in h},f.get=h=>h[n],o=(0,r[w])(b[g],d),a._=1,nu(o)&&(b[g]=o);return b&&Jd(i,n,b),i},iu=(e,t,n)=>t.has(e)||Ps("Cannot "+n),xv=(e,t,n)=>(iu(e,t,"read from private field"),t.get(e)),bv=(e,t,n)=>t.has(e)?Ps("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),yv=(e,t,n,r)=>(iu(e,t,"write to private field"),t.set(e,n),n),wt=class Fo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Fo(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Fo(t,n)}},Nt=class fn{constructor(t,n,r,i){this.left=t,this.top=n,this.width=r,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:i,width:s,height:o,scale:a}=this,d=new fn(i+t,r+n,s,o);return d.scale=fv({},a),d}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new wt((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof fn))return!1;const{left:n,top:r,width:i,height:s}=this;return n===t.left&&r===t.top&&i===t.width&&s===t.height}containsPoint(t){const{top:n,left:r,bottom:i,right:s}=this;return n<=t.y&&t.y<=i&&r<=t.x&&t.x<=s}intersectionArea(t){return t instanceof fn?wv(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:i}){return new fn(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],d=o==="x"?s.left:s.top,f=o==="x"?s.width:s.height;return a=="start"?d:a=="end"?d+f:d+f/2};return wt.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return fn.from(t).intersectionRatio(fn.from(n))}};function wv(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),o=i-r,a=s-n;return r<i&&n<s?o*a:0}var su,ou,Bo,_i,bi,Rs=class extends(Bo=Cn,ou=[ze],su=[ze],Bo){constructor(e){const t=wt.from(e);super(t,(n,r)=>wt.equals(n,r)),vv(bi,5,this),bv(this,_i,0),this.velocity={x:0,y:0}}get delta(){return wt.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=wt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-xv(this,_i),o=a=>Math.round(a/s*100);De(()=>{yv(this,_i,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(wt.from(e)),this.velocity={x:0,y:0}}};bi=pv(Bo);_i=new WeakMap;ru(bi,2,"delta",ou,Rs);ru(bi,2,"direction",su,Rs);gv(bi,Rs);function _o({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(ic(r,2)+ic(i,2))>n:"x"in n&&"y"in n?r>n.x&&i>n.y:"x"in n?r>n.x:"y"in n?i>n.y:!1}var au=(e=>(e.Horizontal="x",e.Vertical="y",e))(au||{}),lu=Object.values(au),kv=Object.create,za=Object.defineProperty,Sv=Object.defineProperties,$v=Object.getOwnPropertyDescriptor,jv=Object.getOwnPropertyDescriptors,fs=Object.getOwnPropertySymbols,cu=Object.prototype.hasOwnProperty,du=Object.prototype.propertyIsEnumerable,uu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),pr=e=>{throw TypeError(e)},qo=(e,t,n)=>t in e?za(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,La=(e,t)=>{for(var n in t||(t={}))cu.call(t,n)&&qo(e,n,t[n]);if(fs)for(var n of fs(t))du.call(t,n)&&qo(e,n,t[n]);return e},Fa=(e,t)=>Sv(e,jv(t)),sc=(e,t)=>za(e,"name",{value:t,configurable:!0}),hu=(e,t)=>{var n={};for(var r in e)cu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&fs)for(var r of fs(e))t.indexOf(r)<0&&du.call(e,r)&&(n[r]=e[r]);return n},mr=e=>{var t;return[,,,kv((t=e?.[uu("metadata")])!=null?t:null)]},fu=["class","method","getter","setter","accessor","field","value","get","set"],Pr=e=>e!==void 0&&typeof e!="function"?pr("Function expected"):e,Mv=(e,t,n,r,i)=>({kind:fu[e],name:t,metadata:r,addInitializer:s=>n._?pr("Already initialized"):i.push(Pr(s||null))}),Tn=(e,t)=>qo(t,uu("metadata"),e[3]),te=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},ce=(e,t,n,r,i,s)=>{var o,a,d,f,c,l=t&7,u=!!(t&8),p=!!(t&16),g=l>3?e.length+1:l?u?1:2:0,v=fu[l+5],b=l>3&&(e[g-1]=[]),w=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&$v(l<4?i:{get[n](){return We(this,s)},set[n](y){return xt(this,s,y)}},n));l?p&&l<4&&sc(s,(l>2?"set ":l>1?"get ":"")+n):sc(i,n);for(var x=r.length-1;x>=0;x--)f=Mv(l,n,d={},e[3],w),l&&(f.static=u,f.private=p,c=f.access={has:p?y=>Ev(i,y):y=>n in y},l^3&&(c.get=p?y=>(l^1?We:pu)(y,i,l^4?s:h.get):y=>y[n]),l>2&&(c.set=p?(y,k)=>xt(y,i,k,l^4?s:h.set):(y,k)=>y[n]=k)),a=(0,r[x])(l?l<4?p?s:h[v]:l>4?void 0:{get:h.get,set:h.set}:i,f),d._=1,l^4||a===void 0?Pr(a)&&(l>4?b.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?pr("Object expected"):(Pr(o=a.get)&&(h.get=o),Pr(o=a.set)&&(h.set=o),Pr(o=a.init)&&b.unshift(o));return l||Tn(e,i),h&&za(i,n,h),p?l^4?s:h:i},Ba=(e,t,n)=>t.has(e)||pr("Cannot "+n),Ev=(e,t)=>Object(t)!==t?pr('Cannot use the "in" operator on this value'):e.has(t),We=(e,t,n)=>(Ba(e,t,"read from private field"),n?n.call(e):t.get(e)),me=(e,t,n)=>t.has(e)?pr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),xt=(e,t,n,r)=>(Ba(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),pu=(e,t,n)=>(Ba(e,t,"access private method"),n);function mu(e,t){return{plugin:e,options:t}}function yi(e){return t=>mu(e,t)}function ai(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var gu,li,_a,qi;gu=[ae];var it=class{constructor(e,t){this.manager=e,this.options=t,me(this,_a,te(li,8,this,!1)),te(li,11,this),me(this,qi,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return oe(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=$t(e.bind(this));return We(this,qi).add(t),t}destroy(){We(this,qi).forEach(e=>e())}static configure(e){return mu(this,e)}};li=mr(null);_a=new WeakMap;qi=new WeakMap;ce(li,4,"disabled",gu,it,_a);Tn(li,it);var wi=class extends it{},Hi,eo=class{constructor(e){this.manager=e,this.instances=new Map,me(this,Hi,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(ai).reduce((r,i)=>{const s=r.find(({plugin:o})=>o===i.plugin);return s?(s.options=i.options,r):[...r,i]},[]),n=t.map(({plugin:r})=>r);for(const r of We(this,Hi))if(!n.includes(r)){if(r.prototype instanceof wi)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);xt(this,Hi,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};Hi=new WeakMap;function Cv(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Di=[],Fn,Bn,Tv=class extends it{constructor(e){super(e),me(this,Fn),me(this,Bn),this.computeCollisions=this.computeCollisions.bind(this),xt(this,Bn,dr(Di)),this.destroy=xi(()=>{const t=this.computeCollisions(),n=oe(()=>this.manager.dragOperation.position.current);if(t!==Di){const r=We(this,Fn);if(xt(this,Fn,n),r&&n.x==r.x&&n.y==r.y)return}else xt(this,Fn,void 0);We(this,Bn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){oe(()=>{e?We(this,Bn).value=this.computeCollisions():xt(this,Fn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Di;const a=[],d=[];for(const f of e??n.droppables){if(f.disabled||i&&!f.accepts(i))continue;const c=t??f.collisionDetector;if(!c)continue;d.push(f),f.shape;const l=oe(()=>c({droppable:f,dragOperation:r}));l&&(f.collisionPriority!=null&&(l.priority=f.collisionPriority),a.push(l))}return d.length===0?Di:(a.sort(Cv),a)}get collisions(){return We(this,Bn).value}};Fn=new WeakMap;Bn=new WeakMap;var vu,xu,bu,qa,yu,Tt,Ha,Gn,Ua,Va;bu=[ae],xu=[ae],vu=[ae];var Ut=class pn{constructor(t,n){me(this,Ha,te(Tt,8,this)),te(Tt,11,this),me(this,Gn),me(this,Ua,te(Tt,12,this)),te(Tt,15,this),me(this,Va,te(Tt,16,this)),te(Tt,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let d=i;xt(this,Gn,dr(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var f;return[()=>{const{id:c,manager:l}=this;if(c!==d)return d=c,l?.registry.register(this),()=>l?.registry.unregister(this)},...(f=r?.())!=null?f:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),n&&a&&queueMicrotask(this.register)}get id(){var t,n;const r=We(this,Gn).value;return(n=(t=pn.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=pn.pendingIdChanges)==null?void 0:n.get(this))!=null?r:We(this,Gn).peek();t!==i&&(pn.pendingIdChanges||(pn.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return pu(s=pn,qa,yu).call(s)})),pn.pendingIdChanges.set(this,t))}register(){var t;return(t=this.manager)==null?void 0:t.registry.register(this)}unregister(){var t;(t=this.manager)==null||t.registry.unregister(this)}destroy(){var t;(t=this.manager)==null||t.registry.unregister(this)}};Tt=mr(null);qa=new WeakSet;yu=function(){const e=Ut.pendingIdChanges;Ut.pendingIdChanges=null,e&&De(()=>{for(const[t,n]of e)We(t,Gn).value=n})};Ha=new WeakMap;Gn=new WeakMap;Ua=new WeakMap;Va=new WeakMap;ce(Tt,4,"manager",bu,Ut,Ha);ce(Tt,4,"data",xu,Ut,Ua);ce(Tt,4,"disabled",vu,Ut,Va);me(Ut,qa);Tn(Tt,Ut);Ut.pendingIdChanges=null;var Is=Ut,oc=class{constructor(){this.map=dr(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));const s=new Map(n);for(const[a,d]of n)if(d===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=xi(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;this.cleanupFunctions.get(t)?.(),this.cleanupFunctions.delete(t);const i=new Map(n);i.delete(e),this.map.value=i}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this)this.cleanupFunctions.get(e)?.(),e.destroy();this.map.value=new Map}},wu,ku,Su,$u,ju,Mu,Ho,at,Ka,Ga,Ya,Wt=class extends(Ho=Is,Mu=[ae],ju=[ae],$u=[ae],Su=[ze],ku=[ze],wu=[ze],Ho){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,d=hu(n,["modifiers","type","sensors","plugins","effects"]);super(Fa(La({},d),{effects:()=>{var f;return[...(f=a?.())!=null?f:[],()=>{const{manager:c,plugins:l}=this;if(!(!c||!l))for(const u of l){const{plugin:p}=ai(u);c.registry.plugins.register(p)}}]}}),t),te(at,5,this),me(this,Ka,te(at,8,this)),te(at,11,this),me(this,Ga,te(at,12,this)),te(at,15,this),me(this,Ya,te(at,16,this,this.isDragSource?"dragging":"idle")),te(at,19,this),this.type=i,this.sensors=s,this.modifiers=r,this.alignment=d.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(const t of this.plugins){const n=ai(t);if(n.plugin===e)return n.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.source)==null?void 0:t.id)===this.id}};at=mr(Ho);Ka=new WeakMap;Ga=new WeakMap;Ya=new WeakMap;ce(at,4,"type",Mu,Wt,Ka);ce(at,4,"modifiers",ju,Wt,Ga);ce(at,4,"status",$u,Wt,Ya);ce(at,2,"isDropping",Su,Wt);ce(at,2,"isDragging",ku,Wt);ce(at,2,"isDragSource",wu,Wt);Tn(at,Wt);var Eu,Cu,Tu,Du,Ou,Au,Uo,Ue,Xa,Qa,Za,Ja,el,zt=class extends(Uo=Is,Au=[ae],Ou=[ae],Du=[ae],Tu=[ae],Cu=[ae],Eu=[ze],Uo){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=hu(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),te(Ue,5,this),me(this,Xa,te(Ue,8,this)),te(Ue,11,this),me(this,Qa,te(Ue,12,this)),te(Ue,15,this),me(this,Za,te(Ue,16,this)),te(Ue,19,this),me(this,Ja,te(Ue,20,this)),te(Ue,23,this),me(this,el,te(Ue,24,this)),te(Ue,27,this),this.accept=r,this.collisionDetector=i,this.collisionPriority=s,this.type=o}accepts(e){const{accept:t}=this;return t?typeof t=="function"?t(e):e.type?Array.isArray(t)?t.includes(e.type):e.type===t:!1:!0}get isDropTarget(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.target)==null?void 0:t.id)===this.id}};Ue=mr(Uo);Xa=new WeakMap;Qa=new WeakMap;Za=new WeakMap;Ja=new WeakMap;el=new WeakMap;ce(Ue,4,"accept",Au,zt,Xa);ce(Ue,4,"type",Ou,zt,Qa);ce(Ue,4,"collisionDetector",Du,zt,Za);ce(Ue,4,"collisionPriority",Tu,zt,Ja);ce(Ue,4,"shape",Cu,zt,el);ce(Ue,2,"isDropTarget",Eu,zt);Tn(Ue,zt);var Dv=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const i of r)i(...t)}},Ov=class extends Dv{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Ui(e,t=!0){let n=!1;return Fa(La({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Av=class extends wi{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=xi(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||Is.pendingIdChanges)return;const o=Ui({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;oe(()=>{var d;a?.id!==((d=e.dragOperation.target)==null?void 0:d.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},gr=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(gr||{}),vr=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(vr||{}),Pu,Ru,Iu,Nu,Wu,zu,Lu,St,tl;Lu=[ae],zu=[ze],Wu=[ze],Nu=[ze],Iu=[ze],Ru=[ze],Pu=[ze];var Kt=class{constructor(){te(St,5,this),me(this,tl,te(St,8,this,"idle")),te(St,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};St=mr(null);tl=new WeakMap;ce(St,4,"value",Lu,Kt,tl);ce(St,2,"current",zu,Kt);ce(St,2,"idle",Wu,Kt);ce(St,2,"initializing",Nu,Kt);ce(St,2,"initialized",Iu,Kt);ce(St,2,"dragging",Ru,Kt);ce(St,2,"dropped",Pu,Kt);Tn(St,Kt);var Pv=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return oe(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Ui({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return oe(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const n=new AbortController,{event:r,coordinates:i}=e;De(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});const s=Ui({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",s),s.defaultPrevented?(t.reset(),n.abort(),n):(t.status.set("initializing"),t.controller=n,this.manager.renderer.rendering.then(()=>{if(n.signal.aborted)return;const{status:o}=t;o.current==="initializing"&&De(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return oe(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Ui({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,d,f,c,l;if(o.defaultPrevented)return;const u=(l=e.to)!=null?l:{x:r.position.current.x+((d=(a=e.by)==null?void 0:a.x)!=null?d:0),y:r.position.current.y+((c=(f=e.by)==null?void 0:f.y)!=null?c:0)};r.position.current=u})})}stop(e={}){return oe(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const d={resume:()=>{},abort:()=>{}};return s=new Promise((f,c)=>{d.resume=f,d.abort=c}),d};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const d=oe(()=>{var c;return((c=r.source)==null?void 0:c.status)==="dropping"}),f=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(d){const{source:c}=r,l=$t(()=>{c?.status==="idle"&&(l(),f())})}else this.manager.renderer.rendering.then(f)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),s?s.then(a).catch(()=>r.reset()):a()})}},rr=class extends it{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Rv=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},Vi,Fu=class{constructor(e){this.options=e,me(this,Vi)}set controller(e){xt(this,Vi,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=We(this,Vi))==null||t.activate(e)}};Vi=new WeakMap;var ac=class extends it{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Iv=class{constructor(e){this.draggables=new oc,this.droppables=new oc,this.plugins=new eo(e),this.sensors=new eo(e),this.modifiers=new eo(e)}register(e,t){if(e instanceof Wt)return this.draggables.register(e.id,e);if(e instanceof zt)return this.droppables.register(e.id,e);if(e.prototype instanceof ac)return this.modifiers.register(e,t);if(e.prototype instanceof rr)return this.sensors.register(e,t);if(e.prototype instanceof it)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Is)return e instanceof Wt?this.draggables.unregister(e.id,e):e instanceof zt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof ac)return this.modifiers.unregister(e);if(e.prototype instanceof rr)return this.sensors.unregister(e);if(e.prototype instanceof it)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},Bu,_u,qu,Hu,Uu,Vu,Ku,Gu,Yu,Rr,Ki,_n,Te,nl,rl,il,sl,ol,Ir;Yu=[ze],Gu=[ae],Ku=[ae],Vu=[ae],Uu=[ae],Hu=[ae],qu=[ze],_u=[ze],Bu=[ze];var Pt=class{constructor(e){te(Te,5,this),me(this,Rr),me(this,Ki),me(this,_n,new Cn(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Kt,me(this,nl,te(Te,8,this,!1)),te(Te,11,this),me(this,rl,te(Te,12,this,null)),te(Te,15,this),me(this,il,te(Te,16,this,null)),te(Te,19,this),me(this,sl,te(Te,20,this,null)),te(Te,23,this),me(this,ol,te(Te,24,this,[])),te(Te,27,this),this.position=new Rs({x:0,y:0}),me(this,Ir,{x:0,y:0}),xt(this,Rr,e)}get shape(){const{current:e,initial:t,previous:n}=We(this,_n);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?We(this,_n).current=e:We(this,_n).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=We(this,Rr).registry.draggables.get(t);return n&&xt(this,Ki,n),(e=n??We(this,Ki))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=We(this,Rr).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(Fa(La({},this.snapshot()),{transform:n}));return xt(this,Ir,n),n}snapshot(){return oe(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:We(this,Ir),shape:this.shape?Js(this.shape):null,position:Js(this.position),status:Js(this.status),canceled:this.canceled}))}reset(){De(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,We(this,_n).reset(),this.position.reset({x:0,y:0}),xt(this,Ir,{x:0,y:0}),this.modifiers=[]})}};Te=mr(null);Rr=new WeakMap;Ki=new WeakMap;_n=new WeakMap;nl=new WeakMap;rl=new WeakMap;il=new WeakMap;sl=new WeakMap;ol=new WeakMap;Ir=new WeakMap;ce(Te,2,"shape",Yu,Pt);ce(Te,4,"canceled",Gu,Pt,nl);ce(Te,4,"activatorEvent",Ku,Pt,rl);ce(Te,4,"sourceIdentifier",Vu,Pt,il);ce(Te,4,"targetIdentifier",Uu,Pt,sl);ce(Te,4,"modifiers",Hu,Pt,ol);ce(Te,2,"source",qu,Pt);ce(Te,2,"target",_u,Pt);ce(Te,2,"transform",Bu,Pt);Tn(Te,Pt);var Nv={get rendering(){return Promise.resolve()}};function At(e,t){return typeof e=="function"?e(t):e??t}var Wv=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(l=>l.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var t;const n=e??{},r=At(n.plugins,[]),i=At(n.sensors,[]),s=At(n.modifiers,[]),o=(t=n.renderer)!=null?t:Nv,a=new Ov(this),d=new Iv(this);this.registry=d,this.monitor=a,this.renderer=o,this.actions=new Pv(this),this.dragOperation=new Pt(this),this.collisionObserver=new Tv(this),this.plugins=[Av,...r],this.modifiers=s,this.sensors=i;const{destroy:f}=this,c=xi(()=>{var l,u,p;const g=oe(()=>this.dragOperation.modifiers),v=this.modifiers;for(const b of g)v.includes(b)||b.destroy();this.dragOperation.modifiers=(p=(u=(l=this.dragOperation.source)==null?void 0:l.modifiers)==null?void 0:u.map(b=>{const{plugin:w,options:h}=ai(b);return new w(this,h)}))!=null?p:v});this.destroy=()=>{c(),f()}}get plugins(){return this.registry.plugins.values}set plugins(e){this.registry.plugins.values=e}get modifiers(){return this.registry.modifiers.values}set modifiers(e){this.registry.modifiers.values=e}get sensors(){return this.registry.sensors.values}set sensors(e){this.registry.sensors.values=e}},Xu=e=>{throw TypeError(e)},al=(e,t,n)=>t.has(e)||Xu("Cannot "+n),ee=(e,t,n)=>(al(e,t,"read from private field"),t.get(e)),ut=(e,t,n)=>t.has(e)?Xu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),gt=(e,t,n,r)=>(al(e,t,"write to private field"),t.set(e,n),n),Qu=(e,t,n)=>(al(e,t,"access private method"),n);function Ns(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Zu(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(Ns(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function Ws(e){const{width:t,height:n,top:r,left:i,bottom:s,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:i,bottom:s,right:o}}function ll(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ki(e){return"nodeType"in e}function bt(e){var t,n,r;return e?ll(e)?e:ki(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function cl(e){const{Document:t}=bt(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function on(e){return!e||ll(e)?!1:e instanceof bt(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Ju(e){return e instanceof bt(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function xr(e){return e?ll(e)?e.document:ki(e)?cl(e)?e:on(e)||Ju(e)?e.ownerDocument:document:document:document}function zv(e){var t,n,r,i;const{documentElement:s}=xr(e),o=bt(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,d=(n=o?.height)!=null?n:s.clientHeight,f=(r=o?.offsetTop)!=null?r:0,c=(i=o?.offsetLeft)!=null?i:0;return{top:f,left:c,right:c+a,bottom:f+d,width:a,height:d}}function Lv(e,t){if(Fv(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function Fv(e){return e.tagName==="DETAILS"}function ci(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let d=t;const{ownerDocument:f}=e,c=(r=f.defaultView)!=null?r:window;let l=e.parentElement;for(;l&&l!==f.documentElement;){if(!Lv(l)){const x=l.getBoundingClientRect(),y=n*(x.bottom-x.top),k=n*(x.right-x.left),C=n*(x.bottom-x.top),$=n*(x.right-x.left);d={top:Math.max(d.top,x.top-y),right:Math.min(d.right,x.right+k),bottom:Math.min(d.bottom,x.bottom+C),left:Math.max(d.left,x.left-$),width:0,height:0},d.width=d.right-d.left,d.height=d.bottom-d.top}l=l.parentElement}const u=c.visualViewport,p=(i=u?.offsetTop)!=null?i:0,g=(s=u?.offsetLeft)!=null?s:0,v=(o=u?.width)!=null?o:c.innerWidth,b=(a=u?.height)!=null?a:c.innerHeight,w=n*b,h=n*v;return d={top:Math.max(d.top,p-w),right:Math.min(d.right,g+v+h),bottom:Math.min(d.bottom,p+b+w),left:Math.max(d.left,g-h),width:0,height:0},d.width=d.right-d.left,d.height=d.bottom-d.top,d.width<0&&(d.width=0),d.height<0&&(d.height=0),d}function ir(e){return{x:e.clientX,y:e.clientY}}var eh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Vo(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const i=r.contentDocument;i&&!t.has(i)&&n.push(...Vo(i,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const i=r.parent;i&&i.document&&i.document!==e&&n.push(...Vo(i.document,t))}}catch{}return n}function dl(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function th(){var e,t;const n=dl()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function ul(e){return!e||!ki(e)?!1:e instanceof bt(e).ShadowRoot}function ps(e){if(e&&ki(e)){let t=e.getRootNode();if(ul(t)||t instanceof Document)return t}return xr(e)}function hl(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Bv(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((i,s)=>{const o=r[s];lc(i)&&lc(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),cc(i)&&cc(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function lc(e){return"value"in e}function cc(e){return e.tagName==="CANVAS"}function nh(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(_v(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return nh(i,{x:t-s,y:n-o})}}return r}function _v(e){return e?.tagName==="IFRAME"}var Ko=new WeakMap;function qv(e){return e.closest(`
1
+ import{g as rp,b as ip,r as S,u as sp,b9 as op,l as ap,i as lp,ba as cp,n as dp,j as m,f as up,h as hp,s as ka,m as fp,v as Wl,Z as ad,U as qe,bb as cn,bc as Cs,aD as ft,ae as rt,L as Dt,K as $n,bd as nr,ak as Oe,be as Sa,bf as vi,bg as Xn,bh as pp,bi as ld,bj as rn,bk as mp,bl as gp,bm as mo,bn as vp,T as ve,as as ht,bo as xp,bp,bq as yp,O as $a,aK as wp,br as Qt,bs as kp,bt as ja,bu as Sp,bv as cd,bw as dd,bx as $p,by as jp,a0 as go,bz as Mp,bA as Ep,bB as vo,a_ as ud,B as hd,bC as nt,I as _,aJ as Xe,bD as mt,bE as Ma,Y as Bt,bF as Cp,bG as pt,bH as zl,bI as Gr,bJ as fd,bK as Tp,bL as Ea,ag as Dp,bM as Op,bN as Ap,bO as Pp,bP as Rp,bQ as Ip,bR as pd,bS as Np,bT as Wp,bU as md,bV as gd,bW as vd,bX as zp,bY as Lp,bZ as Fp,b_ as Bp,b$ as _p,c0 as qp,c1 as Hp,c2 as Up,c3 as Vp,G as Kp,c4 as Gp,c5 as Yp,c6 as xo,c7 as bo,c8 as Ll,c9 as Xp,ca as Qp,cb as Zp,cc as Qn,cd as Jp,ce as em,cf as tm,cg as nm,ch as rm,ci as xd,cj as Ca,ck as im,cl as sm,cm as bd,cn as om,co as am,cp as lm,cq as Ts,cr as ns,cs as cm,ct as dm,cu as rs,cv as um,cw as kn,cx as hm,cy as fm,cz as yd,cA as pm,cB as mm,aP as Ta,aF as Zt,cC as yo,cD as gm,cE as vm,cF as wd,W as kd,cG as xm,cH as bm,cI as Ds,cJ as ym,cK as wo,cL as wm,cM as km,cN as Sm,cO as Sd,cP as $m,X as jm,cQ as Mm,cR as Em,cS as Cm,cT as Tm,cU as Dm,cV as Om,cW as Da,cX as Am,cY as Pm,cZ as $d,c_ as Rm,c$ as Im,d0 as Nm,d1 as Oa,d2 as Wm,d3 as zm,d4 as Lm,d5 as Pn,d6 as jd,d7 as Fl,d8 as Bl,d9 as Vs,da as Fm,S as Bm,db as _m,dc as qm,dd as Hm,de as Md,df as Um,dg as Vm,aj as Km}from"./index-iyvwQg3j.js";import{dh as tk,di as nk,dj as rk,dk as ik,dl as sk,dm as ok,dn as ak,dp as lk,dq as ck,dr as dk,ds as uk}from"./index-iyvwQg3j.js";import{T as Ed,a as ko}from"./ToggleButtonGroup-DnK5WHKM.js";function Gm(e){return rp("MuiCollapse",e)}ip("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);const Ym=e=>{const{orientation:t,classes:n}=e,r={root:["root",`${t}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${t}`],wrapperInner:["wrapperInner",`${t}`]};return hp(r,Gm,n)},Xm=ka("div",{name:"MuiCollapse",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,t[n.orientation],n.state==="entered"&&t.entered,n.state==="exited"&&!n.in&&n.collapsedSize==="0px"&&t.hidden]}})(fp(({theme:e})=>({height:0,overflow:"hidden",transition:e.transitions.create("height"),variants:[{props:{orientation:"horizontal"},style:{height:"auto",width:0,transition:e.transitions.create("width")}},{props:{state:"entered"},style:{height:"auto",overflow:"visible"}},{props:{state:"entered",orientation:"horizontal"},style:{width:"auto"}},{props:({ownerState:t})=>t.state==="exited"&&!t.in&&t.collapsedSize==="0px",style:{visibility:"hidden"}}]}))),Qm=ka("div",{name:"MuiCollapse",slot:"Wrapper"})({display:"flex",width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),Zm=ka("div",{name:"MuiCollapse",slot:"WrapperInner"})({width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),So=S.forwardRef(function(t,n){const r=sp({props:t,name:"MuiCollapse"}),{addEndListener:i,children:s,className:o,collapsedSize:a="0px",component:d,easing:f,in:c,onEnter:l,onEntered:u,onEntering:p,onExit:g,onExited:v,onExiting:b,orientation:w="vertical",style:h,timeout:x=op.standard,TransitionComponent:y=ap,...k}=r,C={...r,orientation:w,collapsedSize:a},$=Ym(C),T=lp(),j=cp(),M=S.useRef(null),I=S.useRef(),N=typeof a=="number"?`${a}px`:a,A=w==="horizontal",L=A?"width":"height",B=S.useRef(null),q=dp(n,B),P=H=>ne=>{if(H){const Q=B.current;ne===void 0?H(Q):H(Q,ne)}},F=()=>M.current?M.current[A?"clientWidth":"clientHeight"]:0,E=P((H,ne)=>{M.current&&A&&(M.current.style.position="absolute"),H.style[L]=N,l&&l(H,ne)}),D=P((H,ne)=>{const Q=F();M.current&&A&&(M.current.style.position="");const{duration:ge,easing:Z}=Wl({style:h,timeout:x,easing:f},{mode:"enter"});if(x==="auto"){const Ae=T.transitions.getAutoHeightDuration(Q);H.style.transitionDuration=`${Ae}ms`,I.current=Ae}else H.style.transitionDuration=typeof ge=="string"?ge:`${ge}ms`;H.style[L]=`${Q}px`,H.style.transitionTimingFunction=Z,p&&p(H,ne)}),W=P((H,ne)=>{H.style[L]="auto",u&&u(H,ne)}),U=P(H=>{H.style[L]=`${F()}px`,g&&g(H)}),V=P(v),Y=P(H=>{const ne=F(),{duration:Q,easing:ge}=Wl({style:h,timeout:x,easing:f},{mode:"exit"});if(x==="auto"){const Z=T.transitions.getAutoHeightDuration(ne);H.style.transitionDuration=`${Z}ms`,I.current=Z}else H.style.transitionDuration=typeof Q=="string"?Q:`${Q}ms`;H.style[L]=N,H.style.transitionTimingFunction=ge,b&&b(H)}),re=H=>{x==="auto"&&j.start(I.current||0,H),i&&i(B.current,H)};return m.jsx(y,{in:c,onEnter:E,onEntered:W,onEntering:D,onExit:U,onExited:V,onExiting:Y,addEndListener:re,nodeRef:B,timeout:x==="auto"?null:x,...k,children:(H,{ownerState:ne,...Q})=>m.jsx(Xm,{as:d,className:up($.root,o,{entered:$.entered,exited:!c&&N==="0px"&&$.hidden}[H]),style:{[A?"minWidth":"minHeight"]:N,...h},ref:q,ownerState:{...C,state:H},...Q,children:m.jsx(Qm,{ownerState:{...C,state:H},className:$.wrapper,ref:M,children:m.jsx(Zm,{ownerState:{...C,state:H},className:$.wrapperInner,children:s})})})})});So&&(So.muiSupportAuto=!0);var _l={};const je=e=>e.kind==="text",le=e=>e.kind!=="text",Mr=e=>le(e)?e.label??e.name:e.name,vt=e=>e.declaration.kind==="query"?e.name:`${e.source} -> ${e.name}`,cr=e=>e.declaration.kind==="inherited"||e.declaration.kind==="query",fe=e=>je(e)?`text.${e.name}`:e.declaration.kind==="query"?`query.${e.name}`:`${e.source}.${e.name}`,ql=".malloy-big-value, .malloy-table",Jm=e=>e.querySelector(ql)!==null&&![...e.querySelectorAll(".malloy-chart")].some(t=>t.closest(ql)===null),is=(e,t)=>je(e)?cm:t&&Jm(t)?dm:rs,ii=e=>e.rowspan??Ea[je(e)?"text":"query"];function sn(e,t){if(e.row===void 0||e.col===void 0)return;const n=Math.min(e.colspan??1,t);return{row:e.row,col:Math.min(e.col,t-n+1),colspan:n,rowspan:ii(e)}}const si=(e,t)=>e.col<t.col+t.colspan&&t.col<e.col+e.colspan&&e.row<t.row+t.rowspan&&t.row<e.row+e.rowspan;function Kn(e){return e.map((t,n)=>({tile:t,index:n})).sort((t,n)=>(t.tile.row??1/0)-(n.tile.row??1/0)||(t.tile.col??1/0)-(n.tile.col??1/0)||t.index-n.index).map(({tile:t})=>t)}function Ht(e,t,n){const r=e.map(a=>({...a})),i=[],s=a=>{const d=sn(r[a],t);d&&(r[a].col=d.col,i.push(d))};n!==void 0&&s(n);const o=r.map((a,d)=>({tile:a,index:d})).filter(({index:a,tile:d})=>a!==n&&d.row!==void 0).sort((a,d)=>(a.tile.row??0)-(d.tile.row??0)||(a.tile.col??0)-(d.tile.col??0)||a.index-d.index);for(const{index:a}of o){const d=sn(r[a],t);if(d){for(;;){const f=i.filter(c=>si(d,c));if(f.length===0)break;d.row=Math.max(...f.map(c=>c.row+c.rowspan))}r[a].row=d.row,s(a)}}return r}function eg(e,t,n,r){const i=e.flatMap((d,f)=>{const c=f===t?void 0:sn(d,r);return c?[c]:[]}),s=Math.max(1,...i.map(d=>d.row+d.rowspan)),o={...e[t],...n,row:Math.min(n.row,s)},a=sn(o,r);if(a){for(;;){const d=i.filter(f=>f.row<a.row&&si(a,f));if(d.length===0)break;a.row=Math.max(...d.map(f=>f.row+f.rowspan))}o.row=a.row}return Ht(e.map((d,f)=>f===t?o:d),r,t)}const ss=(e,t)=>(e-pt*(t-1))/t,Cd=ns+pt;function Td(e,t,n,r,i){const s=Math.min(n,r),o=Math.round(e/(i+pt))+1;return{row:Math.max(1,Math.round(t/Cd)+1),col:Math.min(Math.max(o,1),r-s+1)}}function Dd(e,t,n,r){const i=e.map((s,o)=>{if(s.row!==void 0&&s.col!==void 0)return s;const a=t[o];if(!a)return s;const{break:d,...f}=s,c=s.colspan??Math.max(1,Math.round((a.width+pt)/(r+pt))),l=Td(a.left,a.top,c,n,r),u=(a.top+a.height+pt)/Cd,p=je(s)?Math.ceil(u-.02):Math.round(u);return{...f,...l,colspan:c,rowspan:s.rowspan??Math.max(is(s),p-l.row+1)}});return Ht(i,n)}function Hl(e,t,n){const r=e.flatMap((s,o)=>{const a=o===t?void 0:sn(s,n);return a?[a]:[]});if(r.length===0)return[...e];const i=Math.max(...r.map(s=>s.row+s.rowspan));return e.map((s,o)=>o===t?{...s,row:i,col:1}:s)}function Od(e,t){const n=e.map(s=>({...s})),r=[],i=n.map((s,o)=>({tile:s,index:o})).filter(({tile:s})=>s.row!==void 0&&s.col!==void 0).sort((s,o)=>(s.tile.row??0)-(o.tile.row??0)||(s.tile.col??0)-(o.tile.col??0)||s.index-o.index);for(const{index:s}of i){const o=sn(n[s],t);if(o){for(;o.row>1&&!r.some(a=>si({...o,row:o.row-1},a));)o.row-=1;n[s].row=o.row,n[s].col=o.col,r.push(o)}}return n}const tg=(e,t)=>Od(e,t).some((n,r)=>n.row!==e[r].row||n.col!==e[r].col);function ng(e){return Kn(e).map(t=>{const{row:n,col:r,...i}=t;return i})}const rg=(e,t,n)=>e.map((r,i)=>i===t?{...r,...n}:r);function Ul(e,t,n,r,i){const s=sn(e[t],i);if(!s)return[...e];const o={row:Math.max(1,s.row+n),col:Math.min(Math.max(1,s.col+r),i-s.colspan+1)};if(o.row===s.row&&o.col===s.col)return[...e];const a={...s,...o},d=e.flatMap((p,g)=>{const v=g===t?void 0:sn(p,i);return v&&si(a,v)&&!si(s,v)?[{i:g,other:v}]:[]}),f=d.length===1?d[0]:void 0;if(!f)return Ht(rg(e,t,o),i,t);const{i:c,other:l}=f,u=e.map(p=>({...p}));return n>0?(u[c].row=s.row,u[t].row=s.row+l.rowspan):n<0?(u[t].row=l.row,u[c].row=l.row+s.rowspan):r>0?(u[c].col=s.col,u[t].col=s.col+l.colspan):(u[t].col=l.col,u[c].col=l.col+s.colspan),Ht(u,i,t)}const Ad=(e,t)=>e?.col===void 0?t:Math.max(1,t-e.col+1);function ig(e){return je(e)||e.rowspan===void 0?e:Ds(e.chart)&&e.chart!=="big_value"&&e.rowspan<rs?{...e,rowspan:rs}:e}const Pd=mt(m.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),Rd=mt(m.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"})),sg=mt(m.jsx("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"}));function Id(e){const{theme:t}=qe(),n=t.ui,[r,i]=S.useState(null),{status:s,draftKeptAt:o,discard:a,restored:d,dismissRestored:f}=e,c=d!==void 0&&!d.pending&&s==="unsaved"?d:void 0,l=s==="saved"?"Saved":s==="saving"?"Saving…":o!==void 0?"Draft saved":"Unsaved changes",u=c?`Restored your unsaved edits from ${$o(c.savedAt)}`:void 0,p=s==="unsaved"&&o!==void 0?"Your edits are kept in this browser. Done saves them to the report.":e.saveTarget,g=a!==void 0&&s==="unsaved",v=()=>{i(null),c&&f?.()},b=x=>({display:"inline-flex",alignItems:"center",justifyContent:"flex-end",gap:.75,minWidth:132,height:n.size.control,px:1,borderRadius:n.radius.control,font:"inherit",...n.type.control,whiteSpace:"nowrap",color:s==="saved"?x.palette.text.secondary:x.palette.text.primary,transition:`color ${nt}, background-color ${nt}`,...g?{"&:hover":{bgcolor:x.palette.action.hover}}:{}}),w=m.jsxs(m.Fragment,{children:[m.jsx(_,{component:"span","aria-hidden":!0,sx:{width:16,height:16,flex:"none",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:s==="saved"?m.jsx(Ts,{sx:{fontSize:16}}):m.jsx(_,{component:"span","data-restored":c?"true":void 0,sx:x=>({width:7,height:7,borderRadius:"50%",bgcolor:c?t.accent:s==="saving"||o!==void 0?x.palette.text.disabled:x.palette.warning.main,transition:`background-color ${nt}`})})}),m.jsx(_,{component:"span","aria-hidden":!0,children:l}),m.jsx(Sa,{"aria-hidden":!0,sx:{fontSize:16,ml:-.25,visibility:g?"visible":"hidden"}})]}),h=m.jsx(_,{component:"span",role:"status","aria-live":"polite",sx:og,children:u?`${l}. ${u}.`:l});return m.jsxs(m.Fragment,{children:[h,m.jsx(Dt,{title:u??p,describeChild:!0,children:g?m.jsx(hd,{className:rt.saveStatus,"aria-label":l,...u?{"aria-description":u}:{},"aria-haspopup":"menu","aria-expanded":r!==null,onClick:x=>i(x.currentTarget),sx:b,children:w}):m.jsx(_,{component:"span",className:rt.saveStatus,sx:b,children:w})}),m.jsxs(Xn,{className:rt.menu,anchorEl:r,open:r!==null,onClose:v,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:-4,horizontal:"left"},slotProps:{paper:{sx:{minWidth:240,borderRadius:n.radius.menu,border:`1px solid ${cn(t.cardBorder)}`,boxShadow:n.shadow.menu}}},MenuListProps:{dense:!0,sx:{py:.5}},children:[(u!==void 0||o!==void 0)&&m.jsx(_,{component:"li",role:"presentation",sx:{px:1.75,pt:.75,pb:1,...n.type.caption,color:"text.secondary"},children:u??`Kept in this browser at ${$o(o)}`}),m.jsxs(Xe,{onClick:()=>{i(null),a?.()},sx:{mx:.5,borderRadius:n.radius.control,gap:1.25,color:"error.main","&.Mui-focusVisible":{outline:"none",bgcolor:"action.hover"}},children:[m.jsx(sg,{fontSize:"small"}),"Discard edits"]})]})]})}function $o(e){const t=new Date(e);return new Date().toDateString()===t.toDateString()?t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}const og={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},jo=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),Sn=jo?"⌘":"Ctrl+",Vl=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},Ks=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function ag(e){const t=S.useRef(e);S.useEffect(()=>{t.current=e});const[n,r]=S.useState(!1);S.useEffect(()=>{n&&(r(!1),t.current.save?.())},[n]),S.useEffect(()=>{const i=s=>{const o=t.current;if(o.paused)return;const a=jo?s.metaKey:s.ctrlKey,d=s.key.toLowerCase();if(s.key==="Escape"){if(Vl(s.target)||Ks(s.target))return;o.escape();return}if(Vl(s.target)){if(a&&d==="s"){if(s.preventDefault(),!o.save||Ks(s.target))return;s.target.blur(),r(!0)}return}if(Ks(s.target)){a&&d==="s"&&s.preventDefault();return}if(a&&d==="z"){s.preventDefault(),s.shiftKey?o.redo():o.undo();return}if(!jo&&a&&d==="y"){s.preventDefault(),o.redo();return}if(a&&d==="s"){s.preventDefault(),o.save?.();return}if(o.move&&s.altKey&&!a&&!s.shiftKey){const f=s.key==="ArrowLeft"?[0,-1]:s.key==="ArrowRight"?[0,1]:s.key==="ArrowUp"?[-1,0]:s.key==="ArrowDown"?[1,0]:void 0;if(f&&o.move(f[0],f[1])){s.preventDefault();return}}o.nudge&&!a&&!s.altKey&&!s.shiftKey&&(s.key==="ArrowLeft"||s.key==="ArrowRight")&&(s.preventDefault(),o.nudge(s.key==="ArrowRight"?1:-1))};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[])}const Yr=(e,t,n=Ma)=>({height:n.size.control,minHeight:n.size.control,px:1.5,borderRadius:n.radius.control,boxShadow:"none",...n.type.control,"&:hover":{boxShadow:"none"},"& .MuiButton-startIcon":{mr:.5,"& svg":{fontSize:18}},"&.MuiButton-outlined":{borderColor:e,"&:hover":{borderColor:t}}}),oi=(e=Ma)=>({width:e.size.control,height:e.size.control,borderRadius:e.radius.control,"& svg":{fontSize:18}}),os={height:20,alignSelf:"center",mx:.5,my:0},as=(e,t=Ma)=>({height:t.size.control,boxSizing:"border-box",borderRadius:t.radius.control,border:`1px solid ${e}`,overflow:"hidden",bgcolor:"background.paper","& .MuiToggleButton-root":{border:"none",borderRadius:"0 !important",m:"0 !important",px:1.5,py:0,height:"100%",...t.type.control,color:"text.secondary","& + .MuiToggleButton-root":{borderLeft:`1px solid ${e}`},"&:hover":{bgcolor:"action.hover"},"&.Mui-selected, &.Mui-selected:hover":{bgcolor:"action.selected",color:"text.primary"}}}),Mo={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function lg({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:i,saving:s,onSave:o,savesTo:a="package",saveLabel:d,saveButton:f,actions:c,onAddTile:l,arrange:u,onExit:p,saveStatus:g}){const{theme:v}=qe(),b=cn(v.cardBorder),w=Cs(v.cardBorder,v.tileTitle);return m.jsxs(ft,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[u,l&&m.jsx(Oe,{variant:"outlined",startIcon:m.jsx(vi,{}),onClick:l,"aria-label":"Add tile",sx:Yr(b,w,v.ui),children:"Tile"}),l&&m.jsx(nr,{orientation:"vertical",sx:os}),m.jsx(Dt,{title:`Undo (${Sn}Z)`,children:m.jsx("span",{children:m.jsx($n,{"aria-label":"Undo",disabled:!e,onClick:n,sx:oi(v.ui),children:m.jsx(Rd,{fontSize:"small"})})})}),m.jsx(Dt,{title:`Redo (${Sn}⇧Z)`,children:m.jsx("span",{children:m.jsx($n,{"aria-label":"Redo",disabled:!t,onClick:r,sx:oi(v.ui),children:m.jsx(Pd,{fontSize:"small"})})})}),(c||o||p)&&m.jsx(nr,{orientation:"vertical",sx:os}),c,o&&g&&m.jsx(Id,{...g}),o?m.jsx(Dt,{title:i?`Save (${Sn}S) · ${d??Mo[a]}`:d??Mo[a],children:m.jsx("span",{children:m.jsx(Oe,{ref:f,variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{...Yr(b,w,v.ui),minWidth:88},children:s?"Saving…":i?"Save":"Saved"})})}):null,o&&m.jsx(_,{component:"span","aria-live":"polite",sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},children:s?"Saving":i?"Unsaved changes":"All changes saved"}),p&&m.jsx(jm,{label:"Close",icon:m.jsx(Ts,{}),onClick:p})]})}const cg=e=>`This view has no field for the x-axis: ${e.toLowerCase()} needs a group by, such as a date or a category`,Kl={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map",combo_chart:"Bar and line"};function Nd(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this tile's details":n==="unlisted"?"Not in the model's list, so its shape is unknown":void 0,i=e?.shape,s=o=>{if(t===o)return;if(o==="big_value")return e?.aggregateOnly===!0?void 0:i&&i.groupBys>0?"This view has a group by, so it is more than one row; big numbers need a view of totals only":r??"Needs results that are only totals (no group by)";if(o==="shape_map"||o==="segment_map")return e?.chart===o?void 0:r??"Needs a map chart set in the model";if(e?.chart===o)return;if(!i)return o==="combo_chart"?r??"Needs a view with a group by and exactly two totals: the first is drawn as bars, the second as a line":void 0;const a=`A ${Kl[o].toLowerCase()} chart`;switch(Um(o,i)){case"no_x_axis":return cg(a);case"combo_totals":return`A bar and line chart needs exactly two totals, the first drawn as bars and the second as a line; this view has ${i.totals}`;case"no_y_axis":return`This view has no total for the y-axis: ${a.toLowerCase()} needs at least one aggregate`;default:return}};return[{value:"default",label:"Default",hint:"As set in the model"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map","combo_chart"].map(o=>{const a=s(o);return{value:o,label:Kl[o],...a?{disabled:!0,reason:a}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Gl(e){return e.description??qm(e.name)}const dg={bar_chart:"a bar chart",line_chart:"a line chart",scatter_chart:"a scatter chart",combo_chart:"a bar and line chart",shape_map:"a shape map",segment_map:"a segment map",big_value:"a big value",sparkline:"a sparkline"},Ci=(e,t)=>`${e}\0${t}`;function ug({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s,onAddText:o,renderPreview:a}){const{theme:d}=qe(),f=d.ui,c=cn(d.cardBorder),l=S.useMemo(()=>n?.sources??[],[n]),[u,p]=S.useState(""),[g,v]=S.useState(),[b,w]=S.useState(""),[h,x]=S.useState("default"),y=S.useRef(null),k=S.useMemo(()=>{const P=new Set(t.sources.map(F=>F.base));return[...l].sort((F,E)=>Number(P.has(E.name))-Number(P.has(F.name)))},[l,t]),C=k.filter(P=>P.views.length>0),$=k.filter(P=>P.views.length===0),T=S.useMemo(()=>new Map(C.flatMap(P=>P.views.map(F=>[Ci(P.name,F.name),{source:P,view:F,key:Ci(P.name,F.name)}]))),[C]),j=S.useMemo(()=>C.map(P=>({key:P.name,label:P.name,...P.description?{detail:P.description}:{},entries:P.views.map(F=>({key:Ci(P.name,F.name),name:F.name,title:Gl(F),...F.chart?{chart:F.chart}:{}}))})),[C]),M=g===void 0?void 0:T.get(g);S.useEffect(()=>{if(!e)return;p(""),w(""),x("default");const P=C[0]?.views[0];v(P&&C[0]?Ci(C[0].name,P.name):void 0)},[e]);const I=M?[M.source.name,M.view.name].filter(P=>!wo(P)).map(P=>`"${P}" is not a plain Malloy name, so a tile cannot be written for it.`)[0]:void 0,N=M!==void 0&&I===void 0,A=M?Gl(M.view):"",L=h!=="default"&&M?{chart:h,chartCarried:M.view.chart?[M.view.chart]:[]}:{},B=(P=M)=>{if(!P||![P.source.name,P.view.name].every(wo))return;const F=P.key===M?.key,E=Vm(Math.ceil(r/2),r);s({base:P.source.name,modelPath:P.source.modelPath,...P.source.exporters?{exporters:P.source.exporters}:{},view:P.view.name,...F&&b.trim()?{label:b.trim()}:{},...F?L:{},...E!==void 0?{colspan:E}:{}})},q=M?Nd(M.view,h).filter(P=>P.value!=="custom"&&P.disabled!==!0):[];return m.jsx(Ta,{className:`${rt.dialog} ${rt.addTileDialog}`,open:e,onClose:i,maxWidth:"md",initialFocus:y,title:"Add a tile",description:"Pick what the tile shows from the model. You can change its title and chart now or later.",actions:m.jsxs(m.Fragment,{children:[m.jsx(Oe,{onClick:o,sx:{mr:"auto"},children:"Add text instead"}),m.jsx(Oe,{onClick:i,children:"Cancel"}),m.jsx(Oe,{variant:"contained",disabled:!N,onClick:()=>B(),children:"Add tile"})]}),children:m.jsxs(_,{sx:{mx:-3,mb:-1,borderTop:`1px solid ${c}`,borderBottom:`1px solid ${c}`,display:"grid",gridTemplateColumns:{xs:"1fr",md:"320px minmax(0, 1fr)"},height:{md:460}},children:[m.jsx(_,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${c}`},maxHeight:{xs:280,md:"none"}},children:m.jsx(wm,{groups:j,query:u,onQuery:p,picked:M?.key,onPick:P=>{v(P),x("default")},onTake:P=>B(T.get(P)),searchRef:y,empty:m.jsx(ve,{variant:"body2",sx:{color:d.tileTitle,p:2},children:n?"This package's models have nothing to put on a tile yet.":"The package's sources are still loading."}),footer:$.length>0&&m.jsxs(ve,{variant:"caption",component:"p",sx:{color:"text.secondary",px:2,pt:1.5},children:["Also in this package, with no views to show:"," ",$.map(P=>P.name).join(", "),"."]})})}),m.jsx(_,{sx:P=>({p:2.5,display:"flex",flexDirection:"column",gap:2,minHeight:0,overflowY:"auto",bgcolor:`color-mix(in srgb, ${P.palette.text.primary} 3%, ${P.palette.background.paper})`}),children:M?m.jsxs(m.Fragment,{children:[m.jsx(_,{"aria-label":"Preview",role:"region",sx:P=>({height:240,flex:"none",display:"flex",position:"relative",overflow:"hidden",borderRadius:f.radius.tile,border:`1px solid ${c}`,bgcolor:P.palette.background.paper,"&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,height:40,pointerEvents:"none",background:`linear-gradient(to bottom, transparent, ${P.palette.background.paper})`}}),children:a?m.jsx(_,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:a({base:M.source.name,modelPath:M.source.modelPath,view:M.view.name,label:b.trim()||A,...h!=="default"?L:{},givens:M.source.givens})}):m.jsxs(_,{sx:P=>({flex:1,border:`1px solid ${c}`,borderRadius:f.radius.tile,bgcolor:P.palette.background.paper,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,color:"text.secondary"}),children:[m.jsx(km,{chart:M.view.chart}),m.jsxs(ve,{variant:"body2",children:[M.source.name," → ",M.view.name]})]})}),m.jsx(Zt,{size:"small",label:"Title",placeholder:A,value:b,onChange:P=>w(P.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Tile title"}}),m.jsxs(_,{children:[m.jsx(ve,{component:"div",sx:{...f.type.label,color:"text.secondary",mb:.75},children:"Chart"}),m.jsx(Ed,{size:"small",exclusive:!0,value:h,"aria-label":"Chart",onChange:(P,F)=>{F!==null&&x(F)},sx:{...as(c,f),"& .MuiToggleButton-root":{...as(c,f)["& .MuiToggleButton-root"],textTransform:"none"}},children:q.map(P=>m.jsx(ko,{value:P.value,children:P.label},P.value))}),m.jsx(ve,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:M.view.chart?`The model sets ${dg[M.view.chart]??"a chart"}.`:"The model sets no chart, so it shows as a table."})]}),I&&m.jsx(ve,{variant:"body2",color:"error",children:I})]}):m.jsx(ve,{variant:"body2",sx:{color:"text.secondary",m:"auto"},children:"Pick a view to see it here."})})]})})}function hg(e,t,{modelPath:n,textHeld:r,widths:i,insertAt:s}){t.modelPath&&!r&&(e.imports=Fm(e,t.base,t.modelPath,n,t.exporters??[t.modelPath]));const o=Wd(e,t.base),a=Eo(e,o.name,t.view);e.tiles.splice(s??e.tiles.length,0,{name:a,source:o.name,declaration:{kind:"reference",from:t.view},...i&&t.colspan!==void 0?{colspan:t.colspan}:{},...t.label?{label:t.label}:{},...t.chart?{chart:t.chart}:{},...t.chartCarried?{chartCarried:t.chartCarried}:{}})}function Wd(e,t,{unscoped:n=!1}={}){const r=e.sources.find(a=>a.base===t&&(!n||!a.scopedBy?.length));if(r)return r;const i=new Set(e.sources.map(a=>a.name));let s=`${t}_tiles`;for(let a=2;i.has(s);a++)s=`${t}_tiles_${a}`;const o={name:s,base:t};return e.sources.push(o),o}function Eo(e,t,n){const r=new Set(e.tiles.filter(le).filter(s=>s.source===t).map(s=>s.name));let i=`${n}_tile`;for(let s=2;r.has(i);s++)i=`${n}_tile_${s}`;return i}function ls(e){switch(e.declaration.kind){case"inline":return"Its query is written in this file, and the builder does not copy a query's body.";case"opaque":return`Its query is ${e.declaration.why}, which the builder does not copy.`;case"query":return"It names a query, and a copy could not be told apart from it: the builder writes nothing about such a tile but its place.";default:return e.chart==="custom"?"Its chart line is one the builder does not write, so a copy would lose it.":void 0}}function fg(e,t){const n=e.tiles[t];if(!n||!le(n)||ls(n)!==void 0)return;let r;if(n.declaration.kind==="reference"){const{break:s,...o}=structuredClone(n);r={...o,name:Eo(e,n.source,n.declaration.from)}}else{const s=e.sources.find(o=>o.name===n.source)??Wd(e,n.source,{unscoped:!0});r={name:Eo(e,s.name,n.name),source:s.name,declaration:{kind:"reference",from:n.name},...n.colspan!==void 0?{colspan:n.colspan}:{}}}const i=n.row!==void 0&&n.col!==void 0;return i&&(r={...r,row:(n.row??1)+ii(n),col:n.col,...n.rowspan!==void 0?{rowspan:n.rowspan}:{}}),e.tiles.splice(t+1,0,r),i&&(e.tiles=Ht(e.tiles,e.columns??um,t+1)),t+1}const Ti="self";function pg({open:e,document:t,source:n,givenNames:r,dashboards:i,tileLabel:s,onClose:o,onApply:a}){const{theme:d}=qe(),f=d.ui,[c,l]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(x=>x.source===n.name);l((n.dimensions??[]).map(x=>{const y=h.find(k=>k.name===x.name);return{name:x.name,expression:x.expression,to:y?.to??[],given:y?.given??""}}))},[e,n,t]);const u=(h,x)=>l(y=>y.map((k,C)=>{if(C!==h)return k;const $={...k};return x($),$})),p=[Ti,...i.filter(h=>h!==Ti)],g=h=>h===Ti?"This report":h,v=()=>{n&&(a(c.filter(h=>h.to.length>0).map(h=>({source:n.name,name:h.name,expression:h.expression,to:h.to,...h.given?{given:h.given}:{}}))),o())},b=cn(d.cardBorder),w=(h,x)=>u(h,y=>{x?y.to=y.lastTo?.length?y.lastTo:[Ti]:(y.lastTo=y.to,y.to=[])});return m.jsx(Ta,{className:`${rt.dialog} ${rt.clickableCellsDialog}`,open:e,onClose:o,title:"Clickable cells",description:m.jsxs(m.Fragment,{children:[s&&m.jsxs(_,{component:"span",sx:{fontWeight:f.type.label.fontWeight},children:[s," ·"," "]}),"A click on a table cell sets a filter to its value, on this report or on the one it opens. Bars, lines and points on a chart do not respond to a click. Clicks work in the report, not while you edit it."]}),actions:m.jsxs(m.Fragment,{children:[m.jsx(Oe,{onClick:o,children:"Cancel"}),m.jsx(Oe,{variant:"contained",onClick:v,disabled:c.length===0,children:"Apply"})]}),children:c.length===0?m.jsx(ve,{variant:"body2",sx:{color:d.tileTitle,pt:1},children:n?m.jsxs(m.Fragment,{children:[m.jsx(_,{component:"code",children:n.name})," declares no dimensions of its own in this file. A click is a tag on the dimension's declaration, so a dimension the model declares is made clickable in the model; to make one clickable here, declare it in"," ",m.jsx(_,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):m.jsx(_,{role:"list","aria-label":"Dimensions",children:c.map((h,x)=>{const y=h.to.length>0;return m.jsxs(_,{role:"listitem",sx:{display:"grid",gridTemplateColumns:{xs:"auto minmax(0, 1fr)",sm:"auto minmax(0, 0.9fr) minmax(0, 1.6fr)"},alignItems:"center",columnGap:1.5,rowGap:1,py:1.25,borderTop:x===0?"none":`1px solid ${b}`},children:[m.jsx(ym,{size:"small",checked:y,onChange:k=>w(x,k.target.checked),slotProps:{input:{"aria-label":`${h.name} is clickable`}}}),m.jsxs(_,{sx:{minWidth:0},children:[m.jsx(_,{sx:{...f.type.control,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:mg(h.name)}),m.jsxs(_,{title:h.expression,sx:{...f.type.code,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[h.name," is ",h.expression]})]}),y?m.jsxs(ft,{direction:"row",sx:{gridColumn:{xs:"1 / -1",sm:"auto"},alignItems:"center",gap:1,justifyContent:"flex-end",...f.type.control},children:[m.jsx(_,{component:"span",sx:{color:"text.secondary"},children:"Opens"}),m.jsx(Zt,{select:!0,size:"small",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:k=>k.map(g).join(", ")},onChange:k=>u(x,C=>{const $=k.target.value,T=Array.isArray($)?$:String($).split(",").filter(Boolean);T.length===0&&(C.lastTo=C.to),C.to=T}),sx:{flex:"1 1 150px",minWidth:0,maxWidth:200},children:p.map(k=>m.jsxs(Xe,{value:k,children:[m.jsx(yo,{size:"small",checked:h.to.includes(k),sx:{p:0,mr:1}}),m.jsx(Bt,{primary:g(k)})]},k))}),m.jsx(_,{component:"span",sx:{color:"text.secondary"},children:"sets"}),m.jsxs(Zt,{select:!0,size:"small",value:h.given,inputProps:{"aria-label":`Control ${h.name} sets`},SelectProps:{displayEmpty:!0,renderValue:k=>k===""?h.name:String(k)},onChange:k=>u(x,C=>{C.given=k.target.value}),sx:{flex:"1 1 120px",minWidth:0,maxWidth:170},children:[m.jsx(Xe,{value:"",children:m.jsx(Bt,{primary:h.name,secondary:"Named like the dimension"})}),r.map(k=>m.jsx(Xe,{value:k,children:k},k))]})]}):m.jsx(ve,{variant:"body2",sx:{color:"text.secondary",textAlign:"right",display:{xs:"none",sm:"block"}},children:"Not clickable"})]},h.name)})})})}function mg(e){const t=e.replace(/_+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const gg=mt(m.jsx("path",{d:"M12 4c4.41 0 8 3.59 8 8s-3.59 8-8 8-8-3.59-8-8 3.59-8 8-8m0-2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 13-4-4h8z"})),vg=mt(m.jsx("path",{d:"M11 7H2v2h9zm0 8H2v2h9zm5.34-4L12.8 7.46l1.41-1.41 2.12 2.12 4.24-4.24L22 5.34zm0 8-3.54-3.54 1.41-1.41 2.12 2.12 4.24-4.24L22 13.34z"})),xg=mt(m.jsx("path",{d:"M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 16H5V10h14zm0-12H5V6h14zm-7 5h5v5h-5z"})),bg=mt(m.jsx("path",{d:"M19.5 9.5c-1.03 0-1.9.62-2.29 1.5h-2.92c-.39-.88-1.26-1.5-2.29-1.5s-1.9.62-2.29 1.5H6.79c-.39-.88-1.26-1.5-2.29-1.5C3.12 9.5 2 10.62 2 12s1.12 2.5 2.5 2.5c1.03 0 1.9-.62 2.29-1.5h2.92c.39.88 1.26 1.5 2.29 1.5s1.9-.62 2.29-1.5h2.92c.39.88 1.26 1.5 2.29 1.5 1.38 0 2.5-1.12 2.5-2.5s-1.12-2.5-2.5-2.5"})),yg=mt(m.jsx("path",{d:"M4 9h16v2H4zm0 4h10v2H4z"})),wg=mt(m.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33v-4h3.33zM19 17h-3.33v-4H19zm0-6h-8.67V7H19z"}));function kg(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of le(s)?s.filters??[]:[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],i=new Set;for(const s of e.localGivens??[])i.add(s.name),r.push({name:s.name,...s.label===void 0?{}:{label:s.label},type:s.type,...s.suggest?{field:s.suggest.dimension}:{},origin:"dashboard",local:s,boundTiles:n.get(s.name)??0});for(const s of t)i.has(s.name)||(i.add(s.name),r.push({...s,origin:"model",boundTiles:n.get(s.name)??0}));for(const[s,o]of n)i.has(s)||r.push({name:s,origin:"model",boundTiles:o});return r}function cs(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function Sg(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function Xr(e,t){const n=Sg(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const i=new Set(["date","timestamp"]);return i.has(n)?i.has(r):n===r}function Co(e){switch(e?.replace(/_type$/,"")){case"string":return"text";case"number":return"a number";case"date":return"a date";case"timestamp":return"a timestamp";case"boolean":return"true or false";default:return e??"an unknown type"}}function $g(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const jg=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function Mg(e,t){const n=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",r=/^[A-Z_]/.test(n)?n:`F_${n}`,i=Md(r)?r:`${r}_FILTER`,s=new Set(t);if(!s.has(i))return i;for(let o=2;;o++)if(!s.has(`${i}_${o}`))return`${i}_${o}`}const Eg=[{kind:"select",label:"Pick one",hint:"A dropdown of the field's values"},{kind:"multiselect",label:"Pick several",hint:"The same, taking more than one"},{kind:"text",label:"Text",hint:"A box taking Malloy filter syntax"},{kind:"number",label:"Number range",hint:"A slider over the field's values"},{kind:"date",label:"On or after a date",hint:"A date picker; tiles keep rows on or after it"}];function Dr(e){const t=e.label.trim()||e.name,n=e.field;switch(e.kind){case"select":case"multiselect":return{name:e.name,type:"filter<string>",default:"f''",label:t,control:e.kind,...e.source?{suggest:{source:e.source,dimension:n}}:{}};case"text":return{name:e.name,type:"filter<string>",default:"f''",label:t};case"number":return{name:e.name,type:"filter<number>",default:"f''",label:t,...e.range?{rangeMin:e.range.min,rangeMax:e.range.max}:{}};case"date":return{name:e.name,type:"date",default:`@${e.dateDefault??new Date().toISOString().slice(0,10)}`,label:t}}}const To=e=>le(e)&&!cr(e)&&e.declaration.kind!=="opaque";function Cg(e,t){return e.tiles.map(n=>{const r=(le(n)?n.filters??[]:[]).find(i=>i.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:cs(t.type)!==void 0?{op:cs(t.type)}:{}}})}function Tg(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!To(s))return;const o=(s.filters??[]).filter(d=>d.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?s.filters=a:delete s.filters})}function Dg(e,t){const n=(e.localGivens??[]).filter(s=>s.name!==t.name),r=(e.localGivens??[]).findIndex(s=>s.name===t.name),i=[...n];i.splice(r>=0?r:i.length,0,t),e.localGivens=i}function Og(e,t){for(const r of e.tiles){if(!le(r))continue;const i=(r.filters??[]).filter(s=>s.given!==t);i.length>0?r.filters=i:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const Do=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function Ag({open:e,document:t,control:n,available:r,takenNames:i=[],fieldsFor:s,onApply:o}){const a=S.useRef(n);e&&(a.current=n);const d=e?n:a.current,f=d!==void 0,[c,l]=S.useState({kind:"new"}),[u,p]=S.useState(""),[g,v]=S.useState("select"),[b,w]=S.useState(""),[h,x]=S.useState(""),[y,k]=S.useState([]),[C,$]=S.useState(!1),[T,j]=S.useState(!1),M=O=>t.sources.find(z=>z.name===O.source)?.base??O.source;S.useEffect(()=>{if(e)if(j(n!==void 0),n){l({kind:"existing",name:n.name}),p(n.label??"");const O=Cg(t,n);k(O);const z=O.filter(G=>G.include),K=new Set(z.map(G=>G.field));x(K.size===1?z[0].field:n.field??""),$(K.size>1)}else l({kind:"new"}),p(""),v("select"),x(""),w(new Date().toISOString().slice(0,10)),k(t.tiles.map(O=>({include:To(O),field:""}))),$(!1)},[e,n,t]);const I=S.useMemo(()=>[...(t.localGivens??[]).map(O=>O.name),...r.map(O=>O.name),...i],[t,r,i]),N=S.useMemo(()=>h.trim()?Mg(h.trim(),I):"",[h,I]),A=c.kind==="existing"?n??r.find(O=>O.name===c.name):N?{name:N,type:Dr({name:N,label:u,kind:g,field:h}).type}:void 0,L=A?.type!==void 0&&!A.type.startsWith("filter<"),B=y.find(O=>O.include)?.op??cs(A?.type),q=(O,z)=>{j(!0),k(K=>K.map((G,ke)=>ke===O?{...G,...z}:G))},P=O=>{j(!0),k(z=>z.map(K=>({...K,op:O})))},F=O=>{const z=cs(O);k(K=>K.map(({op:G,...ke})=>z?{...ke,op:z}:ke))},E=O=>{j(!0),l({kind:"existing",name:O.name}),x(O.field??""),F(O.type)},D=O=>{j(!0),v(O),F(Dr({name:"X",label:u,kind:O,field:h}).type)},W=t.tiles.map(To),U=W.filter(Boolean).length,V=y.filter((O,z)=>O.include&&W[z]).length,Y=t.tiles.filter((O,z)=>(y[z]?.include??!1)&&W[z]&&le(O)),re=Y.length>0?Y:t.tiles.filter((O,z)=>W[z]&&le(O)),H=S.useMemo(()=>{const O=new Map;let z=!1;for(const K of re){const G=s?.(K);if(G){z=!0;for(const ke of G)O.has(ke.name)||O.set(ke.name,ke)}}return z?[...O.values()]:void 0},[y,t.tiles,s]),ne=(()=>{const O=h.trim();for(const z of Y){const K=s?.(z);if(!K||K.some(G=>G.name===O))return M(z)}return Y[0]?M(Y[0]):t.sources[0]?.base})(),Q=O=>{j(!0),k(z=>z.map((K,G)=>({...K,include:O&&W[G]})))},ge=S.useMemo(()=>C?y:y.map(O=>({...O,field:h})),[C,y,h]),Z=O=>{for(const z of re){const K=s?.(z)?.find(G=>G.name===O.trim());if(K?.type)return K.type}},Ae=O=>Xr(A?.type,O.type),Pe=(O,z)=>{if(O.trim()==="")return"Pick the field this filter compares.";const K=z?s?.(z):void 0;if(!K)return;const G=K.find(ke=>ke.name===O.trim());if(!G)return`Not a field of ${z?M(z):"the tiles' source"}.`;if(G.type&&!Xr(A?.type,G.type))return`${O.trim()} is ${Co(G.type)}; this filter compares ${Co(A?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},X=O=>{if(j(!0),x(O),f||c.kind!=="new")return;const z=Z(O),K=Dr({name:"X",label:u,kind:g,field:O}).type;z&&!Xr(K,z)&&D($g(z))},we=O=>{const z=t.tiles[O];return z&&le(z)?z:void 0},ye=ge.map((O,z)=>O.include&&W[z]?Pe(O.field,we(z)):void 0),se=ye.every(O=>O===void 0),Re=T?ye:ye.map(()=>{}),Ke=T&&!C&&V>0?Y.map(O=>Pe(h,O)).find(Boolean):void 0,Ie=A!==void 0&&se&&(c.kind==="existing"||h.trim()!==""&&N!==""),Qe=()=>{if(!(!A||!Ie))if(c.kind==="new")o(A.name,ge,Dr({name:A.name,label:u.trim()||Do(A.name),kind:g,field:h.trim(),...ne?{source:ne}:{},...b?{dateDefault:b}:{}}));else if(n?.origin==="dashboard"&&n.local){const O=u.trim(),z=O!==(n.local.label??"");o(A.name,ge,z?{...n.local,...O?{label:O}:{}}:void 0)}else o(A.name,ge)},Ze=f&&d.origin==="model";return{editing:f,shown:d,fromModel:Ze,source:c,setSource:l,label:u,setLabel:p,kind:g,dateDefault:b,setDateDefault:w,field:h,rows:y,setRows:k,perTile:C,setPerTile:$,newName:N,target:A,valueTyped:L,commonOp:B,setRow:q,setCommonOp:P,pickExisting:E,pickKind:D,bindable:W,bindableCount:U,included:V,commonFields:H,setAll:Q,accepts:Ae,pickField:X,rowProblems:Re,commonProblem:Ke,canApply:Ie,apply:Qe}}function Yl({value:e,onChange:t,fields:n,accepts:r,label:i,ariaLabel:s,error:o,helperText:a,disabled:d,autoFocus:f,placeholder:c,inputRef:l,sx:u}){const p=S.useMemo(()=>(n??[]).filter(v=>r?.(v)??!0).map(v=>v.name),[n,r]),g=S.useMemo(()=>new Map((n??[]).map(v=>[v.name,v.type])),[n]);return m.jsx(_m,{freeSolo:!0,size:"small",options:p,inputValue:e,onInputChange:(v,b)=>t(b),value:e,onChange:(v,b)=>t(typeof b=="string"?b:""),disabled:d,disableClearable:!0,renderOption:(v,b)=>S.createElement("li",{...v,key:b},m.jsx(Ql,{type:g.get(b)}),m.jsx(ve,{variant:"body2",sx:{flex:1,ml:1},children:b})),renderInput:v=>m.jsx(Zt,{...v,label:i,placeholder:c,autoFocus:f,...l?{inputRef:l}:{},error:o,helperText:a,InputLabelProps:{...v.InputLabelProps,shrink:!0},InputProps:{...v.InputProps,startAdornment:g.get(e.trim())?m.jsx(_,{sx:{display:"flex",ml:.5,mr:-.25},children:m.jsx(Ql,{type:g.get(e.trim())})}):void 0},inputProps:{...v.inputProps,"aria-label":s}}),sx:u})}const Pg=e=>e&&le(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:e&&le(e)&&e.declaration.kind==="query"?{label:"Not bindable",reason:"It names a query, whose filters live in that query's own definition."}:{label:"From the model",reason:"Declared on its source, which this report does not write."};function Rg({open:e,document:t,control:n,available:r,takenNames:i,fieldsFor:s,onClose:o,onApply:a,onRemove:d}){const{theme:f}=qe(),c=f.ui,{editing:l,shown:u,fromModel:p,source:g,setSource:v,label:b,setLabel:w,kind:h,dateDefault:x,setDateDefault:y,field:k,rows:C,setRows:$,perTile:T,setPerTile:j,newName:M,target:I,valueTyped:N,commonOp:A,setRow:L,setCommonOp:B,pickExisting:q,pickKind:P,bindable:F,bindableCount:E,included:D,commonFields:W,setAll:U,accepts:V,pickField:Y,rowProblems:re,commonProblem:H,canApply:ne,apply:Q}=Ag({open:e,document:t,control:n,available:r,...i?{takenNames:i}:{},fieldsFor:s,onApply:a}),ge=S.useRef(null),Z=cn(f.cardBorder),Ae=Cs(f.cardBorder,f.tileTitle),[Pe,X]=S.useState(!1),[we,ye]=S.useState(!1);S.useEffect(()=>{e?ye(!0):X(!1)},[e]),S.useEffect(()=>{we&&(ye(!1),X(l&&D<E))},[we]),S.useEffect(()=>{T&&X(!0)},[T]);const se=W?.find(O=>O.name===k.trim())?.type,Re=O=>{if(!se)return;const z=Dr({name:"X",label:b,kind:O,field:k}).type;return Xr(z,se)?void 0:`${k.trim()} is ${Co(se)}, which this control cannot filter.`},Ke=b.trim()||(M?Do(M):"Filter"),Ie=h==="number"?"Any":h==="date"?x?new Date(`${x}T00:00:00`).toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"}):"Any":"All",Qe={...as(Z,c),alignSelf:"flex-start","& .MuiToggleButton-root":{...as(Z,c)["& .MuiToggleButton-root"],textTransform:"none"}},Ze=(O,z,K)=>m.jsx(Zt,{select:!0,size:"small",label:"Compares",value:O??">=",onChange:G=>z(G.target.value),inputProps:{"aria-label":K},sx:{width:130},children:jg.filter(G=>G.op!=="~").map(G=>m.jsx(Xe,{value:G.op,children:G.label},G.op))});return m.jsx(Ta,{className:`${rt.dialog} ${rt.filterDialog}`,open:e,onClose:o,...l?{}:{initialFocus:ge},title:l?u.label??u.name:"Add a filter",description:l?m.jsxs(m.Fragment,{children:[m.jsxs(_,{component:"span",sx:{fontFamily:c.font.mono},children:["$",u.name]}),p?" · declared in the model, so its label and options are set there":" · declared in this report"]}):"A filter on the page, and the tiles it filters.",actions:m.jsxs(m.Fragment,{children:[l&&m.jsx(Oe,{color:"error",startIcon:m.jsx(vm,{}),onClick:()=>d(u.name),sx:O=>({mr:"auto",color:gm(O)}),children:"Remove filter"}),m.jsx(Oe,{onClick:o,children:"Cancel"}),m.jsx(Dt,{title:ne||I===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:m.jsx("span",{children:m.jsx(Oe,{variant:"contained",onClick:Q,disabled:!ne,children:l?"Apply":"Add filter"})})})]}),children:m.jsxs(ft,{sx:{gap:2.5,pt:1},children:[!l&&r.length>0&&m.jsxs(Ed,{exclusive:!0,size:"small",value:g.kind,onChange:(O,z)=>{z==="new"?v({kind:"new"}):z==="existing"&&r[0]&&q(r[0])},"aria-label":"Where the filter comes from",sx:Qe,children:[m.jsx(ko,{value:"new",children:"New in this report"}),m.jsx(ko,{value:"existing",children:"From the model"})]}),!l&&g.kind==="existing"?m.jsx(Zt,{select:!0,size:"small",label:"Filter",value:g.name,onChange:O=>{const z=r.find(K=>K.name===O.target.value);z&&q(z)},children:r.map(O=>m.jsxs(Xe,{value:O.name,children:[O.label??O.name,m.jsxs(ve,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",O.name]})]},O.name))}):null,m.jsxs(_,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:p?"1fr":"minmax(0, 1.4fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[!T&&m.jsx(Yl,{value:k,onChange:Y,fields:W,accepts:V,label:"Field",ariaLabel:"Field to filter",placeholder:"category",inputRef:ge,error:H!==void 0,helperText:H??(!l&&M?`Declared as $${M}`:void 0)}),!p&&m.jsx(Zt,{size:"small",label:"Label",placeholder:M?Do(M):"",value:b,onChange:O=>w(O.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Filter label"}})]}),N&&!T&&Ze(A,B,"Comparison"),!l&&g.kind==="new"&&m.jsxs(_,{children:[m.jsx(Xl,{children:"Control"}),m.jsx(_,{role:"radiogroup","aria-label":"Filter kind",sx:{display:"grid",gridTemplateColumns:{xs:"repeat(3, minmax(0, 1fr))",sm:"repeat(5, minmax(0, 1fr))"},gap:1},children:Eg.map(O=>{const z=O.kind===h,K=Re(O.kind);return m.jsx(Dt,{title:K??O.hint,describeChild:!0,children:m.jsxs(hd,{role:"radio","aria-checked":z,"aria-label":O.label,"aria-disabled":K!==void 0,onClick:()=>{K===void 0&&P(O.kind)},sx:G=>({flexDirection:"column",gap:.5,px:1,py:1.25,borderRadius:c.radius.tile,border:`1px solid ${z?f.accent:Z}`,boxShadow:z?`0 0 0 1px ${f.accent}`:"none",bgcolor:z?`color-mix(in srgb, ${f.accent} 6%, ${G.palette.background.paper})`:G.palette.background.paper,color:z?f.accent:G.palette.text.secondary,opacity:K?.45:1,cursor:K?"default":"pointer",transition:`border-color ${nt}, background-color ${nt}`,"&:hover":K||z?{}:{borderColor:Ae}}),children:[m.jsx(Ng,{kind:O.kind}),m.jsx(_,{component:"span",sx:{...c.type.caption,fontWeight:z?600:500,color:z?f.accent:"text.primary",textAlign:"center"},children:Ig[O.kind]})]})},O.kind)})}),h==="date"&&m.jsx(Zt,{size:"small",type:"date",label:"Starts at",value:x,onChange:O=>y(O.target.value),InputLabelProps:{shrink:!0},sx:{mt:1.5,width:200}})]}),m.jsxs(_,{sx:{border:`1px solid ${Z}`,borderRadius:c.radius.tile,overflow:"hidden"},children:[m.jsxs(ft,{direction:"row",sx:{alignItems:"center",gap:1.25,px:1.5,py:1},children:[m.jsx(wg,{"aria-hidden":!0,sx:{fontSize:18,color:"text.secondary"}}),m.jsxs(ve,{variant:"body2",sx:{flex:1,minWidth:0},children:[m.jsx(_,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:D===E&&E>0?`Applies to all ${D} tile${D===1?"":"s"}`:`Applies to ${D} of ${E} tile${E===1?"":"s"}`}),!T&&k.trim()!==""&&D>0&&m.jsxs(_,{component:"span",sx:{color:"text.secondary"},children:[" · each filters on ",m.jsx(_,{component:"span",sx:{...c.type.code},children:k.trim()})]})]}),!T&&m.jsx(Oe,{size:"small","aria-expanded":Pe,onClick:()=>X(O=>!O),children:Pe?"Done choosing":"Choose tiles"})]}),m.jsx(So,{in:Pe,unmountOnExit:!0,children:m.jsxs(_,{sx:{borderTop:`1px solid ${Z}`,px:.5,pb:1},children:[m.jsxs(ft,{direction:"row",sx:{alignItems:"center",gap:.5,pt:.5},children:[m.jsx(yo,{size:"small",checked:E>0&&D===E,indeterminate:D>0&&D<E,disabled:E===0,onChange:O=>U(O.target.checked),inputProps:{"aria-label":"All tiles"}}),m.jsx(ve,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:"All tiles"}),m.jsx(Oe,{size:"small",onClick:()=>{T||$(O=>O.map(z=>({...z,field:k}))),j(O=>!O)},children:T?"Same field for all":"Adjust per tile"})]}),m.jsx(ft,{sx:{gap:T?1:0},children:t.tiles.map((O,z)=>{if(!le(O))return null;const K=C[z],G=O.label??O.name,ke=T?re[z]:void 0;return m.jsxs(ft,{direction:"row",sx:{gap:1,alignItems:T?"flex-start":"center",opacity:F[z]?1:.6},children:[m.jsx(yo,{size:"small",disabled:!F[z],checked:(K?.include??!1)&&F[z],inputProps:{"aria-label":`Filter ${G}`},onChange:Me=>L(z,{include:Me.target.checked})}),m.jsx(ve,{variant:"body2",sx:{flex:1,minWidth:0,pt:T?1:0},noWrap:!0,children:G}),F[z]?T&&m.jsxs(m.Fragment,{children:[N&&Ze(K?.op,Me=>L(z,{op:Me}),`Comparison for ${G}`),m.jsx(Yl,{value:K?.field??"",onChange:Me=>L(z,{field:Me}),fields:s?.(O),accepts:V,label:"Field",ariaLabel:`Field for ${G}`,disabled:!K?.include,error:ke!==void 0,helperText:ke,sx:{width:220,pr:1}})]}):m.jsx(ve,{variant:"caption",sx:{color:f.tileTitle,pr:1,maxWidth:260,textAlign:"right"},children:Pg(t.tiles[z]).reason})]},fe(O))})})]})})]}),D===0&&m.jsx(ve,{variant:"caption",sx:{color:"warning.main",display:"block",mt:-1.5},children:"No tile is ticked, so this control will not appear on the report."}),!p&&m.jsxs(_,{children:[m.jsx(Xl,{children:"Preview"}),m.jsx(_,{sx:O=>({display:"flex",alignItems:"center",gap:1,p:1.5,borderRadius:c.radius.tile,bgcolor:O.palette.action.hover}),children:m.jsxs(_,{"aria-hidden":!0,sx:O=>({display:"inline-flex",alignItems:"center",gap:.75,height:30,px:1.25,borderRadius:c.radius.control,border:`1px solid ${Z}`,bgcolor:O.palette.background.paper,...c.type.control}),children:[m.jsx(_,{component:"span",sx:{color:"text.secondary"},children:Ke}),m.jsx(_,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:Ie}),m.jsx(Sa,{sx:{fontSize:16,color:"text.secondary"}})]})})]})]})})}function Xl({children:e}){const t=qe().theme.ui;return m.jsx(ve,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}const Ig={select:"Pick one",multiselect:"Pick several",text:"Text",number:"Range",date:"Date"};function Ng({kind:e}){const t={fontSize:22};switch(e){case"select":return m.jsx(gg,{sx:t});case"multiselect":return m.jsx(vg,{sx:t});case"text":return m.jsx(yg,{sx:t});case"number":return m.jsx(bg,{sx:t});case"date":return m.jsx(xg,{sx:t})}}function Ql({type:e}){const t=e?.replace(/_type$/,""),n=t==="string"?"Abc":t==="number"?"#":t==="date"||t==="timestamp"?"Date":t==="boolean"?"T/F":void 0,r=qe().theme.ui;return n?m.jsx(_,{component:"span","aria-hidden":!0,sx:i=>({fontFamily:r.font.mono,fontSize:10,fontWeight:r.type.label.fontWeight,color:i.palette.text.secondary,bgcolor:i.palette.action.hover,borderRadius:"4px",px:.5,py:.25,minWidth:22,textAlign:"center",flex:"none"}),children:n}):null}const Zl=mt(m.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}));function zd(e,t,n,r){const[i,s]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&s(structuredClone(e))},[t,e]),{draft:i,patch:o=>s(a=>{if(a===void 0)return a;const d=structuredClone(a);return o(d),d}),apply:o=>{if(i===void 0)return;const a=structuredClone(i);o(a),s(a),JSON.stringify(a)!==JSON.stringify(e)&&n(a)},close:()=>{i!==void 0&&e!==void 0&&JSON.stringify(i)!==JSON.stringify(e)&&n(i),r()},discard:()=>s(void 0)}}const Wg=e=>e&&e.length===1?`This tile's chart line (${e[0]}) is not one the builder models, so its chart cannot be changed here.`:`This tile has ${e?.length??"several"} chart lines${e?` (${e.join(" and ")})`:""}, so its chart cannot be changed here.`,zg=new Set(["bar_chart","line_chart","scatter_chart","combo_chart"]),Lg="Its chart's bars, lines and points do not respond to a click; show it as a table to click its cells.",Fg="Declared on its source, so its chart is set in the model.",Bg="It names a query, so its chart is set where that query is declared.";function _g({anchor:e,tile:t,onClose:n,onCommit:r,onDrills:i,onDuplicate:s,duplicateBlocked:o,view:a,viewStatus:d}){const{theme:f}=qe(),c=f.ui,{draft:l,apply:u,patch:p,close:g}=zd(t,e!==null,r,n),[v,b]=S.useState(void 0),w=l!==void 0&&le(l)?l:void 0,h=w!==void 0&&!cr(w),x=E=>u(D=>{le(D)&&E(D)}),y=S.useRef(void 0),k=S.useRef(null),C=e!==null;S.useEffect(()=>{C?y.current=t&&le(t)?t.chart:void 0:b(void 0)},[C]);const $=w?.chart??"default",T=Nd(a,$,d),j=w?w.declaration.kind==="query"?Bg:h?w.chart==="custom"?Wg(w.chartLines):void 0:Fg:void 0,M=E=>x(D=>{const W=y.current;E===(W??"default")?(W===void 0?delete D.chart:D.chart=W,delete D.chartCarried):(D.chart=E,a?D.chartCarried=a.chart?[a.chart]:[]:delete D.chartCarried)}),I=h?i?void 0:"Its source declares no dimension a click could filter by.":void 0,N=$==="default"?a?.chart:$,A=N!==void 0&&zg.has(N)?Lg:void 0,L=E=>D=>b({kind:E,anchor:D.currentTarget}),B=j??(N===void 0||!qg.has(N)?"Only a bar, line, scatter or bar and line chart has a color to set.":void 0),q=Array.from(new Set(f.series.map(wd).filter(E=>E!==void 0))).slice(0,8),P=E=>x(D=>{E===void 0?delete D.color:D.color=E.toLowerCase()}),F=(E,D,W)=>m.jsxs(m.Fragment,{children:[m.jsx(Bt,{primary:E,...W?{secondary:W}:{},secondaryTypographyProps:{sx:{whiteSpace:"normal",maxWidth:240}}}),D&&m.jsx(ve,{variant:"body2",sx:{color:"text.secondary",ml:2},children:D})]});return m.jsxs(m.Fragment,{children:[m.jsxs(Xn,{className:rt.menu,open:e!==null&&l!==void 0,anchorEl:e,onClose:g,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":w?vt(w):"Tile"},slotProps:{paper:{sx:{minWidth:240,mt:.5,borderRadius:c.radius.menu,border:`1px solid ${cn(f.cardBorder)}`,boxShadow:c.shadow.menu}}},children:[w&&m.jsxs(Xe,{"aria-haspopup":"menu","aria-expanded":v?.kind==="chart",disabled:j!==void 0,onClick:L("chart"),onKeyDown:E=>{E.key==="ArrowRight"&&j===void 0&&b({kind:"chart",anchor:E.currentTarget})},children:[F("Chart",j?void 0:T.find(E=>E.value===$)?.label,j),m.jsx(Zl,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),w&&j===void 0&&m.jsxs(Xe,{"aria-haspopup":"menu","aria-expanded":v?.kind==="color",disabled:B!==void 0,onClick:L("color"),onKeyDown:E=>{E.key==="ArrowRight"&&B===void 0&&b({kind:"color",anchor:E.currentTarget})},children:[F("Color",B?void 0:w.color??"Theme",B),!B&&m.jsx(Gs,{color:w.color??f.series[0],trailing:!0}),m.jsx(Zl,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),h&&m.jsx(Xe,{"aria-haspopup":"dialog",disabled:I!==void 0,onClick:()=>{g(),i?.()},children:F("Clickable cells…",void 0,I??A)}),w&&s&&m.jsx(Xe,{disabled:o!==void 0,onClick:()=>{g(),s()},children:F("Duplicate",void 0,o)}),w?.declaration.kind==="opaque"&&m.jsxs(ve,{variant:"body2",sx:{color:f.tileTitle,px:2,py:.75,maxWidth:260},children:["Its body is ",w.declaration.why,", so a filter has no single place to go."]}),w&&m.jsx(nr,{}),w&&m.jsx(_,{"aria-hidden":!0,sx:{px:2,py:.5,...c.type.code,color:"text.secondary"},children:vt(w).replace("->","→")})]}),m.jsx(Xn,{className:rt.menu,open:v?.kind==="chart",anchorEl:v?.anchor??null,onClose:()=>b(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":"Chart",onKeyDown:E=>{E.key==="ArrowLeft"&&(E.preventDefault(),b(void 0))}},children:T.filter(E=>E.value!=="custom").map(E=>m.jsxs(Xe,{role:"menuitemradio","aria-checked":E.value===$,disabled:E.disabled===!0,onClick:()=>{M(E.value),b(void 0)},children:[m.jsx(Bt,{primary:E.label,...E.reason??E.hint?{secondary:E.reason??E.hint}:{}}),E.value===$&&m.jsx(kd,{sx:{minWidth:0,ml:2},children:m.jsx(Ts,{fontSize:"small",sx:{color:f.accent}})})]},E.value))}),m.jsxs(Xn,{className:rt.menu,open:v?.kind==="color",anchorEl:v?.anchor??null,onClose:()=>b(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,"aria-label":"Color",onKeyDown:E=>{E.key==="ArrowLeft"&&(E.preventDefault(),b(void 0))}},children:[m.jsxs(Xe,{role:"menuitemradio","aria-checked":w?.color===void 0,onClick:()=>{P(void 0),b(void 0)},children:[m.jsx(Gs,{color:f.series[0]}),m.jsx(Bt,{primary:"Theme",secondary:"The page's own colors"}),w?.color===void 0&&m.jsx(Jl,{color:f.accent})]}),q.map(E=>m.jsxs(Xe,{role:"menuitemradio","aria-checked":w?.color===E.toLowerCase(),onClick:()=>{P(E),b(void 0)},children:[m.jsx(Gs,{color:E}),m.jsx(Bt,{primary:E.toLowerCase()}),w?.color===E.toLowerCase()&&m.jsx(Jl,{color:f.accent})]},E)),m.jsx(nr,{}),m.jsxs(Xe,{component:"label","aria-checked":w?.color!==void 0&&!q.some(E=>E.toLowerCase()===w.color),role:"menuitemradio",onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),k.current?.click())},children:[m.jsx("input",{ref:k,type:"color","aria-label":"Other color",value:w?.color??Hg(f.series[0]),onChange:E=>{const D=E.target.value;xm(D)&&p(W=>{le(W)&&(W.color=D.toLowerCase())})},style:{width:18,height:18,padding:0,border:"none",background:"none",marginRight:12}}),m.jsx(Bt,{primary:"Other color…"})]})]})]})}const qg=new Set(["bar_chart","line_chart","scatter_chart","combo_chart"]),Hg=e=>(e&&wd(e))??"#000000";function Gs({color:e,trailing:t=!1}){return m.jsx(_,{"aria-hidden":!0,"data-swatch":t?"trailing":"leading",sx:{width:14,height:14,borderRadius:"3px",bgcolor:e,border:"1px solid rgba(0,0,0,0.15)",...t?{ml:1}:{mr:1.5},flex:"none"}})}function Jl({color:e}){return m.jsx(kd,{sx:{minWidth:0,ml:2},children:m.jsx(Ts,{fontSize:"small",sx:{color:e}})})}const Os=e=>e.label??bm(vt(e));function Ug({editor:e,catalog:t,columns:n,dashboards:r,bindings:i,tiles:s,drillSource:o,setDrillSource:a,exitDialog:d,renderViewPreview:f,takenGivenNames:c}){const{filterDialog:l,setFilterDialog:u}=i,{menu:p,setMenu:g}=s,[v,b]=S.useState(),w=p===void 0?void 0:e.document.tiles[p.index],h=w&&le(w)?w:void 0,x=(()=>{if(!h||!t)return;const y=t.documentViews?.get(h.source??"")?.get(h.name);if(y&&e.document.sources.some($=>$.name===h.source))return y;if(h.declaration.kind==="inline"||h.declaration.kind==="opaque")return;const k=e.document.sources.find($=>$.name===h.source)?.base??h.source,C=h.declaration.kind==="reference"?h.declaration.from:h.name;return t.sources.find($=>$.name===k)?.views.find($=>$.name===C)})();return m.jsxs(m.Fragment,{children:[m.jsx(Rg,{open:l!==void 0,document:e.document,...l?.control?{control:l.control}:{},available:i.available,...c?{takenNames:c}:{},...t?{fieldsFor:i.fieldsFor}:{},onClose:()=>u(void 0),onApply:i.applyFilter,onRemove:i.dropControl}),m.jsx(_g,{anchor:p?.anchor??null,tile:p===void 0?void 0:e.document.tiles[p.index],onClose:()=>g(void 0),onCommit:y=>{const k=p?.index;if(k===void 0)return;const C=ig(y);e.update($=>{$.tiles[k]=C,C!==y&&rn($.tiles)&&($.tiles=Ht($.tiles,n,k))})},view:x,...x===void 0&&h?{viewStatus:t?"unlisted":"loading"}:{},onDuplicate:()=>{p&&s.duplicate(p.index)},...h&&ls(h)!==void 0?{duplicateBlocked:ls(h)}:{},...(e.document.sources.find(y=>y.name===h?.source)?.dimensions?.length??0)>0?{onDrills:()=>{b(h?Os(h):void 0),a(h?.source)}}:{}}),m.jsx(pg,{open:o!==void 0,document:e.document,source:e.document.sources.find(y=>y.name===o),givenNames:i.controlList.map(y=>y.name),dashboards:r??[],...v?{tileLabel:v}:{},onClose:()=>a(void 0),onApply:y=>e.update(k=>{const C=[...(k.drills??[]).filter($=>$.source!==o),...y];C.length===0?delete k.drills:k.drills=C})}),m.jsx(Dp,{...d}),m.jsx(ug,{open:s.addingTile,document:e.document,catalog:t,columns:n,onClose:s.closeAdd,onAdd:s.addTile,onAddText:s.addText,...f?{renderPreview:f}:{}})]})}var Vg=Symbol.for("preact-signals");function As(){if(_t>1)_t--;else{var e,t=!1;for((function(){var i=us;for(us=void 0;i!==void 0;){var s=i.S;if(s.v===i.v)for(var o=s.t;o!==void 0;o=o.x)o.i===i.i&&(o.i=s.i);i=i.o}})();Zr!==void 0;){var n=Zr;for(Zr=void 0,ds++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Fd(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(ds=0,_t--,t)throw e}}function De(e){if(_t>0)return e();Oo=++Kg,_t++;try{return e()}finally{As()}}var Qr,Se=void 0;function oe(e){var t=Se,n=Qr;Se=void 0,Qr=void 0;try{return e()}finally{Se=t,Qr=n}}var Zr=void 0,_t=0,ds=0,Kg=0,Oo=0,us=void 0,hs=0;function Ld(e){if(Se!==void 0){var t=e.n;if(t===void 0||t.t!==Se)return t={i:0,S:e,p:Se.s,n:void 0,t:Se,e:void 0,x:void 0,r:t},Se.s!==void 0&&(Se.s.n=t),Se.s=t,e.n=t,32&Se.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=Se.s,t.n=void 0,Se.s.n=t,Se.s=t),t}}function dt(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}dt.prototype.brand=Vg;dt.prototype.h=function(){return!0};dt.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n!==void 0?n.e=e:oe(function(){var r;(r=t.W)==null||r.call(t)}))};dt.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&oe(function(){var i;(i=t.Z)==null||i.call(t)}))}};dt.prototype.subscribe=function(e){var t=this;return $t(function(){var n=t.value;oe(function(){return e(n)})},{name:"sub"})};dt.prototype.valueOf=function(){return this.value};dt.prototype.toString=function(){return this.value+""};dt.prototype.toJSON=function(){return this.value};dt.prototype.peek=function(){var e=this;return oe(function(){return e.value})};Object.defineProperty(dt.prototype,"value",{get:function(){var e=Ld(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ds>100)throw new Error("Cycle detected");(function(n){_t!==0&&ds===0&&n.l!==Oo&&(n.l=Oo,us={S:n,v:n.v,i:n.i,o:us})})(this),this.v=e,this.i++,hs++,_t++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{As()}}}});function dr(e,t){return new dt(e,t)}function Fd(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Bd(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function _d(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function En(e,t){dt.call(this,void 0,t),this.x=e,this.s=void 0,this.g=hs-1,this.f=4}En.prototype=new dt;En.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===hs))return!0;if(this.g=hs,this.f|=1,this.i>0&&!Fd(this))return this.f&=-2,!0;var e=Se;try{Bd(this),Se=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return Se=e,_d(this),this.f&=-2,!0};En.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}dt.prototype.S.call(this,e)};En.prototype.U=function(e){if(this.t!==void 0&&(dt.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};En.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(En.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Ld(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function ec(e,t){return new En(e,t)}function qd(e){var t=e.m;if(e.m=void 0,typeof t=="function"){_t++;var n=Se;Se=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Aa(e),r}finally{Se=n,As()}}}function Aa(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,qd(e)}function Gg(e){if(Se!==this)throw new Error("Out-of-order effect");_d(this),Se=e,this.f&=-2,8&this.f&&Aa(this),As()}function ur(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Qr&&Qr.push(this)}ur.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.m=t)}finally{e()}};ur.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,qd(this),Bd(this),_t++;var e=Se;return Se=this,Gg.bind(this,e)};ur.prototype.N=function(){2&this.f||(this.f|=2,this.u=Zr,Zr=this)};ur.prototype.d=function(){this.f|=8,1&this.f||Aa(this)};ur.prototype.dispose=function(){this.d()};function $t(e,t){var n=new ur(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Yg=Object.create,Pa=Object.defineProperty,Xg=Object.defineProperties,Qg=Object.getOwnPropertyDescriptor,Zg=Object.getOwnPropertyDescriptors,tc=Object.getOwnPropertySymbols,Jg=Object.prototype.hasOwnProperty,ev=Object.prototype.propertyIsEnumerable,tv=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),hr=e=>{throw TypeError(e)},Ao=(e,t,n)=>t in e?Pa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nv=(e,t)=>{for(var n in t||(t={}))Jg.call(t,n)&&Ao(e,n,t[n]);if(tc)for(var n of tc(t))ev.call(t,n)&&Ao(e,n,t[n]);return e},rv=(e,t)=>Xg(e,Zg(t)),nc=(e,t)=>Pa(e,"name",{value:t,configurable:!0}),iv=e=>{var t;return[,,,Yg((t=void 0)!=null?t:null)]},Hd=["class","method","getter","setter","accessor","field","value","get","set"],Or=e=>e!==void 0&&typeof e!="function"?hr("Function expected"):e,sv=(e,t,n,r,i)=>({kind:Hd[e],name:t,metadata:r,addInitializer:s=>n._?hr("Already initialized"):i.push(Or(s||null))}),Ud=(e,t)=>Ao(t,tv("metadata"),e[3]),un=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},fr=(e,t,n,r,i,s)=>{var o,a,d,f,c,l=t&7,u=!!(t&8),p=!!(t&16),g=l>3?e.length+1:l?u?1:2:0,v=Hd[l+5],b=l>3&&(e[g-1]=[]),w=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&Qg(l<4?i:{get[n](){return yt(this,s)},set[n](y){return Xt(this,s,y)}},n));l?p&&l<4&&nc(s,(l>2?"set ":l>1?"get ":"")+n):nc(i,n);for(var x=r.length-1;x>=0;x--)f=sv(l,n,d={},e[3],w),l&&(f.static=u,f.private=p,c=f.access={has:p?y=>ov(i,y):y=>n in y},l^3&&(c.get=p?y=>(l^1?yt:av)(y,i,l^4?s:h.get):y=>y[n]),l>2&&(c.set=p?(y,k)=>Xt(y,i,k,l^4?s:h.set):(y,k)=>y[n]=k)),a=(0,r[x])(l?l<4?p?s:h[v]:l>4?void 0:{get:h.get,set:h.set}:i,f),d._=1,l^4||a===void 0?Or(a)&&(l>4?b.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?hr("Object expected"):(Or(o=a.get)&&(h.get=o),Or(o=a.set)&&(h.set=o),Or(o=a.init)&&b.unshift(o));return l||Ud(e,i),h&&Pa(i,n,h),p?l^4?s:h:i},Ra=(e,t,n)=>t.has(e)||hr("Cannot "+n),ov=(e,t)=>Object(t)!==t?hr('Cannot use the "in" operator on this value'):e.has(t),yt=(e,t,n)=>(Ra(e,t,"read from private field"),n?n.call(e):t.get(e)),Ar=(e,t,n)=>t.has(e)?hr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Xt=(e,t,n,r)=>(Ra(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),av=(e,t,n)=>(Ra(e,t,"access private method"),n);function Po(e,t){if(t){let n;return ec(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return ec(e)}function Ct(e,t){if(Object.is(e,t))return!0;if(e===null||t===null)return!1;if(typeof e=="function"&&typeof t=="function")return e===t;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((n,r)=>!Ct(n,t[r]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(i=>!Ct(e[i],t[i]))}return!1}function ae({get:e},t){return{init(n){return dr(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function ze(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Po(e.bind(this)),n.set(this,r)),r.value}}function Ys(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),i=Object.getOwnPropertyDescriptor(r,n.name);i&&Object.defineProperty(r,n.name,rv(nv({},i),{enumerable:e}))})}}function xi(...e){const t=e.map(n=>$t(n));return()=>t.forEach(n=>n())}var Vd,Kd,Gd,Yd,Xd,Qd,ot,Ia,Xs,Ro,Io,tt,Na,Qs,Zd,No,Wa,Zs,Wo,zo;Qd=[ae],Xd=[ae],Yd=[ae],Gd=[Ys()],Kd=[Ys()],Vd=[Ys()];var Cn=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,un(ot,5,this),Ar(this,tt),Ar(this,Ia,un(ot,8,this)),un(ot,11,this),Ar(this,Na,un(ot,12,this)),un(ot,15,this),Ar(this,Wa,un(ot,16,this)),un(ot,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return yt(this,tt,Wo)}get initial(){return yt(this,tt,Ro)}get previous(){return yt(this,tt,Zd)}set current(e){const t=oe(()=>yt(this,tt,Wo));e&&t&&this.equals(t,e)||De(()=>{yt(this,tt,Ro)||Xt(this,tt,e,Io),Xt(this,tt,t,No),Xt(this,tt,e,zo)})}reset(e=this.defaultValue){De(()=>{Xt(this,tt,void 0,No),Xt(this,tt,e,Io),Xt(this,tt,e,zo)})}};ot=iv();Ia=new WeakMap;tt=new WeakSet;Na=new WeakMap;Wa=new WeakMap;Xs=fr(ot,20,"#initial",Qd,tt,Ia),Ro=Xs.get,Io=Xs.set;Qs=fr(ot,20,"#previous",Xd,tt,Na),Zd=Qs.get,No=Qs.set;Zs=fr(ot,20,"#current",Yd,tt,Wa),Wo=Zs.get,zo=Zs.set;fr(ot,2,"current",Gd,Cn);fr(ot,2,"initial",Kd,Cn);fr(ot,2,"previous",Vd,Cn);Ud(ot,Cn);function Js(e){return oe(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var hn,lv=class{constructor(){Ar(this,hn,new WeakMap)}get(e,t){var n;return e?(n=yt(this,hn).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return yt(this,hn).has(e)||yt(this,hn).set(e,new Map),(r=yt(this,hn).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=yt(this,hn).get(e))==null?void 0:t.clear():void 0}};hn=new WeakMap;var cv=Object.create,Jd=Object.defineProperty,dv=Object.getOwnPropertyDescriptor,rc=Object.getOwnPropertySymbols,uv=Object.prototype.hasOwnProperty,hv=Object.prototype.propertyIsEnumerable,eu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ps=e=>{throw TypeError(e)},ic=Math.pow,Lo=(e,t,n)=>t in e?Jd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fv=(e,t)=>{for(var n in t||(t={}))uv.call(t,n)&&Lo(e,n,t[n]);if(rc)for(var n of rc(t))hv.call(t,n)&&Lo(e,n,t[n]);return e},pv=e=>{var t;return[,,,cv((t=e?.[eu("metadata")])!=null?t:null)]},tu=["class","method","getter","setter","accessor","field","value","get","set"],nu=e=>e!==void 0&&typeof e!="function"?Ps("Function expected"):e,mv=(e,t,n,r,i)=>({kind:tu[e],name:t,metadata:r,addInitializer:s=>n._?Ps("Already initialized"):i.push(nu(s||null))}),gv=(e,t)=>Lo(t,eu("metadata"),e[3]),vv=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)s[i].call(n);return r},ru=(e,t,n,r,i,s)=>{for(var o,a,d,f,c=t&7,l=!1,u=!1,p=2,g=tu[c+5],v=e[p]||(e[p]=[]),b=(i=i.prototype,dv(i,n)),w=r.length-1;w>=0;w--)d=mv(c,n,a={},e[3],v),d.static=l,d.private=u,f=d.access={has:h=>n in h},f.get=h=>h[n],o=(0,r[w])(b[g],d),a._=1,nu(o)&&(b[g]=o);return b&&Jd(i,n,b),i},iu=(e,t,n)=>t.has(e)||Ps("Cannot "+n),xv=(e,t,n)=>(iu(e,t,"read from private field"),t.get(e)),bv=(e,t,n)=>t.has(e)?Ps("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),yv=(e,t,n,r)=>(iu(e,t,"write to private field"),t.set(e,n),n),wt=class Fo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Fo(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Fo(t,n)}},Nt=class fn{constructor(t,n,r,i){this.left=t,this.top=n,this.width=r,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:r,left:i,width:s,height:o,scale:a}=this,d=new fn(i+t,r+n,s,o);return d.scale=fv({},a),d}get boundingRectangle(){const{width:t,height:n,left:r,top:i,right:s,bottom:o}=this;return{width:t,height:n,left:r,top:i,right:s,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:i}=this;return new wt((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof fn))return!1;const{left:n,top:r,width:i,height:s}=this;return n===t.left&&r===t.top&&i===t.width&&s===t.height}containsPoint(t){const{top:n,left:r,bottom:i,right:s}=this;return n<=t.y&&t.y<=i&&r<=t.x&&t.x<=s}intersectionArea(t){return t instanceof fn?wv(this,t):0}intersectionRatio(t){const{area:n}=this,r=this.intersectionArea(t);return r/(t.area+n-r)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}get aspectRatio(){const{width:t,height:n}=this;return t/n}get corners(){return[{x:this.left,y:this.top},{x:this.right,y:this.top},{x:this.left,y:this.bottom},{x:this.right,y:this.bottom}]}static from({top:t,left:n,width:r,height:i}){return new fn(n,t,r,i)}static delta(t,n,r={x:"center",y:"center"}){const i=(s,o)=>{const a=r[o],d=o==="x"?s.left:s.top,f=o==="x"?s.width:s.height;return a=="start"?d:a=="end"?d+f:d+f/2};return wt.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return fn.from(t).intersectionRatio(fn.from(n))}};function wv(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),o=i-r,a=s-n;return r<i&&n<s?o*a:0}var su,ou,Bo,_i,bi,Rs=class extends(Bo=Cn,ou=[ze],su=[ze],Bo){constructor(e){const t=wt.from(e);super(t,(n,r)=>wt.equals(n,r)),vv(bi,5,this),bv(this,_i,0),this.velocity={x:0,y:0}}get delta(){return wt.delta(this.current,this.initial)}get direction(){const{current:e,previous:t}=this;if(!t)return null;const n={x:e.x-t.x,y:e.y-t.y};return!n.x&&!n.y?null:Math.abs(n.x)>Math.abs(n.y)?n.x>0?"right":"left":n.y>0?"down":"up"}get current(){return super.current}set current(e){const{current:t}=this,n=wt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-xv(this,_i),o=a=>Math.round(a/s*100);De(()=>{yv(this,_i,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(wt.from(e)),this.velocity={x:0,y:0}}};bi=pv(Bo);_i=new WeakMap;ru(bi,2,"delta",ou,Rs);ru(bi,2,"direction",su,Rs);gv(bi,Rs);function _o({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(ic(r,2)+ic(i,2))>n:"x"in n&&"y"in n?r>n.x&&i>n.y:"x"in n?r>n.x:"y"in n?i>n.y:!1}var au=(e=>(e.Horizontal="x",e.Vertical="y",e))(au||{}),lu=Object.values(au),kv=Object.create,za=Object.defineProperty,Sv=Object.defineProperties,$v=Object.getOwnPropertyDescriptor,jv=Object.getOwnPropertyDescriptors,fs=Object.getOwnPropertySymbols,cu=Object.prototype.hasOwnProperty,du=Object.prototype.propertyIsEnumerable,uu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),pr=e=>{throw TypeError(e)},qo=(e,t,n)=>t in e?za(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,La=(e,t)=>{for(var n in t||(t={}))cu.call(t,n)&&qo(e,n,t[n]);if(fs)for(var n of fs(t))du.call(t,n)&&qo(e,n,t[n]);return e},Fa=(e,t)=>Sv(e,jv(t)),sc=(e,t)=>za(e,"name",{value:t,configurable:!0}),hu=(e,t)=>{var n={};for(var r in e)cu.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&fs)for(var r of fs(e))t.indexOf(r)<0&&du.call(e,r)&&(n[r]=e[r]);return n},mr=e=>{var t;return[,,,kv((t=e?.[uu("metadata")])!=null?t:null)]},fu=["class","method","getter","setter","accessor","field","value","get","set"],Pr=e=>e!==void 0&&typeof e!="function"?pr("Function expected"):e,Mv=(e,t,n,r,i)=>({kind:fu[e],name:t,metadata:r,addInitializer:s=>n._?pr("Already initialized"):i.push(Pr(s||null))}),Tn=(e,t)=>qo(t,uu("metadata"),e[3]),te=(e,t,n,r)=>{for(var i=0,s=e[t>>1],o=s&&s.length;i<o;i++)t&1?s[i].call(n):r=s[i].call(n,r);return r},ce=(e,t,n,r,i,s)=>{var o,a,d,f,c,l=t&7,u=!!(t&8),p=!!(t&16),g=l>3?e.length+1:l?u?1:2:0,v=fu[l+5],b=l>3&&(e[g-1]=[]),w=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&$v(l<4?i:{get[n](){return We(this,s)},set[n](y){return xt(this,s,y)}},n));l?p&&l<4&&sc(s,(l>2?"set ":l>1?"get ":"")+n):sc(i,n);for(var x=r.length-1;x>=0;x--)f=Mv(l,n,d={},e[3],w),l&&(f.static=u,f.private=p,c=f.access={has:p?y=>Ev(i,y):y=>n in y},l^3&&(c.get=p?y=>(l^1?We:pu)(y,i,l^4?s:h.get):y=>y[n]),l>2&&(c.set=p?(y,k)=>xt(y,i,k,l^4?s:h.set):(y,k)=>y[n]=k)),a=(0,r[x])(l?l<4?p?s:h[v]:l>4?void 0:{get:h.get,set:h.set}:i,f),d._=1,l^4||a===void 0?Pr(a)&&(l>4?b.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?pr("Object expected"):(Pr(o=a.get)&&(h.get=o),Pr(o=a.set)&&(h.set=o),Pr(o=a.init)&&b.unshift(o));return l||Tn(e,i),h&&za(i,n,h),p?l^4?s:h:i},Ba=(e,t,n)=>t.has(e)||pr("Cannot "+n),Ev=(e,t)=>Object(t)!==t?pr('Cannot use the "in" operator on this value'):e.has(t),We=(e,t,n)=>(Ba(e,t,"read from private field"),n?n.call(e):t.get(e)),me=(e,t,n)=>t.has(e)?pr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),xt=(e,t,n,r)=>(Ba(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),pu=(e,t,n)=>(Ba(e,t,"access private method"),n);function mu(e,t){return{plugin:e,options:t}}function yi(e){return t=>mu(e,t)}function ai(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var gu,li,_a,qi;gu=[ae];var it=class{constructor(e,t){this.manager=e,this.options=t,me(this,_a,te(li,8,this,!1)),te(li,11,this),me(this,qi,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return oe(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=$t(e.bind(this));return We(this,qi).add(t),t}destroy(){We(this,qi).forEach(e=>e())}static configure(e){return mu(this,e)}};li=mr(null);_a=new WeakMap;qi=new WeakMap;ce(li,4,"disabled",gu,it,_a);Tn(li,it);var wi=class extends it{},Hi,eo=class{constructor(e){this.manager=e,this.instances=new Map,me(this,Hi,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(ai).reduce((r,i)=>{const s=r.find(({plugin:o})=>o===i.plugin);return s?(s.options=i.options,r):[...r,i]},[]),n=t.map(({plugin:r})=>r);for(const r of We(this,Hi))if(!n.includes(r)){if(r.prototype instanceof wi)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);xt(this,Hi,n)}get(e){return this.instances.get(e)}register(e,t){const n=this.instances.get(e);if(n)return n.options!==t&&(n.options=t),n;const r=new e(this.manager,t);return this.instances.set(e,r),r}unregister(e){const t=this.instances.get(e);t&&(t.destroy(),this.instances.delete(e))}destroy(){for(const e of this.instances.values())e.destroy();this.instances.clear()}};Hi=new WeakMap;function Cv(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Di=[],Fn,Bn,Tv=class extends it{constructor(e){super(e),me(this,Fn),me(this,Bn),this.computeCollisions=this.computeCollisions.bind(this),xt(this,Bn,dr(Di)),this.destroy=xi(()=>{const t=this.computeCollisions(),n=oe(()=>this.manager.dragOperation.position.current);if(t!==Di){const r=We(this,Fn);if(xt(this,Fn,n),r&&n.x==r.x&&n.y==r.y)return}else xt(this,Fn,void 0);We(this,Bn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){oe(()=>{e?We(this,Bn).value=this.computeCollisions():xt(this,Fn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return Di;const a=[],d=[];for(const f of e??n.droppables){if(f.disabled||i&&!f.accepts(i))continue;const c=t??f.collisionDetector;if(!c)continue;d.push(f),f.shape;const l=oe(()=>c({droppable:f,dragOperation:r}));l&&(f.collisionPriority!=null&&(l.priority=f.collisionPriority),a.push(l))}return d.length===0?Di:(a.sort(Cv),a)}get collisions(){return We(this,Bn).value}};Fn=new WeakMap;Bn=new WeakMap;var vu,xu,bu,qa,yu,Tt,Ha,Gn,Ua,Va;bu=[ae],xu=[ae],vu=[ae];var Ut=class pn{constructor(t,n){me(this,Ha,te(Tt,8,this)),te(Tt,11,this),me(this,Gn),me(this,Ua,te(Tt,12,this)),te(Tt,15,this),me(this,Va,te(Tt,16,this)),te(Tt,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let d=i;xt(this,Gn,dr(i)),this.manager=n,this.data=s,this.disabled=o,this.effects=()=>{var f;return[()=>{const{id:c,manager:l}=this;if(c!==d)return d=c,l?.registry.register(this),()=>l?.registry.unregister(this)},...(f=r?.())!=null?f:[]]},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this),this.destroy=this.destroy.bind(this),n&&a&&queueMicrotask(this.register)}get id(){var t,n;const r=We(this,Gn).value;return(n=(t=pn.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=pn.pendingIdChanges)==null?void 0:n.get(this))!=null?r:We(this,Gn).peek();t!==i&&(pn.pendingIdChanges||(pn.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return pu(s=pn,qa,yu).call(s)})),pn.pendingIdChanges.set(this,t))}register(){var t;return(t=this.manager)==null?void 0:t.registry.register(this)}unregister(){var t;(t=this.manager)==null||t.registry.unregister(this)}destroy(){var t;(t=this.manager)==null||t.registry.unregister(this)}};Tt=mr(null);qa=new WeakSet;yu=function(){const e=Ut.pendingIdChanges;Ut.pendingIdChanges=null,e&&De(()=>{for(const[t,n]of e)We(t,Gn).value=n})};Ha=new WeakMap;Gn=new WeakMap;Ua=new WeakMap;Va=new WeakMap;ce(Tt,4,"manager",bu,Ut,Ha);ce(Tt,4,"data",xu,Ut,Ua);ce(Tt,4,"disabled",vu,Ut,Va);me(Ut,qa);Tn(Tt,Ut);Ut.pendingIdChanges=null;var Is=Ut,oc=class{constructor(){this.map=dr(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),i=()=>this.unregister(e,t);if(r===t)return i;r&&r.id===e&&(this.cleanupFunctions.get(r)?.(),this.cleanupFunctions.delete(r));const s=new Map(n);for(const[a,d]of n)if(d===t&&a!==e){s.delete(a);break}s.set(e,t),this.map.value=s;const o=xi(...t.effects());return this.cleanupFunctions.set(t,o),i},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;this.cleanupFunctions.get(t)?.(),this.cleanupFunctions.delete(t);const i=new Map(n);i.delete(e),this.map.value=i}}[Symbol.iterator](){return this.map.peek().values()}get value(){return this.map.value.values()}has(e){return this.map.value.has(e)}get(e){return this.map.value.get(e)}destroy(){for(const e of this)this.cleanupFunctions.get(e)?.(),e.destroy();this.map.value=new Map}},wu,ku,Su,$u,ju,Mu,Ho,at,Ka,Ga,Ya,Wt=class extends(Ho=Is,Mu=[ae],ju=[ae],$u=[ae],Su=[ze],ku=[ze],wu=[ze],Ho){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,d=hu(n,["modifiers","type","sensors","plugins","effects"]);super(Fa(La({},d),{effects:()=>{var f;return[...(f=a?.())!=null?f:[],()=>{const{manager:c,plugins:l}=this;if(!(!c||!l))for(const u of l){const{plugin:p}=ai(u);c.registry.plugins.register(p)}}]}}),t),te(at,5,this),me(this,Ka,te(at,8,this)),te(at,11,this),me(this,Ga,te(at,12,this)),te(at,15,this),me(this,Ya,te(at,16,this,this.isDragSource?"dragging":"idle")),te(at,19,this),this.type=i,this.sensors=s,this.modifiers=r,this.alignment=d.alignment,this.plugins=o}pluginConfig(e){if(this.plugins)for(const t of this.plugins){const n=ai(t);if(n.plugin===e)return n.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.source)==null?void 0:t.id)===this.id}};at=mr(Ho);Ka=new WeakMap;Ga=new WeakMap;Ya=new WeakMap;ce(at,4,"type",Mu,Wt,Ka);ce(at,4,"modifiers",ju,Wt,Ga);ce(at,4,"status",$u,Wt,Ya);ce(at,2,"isDropping",Su,Wt);ce(at,2,"isDragging",ku,Wt);ce(at,2,"isDragSource",wu,Wt);Tn(at,Wt);var Eu,Cu,Tu,Du,Ou,Au,Uo,Ue,Xa,Qa,Za,Ja,el,zt=class extends(Uo=Is,Au=[ae],Ou=[ae],Du=[ae],Tu=[ae],Cu=[ae],Eu=[ze],Uo){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=hu(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),te(Ue,5,this),me(this,Xa,te(Ue,8,this)),te(Ue,11,this),me(this,Qa,te(Ue,12,this)),te(Ue,15,this),me(this,Za,te(Ue,16,this)),te(Ue,19,this),me(this,Ja,te(Ue,20,this)),te(Ue,23,this),me(this,el,te(Ue,24,this)),te(Ue,27,this),this.accept=r,this.collisionDetector=i,this.collisionPriority=s,this.type=o}accepts(e){const{accept:t}=this;return t?typeof t=="function"?t(e):e.type?Array.isArray(t)?t.includes(e.type):e.type===t:!1:!0}get isDropTarget(){var e,t;return((t=(e=this.manager)==null?void 0:e.dragOperation.target)==null?void 0:t.id)===this.id}};Ue=mr(Uo);Xa=new WeakMap;Qa=new WeakMap;Za=new WeakMap;Ja=new WeakMap;el=new WeakMap;ce(Ue,4,"accept",Au,zt,Xa);ce(Ue,4,"type",Ou,zt,Qa);ce(Ue,4,"collisionDetector",Du,zt,Za);ce(Ue,4,"collisionPriority",Tu,zt,Ja);ce(Ue,4,"shape",Cu,zt,el);ce(Ue,2,"isDropTarget",Eu,zt);Tn(Ue,zt);var Dv=class{constructor(){this.registry=new Map}addEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));return r.add(t),n.set(e,r),()=>this.removeEventListener(e,t)}removeEventListener(e,t){const{registry:n}=this,r=new Set(n.get(e));r.delete(t),n.set(e,r)}dispatch(e,...t){const{registry:n}=this,r=n.get(e);if(r)for(const i of r)i(...t)}},Ov=class extends Dv{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Ui(e,t=!0){let n=!1;return Fa(La({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var Av=class extends wi{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=xi(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||Is.pendingIdChanges)return;const o=Ui({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;oe(()=>{var d;a?.id!==((d=e.dragOperation.target)==null?void 0:d.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},gr=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(gr||{}),vr=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(vr||{}),Pu,Ru,Iu,Nu,Wu,zu,Lu,St,tl;Lu=[ae],zu=[ze],Wu=[ze],Nu=[ze],Iu=[ze],Ru=[ze],Pu=[ze];var Kt=class{constructor(){te(St,5,this),me(this,tl,te(St,8,this,"idle")),te(St,11,this)}get current(){return this.value}get idle(){return this.value==="idle"}get initializing(){return this.value==="initializing"}get initialized(){const{value:e}=this;return e!=="idle"&&e!=="initialization-pending"}get dragging(){return this.value==="dragging"}get dropped(){return this.value==="dropped"}set(e){this.value=e}};St=mr(null);tl=new WeakMap;ce(St,4,"value",Lu,Kt,tl);ce(St,2,"current",zu,Kt);ce(St,2,"idle",Wu,Kt);ce(St,2,"initializing",Nu,Kt);ce(St,2,"initialized",Iu,Kt);ce(St,2,"dragging",Ru,Kt);ce(St,2,"dropped",Pu,Kt);Tn(St,Kt);var Pv=class{constructor(e){this.manager=e}setDragSource(e){const{dragOperation:t}=this.manager;t.sourceIdentifier=typeof e=="string"||typeof e=="number"?e:e.id}setDropTarget(e){return oe(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Ui({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return oe(()=>{const{dragOperation:t}=this.manager;if(e.source!=null&&this.setDragSource(e.source),!t.source)throw new Error("Cannot start a drag operation without a drag source");if(!t.status.idle)throw new Error("Cannot start a drag operation while another is active");const n=new AbortController,{event:r,coordinates:i}=e;De(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});const s=Ui({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",s),s.defaultPrevented?(t.reset(),n.abort(),n):(t.status.set("initializing"),t.controller=n,this.manager.renderer.rendering.then(()=>{if(n.signal.aborted)return;const{status:o}=t;o.current==="initializing"&&De(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return oe(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Ui({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,d,f,c,l;if(o.defaultPrevented)return;const u=(l=e.to)!=null?l:{x:r.position.current.x+((d=(a=e.by)==null?void 0:a.x)!=null?d:0),y:r.position.current.y+((c=(f=e.by)==null?void 0:f.y)!=null?c:0)};r.position.current=u})})}stop(e={}){return oe(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:i}=r;if(!i||i.signal.aborted)return;let s;const o=()=>{const d={resume:()=>{},abort:()=>{}};return s=new Promise((f,c)=>{d.resume=f,d.abort=c}),d};i.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const d=oe(()=>{var c;return((c=r.source)==null?void 0:c.status)==="dropping"}),f=()=>{r.controller===i&&(r.controller=void 0),r.reset()};if(d){const{source:c}=r,l=$t(()=>{c?.status==="idle"&&(l(),f())})}else this.manager.renderer.rendering.then(f)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),s?s.then(a).catch(()=>r.reset()):a()})}},rr=class extends it{constructor(e,t){super(e,t),this.manager=e,this.options=t}},Rv=class extends AbortController{constructor(e,t){super(),this.constraints=e,this.onActivate=t,this.activated=!1;for(const n of e??[])n.controller=this}onEvent(e){var t;if(!this.activated)if((t=this.constraints)!=null&&t.length)for(const n of this.constraints)n.onEvent(e);else this.activate(e)}activate(e){this.activated||(this.activated=!0,this.onActivate(e))}abort(e){this.activated=!1,super.abort(e)}},Vi,Fu=class{constructor(e){this.options=e,me(this,Vi)}set controller(e){xt(this,Vi,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=We(this,Vi))==null||t.activate(e)}};Vi=new WeakMap;var ac=class extends it{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Iv=class{constructor(e){this.draggables=new oc,this.droppables=new oc,this.plugins=new eo(e),this.sensors=new eo(e),this.modifiers=new eo(e)}register(e,t){if(e instanceof Wt)return this.draggables.register(e.id,e);if(e instanceof zt)return this.droppables.register(e.id,e);if(e.prototype instanceof ac)return this.modifiers.register(e,t);if(e.prototype instanceof rr)return this.sensors.register(e,t);if(e.prototype instanceof it)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Is)return e instanceof Wt?this.draggables.unregister(e.id,e):e instanceof zt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof ac)return this.modifiers.unregister(e);if(e.prototype instanceof rr)return this.sensors.unregister(e);if(e.prototype instanceof it)return this.plugins.unregister(e);throw new Error("Invalid instance type")}destroy(){this.draggables.destroy(),this.droppables.destroy(),this.plugins.destroy(),this.sensors.destroy(),this.modifiers.destroy()}},Bu,_u,qu,Hu,Uu,Vu,Ku,Gu,Yu,Rr,Ki,_n,Te,nl,rl,il,sl,ol,Ir;Yu=[ze],Gu=[ae],Ku=[ae],Vu=[ae],Uu=[ae],Hu=[ae],qu=[ze],_u=[ze],Bu=[ze];var Pt=class{constructor(e){te(Te,5,this),me(this,Rr),me(this,Ki),me(this,_n,new Cn(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Kt,me(this,nl,te(Te,8,this,!1)),te(Te,11,this),me(this,rl,te(Te,12,this,null)),te(Te,15,this),me(this,il,te(Te,16,this,null)),te(Te,19,this),me(this,sl,te(Te,20,this,null)),te(Te,23,this),me(this,ol,te(Te,24,this,[])),te(Te,27,this),this.position=new Rs({x:0,y:0}),me(this,Ir,{x:0,y:0}),xt(this,Rr,e)}get shape(){const{current:e,initial:t,previous:n}=We(this,_n);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?We(this,_n).current=e:We(this,_n).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=We(this,Rr).registry.draggables.get(t);return n&&xt(this,Ki,n),(e=n??We(this,Ki))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=We(this,Rr).registry.droppables.get(t))!=null?e:null}get transform(){const{x:e,y:t}=this.position.delta;let n={x:e,y:t};for(const r of this.modifiers)n=r.apply(Fa(La({},this.snapshot()),{transform:n}));return xt(this,Ir,n),n}snapshot(){return oe(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:We(this,Ir),shape:this.shape?Js(this.shape):null,position:Js(this.position),status:Js(this.status),canceled:this.canceled}))}reset(){De(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,We(this,_n).reset(),this.position.reset({x:0,y:0}),xt(this,Ir,{x:0,y:0}),this.modifiers=[]})}};Te=mr(null);Rr=new WeakMap;Ki=new WeakMap;_n=new WeakMap;nl=new WeakMap;rl=new WeakMap;il=new WeakMap;sl=new WeakMap;ol=new WeakMap;Ir=new WeakMap;ce(Te,2,"shape",Yu,Pt);ce(Te,4,"canceled",Gu,Pt,nl);ce(Te,4,"activatorEvent",Ku,Pt,rl);ce(Te,4,"sourceIdentifier",Vu,Pt,il);ce(Te,4,"targetIdentifier",Uu,Pt,sl);ce(Te,4,"modifiers",Hu,Pt,ol);ce(Te,2,"source",qu,Pt);ce(Te,2,"target",_u,Pt);ce(Te,2,"transform",Bu,Pt);Tn(Te,Pt);var Nv={get rendering(){return Promise.resolve()}};function At(e,t){return typeof e=="function"?e(t):e??t}var Wv=class{constructor(e){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(l=>l.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var t;const n=e??{},r=At(n.plugins,[]),i=At(n.sensors,[]),s=At(n.modifiers,[]),o=(t=n.renderer)!=null?t:Nv,a=new Ov(this),d=new Iv(this);this.registry=d,this.monitor=a,this.renderer=o,this.actions=new Pv(this),this.dragOperation=new Pt(this),this.collisionObserver=new Tv(this),this.plugins=[Av,...r],this.modifiers=s,this.sensors=i;const{destroy:f}=this,c=xi(()=>{var l,u,p;const g=oe(()=>this.dragOperation.modifiers),v=this.modifiers;for(const b of g)v.includes(b)||b.destroy();this.dragOperation.modifiers=(p=(u=(l=this.dragOperation.source)==null?void 0:l.modifiers)==null?void 0:u.map(b=>{const{plugin:w,options:h}=ai(b);return new w(this,h)}))!=null?p:v});this.destroy=()=>{c(),f()}}get plugins(){return this.registry.plugins.values}set plugins(e){this.registry.plugins.values=e}get modifiers(){return this.registry.modifiers.values}set modifiers(e){this.registry.modifiers.values=e}get sensors(){return this.registry.sensors.values}set sensors(e){this.registry.sensors.values=e}},Xu=e=>{throw TypeError(e)},al=(e,t,n)=>t.has(e)||Xu("Cannot "+n),ee=(e,t,n)=>(al(e,t,"read from private field"),t.get(e)),ut=(e,t,n)=>t.has(e)?Xu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),gt=(e,t,n,r)=>(al(e,t,"write to private field"),t.set(e,n),n),Qu=(e,t,n)=>(al(e,t,"access private method"),n);function Ns(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Zu(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(Ns(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function Ws(e){const{width:t,height:n,top:r,left:i,bottom:s,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:i,bottom:s,right:o}}function ll(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ki(e){return"nodeType"in e}function bt(e){var t,n,r;return e?ll(e)?e:ki(e)?"defaultView"in e?(t=e.defaultView)!=null?t:window:(r=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?r:window:window:window}function cl(e){const{Document:t}=bt(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function on(e){return!e||ll(e)?!1:e instanceof bt(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Ju(e){return e instanceof bt(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function xr(e){return e?ll(e)?e.document:ki(e)?cl(e)?e:on(e)||Ju(e)?e.ownerDocument:document:document:document}function zv(e){var t,n,r,i;const{documentElement:s}=xr(e),o=bt(e).visualViewport,a=(t=o?.width)!=null?t:s.clientWidth,d=(n=o?.height)!=null?n:s.clientHeight,f=(r=o?.offsetTop)!=null?r:0,c=(i=o?.offsetLeft)!=null?i:0;return{top:f,left:c,right:c+a,bottom:f+d,width:a,height:d}}function Lv(e,t){if(Fv(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function Fv(e){return e.tagName==="DETAILS"}function ci(e,t=e.getBoundingClientRect(),n=0){var r,i,s,o,a;let d=t;const{ownerDocument:f}=e,c=(r=f.defaultView)!=null?r:window;let l=e.parentElement;for(;l&&l!==f.documentElement;){if(!Lv(l)){const x=l.getBoundingClientRect(),y=n*(x.bottom-x.top),k=n*(x.right-x.left),C=n*(x.bottom-x.top),$=n*(x.right-x.left);d={top:Math.max(d.top,x.top-y),right:Math.min(d.right,x.right+k),bottom:Math.min(d.bottom,x.bottom+C),left:Math.max(d.left,x.left-$),width:0,height:0},d.width=d.right-d.left,d.height=d.bottom-d.top}l=l.parentElement}const u=c.visualViewport,p=(i=u?.offsetTop)!=null?i:0,g=(s=u?.offsetLeft)!=null?s:0,v=(o=u?.width)!=null?o:c.innerWidth,b=(a=u?.height)!=null?a:c.innerHeight,w=n*b,h=n*v;return d={top:Math.max(d.top,p-w),right:Math.min(d.right,g+v+h),bottom:Math.min(d.bottom,p+b+w),left:Math.max(d.left,g-h),width:0,height:0},d.width=d.right-d.left,d.height=d.bottom-d.top,d.width<0&&(d.width=0),d.height<0&&(d.height=0),d}function ir(e){return{x:e.clientX,y:e.clientY}}var eh=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Vo(e=document,t=new Set){if(t.has(e))return[];t.add(e);const n=[e];for(const r of Array.from(e.querySelectorAll("iframe, frame")))try{const i=r.contentDocument;i&&!t.has(i)&&n.push(...Vo(i,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const i=r.parent;i&&i.document&&i.document!==e&&n.push(...Vo(i.document,t))}}catch{}return n}function dl(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function th(){var e,t;const n=dl()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function ul(e){return!e||!ki(e)?!1:e instanceof bt(e).ShadowRoot}function ps(e){if(e&&ki(e)){let t=e.getRootNode();if(ul(t)||t instanceof Document)return t}return xr(e)}function hl(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Bv(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((i,s)=>{const o=r[s];lc(i)&&lc(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),cc(i)&&cc(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function lc(e){return"value"in e}function cc(e){return e.tagName==="CANVAS"}function nh(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(_v(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return nh(i,{x:t-s,y:n-o})}}return r}function _v(e){return e?.tagName==="IFRAME"}var Ko=new WeakMap;function qv(e){return e.closest(`
2
2
  input:not([disabled]),
3
3
  select:not([disabled]),
4
4
  textarea:not([disabled]),
@@ -16,7 +16,7 @@ SPDX-License-Identifier: MIT
16
16
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
17
17
  />
18
18
  <title>Malloy Publisher</title>
19
- <script type="module" crossorigin src="/assets/index-DYqHxLwV.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-iyvwQg3j.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-DUqldpo0.css">
21
21
  </head>
22
22
  <body>
@@ -164831,7 +164831,7 @@ var init_telemetry = __esm(() => {
164831
164831
  });
164832
164832
 
164833
164833
  // package.json
164834
- var version = "0.10.1";
164834
+ var version = "0.10.2";
164835
164835
  var init_package = () => {};
164836
164836
 
164837
164837
  // src/version.ts