@malloy-publisher/app 0.9.11 → 0.9.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{g as ef,b as tf,r as S,u as nf,b6 as rf,k as sf,i as of,b7 as af,l as lf,j as m,f as cf,h as df,s as ta,m as uf,t as vl,Z as hf,V as _e,b8 as Vt,b9 as fs,aD as tt,ae as Ze,L as lt,K as _n,ba as zn,ak as ke,bb as na,bc as ti,bd as Hi,be as ff,bf as pf,bg as mf,bh as gf,bi as vf,T as fe,as as it,bj as bf,bk as xf,bl as yf,O as ra,aK as wf,bm as Lt,bn as kf,bo as ia,bp as Sf,bq as sa,br as Oc,bs as $f,bt as jf,a0 as Qs,bu as Cf,bv as Mf,bw as bl,bx as mi,aX as Tc,I as H,B as Dc,by as Be,aJ as bt,bz as ot,bA as oa,bB as Ef,bC as Wn,U as Of,bD as aa,bE as Tf,ag as Df,bF as Af,bG as Rf,bH as Pf,bI as If,bJ as zf,bK as Ac,bL as Wf,bM as Nf,bN as Rc,bO as Pc,bP as Ic,bQ as Lf,bR as Ff,bS as Bf,bT as _f,bU as Hf,bV as Uf,bW as qf,bX as Kf,bY as Gf,F as Yf,bZ as Vf,b_ as Xf,b$ as eo,c0 as to,c1 as xl,c2 as Jf,c3 as Zf,c4 as Qf,c5 as ep,c6 as cn,c7 as tp,c8 as np,c9 as rp,ca as zc,cb as la,cc as ip,cd as sp,ce as Wc,cf as op,cg as ap,ch as lp,ci as qt,cj as cp,ck as dp,cl as Nc,cm as up,cn as hp,aP as ca,aF as Ft,co as no,cp as fp,cq as pp,Y as Ui,X as mp,cr as gp,cs as vp,ct as ro,cu as bp,cv as xp,cw as yp,cx as Lc,cy as wp,cz as kp,cA as Sp,cB as $p,cC as jp,cD as da,cE as Cp,cF as ua,aT as Mp,cG as Ep,cH as Op,cI as Tp,cJ as Dp,cK as Ap,cL as xn,cM as yl,cN as wl,cO as Ds,cP as Rp,S as Pp,cQ as Ip,cR as zp,cS as Wp,cT as Np,cU as Fc,aj as Lp}from"./index-gQEuz0Cg.js";import{cV as T0,cW as D0,cX as A0,cY as R0,cZ as P0,c_ as I0,c$ as z0,d0 as W0,d1 as N0,d2 as L0,d3 as F0}from"./index-gQEuz0Cg.js";import{T as ps,a as un}from"./ToggleButtonGroup-TKxhg0Mg.js";function Fp(e){return ef("MuiCollapse",e)}tf("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);const Bp=e=>{const{orientation:t,classes:n}=e,r={root:["root",`${t}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${t}`],wrapperInner:["wrapperInner",`${t}`]};return df(r,Fp,n)},_p=ta("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]}})(uf(({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"}}]}))),Hp=ta("div",{name:"MuiCollapse",slot:"Wrapper"})({display:"flex",width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),Up=ta("div",{name:"MuiCollapse",slot:"WrapperInner"})({width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),io=S.forwardRef(function(t,n){const r=nf({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:y,orientation:k="vertical",style:h,timeout:b=rf.standard,TransitionComponent:x=sf,...w}=r,$={...r,orientation:k,collapsedSize:a},E=Bp($),D=of(),O=af(),j=S.useRef(null),P=S.useRef(),R=typeof a=="number"?`${a}px`:a,A=k==="horizontal",L=A?"width":"height",U=S.useRef(null),_=lf(n,U),T=N=>Z=>{if(N){const pe=U.current;Z===void 0?N(pe):N(pe,Z)}},z=()=>j.current?j.current[A?"clientWidth":"clientHeight"]:0,F=T((N,Z)=>{j.current&&A&&(j.current.style.position="absolute"),N.style[L]=R,l&&l(N,Z)}),W=T((N,Z)=>{const pe=z();j.current&&A&&(j.current.style.position="");const{duration:ne,easing:Q}=vl({style:h,timeout:b,easing:f},{mode:"enter"});if(b==="auto"){const Se=D.transitions.getAutoHeightDuration(pe);N.style.transitionDuration=`${Se}ms`,P.current=Se}else N.style.transitionDuration=typeof ne=="string"?ne:`${ne}ms`;N.style[L]=`${pe}px`,N.style.transitionTimingFunction=Q,p&&p(N,Z)}),B=T((N,Z)=>{N.style[L]="auto",u&&u(N,Z)}),X=T(N=>{N.style[L]=`${z()}px`,g&&g(N)}),J=T(v),re=T(N=>{const Z=z(),{duration:pe,easing:ne}=vl({style:h,timeout:b,easing:f},{mode:"exit"});if(b==="auto"){const Q=D.transitions.getAutoHeightDuration(Z);N.style.transitionDuration=`${Q}ms`,P.current=Q}else N.style.transitionDuration=typeof pe=="string"?pe:`${pe}ms`;N.style[L]=R,N.style.transitionTimingFunction=ne,y&&y(N)}),ee=N=>{b==="auto"&&O.start(P.current||0,N),i&&i(U.current,N)};return m.jsx(x,{in:c,onEnter:F,onEntered:B,onEntering:W,onExit:X,onExited:J,onExiting:re,addEndListener:ee,nodeRef:U,timeout:b==="auto"?null:b,...w,children:(N,{ownerState:Z,...pe})=>m.jsx(_p,{as:d,className:cf(E.root,o,{entered:E.entered,exited:!c&&R==="0px"&&E.hidden}[N]),style:{[A?"minWidth":"minHeight"]:R,...h},ref:_,ownerState:{...$,state:N},...pe,children:m.jsx(Hp,{ownerState:{...$,state:N},className:E.wrapper,ref:j,children:m.jsx(Up,{ownerState:{...$,state:N},className:E.wrapperInner,children:s})})})})});io&&(io.muiSupportAuto=!0);var kl={};const Bc=ot(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"})),_c=ot(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"})),so=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),dn=so?"⌘":"Ctrl+",Sl=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},As=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function qp(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=so?s.metaKey:s.ctrlKey,d=s.key.toLowerCase();if(s.key==="Escape"){if(Sl(s.target)||As(s.target))return;o.escape();return}if(Sl(s.target)){if(a&&d==="s"){if(s.preventDefault(),!o.save||As(s.target))return;s.target.blur(),r(!0)}return}if(As(s.target)){a&&d==="s"&&s.preventDefault();return}if(a&&d==="z"){s.preventDefault(),s.shiftKey?o.redo():o.undo();return}if(!so&&a&&d==="y"){s.preventDefault(),o.redo();return}if(a&&d==="s"){s.preventDefault(),o.save?.();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 Pr=(e,t,n=oa)=>({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}}}),qi=(e=oa)=>({width:e.size.control,height:e.size.control,borderRadius:e.radius.control,"& svg":{fontSize:18}}),Ir={height:20,alignSelf:"center",mx:.5,my:0},Hn=(e,t=oa)=>({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"}}}),oo={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function Kp({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,onExit:u,layout:p,onLayoutChange:g}){const{theme:v}=_e(),y=Vt(v.cardBorder),k=fs(v.cardBorder,v.tileTitle);return m.jsxs(tt,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[p&&g&&m.jsxs(m.Fragment,{children:[m.jsx(lt,{title:"Layout: tiles side by side, or one after another",children:m.jsxs(ps,{size:"small",exclusive:!0,value:p,"aria-label":"Layout",onChange:(h,b)=>{b&&b!==p&&g(b)},sx:Hn(y,v.ui),children:[m.jsx(un,{value:"linear","aria-label":"Linear layout",children:"Linear"}),m.jsx(un,{value:"grid","aria-label":"Grid layout",children:"Grid"})]})}),m.jsx(zn,{orientation:"vertical",sx:Ir})]}),l&&m.jsx(ke,{variant:"outlined",startIcon:m.jsx(ti,{}),onClick:l,"aria-label":"Add tile",sx:Pr(y,k,v.ui),children:"Tile"}),l&&m.jsx(zn,{orientation:"vertical",sx:Ir}),m.jsx(lt,{title:`Undo (${dn}Z)`,children:m.jsx("span",{children:m.jsx(_n,{"aria-label":"Undo",disabled:!e,onClick:n,sx:qi(v.ui),children:m.jsx(_c,{fontSize:"small"})})})}),m.jsx(lt,{title:`Redo (${dn}⇧Z)`,children:m.jsx("span",{children:m.jsx(_n,{"aria-label":"Redo",disabled:!t,onClick:r,sx:qi(v.ui),children:m.jsx(Bc,{fontSize:"small"})})})}),(c||o||u)&&m.jsx(zn,{orientation:"vertical",sx:Ir}),c,o?m.jsx(lt,{title:i?`Save (${dn}S) · ${d??oo[a]}`:d??oo[a],children:m.jsx("span",{children:m.jsx(ke,{ref:f,variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{...Pr(y,k,v.ui),minWidth:88},children:s?"Saving…":i?"Save":"Saved"})})}):null,o&&m.jsx(H,{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"}),u&&m.jsx(Of,{label:"Close",icon:m.jsx(aa,{}),onClick:u})]})}const Gp={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function Hc(e,t,n){const r=i=>{if(t!==i){if(i==="big_value")return e?.aggregateOnly===!0?void 0:"Needs a view with only totals (no group by)";if(i==="shape_map"||i==="segment_map")return e?.chart===i?void 0:"Needs a view that already carries a map chart"}};return[{value:"default",label:"From the view"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"].map(i=>{const s=r(i);return{value:i,label:Gp[i],...s?{disabled:!0,reason:s}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function $l(e){return e.description??zp(e.name)}const Yp={bar_chart:"a bar chart",line_chart:"a line chart",scatter_chart:"a scatter chart",shape_map:"a shape map",segment_map:"a segment map",big_value:"a big value",sparkline:"a sparkline"},gi=(e,t)=>`${e}\0${t}`;function Vp({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s,onAddText:o,renderPreview:a}){const{theme:d}=_e(),f=d.ui,c=Vt(d.cardBorder),l=S.useMemo(()=>n?.sources??[],[n]),[u,p]=S.useState(""),[g,v]=S.useState(),[y,k]=S.useState(""),[h,b]=S.useState("default"),x=S.useRef(null),w=S.useMemo(()=>{const T=new Set(t.sources.map(z=>z.base));return[...l].sort((z,F)=>Number(T.has(F.name))-Number(T.has(z.name)))},[l,t]),$=w.filter(T=>T.views.length>0),E=w.filter(T=>T.views.length===0),D=S.useMemo(()=>new Map($.flatMap(T=>T.views.map(z=>[gi(T.name,z.name),{source:T,view:z,key:gi(T.name,z.name)}]))),[$]),O=S.useMemo(()=>$.map(T=>({key:T.name,label:T.name,...T.description?{detail:T.description}:{},entries:T.views.map(z=>({key:gi(T.name,z.name),name:z.name,title:$l(z),...z.chart?{chart:z.chart}:{}}))})),[$]),j=g===void 0?void 0:D.get(g);S.useEffect(()=>{if(!e)return;p(""),k(""),b("default");const T=$[0]?.views[0];v(T&&$[0]?gi($[0].name,T.name):void 0)},[e]);const P=j?[j.source.name,j.view.name].filter(T=>!ro(T)).map(T=>`"${T}" is not a plain Malloy name, so a tile cannot be written for it.`)[0]:void 0,R=j!==void 0&&P===void 0,A=j?$l(j.view):"",L=h!=="default"&&j?{chart:h,chartCarried:j.view.chart?[j.view.chart]:[]}:{},U=(T=j)=>{if(!T||![T.source.name,T.view.name].every(ro))return;const z=T.key===j?.key;s({base:T.source.name,modelPath:T.source.modelPath,...T.source.exporters?{exporters:T.source.exporters}:{},view:T.view.name,...z&&y.trim()?{label:y.trim()}:{},...z?L:{},colspan:Math.ceil(r/2)})},_=j?Hc(j.view,h).filter(T=>T.value!=="custom"&&T.disabled!==!0):[];return m.jsx(ca,{className:`${Ze.dialog} ${Ze.addTileDialog}`,open:e,onClose:i,maxWidth:"md",initialFocus:x,title:"Add a tile",description:"Pick a view from this package. You can change its title and chart now or later.",actions:m.jsxs(m.Fragment,{children:[m.jsx(ke,{onClick:o,sx:{mr:"auto"},children:"Add text instead"}),m.jsx(ke,{onClick:i,children:"Cancel"}),m.jsx(ke,{variant:"contained",disabled:!R,onClick:()=>U(),children:"Add tile"})]}),children:m.jsxs(H,{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(H,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${c}`},maxHeight:{xs:280,md:"none"}},children:m.jsx(bp,{groups:O,query:u,onQuery:p,picked:j?.key,onPick:T=>{v(T),b("default")},onTake:T=>U(D.get(T)),searchRef:x,empty:m.jsx(fe,{variant:"body2",sx:{color:d.tileTitle,p:2},children:n?"This package publishes no source with a view to put on a tile.":"The package's sources are still loading."}),footer:E.length>0&&m.jsxs(fe,{variant:"caption",component:"p",sx:{color:"text.secondary",px:2,pt:1.5},children:["Also in this package, with no views to show:"," ",E.map(T=>T.name).join(", "),"."]})})}),m.jsx(H,{sx:T=>({p:2.5,display:"flex",flexDirection:"column",gap:2,minHeight:0,overflowY:"auto",bgcolor:`color-mix(in srgb, ${T.palette.text.primary} 3%, ${T.palette.background.paper})`}),children:j?m.jsxs(m.Fragment,{children:[m.jsx(H,{"aria-label":"Preview",role:"region",sx:T=>({height:240,flex:"none",display:"flex",position:"relative",overflow:"hidden",borderRadius:f.radius.tile,border:`1px solid ${c}`,bgcolor:T.palette.background.paper,"&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,height:40,pointerEvents:"none",background:`linear-gradient(to bottom, transparent, ${T.palette.background.paper})`}}),children:a?m.jsx(H,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:a({base:j.source.name,modelPath:j.source.modelPath,view:j.view.name,label:y.trim()||A,...h!=="default"?L:{},givens:j.source.givens})}):m.jsxs(H,{sx:T=>({flex:1,border:`1px solid ${c}`,borderRadius:f.radius.tile,bgcolor:T.palette.background.paper,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,color:"text.secondary"}),children:[m.jsx(xp,{chart:j.view.chart}),m.jsxs(fe,{variant:"body2",children:[j.source.name," → ",j.view.name]})]})}),m.jsx(Ft,{size:"small",label:"Title",placeholder:A,value:y,onChange:T=>k(T.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Tile title"}}),m.jsxs(H,{children:[m.jsx(fe,{component:"div",sx:{...f.type.label,color:"text.secondary",mb:.75},children:"Chart"}),m.jsx(ps,{size:"small",exclusive:!0,value:h,"aria-label":"Chart",onChange:(T,z)=>{z!==null&&b(z)},sx:{...Hn(c,f),"& .MuiToggleButton-root":{...Hn(c,f)["& .MuiToggleButton-root"],textTransform:"none"}},children:_.map(T=>m.jsx(un,{value:T.value,children:T.label},T.value))}),m.jsx(fe,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:j.view.chart?`The view declares ${Yp[j.view.chart]??"a chart"}.`:"The view declares no chart, so it shows as a table."})]}),P&&m.jsx(fe,{variant:"body2",color:"error",children:P})]}):m.jsx(fe,{variant:"body2",sx:{color:"text.secondary",m:"auto"},children:"Pick a view to see it here."})})]})})}const De=e=>e.kind==="text",de=e=>e.kind!=="text",pr=e=>de(e)?e.label??e.name:e.name,Ie=e=>De(e)?`text.${e.name}`:`${e.source}.${e.name}`;function Xp(e,t,{modelPath:n,textHeld:r,widths:i,insertAt:s}){t.modelPath&&!r&&(e.imports=Rp(e,t.base,t.modelPath,n,t.exporters??[t.modelPath]));const o=Uc(e,t.base),a=ao(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?{colspan:t.colspan}:{},...t.label?{label:t.label}:{},...t.chart?{chart:t.chart}:{},...t.chartCarried?{chartCarried:t.chartCarried}:{}})}function Uc(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 ao(e,t,n){const r=new Set(e.tiles.filter(de).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 Ki(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.`;default:return e.chart==="custom"?"Its chart line is one the builder does not write, so a copy would lose it.":void 0}}function Jp(e,t){const n=e.tiles[t];if(!n||!de(n)||Ki(n)!==void 0)return;let r;if(n.declaration.kind==="reference"){const{break:i,...s}=structuredClone(n);r={...s,name:ao(e,n.source,n.declaration.from)}}else{const i=e.sources.find(s=>s.name===n.source)??Uc(e,n.source,{unscoped:!0});r={name:ao(e,i.name,n.name),source:i.name,declaration:{kind:"reference",from:n.name},...n.colspan!==void 0?{colspan:n.colspan}:{}}}return e.tiles.splice(t+1,0,r),t+1}const vi="self";function Zp({open:e,document:t,source:n,givenNames:r,dashboards:i,tileLabel:s,onClose:o,onApply:a}){const{theme:d}=_e(),f=d.ui,[c,l]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(b=>b.source===n.name);l((n.dimensions??[]).map(b=>{const x=h.find(w=>w.name===b.name);return{name:b.name,expression:b.expression,to:x?.to??[],given:x?.given??""}}))},[e,n,t]);const u=(h,b)=>l(x=>x.map((w,$)=>{if($!==h)return w;const E={...w};return b(E),E})),p=[vi,...i.filter(h=>h!==vi)],g=h=>h===vi?"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())},y=Vt(d.cardBorder),k=(h,b)=>u(h,x=>{b?x.to=x.lastTo?.length?x.lastTo:[vi]:(x.lastTo=x.to,x.to=[])});return m.jsx(ca,{className:`${Ze.dialog} ${Ze.clickableCellsDialog}`,open:e,onClose:o,title:"Clickable cells",description:m.jsxs(m.Fragment,{children:[s&&m.jsxs(H,{component:"span",sx:{fontWeight:f.type.label.fontWeight},children:[s," ·"," "]}),"A click on a cell sets a filter to its value, on this report or on the one it opens."]}),actions:m.jsxs(m.Fragment,{children:[m.jsx(ke,{onClick:o,children:"Cancel"}),m.jsx(ke,{variant:"contained",onClick:v,disabled:c.length===0,children:"Apply"})]}),children:c.length===0?m.jsx(fe,{variant:"body2",sx:{color:d.tileTitle,pt:1},children:n?m.jsxs(m.Fragment,{children:[m.jsx(H,{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(H,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):m.jsx(H,{role:"list","aria-label":"Dimensions",children:c.map((h,b)=>{const x=h.to.length>0;return m.jsxs(H,{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:b===0?"none":`1px solid ${y}`},children:[m.jsx(vp,{size:"small",checked:x,onChange:w=>k(b,w.target.checked),slotProps:{input:{"aria-label":`${h.name} is clickable`}}}),m.jsxs(H,{sx:{minWidth:0},children:[m.jsx(H,{sx:{...f.type.control,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Qp(h.name)}),m.jsxs(H,{title:h.expression,sx:{...f.type.code,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[h.name," is ",h.expression]})]}),x?m.jsxs(tt,{direction:"row",sx:{gridColumn:{xs:"1 / -1",sm:"auto"},alignItems:"center",gap:1,justifyContent:"flex-end",...f.type.control},children:[m.jsx(H,{component:"span",sx:{color:"text.secondary"},children:"Opens"}),m.jsx(Ft,{select:!0,size:"small",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:w=>w.map(g).join(", ")},onChange:w=>u(b,$=>{const E=w.target.value,D=Array.isArray(E)?E:String(E).split(",").filter(Boolean);D.length===0&&($.lastTo=$.to),$.to=D}),sx:{flex:"1 1 150px",minWidth:0,maxWidth:200},children:p.map(w=>m.jsxs(bt,{value:w,children:[m.jsx(no,{size:"small",checked:h.to.includes(w),sx:{p:0,mr:1}}),m.jsx(Ui,{primary:g(w)})]},w))}),m.jsx(H,{component:"span",sx:{color:"text.secondary"},children:"sets"}),m.jsxs(Ft,{select:!0,size:"small",value:h.given,inputProps:{"aria-label":`Control ${h.name} sets`},SelectProps:{displayEmpty:!0,renderValue:w=>w===""?h.name:String(w)},onChange:w=>u(b,$=>{$.given=w.target.value}),sx:{flex:"1 1 120px",minWidth:0,maxWidth:170},children:[m.jsx(bt,{value:"",children:m.jsx(Ui,{primary:h.name,secondary:"Named like the dimension"})}),r.map(w=>m.jsx(bt,{value:w,children:w},w))]})]}):m.jsx(fe,{variant:"body2",sx:{color:"text.secondary",textAlign:"right",display:{xs:"none",sm:"block"}},children:"Not clickable"})]},h.name)})})})}function Qp(e){const t=e.replace(/_+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const em=ot(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"})),tm=ot(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"})),nm=ot(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"})),rm=ot(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"})),im=ot(m.jsx("path",{d:"M4 9h16v2H4zm0 4h10v2H4z"})),sm=ot(m.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33v-4h3.33zM19 17h-3.33v-4H19zm0-6h-8.67V7H19z"}));function om(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of de(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 Gi(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function am(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function zr(e,t){const n=am(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 lo(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 lm(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const cm=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function dm(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=Fc(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 um=[{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 vr(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 co=e=>de(e)&&e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function hm(e,t){return e.tiles.map(n=>{const r=(de(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}:Gi(t.type)!==void 0?{op:Gi(t.type)}:{}}})}function fm(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!co(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 pm(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 mm(e,t){for(const r of e.tiles){if(!de(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 uo=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function gm({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"),[y,k]=S.useState(""),[h,b]=S.useState(""),[x,w]=S.useState([]),[$,E]=S.useState(!1),[D,O]=S.useState(!1),j=M=>t.sources.find(I=>I.name===M.source)?.base??M.source;S.useEffect(()=>{if(e)if(O(n!==void 0),n){l({kind:"existing",name:n.name}),p(n.label??"");const M=hm(t,n);w(M);const I=M.filter(C=>C.include),q=new Set(I.map(C=>C.field));b(q.size===1?I[0].field:n.field??""),E(q.size>1)}else l({kind:"new"}),p(""),v("select"),b(""),k(new Date().toISOString().slice(0,10)),w(t.tiles.map(M=>({include:co(M),field:""}))),E(!1)},[e,n,t]);const P=S.useMemo(()=>[...(t.localGivens??[]).map(M=>M.name),...r.map(M=>M.name),...i],[t,r,i]),R=S.useMemo(()=>h.trim()?dm(h.trim(),P):"",[h,P]),A=c.kind==="existing"?n??r.find(M=>M.name===c.name):R?{name:R,type:vr({name:R,label:u,kind:g,field:h}).type}:void 0,L=A?.type!==void 0&&!A.type.startsWith("filter<"),U=x.find(M=>M.include)?.op??Gi(A?.type),_=(M,I)=>{O(!0),w(q=>q.map((C,te)=>te===M?{...C,...I}:C))},T=M=>{O(!0),w(I=>I.map(q=>({...q,op:M})))},z=M=>{const I=Gi(M);w(q=>q.map(({op:C,...te})=>I?{...te,op:I}:te))},F=M=>{O(!0),l({kind:"existing",name:M.name}),b(M.field??""),z(M.type)},W=M=>{O(!0),v(M),z(vr({name:"X",label:u,kind:M,field:h}).type)},B=t.tiles.map(co),X=B.filter(Boolean).length,J=x.filter((M,I)=>M.include&&B[I]).length,re=t.tiles.filter((M,I)=>(x[I]?.include??!1)&&B[I]&&de(M)),ee=re.length>0?re:t.tiles.filter((M,I)=>B[I]&&de(M)),N=S.useMemo(()=>{const M=new Map;let I=!1;for(const q of ee){const C=s?.(q);if(C){I=!0;for(const te of C)M.has(te.name)||M.set(te.name,te)}}return I?[...M.values()]:void 0},[x,t.tiles,s]),Z=(()=>{const M=h.trim();for(const I of re){const q=s?.(I);if(!q||q.some(C=>C.name===M))return j(I)}return re[0]?j(re[0]):t.sources[0]?.base})(),pe=M=>{O(!0),w(I=>I.map((q,C)=>({...q,include:M&&B[C]})))},ne=S.useMemo(()=>$?x:x.map(M=>({...M,field:h})),[$,x,h]),Q=M=>{for(const I of ee){const q=s?.(I)?.find(C=>C.name===M.trim());if(q?.type)return q.type}},Se=M=>zr(A?.type,M.type),be=(M,I)=>{if(M.trim()==="")return"Pick the field this filter compares.";const q=I?s?.(I):void 0;if(!q)return;const C=q.find(te=>te.name===M.trim());if(!C)return`Not a field of ${I?j(I):"the tiles' source"}.`;if(C.type&&!zr(A?.type,C.type))return`${M.trim()} is ${lo(C.type)}; this filter compares ${lo(A?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},G=M=>{if(O(!0),b(M),f||c.kind!=="new")return;const I=Q(M),q=vr({name:"X",label:u,kind:g,field:M}).type;I&&!zr(q,I)&&W(lm(I))},$e=M=>{const I=t.tiles[M];return I&&de(I)?I:void 0},he=ne.map((M,I)=>M.include&&B[I]?be(M.field,$e(I)):void 0),ie=he.every(M=>M===void 0),Ne=D?he:he.map(()=>{}),Ke=D&&!$&&J>0?re.map(M=>be(h,M)).find(Boolean):void 0,He=A!==void 0&&ie&&(c.kind==="existing"||h.trim()!==""&&R!==""),Ge=()=>{if(!(!A||!He))if(c.kind==="new")o(A.name,ne,vr({name:A.name,label:u.trim()||uo(A.name),kind:g,field:h.trim(),...Z?{source:Z}:{},...y?{dateDefault:y}:{}}));else if(n?.origin==="dashboard"&&n.local){const M=u.trim(),I=M!==(n.local.label??"");o(A.name,ne,I?{...n.local,...M?{label:M}:{}}:void 0)}else o(A.name,ne)},Ye=f&&d.origin==="model";return{editing:f,shown:d,fromModel:Ye,source:c,setSource:l,label:u,setLabel:p,kind:g,dateDefault:y,setDateDefault:k,field:h,rows:x,setRows:w,perTile:$,setPerTile:E,newName:R,target:A,valueTyped:L,commonOp:U,setRow:_,setCommonOp:T,pickExisting:F,pickKind:W,bindable:B,bindableCount:X,included:J,commonFields:N,setAll:pe,accepts:Se,pickField:G,rowProblems:Ne,commonProblem:Ke,canApply:He,apply:Ge}}function jl({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(Ip,{freeSolo:!0,size:"small",options:p,inputValue:e,onInputChange:(v,y)=>t(y),value:e,onChange:(v,y)=>t(typeof y=="string"?y:""),disabled:d,disableClearable:!0,renderOption:(v,y)=>S.createElement("li",{...v,key:y},m.jsx(Ml,{type:g.get(y)}),m.jsx(fe,{variant:"body2",sx:{flex:1,ml:1},children:y})),renderInput:v=>m.jsx(Ft,{...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(H,{sx:{display:"flex",ml:.5,mr:-.25},children:m.jsx(Ml,{type:g.get(e.trim())})}):void 0},inputProps:{...v.inputProps,"aria-label":s}}),sx:u})}const vm=e=>e&&de(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:{label:"From the model",reason:"Declared on its source, which this report does not write."};function bm({open:e,document:t,control:n,available:r,takenNames:i,fieldsFor:s,onClose:o,onApply:a,onRemove:d}){const{theme:f}=_e(),c=f.ui,{editing:l,shown:u,fromModel:p,source:g,setSource:v,label:y,setLabel:k,kind:h,dateDefault:b,setDateDefault:x,field:w,rows:$,setRows:E,perTile:D,setPerTile:O,newName:j,target:P,valueTyped:R,commonOp:A,setRow:L,setCommonOp:U,pickExisting:_,pickKind:T,bindable:z,bindableCount:F,included:W,commonFields:B,setAll:X,accepts:J,pickField:re,rowProblems:ee,commonProblem:N,canApply:Z,apply:pe}=gm({open:e,document:t,control:n,available:r,...i?{takenNames:i}:{},fieldsFor:s,onApply:a}),ne=S.useRef(null),Q=Vt(f.cardBorder),Se=fs(f.cardBorder,f.tileTitle),[be,G]=S.useState(!1),[$e,he]=S.useState(!1);S.useEffect(()=>{e?he(!0):G(!1)},[e]),S.useEffect(()=>{$e&&(he(!1),G(l&&W<F))},[$e]),S.useEffect(()=>{D&&G(!0)},[D]);const ie=B?.find(M=>M.name===w.trim())?.type,Ne=M=>{if(!ie)return;const I=vr({name:"X",label:y,kind:M,field:w}).type;return zr(I,ie)?void 0:`${w.trim()} is ${lo(ie)}, which this control cannot filter.`},Ke=y.trim()||(j?uo(j):"Filter"),He=h==="number"?"Any":h==="date"?b?new Date(`${b}T00:00:00`).toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"}):"Any":"All",Ge={...Hn(Q,c),alignSelf:"flex-start","& .MuiToggleButton-root":{...Hn(Q,c)["& .MuiToggleButton-root"],textTransform:"none"}},Ye=(M,I,q)=>m.jsx(Ft,{select:!0,size:"small",label:"Compares",value:M??">=",onChange:C=>I(C.target.value),inputProps:{"aria-label":q},sx:{width:130},children:cm.filter(C=>C.op!=="~").map(C=>m.jsx(bt,{value:C.op,children:C.label},C.op))});return m.jsx(ca,{className:`${Ze.dialog} ${Ze.filterDialog}`,open:e,onClose:o,...l?{}:{initialFocus:ne},title:l?u.label??u.name:"Add a filter",description:l?m.jsxs(m.Fragment,{children:[m.jsxs(H,{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(ke,{color:"error",startIcon:m.jsx(pp,{}),onClick:()=>d(u.name),sx:M=>({mr:"auto",color:fp(M)}),children:"Remove filter"}),m.jsx(ke,{onClick:o,children:"Cancel"}),m.jsx(lt,{title:Z||P===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:m.jsx("span",{children:m.jsx(ke,{variant:"contained",onClick:pe,disabled:!Z,children:l?"Apply":"Add filter"})})})]}),children:m.jsxs(tt,{sx:{gap:2.5,pt:1},children:[!l&&r.length>0&&m.jsxs(ps,{exclusive:!0,size:"small",value:g.kind,onChange:(M,I)=>{I==="new"?v({kind:"new"}):I==="existing"&&r[0]&&_(r[0])},"aria-label":"Where the filter comes from",sx:Ge,children:[m.jsx(un,{value:"new",children:"New in this report"}),m.jsx(un,{value:"existing",children:"From the model"})]}),!l&&g.kind==="existing"?m.jsx(Ft,{select:!0,size:"small",label:"Filter",value:g.name,onChange:M=>{const I=r.find(q=>q.name===M.target.value);I&&_(I)},children:r.map(M=>m.jsxs(bt,{value:M.name,children:[M.label??M.name,m.jsxs(fe,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",M.name]})]},M.name))}):null,m.jsxs(H,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:p?"1fr":"minmax(0, 1.4fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[!D&&m.jsx(jl,{value:w,onChange:re,fields:B,accepts:J,label:"Field",ariaLabel:"Field to filter",placeholder:"category",inputRef:ne,error:N!==void 0,helperText:N??(!l&&j?`Declared as $${j}`:void 0)}),!p&&m.jsx(Ft,{size:"small",label:"Label",placeholder:j?uo(j):"",value:y,onChange:M=>k(M.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Filter label"}})]}),R&&!D&&Ye(A,U,"Comparison"),!l&&g.kind==="new"&&m.jsxs(H,{children:[m.jsx(Cl,{children:"Control"}),m.jsx(H,{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:um.map(M=>{const I=M.kind===h,q=Ne(M.kind);return m.jsx(lt,{title:q??M.hint,describeChild:!0,children:m.jsxs(Dc,{role:"radio","aria-checked":I,"aria-label":M.label,"aria-disabled":q!==void 0,onClick:()=>{q===void 0&&T(M.kind)},sx:C=>({flexDirection:"column",gap:.5,px:1,py:1.25,borderRadius:c.radius.tile,border:`1px solid ${I?f.accent:Q}`,boxShadow:I?`0 0 0 1px ${f.accent}`:"none",bgcolor:I?`color-mix(in srgb, ${f.accent} 6%, ${C.palette.background.paper})`:C.palette.background.paper,color:I?f.accent:C.palette.text.secondary,opacity:q?.45:1,cursor:q?"default":"pointer",transition:`border-color ${Be}, background-color ${Be}`,"&:hover":q||I?{}:{borderColor:Se}}),children:[m.jsx(ym,{kind:M.kind}),m.jsx(H,{component:"span",sx:{...c.type.caption,fontWeight:I?600:500,color:I?f.accent:"text.primary",textAlign:"center"},children:xm[M.kind]})]})},M.kind)})}),h==="date"&&m.jsx(Ft,{size:"small",type:"date",label:"Starts at",value:b,onChange:M=>x(M.target.value),InputLabelProps:{shrink:!0},sx:{mt:1.5,width:200}})]}),m.jsxs(H,{sx:{border:`1px solid ${Q}`,borderRadius:c.radius.tile,overflow:"hidden"},children:[m.jsxs(tt,{direction:"row",sx:{alignItems:"center",gap:1.25,px:1.5,py:1},children:[m.jsx(sm,{"aria-hidden":!0,sx:{fontSize:18,color:"text.secondary"}}),m.jsxs(fe,{variant:"body2",sx:{flex:1,minWidth:0},children:[m.jsx(H,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:W===F&&F>0?`Applies to all ${W} tile${W===1?"":"s"}`:`Applies to ${W} of ${F} tile${F===1?"":"s"}`}),!D&&w.trim()!==""&&W>0&&m.jsxs(H,{component:"span",sx:{color:"text.secondary"},children:[" · each filters on ",m.jsx(H,{component:"span",sx:{...c.type.code},children:w.trim()})]})]}),!D&&m.jsx(ke,{size:"small","aria-expanded":be,onClick:()=>G(M=>!M),children:be?"Done choosing":"Choose tiles"})]}),m.jsx(io,{in:be,unmountOnExit:!0,children:m.jsxs(H,{sx:{borderTop:`1px solid ${Q}`,px:.5,pb:1},children:[m.jsxs(tt,{direction:"row",sx:{alignItems:"center",gap:.5,pt:.5},children:[m.jsx(no,{size:"small",checked:F>0&&W===F,indeterminate:W>0&&W<F,disabled:F===0,onChange:M=>X(M.target.checked),inputProps:{"aria-label":"All tiles"}}),m.jsx(fe,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:"All tiles"}),m.jsx(ke,{size:"small",onClick:()=>{D||E(M=>M.map(I=>({...I,field:w}))),O(M=>!M)},children:D?"Same field for all":"Adjust per tile"})]}),m.jsx(tt,{sx:{gap:D?1:0},children:t.tiles.map((M,I)=>{if(!de(M))return null;const q=$[I],C=M.label??M.name,te=D?ee[I]:void 0;return m.jsxs(tt,{direction:"row",sx:{gap:1,alignItems:D?"flex-start":"center",opacity:z[I]?1:.6},children:[m.jsx(no,{size:"small",disabled:!z[I],checked:(q?.include??!1)&&z[I],inputProps:{"aria-label":`Filter ${C}`},onChange:K=>L(I,{include:K.target.checked})}),m.jsx(fe,{variant:"body2",sx:{flex:1,minWidth:0,pt:D?1:0},noWrap:!0,children:C}),z[I]?D&&m.jsxs(m.Fragment,{children:[R&&Ye(q?.op,K=>L(I,{op:K}),`Comparison for ${C}`),m.jsx(jl,{value:q?.field??"",onChange:K=>L(I,{field:K}),fields:s?.(M),accepts:J,label:"Field",ariaLabel:`Field for ${C}`,disabled:!q?.include,error:te!==void 0,helperText:te,sx:{width:220,pr:1}})]}):m.jsx(fe,{variant:"caption",sx:{color:f.tileTitle,pr:1,maxWidth:260,textAlign:"right"},children:vm(t.tiles[I]).reason})]},`${M.source}.${M.name}`)})})]})})]}),W===0&&m.jsx(fe,{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(H,{children:[m.jsx(Cl,{children:"Preview"}),m.jsx(H,{sx:M=>({display:"flex",alignItems:"center",gap:1,p:1.5,borderRadius:c.radius.tile,bgcolor:M.palette.action.hover}),children:m.jsxs(H,{"aria-hidden":!0,sx:M=>({display:"inline-flex",alignItems:"center",gap:.75,height:30,px:1.25,borderRadius:c.radius.control,border:`1px solid ${Q}`,bgcolor:M.palette.background.paper,...c.type.control}),children:[m.jsx(H,{component:"span",sx:{color:"text.secondary"},children:Ke}),m.jsx(H,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:He}),m.jsx(na,{sx:{fontSize:16,color:"text.secondary"}})]})})]})]})})}function Cl({children:e}){const t=_e().theme.ui;return m.jsx(fe,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}const xm={select:"Pick one",multiselect:"Pick several",text:"Text",number:"Range",date:"Date"};function ym({kind:e}){const t={fontSize:22};switch(e){case"select":return m.jsx(em,{sx:t});case"multiselect":return m.jsx(tm,{sx:t});case"text":return m.jsx(im,{sx:t});case"number":return m.jsx(rm,{sx:t});case"date":return m.jsx(nm,{sx:t})}}function Ml({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=_e().theme.ui;return n?m.jsx(H,{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 wm=ot(m.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}));function qc(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 km=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.`,Sm="Declared on its source, so its chart is set in the model.";function $m({anchor:e,tile:t,onClose:n,onCommit:r,onDrills:i,onDuplicate:s,duplicateBlocked:o,view:a}){const{theme:d}=_e(),f=d.ui,{draft:c,apply:l,close:u}=qc(t,e!==null,r,n),[p,g]=S.useState(void 0),v=c!==void 0&&de(c)?c:void 0,y=v!==void 0&&v.declaration.kind!=="inherited",k=P=>l(R=>{de(R)&&P(R)}),h=S.useRef(void 0),b=e!==null;S.useEffect(()=>{b?h.current=t&&de(t)?t.chart:void 0:g(void 0)},[b]);const x=v?.chart??"default",w=Hc(a,x),$=v?y?v.chart==="custom"?km(v.chartLines):void 0:Sm:void 0,E=P=>k(R=>{const A=h.current;P===(A??"default")?(A===void 0?delete R.chart:R.chart=A,delete R.chartCarried):(R.chart=P,a?R.chartCarried=a.chart?[a.chart]:[]:delete R.chartCarried)}),D=y?i?void 0:"Its source declares no dimension a click could filter by.":void 0,O=P=>R=>g({kind:P,anchor:R.currentTarget}),j=(P,R,A)=>m.jsxs(m.Fragment,{children:[m.jsx(Ui,{primary:P,...A?{secondary:A}:{},secondaryTypographyProps:{sx:{whiteSpace:"normal",maxWidth:240}}}),R&&m.jsx(fe,{variant:"body2",sx:{color:"text.secondary",ml:2},children:R})]});return m.jsxs(m.Fragment,{children:[m.jsxs(Hi,{className:Ze.menu,open:e!==null&&c!==void 0,anchorEl:e,onClose:u,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":v?`${v.source} ${v.name}`:"Tile"},slotProps:{paper:{sx:{minWidth:240,mt:.5,borderRadius:f.radius.menu,border:`1px solid ${Vt(d.cardBorder)}`,boxShadow:f.shadow.menu}}},children:[v&&m.jsxs(bt,{"aria-haspopup":"menu","aria-expanded":p?.kind==="chart",disabled:$!==void 0,onClick:O("chart"),onKeyDown:P=>{P.key==="ArrowRight"&&$===void 0&&g({kind:"chart",anchor:P.currentTarget})},children:[j("Chart",$?void 0:w.find(P=>P.value===x)?.label,$),m.jsx(wm,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),y&&m.jsx(bt,{"aria-haspopup":"dialog",disabled:D!==void 0,onClick:()=>{u(),i?.()},children:j("Clickable cells…",void 0,D)}),v&&s&&m.jsx(bt,{disabled:o!==void 0,onClick:()=>{u(),s()},children:j("Duplicate",void 0,o)}),v?.declaration.kind==="opaque"&&m.jsxs(fe,{variant:"body2",sx:{color:d.tileTitle,px:2,py:.75,maxWidth:260},children:["Its body is ",v.declaration.why,", so a filter has no single place to go."]}),v&&m.jsx(zn,{}),v&&m.jsxs(H,{"aria-hidden":!0,sx:{px:2,py:.5,...f.type.code,color:"text.secondary"},children:[v.source," → ",v.name]})]}),m.jsx(Hi,{className:Ze.menu,open:p?.kind==="chart",anchorEl:p?.anchor??null,onClose:()=>g(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":"Chart",onKeyDown:P=>{P.key==="ArrowLeft"&&(P.preventDefault(),g(void 0))}},children:w.filter(P=>P.value!=="custom").map(P=>m.jsxs(bt,{role:"menuitemradio","aria-checked":P.value===x,disabled:P.disabled===!0,onClick:()=>{E(P.value),g(void 0)},children:[m.jsx(Ui,{primary:P.label,...P.reason?{secondary:P.reason}:{}}),P.value===x&&m.jsx(mp,{sx:{minWidth:0,ml:2},children:m.jsx(aa,{fontSize:"small",sx:{color:d.accent}})})]},P.value))})]})}const Nn=e=>e.label??gp(`${e.source} -> ${e.name}`);function jm({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,y]=S.useState(),k=p===void 0?void 0:e.document.tiles[p.index],h=k&&de(k)?k:void 0,b=(()=>{if(!h||!t)return;const x=e.document.sources.find($=>$.name===h.source)?.base??h.source,w=h.declaration.kind==="reference"?h.declaration.from:h.name;return t.sources.find($=>$.name===x)?.views.find($=>$.name===w)})();return m.jsxs(m.Fragment,{children:[m.jsx(bm,{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($m,{anchor:p?.anchor??null,tile:p===void 0?void 0:e.document.tiles[p.index],onClose:()=>g(void 0),onCommit:x=>{const w=p?.index;w!==void 0&&e.update($=>{$.tiles[w]=x})},view:b,onDuplicate:()=>{p&&s.duplicate(p.index)},...h&&Ki(h)!==void 0?{duplicateBlocked:Ki(h)}:{},...(e.document.sources.find(x=>x.name===h?.source)?.dimensions?.length??0)>0?{onDrills:()=>{y(h?Nn(h):void 0),a(h?.source)}}:{}}),m.jsx(Zp,{open:o!==void 0,document:e.document,source:e.document.sources.find(x=>x.name===o),givenNames:i.controlList.map(x=>x.name),dashboards:r??[],...v?{tileLabel:v}:{},onClose:()=>a(void 0),onApply:x=>e.update(w=>{const $=[...(w.drills??[]).filter(E=>E.source!==o),...x];$.length===0?delete w.drills:w.drills=$})}),m.jsx(Df,{...d}),m.jsx(Vp,{open:s.addingTile,document:e.document,catalog:t,columns:n,onClose:s.closeAdd,onAdd:s.addTile,onAddText:s.addText,...f?{renderPreview:f}:{}})]})}var Cm=Symbol.for("preact-signals");function ms(){if(Tt>1)Tt--;else{var e,t=!1;for((function(){var i=Vi;for(Vi=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}})();Nr!==void 0;){var n=Nr;for(Nr=void 0,Yi++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Gc(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(Yi=0,Tt--,t)throw e}}function Me(e){if(Tt>0)return e();ho=++Mm,Tt++;try{return e()}finally{ms()}}var Wr,xe=void 0;function ae(e){var t=xe,n=Wr;xe=void 0,Wr=void 0;try{return e()}finally{xe=t,Wr=n}}var Nr=void 0,Tt=0,Yi=0,Mm=0,ho=0,Vi=void 0,Xi=0;function Kc(e){if(xe!==void 0){var t=e.n;if(t===void 0||t.t!==xe)return t={i:0,S:e,p:xe.s,n:void 0,t:xe,e:void 0,x:void 0,r:t},xe.s!==void 0&&(xe.s.n=t),xe.s=t,e.n=t,32&xe.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=xe.s,t.n=void 0,xe.s.n=t,xe.s=t),t}}function Qe(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}Qe.prototype.brand=Cm;Qe.prototype.h=function(){return!0};Qe.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:ae(function(){var r;(r=t.W)==null||r.call(t)}))};Qe.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&&ae(function(){var i;(i=t.Z)==null||i.call(t)}))}};Qe.prototype.subscribe=function(e){var t=this;return pt(function(){var n=t.value;ae(function(){return e(n)})},{name:"sub"})};Qe.prototype.valueOf=function(){return this.value};Qe.prototype.toString=function(){return this.value+""};Qe.prototype.toJSON=function(){return this.value};Qe.prototype.peek=function(){var e=this;return ae(function(){return e.value})};Object.defineProperty(Qe.prototype,"value",{get:function(){var e=Kc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Yi>100)throw new Error("Cycle detected");(function(n){Tt!==0&&Yi===0&&n.l!==ho&&(n.l=ho,Vi={S:n,v:n.v,i:n.i,o:Vi})})(this),this.v=e,this.i++,Xi++,Tt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ms()}}}});function Xn(e,t){return new Qe(e,t)}function Gc(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 Yc(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 Vc(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 pn(e,t){Qe.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Xi-1,this.f=4}pn.prototype=new Qe;pn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Xi))return!0;if(this.g=Xi,this.f|=1,this.i>0&&!Gc(this))return this.f&=-2,!0;var e=xe;try{Yc(this),xe=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 xe=e,Vc(this),this.f&=-2,!0};pn.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)}Qe.prototype.S.call(this,e)};pn.prototype.U=function(e){if(this.t!==void 0&&(Qe.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)}};pn.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(pn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Kc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function El(e,t){return new pn(e,t)}function Xc(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Tt++;var n=xe;xe=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,ha(e),r}finally{xe=n,ms()}}}function ha(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Xc(e)}function Em(e){if(xe!==this)throw new Error("Out-of-order effect");Vc(this),xe=e,this.f&=-2,8&this.f&&ha(this),ms()}function Jn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Wr&&Wr.push(this)}Jn.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()}};Jn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Xc(this),Yc(this),Tt++;var e=xe;return xe=this,Em.bind(this,e)};Jn.prototype.N=function(){2&this.f||(this.f|=2,this.u=Nr,Nr=this)};Jn.prototype.d=function(){this.f|=8,1&this.f||ha(this)};Jn.prototype.dispose=function(){this.d()};function pt(e,t){var n=new Jn(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Om=Object.create,fa=Object.defineProperty,Tm=Object.defineProperties,Dm=Object.getOwnPropertyDescriptor,Am=Object.getOwnPropertyDescriptors,Ol=Object.getOwnPropertySymbols,Rm=Object.prototype.hasOwnProperty,Pm=Object.prototype.propertyIsEnumerable,Im=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Zn=e=>{throw TypeError(e)},fo=(e,t,n)=>t in e?fa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zm=(e,t)=>{for(var n in t||(t={}))Rm.call(t,n)&&fo(e,n,t[n]);if(Ol)for(var n of Ol(t))Pm.call(t,n)&&fo(e,n,t[n]);return e},Wm=(e,t)=>Tm(e,Am(t)),Tl=(e,t)=>fa(e,"name",{value:t,configurable:!0}),Nm=e=>{var t;return[,,,Om((t=void 0)!=null?t:null)]},Jc=["class","method","getter","setter","accessor","field","value","get","set"],br=e=>e!==void 0&&typeof e!="function"?Zn("Function expected"):e,Lm=(e,t,n,r,i)=>({kind:Jc[e],name:t,metadata:r,addInitializer:s=>n._?Zn("Already initialized"):i.push(br(s||null))}),Zc=(e,t)=>fo(t,Im("metadata"),e[3]),Jt=(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},Qn=(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=Jc[l+5],y=l>3&&(e[g-1]=[]),k=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&Dm(l<4?i:{get[n](){return ct(this,s)},set[n](x){return Nt(this,s,x)}},n));l?p&&l<4&&Tl(s,(l>2?"set ":l>1?"get ":"")+n):Tl(i,n);for(var b=r.length-1;b>=0;b--)f=Lm(l,n,d={},e[3],k),l&&(f.static=u,f.private=p,c=f.access={has:p?x=>Fm(i,x):x=>n in x},l^3&&(c.get=p?x=>(l^1?ct:Bm)(x,i,l^4?s:h.get):x=>x[n]),l>2&&(c.set=p?(x,w)=>Nt(x,i,w,l^4?s:h.set):(x,w)=>x[n]=w)),a=(0,r[b])(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?br(a)&&(l>4?y.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?Zn("Object expected"):(br(o=a.get)&&(h.get=o),br(o=a.set)&&(h.set=o),br(o=a.init)&&y.unshift(o));return l||Zc(e,i),h&&fa(i,n,h),p?l^4?s:h:i},pa=(e,t,n)=>t.has(e)||Zn("Cannot "+n),Fm=(e,t)=>Object(t)!==t?Zn('Cannot use the "in" operator on this value'):e.has(t),ct=(e,t,n)=>(pa(e,t,"read from private field"),n?n.call(e):t.get(e)),xr=(e,t,n)=>t.has(e)?Zn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Nt=(e,t,n,r)=>(pa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Bm=(e,t,n)=>(pa(e,t,"access private method"),n);function po(e,t){if(t){let n;return El(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return El(e)}function gt(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)=>!gt(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=>!gt(e[i],t[i]))}return!1}function le({get:e},t){return{init(n){return Xn(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Oe(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 Rs(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,Wm(zm({},i),{enumerable:e}))})}}function ni(...e){const t=e.map(n=>pt(n));return()=>t.forEach(n=>n())}var Qc,ed,td,nd,rd,id,Ve,ma,Ps,mo,go,Ue,ga,Is,sd,vo,va,zs,bo,xo;id=[le],rd=[le],nd=[le],td=[Rs()],ed=[Rs()],Qc=[Rs()];var mn=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Jt(Ve,5,this),xr(this,Ue),xr(this,ma,Jt(Ve,8,this)),Jt(Ve,11,this),xr(this,ga,Jt(Ve,12,this)),Jt(Ve,15,this),xr(this,va,Jt(Ve,16,this)),Jt(Ve,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return ct(this,Ue,bo)}get initial(){return ct(this,Ue,mo)}get previous(){return ct(this,Ue,sd)}set current(e){const t=ae(()=>ct(this,Ue,bo));e&&t&&this.equals(t,e)||Me(()=>{ct(this,Ue,mo)||Nt(this,Ue,e,go),Nt(this,Ue,t,vo),Nt(this,Ue,e,xo)})}reset(e=this.defaultValue){Me(()=>{Nt(this,Ue,void 0,vo),Nt(this,Ue,e,go),Nt(this,Ue,e,xo)})}};Ve=Nm();ma=new WeakMap;Ue=new WeakSet;ga=new WeakMap;va=new WeakMap;Ps=Qn(Ve,20,"#initial",id,Ue,ma),mo=Ps.get,go=Ps.set;Is=Qn(Ve,20,"#previous",rd,Ue,ga),sd=Is.get,vo=Is.set;zs=Qn(Ve,20,"#current",nd,Ue,va),bo=zs.get,xo=zs.set;Qn(Ve,2,"current",td,mn);Qn(Ve,2,"initial",ed,mn);Qn(Ve,2,"previous",Qc,mn);Zc(Ve,mn);function Ws(e){return ae(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Zt,_m=class{constructor(){xr(this,Zt,new WeakMap)}get(e,t){var n;return e?(n=ct(this,Zt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return ct(this,Zt).has(e)||ct(this,Zt).set(e,new Map),(r=ct(this,Zt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=ct(this,Zt).get(e))==null?void 0:t.clear():void 0}};Zt=new WeakMap;var Hm=Object.create,od=Object.defineProperty,Um=Object.getOwnPropertyDescriptor,Dl=Object.getOwnPropertySymbols,qm=Object.prototype.hasOwnProperty,Km=Object.prototype.propertyIsEnumerable,ad=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),gs=e=>{throw TypeError(e)},Al=Math.pow,yo=(e,t,n)=>t in e?od(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gm=(e,t)=>{for(var n in t||(t={}))qm.call(t,n)&&yo(e,n,t[n]);if(Dl)for(var n of Dl(t))Km.call(t,n)&&yo(e,n,t[n]);return e},Ym=e=>{var t;return[,,,Hm((t=e?.[ad("metadata")])!=null?t:null)]},ld=["class","method","getter","setter","accessor","field","value","get","set"],cd=e=>e!==void 0&&typeof e!="function"?gs("Function expected"):e,Vm=(e,t,n,r,i)=>({kind:ld[e],name:t,metadata:r,addInitializer:s=>n._?gs("Already initialized"):i.push(cd(s||null))}),Xm=(e,t)=>yo(t,ad("metadata"),e[3]),Jm=(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},dd=(e,t,n,r,i,s)=>{for(var o,a,d,f,c=t&7,l=!1,u=!1,p=2,g=ld[c+5],v=e[p]||(e[p]=[]),y=(i=i.prototype,Um(i,n)),k=r.length-1;k>=0;k--)d=Vm(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[k])(y[g],d),a._=1,cd(o)&&(y[g]=o);return y&&od(i,n,y),i},ud=(e,t,n)=>t.has(e)||gs("Cannot "+n),Zm=(e,t,n)=>(ud(e,t,"read from private field"),t.get(e)),Qm=(e,t,n)=>t.has(e)?gs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),eg=(e,t,n,r)=>(ud(e,t,"write to private field"),t.set(e,n),n),dt=class wo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new wo(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 wo(t,n)}},jt=class Qt{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 Qt(i+t,r+n,s,o);return d.scale=Gm({},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 dt((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Qt))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 Qt?tg(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 Qt(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 dt.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return Qt.from(t).intersectionRatio(Qt.from(n))}};function tg(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 hd,fd,ko,Oi,ri,vs=class extends(ko=mn,fd=[Oe],hd=[Oe],ko){constructor(e){const t=dt.from(e);super(t,(n,r)=>dt.equals(n,r)),Jm(ri,5,this),Qm(this,Oi,0),this.velocity={x:0,y:0}}get delta(){return dt.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=dt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-Zm(this,Oi),o=a=>Math.round(a/s*100);Me(()=>{eg(this,Oi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(dt.from(e)),this.velocity={x:0,y:0}}};ri=Ym(ko);Oi=new WeakMap;dd(ri,2,"delta",fd,vs);dd(ri,2,"direction",hd,vs);Xm(ri,vs);function So({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(Al(r,2)+Al(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 pd=(e=>(e.Horizontal="x",e.Vertical="y",e))(pd||{}),md=Object.values(pd),ng=Object.create,ba=Object.defineProperty,rg=Object.defineProperties,ig=Object.getOwnPropertyDescriptor,sg=Object.getOwnPropertyDescriptors,Ji=Object.getOwnPropertySymbols,gd=Object.prototype.hasOwnProperty,vd=Object.prototype.propertyIsEnumerable,bd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),er=e=>{throw TypeError(e)},$o=(e,t,n)=>t in e?ba(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xa=(e,t)=>{for(var n in t||(t={}))gd.call(t,n)&&$o(e,n,t[n]);if(Ji)for(var n of Ji(t))vd.call(t,n)&&$o(e,n,t[n]);return e},ya=(e,t)=>rg(e,sg(t)),Rl=(e,t)=>ba(e,"name",{value:t,configurable:!0}),xd=(e,t)=>{var n={};for(var r in e)gd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ji)for(var r of Ji(e))t.indexOf(r)<0&&vd.call(e,r)&&(n[r]=e[r]);return n},tr=e=>{var t;return[,,,ng((t=e?.[bd("metadata")])!=null?t:null)]},yd=["class","method","getter","setter","accessor","field","value","get","set"],yr=e=>e!==void 0&&typeof e!="function"?er("Function expected"):e,og=(e,t,n,r,i)=>({kind:yd[e],name:t,metadata:r,addInitializer:s=>n._?er("Already initialized"):i.push(yr(s||null))}),gn=(e,t)=>$o(t,bd("metadata"),e[3]),V=(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=yd[l+5],y=l>3&&(e[g-1]=[]),k=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&ig(l<4?i:{get[n](){return Ee(this,s)},set[n](x){return st(this,s,x)}},n));l?p&&l<4&&Rl(s,(l>2?"set ":l>1?"get ":"")+n):Rl(i,n);for(var b=r.length-1;b>=0;b--)f=og(l,n,d={},e[3],k),l&&(f.static=u,f.private=p,c=f.access={has:p?x=>ag(i,x):x=>n in x},l^3&&(c.get=p?x=>(l^1?Ee:wd)(x,i,l^4?s:h.get):x=>x[n]),l>2&&(c.set=p?(x,w)=>st(x,i,w,l^4?s:h.set):(x,w)=>x[n]=w)),a=(0,r[b])(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?yr(a)&&(l>4?y.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?er("Object expected"):(yr(o=a.get)&&(h.get=o),yr(o=a.set)&&(h.set=o),yr(o=a.init)&&y.unshift(o));return l||gn(e,i),h&&ba(i,n,h),p?l^4?s:h:i},wa=(e,t,n)=>t.has(e)||er("Cannot "+n),ag=(e,t)=>Object(t)!==t?er('Cannot use the "in" operator on this value'):e.has(t),Ee=(e,t,n)=>(wa(e,t,"read from private field"),n?n.call(e):t.get(e)),ue=(e,t,n)=>t.has(e)?er("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),st=(e,t,n,r)=>(wa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),wd=(e,t,n)=>(wa(e,t,"access private method"),n);function kd(e,t){return{plugin:e,options:t}}function ii(e){return t=>kd(e,t)}function Ur(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Sd,qr,ka,Ti;Sd=[le];var qe=class{constructor(e,t){this.manager=e,this.options=t,ue(this,ka,V(qr,8,this,!1)),V(qr,11,this),ue(this,Ti,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return ae(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=pt(e.bind(this));return Ee(this,Ti).add(t),t}destroy(){Ee(this,Ti).forEach(e=>e())}static configure(e){return kd(this,e)}};qr=tr(null);ka=new WeakMap;Ti=new WeakMap;ce(qr,4,"disabled",Sd,qe,ka);gn(qr,qe);var si=class extends qe{},Di,Ns=class{constructor(e){this.manager=e,this.instances=new Map,ue(this,Di,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(Ur).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 Ee(this,Di))if(!n.includes(r)){if(r.prototype instanceof si)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);st(this,Di,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()}};Di=new WeakMap;function lg(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var bi=[],Cn,Mn,cg=class extends qe{constructor(e){super(e),ue(this,Cn),ue(this,Mn),this.computeCollisions=this.computeCollisions.bind(this),st(this,Mn,Xn(bi)),this.destroy=ni(()=>{const t=this.computeCollisions(),n=ae(()=>this.manager.dragOperation.position.current);if(t!==bi){const r=Ee(this,Cn);if(st(this,Cn,n),r&&n.x==r.x&&n.y==r.y)return}else st(this,Cn,void 0);Ee(this,Mn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){ae(()=>{e?Ee(this,Mn).value=this.computeCollisions():st(this,Cn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return bi;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=ae(()=>c({droppable:f,dragOperation:r}));l&&(f.collisionPriority!=null&&(l.priority=f.collisionPriority),a.push(l))}return d.length===0?bi:(a.sort(lg),a)}get collisions(){return Ee(this,Mn).value}};Cn=new WeakMap;Mn=new WeakMap;var $d,jd,Cd,Sa,Md,vt,$a,Rn,ja,Ca;Cd=[le],jd=[le],$d=[le];var At=class en{constructor(t,n){ue(this,$a,V(vt,8,this)),V(vt,11,this),ue(this,Rn),ue(this,ja,V(vt,12,this)),V(vt,15,this),ue(this,Ca,V(vt,16,this)),V(vt,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let d=i;st(this,Rn,Xn(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=Ee(this,Rn).value;return(n=(t=en.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=en.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Ee(this,Rn).peek();t!==i&&(en.pendingIdChanges||(en.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return wd(s=en,Sa,Md).call(s)})),en.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)}};vt=tr(null);Sa=new WeakSet;Md=function(){const e=At.pendingIdChanges;At.pendingIdChanges=null,e&&Me(()=>{for(const[t,n]of e)Ee(t,Rn).value=n})};$a=new WeakMap;Rn=new WeakMap;ja=new WeakMap;Ca=new WeakMap;ce(vt,4,"manager",Cd,At,$a);ce(vt,4,"data",jd,At,ja);ce(vt,4,"disabled",$d,At,Ca);ue(At,Sa);gn(vt,At);At.pendingIdChanges=null;var bs=At,Pl=class{constructor(){this.map=Xn(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=ni(...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}},Ed,Od,Td,Dd,Ad,Rd,jo,Xe,Ma,Ea,Oa,Ct=class extends(jo=bs,Rd=[le],Ad=[le],Dd=[le],Td=[Oe],Od=[Oe],Ed=[Oe],jo){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,d=xd(n,["modifiers","type","sensors","plugins","effects"]);super(ya(xa({},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}=Ur(u);c.registry.plugins.register(p)}}]}}),t),V(Xe,5,this),ue(this,Ma,V(Xe,8,this)),V(Xe,11,this),ue(this,Ea,V(Xe,12,this)),V(Xe,15,this),ue(this,Oa,V(Xe,16,this,this.isDragSource?"dragging":"idle")),V(Xe,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=Ur(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}};Xe=tr(jo);Ma=new WeakMap;Ea=new WeakMap;Oa=new WeakMap;ce(Xe,4,"type",Rd,Ct,Ma);ce(Xe,4,"modifiers",Ad,Ct,Ea);ce(Xe,4,"status",Dd,Ct,Oa);ce(Xe,2,"isDropping",Td,Ct);ce(Xe,2,"isDragging",Od,Ct);ce(Xe,2,"isDragSource",Ed,Ct);gn(Xe,Ct);var Pd,Id,zd,Wd,Nd,Ld,Co,Pe,Ta,Da,Aa,Ra,Pa,Mt=class extends(Co=bs,Ld=[le],Nd=[le],Wd=[le],zd=[le],Id=[le],Pd=[Oe],Co){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=xd(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),V(Pe,5,this),ue(this,Ta,V(Pe,8,this)),V(Pe,11,this),ue(this,Da,V(Pe,12,this)),V(Pe,15,this),ue(this,Aa,V(Pe,16,this)),V(Pe,19,this),ue(this,Ra,V(Pe,20,this)),V(Pe,23,this),ue(this,Pa,V(Pe,24,this)),V(Pe,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}};Pe=tr(Co);Ta=new WeakMap;Da=new WeakMap;Aa=new WeakMap;Ra=new WeakMap;Pa=new WeakMap;ce(Pe,4,"accept",Ld,Mt,Ta);ce(Pe,4,"type",Nd,Mt,Da);ce(Pe,4,"collisionDetector",Wd,Mt,Aa);ce(Pe,4,"collisionPriority",zd,Mt,Ra);ce(Pe,4,"shape",Id,Mt,Pa);ce(Pe,2,"isDropTarget",Pd,Mt);gn(Pe,Mt);var dg=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)}},ug=class extends dg{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Ai(e,t=!0){let n=!1;return ya(xa({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var hg=class extends si{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=ni(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||bs.pendingIdChanges)return;const o=Ai({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;ae(()=>{var d;a?.id!==((d=e.dragOperation.target)==null?void 0:d.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},nr=(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))(nr||{}),rr=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(rr||{}),Fd,Bd,_d,Hd,Ud,qd,Kd,ft,Ia;Kd=[le],qd=[Oe],Ud=[Oe],Hd=[Oe],_d=[Oe],Bd=[Oe],Fd=[Oe];var Pt=class{constructor(){V(ft,5,this),ue(this,Ia,V(ft,8,this,"idle")),V(ft,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}};ft=tr(null);Ia=new WeakMap;ce(ft,4,"value",Kd,Pt,Ia);ce(ft,2,"current",qd,Pt);ce(ft,2,"idle",Ud,Pt);ce(ft,2,"initializing",Hd,Pt);ce(ft,2,"initialized",_d,Pt);ce(ft,2,"dragging",Bd,Pt);ce(ft,2,"dropped",Fd,Pt);gn(ft,Pt);var fg=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 ae(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Ai({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return ae(()=>{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;Me(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});const s=Ai({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"&&Me(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return ae(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Ai({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 ae(()=>{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=ae(()=>{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=pt(()=>{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()})}},Un=class extends qe{constructor(e,t){super(e,t),this.manager=e,this.options=t}},pg=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)}},Ri,Gd=class{constructor(e){this.options=e,ue(this,Ri)}set controller(e){st(this,Ri,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ee(this,Ri))==null||t.activate(e)}};Ri=new WeakMap;var Il=class extends qe{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},mg=class{constructor(e){this.draggables=new Pl,this.droppables=new Pl,this.plugins=new Ns(e),this.sensors=new Ns(e),this.modifiers=new Ns(e)}register(e,t){if(e instanceof Ct)return this.draggables.register(e.id,e);if(e instanceof Mt)return this.droppables.register(e.id,e);if(e.prototype instanceof Il)return this.modifiers.register(e,t);if(e.prototype instanceof Un)return this.sensors.register(e,t);if(e.prototype instanceof qe)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof bs)return e instanceof Ct?this.draggables.unregister(e.id,e):e instanceof Mt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Il)return this.modifiers.unregister(e);if(e.prototype instanceof Un)return this.sensors.unregister(e);if(e.prototype instanceof qe)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()}},Yd,Vd,Xd,Jd,Zd,Qd,eu,tu,nu,wr,Pi,En,Ce,za,Wa,Na,La,Fa,kr;nu=[Oe],tu=[le],eu=[le],Qd=[le],Zd=[le],Jd=[le],Xd=[Oe],Vd=[Oe],Yd=[Oe];var wt=class{constructor(e){V(Ce,5,this),ue(this,wr),ue(this,Pi),ue(this,En,new mn(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Pt,ue(this,za,V(Ce,8,this,!1)),V(Ce,11,this),ue(this,Wa,V(Ce,12,this,null)),V(Ce,15,this),ue(this,Na,V(Ce,16,this,null)),V(Ce,19,this),ue(this,La,V(Ce,20,this,null)),V(Ce,23,this),ue(this,Fa,V(Ce,24,this,[])),V(Ce,27,this),this.position=new vs({x:0,y:0}),ue(this,kr,{x:0,y:0}),st(this,wr,e)}get shape(){const{current:e,initial:t,previous:n}=Ee(this,En);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ee(this,En).current=e:Ee(this,En).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ee(this,wr).registry.draggables.get(t);return n&&st(this,Pi,n),(e=n??Ee(this,Pi))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ee(this,wr).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(ya(xa({},this.snapshot()),{transform:n}));return st(this,kr,n),n}snapshot(){return ae(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ee(this,kr),shape:this.shape?Ws(this.shape):null,position:Ws(this.position),status:Ws(this.status),canceled:this.canceled}))}reset(){Me(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ee(this,En).reset(),this.position.reset({x:0,y:0}),st(this,kr,{x:0,y:0}),this.modifiers=[]})}};Ce=tr(null);wr=new WeakMap;Pi=new WeakMap;En=new WeakMap;za=new WeakMap;Wa=new WeakMap;Na=new WeakMap;La=new WeakMap;Fa=new WeakMap;kr=new WeakMap;ce(Ce,2,"shape",nu,wt);ce(Ce,4,"canceled",tu,wt,za);ce(Ce,4,"activatorEvent",eu,wt,Wa);ce(Ce,4,"sourceIdentifier",Qd,wt,Na);ce(Ce,4,"targetIdentifier",Zd,wt,La);ce(Ce,4,"modifiers",Jd,wt,Fa);ce(Ce,2,"source",Xd,wt);ce(Ce,2,"target",Vd,wt);ce(Ce,2,"transform",Yd,wt);gn(Ce,wt);var gg={get rendering(){return Promise.resolve()}};function yt(e,t){return typeof e=="function"?e(t):e??t}var vg=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=yt(n.plugins,[]),i=yt(n.sensors,[]),s=yt(n.modifiers,[]),o=(t=n.renderer)!=null?t:gg,a=new ug(this),d=new mg(this);this.registry=d,this.monitor=a,this.renderer=o,this.actions=new fg(this),this.dragOperation=new wt(this),this.collisionObserver=new cg(this),this.plugins=[hg,...r],this.modifiers=s,this.sensors=i;const{destroy:f}=this,c=ni(()=>{var l,u,p;const g=ae(()=>this.dragOperation.modifiers),v=this.modifiers;for(const y of g)v.includes(y)||y.destroy();this.dragOperation.modifiers=(p=(u=(l=this.dragOperation.source)==null?void 0:l.modifiers)==null?void 0:u.map(y=>{const{plugin:k,options:h}=Ur(y);return new k(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}},ru=e=>{throw TypeError(e)},Ba=(e,t,n)=>t.has(e)||ru("Cannot "+n),Y=(e,t,n)=>(Ba(e,t,"read from private field"),t.get(e)),et=(e,t,n)=>t.has(e)?ru("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rt=(e,t,n,r)=>(Ba(e,t,"write to private field"),t.set(e,n),n),iu=(e,t,n)=>(Ba(e,t,"access private method"),n);function xs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function su(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(xs(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function ys(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 _a(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function oi(e){return"nodeType"in e}function at(e){var t,n,r;return e?_a(e)?e:oi(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 Ha(e){const{Document:t}=at(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Kt(e){return!e||_a(e)?!1:e instanceof at(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function ou(e){return e instanceof at(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function ir(e){return e?_a(e)?e.document:oi(e)?Ha(e)?e:Kt(e)||ou(e)?e.ownerDocument:document:document:document}function bg(e){var t,n,r,i;const{documentElement:s}=ir(e),o=at(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 xg(e,t){if(yg(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function yg(e){return e.tagName==="DETAILS"}function Kr(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(!xg(l)){const b=l.getBoundingClientRect(),x=n*(b.bottom-b.top),w=n*(b.right-b.left),$=n*(b.bottom-b.top),E=n*(b.right-b.left);d={top:Math.max(d.top,b.top-x),right:Math.min(d.right,b.right+w),bottom:Math.min(d.bottom,b.bottom+$),left:Math.max(d.left,b.left-E),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,y=(a=u?.height)!=null?a:c.innerHeight,k=n*y,h=n*v;return d={top:Math.max(d.top,p-k),right:Math.min(d.right,g+v+h),bottom:Math.min(d.bottom,p+y+k),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 qn(e){return{x:e.clientX,y:e.clientY}}var au=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Mo(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(...Mo(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(...Mo(i.document,t))}}catch{}return n}function Ua(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function lu(){var e,t;const n=Ua()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function qa(e){return!e||!oi(e)?!1:e instanceof at(e).ShadowRoot}function Zi(e){if(e&&oi(e)){let t=e.getRootNode();if(qa(t)||t instanceof Document)return t}return ir(e)}function Ka(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function wg(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];zl(i)&&zl(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),Wl(i)&&Wl(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function zl(e){return"value"in e}function Wl(e){return e.tagName==="CANVAS"}function cu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(kg(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return cu(i,{x:t-s,y:n-o})}}return r}function kg(e){return e?.tagName==="IFRAME"}var Eo=new WeakMap;function Sg(e){return e.closest(`
1
+ import{g as ef,b as tf,r as S,u as nf,b6 as rf,k as sf,i as of,b7 as af,l as lf,j as m,f as cf,h as df,s as ta,m as uf,t as vl,Z as hf,V as _e,b8 as Vt,b9 as fs,aD as tt,ae as Ze,L as lt,K as _n,ba as zn,ak as ke,bb as na,bc as ti,bd as Hi,be as ff,bf as pf,bg as mf,bh as gf,bi as vf,T as fe,as as it,bj as bf,bk as xf,bl as yf,O as ra,aK as wf,bm as Lt,bn as kf,bo as ia,bp as Sf,bq as sa,br as Oc,bs as $f,bt as jf,a0 as Qs,bu as Cf,bv as Mf,bw as bl,bx as mi,aX as Tc,I as H,B as Dc,by as Be,aJ as bt,bz as ot,bA as oa,bB as Ef,bC as Wn,G as Of,bD as aa,bE as Tf,ag as Df,bF as Af,bG as Rf,bH as Pf,bI as If,bJ as zf,bK as Ac,bL as Wf,bM as Nf,bN as Rc,bO as Pc,bP as Ic,bQ as Lf,bR as Ff,bS as Bf,bT as _f,bU as Hf,bV as Uf,bW as qf,bX as Kf,bY as Gf,F as Yf,bZ as Vf,b_ as Xf,b$ as eo,c0 as to,c1 as xl,c2 as Jf,c3 as Zf,c4 as Qf,c5 as ep,c6 as cn,c7 as tp,c8 as np,c9 as rp,ca as zc,cb as la,cc as ip,cd as sp,ce as Wc,cf as op,cg as ap,ch as lp,ci as qt,cj as cp,ck as dp,cl as Nc,cm as up,cn as hp,aP as ca,aF as Ft,co as no,cp as fp,cq as pp,Y as Ui,X as mp,cr as gp,cs as vp,ct as ro,cu as bp,cv as xp,cw as yp,cx as Lc,cy as wp,cz as kp,cA as Sp,cB as $p,cC as jp,cD as da,cE as Cp,cF as ua,aT as Mp,cG as Ep,cH as Op,cI as Tp,cJ as Dp,cK as Ap,cL as xn,cM as yl,cN as wl,cO as Ds,cP as Rp,S as Pp,cQ as Ip,cR as zp,cS as Wp,cT as Np,cU as Fc,aj as Lp}from"./index-5On9Gkpl.js";import{cV as T0,cW as D0,cX as A0,cY as R0,cZ as P0,c_ as I0,c$ as z0,d0 as W0,d1 as N0,d2 as L0,d3 as F0}from"./index-5On9Gkpl.js";import{T as ps,a as un}from"./ToggleButtonGroup-C6Lespxy.js";function Fp(e){return ef("MuiCollapse",e)}tf("MuiCollapse",["root","horizontal","vertical","entered","hidden","wrapper","wrapperInner"]);const Bp=e=>{const{orientation:t,classes:n}=e,r={root:["root",`${t}`],entered:["entered"],hidden:["hidden"],wrapper:["wrapper",`${t}`],wrapperInner:["wrapperInner",`${t}`]};return df(r,Fp,n)},_p=ta("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]}})(uf(({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"}}]}))),Hp=ta("div",{name:"MuiCollapse",slot:"Wrapper"})({display:"flex",width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),Up=ta("div",{name:"MuiCollapse",slot:"WrapperInner"})({width:"100%",variants:[{props:{orientation:"horizontal"},style:{width:"auto",height:"100%"}}]}),io=S.forwardRef(function(t,n){const r=nf({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:y,orientation:k="vertical",style:h,timeout:b=rf.standard,TransitionComponent:x=sf,...w}=r,$={...r,orientation:k,collapsedSize:a},E=Bp($),D=of(),O=af(),j=S.useRef(null),P=S.useRef(),R=typeof a=="number"?`${a}px`:a,A=k==="horizontal",L=A?"width":"height",U=S.useRef(null),_=lf(n,U),T=N=>Z=>{if(N){const pe=U.current;Z===void 0?N(pe):N(pe,Z)}},z=()=>j.current?j.current[A?"clientWidth":"clientHeight"]:0,F=T((N,Z)=>{j.current&&A&&(j.current.style.position="absolute"),N.style[L]=R,l&&l(N,Z)}),W=T((N,Z)=>{const pe=z();j.current&&A&&(j.current.style.position="");const{duration:ne,easing:Q}=vl({style:h,timeout:b,easing:f},{mode:"enter"});if(b==="auto"){const Se=D.transitions.getAutoHeightDuration(pe);N.style.transitionDuration=`${Se}ms`,P.current=Se}else N.style.transitionDuration=typeof ne=="string"?ne:`${ne}ms`;N.style[L]=`${pe}px`,N.style.transitionTimingFunction=Q,p&&p(N,Z)}),B=T((N,Z)=>{N.style[L]="auto",u&&u(N,Z)}),X=T(N=>{N.style[L]=`${z()}px`,g&&g(N)}),J=T(v),re=T(N=>{const Z=z(),{duration:pe,easing:ne}=vl({style:h,timeout:b,easing:f},{mode:"exit"});if(b==="auto"){const Q=D.transitions.getAutoHeightDuration(Z);N.style.transitionDuration=`${Q}ms`,P.current=Q}else N.style.transitionDuration=typeof pe=="string"?pe:`${pe}ms`;N.style[L]=R,N.style.transitionTimingFunction=ne,y&&y(N)}),ee=N=>{b==="auto"&&O.start(P.current||0,N),i&&i(U.current,N)};return m.jsx(x,{in:c,onEnter:F,onEntered:B,onEntering:W,onExit:X,onExited:J,onExiting:re,addEndListener:ee,nodeRef:U,timeout:b==="auto"?null:b,...w,children:(N,{ownerState:Z,...pe})=>m.jsx(_p,{as:d,className:cf(E.root,o,{entered:E.entered,exited:!c&&R==="0px"&&E.hidden}[N]),style:{[A?"minWidth":"minHeight"]:R,...h},ref:_,ownerState:{...$,state:N},...pe,children:m.jsx(Hp,{ownerState:{...$,state:N},className:E.wrapper,ref:j,children:m.jsx(Up,{ownerState:{...$,state:N},className:E.wrapperInner,children:s})})})})});io&&(io.muiSupportAuto=!0);var kl={};const Bc=ot(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"})),_c=ot(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"})),so=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),dn=so?"⌘":"Ctrl+",Sl=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},As=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function qp(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=so?s.metaKey:s.ctrlKey,d=s.key.toLowerCase();if(s.key==="Escape"){if(Sl(s.target)||As(s.target))return;o.escape();return}if(Sl(s.target)){if(a&&d==="s"){if(s.preventDefault(),!o.save||As(s.target))return;s.target.blur(),r(!0)}return}if(As(s.target)){a&&d==="s"&&s.preventDefault();return}if(a&&d==="z"){s.preventDefault(),s.shiftKey?o.redo():o.undo();return}if(!so&&a&&d==="y"){s.preventDefault(),o.redo();return}if(a&&d==="s"){s.preventDefault(),o.save?.();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 Pr=(e,t,n=oa)=>({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}}}),qi=(e=oa)=>({width:e.size.control,height:e.size.control,borderRadius:e.radius.control,"& svg":{fontSize:18}}),Ir={height:20,alignSelf:"center",mx:.5,my:0},Hn=(e,t=oa)=>({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"}}}),oo={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function Kp({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,onExit:u,layout:p,onLayoutChange:g}){const{theme:v}=_e(),y=Vt(v.cardBorder),k=fs(v.cardBorder,v.tileTitle);return m.jsxs(tt,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[p&&g&&m.jsxs(m.Fragment,{children:[m.jsx(lt,{title:"Layout: tiles side by side, or one after another",children:m.jsxs(ps,{size:"small",exclusive:!0,value:p,"aria-label":"Layout",onChange:(h,b)=>{b&&b!==p&&g(b)},sx:Hn(y,v.ui),children:[m.jsx(un,{value:"linear","aria-label":"Linear layout",children:"Linear"}),m.jsx(un,{value:"grid","aria-label":"Grid layout",children:"Grid"})]})}),m.jsx(zn,{orientation:"vertical",sx:Ir})]}),l&&m.jsx(ke,{variant:"outlined",startIcon:m.jsx(ti,{}),onClick:l,"aria-label":"Add tile",sx:Pr(y,k,v.ui),children:"Tile"}),l&&m.jsx(zn,{orientation:"vertical",sx:Ir}),m.jsx(lt,{title:`Undo (${dn}Z)`,children:m.jsx("span",{children:m.jsx(_n,{"aria-label":"Undo",disabled:!e,onClick:n,sx:qi(v.ui),children:m.jsx(_c,{fontSize:"small"})})})}),m.jsx(lt,{title:`Redo (${dn}⇧Z)`,children:m.jsx("span",{children:m.jsx(_n,{"aria-label":"Redo",disabled:!t,onClick:r,sx:qi(v.ui),children:m.jsx(Bc,{fontSize:"small"})})})}),(c||o||u)&&m.jsx(zn,{orientation:"vertical",sx:Ir}),c,o?m.jsx(lt,{title:i?`Save (${dn}S) · ${d??oo[a]}`:d??oo[a],children:m.jsx("span",{children:m.jsx(ke,{ref:f,variant:i?"contained":"outlined",disabled:!i||s,onClick:o,sx:{...Pr(y,k,v.ui),minWidth:88},children:s?"Saving…":i?"Save":"Saved"})})}):null,o&&m.jsx(H,{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"}),u&&m.jsx(Of,{label:"Close",icon:m.jsx(aa,{}),onClick:u})]})}const Gp={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function Hc(e,t,n){const r=i=>{if(t!==i){if(i==="big_value")return e?.aggregateOnly===!0?void 0:"Needs a view with only totals (no group by)";if(i==="shape_map"||i==="segment_map")return e?.chart===i?void 0:"Needs a view that already carries a map chart"}};return[{value:"default",label:"From the view"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"].map(i=>{const s=r(i);return{value:i,label:Gp[i],...s?{disabled:!0,reason:s}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function $l(e){return e.description??zp(e.name)}const Yp={bar_chart:"a bar chart",line_chart:"a line chart",scatter_chart:"a scatter chart",shape_map:"a shape map",segment_map:"a segment map",big_value:"a big value",sparkline:"a sparkline"},gi=(e,t)=>`${e}\0${t}`;function Vp({open:e,document:t,catalog:n,columns:r,onClose:i,onAdd:s,onAddText:o,renderPreview:a}){const{theme:d}=_e(),f=d.ui,c=Vt(d.cardBorder),l=S.useMemo(()=>n?.sources??[],[n]),[u,p]=S.useState(""),[g,v]=S.useState(),[y,k]=S.useState(""),[h,b]=S.useState("default"),x=S.useRef(null),w=S.useMemo(()=>{const T=new Set(t.sources.map(z=>z.base));return[...l].sort((z,F)=>Number(T.has(F.name))-Number(T.has(z.name)))},[l,t]),$=w.filter(T=>T.views.length>0),E=w.filter(T=>T.views.length===0),D=S.useMemo(()=>new Map($.flatMap(T=>T.views.map(z=>[gi(T.name,z.name),{source:T,view:z,key:gi(T.name,z.name)}]))),[$]),O=S.useMemo(()=>$.map(T=>({key:T.name,label:T.name,...T.description?{detail:T.description}:{},entries:T.views.map(z=>({key:gi(T.name,z.name),name:z.name,title:$l(z),...z.chart?{chart:z.chart}:{}}))})),[$]),j=g===void 0?void 0:D.get(g);S.useEffect(()=>{if(!e)return;p(""),k(""),b("default");const T=$[0]?.views[0];v(T&&$[0]?gi($[0].name,T.name):void 0)},[e]);const P=j?[j.source.name,j.view.name].filter(T=>!ro(T)).map(T=>`"${T}" is not a plain Malloy name, so a tile cannot be written for it.`)[0]:void 0,R=j!==void 0&&P===void 0,A=j?$l(j.view):"",L=h!=="default"&&j?{chart:h,chartCarried:j.view.chart?[j.view.chart]:[]}:{},U=(T=j)=>{if(!T||![T.source.name,T.view.name].every(ro))return;const z=T.key===j?.key;s({base:T.source.name,modelPath:T.source.modelPath,...T.source.exporters?{exporters:T.source.exporters}:{},view:T.view.name,...z&&y.trim()?{label:y.trim()}:{},...z?L:{},colspan:Math.ceil(r/2)})},_=j?Hc(j.view,h).filter(T=>T.value!=="custom"&&T.disabled!==!0):[];return m.jsx(ca,{className:`${Ze.dialog} ${Ze.addTileDialog}`,open:e,onClose:i,maxWidth:"md",initialFocus:x,title:"Add a tile",description:"Pick a view from this package. You can change its title and chart now or later.",actions:m.jsxs(m.Fragment,{children:[m.jsx(ke,{onClick:o,sx:{mr:"auto"},children:"Add text instead"}),m.jsx(ke,{onClick:i,children:"Cancel"}),m.jsx(ke,{variant:"contained",disabled:!R,onClick:()=>U(),children:"Add tile"})]}),children:m.jsxs(H,{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(H,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${c}`},maxHeight:{xs:280,md:"none"}},children:m.jsx(bp,{groups:O,query:u,onQuery:p,picked:j?.key,onPick:T=>{v(T),b("default")},onTake:T=>U(D.get(T)),searchRef:x,empty:m.jsx(fe,{variant:"body2",sx:{color:d.tileTitle,p:2},children:n?"This package publishes no source with a view to put on a tile.":"The package's sources are still loading."}),footer:E.length>0&&m.jsxs(fe,{variant:"caption",component:"p",sx:{color:"text.secondary",px:2,pt:1.5},children:["Also in this package, with no views to show:"," ",E.map(T=>T.name).join(", "),"."]})})}),m.jsx(H,{sx:T=>({p:2.5,display:"flex",flexDirection:"column",gap:2,minHeight:0,overflowY:"auto",bgcolor:`color-mix(in srgb, ${T.palette.text.primary} 3%, ${T.palette.background.paper})`}),children:j?m.jsxs(m.Fragment,{children:[m.jsx(H,{"aria-label":"Preview",role:"region",sx:T=>({height:240,flex:"none",display:"flex",position:"relative",overflow:"hidden",borderRadius:f.radius.tile,border:`1px solid ${c}`,bgcolor:T.palette.background.paper,"&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,height:40,pointerEvents:"none",background:`linear-gradient(to bottom, transparent, ${T.palette.background.paper})`}}),children:a?m.jsx(H,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:a({base:j.source.name,modelPath:j.source.modelPath,view:j.view.name,label:y.trim()||A,...h!=="default"?L:{},givens:j.source.givens})}):m.jsxs(H,{sx:T=>({flex:1,border:`1px solid ${c}`,borderRadius:f.radius.tile,bgcolor:T.palette.background.paper,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,color:"text.secondary"}),children:[m.jsx(xp,{chart:j.view.chart}),m.jsxs(fe,{variant:"body2",children:[j.source.name," → ",j.view.name]})]})}),m.jsx(Ft,{size:"small",label:"Title",placeholder:A,value:y,onChange:T=>k(T.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Tile title"}}),m.jsxs(H,{children:[m.jsx(fe,{component:"div",sx:{...f.type.label,color:"text.secondary",mb:.75},children:"Chart"}),m.jsx(ps,{size:"small",exclusive:!0,value:h,"aria-label":"Chart",onChange:(T,z)=>{z!==null&&b(z)},sx:{...Hn(c,f),"& .MuiToggleButton-root":{...Hn(c,f)["& .MuiToggleButton-root"],textTransform:"none"}},children:_.map(T=>m.jsx(un,{value:T.value,children:T.label},T.value))}),m.jsx(fe,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:j.view.chart?`The view declares ${Yp[j.view.chart]??"a chart"}.`:"The view declares no chart, so it shows as a table."})]}),P&&m.jsx(fe,{variant:"body2",color:"error",children:P})]}):m.jsx(fe,{variant:"body2",sx:{color:"text.secondary",m:"auto"},children:"Pick a view to see it here."})})]})})}const De=e=>e.kind==="text",de=e=>e.kind!=="text",pr=e=>de(e)?e.label??e.name:e.name,Ie=e=>De(e)?`text.${e.name}`:`${e.source}.${e.name}`;function Xp(e,t,{modelPath:n,textHeld:r,widths:i,insertAt:s}){t.modelPath&&!r&&(e.imports=Rp(e,t.base,t.modelPath,n,t.exporters??[t.modelPath]));const o=Uc(e,t.base),a=ao(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?{colspan:t.colspan}:{},...t.label?{label:t.label}:{},...t.chart?{chart:t.chart}:{},...t.chartCarried?{chartCarried:t.chartCarried}:{}})}function Uc(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 ao(e,t,n){const r=new Set(e.tiles.filter(de).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 Ki(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.`;default:return e.chart==="custom"?"Its chart line is one the builder does not write, so a copy would lose it.":void 0}}function Jp(e,t){const n=e.tiles[t];if(!n||!de(n)||Ki(n)!==void 0)return;let r;if(n.declaration.kind==="reference"){const{break:i,...s}=structuredClone(n);r={...s,name:ao(e,n.source,n.declaration.from)}}else{const i=e.sources.find(s=>s.name===n.source)??Uc(e,n.source,{unscoped:!0});r={name:ao(e,i.name,n.name),source:i.name,declaration:{kind:"reference",from:n.name},...n.colspan!==void 0?{colspan:n.colspan}:{}}}return e.tiles.splice(t+1,0,r),t+1}const vi="self";function Zp({open:e,document:t,source:n,givenNames:r,dashboards:i,tileLabel:s,onClose:o,onApply:a}){const{theme:d}=_e(),f=d.ui,[c,l]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const h=(t.drills??[]).filter(b=>b.source===n.name);l((n.dimensions??[]).map(b=>{const x=h.find(w=>w.name===b.name);return{name:b.name,expression:b.expression,to:x?.to??[],given:x?.given??""}}))},[e,n,t]);const u=(h,b)=>l(x=>x.map((w,$)=>{if($!==h)return w;const E={...w};return b(E),E})),p=[vi,...i.filter(h=>h!==vi)],g=h=>h===vi?"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())},y=Vt(d.cardBorder),k=(h,b)=>u(h,x=>{b?x.to=x.lastTo?.length?x.lastTo:[vi]:(x.lastTo=x.to,x.to=[])});return m.jsx(ca,{className:`${Ze.dialog} ${Ze.clickableCellsDialog}`,open:e,onClose:o,title:"Clickable cells",description:m.jsxs(m.Fragment,{children:[s&&m.jsxs(H,{component:"span",sx:{fontWeight:f.type.label.fontWeight},children:[s," ·"," "]}),"A click on a cell sets a filter to its value, on this report or on the one it opens."]}),actions:m.jsxs(m.Fragment,{children:[m.jsx(ke,{onClick:o,children:"Cancel"}),m.jsx(ke,{variant:"contained",onClick:v,disabled:c.length===0,children:"Apply"})]}),children:c.length===0?m.jsx(fe,{variant:"body2",sx:{color:d.tileTitle,pt:1},children:n?m.jsxs(m.Fragment,{children:[m.jsx(H,{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(H,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):m.jsx(H,{role:"list","aria-label":"Dimensions",children:c.map((h,b)=>{const x=h.to.length>0;return m.jsxs(H,{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:b===0?"none":`1px solid ${y}`},children:[m.jsx(vp,{size:"small",checked:x,onChange:w=>k(b,w.target.checked),slotProps:{input:{"aria-label":`${h.name} is clickable`}}}),m.jsxs(H,{sx:{minWidth:0},children:[m.jsx(H,{sx:{...f.type.control,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Qp(h.name)}),m.jsxs(H,{title:h.expression,sx:{...f.type.code,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[h.name," is ",h.expression]})]}),x?m.jsxs(tt,{direction:"row",sx:{gridColumn:{xs:"1 / -1",sm:"auto"},alignItems:"center",gap:1,justifyContent:"flex-end",...f.type.control},children:[m.jsx(H,{component:"span",sx:{color:"text.secondary"},children:"Opens"}),m.jsx(Ft,{select:!0,size:"small",value:h.to,inputProps:{"aria-label":`Where ${h.name} goes`},SelectProps:{multiple:!0,renderValue:w=>w.map(g).join(", ")},onChange:w=>u(b,$=>{const E=w.target.value,D=Array.isArray(E)?E:String(E).split(",").filter(Boolean);D.length===0&&($.lastTo=$.to),$.to=D}),sx:{flex:"1 1 150px",minWidth:0,maxWidth:200},children:p.map(w=>m.jsxs(bt,{value:w,children:[m.jsx(no,{size:"small",checked:h.to.includes(w),sx:{p:0,mr:1}}),m.jsx(Ui,{primary:g(w)})]},w))}),m.jsx(H,{component:"span",sx:{color:"text.secondary"},children:"sets"}),m.jsxs(Ft,{select:!0,size:"small",value:h.given,inputProps:{"aria-label":`Control ${h.name} sets`},SelectProps:{displayEmpty:!0,renderValue:w=>w===""?h.name:String(w)},onChange:w=>u(b,$=>{$.given=w.target.value}),sx:{flex:"1 1 120px",minWidth:0,maxWidth:170},children:[m.jsx(bt,{value:"",children:m.jsx(Ui,{primary:h.name,secondary:"Named like the dimension"})}),r.map(w=>m.jsx(bt,{value:w,children:w},w))]})]}):m.jsx(fe,{variant:"body2",sx:{color:"text.secondary",textAlign:"right",display:{xs:"none",sm:"block"}},children:"Not clickable"})]},h.name)})})})}function Qp(e){const t=e.replace(/_+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const em=ot(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"})),tm=ot(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"})),nm=ot(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"})),rm=ot(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"})),im=ot(m.jsx("path",{d:"M4 9h16v2H4zm0 4h10v2H4z"})),sm=ot(m.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33v-4h3.33zM19 17h-3.33v-4H19zm0-6h-8.67V7H19z"}));function om(e,t=[]){const n=new Map;for(const s of e.tiles)for(const o of de(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 Gi(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function am(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function zr(e,t){const n=am(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 lo(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 lm(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const cm=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function dm(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=Fc(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 um=[{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 vr(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 co=e=>de(e)&&e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function hm(e,t){return e.tiles.map(n=>{const r=(de(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}:Gi(t.type)!==void 0?{op:Gi(t.type)}:{}}})}function fm(e,t,n){n.forEach((r,i)=>{const s=e.tiles[i];if(!s||!co(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 pm(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 mm(e,t){for(const r of e.tiles){if(!de(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 uo=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function gm({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"),[y,k]=S.useState(""),[h,b]=S.useState(""),[x,w]=S.useState([]),[$,E]=S.useState(!1),[D,O]=S.useState(!1),j=M=>t.sources.find(I=>I.name===M.source)?.base??M.source;S.useEffect(()=>{if(e)if(O(n!==void 0),n){l({kind:"existing",name:n.name}),p(n.label??"");const M=hm(t,n);w(M);const I=M.filter(C=>C.include),q=new Set(I.map(C=>C.field));b(q.size===1?I[0].field:n.field??""),E(q.size>1)}else l({kind:"new"}),p(""),v("select"),b(""),k(new Date().toISOString().slice(0,10)),w(t.tiles.map(M=>({include:co(M),field:""}))),E(!1)},[e,n,t]);const P=S.useMemo(()=>[...(t.localGivens??[]).map(M=>M.name),...r.map(M=>M.name),...i],[t,r,i]),R=S.useMemo(()=>h.trim()?dm(h.trim(),P):"",[h,P]),A=c.kind==="existing"?n??r.find(M=>M.name===c.name):R?{name:R,type:vr({name:R,label:u,kind:g,field:h}).type}:void 0,L=A?.type!==void 0&&!A.type.startsWith("filter<"),U=x.find(M=>M.include)?.op??Gi(A?.type),_=(M,I)=>{O(!0),w(q=>q.map((C,te)=>te===M?{...C,...I}:C))},T=M=>{O(!0),w(I=>I.map(q=>({...q,op:M})))},z=M=>{const I=Gi(M);w(q=>q.map(({op:C,...te})=>I?{...te,op:I}:te))},F=M=>{O(!0),l({kind:"existing",name:M.name}),b(M.field??""),z(M.type)},W=M=>{O(!0),v(M),z(vr({name:"X",label:u,kind:M,field:h}).type)},B=t.tiles.map(co),X=B.filter(Boolean).length,J=x.filter((M,I)=>M.include&&B[I]).length,re=t.tiles.filter((M,I)=>(x[I]?.include??!1)&&B[I]&&de(M)),ee=re.length>0?re:t.tiles.filter((M,I)=>B[I]&&de(M)),N=S.useMemo(()=>{const M=new Map;let I=!1;for(const q of ee){const C=s?.(q);if(C){I=!0;for(const te of C)M.has(te.name)||M.set(te.name,te)}}return I?[...M.values()]:void 0},[x,t.tiles,s]),Z=(()=>{const M=h.trim();for(const I of re){const q=s?.(I);if(!q||q.some(C=>C.name===M))return j(I)}return re[0]?j(re[0]):t.sources[0]?.base})(),pe=M=>{O(!0),w(I=>I.map((q,C)=>({...q,include:M&&B[C]})))},ne=S.useMemo(()=>$?x:x.map(M=>({...M,field:h})),[$,x,h]),Q=M=>{for(const I of ee){const q=s?.(I)?.find(C=>C.name===M.trim());if(q?.type)return q.type}},Se=M=>zr(A?.type,M.type),be=(M,I)=>{if(M.trim()==="")return"Pick the field this filter compares.";const q=I?s?.(I):void 0;if(!q)return;const C=q.find(te=>te.name===M.trim());if(!C)return`Not a field of ${I?j(I):"the tiles' source"}.`;if(C.type&&!zr(A?.type,C.type))return`${M.trim()} is ${lo(C.type)}; this filter compares ${lo(A?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},G=M=>{if(O(!0),b(M),f||c.kind!=="new")return;const I=Q(M),q=vr({name:"X",label:u,kind:g,field:M}).type;I&&!zr(q,I)&&W(lm(I))},$e=M=>{const I=t.tiles[M];return I&&de(I)?I:void 0},he=ne.map((M,I)=>M.include&&B[I]?be(M.field,$e(I)):void 0),ie=he.every(M=>M===void 0),Ne=D?he:he.map(()=>{}),Ke=D&&!$&&J>0?re.map(M=>be(h,M)).find(Boolean):void 0,He=A!==void 0&&ie&&(c.kind==="existing"||h.trim()!==""&&R!==""),Ge=()=>{if(!(!A||!He))if(c.kind==="new")o(A.name,ne,vr({name:A.name,label:u.trim()||uo(A.name),kind:g,field:h.trim(),...Z?{source:Z}:{},...y?{dateDefault:y}:{}}));else if(n?.origin==="dashboard"&&n.local){const M=u.trim(),I=M!==(n.local.label??"");o(A.name,ne,I?{...n.local,...M?{label:M}:{}}:void 0)}else o(A.name,ne)},Ye=f&&d.origin==="model";return{editing:f,shown:d,fromModel:Ye,source:c,setSource:l,label:u,setLabel:p,kind:g,dateDefault:y,setDateDefault:k,field:h,rows:x,setRows:w,perTile:$,setPerTile:E,newName:R,target:A,valueTyped:L,commonOp:U,setRow:_,setCommonOp:T,pickExisting:F,pickKind:W,bindable:B,bindableCount:X,included:J,commonFields:N,setAll:pe,accepts:Se,pickField:G,rowProblems:Ne,commonProblem:Ke,canApply:He,apply:Ge}}function jl({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(Ip,{freeSolo:!0,size:"small",options:p,inputValue:e,onInputChange:(v,y)=>t(y),value:e,onChange:(v,y)=>t(typeof y=="string"?y:""),disabled:d,disableClearable:!0,renderOption:(v,y)=>S.createElement("li",{...v,key:y},m.jsx(Ml,{type:g.get(y)}),m.jsx(fe,{variant:"body2",sx:{flex:1,ml:1},children:y})),renderInput:v=>m.jsx(Ft,{...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(H,{sx:{display:"flex",ml:.5,mr:-.25},children:m.jsx(Ml,{type:g.get(e.trim())})}):void 0},inputProps:{...v.inputProps,"aria-label":s}}),sx:u})}const vm=e=>e&&de(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:{label:"From the model",reason:"Declared on its source, which this report does not write."};function bm({open:e,document:t,control:n,available:r,takenNames:i,fieldsFor:s,onClose:o,onApply:a,onRemove:d}){const{theme:f}=_e(),c=f.ui,{editing:l,shown:u,fromModel:p,source:g,setSource:v,label:y,setLabel:k,kind:h,dateDefault:b,setDateDefault:x,field:w,rows:$,setRows:E,perTile:D,setPerTile:O,newName:j,target:P,valueTyped:R,commonOp:A,setRow:L,setCommonOp:U,pickExisting:_,pickKind:T,bindable:z,bindableCount:F,included:W,commonFields:B,setAll:X,accepts:J,pickField:re,rowProblems:ee,commonProblem:N,canApply:Z,apply:pe}=gm({open:e,document:t,control:n,available:r,...i?{takenNames:i}:{},fieldsFor:s,onApply:a}),ne=S.useRef(null),Q=Vt(f.cardBorder),Se=fs(f.cardBorder,f.tileTitle),[be,G]=S.useState(!1),[$e,he]=S.useState(!1);S.useEffect(()=>{e?he(!0):G(!1)},[e]),S.useEffect(()=>{$e&&(he(!1),G(l&&W<F))},[$e]),S.useEffect(()=>{D&&G(!0)},[D]);const ie=B?.find(M=>M.name===w.trim())?.type,Ne=M=>{if(!ie)return;const I=vr({name:"X",label:y,kind:M,field:w}).type;return zr(I,ie)?void 0:`${w.trim()} is ${lo(ie)}, which this control cannot filter.`},Ke=y.trim()||(j?uo(j):"Filter"),He=h==="number"?"Any":h==="date"?b?new Date(`${b}T00:00:00`).toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"}):"Any":"All",Ge={...Hn(Q,c),alignSelf:"flex-start","& .MuiToggleButton-root":{...Hn(Q,c)["& .MuiToggleButton-root"],textTransform:"none"}},Ye=(M,I,q)=>m.jsx(Ft,{select:!0,size:"small",label:"Compares",value:M??">=",onChange:C=>I(C.target.value),inputProps:{"aria-label":q},sx:{width:130},children:cm.filter(C=>C.op!=="~").map(C=>m.jsx(bt,{value:C.op,children:C.label},C.op))});return m.jsx(ca,{className:`${Ze.dialog} ${Ze.filterDialog}`,open:e,onClose:o,...l?{}:{initialFocus:ne},title:l?u.label??u.name:"Add a filter",description:l?m.jsxs(m.Fragment,{children:[m.jsxs(H,{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(ke,{color:"error",startIcon:m.jsx(pp,{}),onClick:()=>d(u.name),sx:M=>({mr:"auto",color:fp(M)}),children:"Remove filter"}),m.jsx(ke,{onClick:o,children:"Cancel"}),m.jsx(lt,{title:Z||P===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:m.jsx("span",{children:m.jsx(ke,{variant:"contained",onClick:pe,disabled:!Z,children:l?"Apply":"Add filter"})})})]}),children:m.jsxs(tt,{sx:{gap:2.5,pt:1},children:[!l&&r.length>0&&m.jsxs(ps,{exclusive:!0,size:"small",value:g.kind,onChange:(M,I)=>{I==="new"?v({kind:"new"}):I==="existing"&&r[0]&&_(r[0])},"aria-label":"Where the filter comes from",sx:Ge,children:[m.jsx(un,{value:"new",children:"New in this report"}),m.jsx(un,{value:"existing",children:"From the model"})]}),!l&&g.kind==="existing"?m.jsx(Ft,{select:!0,size:"small",label:"Filter",value:g.name,onChange:M=>{const I=r.find(q=>q.name===M.target.value);I&&_(I)},children:r.map(M=>m.jsxs(bt,{value:M.name,children:[M.label??M.name,m.jsxs(fe,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",M.name]})]},M.name))}):null,m.jsxs(H,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:p?"1fr":"minmax(0, 1.4fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[!D&&m.jsx(jl,{value:w,onChange:re,fields:B,accepts:J,label:"Field",ariaLabel:"Field to filter",placeholder:"category",inputRef:ne,error:N!==void 0,helperText:N??(!l&&j?`Declared as $${j}`:void 0)}),!p&&m.jsx(Ft,{size:"small",label:"Label",placeholder:j?uo(j):"",value:y,onChange:M=>k(M.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Filter label"}})]}),R&&!D&&Ye(A,U,"Comparison"),!l&&g.kind==="new"&&m.jsxs(H,{children:[m.jsx(Cl,{children:"Control"}),m.jsx(H,{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:um.map(M=>{const I=M.kind===h,q=Ne(M.kind);return m.jsx(lt,{title:q??M.hint,describeChild:!0,children:m.jsxs(Dc,{role:"radio","aria-checked":I,"aria-label":M.label,"aria-disabled":q!==void 0,onClick:()=>{q===void 0&&T(M.kind)},sx:C=>({flexDirection:"column",gap:.5,px:1,py:1.25,borderRadius:c.radius.tile,border:`1px solid ${I?f.accent:Q}`,boxShadow:I?`0 0 0 1px ${f.accent}`:"none",bgcolor:I?`color-mix(in srgb, ${f.accent} 6%, ${C.palette.background.paper})`:C.palette.background.paper,color:I?f.accent:C.palette.text.secondary,opacity:q?.45:1,cursor:q?"default":"pointer",transition:`border-color ${Be}, background-color ${Be}`,"&:hover":q||I?{}:{borderColor:Se}}),children:[m.jsx(ym,{kind:M.kind}),m.jsx(H,{component:"span",sx:{...c.type.caption,fontWeight:I?600:500,color:I?f.accent:"text.primary",textAlign:"center"},children:xm[M.kind]})]})},M.kind)})}),h==="date"&&m.jsx(Ft,{size:"small",type:"date",label:"Starts at",value:b,onChange:M=>x(M.target.value),InputLabelProps:{shrink:!0},sx:{mt:1.5,width:200}})]}),m.jsxs(H,{sx:{border:`1px solid ${Q}`,borderRadius:c.radius.tile,overflow:"hidden"},children:[m.jsxs(tt,{direction:"row",sx:{alignItems:"center",gap:1.25,px:1.5,py:1},children:[m.jsx(sm,{"aria-hidden":!0,sx:{fontSize:18,color:"text.secondary"}}),m.jsxs(fe,{variant:"body2",sx:{flex:1,minWidth:0},children:[m.jsx(H,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:W===F&&F>0?`Applies to all ${W} tile${W===1?"":"s"}`:`Applies to ${W} of ${F} tile${F===1?"":"s"}`}),!D&&w.trim()!==""&&W>0&&m.jsxs(H,{component:"span",sx:{color:"text.secondary"},children:[" · each filters on ",m.jsx(H,{component:"span",sx:{...c.type.code},children:w.trim()})]})]}),!D&&m.jsx(ke,{size:"small","aria-expanded":be,onClick:()=>G(M=>!M),children:be?"Done choosing":"Choose tiles"})]}),m.jsx(io,{in:be,unmountOnExit:!0,children:m.jsxs(H,{sx:{borderTop:`1px solid ${Q}`,px:.5,pb:1},children:[m.jsxs(tt,{direction:"row",sx:{alignItems:"center",gap:.5,pt:.5},children:[m.jsx(no,{size:"small",checked:F>0&&W===F,indeterminate:W>0&&W<F,disabled:F===0,onChange:M=>X(M.target.checked),inputProps:{"aria-label":"All tiles"}}),m.jsx(fe,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:"All tiles"}),m.jsx(ke,{size:"small",onClick:()=>{D||E(M=>M.map(I=>({...I,field:w}))),O(M=>!M)},children:D?"Same field for all":"Adjust per tile"})]}),m.jsx(tt,{sx:{gap:D?1:0},children:t.tiles.map((M,I)=>{if(!de(M))return null;const q=$[I],C=M.label??M.name,te=D?ee[I]:void 0;return m.jsxs(tt,{direction:"row",sx:{gap:1,alignItems:D?"flex-start":"center",opacity:z[I]?1:.6},children:[m.jsx(no,{size:"small",disabled:!z[I],checked:(q?.include??!1)&&z[I],inputProps:{"aria-label":`Filter ${C}`},onChange:K=>L(I,{include:K.target.checked})}),m.jsx(fe,{variant:"body2",sx:{flex:1,minWidth:0,pt:D?1:0},noWrap:!0,children:C}),z[I]?D&&m.jsxs(m.Fragment,{children:[R&&Ye(q?.op,K=>L(I,{op:K}),`Comparison for ${C}`),m.jsx(jl,{value:q?.field??"",onChange:K=>L(I,{field:K}),fields:s?.(M),accepts:J,label:"Field",ariaLabel:`Field for ${C}`,disabled:!q?.include,error:te!==void 0,helperText:te,sx:{width:220,pr:1}})]}):m.jsx(fe,{variant:"caption",sx:{color:f.tileTitle,pr:1,maxWidth:260,textAlign:"right"},children:vm(t.tiles[I]).reason})]},`${M.source}.${M.name}`)})})]})})]}),W===0&&m.jsx(fe,{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(H,{children:[m.jsx(Cl,{children:"Preview"}),m.jsx(H,{sx:M=>({display:"flex",alignItems:"center",gap:1,p:1.5,borderRadius:c.radius.tile,bgcolor:M.palette.action.hover}),children:m.jsxs(H,{"aria-hidden":!0,sx:M=>({display:"inline-flex",alignItems:"center",gap:.75,height:30,px:1.25,borderRadius:c.radius.control,border:`1px solid ${Q}`,bgcolor:M.palette.background.paper,...c.type.control}),children:[m.jsx(H,{component:"span",sx:{color:"text.secondary"},children:Ke}),m.jsx(H,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:He}),m.jsx(na,{sx:{fontSize:16,color:"text.secondary"}})]})})]})]})})}function Cl({children:e}){const t=_e().theme.ui;return m.jsx(fe,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}const xm={select:"Pick one",multiselect:"Pick several",text:"Text",number:"Range",date:"Date"};function ym({kind:e}){const t={fontSize:22};switch(e){case"select":return m.jsx(em,{sx:t});case"multiselect":return m.jsx(tm,{sx:t});case"text":return m.jsx(im,{sx:t});case"number":return m.jsx(rm,{sx:t});case"date":return m.jsx(nm,{sx:t})}}function Ml({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=_e().theme.ui;return n?m.jsx(H,{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 wm=ot(m.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}));function qc(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 km=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.`,Sm="Declared on its source, so its chart is set in the model.";function $m({anchor:e,tile:t,onClose:n,onCommit:r,onDrills:i,onDuplicate:s,duplicateBlocked:o,view:a}){const{theme:d}=_e(),f=d.ui,{draft:c,apply:l,close:u}=qc(t,e!==null,r,n),[p,g]=S.useState(void 0),v=c!==void 0&&de(c)?c:void 0,y=v!==void 0&&v.declaration.kind!=="inherited",k=P=>l(R=>{de(R)&&P(R)}),h=S.useRef(void 0),b=e!==null;S.useEffect(()=>{b?h.current=t&&de(t)?t.chart:void 0:g(void 0)},[b]);const x=v?.chart??"default",w=Hc(a,x),$=v?y?v.chart==="custom"?km(v.chartLines):void 0:Sm:void 0,E=P=>k(R=>{const A=h.current;P===(A??"default")?(A===void 0?delete R.chart:R.chart=A,delete R.chartCarried):(R.chart=P,a?R.chartCarried=a.chart?[a.chart]:[]:delete R.chartCarried)}),D=y?i?void 0:"Its source declares no dimension a click could filter by.":void 0,O=P=>R=>g({kind:P,anchor:R.currentTarget}),j=(P,R,A)=>m.jsxs(m.Fragment,{children:[m.jsx(Ui,{primary:P,...A?{secondary:A}:{},secondaryTypographyProps:{sx:{whiteSpace:"normal",maxWidth:240}}}),R&&m.jsx(fe,{variant:"body2",sx:{color:"text.secondary",ml:2},children:R})]});return m.jsxs(m.Fragment,{children:[m.jsxs(Hi,{className:Ze.menu,open:e!==null&&c!==void 0,anchorEl:e,onClose:u,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":v?`${v.source} ${v.name}`:"Tile"},slotProps:{paper:{sx:{minWidth:240,mt:.5,borderRadius:f.radius.menu,border:`1px solid ${Vt(d.cardBorder)}`,boxShadow:f.shadow.menu}}},children:[v&&m.jsxs(bt,{"aria-haspopup":"menu","aria-expanded":p?.kind==="chart",disabled:$!==void 0,onClick:O("chart"),onKeyDown:P=>{P.key==="ArrowRight"&&$===void 0&&g({kind:"chart",anchor:P.currentTarget})},children:[j("Chart",$?void 0:w.find(P=>P.value===x)?.label,$),m.jsx(wm,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),y&&m.jsx(bt,{"aria-haspopup":"dialog",disabled:D!==void 0,onClick:()=>{u(),i?.()},children:j("Clickable cells…",void 0,D)}),v&&s&&m.jsx(bt,{disabled:o!==void 0,onClick:()=>{u(),s()},children:j("Duplicate",void 0,o)}),v?.declaration.kind==="opaque"&&m.jsxs(fe,{variant:"body2",sx:{color:d.tileTitle,px:2,py:.75,maxWidth:260},children:["Its body is ",v.declaration.why,", so a filter has no single place to go."]}),v&&m.jsx(zn,{}),v&&m.jsxs(H,{"aria-hidden":!0,sx:{px:2,py:.5,...f.type.code,color:"text.secondary"},children:[v.source," → ",v.name]})]}),m.jsx(Hi,{className:Ze.menu,open:p?.kind==="chart",anchorEl:p?.anchor??null,onClose:()=>g(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":"Chart",onKeyDown:P=>{P.key==="ArrowLeft"&&(P.preventDefault(),g(void 0))}},children:w.filter(P=>P.value!=="custom").map(P=>m.jsxs(bt,{role:"menuitemradio","aria-checked":P.value===x,disabled:P.disabled===!0,onClick:()=>{E(P.value),g(void 0)},children:[m.jsx(Ui,{primary:P.label,...P.reason?{secondary:P.reason}:{}}),P.value===x&&m.jsx(mp,{sx:{minWidth:0,ml:2},children:m.jsx(aa,{fontSize:"small",sx:{color:d.accent}})})]},P.value))})]})}const Nn=e=>e.label??gp(`${e.source} -> ${e.name}`);function jm({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,y]=S.useState(),k=p===void 0?void 0:e.document.tiles[p.index],h=k&&de(k)?k:void 0,b=(()=>{if(!h||!t)return;const x=e.document.sources.find($=>$.name===h.source)?.base??h.source,w=h.declaration.kind==="reference"?h.declaration.from:h.name;return t.sources.find($=>$.name===x)?.views.find($=>$.name===w)})();return m.jsxs(m.Fragment,{children:[m.jsx(bm,{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($m,{anchor:p?.anchor??null,tile:p===void 0?void 0:e.document.tiles[p.index],onClose:()=>g(void 0),onCommit:x=>{const w=p?.index;w!==void 0&&e.update($=>{$.tiles[w]=x})},view:b,onDuplicate:()=>{p&&s.duplicate(p.index)},...h&&Ki(h)!==void 0?{duplicateBlocked:Ki(h)}:{},...(e.document.sources.find(x=>x.name===h?.source)?.dimensions?.length??0)>0?{onDrills:()=>{y(h?Nn(h):void 0),a(h?.source)}}:{}}),m.jsx(Zp,{open:o!==void 0,document:e.document,source:e.document.sources.find(x=>x.name===o),givenNames:i.controlList.map(x=>x.name),dashboards:r??[],...v?{tileLabel:v}:{},onClose:()=>a(void 0),onApply:x=>e.update(w=>{const $=[...(w.drills??[]).filter(E=>E.source!==o),...x];$.length===0?delete w.drills:w.drills=$})}),m.jsx(Df,{...d}),m.jsx(Vp,{open:s.addingTile,document:e.document,catalog:t,columns:n,onClose:s.closeAdd,onAdd:s.addTile,onAddText:s.addText,...f?{renderPreview:f}:{}})]})}var Cm=Symbol.for("preact-signals");function ms(){if(Tt>1)Tt--;else{var e,t=!1;for((function(){var i=Vi;for(Vi=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}})();Nr!==void 0;){var n=Nr;for(Nr=void 0,Yi++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Gc(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=r}}if(Yi=0,Tt--,t)throw e}}function Me(e){if(Tt>0)return e();ho=++Mm,Tt++;try{return e()}finally{ms()}}var Wr,xe=void 0;function ae(e){var t=xe,n=Wr;xe=void 0,Wr=void 0;try{return e()}finally{xe=t,Wr=n}}var Nr=void 0,Tt=0,Yi=0,Mm=0,ho=0,Vi=void 0,Xi=0;function Kc(e){if(xe!==void 0){var t=e.n;if(t===void 0||t.t!==xe)return t={i:0,S:e,p:xe.s,n:void 0,t:xe,e:void 0,x:void 0,r:t},xe.s!==void 0&&(xe.s.n=t),xe.s=t,e.n=t,32&xe.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=xe.s,t.n=void 0,xe.s.n=t,xe.s=t),t}}function Qe(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}Qe.prototype.brand=Cm;Qe.prototype.h=function(){return!0};Qe.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:ae(function(){var r;(r=t.W)==null||r.call(t)}))};Qe.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&&ae(function(){var i;(i=t.Z)==null||i.call(t)}))}};Qe.prototype.subscribe=function(e){var t=this;return pt(function(){var n=t.value;ae(function(){return e(n)})},{name:"sub"})};Qe.prototype.valueOf=function(){return this.value};Qe.prototype.toString=function(){return this.value+""};Qe.prototype.toJSON=function(){return this.value};Qe.prototype.peek=function(){var e=this;return ae(function(){return e.value})};Object.defineProperty(Qe.prototype,"value",{get:function(){var e=Kc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Yi>100)throw new Error("Cycle detected");(function(n){Tt!==0&&Yi===0&&n.l!==ho&&(n.l=ho,Vi={S:n,v:n.v,i:n.i,o:Vi})})(this),this.v=e,this.i++,Xi++,Tt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ms()}}}});function Xn(e,t){return new Qe(e,t)}function Gc(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 Yc(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 Vc(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 pn(e,t){Qe.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Xi-1,this.f=4}pn.prototype=new Qe;pn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Xi))return!0;if(this.g=Xi,this.f|=1,this.i>0&&!Gc(this))return this.f&=-2,!0;var e=xe;try{Yc(this),xe=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 xe=e,Vc(this),this.f&=-2,!0};pn.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)}Qe.prototype.S.call(this,e)};pn.prototype.U=function(e){if(this.t!==void 0&&(Qe.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)}};pn.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(pn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Kc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function El(e,t){return new pn(e,t)}function Xc(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Tt++;var n=xe;xe=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,ha(e),r}finally{xe=n,ms()}}}function ha(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Xc(e)}function Em(e){if(xe!==this)throw new Error("Out-of-order effect");Vc(this),xe=e,this.f&=-2,8&this.f&&ha(this),ms()}function Jn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Wr&&Wr.push(this)}Jn.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()}};Jn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Xc(this),Yc(this),Tt++;var e=xe;return xe=this,Em.bind(this,e)};Jn.prototype.N=function(){2&this.f||(this.f|=2,this.u=Nr,Nr=this)};Jn.prototype.d=function(){this.f|=8,1&this.f||ha(this)};Jn.prototype.dispose=function(){this.d()};function pt(e,t){var n=new Jn(e,t);try{n.c()}catch(i){throw n.d(),i}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Om=Object.create,fa=Object.defineProperty,Tm=Object.defineProperties,Dm=Object.getOwnPropertyDescriptor,Am=Object.getOwnPropertyDescriptors,Ol=Object.getOwnPropertySymbols,Rm=Object.prototype.hasOwnProperty,Pm=Object.prototype.propertyIsEnumerable,Im=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Zn=e=>{throw TypeError(e)},fo=(e,t,n)=>t in e?fa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zm=(e,t)=>{for(var n in t||(t={}))Rm.call(t,n)&&fo(e,n,t[n]);if(Ol)for(var n of Ol(t))Pm.call(t,n)&&fo(e,n,t[n]);return e},Wm=(e,t)=>Tm(e,Am(t)),Tl=(e,t)=>fa(e,"name",{value:t,configurable:!0}),Nm=e=>{var t;return[,,,Om((t=void 0)!=null?t:null)]},Jc=["class","method","getter","setter","accessor","field","value","get","set"],br=e=>e!==void 0&&typeof e!="function"?Zn("Function expected"):e,Lm=(e,t,n,r,i)=>({kind:Jc[e],name:t,metadata:r,addInitializer:s=>n._?Zn("Already initialized"):i.push(br(s||null))}),Zc=(e,t)=>fo(t,Im("metadata"),e[3]),Jt=(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},Qn=(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=Jc[l+5],y=l>3&&(e[g-1]=[]),k=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&Dm(l<4?i:{get[n](){return ct(this,s)},set[n](x){return Nt(this,s,x)}},n));l?p&&l<4&&Tl(s,(l>2?"set ":l>1?"get ":"")+n):Tl(i,n);for(var b=r.length-1;b>=0;b--)f=Lm(l,n,d={},e[3],k),l&&(f.static=u,f.private=p,c=f.access={has:p?x=>Fm(i,x):x=>n in x},l^3&&(c.get=p?x=>(l^1?ct:Bm)(x,i,l^4?s:h.get):x=>x[n]),l>2&&(c.set=p?(x,w)=>Nt(x,i,w,l^4?s:h.set):(x,w)=>x[n]=w)),a=(0,r[b])(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?br(a)&&(l>4?y.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?Zn("Object expected"):(br(o=a.get)&&(h.get=o),br(o=a.set)&&(h.set=o),br(o=a.init)&&y.unshift(o));return l||Zc(e,i),h&&fa(i,n,h),p?l^4?s:h:i},pa=(e,t,n)=>t.has(e)||Zn("Cannot "+n),Fm=(e,t)=>Object(t)!==t?Zn('Cannot use the "in" operator on this value'):e.has(t),ct=(e,t,n)=>(pa(e,t,"read from private field"),n?n.call(e):t.get(e)),xr=(e,t,n)=>t.has(e)?Zn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Nt=(e,t,n,r)=>(pa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Bm=(e,t,n)=>(pa(e,t,"access private method"),n);function po(e,t){if(t){let n;return El(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return El(e)}function gt(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)=>!gt(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=>!gt(e[i],t[i]))}return!1}function le({get:e},t){return{init(n){return Xn(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Oe(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 Rs(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,Wm(zm({},i),{enumerable:e}))})}}function ni(...e){const t=e.map(n=>pt(n));return()=>t.forEach(n=>n())}var Qc,ed,td,nd,rd,id,Ve,ma,Ps,mo,go,Ue,ga,Is,sd,vo,va,zs,bo,xo;id=[le],rd=[le],nd=[le],td=[Rs()],ed=[Rs()],Qc=[Rs()];var mn=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Jt(Ve,5,this),xr(this,Ue),xr(this,ma,Jt(Ve,8,this)),Jt(Ve,11,this),xr(this,ga,Jt(Ve,12,this)),Jt(Ve,15,this),xr(this,va,Jt(Ve,16,this)),Jt(Ve,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return ct(this,Ue,bo)}get initial(){return ct(this,Ue,mo)}get previous(){return ct(this,Ue,sd)}set current(e){const t=ae(()=>ct(this,Ue,bo));e&&t&&this.equals(t,e)||Me(()=>{ct(this,Ue,mo)||Nt(this,Ue,e,go),Nt(this,Ue,t,vo),Nt(this,Ue,e,xo)})}reset(e=this.defaultValue){Me(()=>{Nt(this,Ue,void 0,vo),Nt(this,Ue,e,go),Nt(this,Ue,e,xo)})}};Ve=Nm();ma=new WeakMap;Ue=new WeakSet;ga=new WeakMap;va=new WeakMap;Ps=Qn(Ve,20,"#initial",id,Ue,ma),mo=Ps.get,go=Ps.set;Is=Qn(Ve,20,"#previous",rd,Ue,ga),sd=Is.get,vo=Is.set;zs=Qn(Ve,20,"#current",nd,Ue,va),bo=zs.get,xo=zs.set;Qn(Ve,2,"current",td,mn);Qn(Ve,2,"initial",ed,mn);Qn(Ve,2,"previous",Qc,mn);Zc(Ve,mn);function Ws(e){return ae(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Zt,_m=class{constructor(){xr(this,Zt,new WeakMap)}get(e,t){var n;return e?(n=ct(this,Zt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return ct(this,Zt).has(e)||ct(this,Zt).set(e,new Map),(r=ct(this,Zt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=ct(this,Zt).get(e))==null?void 0:t.clear():void 0}};Zt=new WeakMap;var Hm=Object.create,od=Object.defineProperty,Um=Object.getOwnPropertyDescriptor,Dl=Object.getOwnPropertySymbols,qm=Object.prototype.hasOwnProperty,Km=Object.prototype.propertyIsEnumerable,ad=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),gs=e=>{throw TypeError(e)},Al=Math.pow,yo=(e,t,n)=>t in e?od(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gm=(e,t)=>{for(var n in t||(t={}))qm.call(t,n)&&yo(e,n,t[n]);if(Dl)for(var n of Dl(t))Km.call(t,n)&&yo(e,n,t[n]);return e},Ym=e=>{var t;return[,,,Hm((t=e?.[ad("metadata")])!=null?t:null)]},ld=["class","method","getter","setter","accessor","field","value","get","set"],cd=e=>e!==void 0&&typeof e!="function"?gs("Function expected"):e,Vm=(e,t,n,r,i)=>({kind:ld[e],name:t,metadata:r,addInitializer:s=>n._?gs("Already initialized"):i.push(cd(s||null))}),Xm=(e,t)=>yo(t,ad("metadata"),e[3]),Jm=(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},dd=(e,t,n,r,i,s)=>{for(var o,a,d,f,c=t&7,l=!1,u=!1,p=2,g=ld[c+5],v=e[p]||(e[p]=[]),y=(i=i.prototype,Um(i,n)),k=r.length-1;k>=0;k--)d=Vm(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[k])(y[g],d),a._=1,cd(o)&&(y[g]=o);return y&&od(i,n,y),i},ud=(e,t,n)=>t.has(e)||gs("Cannot "+n),Zm=(e,t,n)=>(ud(e,t,"read from private field"),t.get(e)),Qm=(e,t,n)=>t.has(e)?gs("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),eg=(e,t,n,r)=>(ud(e,t,"write to private field"),t.set(e,n),n),dt=class wo{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new wo(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 wo(t,n)}},jt=class Qt{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 Qt(i+t,r+n,s,o);return d.scale=Gm({},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 dt((t+r)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Qt))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 Qt?tg(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 Qt(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 dt.delta({x:i(t,"x"),y:i(t,"y")},{x:i(n,"x"),y:i(n,"y")})}static intersectionRatio(t,n){return Qt.from(t).intersectionRatio(Qt.from(n))}};function tg(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 hd,fd,ko,Oi,ri,vs=class extends(ko=mn,fd=[Oe],hd=[Oe],ko){constructor(e){const t=dt.from(e);super(t,(n,r)=>dt.equals(n,r)),Jm(ri,5,this),Qm(this,Oi,0),this.velocity={x:0,y:0}}get delta(){return dt.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=dt.from(e),r={x:n.x-t.x,y:n.y-t.y},i=Date.now(),s=i-Zm(this,Oi),o=a=>Math.round(a/s*100);Me(()=>{eg(this,Oi,i),this.velocity={x:o(r.x),y:o(r.y)},super.current=n})}reset(e=this.defaultValue){super.reset(dt.from(e)),this.velocity={x:0,y:0}}};ri=Ym(ko);Oi=new WeakMap;dd(ri,2,"delta",fd,vs);dd(ri,2,"direction",hd,vs);Xm(ri,vs);function So({x:e,y:t},n){const r=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(Al(r,2)+Al(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 pd=(e=>(e.Horizontal="x",e.Vertical="y",e))(pd||{}),md=Object.values(pd),ng=Object.create,ba=Object.defineProperty,rg=Object.defineProperties,ig=Object.getOwnPropertyDescriptor,sg=Object.getOwnPropertyDescriptors,Ji=Object.getOwnPropertySymbols,gd=Object.prototype.hasOwnProperty,vd=Object.prototype.propertyIsEnumerable,bd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),er=e=>{throw TypeError(e)},$o=(e,t,n)=>t in e?ba(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xa=(e,t)=>{for(var n in t||(t={}))gd.call(t,n)&&$o(e,n,t[n]);if(Ji)for(var n of Ji(t))vd.call(t,n)&&$o(e,n,t[n]);return e},ya=(e,t)=>rg(e,sg(t)),Rl=(e,t)=>ba(e,"name",{value:t,configurable:!0}),xd=(e,t)=>{var n={};for(var r in e)gd.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ji)for(var r of Ji(e))t.indexOf(r)<0&&vd.call(e,r)&&(n[r]=e[r]);return n},tr=e=>{var t;return[,,,ng((t=e?.[bd("metadata")])!=null?t:null)]},yd=["class","method","getter","setter","accessor","field","value","get","set"],yr=e=>e!==void 0&&typeof e!="function"?er("Function expected"):e,og=(e,t,n,r,i)=>({kind:yd[e],name:t,metadata:r,addInitializer:s=>n._?er("Already initialized"):i.push(yr(s||null))}),gn=(e,t)=>$o(t,bd("metadata"),e[3]),V=(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=yd[l+5],y=l>3&&(e[g-1]=[]),k=e[g]||(e[g]=[]),h=l&&(!p&&!u&&(i=i.prototype),l<5&&(l>3||!p)&&ig(l<4?i:{get[n](){return Ee(this,s)},set[n](x){return st(this,s,x)}},n));l?p&&l<4&&Rl(s,(l>2?"set ":l>1?"get ":"")+n):Rl(i,n);for(var b=r.length-1;b>=0;b--)f=og(l,n,d={},e[3],k),l&&(f.static=u,f.private=p,c=f.access={has:p?x=>ag(i,x):x=>n in x},l^3&&(c.get=p?x=>(l^1?Ee:wd)(x,i,l^4?s:h.get):x=>x[n]),l>2&&(c.set=p?(x,w)=>st(x,i,w,l^4?s:h.set):(x,w)=>x[n]=w)),a=(0,r[b])(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?yr(a)&&(l>4?y.unshift(a):l?p?s=a:h[v]=a:i=a):typeof a!="object"||a===null?er("Object expected"):(yr(o=a.get)&&(h.get=o),yr(o=a.set)&&(h.set=o),yr(o=a.init)&&y.unshift(o));return l||gn(e,i),h&&ba(i,n,h),p?l^4?s:h:i},wa=(e,t,n)=>t.has(e)||er("Cannot "+n),ag=(e,t)=>Object(t)!==t?er('Cannot use the "in" operator on this value'):e.has(t),Ee=(e,t,n)=>(wa(e,t,"read from private field"),n?n.call(e):t.get(e)),ue=(e,t,n)=>t.has(e)?er("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),st=(e,t,n,r)=>(wa(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),wd=(e,t,n)=>(wa(e,t,"access private method"),n);function kd(e,t){return{plugin:e,options:t}}function ii(e){return t=>kd(e,t)}function Ur(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Sd,qr,ka,Ti;Sd=[le];var qe=class{constructor(e,t){this.manager=e,this.options=t,ue(this,ka,V(qr,8,this,!1)),V(qr,11,this),ue(this,Ti,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return ae(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=pt(e.bind(this));return Ee(this,Ti).add(t),t}destroy(){Ee(this,Ti).forEach(e=>e())}static configure(e){return kd(this,e)}};qr=tr(null);ka=new WeakMap;Ti=new WeakMap;ce(qr,4,"disabled",Sd,qe,ka);gn(qr,qe);var si=class extends qe{},Di,Ns=class{constructor(e){this.manager=e,this.instances=new Map,ue(this,Di,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(Ur).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 Ee(this,Di))if(!n.includes(r)){if(r.prototype instanceof si)continue;this.unregister(r)}for(const{plugin:r,options:i}of t)this.register(r,i);st(this,Di,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()}};Di=new WeakMap;function lg(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var bi=[],Cn,Mn,cg=class extends qe{constructor(e){super(e),ue(this,Cn),ue(this,Mn),this.computeCollisions=this.computeCollisions.bind(this),st(this,Mn,Xn(bi)),this.destroy=ni(()=>{const t=this.computeCollisions(),n=ae(()=>this.manager.dragOperation.position.current);if(t!==bi){const r=Ee(this,Cn);if(st(this,Cn,n),r&&n.x==r.x&&n.y==r.y)return}else st(this,Cn,void 0);Ee(this,Mn).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){ae(()=>{e?Ee(this,Mn).value=this.computeCollisions():st(this,Cn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:i,shape:s,status:o}=r;if(!o.initialized||!s)return bi;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=ae(()=>c({droppable:f,dragOperation:r}));l&&(f.collisionPriority!=null&&(l.priority=f.collisionPriority),a.push(l))}return d.length===0?bi:(a.sort(lg),a)}get collisions(){return Ee(this,Mn).value}};Cn=new WeakMap;Mn=new WeakMap;var $d,jd,Cd,Sa,Md,vt,$a,Rn,ja,Ca;Cd=[le],jd=[le],$d=[le];var At=class en{constructor(t,n){ue(this,$a,V(vt,8,this)),V(vt,11,this),ue(this,Rn),ue(this,ja,V(vt,12,this)),V(vt,15,this),ue(this,Ca,V(vt,16,this)),V(vt,19,this);const{effects:r,id:i,data:s={},disabled:o=!1,register:a=!0}=t;let d=i;st(this,Rn,Xn(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=Ee(this,Rn).value;return(n=(t=en.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const i=(r=(n=en.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Ee(this,Rn).peek();t!==i&&(en.pendingIdChanges||(en.pendingIdChanges=new Map,queueMicrotask(()=>{var s;return wd(s=en,Sa,Md).call(s)})),en.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)}};vt=tr(null);Sa=new WeakSet;Md=function(){const e=At.pendingIdChanges;At.pendingIdChanges=null,e&&Me(()=>{for(const[t,n]of e)Ee(t,Rn).value=n})};$a=new WeakMap;Rn=new WeakMap;ja=new WeakMap;Ca=new WeakMap;ce(vt,4,"manager",Cd,At,$a);ce(vt,4,"data",jd,At,ja);ce(vt,4,"disabled",$d,At,Ca);ue(At,Sa);gn(vt,At);At.pendingIdChanges=null;var bs=At,Pl=class{constructor(){this.map=Xn(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=ni(...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}},Ed,Od,Td,Dd,Ad,Rd,jo,Xe,Ma,Ea,Oa,Ct=class extends(jo=bs,Rd=[le],Ad=[le],Dd=[le],Td=[Oe],Od=[Oe],Ed=[Oe],jo){constructor(e,t){var n=e,{modifiers:r,type:i,sensors:s,plugins:o,effects:a}=n,d=xd(n,["modifiers","type","sensors","plugins","effects"]);super(ya(xa({},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}=Ur(u);c.registry.plugins.register(p)}}]}}),t),V(Xe,5,this),ue(this,Ma,V(Xe,8,this)),V(Xe,11,this),ue(this,Ea,V(Xe,12,this)),V(Xe,15,this),ue(this,Oa,V(Xe,16,this,this.isDragSource?"dragging":"idle")),V(Xe,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=Ur(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}};Xe=tr(jo);Ma=new WeakMap;Ea=new WeakMap;Oa=new WeakMap;ce(Xe,4,"type",Rd,Ct,Ma);ce(Xe,4,"modifiers",Ad,Ct,Ea);ce(Xe,4,"status",Dd,Ct,Oa);ce(Xe,2,"isDropping",Td,Ct);ce(Xe,2,"isDragging",Od,Ct);ce(Xe,2,"isDragSource",Ed,Ct);gn(Xe,Ct);var Pd,Id,zd,Wd,Nd,Ld,Co,Pe,Ta,Da,Aa,Ra,Pa,Mt=class extends(Co=bs,Ld=[le],Nd=[le],Wd=[le],zd=[le],Id=[le],Pd=[Oe],Co){constructor(e,t){var n=e,{accept:r,collisionDetector:i,collisionPriority:s,type:o}=n,a=xd(n,["accept","collisionDetector","collisionPriority","type"]);super(a,t),V(Pe,5,this),ue(this,Ta,V(Pe,8,this)),V(Pe,11,this),ue(this,Da,V(Pe,12,this)),V(Pe,15,this),ue(this,Aa,V(Pe,16,this)),V(Pe,19,this),ue(this,Ra,V(Pe,20,this)),V(Pe,23,this),ue(this,Pa,V(Pe,24,this)),V(Pe,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}};Pe=tr(Co);Ta=new WeakMap;Da=new WeakMap;Aa=new WeakMap;Ra=new WeakMap;Pa=new WeakMap;ce(Pe,4,"accept",Ld,Mt,Ta);ce(Pe,4,"type",Nd,Mt,Da);ce(Pe,4,"collisionDetector",Wd,Mt,Aa);ce(Pe,4,"collisionPriority",zd,Mt,Ra);ce(Pe,4,"shape",Id,Mt,Pa);ce(Pe,2,"isDropTarget",Pd,Mt);gn(Pe,Mt);var dg=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)}},ug=class extends dg{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function Ai(e,t=!0){let n=!1;return ya(xa({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var hg=class extends si{constructor(e){super(e);const t=(r,i)=>r.map(({id:s})=>s).join("")===i.map(({id:s})=>s).join("");let n=[];this.destroy=ni(()=>{const{dragOperation:r,collisionObserver:i}=e;r.status.initializing&&(n=[],i.enable())},()=>{const{collisionObserver:r,monitor:i}=e,{collisions:s}=r;if(r.isDisabled()||bs.pendingIdChanges)return;const o=Ai({collisions:s});if(i.dispatch("collision",o),o.defaultPrevented||t(s,n))return;n=s;const[a]=s;ae(()=>{var d;a?.id!==((d=e.dragOperation.target)==null?void 0:d.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},nr=(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))(nr||{}),rr=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(rr||{}),Fd,Bd,_d,Hd,Ud,qd,Kd,ft,Ia;Kd=[le],qd=[Oe],Ud=[Oe],Hd=[Oe],_d=[Oe],Bd=[Oe],Fd=[Oe];var Pt=class{constructor(){V(ft,5,this),ue(this,Ia,V(ft,8,this,"idle")),V(ft,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}};ft=tr(null);Ia=new WeakMap;ce(ft,4,"value",Kd,Pt,Ia);ce(ft,2,"current",qd,Pt);ce(ft,2,"idle",Ud,Pt);ce(ft,2,"initializing",Hd,Pt);ce(ft,2,"initialized",_d,Pt);ce(ft,2,"dragging",Bd,Pt);ce(ft,2,"dropped",Fd,Pt);gn(ft,Pt);var fg=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 ae(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=Ai({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return ae(()=>{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;Me(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=r??null,t.position.reset(i)});const s=Ai({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"&&Me(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:r,operation:t.snapshot(),cancelable:!1})})}),n)})}move(e){return ae(()=>{var t,n;const{dragOperation:r}=this.manager,{status:i,controller:s}=r;if(!i.dragging||!s||s.signal.aborted)return;const o=Ai({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 ae(()=>{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=ae(()=>{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=pt(()=>{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()})}},Un=class extends qe{constructor(e,t){super(e,t),this.manager=e,this.options=t}},pg=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)}},Ri,Gd=class{constructor(e){this.options=e,ue(this,Ri)}set controller(e){st(this,Ri,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Ee(this,Ri))==null||t.activate(e)}};Ri=new WeakMap;var Il=class extends qe{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},mg=class{constructor(e){this.draggables=new Pl,this.droppables=new Pl,this.plugins=new Ns(e),this.sensors=new Ns(e),this.modifiers=new Ns(e)}register(e,t){if(e instanceof Ct)return this.draggables.register(e.id,e);if(e instanceof Mt)return this.droppables.register(e.id,e);if(e.prototype instanceof Il)return this.modifiers.register(e,t);if(e.prototype instanceof Un)return this.sensors.register(e,t);if(e.prototype instanceof qe)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof bs)return e instanceof Ct?this.draggables.unregister(e.id,e):e instanceof Mt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof Il)return this.modifiers.unregister(e);if(e.prototype instanceof Un)return this.sensors.unregister(e);if(e.prototype instanceof qe)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()}},Yd,Vd,Xd,Jd,Zd,Qd,eu,tu,nu,wr,Pi,En,Ce,za,Wa,Na,La,Fa,kr;nu=[Oe],tu=[le],eu=[le],Qd=[le],Zd=[le],Jd=[le],Xd=[Oe],Vd=[Oe],Yd=[Oe];var wt=class{constructor(e){V(Ce,5,this),ue(this,wr),ue(this,Pi),ue(this,En,new mn(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Pt,ue(this,za,V(Ce,8,this,!1)),V(Ce,11,this),ue(this,Wa,V(Ce,12,this,null)),V(Ce,15,this),ue(this,Na,V(Ce,16,this,null)),V(Ce,19,this),ue(this,La,V(Ce,20,this,null)),V(Ce,23,this),ue(this,Fa,V(Ce,24,this,[])),V(Ce,27,this),this.position=new vs({x:0,y:0}),ue(this,kr,{x:0,y:0}),st(this,wr,e)}get shape(){const{current:e,initial:t,previous:n}=Ee(this,En);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Ee(this,En).current=e:Ee(this,En).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Ee(this,wr).registry.draggables.get(t);return n&&st(this,Pi,n),(e=n??Ee(this,Pi))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Ee(this,wr).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(ya(xa({},this.snapshot()),{transform:n}));return st(this,kr,n),n}snapshot(){return ae(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Ee(this,kr),shape:this.shape?Ws(this.shape):null,position:Ws(this.position),status:Ws(this.status),canceled:this.canceled}))}reset(){Me(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Ee(this,En).reset(),this.position.reset({x:0,y:0}),st(this,kr,{x:0,y:0}),this.modifiers=[]})}};Ce=tr(null);wr=new WeakMap;Pi=new WeakMap;En=new WeakMap;za=new WeakMap;Wa=new WeakMap;Na=new WeakMap;La=new WeakMap;Fa=new WeakMap;kr=new WeakMap;ce(Ce,2,"shape",nu,wt);ce(Ce,4,"canceled",tu,wt,za);ce(Ce,4,"activatorEvent",eu,wt,Wa);ce(Ce,4,"sourceIdentifier",Qd,wt,Na);ce(Ce,4,"targetIdentifier",Zd,wt,La);ce(Ce,4,"modifiers",Jd,wt,Fa);ce(Ce,2,"source",Xd,wt);ce(Ce,2,"target",Vd,wt);ce(Ce,2,"transform",Yd,wt);gn(Ce,wt);var gg={get rendering(){return Promise.resolve()}};function yt(e,t){return typeof e=="function"?e(t):e??t}var vg=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=yt(n.plugins,[]),i=yt(n.sensors,[]),s=yt(n.modifiers,[]),o=(t=n.renderer)!=null?t:gg,a=new ug(this),d=new mg(this);this.registry=d,this.monitor=a,this.renderer=o,this.actions=new fg(this),this.dragOperation=new wt(this),this.collisionObserver=new cg(this),this.plugins=[hg,...r],this.modifiers=s,this.sensors=i;const{destroy:f}=this,c=ni(()=>{var l,u,p;const g=ae(()=>this.dragOperation.modifiers),v=this.modifiers;for(const y of g)v.includes(y)||y.destroy();this.dragOperation.modifiers=(p=(u=(l=this.dragOperation.source)==null?void 0:l.modifiers)==null?void 0:u.map(y=>{const{plugin:k,options:h}=Ur(y);return new k(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}},ru=e=>{throw TypeError(e)},Ba=(e,t,n)=>t.has(e)||ru("Cannot "+n),Y=(e,t,n)=>(Ba(e,t,"read from private field"),t.get(e)),et=(e,t,n)=>t.has(e)?ru("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),rt=(e,t,n,r)=>(Ba(e,t,"write to private field"),t.set(e,n),n),iu=(e,t,n)=>(Ba(e,t,"access private method"),n);function xs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function su(e,t){const n=e.getAnimations();let r=null;for(const i of n){if(i.playState!=="running")continue;const{effect:s}=i,o=(xs(s)?s.getKeyframes():[]).filter(t);o.length>0&&(r=[o[o.length-1],i])}return r}function ys(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 _a(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function oi(e){return"nodeType"in e}function at(e){var t,n,r;return e?_a(e)?e:oi(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 Ha(e){const{Document:t}=at(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Kt(e){return!e||_a(e)?!1:e instanceof at(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function ou(e){return e instanceof at(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function ir(e){return e?_a(e)?e.document:oi(e)?Ha(e)?e:Kt(e)||ou(e)?e.ownerDocument:document:document:document}function bg(e){var t,n,r,i;const{documentElement:s}=ir(e),o=at(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 xg(e,t){if(yg(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:i}=getComputedStyle(e);return n==="visible"&&r==="visible"&&i==="visible"}function yg(e){return e.tagName==="DETAILS"}function Kr(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(!xg(l)){const b=l.getBoundingClientRect(),x=n*(b.bottom-b.top),w=n*(b.right-b.left),$=n*(b.bottom-b.top),E=n*(b.right-b.left);d={top:Math.max(d.top,b.top-x),right:Math.min(d.right,b.right+w),bottom:Math.min(d.bottom,b.bottom+$),left:Math.max(d.left,b.left-E),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,y=(a=u?.height)!=null?a:c.innerHeight,k=n*y,h=n*v;return d={top:Math.max(d.top,p-k),right:Math.min(d.right,g+v+h),bottom:Math.min(d.bottom,p+y+k),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 qn(e){return{x:e.clientX,y:e.clientY}}var au=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Mo(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(...Mo(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(...Mo(i.document,t))}}catch{}return n}function Ua(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function lu(){var e,t;const n=Ua()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function qa(e){return!e||!oi(e)?!1:e instanceof at(e).ShadowRoot}function Zi(e){if(e&&oi(e)){let t=e.getRootNode();if(qa(t)||t instanceof Document)return t}return ir(e)}function Ka(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function wg(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];zl(i)&&zl(o)&&(i.type!=="file"&&(i.value=o.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),Wl(i)&&Wl(o)&&o.width>0&&o.height>0&&i.getContext("2d")?.drawImage(o,0,0)}),n}function zl(e){return"value"in e}function Wl(e){return e.tagName==="CANVAS"}function cu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(kg(r)){const{contentDocument:i}=r;if(i){const{left:s,top:o}=r.getBoundingClientRect();return cu(i,{x:t-s,y:n-o})}}return r}function kg(e){return e?.tagName==="IFRAME"}var Eo=new WeakMap;function Sg(e){return e.closest(`
2
2
  input:not([disabled]),
3
3
  select:not([disabled]),
4
4
  textarea:not([disabled]),
package/dist/index.html CHANGED
@@ -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-gQEuz0Cg.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-5On9Gkpl.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-DUqldpo0.css">
21
21
  </head>
22
22
  <body>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@malloy-publisher/app",
3
3
  "description": "Malloy Publisher Console (the built-in web UI)",
4
- "version": "0.9.11",
4
+ "version": "0.9.12",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",
@@ -42,7 +42,7 @@
42
42
  "test:playwright:headed": "bunx playwright test --config=playwright.config.ts --headed"
43
43
  },
44
44
  "dependencies": {
45
- "@malloy-publisher/sdk": "^0.9.11",
45
+ "@malloy-publisher/sdk": "^0.9.12",
46
46
  "@mui/icons-material": "^7.0.2",
47
47
  "@mui/material": "^7.0.2",
48
48
  "@tanstack/react-query": "^5.59.16",
@@ -1 +0,0 @@
1
- import{a as r,D as t,j as e,ab as i,aA as o}from"./index-gQEuz0Cg.js";function m(){const a=r(),{environmentName:n}=t();if(n){const s=i({environmentName:n});return e.jsx(o,{onSelectPackage:a,resourceUri:s})}else return e.jsx("div",{children:e.jsx("h2",{children:"Missing environment name"})})}export{m as default};
@@ -1 +0,0 @@
1
- import{a as n,j as t,v as o}from"./index-gQEuz0Cg.js";function s(){const a=n();return t.jsx(o,{onClickEnvironment:a})}export{s as default};