@malloy-publisher/sdk 0.18.4 → 0.18.5

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
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),k=require("../useCompiledDocument-D1jyJMDg.cjs.js"),$=require("@mui/material"),S=require("react"),be=require("../ServerProvider-Dx0lmu2I.cjs.js"),me=require("../text-entry-BJwltZiy.cjs.js"),Nf=require("react-dom"),uc=require("@tanstack/react-query"),Ce=e=>e.kind==="text",ce=e=>e.kind!=="text",lr=e=>ce(e)?e.label??e.name:e.name,dt=e=>e.declaration.kind==="query"?e.name:`${e.source} -> ${e.name}`,Hn=e=>e.declaration.kind==="inherited"||e.declaration.kind==="query",fe=e=>Ce(e)?`text.${e.name}`:e.declaration.kind==="query"?`query.${e.name}`:`${e.source}.${e.name}`,Ka=".malloy-big-value, .malloy-table",zf=e=>e.querySelector(Ka)!==null&&![...e.querySelectorAll(".malloy-chart")].some(t=>t.closest(Ka)===null),As=(e,t)=>Ce(e)?k.MIN_TEXT_TILE_ROWS:t&&zf(t)?k.MIN_VALUE_TILE_ROWS:k.MIN_TILE_ROWS,Fr=e=>e.rowspan??k.PLACED_DEFAULT_ROWSPAN[Ce(e)?"text":"query"];function Ut(e,t){if(e.row===void 0||e.col===void 0)return;const n=Math.min(e.colspan??1,t);return{row:e.row,col:Math.min(e.col,t-n+1),colspan:n,rowspan:Fr(e)}}const Wr=(e,t)=>e.col<t.col+t.colspan&&t.col<e.col+e.colspan&&e.row<t.row+t.rowspan&&t.row<e.row+e.rowspan;function In(e){return e.map((t,n)=>({tile:t,index:n})).sort((t,n)=>(t.tile.row??1/0)-(n.tile.row??1/0)||(t.tile.col??1/0)-(n.tile.col??1/0)||t.index-n.index).map(({tile:t})=>t)}function Rt(e,t,n){const r=e.map(a=>({...a})),s=[],o=a=>{const l=Ut(r[a],t);l&&(r[a].col=l.col,s.push(l))};n!==void 0&&o(n);const i=r.map((a,l)=>({tile:a,index:l})).filter(({index:a,tile:l})=>a!==n&&l.row!==void 0).sort((a,l)=>(a.tile.row??0)-(l.tile.row??0)||(a.tile.col??0)-(l.tile.col??0)||a.index-l.index);for(const{index:a}of i){const l=Ut(r[a],t);if(l){for(;;){const u=s.filter(c=>Wr(l,c));if(u.length===0)break;l.row=Math.max(...u.map(c=>c.row+c.rowspan))}r[a].row=l.row,o(a)}}return r}function Gf(e,t,n,r){const s=e.flatMap((l,u)=>{const c=u===t?void 0:Ut(l,r);return c?[c]:[]}),o=Math.max(1,...s.map(l=>l.row+l.rowspan)),i={...e[t],...n,row:Math.min(n.row,o)},a=Ut(i,r);if(a){for(;;){const l=s.filter(u=>u.row<a.row&&Wr(a,u));if(l.length===0)break;a.row=Math.max(...l.map(u=>u.row+u.rowspan))}i.row=a.row}return Rt(e.map((l,u)=>u===t?i:l),r,t)}const Ls=(e,t)=>(e-k.GRID_GAP_PX*(t-1))/t,fc=k.TILE_ROW_PX+k.GRID_GAP_PX;function hc(e,t,n,r,s){const o=Math.min(n,r),i=Math.round(e/(s+k.GRID_GAP_PX))+1;return{row:Math.max(1,Math.round(t/fc)+1),col:Math.min(Math.max(i,1),r-o+1)}}function pc(e,t,n,r){const s=e.map((o,i)=>{if(o.row!==void 0&&o.col!==void 0)return o;const a=t[i];if(!a)return o;const{break:l,...u}=o,c=o.colspan??Math.max(1,Math.round((a.width+k.GRID_GAP_PX)/(r+k.GRID_GAP_PX))),d=hc(a.left,a.top,c,n,r),f=(a.top+a.height+k.GRID_GAP_PX)/fc,h=Ce(o)?Math.ceil(f-.02):Math.round(f);return{...u,...d,colspan:c,rowspan:o.rowspan??Math.max(As(o),h-d.row+1)}});return Rt(s,n)}function Va(e,t,n){const r=e.flatMap((o,i)=>{const a=i===t?void 0:Ut(o,n);return a?[a]:[]});if(r.length===0)return[...e];const s=Math.max(...r.map(o=>o.row+o.rowspan));return e.map((o,i)=>i===t?{...o,row:s,col:1}:o)}function gc(e,t){const n=e.map(o=>({...o})),r=[],s=n.map((o,i)=>({tile:o,index:i})).filter(({tile:o})=>o.row!==void 0&&o.col!==void 0).sort((o,i)=>(o.tile.row??0)-(i.tile.row??0)||(o.tile.col??0)-(i.tile.col??0)||o.index-i.index);for(const{index:o}of s){const i=Ut(n[o],t);if(i){for(;i.row>1&&!r.some(a=>Wr({...i,row:i.row-1},a));)i.row-=1;n[o].row=i.row,n[o].col=i.col,r.push(i)}}return n}const Hf=(e,t)=>gc(e,t).some((n,r)=>n.row!==e[r].row||n.col!==e[r].col);function qf(e){return In(e).map(t=>{const{row:n,col:r,...s}=t;return s})}const Uf=(e,t,n)=>e.map((r,s)=>s===t?{...r,...n}:r);function Xa(e,t,n,r,s){const o=Ut(e[t],s);if(!o)return[...e];const i={row:Math.max(1,o.row+n),col:Math.min(Math.max(1,o.col+r),s-o.colspan+1)};if(i.row===o.row&&i.col===o.col)return[...e];const a={...o,...i},l=e.flatMap((h,y)=>{const g=y===t?void 0:Ut(h,s);return g&&Wr(a,g)&&!Wr(o,g)?[{i:y,other:g}]:[]}),u=l.length===1?l[0]:void 0;if(!u)return Rt(Uf(e,t,i),s,t);const{i:c,other:d}=u,f=e.map(h=>({...h}));return n>0?(f[c].row=o.row,f[t].row=o.row+d.rowspan):n<0?(f[t].row=d.row,f[c].row=d.row+o.rowspan):r>0?(f[c].col=o.col,f[t].col=o.col+d.colspan):(f[t].col=d.col,f[c].col=d.col+o.colspan),Rt(f,s,t)}const mc=(e,t)=>e?.col===void 0?t:Math.max(1,t-e.col+1);function Kf(e){return Ce(e)||e.rowspan===void 0?e:k.isChartPick(e.chart)&&e.chart!=="big_value"&&e.rowspan<k.MIN_TILE_ROWS?{...e,rowspan:k.MIN_TILE_ROWS}:e}const vc=k.createSvgIcon(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"})),yc=k.createSvgIcon(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"})),Vf=k.createSvgIcon(m.jsx("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"}));function xc(e){const{theme:t}=be.usePublisherTheme(),n=t.ui,[r,s]=S.useState(null),{status:o,draftKeptAt:i,discard:a,restored:l,dismissRestored:u}=e,c=l!==void 0&&!l.pending&&o==="unsaved"?l:void 0,d=o==="saved"?"Saved":o==="saving"?"Saving…":i!==void 0?"Draft saved":"Unsaved changes",f=c?`Restored your unsaved edits from ${qo(c.savedAt)}`:void 0,h=o==="unsaved"&&i!==void 0?"Your edits are kept in this browser. Done saves them to the report.":e.saveTarget,y=a!==void 0&&o==="unsaved",g=()=>{s(null),c&&u?.()},w=v=>({display:"inline-flex",alignItems:"center",justifyContent:"flex-end",gap:.75,minWidth:132,height:n.size.control,px:1,borderRadius:n.radius.control,font:"inherit",...n.type.control,whiteSpace:"nowrap",color:o==="saved"?v.palette.text.secondary:v.palette.text.primary,transition:`color ${k.MOTION_FAST}, background-color ${k.MOTION_FAST}`,...y?{"&:hover":{bgcolor:v.palette.action.hover}}:{}}),x=m.jsxs(m.Fragment,{children:[m.jsx($.Box,{component:"span","aria-hidden":!0,sx:{width:16,height:16,flex:"none",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:o==="saved"?m.jsx(k.CheckIcon,{sx:{fontSize:16}}):m.jsx($.Box,{component:"span","data-restored":c?"true":void 0,sx:v=>({width:7,height:7,borderRadius:"50%",bgcolor:c?t.accent:o==="saving"||i!==void 0?v.palette.text.disabled:v.palette.warning.main,transition:`background-color ${k.MOTION_FAST}`})})}),m.jsx($.Box,{component:"span","aria-hidden":!0,children:d}),m.jsx(k.ExpandMoreIcon,{"aria-hidden":!0,sx:{fontSize:16,ml:-.25,visibility:y?"visible":"hidden"}})]}),p=m.jsx($.Box,{component:"span",role:"status","aria-live":"polite",sx:Xf,children:f?`${d}. ${f}.`:d});return m.jsxs(m.Fragment,{children:[p,m.jsx($.Tooltip,{title:f??h,describeChild:!0,children:y?m.jsx($.ButtonBase,{className:k.reportClasses.saveStatus,"aria-label":d,...f?{"aria-description":f}:{},"aria-haspopup":"menu","aria-expanded":r!==null,onClick:v=>s(v.currentTarget),sx:w,children:x}):m.jsx($.Box,{component:"span",className:k.reportClasses.saveStatus,sx:w,children:x})}),m.jsxs($.Menu,{className:k.reportClasses.menu,anchorEl:r,open:r!==null,onClose:g,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:-4,horizontal:"left"},slotProps:{paper:{sx:{minWidth:240,borderRadius:n.radius.menu,border:`1px solid ${k.edgeColor(t.cardBorder)}`,boxShadow:n.shadow.menu}}},MenuListProps:{dense:!0,sx:{py:.5}},children:[(f!==void 0||i!==void 0)&&m.jsx($.Box,{component:"li",role:"presentation",sx:{px:1.75,pt:.75,pb:1,...n.type.caption,color:"text.secondary"},children:f??`Kept in this browser at ${qo(i)}`}),m.jsxs($.MenuItem,{onClick:()=>{s(null),a?.()},sx:{mx:.5,borderRadius:n.radius.control,gap:1.25,color:"error.main","&.Mui-focusVisible":{outline:"none",bgcolor:"action.hover"}},children:[m.jsx(Vf,{fontSize:"small"}),"Discard edits"]})]})]})}function qo(e){const t=new Date(e);return new Date().toDateString()===t.toDateString()?t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}const Xf={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},Uo=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),cn=Uo?"⌘":"Ctrl+",Ya=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},So=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function Yf(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 s=o=>{const i=t.current;if(i.paused)return;const a=Uo?o.metaKey:o.ctrlKey,l=o.key.toLowerCase();if(o.key==="Escape"){if(Ya(o.target)||So(o.target))return;i.escape();return}if(Ya(o.target)){if(a&&l==="s"){if(o.preventDefault(),!i.save||So(o.target))return;o.target.blur(),r(!0)}return}if(So(o.target)){a&&l==="s"&&o.preventDefault();return}if(a&&l==="z"){o.preventDefault(),o.shiftKey?i.redo():i.undo();return}if(!Uo&&a&&l==="y"){o.preventDefault(),i.redo();return}if(a&&l==="s"){o.preventDefault(),i.save?.();return}if(i.move&&o.altKey&&!a&&!o.shiftKey){const u=o.key==="ArrowLeft"?[0,-1]:o.key==="ArrowRight"?[0,1]:o.key==="ArrowUp"?[-1,0]:o.key==="ArrowDown"?[1,0]:void 0;if(u&&i.move(u[0],u[1])){o.preventDefault();return}}i.nudge&&!a&&!o.altKey&&!o.shiftKey&&(o.key==="ArrowLeft"||o.key==="ArrowRight")&&(o.preventDefault(),i.nudge(o.key==="ArrowRight"?1:-1))};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[])}const Mr=(e,t,n=be.DEFAULT_UI)=>({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}}}),Nr=(e=be.DEFAULT_UI)=>({width:e.size.control,height:e.size.control,borderRadius:e.radius.control,"& svg":{fontSize:18}}),Bs={height:20,alignSelf:"center",mx:.5,my:0},Fs=(e,t=be.DEFAULT_UI)=>({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"}}}),Ko={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function Qf({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:s,saving:o,onSave:i,savesTo:a="package",saveLabel:l,saveButton:u,actions:c,onAddTile:d,arrange:f,onExit:h,saveStatus:y}){const{theme:g}=be.usePublisherTheme(),w=k.edgeColor(g.cardBorder),x=k.hoverEdgeColor(g.cardBorder,g.tileTitle);return m.jsxs($.Stack,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[f,d&&m.jsx($.Button,{variant:"outlined",startIcon:m.jsx(k.AddIcon,{}),onClick:d,"aria-label":"Add tile",sx:Mr(w,x,g.ui),children:"Tile"}),d&&m.jsx($.Divider,{orientation:"vertical",sx:Bs}),m.jsx($.Tooltip,{title:`Undo (${cn}Z)`,children:m.jsx("span",{children:m.jsx($.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:Nr(g.ui),children:m.jsx(yc,{fontSize:"small"})})})}),m.jsx($.Tooltip,{title:`Redo (${cn}⇧Z)`,children:m.jsx("span",{children:m.jsx($.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:Nr(g.ui),children:m.jsx(vc,{fontSize:"small"})})})}),(c||i||h)&&m.jsx($.Divider,{orientation:"vertical",sx:Bs}),c,i&&y&&m.jsx(xc,{...y}),i?m.jsx($.Tooltip,{title:s?`Save (${cn}S) · ${l??Ko[a]}`:l??Ko[a],children:m.jsx("span",{children:m.jsx($.Button,{ref:u,variant:s?"contained":"outlined",disabled:!s||o,onClick:i,sx:{...Mr(w,x,g.ui),minWidth:88},children:o?"Saving…":s?"Save":"Saved"})})}):null,i&&m.jsx($.Box,{component:"span","aria-live":"polite",sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},children:o?"Saving":s?"Unsaved changes":"All changes saved"}),h&&m.jsx(k.SecondaryButton,{label:"Close",icon:m.jsx(k.CheckIcon,{}),onClick:h})]})}const Zf=e=>`This view has no field for the x-axis: ${e.toLowerCase()} needs a group by, such as a date or a category`,Qa={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map",combo_chart:"Bar and line"};function bc(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this tile's details":n==="unlisted"?"Not in the model's list, so its shape is unknown":void 0,s=e?.shape,o=a=>{if(t===a)return;if(a==="big_value")return e?.aggregateOnly===!0?void 0:s&&s.groupBys>0?"This view has a group by, so it is more than one row; big numbers need a view of totals only":r??"Needs results that are only totals (no group by)";if(a==="shape_map"||a==="segment_map")return e?.chart===a?void 0:r??"Needs a map chart set in the model";if(e?.chart===a)return;if(!s)return a==="combo_chart"?r??"Needs a view with a group by and exactly two totals: the first is drawn as bars, the second as a line":void 0;const l=`A ${Qa[a].toLowerCase()} chart`;switch(k.chartShapeGap(a,s)){case"no_x_axis":return Zf(l);case"combo_totals":return`A bar and line chart needs exactly two totals, the first drawn as bars and the second as a line; this view has ${s.totals}`;case"no_y_axis":return`This view has no total for the y-axis: ${l.toLowerCase()} needs at least one aggregate`;default:return}};return[{value:"default",label:"Default",hint:"As set in the model"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map","combo_chart"].map(a=>{const l=o(a);return{value:a,label:Qa[a],...l?{disabled:!0,reason:l}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Za(e){return e.description??k.readableName(e.name)}const Jf={bar_chart:"a bar chart",line_chart:"a line chart",scatter_chart:"a scatter chart",combo_chart:"a bar and line chart",shape_map:"a shape map",segment_map:"a segment map",big_value:"a big value",sparkline:"a sparkline"},ls=(e,t)=>`${e}\0${t}`;function eh({open:e,document:t,catalog:n,columns:r,onClose:s,onAdd:o,onAddText:i,renderPreview:a}){const{theme:l}=be.usePublisherTheme(),u=l.ui,c=k.edgeColor(l.cardBorder),d=S.useMemo(()=>n?.sources??[],[n]),[f,h]=S.useState(""),[y,g]=S.useState(),[w,x]=S.useState(""),[p,v]=S.useState("default"),_=S.useRef(null),b=S.useMemo(()=>{const j=new Set(t.sources.map(z=>z.base));return[...d].sort((z,D)=>Number(j.has(D.name))-Number(j.has(z.name)))},[d,t]),E=b.filter(j=>j.views.length>0),T=b.filter(j=>j.views.length===0),M=S.useMemo(()=>new Map(E.flatMap(j=>j.views.map(z=>[ls(j.name,z.name),{source:j,view:z,key:ls(j.name,z.name)}]))),[E]),O=S.useMemo(()=>E.map(j=>({key:j.name,label:j.name,...j.description?{detail:j.description}:{},entries:j.views.map(z=>({key:ls(j.name,z.name),name:z.name,title:Za(z),...z.chart?{chart:z.chart}:{}}))})),[E]),C=y===void 0?void 0:M.get(y);S.useEffect(()=>{if(!e)return;h(""),x(""),v("default");const j=E[0]?.views[0];g(j&&E[0]?ls(E[0].name,j.name):void 0)},[e]);const A=C?[C.source.name,C.view.name].filter(j=>!me.isBareName(j)).map(j=>`"${j}" is not a plain Malloy name, so a tile cannot be written for it.`)[0]:void 0,R=C!==void 0&&A===void 0,L=C?Za(C.view):"",G=p!=="default"&&C?{chart:p,chartCarried:C.view.chart?[C.view.chart]:[]}:{},N=(j=C)=>{if(!j||![j.source.name,j.view.name].every(me.isBareName))return;const z=j.key===C?.key,D=k.writtenSpan(Math.ceil(r/2),r);o({base:j.source.name,modelPath:j.source.modelPath,...j.source.exporters?{exporters:j.source.exporters}:{},view:j.view.name,...z&&w.trim()?{label:w.trim()}:{},...z?G:{},...D!==void 0?{colspan:D}:{}})},X=C?bc(C.view,p).filter(j=>j.value!=="custom"&&j.disabled!==!0):[];return m.jsx(k.AppDialog,{className:`${k.reportClasses.dialog} ${k.reportClasses.addTileDialog}`,open:e,onClose:s,maxWidth:"md",initialFocus:_,title:"Add a tile",description:"Pick what the tile shows from the model. You can change its title and chart now or later.",actions:m.jsxs(m.Fragment,{children:[m.jsx($.Button,{onClick:i,sx:{mr:"auto"},children:"Add text instead"}),m.jsx($.Button,{onClick:s,children:"Cancel"}),m.jsx($.Button,{variant:"contained",disabled:!R,onClick:()=>N(),children:"Add tile"})]}),children:m.jsxs($.Box,{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($.Box,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${c}`},maxHeight:{xs:280,md:"none"}},children:m.jsx(k.ViewPicker,{groups:O,query:f,onQuery:h,picked:C?.key,onPick:j=>{g(j),v("default")},onTake:j=>N(M.get(j)),searchRef:_,empty:m.jsx($.Typography,{variant:"body2",sx:{color:l.tileTitle,p:2},children:n?"This package's models have nothing to put on a tile yet.":"The package's sources are still loading."}),footer:T.length>0&&m.jsxs($.Typography,{variant:"caption",component:"p",sx:{color:"text.secondary",px:2,pt:1.5},children:["Also in this package, with no views to show:"," ",T.map(j=>j.name).join(", "),"."]})})}),m.jsx($.Box,{sx:j=>({p:2.5,display:"flex",flexDirection:"column",gap:2,minHeight:0,overflowY:"auto",bgcolor:`color-mix(in srgb, ${j.palette.text.primary} 3%, ${j.palette.background.paper})`}),children:C?m.jsxs(m.Fragment,{children:[m.jsx($.Box,{"aria-label":"Preview",role:"region",sx:j=>({height:240,flex:"none",display:"flex",position:"relative",overflow:"hidden",borderRadius:u.radius.tile,border:`1px solid ${c}`,bgcolor:j.palette.background.paper,"&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,height:40,pointerEvents:"none",background:`linear-gradient(to bottom, transparent, ${j.palette.background.paper})`}}),children:a?m.jsx($.Box,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:a({base:C.source.name,modelPath:C.source.modelPath,view:C.view.name,label:w.trim()||L,...p!=="default"?G:{},givens:C.source.givens})}):m.jsxs($.Box,{sx:j=>({flex:1,border:`1px solid ${c}`,borderRadius:u.radius.tile,bgcolor:j.palette.background.paper,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,color:"text.secondary"}),children:[m.jsx(k.ChartGlyph,{chart:C.view.chart}),m.jsxs($.Typography,{variant:"body2",children:[C.source.name," → ",C.view.name]})]})}),m.jsx($.TextField,{size:"small",label:"Title",placeholder:L,value:w,onChange:j=>x(j.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Tile title"}}),m.jsxs($.Box,{children:[m.jsx($.Typography,{component:"div",sx:{...u.type.label,color:"text.secondary",mb:.75},children:"Chart"}),m.jsx($.ToggleButtonGroup,{size:"small",exclusive:!0,value:p,"aria-label":"Chart",onChange:(j,z)=>{z!==null&&v(z)},sx:{...Fs(c,u),"& .MuiToggleButton-root":{...Fs(c,u)["& .MuiToggleButton-root"],textTransform:"none"}},children:X.map(j=>m.jsx($.ToggleButton,{value:j.value,children:j.label},j.value))}),m.jsx($.Typography,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:C.view.chart?`The model sets ${Jf[C.view.chart]??"a chart"}.`:"The model sets no chart, so it shows as a table."})]}),A&&m.jsx($.Typography,{variant:"body2",color:"error",children:A})]}):m.jsx($.Typography,{variant:"body2",sx:{color:"text.secondary",m:"auto"},children:"Pick a view to see it here."})})]})})}function th(e,t,{modelPath:n,textHeld:r,widths:s,insertAt:o}){t.modelPath&&!r&&(e.imports=k.withSource(e,t.base,t.modelPath,n,t.exporters??[t.modelPath]));const i=wc(e,t.base),a=Vo(e,i.name,t.view);e.tiles.splice(o??e.tiles.length,0,{name:a,source:i.name,declaration:{kind:"reference",from:t.view},...s&&t.colspan!==void 0?{colspan:t.colspan}:{},...t.label?{label:t.label}:{},...t.chart?{chart:t.chart}:{},...t.chartCarried?{chartCarried:t.chartCarried}:{}})}function wc(e,t,{unscoped:n=!1}={}){const r=e.sources.find(a=>a.base===t&&(!n||!a.scopedBy?.length));if(r)return r;const s=new Set(e.sources.map(a=>a.name));let o=`${t}_tiles`;for(let a=2;s.has(o);a++)o=`${t}_tiles_${a}`;const i={name:o,base:t};return e.sources.push(i),i}function Vo(e,t,n){const r=new Set(e.tiles.filter(ce).filter(o=>o.source===t).map(o=>o.name));let s=`${n}_tile`;for(let o=2;r.has(s);o++)s=`${n}_tile_${o}`;return s}function Ws(e){switch(e.declaration.kind){case"inline":return"Its query is written in this file, and the builder does not copy a query's body.";case"opaque":return`Its query is ${e.declaration.why}, which the builder does not copy.`;case"query":return"It names a query, and a copy could not be told apart from it: the builder writes nothing about such a tile but its place.";default:return e.chart==="custom"?"Its chart line is one the builder does not write, so a copy would lose it.":void 0}}function nh(e,t){const n=e.tiles[t];if(!n||!ce(n)||Ws(n)!==void 0)return;let r;if(n.declaration.kind==="reference"){const{break:o,...i}=structuredClone(n);r={...i,name:Vo(e,n.source,n.declaration.from)}}else{const i=e.sources.find(a=>a.name===n.source)??wc(e,n.source,{unscoped:!0});r={name:Vo(e,i.name,n.name),source:i.name,declaration:{kind:"reference",from:n.name},...n.colspan!==void 0?{colspan:n.colspan}:{}}}const s=n.row!==void 0&&n.col!==void 0;return s&&(r={...r,row:(n.row??1)+Fr(n),col:n.col,...n.rowspan!==void 0?{rowspan:n.rowspan}:{}}),e.tiles.splice(t+1,0,r),s&&(e.tiles=Rt(e.tiles,e.columns??k.DEFAULT_COLUMNS,t+1)),t+1}const cs="self";function rh({open:e,document:t,source:n,givenNames:r,dashboards:s,tileLabel:o,onClose:i,onApply:a}){const{theme:l}=be.usePublisherTheme(),u=l.ui,[c,d]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const p=(t.drills??[]).filter(v=>v.source===n.name);d((n.dimensions??[]).map(v=>{const _=p.find(b=>b.name===v.name);return{name:v.name,expression:v.expression,to:_?.to??[],given:_?.given??""}}))},[e,n,t]);const f=(p,v)=>d(_=>_.map((b,E)=>{if(E!==p)return b;const T={...b};return v(T),T})),h=[cs,...s.filter(p=>p!==cs)],y=p=>p===cs?"This report":p,g=()=>{n&&(a(c.filter(p=>p.to.length>0).map(p=>({source:n.name,name:p.name,expression:p.expression,to:p.to,...p.given?{given:p.given}:{}}))),i())},w=k.edgeColor(l.cardBorder),x=(p,v)=>f(p,_=>{v?_.to=_.lastTo?.length?_.lastTo:[cs]:(_.lastTo=_.to,_.to=[])});return m.jsx(k.AppDialog,{className:`${k.reportClasses.dialog} ${k.reportClasses.clickableCellsDialog}`,open:e,onClose:i,title:"Clickable cells",description:m.jsxs(m.Fragment,{children:[o&&m.jsxs($.Box,{component:"span",sx:{fontWeight:u.type.label.fontWeight},children:[o," ·"," "]}),"A click on a table cell sets a filter to its value, on this report or on the one it opens. Bars, lines and points on a chart do not respond to a click. Clicks work in the report, not while you edit it."]}),actions:m.jsxs(m.Fragment,{children:[m.jsx($.Button,{onClick:i,children:"Cancel"}),m.jsx($.Button,{variant:"contained",onClick:g,disabled:c.length===0,children:"Apply"})]}),children:c.length===0?m.jsx($.Typography,{variant:"body2",sx:{color:l.tileTitle,pt:1},children:n?m.jsxs(m.Fragment,{children:[m.jsx($.Box,{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($.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):m.jsx($.Box,{role:"list","aria-label":"Dimensions",children:c.map((p,v)=>{const _=p.to.length>0;return m.jsxs($.Box,{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:v===0?"none":`1px solid ${w}`},children:[m.jsx($.Switch,{size:"small",checked:_,onChange:b=>x(v,b.target.checked),slotProps:{input:{"aria-label":`${p.name} is clickable`}}}),m.jsxs($.Box,{sx:{minWidth:0},children:[m.jsx($.Box,{sx:{...u.type.control,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:sh(p.name)}),m.jsxs($.Box,{title:p.expression,sx:{...u.type.code,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[p.name," is ",p.expression]})]}),_?m.jsxs($.Stack,{direction:"row",sx:{gridColumn:{xs:"1 / -1",sm:"auto"},alignItems:"center",gap:1,justifyContent:"flex-end",...u.type.control},children:[m.jsx($.Box,{component:"span",sx:{color:"text.secondary"},children:"Opens"}),m.jsx($.TextField,{select:!0,size:"small",value:p.to,inputProps:{"aria-label":`Where ${p.name} goes`},SelectProps:{multiple:!0,renderValue:b=>b.map(y).join(", ")},onChange:b=>f(v,E=>{const T=b.target.value,M=Array.isArray(T)?T:String(T).split(",").filter(Boolean);M.length===0&&(E.lastTo=E.to),E.to=M}),sx:{flex:"1 1 150px",minWidth:0,maxWidth:200},children:h.map(b=>m.jsxs($.MenuItem,{value:b,children:[m.jsx($.Checkbox,{size:"small",checked:p.to.includes(b),sx:{p:0,mr:1}}),m.jsx($.ListItemText,{primary:y(b)})]},b))}),m.jsx($.Box,{component:"span",sx:{color:"text.secondary"},children:"sets"}),m.jsxs($.TextField,{select:!0,size:"small",value:p.given,inputProps:{"aria-label":`Control ${p.name} sets`},SelectProps:{displayEmpty:!0,renderValue:b=>b===""?p.name:String(b)},onChange:b=>f(v,E=>{E.given=b.target.value}),sx:{flex:"1 1 120px",minWidth:0,maxWidth:170},children:[m.jsx($.MenuItem,{value:"",children:m.jsx($.ListItemText,{primary:p.name,secondary:"Named like the dimension"})}),r.map(b=>m.jsx($.MenuItem,{value:b,children:b},b))]})]}):m.jsx($.Typography,{variant:"body2",sx:{color:"text.secondary",textAlign:"right",display:{xs:"none",sm:"block"}},children:"Not clickable"})]},p.name)})})})}function sh(e){const t=e.replace(/_+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const oh=k.createSvgIcon(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"})),ih=k.createSvgIcon(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"})),ah=k.createSvgIcon(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"})),lh=k.createSvgIcon(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"})),ch=k.createSvgIcon(m.jsx("path",{d:"M4 9h16v2H4zm0 4h10v2H4z"})),dh=k.createSvgIcon(m.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33v-4h3.33zM19 17h-3.33v-4H19zm0-6h-8.67V7H19z"}));function uh(e,t=[]){const n=new Map;for(const o of e.tiles)for(const i of ce(o)?o.filters??[]:[])n.set(i.given,(n.get(i.given)??0)+1);const r=[],s=new Set;for(const o of e.localGivens??[])s.add(o.name),r.push({name:o.name,...o.label===void 0?{}:{label:o.label},type:o.type,...o.suggest?{field:o.suggest.dimension}:{},origin:"dashboard",local:o,boundTiles:n.get(o.name)??0});for(const o of t)s.has(o.name)||(s.add(o.name),r.push({...o,origin:"model",boundTiles:n.get(o.name)??0}));for(const[o,i]of n)s.has(o)||r.push({name:o,origin:"model",boundTiles:i});return r}function Ns(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function fh(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function Ir(e,t){const n=fh(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const s=new Set(["date","timestamp"]);return s.has(n)?s.has(r):n===r}function Xo(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 hh(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const ph=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function gh(e,t){const r=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",s=/^[A-Z_]/.test(r)?r:`F_${r}`,o=me.isStrictName(s)?s:`${s}_FILTER`,i=new Set(t);if(!i.has(o))return o;for(let a=2;;a++)if(!i.has(`${o}_${a}`))return`${o}_${a}`}const mh=[{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 fr(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 Yo=e=>ce(e)&&!Hn(e)&&e.declaration.kind!=="opaque";function vh(e,t){return e.tiles.map(n=>{const r=(ce(n)?n.filters??[]:[]).find(s=>s.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:Ns(t.type)!==void 0?{op:Ns(t.type)}:{}}})}function yh(e,t,n){n.forEach((r,s)=>{const o=e.tiles[s];if(!o||!Yo(o))return;const i=(o.filters??[]).filter(l=>l.given!==t),a=r.include?[...i,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:i;a.length>0?o.filters=a:delete o.filters})}function xh(e,t){const n=(e.localGivens??[]).filter(o=>o.name!==t.name),r=(e.localGivens??[]).findIndex(o=>o.name===t.name),s=[...n];s.splice(r>=0?r:s.length,0,t),e.localGivens=s}function bh(e,t){for(const r of e.tiles){if(!ce(r))continue;const s=(r.filters??[]).filter(o=>o.given!==t);s.length>0?r.filters=s:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const Qo=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function wh({open:e,document:t,control:n,available:r,takenNames:s=[],fieldsFor:o,onApply:i}){const a=S.useRef(n);e&&(a.current=n);const l=e?n:a.current,u=l!==void 0,[c,d]=S.useState({kind:"new"}),[f,h]=S.useState(""),[y,g]=S.useState("select"),[w,x]=S.useState(""),[p,v]=S.useState(""),[_,b]=S.useState([]),[E,T]=S.useState(!1),[M,O]=S.useState(!1),C=P=>t.sources.find(F=>F.name===P.source)?.base??P.source;S.useEffect(()=>{if(e)if(O(n!==void 0),n){d({kind:"existing",name:n.name}),h(n.label??"");const P=vh(t,n);b(P);const F=P.filter(Y=>Y.include),U=new Set(F.map(Y=>Y.field));v(U.size===1?F[0].field:n.field??""),T(U.size>1)}else d({kind:"new"}),h(""),g("select"),v(""),x(new Date().toISOString().slice(0,10)),b(t.tiles.map(P=>({include:Yo(P),field:""}))),T(!1)},[e,n,t]);const A=S.useMemo(()=>[...(t.localGivens??[]).map(P=>P.name),...r.map(P=>P.name),...s],[t,r,s]),R=S.useMemo(()=>p.trim()?gh(p.trim(),A):"",[p,A]),L=c.kind==="existing"?n??r.find(P=>P.name===c.name):R?{name:R,type:fr({name:R,label:f,kind:y,field:p}).type}:void 0,G=L?.type!==void 0&&!L.type.startsWith("filter<"),N=_.find(P=>P.include)?.op??Ns(L?.type),X=(P,F)=>{O(!0),b(U=>U.map((Y,Se)=>Se===P?{...Y,...F}:Y))},j=P=>{O(!0),b(F=>F.map(U=>({...U,op:P})))},z=P=>{const F=Ns(P);b(U=>U.map(({op:Y,...Se})=>F?{...Se,op:F}:Se))},D=P=>{O(!0),d({kind:"existing",name:P.name}),v(P.field??""),z(P.type)},I=P=>{O(!0),g(P),z(fr({name:"X",label:f,kind:P,field:p}).type)},B=t.tiles.map(Yo),q=B.filter(Boolean).length,H=_.filter((P,F)=>P.include&&B[F]).length,K=t.tiles.filter((P,F)=>(_[F]?.include??!1)&&B[F]&&ce(P)),te=K.length>0?K:t.tiles.filter((P,F)=>B[F]&&ce(P)),ye=S.useMemo(()=>{const P=new Map;let F=!1;for(const U of te){const Y=o?.(U);if(Y){F=!0;for(const Se of Y)P.has(Se.name)||P.set(Se.name,Se)}}return F?[...P.values()]:void 0},[_,t.tiles,o]),_e=(()=>{const P=p.trim();for(const F of K){const U=o?.(F);if(!U||U.some(Y=>Y.name===P))return C(F)}return K[0]?C(K[0]):t.sources[0]?.base})(),re=P=>{O(!0),b(F=>F.map((U,Y)=>({...U,include:P&&B[Y]})))},De=S.useMemo(()=>E?_:_.map(P=>({...P,field:p})),[E,_,p]),ge=P=>{for(const F of te){const U=o?.(F)?.find(Y=>Y.name===P.trim());if(U?.type)return U.type}},ve=P=>Ir(L?.type,P.type),Ge=(P,F)=>{if(P.trim()==="")return"Pick the field this filter compares.";const U=F?o?.(F):void 0;if(!U)return;const Y=U.find(Se=>Se.name===P.trim());if(!Y)return`Not a field of ${F?C(F):"the tiles' source"}.`;if(Y.type&&!Ir(L?.type,Y.type))return`${P.trim()} is ${Xo(Y.type)}; this filter compares ${Xo(L?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},Z=P=>{if(O(!0),v(P),u||c.kind!=="new")return;const F=ge(P),U=fr({name:"X",label:f,kind:y,field:P}).type;F&&!Ir(U,F)&&I(hh(F))},Xe=P=>{const F=t.tiles[P];return F&&ce(F)?F:void 0},ke=De.map((P,F)=>P.include&&B[F]?Ge(P.field,Xe(F)):void 0),ue=ke.every(P=>P===void 0),Oe=M?ke:ke.map(()=>{}),Ae=M&&!E&&H>0?K.map(P=>Ge(p,P)).find(Boolean):void 0,ie=L!==void 0&&ue&&(c.kind==="existing"||p.trim()!==""&&R!==""),qe=()=>{if(!(!L||!ie))if(c.kind==="new")i(L.name,De,fr({name:L.name,label:f.trim()||Qo(L.name),kind:y,field:p.trim(),..._e?{source:_e}:{},...w?{dateDefault:w}:{}}));else if(n?.origin==="dashboard"&&n.local){const P=f.trim(),F=P!==(n.local.label??"");i(L.name,De,F?{...n.local,...P?{label:P}:{}}:void 0)}else i(L.name,De)},Ye=u&&l.origin==="model";return{editing:u,shown:l,fromModel:Ye,source:c,setSource:d,label:f,setLabel:h,kind:y,dateDefault:w,setDateDefault:x,field:p,rows:_,setRows:b,perTile:E,setPerTile:T,newName:R,target:L,valueTyped:G,commonOp:N,setRow:X,setCommonOp:j,pickExisting:D,pickKind:I,bindable:B,bindableCount:q,included:H,commonFields:ye,setAll:re,accepts:ve,pickField:Z,rowProblems:Oe,commonProblem:Ae,canApply:ie,apply:qe}}function Ja({value:e,onChange:t,fields:n,accepts:r,label:s,ariaLabel:o,error:i,helperText:a,disabled:l,autoFocus:u,placeholder:c,inputRef:d,sx:f}){const h=S.useMemo(()=>(n??[]).filter(g=>r?.(g)??!0).map(g=>g.name),[n,r]),y=S.useMemo(()=>new Map((n??[]).map(g=>[g.name,g.type])),[n]);return m.jsx($.Autocomplete,{freeSolo:!0,size:"small",options:h,inputValue:e,onInputChange:(g,w)=>t(w),value:e,onChange:(g,w)=>t(typeof w=="string"?w:""),disabled:l,disableClearable:!0,renderOption:(g,w)=>S.createElement("li",{...g,key:w},m.jsx(tl,{type:y.get(w)}),m.jsx($.Typography,{variant:"body2",sx:{flex:1,ml:1},children:w})),renderInput:g=>m.jsx($.TextField,{...g,label:s,placeholder:c,autoFocus:u,...d?{inputRef:d}:{},error:i,helperText:a,InputLabelProps:{...g.InputLabelProps,shrink:!0},InputProps:{...g.InputProps,startAdornment:y.get(e.trim())?m.jsx($.Box,{sx:{display:"flex",ml:.5,mr:-.25},children:m.jsx(tl,{type:y.get(e.trim())})}):void 0},inputProps:{...g.inputProps,"aria-label":o}}),sx:f})}const _h=e=>e&&ce(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:e&&ce(e)&&e.declaration.kind==="query"?{label:"Not bindable",reason:"It names a query, whose filters live in that query's own definition."}:{label:"From the model",reason:"Declared on its source, which this report does not write."};function kh({open:e,document:t,control:n,available:r,takenNames:s,fieldsFor:o,onClose:i,onApply:a,onRemove:l}){const{theme:u}=be.usePublisherTheme(),c=u.ui,{editing:d,shown:f,fromModel:h,source:y,setSource:g,label:w,setLabel:x,kind:p,dateDefault:v,setDateDefault:_,field:b,rows:E,setRows:T,perTile:M,setPerTile:O,newName:C,target:A,valueTyped:R,commonOp:L,setRow:G,setCommonOp:N,pickExisting:X,pickKind:j,bindable:z,bindableCount:D,included:I,commonFields:B,setAll:q,accepts:H,pickField:K,rowProblems:te,commonProblem:ye,canApply:_e,apply:re}=wh({open:e,document:t,control:n,available:r,...s?{takenNames:s}:{},fieldsFor:o,onApply:a}),De=S.useRef(null),ge=k.edgeColor(u.cardBorder),ve=k.hoverEdgeColor(u.cardBorder,u.tileTitle),[Ge,Z]=S.useState(!1),[Xe,ke]=S.useState(!1);S.useEffect(()=>{e?ke(!0):Z(!1)},[e]),S.useEffect(()=>{Xe&&(ke(!1),Z(d&&I<D))},[Xe]),S.useEffect(()=>{M&&Z(!0)},[M]);const ue=B?.find(P=>P.name===b.trim())?.type,Oe=P=>{if(!ue)return;const F=fr({name:"X",label:w,kind:P,field:b}).type;return Ir(F,ue)?void 0:`${b.trim()} is ${Xo(ue)}, which this control cannot filter.`},Ae=w.trim()||(C?Qo(C):"Filter"),ie=p==="number"?"Any":p==="date"?v?new Date(`${v}T00:00:00`).toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"}):"Any":"All",qe={...Fs(ge,c),alignSelf:"flex-start","& .MuiToggleButton-root":{...Fs(ge,c)["& .MuiToggleButton-root"],textTransform:"none"}},Ye=(P,F,U)=>m.jsx($.TextField,{select:!0,size:"small",label:"Compares",value:P??">=",onChange:Y=>F(Y.target.value),inputProps:{"aria-label":U},sx:{width:130},children:ph.filter(Y=>Y.op!=="~").map(Y=>m.jsx($.MenuItem,{value:Y.op,children:Y.label},Y.op))});return m.jsx(k.AppDialog,{className:`${k.reportClasses.dialog} ${k.reportClasses.filterDialog}`,open:e,onClose:i,...d?{}:{initialFocus:De},title:d?f.label??f.name:"Add a filter",description:d?m.jsxs(m.Fragment,{children:[m.jsxs($.Box,{component:"span",sx:{fontFamily:c.font.mono},children:["$",f.name]}),h?" · 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:[d&&m.jsx($.Button,{color:"error",startIcon:m.jsx(k.DeleteOutlineIcon,{}),onClick:()=>l(f.name),sx:P=>({mr:"auto",color:k.dangerTextColor(P)}),children:"Remove filter"}),m.jsx($.Button,{onClick:i,children:"Cancel"}),m.jsx($.Tooltip,{title:_e||A===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:m.jsx("span",{children:m.jsx($.Button,{variant:"contained",onClick:re,disabled:!_e,children:d?"Apply":"Add filter"})})})]}),children:m.jsxs($.Stack,{sx:{gap:2.5,pt:1},children:[!d&&r.length>0&&m.jsxs($.ToggleButtonGroup,{exclusive:!0,size:"small",value:y.kind,onChange:(P,F)=>{F==="new"?g({kind:"new"}):F==="existing"&&r[0]&&X(r[0])},"aria-label":"Where the filter comes from",sx:qe,children:[m.jsx($.ToggleButton,{value:"new",children:"New in this report"}),m.jsx($.ToggleButton,{value:"existing",children:"From the model"})]}),!d&&y.kind==="existing"?m.jsx($.TextField,{select:!0,size:"small",label:"Filter",value:y.name,onChange:P=>{const F=r.find(U=>U.name===P.target.value);F&&X(F)},children:r.map(P=>m.jsxs($.MenuItem,{value:P.name,children:[P.label??P.name,m.jsxs($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",P.name]})]},P.name))}):null,m.jsxs($.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:h?"1fr":"minmax(0, 1.4fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[!M&&m.jsx(Ja,{value:b,onChange:K,fields:B,accepts:H,label:"Field",ariaLabel:"Field to filter",placeholder:"category",inputRef:De,error:ye!==void 0,helperText:ye??(!d&&C?`Declared as $${C}`:void 0)}),!h&&m.jsx($.TextField,{size:"small",label:"Label",placeholder:C?Qo(C):"",value:w,onChange:P=>x(P.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Filter label"}})]}),R&&!M&&Ye(L,N,"Comparison"),!d&&y.kind==="new"&&m.jsxs($.Box,{children:[m.jsx(el,{children:"Control"}),m.jsx($.Box,{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:mh.map(P=>{const F=P.kind===p,U=Oe(P.kind);return m.jsx($.Tooltip,{title:U??P.hint,describeChild:!0,children:m.jsxs($.ButtonBase,{role:"radio","aria-checked":F,"aria-label":P.label,"aria-disabled":U!==void 0,onClick:()=>{U===void 0&&j(P.kind)},sx:Y=>({flexDirection:"column",gap:.5,px:1,py:1.25,borderRadius:c.radius.tile,border:`1px solid ${F?u.accent:ge}`,boxShadow:F?`0 0 0 1px ${u.accent}`:"none",bgcolor:F?`color-mix(in srgb, ${u.accent} 6%, ${Y.palette.background.paper})`:Y.palette.background.paper,color:F?u.accent:Y.palette.text.secondary,opacity:U?.45:1,cursor:U?"default":"pointer",transition:`border-color ${k.MOTION_FAST}, background-color ${k.MOTION_FAST}`,"&:hover":U||F?{}:{borderColor:ve}}),children:[m.jsx($h,{kind:P.kind}),m.jsx($.Box,{component:"span",sx:{...c.type.caption,fontWeight:F?600:500,color:F?u.accent:"text.primary",textAlign:"center"},children:Sh[P.kind]})]})},P.kind)})}),p==="date"&&m.jsx($.TextField,{size:"small",type:"date",label:"Starts at",value:v,onChange:P=>_(P.target.value),InputLabelProps:{shrink:!0},sx:{mt:1.5,width:200}})]}),m.jsxs($.Box,{sx:{border:`1px solid ${ge}`,borderRadius:c.radius.tile,overflow:"hidden"},children:[m.jsxs($.Stack,{direction:"row",sx:{alignItems:"center",gap:1.25,px:1.5,py:1},children:[m.jsx(dh,{"aria-hidden":!0,sx:{fontSize:18,color:"text.secondary"}}),m.jsxs($.Typography,{variant:"body2",sx:{flex:1,minWidth:0},children:[m.jsx($.Box,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:I===D&&D>0?`Applies to all ${I} tile${I===1?"":"s"}`:`Applies to ${I} of ${D} tile${D===1?"":"s"}`}),!M&&b.trim()!==""&&I>0&&m.jsxs($.Box,{component:"span",sx:{color:"text.secondary"},children:[" · each filters on ",m.jsx($.Box,{component:"span",sx:{...c.type.code},children:b.trim()})]})]}),!M&&m.jsx($.Button,{size:"small","aria-expanded":Ge,onClick:()=>Z(P=>!P),children:Ge?"Done choosing":"Choose tiles"})]}),m.jsx($.Collapse,{in:Ge,unmountOnExit:!0,children:m.jsxs($.Box,{sx:{borderTop:`1px solid ${ge}`,px:.5,pb:1},children:[m.jsxs($.Stack,{direction:"row",sx:{alignItems:"center",gap:.5,pt:.5},children:[m.jsx($.Checkbox,{size:"small",checked:D>0&&I===D,indeterminate:I>0&&I<D,disabled:D===0,onChange:P=>q(P.target.checked),inputProps:{"aria-label":"All tiles"}}),m.jsx($.Typography,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:"All tiles"}),m.jsx($.Button,{size:"small",onClick:()=>{M||T(P=>P.map(F=>({...F,field:b}))),O(P=>!P)},children:M?"Same field for all":"Adjust per tile"})]}),m.jsx($.Stack,{sx:{gap:M?1:0},children:t.tiles.map((P,F)=>{if(!ce(P))return null;const U=E[F],Y=P.label??P.name,Se=M?te[F]:void 0;return m.jsxs($.Stack,{direction:"row",sx:{gap:1,alignItems:M?"flex-start":"center",opacity:z[F]?1:.6},children:[m.jsx($.Checkbox,{size:"small",disabled:!z[F],checked:(U?.include??!1)&&z[F],inputProps:{"aria-label":`Filter ${Y}`},onChange:we=>G(F,{include:we.target.checked})}),m.jsx($.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:M?1:0},noWrap:!0,children:Y}),z[F]?M&&m.jsxs(m.Fragment,{children:[R&&Ye(U?.op,we=>G(F,{op:we}),`Comparison for ${Y}`),m.jsx(Ja,{value:U?.field??"",onChange:we=>G(F,{field:we}),fields:o?.(P),accepts:H,label:"Field",ariaLabel:`Field for ${Y}`,disabled:!U?.include,error:Se!==void 0,helperText:Se,sx:{width:220,pr:1}})]}):m.jsx($.Typography,{variant:"caption",sx:{color:u.tileTitle,pr:1,maxWidth:260,textAlign:"right"},children:_h(t.tiles[F]).reason})]},fe(P))})})]})})]}),I===0&&m.jsx($.Typography,{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."}),!h&&m.jsxs($.Box,{children:[m.jsx(el,{children:"Preview"}),m.jsx($.Box,{sx:P=>({display:"flex",alignItems:"center",gap:1,p:1.5,borderRadius:c.radius.tile,bgcolor:P.palette.action.hover}),children:m.jsxs($.Box,{"aria-hidden":!0,sx:P=>({display:"inline-flex",alignItems:"center",gap:.75,height:30,px:1.25,borderRadius:c.radius.control,border:`1px solid ${ge}`,bgcolor:P.palette.background.paper,...c.type.control}),children:[m.jsx($.Box,{component:"span",sx:{color:"text.secondary"},children:Ae}),m.jsx($.Box,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:ie}),m.jsx(k.ExpandMoreIcon,{sx:{fontSize:16,color:"text.secondary"}})]})})]})]})})}function el({children:e}){const t=be.usePublisherTheme().theme.ui;return m.jsx($.Typography,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}const Sh={select:"Pick one",multiselect:"Pick several",text:"Text",number:"Range",date:"Date"};function $h({kind:e}){const t={fontSize:22};switch(e){case"select":return m.jsx(oh,{sx:t});case"multiselect":return m.jsx(ih,{sx:t});case"text":return m.jsx(ch,{sx:t});case"number":return m.jsx(lh,{sx:t});case"date":return m.jsx(ah,{sx:t})}}function tl({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=be.usePublisherTheme().theme.ui;return n?m.jsx($.Box,{component:"span","aria-hidden":!0,sx:s=>({fontFamily:r.font.mono,fontSize:10,fontWeight:r.type.label.fontWeight,color:s.palette.text.secondary,bgcolor:s.palette.action.hover,borderRadius:"4px",px:.5,py:.25,minWidth:22,textAlign:"center",flex:"none"}),children:n}):null}const nl=k.createSvgIcon(m.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}));function _c(e,t,n,r){const[s,o]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&o(structuredClone(e))},[t,e]),{draft:s,patch:c=>o(d=>{if(d===void 0)return d;const f=structuredClone(d);return c(f),f}),apply:c=>{if(s===void 0)return;const d=structuredClone(s);c(d),o(d),JSON.stringify(d)!==JSON.stringify(e)&&n(d)},close:()=>{s!==void 0&&e!==void 0&&JSON.stringify(s)!==JSON.stringify(e)&&n(s),r()},discard:()=>o(void 0)}}const Th=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.`,Eh=new Set(["bar_chart","line_chart","scatter_chart","combo_chart"]),Ch="Its chart's bars, lines and points do not respond to a click; show it as a table to click its cells.",Oh="Declared on its source, so its chart is set in the model.",Mh="It names a query, so its chart is set where that query is declared.";function Ih({anchor:e,tile:t,onClose:n,onCommit:r,onDrills:s,onDuplicate:o,duplicateBlocked:i,view:a,viewStatus:l}){const{theme:u}=be.usePublisherTheme(),c=u.ui,{draft:d,apply:f,patch:h,close:y}=_c(t,e!==null,r,n),[g,w]=S.useState(void 0),x=d!==void 0&&ce(d)?d:void 0,p=x!==void 0&&!Hn(x),v=D=>f(I=>{ce(I)&&D(I)}),_=S.useRef(void 0),b=S.useRef(null),E=e!==null;S.useEffect(()=>{E?_.current=t&&ce(t)?t.chart:void 0:w(void 0)},[E]);const T=x?.chart??"default",M=bc(a,T,l),O=x?x.declaration.kind==="query"?Mh:p?x.chart==="custom"?Th(x.chartLines):void 0:Oh:void 0,C=D=>v(I=>{const B=_.current;D===(B??"default")?(B===void 0?delete I.chart:I.chart=B,delete I.chartCarried):(I.chart=D,a?I.chartCarried=a.chart?[a.chart]:[]:delete I.chartCarried)}),A=p?s?void 0:"Its source declares no dimension a click could filter by.":void 0,R=T==="default"?a?.chart:T,L=R!==void 0&&Eh.has(R)?Ch:void 0,G=D=>I=>w({kind:D,anchor:I.currentTarget}),N=O??(R===void 0||!Dh.has(R)?"Only a bar, line, scatter or bar and line chart has a color to set.":void 0),X=Array.from(new Set(u.series.map(k.seriesColorFrom).filter(D=>D!==void 0))).slice(0,8),j=D=>v(I=>{D===void 0?delete I.color:I.color=D.toLowerCase()}),z=(D,I,B)=>m.jsxs(m.Fragment,{children:[m.jsx($.ListItemText,{primary:D,...B?{secondary:B}:{},secondaryTypographyProps:{sx:{whiteSpace:"normal",maxWidth:240}}}),I&&m.jsx($.Typography,{variant:"body2",sx:{color:"text.secondary",ml:2},children:I})]});return m.jsxs(m.Fragment,{children:[m.jsxs($.Menu,{className:k.reportClasses.menu,open:e!==null&&d!==void 0,anchorEl:e,onClose:y,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":x?dt(x):"Tile"},slotProps:{paper:{sx:{minWidth:240,mt:.5,borderRadius:c.radius.menu,border:`1px solid ${k.edgeColor(u.cardBorder)}`,boxShadow:c.shadow.menu}}},children:[x&&m.jsxs($.MenuItem,{"aria-haspopup":"menu","aria-expanded":g?.kind==="chart",disabled:O!==void 0,onClick:G("chart"),onKeyDown:D=>{D.key==="ArrowRight"&&O===void 0&&w({kind:"chart",anchor:D.currentTarget})},children:[z("Chart",O?void 0:M.find(D=>D.value===T)?.label,O),m.jsx(nl,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),x&&O===void 0&&m.jsxs($.MenuItem,{"aria-haspopup":"menu","aria-expanded":g?.kind==="color",disabled:N!==void 0,onClick:G("color"),onKeyDown:D=>{D.key==="ArrowRight"&&N===void 0&&w({kind:"color",anchor:D.currentTarget})},children:[z("Color",N?void 0:x.color??"Theme",N),!N&&m.jsx($o,{color:x.color??u.series[0],trailing:!0}),m.jsx(nl,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),p&&m.jsx($.MenuItem,{"aria-haspopup":"dialog",disabled:A!==void 0,onClick:()=>{y(),s?.()},children:z("Clickable cells…",void 0,A??L)}),x&&o&&m.jsx($.MenuItem,{disabled:i!==void 0,onClick:()=>{y(),o()},children:z("Duplicate",void 0,i)}),x?.declaration.kind==="opaque"&&m.jsxs($.Typography,{variant:"body2",sx:{color:u.tileTitle,px:2,py:.75,maxWidth:260},children:["Its body is ",x.declaration.why,", so a filter has no single place to go."]}),x&&m.jsx($.Divider,{}),x&&m.jsx($.Box,{"aria-hidden":!0,sx:{px:2,py:.5,...c.type.code,color:"text.secondary"},children:dt(x).replace("->","→")})]}),m.jsx($.Menu,{className:k.reportClasses.menu,open:g?.kind==="chart",anchorEl:g?.anchor??null,onClose:()=>w(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":"Chart",onKeyDown:D=>{D.key==="ArrowLeft"&&(D.preventDefault(),w(void 0))}},children:M.filter(D=>D.value!=="custom").map(D=>m.jsxs($.MenuItem,{role:"menuitemradio","aria-checked":D.value===T,disabled:D.disabled===!0,onClick:()=>{C(D.value),w(void 0)},children:[m.jsx($.ListItemText,{primary:D.label,...D.reason??D.hint?{secondary:D.reason??D.hint}:{}}),D.value===T&&m.jsx($.ListItemIcon,{sx:{minWidth:0,ml:2},children:m.jsx(k.CheckIcon,{fontSize:"small",sx:{color:u.accent}})})]},D.value))}),m.jsxs($.Menu,{className:k.reportClasses.menu,open:g?.kind==="color",anchorEl:g?.anchor??null,onClose:()=>w(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,"aria-label":"Color",onKeyDown:D=>{D.key==="ArrowLeft"&&(D.preventDefault(),w(void 0))}},children:[m.jsxs($.MenuItem,{role:"menuitemradio","aria-checked":x?.color===void 0,onClick:()=>{j(void 0),w(void 0)},children:[m.jsx($o,{color:u.series[0]}),m.jsx($.ListItemText,{primary:"Theme",secondary:"The page's own colors"}),x?.color===void 0&&m.jsx(rl,{color:u.accent})]}),X.map(D=>m.jsxs($.MenuItem,{role:"menuitemradio","aria-checked":x?.color===D.toLowerCase(),onClick:()=>{j(D),w(void 0)},children:[m.jsx($o,{color:D}),m.jsx($.ListItemText,{primary:D.toLowerCase()}),x?.color===D.toLowerCase()&&m.jsx(rl,{color:u.accent})]},D)),m.jsx($.Divider,{}),m.jsxs($.MenuItem,{component:"label","aria-checked":x?.color!==void 0&&!X.some(D=>D.toLowerCase()===x.color),role:"menuitemradio",onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),b.current?.click())},children:[m.jsx("input",{ref:b,type:"color","aria-label":"Other color",value:x?.color??Ph(u.series[0]),onChange:D=>{const I=D.target.value;k.isSeriesColor(I)&&h(B=>{ce(B)&&(B.color=I.toLowerCase())})},style:{width:18,height:18,padding:0,border:"none",background:"none",marginRight:12}}),m.jsx($.ListItemText,{primary:"Other color…"})]})]})]})}const Dh=new Set(["bar_chart","line_chart","scatter_chart","combo_chart"]),Ph=e=>(e&&k.seriesColorFrom(e))??"#000000";function $o({color:e,trailing:t=!1}){return m.jsx($.Box,{"aria-hidden":!0,"data-swatch":t?"trailing":"leading",sx:{width:14,height:14,borderRadius:"3px",bgcolor:e,border:"1px solid rgba(0,0,0,0.15)",...t?{ml:1}:{mr:1.5},flex:"none"}})}function rl({color:e}){return m.jsx($.ListItemIcon,{sx:{minWidth:0,ml:2},children:m.jsx(k.CheckIcon,{fontSize:"small",sx:{color:e}})})}const co=e=>e.label??k.tileTitle(dt(e));function jh({editor:e,catalog:t,columns:n,dashboards:r,bindings:s,tiles:o,drillSource:i,setDrillSource:a,exitDialog:l,renderViewPreview:u,takenGivenNames:c}){const{filterDialog:d,setFilterDialog:f}=s,{menu:h,setMenu:y}=o,[g,w]=S.useState(),x=h===void 0?void 0:e.document.tiles[h.index],p=x&&ce(x)?x:void 0,v=(()=>{if(!p||!t)return;const _=t.documentViews?.get(p.source??"")?.get(p.name);if(_&&e.document.sources.some(T=>T.name===p.source))return _;if(p.declaration.kind==="inline"||p.declaration.kind==="opaque")return;const b=e.document.sources.find(T=>T.name===p.source)?.base??p.source,E=p.declaration.kind==="reference"?p.declaration.from:p.name;return t.sources.find(T=>T.name===b)?.views.find(T=>T.name===E)})();return m.jsxs(m.Fragment,{children:[m.jsx(kh,{open:d!==void 0,document:e.document,...d?.control?{control:d.control}:{},available:s.available,...c?{takenNames:c}:{},...t?{fieldsFor:s.fieldsFor}:{},onClose:()=>f(void 0),onApply:s.applyFilter,onRemove:s.dropControl}),m.jsx(Ih,{anchor:h?.anchor??null,tile:h===void 0?void 0:e.document.tiles[h.index],onClose:()=>y(void 0),onCommit:_=>{const b=h?.index;if(b===void 0)return;const E=Kf(_);e.update(T=>{T.tiles[b]=E,E!==_&&k.isPlaced(T.tiles)&&(T.tiles=Rt(T.tiles,n,b))})},view:v,...v===void 0&&p?{viewStatus:t?"unlisted":"loading"}:{},onDuplicate:()=>{h&&o.duplicate(h.index)},...p&&Ws(p)!==void 0?{duplicateBlocked:Ws(p)}:{},...(e.document.sources.find(_=>_.name===p?.source)?.dimensions?.length??0)>0?{onDrills:()=>{w(p?co(p):void 0),a(p?.source)}}:{}}),m.jsx(rh,{open:i!==void 0,document:e.document,source:e.document.sources.find(_=>_.name===i),givenNames:s.controlList.map(_=>_.name),dashboards:r??[],...g?{tileLabel:g}:{},onClose:()=>a(void 0),onApply:_=>e.update(b=>{const T=[...(b.drills??[]).filter(M=>M.source!==i),..._];T.length===0?delete b.drills:b.drills=T})}),m.jsx(k.UnsavedChangesDialog,{...l}),m.jsx(eh,{open:o.addingTile,document:e.document,catalog:t,columns:n,onClose:o.closeAdd,onAdd:o.addTile,onAddText:o.addText,...u?{renderPreview:u}:{}})]})}var Rh=Symbol.for("preact-signals");function uo(){if(Pt>1)Pt--;else{var e,t=!1;for((function(){var s=Gs;for(Gs=void 0;s!==void 0;){var o=s.S;if(o.v===s.v)for(var i=o.t;i!==void 0;i=i.x)i.i===s.i&&(i.i=o.i);s=s.o}})();Pr!==void 0;){var n=Pr;for(Pr=void 0,zs++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Sc(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(zs=0,Pt--,t)throw e}}function Re(e){if(Pt>0)return e();Zo=++Ah,Pt++;try{return e()}finally{uo()}}var Dr,Te=void 0;function ae(e){var t=Te,n=Dr;Te=void 0,Dr=void 0;try{return e()}finally{Te=t,Dr=n}}var Pr=void 0,Pt=0,zs=0,Ah=0,Zo=0,Gs=void 0,Hs=0;function kc(e){if(Te!==void 0){var t=e.n;if(t===void 0||t.t!==Te)return t={i:0,S:e,p:Te.s,n:void 0,t:Te,e:void 0,x:void 0,r:t},Te.s!==void 0&&(Te.s.n=t),Te.s=t,e.n=t,32&Te.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=Te.s,t.n=void 0,Te.s.n=t,Te.s=t),t}}function it(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}it.prototype.brand=Rh;it.prototype.h=function(){return!0};it.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)}))};it.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 s;(s=t.Z)==null||s.call(t)}))}};it.prototype.subscribe=function(e){var t=this;return yt(function(){var n=t.value;ae(function(){return e(n)})},{name:"sub"})};it.prototype.valueOf=function(){return this.value};it.prototype.toString=function(){return this.value+""};it.prototype.toJSON=function(){return this.value};it.prototype.peek=function(){var e=this;return ae(function(){return e.value})};Object.defineProperty(it.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(zs>100)throw new Error("Cycle detected");(function(n){Pt!==0&&zs===0&&n.l!==Zo&&(n.l=Zo,Gs={S:n,v:n.v,i:n.i,o:Gs})})(this),this.v=e,this.i++,Hs++,Pt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{uo()}}}});function qn(e,t){return new it(e,t)}function Sc(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 $c(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 Tc(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 fn(e,t){it.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Hs-1,this.f=4}fn.prototype=new it;fn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Hs))return!0;if(this.g=Hs,this.f|=1,this.i>0&&!Sc(this))return this.f&=-2,!0;var e=Te;try{$c(this),Te=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 Te=e,Tc(this),this.f&=-2,!0};fn.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)}it.prototype.S.call(this,e)};fn.prototype.U=function(e){if(this.t!==void 0&&(it.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)}};fn.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(fn.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 sl(e,t){return new fn(e,t)}function Ec(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Pt++;var n=Te;Te=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Wi(e),r}finally{Te=n,uo()}}}function Wi(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ec(e)}function Lh(e){if(Te!==this)throw new Error("Out-of-order effect");Tc(this),Te=e,this.f&=-2,8&this.f&&Wi(this),uo()}function Un(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Dr&&Dr.push(this)}Un.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()}};Un.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Ec(this),$c(this),Pt++;var e=Te;return Te=this,Lh.bind(this,e)};Un.prototype.N=function(){2&this.f||(this.f|=2,this.u=Pr,Pr=this)};Un.prototype.d=function(){this.f|=8,1&this.f||Wi(this)};Un.prototype.dispose=function(){this.d()};function yt(e,t){var n=new Un(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Bh=Object.create,Ni=Object.defineProperty,Fh=Object.defineProperties,Wh=Object.getOwnPropertyDescriptor,Nh=Object.getOwnPropertyDescriptors,ol=Object.getOwnPropertySymbols,zh=Object.prototype.hasOwnProperty,Gh=Object.prototype.propertyIsEnumerable,Hh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Kn=e=>{throw TypeError(e)},Jo=(e,t,n)=>t in e?Ni(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qh=(e,t)=>{for(var n in t||(t={}))zh.call(t,n)&&Jo(e,n,t[n]);if(ol)for(var n of ol(t))Gh.call(t,n)&&Jo(e,n,t[n]);return e},Uh=(e,t)=>Fh(e,Nh(t)),il=(e,t)=>Ni(e,"name",{value:t,configurable:!0}),Kh=e=>{var t;return[,,,Bh((t=void 0)!=null?t:null)]},Cc=["class","method","getter","setter","accessor","field","value","get","set"],hr=e=>e!==void 0&&typeof e!="function"?Kn("Function expected"):e,Vh=(e,t,n,r,s)=>({kind:Cc[e],name:t,metadata:r,addInitializer:o=>n._?Kn("Already initialized"):s.push(hr(o||null))}),Oc=(e,t)=>Jo(t,Hh("metadata"),e[3]),Qt=(e,t,n,r)=>{for(var s=0,o=e[t>>1],i=o&&o.length;s<i;s++)t&1?o[s].call(n):r=o[s].call(n,r);return r},Vn=(e,t,n,r,s,o)=>{var i,a,l,u,c,d=t&7,f=!!(t&8),h=!!(t&16),y=d>3?e.length+1:d?f?1:2:0,g=Cc[d+5],w=d>3&&(e[y-1]=[]),x=e[y]||(e[y]=[]),p=d&&(!h&&!f&&(s=s.prototype),d<5&&(d>3||!h)&&Wh(d<4?s:{get[n](){return pt(this,o)},set[n](_){return Nt(this,o,_)}},n));d?h&&d<4&&il(o,(d>2?"set ":d>1?"get ":"")+n):il(s,n);for(var v=r.length-1;v>=0;v--)u=Vh(d,n,l={},e[3],x),d&&(u.static=f,u.private=h,c=u.access={has:h?_=>Xh(s,_):_=>n in _},d^3&&(c.get=h?_=>(d^1?pt:Yh)(_,s,d^4?o:p.get):_=>_[n]),d>2&&(c.set=h?(_,b)=>Nt(_,s,b,d^4?o:p.set):(_,b)=>_[n]=b)),a=(0,r[v])(d?d<4?h?o:p[g]:d>4?void 0:{get:p.get,set:p.set}:s,u),l._=1,d^4||a===void 0?hr(a)&&(d>4?w.unshift(a):d?h?o=a:p[g]=a:s=a):typeof a!="object"||a===null?Kn("Object expected"):(hr(i=a.get)&&(p.get=i),hr(i=a.set)&&(p.set=i),hr(i=a.init)&&w.unshift(i));return d||Oc(e,s),p&&Ni(s,n,p),h?d^4?o:p:s},zi=(e,t,n)=>t.has(e)||Kn("Cannot "+n),Xh=(e,t)=>Object(t)!==t?Kn('Cannot use the "in" operator on this value'):e.has(t),pt=(e,t,n)=>(zi(e,t,"read from private field"),n?n.call(e):t.get(e)),pr=(e,t,n)=>t.has(e)?Kn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Nt=(e,t,n,r)=>(zi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Yh=(e,t,n)=>(zi(e,t,"access private method"),n);function ei(e,t){if(t){let n;return sl(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return sl(e)}function wt(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((r,s)=>!wt(r,t[s]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(o=>!wt(e[o],t[o]))}return!1}function le({get:e},t){return{init(n){return qn(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function We(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=ei(e.bind(this)),n.set(this,r)),r.value}}function To(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),s=Object.getOwnPropertyDescriptor(r,n.name);s&&Object.defineProperty(r,n.name,Uh(qh({},s),{enumerable:e}))})}}function Zr(...e){const t=e.map(n=>yt(n));return()=>t.forEach(n=>n())}var Mc,Ic,Dc,Pc,jc,Rc,nt,Gi,Eo,ti,ni,Je,Hi,Co,Ac,ri,qi,Oo,si,oi;Rc=[le],jc=[le],Pc=[le],Dc=[To()],Ic=[To()],Mc=[To()];var hn=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Qt(nt,5,this),pr(this,Je),pr(this,Gi,Qt(nt,8,this)),Qt(nt,11,this),pr(this,Hi,Qt(nt,12,this)),Qt(nt,15,this),pr(this,qi,Qt(nt,16,this)),Qt(nt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return pt(this,Je,si)}get initial(){return pt(this,Je,ti)}get previous(){return pt(this,Je,Ac)}set current(e){const t=ae(()=>pt(this,Je,si));e&&t&&this.equals(t,e)||Re(()=>{pt(this,Je,ti)||Nt(this,Je,e,ni),Nt(this,Je,t,ri),Nt(this,Je,e,oi)})}reset(e=this.defaultValue){Re(()=>{Nt(this,Je,void 0,ri),Nt(this,Je,e,ni),Nt(this,Je,e,oi)})}};nt=Kh();Gi=new WeakMap;Je=new WeakSet;Hi=new WeakMap;qi=new WeakMap;Eo=Vn(nt,20,"#initial",Rc,Je,Gi),ti=Eo.get,ni=Eo.set;Co=Vn(nt,20,"#previous",jc,Je,Hi),Ac=Co.get,ri=Co.set;Oo=Vn(nt,20,"#current",Pc,Je,qi),si=Oo.get,oi=Oo.set;Vn(nt,2,"current",Dc,hn);Vn(nt,2,"initial",Ic,hn);Vn(nt,2,"previous",Mc,hn);Oc(nt,hn);function Mo(e){return ae(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Zt,Qh=class{constructor(){pr(this,Zt,new WeakMap)}get(e,t){var n;return e?(n=pt(this,Zt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return pt(this,Zt).has(e)||pt(this,Zt).set(e,new Map),(r=pt(this,Zt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=pt(this,Zt).get(e))==null?void 0:t.clear():void 0}};Zt=new WeakMap;var Zh=Object.create,Lc=Object.defineProperty,Jh=Object.getOwnPropertyDescriptor,al=Object.getOwnPropertySymbols,ep=Object.prototype.hasOwnProperty,tp=Object.prototype.propertyIsEnumerable,Bc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),fo=e=>{throw TypeError(e)},ll=Math.pow,ii=(e,t,n)=>t in e?Lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,np=(e,t)=>{for(var n in t||(t={}))ep.call(t,n)&&ii(e,n,t[n]);if(al)for(var n of al(t))tp.call(t,n)&&ii(e,n,t[n]);return e},rp=e=>{var t;return[,,,Zh((t=e?.[Bc("metadata")])!=null?t:null)]},Fc=["class","method","getter","setter","accessor","field","value","get","set"],Wc=e=>e!==void 0&&typeof e!="function"?fo("Function expected"):e,sp=(e,t,n,r,s)=>({kind:Fc[e],name:t,metadata:r,addInitializer:o=>n._?fo("Already initialized"):s.push(Wc(o||null))}),op=(e,t)=>ii(t,Bc("metadata"),e[3]),ip=(e,t,n,r)=>{for(var s=0,o=e[t>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},Nc=(e,t,n,r,s,o)=>{for(var i,a,l,u,c=t&7,d=!1,f=!1,h=2,y=Fc[c+5],g=e[h]||(e[h]=[]),w=(s=s.prototype,Jh(s,n)),x=r.length-1;x>=0;x--)l=sp(c,n,a={},e[3],g),l.static=d,l.private=f,u=l.access={has:p=>n in p},u.get=p=>p[n],i=(0,r[x])(w[y],l),a._=1,Wc(i)&&(w[y]=i);return w&&Lc(s,n,w),s},zc=(e,t,n)=>t.has(e)||fo("Cannot "+n),ap=(e,t,n)=>(zc(e,t,"read from private field"),t.get(e)),lp=(e,t,n)=>t.has(e)?fo("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),cp=(e,t,n,r)=>(zc(e,t,"write to private field"),t.set(e,n),n),gt=class ai{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ai(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 ai(t,n)}},Ct=class Jt{constructor(t,n,r,s){this.left=t,this.top=n,this.width=r,this.height=s,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:s,width:o,height:i,scale:a}=this,l=new Jt(s+t,r+n,o,i);return l.scale=np({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:o,bottom:i}=this;return{width:t,height:n,left:r,top:s,right:o,bottom:i}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new gt((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Jt))return!1;const{left:n,top:r,width:s,height:o}=this;return n===t.left&&r===t.top&&s===t.width&&o===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:o}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=o}intersectionArea(t){return t instanceof Jt?dp(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:s}){return new Jt(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(o,i)=>{const a=r[i],l=i==="x"?o.left:o.top,u=i==="x"?o.width:o.height;return a=="start"?l:a=="end"?l+u:l+u/2};return gt.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return Jt.from(t).intersectionRatio(Jt.from(n))}};function dp(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height),i=s-r,a=o-n;return r<s&&n<o?i*a:0}var Gc,Hc,li,_s,Jr,ho=class extends(li=hn,Hc=[We],Gc=[We],li){constructor(t){const n=gt.from(t);super(n,(r,s)=>gt.equals(r,s)),ip(Jr,5,this),lp(this,_s,0),this.velocity={x:0,y:0}}get delta(){return gt.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=gt.from(t),s={x:r.x-n.x,y:r.y-n.y},o=Date.now(),i=o-ap(this,_s),a=l=>Math.round(l/i*100);Re(()=>{cp(this,_s,o),this.velocity={x:a(s.x),y:a(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(gt.from(t)),this.velocity={x:0,y:0}}};Jr=rp(li);_s=new WeakMap;Nc(Jr,2,"delta",Hc,ho);Nc(Jr,2,"direction",Gc,ho);op(Jr,ho);function ci({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(ll(r,2)+ll(s,2))>n:"x"in n&&"y"in n?r>n.x&&s>n.y:"x"in n?r>n.x:"y"in n?s>n.y:!1}var qc=(e=>(e.Horizontal="x",e.Vertical="y",e))(qc||{}),Uc=Object.values(qc),up=Object.create,Ui=Object.defineProperty,fp=Object.defineProperties,hp=Object.getOwnPropertyDescriptor,pp=Object.getOwnPropertyDescriptors,qs=Object.getOwnPropertySymbols,Kc=Object.prototype.hasOwnProperty,Vc=Object.prototype.propertyIsEnumerable,Xc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Xn=e=>{throw TypeError(e)},di=(e,t,n)=>t in e?Ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ki=(e,t)=>{for(var n in t||(t={}))Kc.call(t,n)&&di(e,n,t[n]);if(qs)for(var n of qs(t))Vc.call(t,n)&&di(e,n,t[n]);return e},Vi=(e,t)=>fp(e,pp(t)),cl=(e,t)=>Ui(e,"name",{value:t,configurable:!0}),Yc=(e,t)=>{var n={};for(var r in e)Kc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&qs)for(var r of qs(e))t.indexOf(r)<0&&Vc.call(e,r)&&(n[r]=e[r]);return n},Yn=e=>{var t;return[,,,up((t=e?.[Xc("metadata")])!=null?t:null)]},Qc=["class","method","getter","setter","accessor","field","value","get","set"],gr=e=>e!==void 0&&typeof e!="function"?Xn("Function expected"):e,gp=(e,t,n,r,s)=>({kind:Qc[e],name:t,metadata:r,addInitializer:o=>n._?Xn("Already initialized"):s.push(gr(o||null))}),pn=(e,t)=>di(t,Xc("metadata"),e[3]),ee=(e,t,n,r)=>{for(var s=0,o=e[t>>1],i=o&&o.length;s<i;s++)t&1?o[s].call(n):r=o[s].call(n,r);return r},de=(e,t,n,r,s,o)=>{var i,a,l,u,c,d=t&7,f=!!(t&8),h=!!(t&16),y=d>3?e.length+1:d?f?1:2:0,g=Qc[d+5],w=d>3&&(e[y-1]=[]),x=e[y]||(e[y]=[]),p=d&&(!h&&!f&&(s=s.prototype),d<5&&(d>3||!h)&&hp(d<4?s:{get[n](){return Fe(this,o)},set[n](_){return ut(this,o,_)}},n));d?h&&d<4&&cl(o,(d>2?"set ":d>1?"get ":"")+n):cl(s,n);for(var v=r.length-1;v>=0;v--)u=gp(d,n,l={},e[3],x),d&&(u.static=f,u.private=h,c=u.access={has:h?_=>mp(s,_):_=>n in _},d^3&&(c.get=h?_=>(d^1?Fe:Zc)(_,s,d^4?o:p.get):_=>_[n]),d>2&&(c.set=h?(_,b)=>ut(_,s,b,d^4?o:p.set):(_,b)=>_[n]=b)),a=(0,r[v])(d?d<4?h?o:p[g]:d>4?void 0:{get:p.get,set:p.set}:s,u),l._=1,d^4||a===void 0?gr(a)&&(d>4?w.unshift(a):d?h?o=a:p[g]=a:s=a):typeof a!="object"||a===null?Xn("Object expected"):(gr(i=a.get)&&(p.get=i),gr(i=a.set)&&(p.set=i),gr(i=a.init)&&w.unshift(i));return d||pn(e,s),p&&Ui(s,n,p),h?d^4?o:p:s},Xi=(e,t,n)=>t.has(e)||Xn("Cannot "+n),mp=(e,t)=>Object(t)!==t?Xn('Cannot use the "in" operator on this value'):e.has(t),Fe=(e,t,n)=>(Xi(e,t,"read from private field"),n?n.call(e):t.get(e)),pe=(e,t,n)=>t.has(e)?Xn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ut=(e,t,n,r)=>(Xi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Zc=(e,t,n)=>(Xi(e,t,"access private method"),n);function Jc(e,t){return{plugin:e,options:t}}function es(e){return t=>Jc(e,t)}function zr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var ed,Gr,Yi,ks;ed=[le];var et=class{constructor(e,t){this.manager=e,this.options=t,pe(this,Yi,ee(Gr,8,this,!1)),ee(Gr,11,this),pe(this,ks,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return ae(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=yt(e.bind(this));return Fe(this,ks).add(t),t}destroy(){Fe(this,ks).forEach(e=>e())}static configure(e){return Jc(this,e)}};Gr=Yn(null);Yi=new WeakMap;ks=new WeakMap;de(Gr,4,"disabled",ed,et,Yi);pn(Gr,et);var ts=class extends et{},Ss,Io=class{constructor(e){this.manager=e,this.instances=new Map,pe(this,Ss,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(zr).reduce((r,s)=>{const o=r.find(({plugin:i})=>i===s.plugin);return o?(o.options=s.options,r):[...r,s]},[]),n=t.map(({plugin:r})=>r);for(const r of Fe(this,Ss))if(!n.includes(r)){if(r.prototype instanceof ts)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);ut(this,Ss,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()}};Ss=new WeakMap;function vp(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var ds=[],Sn,$n,yp=class extends et{constructor(e){super(e),pe(this,Sn),pe(this,$n),this.computeCollisions=this.computeCollisions.bind(this),ut(this,$n,qn(ds)),this.destroy=Zr(()=>{const t=this.computeCollisions(),n=ae(()=>this.manager.dragOperation.position.current);if(t!==ds){const r=Fe(this,Sn);if(ut(this,Sn,n),r&&n.x==r.x&&n.y==r.y)return}else ut(this,Sn,void 0);Fe(this,$n).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){ae(()=>{e?Fe(this,$n).value=this.computeCollisions():ut(this,Sn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:o,status:i}=r;if(!i.initialized||!o)return ds;const a=[],l=[];for(const u of e??n.droppables){if(u.disabled||s&&!u.accepts(s))continue;const c=t??u.collisionDetector;if(!c)continue;l.push(u),u.shape;const d=ae(()=>c({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return l.length===0?ds:(a.sort(vp),a)}get collisions(){return Fe(this,$n).value}};Sn=new WeakMap;$n=new WeakMap;var td,nd,rd,Qi,sd,_t,Zi,Dn,Ji,ea;rd=[le],nd=[le],td=[le];var At=class en{constructor(t,n){pe(this,Zi,ee(_t,8,this)),ee(_t,11,this),pe(this,Dn),pe(this,Ji,ee(_t,12,this)),ee(_t,15,this),pe(this,ea,ee(_t,16,this)),ee(_t,19,this);const{effects:r,id:s,data:o={},disabled:i=!1,register:a=!0}=t;let l=s;ut(this,Dn,qn(s)),this.manager=n,this.data=o,this.disabled=i,this.effects=()=>{var u;return[()=>{const{id:c,manager:d}=this;if(c!==l)return l=c,d?.registry.register(this),()=>d?.registry.unregister(this)},...(u=r?.())!=null?u:[]]},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=Fe(this,Dn).value;return(n=(t=en.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const s=(r=(n=en.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Fe(this,Dn).peek();t!==s&&(en.pendingIdChanges||(en.pendingIdChanges=new Map,queueMicrotask(()=>{var o;return Zc(o=en,Qi,sd).call(o)})),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)}};_t=Yn(null);Qi=new WeakSet;sd=function(){const e=At.pendingIdChanges;At.pendingIdChanges=null,e&&Re(()=>{for(const[t,n]of e)Fe(t,Dn).value=n})};Zi=new WeakMap;Dn=new WeakMap;Ji=new WeakMap;ea=new WeakMap;de(_t,4,"manager",rd,At,Zi);de(_t,4,"data",nd,At,Ji);de(_t,4,"disabled",td,At,ea);pe(At,Qi);pn(_t,At);At.pendingIdChanges=null;var po=At,dl=class{constructor(){this.map=qn(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),s=()=>this.unregister(e,t);if(r===t)return s;if(r&&r.id===e){const a=this.cleanupFunctions.get(r);a?.(),this.cleanupFunctions.delete(r)}const o=new Map(n);for(const[a,l]of n)if(l===t&&a!==e){o.delete(a);break}o.set(e,t),this.map.value=o;const i=Zr(...t.effects());return this.cleanupFunctions.set(t,i),s},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),this.cleanupFunctions.delete(t);const s=new Map(n);s.delete(e),this.map.value=s}}[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){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},od,id,ad,ld,cd,dd,ui,rt,ta,na,ra,Ot=class extends(ui=po,dd=[le],cd=[le],ld=[le],ad=[We],id=[We],od=[We],ui){constructor(t,n){var r=t,{modifiers:s,type:o,sensors:i,plugins:a,effects:l}=r,u=Yc(r,["modifiers","type","sensors","plugins","effects"]);super(Vi(Ki({},u),{effects:()=>{var c;return[...(c=l?.())!=null?c:[],()=>{const{manager:d,plugins:f}=this;if(!(!d||!f))for(const h of f){const{plugin:y}=zr(h);d.registry.plugins.register(y)}}]}}),n),ee(rt,5,this),pe(this,ta,ee(rt,8,this)),ee(rt,11,this),pe(this,na,ee(rt,12,this)),ee(rt,15,this),pe(this,ra,ee(rt,16,this,this.isDragSource?"dragging":"idle")),ee(rt,19,this),this.type=o,this.sensors=i,this.modifiers=s,this.alignment=u.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=zr(n);if(r.plugin===t)return r.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};rt=Yn(ui);ta=new WeakMap;na=new WeakMap;ra=new WeakMap;de(rt,4,"type",dd,Ot,ta);de(rt,4,"modifiers",cd,Ot,na);de(rt,4,"status",ld,Ot,ra);de(rt,2,"isDropping",ad,Ot);de(rt,2,"isDragging",id,Ot);de(rt,2,"isDragSource",od,Ot);pn(rt,Ot);var ud,fd,hd,pd,gd,md,fi,Ke,sa,oa,ia,aa,la,Mt=class extends(fi=po,md=[le],gd=[le],pd=[le],hd=[le],fd=[le],ud=[We],fi){constructor(t,n){var r=t,{accept:s,collisionDetector:o,collisionPriority:i,type:a}=r,l=Yc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),ee(Ke,5,this),pe(this,sa,ee(Ke,8,this)),ee(Ke,11,this),pe(this,oa,ee(Ke,12,this)),ee(Ke,15,this),pe(this,ia,ee(Ke,16,this)),ee(Ke,19,this),pe(this,aa,ee(Ke,20,this)),ee(Ke,23,this),pe(this,la,ee(Ke,24,this)),ee(Ke,27,this),this.accept=s,this.collisionDetector=o,this.collisionPriority=i,this.type=a}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};Ke=Yn(fi);sa=new WeakMap;oa=new WeakMap;ia=new WeakMap;aa=new WeakMap;la=new WeakMap;de(Ke,4,"accept",md,Mt,sa);de(Ke,4,"type",gd,Mt,oa);de(Ke,4,"collisionDetector",pd,Mt,ia);de(Ke,4,"collisionPriority",hd,Mt,aa);de(Ke,4,"shape",fd,Mt,la);de(Ke,2,"isDropTarget",ud,Mt);pn(Ke,Mt);var xp=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 s of r)s(...t)}},bp=class extends xp{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function $s(e,t=!0){let n=!1;return Vi(Ki({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var wp=class extends ts{constructor(e){super(e);const t=(r,s)=>r.map(({id:o})=>o).join("")===s.map(({id:o})=>o).join("");let n=[];this.destroy=Zr(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:o}=r;if(r.isDisabled()||po.pendingIdChanges)return;const i=$s({collisions:o});if(s.dispatch("collision",i),i.defaultPrevented||t(o,n))return;n=o;const[a]=o;ae(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},Qn=(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))(Qn||{}),Zn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Zn||{}),vd,yd,xd,bd,wd,_d,kd,vt,ca;kd=[le],_d=[We],wd=[We],bd=[We],xd=[We],yd=[We],vd=[We];var Bt=class{constructor(){ee(vt,5,this),pe(this,ca,ee(vt,8,this,"idle")),ee(vt,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}};vt=Yn(null);ca=new WeakMap;de(vt,4,"value",kd,Bt,ca);de(vt,2,"current",_d,Bt);de(vt,2,"idle",wd,Bt);de(vt,2,"initializing",bd,Bt);de(vt,2,"initialized",xd,Bt);de(vt,2,"dragging",yd,Bt);de(vt,2,"dropped",vd,Bt);pn(vt,Bt);var _p=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=$s({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 r=new AbortController,{event:s,coordinates:o}=e;Re(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(o)});const i=$s({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",i),i.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:a}=t;a.current==="initializing"&&Re(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return ae(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:o}=r;if(!s.dragging||!o||o.signal.aborted)return;const i=$s({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",i),queueMicrotask(()=>{var a,l,u,c,d;if(i.defaultPrevented)return;const f=(d=e.to)!=null?d:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((c=(u=e.by)==null?void 0:u.y)!=null?c:0)};r.position.current=f})})}stop(e={}){return ae(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let o;const i=()=>{const l={resume:()=>{},abort:()=>{}};return o=new Promise((u,c)=>{l.resume=u,l.abort=c}),l};s.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=ae(()=>{var c;return((c=r.source)==null?void 0:c.status)==="dropping"}),u=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:c}=r,d=yt(()=>{c?.status==="idle"&&(d(),u())})}else this.manager.renderer.rendering.then(u)})};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:i}),o?o.then(a).catch(()=>r.reset()):a()})}},Bn=class extends et{constructor(e,t){super(e,t),this.manager=e,this.options=t}},kp=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)}},Ts,Sd=class{constructor(e){this.options=e,pe(this,Ts)}set controller(e){ut(this,Ts,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Fe(this,Ts))==null||t.activate(e)}};Ts=new WeakMap;var ul=class extends et{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Sp=class{constructor(e){this.draggables=new dl,this.droppables=new dl,this.plugins=new Io(e),this.sensors=new Io(e),this.modifiers=new Io(e)}register(e,t){if(e instanceof Ot)return this.draggables.register(e.id,e);if(e instanceof Mt)return this.droppables.register(e.id,e);if(e.prototype instanceof ul)return this.modifiers.register(e,t);if(e.prototype instanceof Bn)return this.sensors.register(e,t);if(e.prototype instanceof et)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof po)return e instanceof Ot?this.draggables.unregister(e.id,e):e instanceof Mt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof ul)return this.modifiers.unregister(e);if(e.prototype instanceof Bn)return this.sensors.unregister(e);if(e.prototype instanceof et)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()}},$d,Td,Ed,Cd,Od,Md,Id,Dd,Pd,mr,Es,Tn,je,da,ua,fa,ha,pa,vr;Pd=[We],Dd=[le],Id=[le],Md=[le],Od=[le],Cd=[le],Ed=[We],Td=[We],$d=[We];var $t=class{constructor(e){ee(je,5,this),pe(this,mr),pe(this,Es),pe(this,Tn,new hn(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Bt,pe(this,da,ee(je,8,this,!1)),ee(je,11,this),pe(this,ua,ee(je,12,this,null)),ee(je,15,this),pe(this,fa,ee(je,16,this,null)),ee(je,19,this),pe(this,ha,ee(je,20,this,null)),ee(je,23,this),pe(this,pa,ee(je,24,this,[])),ee(je,27,this),this.position=new ho({x:0,y:0}),pe(this,vr,{x:0,y:0}),ut(this,mr,e)}get shape(){const{current:e,initial:t,previous:n}=Fe(this,Tn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Fe(this,Tn).current=e:Fe(this,Tn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Fe(this,mr).registry.draggables.get(t);return n&&ut(this,Es,n),(e=n??Fe(this,Es))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Fe(this,mr).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(Vi(Ki({},this.snapshot()),{transform:n}));return ut(this,vr,n),n}snapshot(){return ae(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Fe(this,vr),shape:this.shape?Mo(this.shape):null,position:Mo(this.position),status:Mo(this.status),canceled:this.canceled}))}reset(){Re(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Fe(this,Tn).reset(),this.position.reset({x:0,y:0}),ut(this,vr,{x:0,y:0}),this.modifiers=[]})}};je=Yn(null);mr=new WeakMap;Es=new WeakMap;Tn=new WeakMap;da=new WeakMap;ua=new WeakMap;fa=new WeakMap;ha=new WeakMap;pa=new WeakMap;vr=new WeakMap;de(je,2,"shape",Pd,$t);de(je,4,"canceled",Dd,$t,da);de(je,4,"activatorEvent",Id,$t,ua);de(je,4,"sourceIdentifier",Md,$t,fa);de(je,4,"targetIdentifier",Od,$t,ha);de(je,4,"modifiers",Cd,$t,pa);de(je,2,"source",Ed,$t);de(je,2,"target",Td,$t);de(je,2,"transform",$d,$t);pn(je,$t);var $p={get rendering(){return Promise.resolve()}};function St(e,t){return typeof e=="function"?e(t):e??t}var Tp=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(f=>f.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=St(r.plugins,[]),o=St(r.sensors,[]),i=St(r.modifiers,[]),a=(n=r.renderer)!=null?n:$p,l=new bp(this),u=new Sp(this);this.registry=u,this.monitor=l,this.renderer=a,this.actions=new _p(this),this.dragOperation=new $t(this),this.collisionObserver=new yp(this),this.plugins=[wp,...s],this.modifiers=i,this.sensors=o;const{destroy:c}=this,d=Zr(()=>{var f,h,y;const g=ae(()=>this.dragOperation.modifiers),w=this.modifiers;for(const x of g)w.includes(x)||x.destroy();this.dragOperation.modifiers=(y=(h=(f=this.dragOperation.source)==null?void 0:f.modifiers)==null?void 0:h.map(x=>{const{plugin:p,options:v}=zr(x);return new p(this,v)}))!=null?y:w});this.destroy=()=>{d(),c()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},jd=e=>{throw TypeError(e)},ga=(e,t,n)=>t.has(e)||jd("Cannot "+n),J=(e,t,n)=>(ga(e,t,"read from private field"),t.get(e)),at=(e,t,n)=>t.has(e)?jd("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ct=(e,t,n,r)=>(ga(e,t,"write to private field"),t.set(e,n),n),Rd=(e,t,n)=>(ga(e,t,"access private method"),n);function go(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Ad(e,t){const n=e.getAnimations();let r=null;for(const s of n){if(s.playState!=="running")continue;const{effect:o}=s,a=(go(o)?o.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],s])}return r}function mo(e){const{width:t,height:n,top:r,left:s,bottom:o,right:i}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:s,bottom:o,right:i}}function ma(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ns(e){return"nodeType"in e}function ft(e){var t,n,r;return e?ma(e)?e:ns(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 va(e){const{Document:t}=ft(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Kt(e){return!e||ma(e)?!1:e instanceof ft(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Ld(e){return e instanceof ft(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Jn(e){return e?ma(e)?e.document:ns(e)?va(e)?e:Kt(e)||Ld(e)?e.ownerDocument:document:document:document}function Ep(e){var t,n,r,s;const{documentElement:o}=Jn(e),i=ft(e).visualViewport,a=(t=i?.width)!=null?t:o.clientWidth,l=(n=i?.height)!=null?n:o.clientHeight,u=(r=i?.offsetTop)!=null?r:0,c=(s=i?.offsetLeft)!=null?s:0;return{top:u,left:c,right:c+a,bottom:u+l,width:a,height:l}}function Cp(e,t){if(Op(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function Op(e){return e.tagName==="DETAILS"}function Hr(e,t=e.getBoundingClientRect(),n=0){var r,s,o,i,a;let l=t;const{ownerDocument:u}=e,c=(r=u.defaultView)!=null?r:window;let d=e.parentElement;for(;d&&d!==u.documentElement;){if(!Cp(d)){const v=d.getBoundingClientRect(),_=n*(v.bottom-v.top),b=n*(v.right-v.left),E=n*(v.bottom-v.top),T=n*(v.right-v.left);l={top:Math.max(l.top,v.top-_),right:Math.min(l.right,v.right+b),bottom:Math.min(l.bottom,v.bottom+E),left:Math.max(l.left,v.left-T),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}d=d.parentElement}const f=c.visualViewport,h=(s=f?.offsetTop)!=null?s:0,y=(o=f?.offsetLeft)!=null?o:0,g=(i=f?.width)!=null?i:c.innerWidth,w=(a=f?.height)!=null?a:c.innerHeight,x=n*w,p=n*g;return l={top:Math.max(l.top,h-x),right:Math.min(l.right,y+g+p),bottom:Math.min(l.bottom,h+w+x),left:Math.max(l.left,y-p),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function Fn(e){return{x:e.clientX,y:e.clientY}}var Bd=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function hi(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 s=r.contentDocument;s&&!t.has(s)&&n.push(...hi(s,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const s=r.parent;s&&s.document&&s.document!==e&&n.push(...hi(s.document,t))}}catch{}return n}function ya(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Fd(){var e,t;const n=ya()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function xa(e){return!e||!ns(e)?!1:e instanceof ft(e).ShadowRoot}function Us(e){if(e&&ns(e)){let t=e.getRootNode();if(xa(t))return t;if(t instanceof Document)return t}return Jn(e)}function ba(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Mp(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((o,i)=>{const a=r[i];if(fl(o)&&fl(a)&&(o.type!=="file"&&(o.value=a.value),o.type==="radio"&&o.name&&(o.name=`Cloned__${o.name}`)),hl(o)&&hl(a)&&a.width>0&&a.height>0){const l=o.getContext("2d");l?.drawImage(a,0,0)}}),n}function fl(e){return"value"in e}function hl(e){return e.tagName==="CANVAS"}function Wd(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Ip(r)){const{contentDocument:s}=r;if(s){const{left:o,top:i}=r.getBoundingClientRect();return Wd(s,{x:t-o,y:n-i})}}return r}function Ip(e){return e?.tagName==="IFRAME"}var pi=new WeakMap;function Dp(e){return e.closest(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),k=require("../useCompiledDocument-DanZRwMi.cjs.js"),$=require("@mui/material"),S=require("react"),be=require("../ServerProvider-BexMzLld.cjs.js"),me=require("../text-entry-BJwltZiy.cjs.js"),Nf=require("react-dom"),uc=require("@tanstack/react-query"),Ce=e=>e.kind==="text",ce=e=>e.kind!=="text",lr=e=>ce(e)?e.label??e.name:e.name,dt=e=>e.declaration.kind==="query"?e.name:`${e.source} -> ${e.name}`,Hn=e=>e.declaration.kind==="inherited"||e.declaration.kind==="query",fe=e=>Ce(e)?`text.${e.name}`:e.declaration.kind==="query"?`query.${e.name}`:`${e.source}.${e.name}`,Ka=".malloy-big-value, .malloy-table",zf=e=>e.querySelector(Ka)!==null&&![...e.querySelectorAll(".malloy-chart")].some(t=>t.closest(Ka)===null),As=(e,t)=>Ce(e)?k.MIN_TEXT_TILE_ROWS:t&&zf(t)?k.MIN_VALUE_TILE_ROWS:k.MIN_TILE_ROWS,Fr=e=>e.rowspan??k.PLACED_DEFAULT_ROWSPAN[Ce(e)?"text":"query"];function Ut(e,t){if(e.row===void 0||e.col===void 0)return;const n=Math.min(e.colspan??1,t);return{row:e.row,col:Math.min(e.col,t-n+1),colspan:n,rowspan:Fr(e)}}const Wr=(e,t)=>e.col<t.col+t.colspan&&t.col<e.col+e.colspan&&e.row<t.row+t.rowspan&&t.row<e.row+e.rowspan;function In(e){return e.map((t,n)=>({tile:t,index:n})).sort((t,n)=>(t.tile.row??1/0)-(n.tile.row??1/0)||(t.tile.col??1/0)-(n.tile.col??1/0)||t.index-n.index).map(({tile:t})=>t)}function Rt(e,t,n){const r=e.map(a=>({...a})),s=[],o=a=>{const l=Ut(r[a],t);l&&(r[a].col=l.col,s.push(l))};n!==void 0&&o(n);const i=r.map((a,l)=>({tile:a,index:l})).filter(({index:a,tile:l})=>a!==n&&l.row!==void 0).sort((a,l)=>(a.tile.row??0)-(l.tile.row??0)||(a.tile.col??0)-(l.tile.col??0)||a.index-l.index);for(const{index:a}of i){const l=Ut(r[a],t);if(l){for(;;){const u=s.filter(c=>Wr(l,c));if(u.length===0)break;l.row=Math.max(...u.map(c=>c.row+c.rowspan))}r[a].row=l.row,o(a)}}return r}function Gf(e,t,n,r){const s=e.flatMap((l,u)=>{const c=u===t?void 0:Ut(l,r);return c?[c]:[]}),o=Math.max(1,...s.map(l=>l.row+l.rowspan)),i={...e[t],...n,row:Math.min(n.row,o)},a=Ut(i,r);if(a){for(;;){const l=s.filter(u=>u.row<a.row&&Wr(a,u));if(l.length===0)break;a.row=Math.max(...l.map(u=>u.row+u.rowspan))}i.row=a.row}return Rt(e.map((l,u)=>u===t?i:l),r,t)}const Ls=(e,t)=>(e-k.GRID_GAP_PX*(t-1))/t,fc=k.TILE_ROW_PX+k.GRID_GAP_PX;function hc(e,t,n,r,s){const o=Math.min(n,r),i=Math.round(e/(s+k.GRID_GAP_PX))+1;return{row:Math.max(1,Math.round(t/fc)+1),col:Math.min(Math.max(i,1),r-o+1)}}function pc(e,t,n,r){const s=e.map((o,i)=>{if(o.row!==void 0&&o.col!==void 0)return o;const a=t[i];if(!a)return o;const{break:l,...u}=o,c=o.colspan??Math.max(1,Math.round((a.width+k.GRID_GAP_PX)/(r+k.GRID_GAP_PX))),d=hc(a.left,a.top,c,n,r),f=(a.top+a.height+k.GRID_GAP_PX)/fc,h=Ce(o)?Math.ceil(f-.02):Math.round(f);return{...u,...d,colspan:c,rowspan:o.rowspan??Math.max(As(o),h-d.row+1)}});return Rt(s,n)}function Va(e,t,n){const r=e.flatMap((o,i)=>{const a=i===t?void 0:Ut(o,n);return a?[a]:[]});if(r.length===0)return[...e];const s=Math.max(...r.map(o=>o.row+o.rowspan));return e.map((o,i)=>i===t?{...o,row:s,col:1}:o)}function gc(e,t){const n=e.map(o=>({...o})),r=[],s=n.map((o,i)=>({tile:o,index:i})).filter(({tile:o})=>o.row!==void 0&&o.col!==void 0).sort((o,i)=>(o.tile.row??0)-(i.tile.row??0)||(o.tile.col??0)-(i.tile.col??0)||o.index-i.index);for(const{index:o}of s){const i=Ut(n[o],t);if(i){for(;i.row>1&&!r.some(a=>Wr({...i,row:i.row-1},a));)i.row-=1;n[o].row=i.row,n[o].col=i.col,r.push(i)}}return n}const Hf=(e,t)=>gc(e,t).some((n,r)=>n.row!==e[r].row||n.col!==e[r].col);function qf(e){return In(e).map(t=>{const{row:n,col:r,...s}=t;return s})}const Uf=(e,t,n)=>e.map((r,s)=>s===t?{...r,...n}:r);function Xa(e,t,n,r,s){const o=Ut(e[t],s);if(!o)return[...e];const i={row:Math.max(1,o.row+n),col:Math.min(Math.max(1,o.col+r),s-o.colspan+1)};if(i.row===o.row&&i.col===o.col)return[...e];const a={...o,...i},l=e.flatMap((h,y)=>{const g=y===t?void 0:Ut(h,s);return g&&Wr(a,g)&&!Wr(o,g)?[{i:y,other:g}]:[]}),u=l.length===1?l[0]:void 0;if(!u)return Rt(Uf(e,t,i),s,t);const{i:c,other:d}=u,f=e.map(h=>({...h}));return n>0?(f[c].row=o.row,f[t].row=o.row+d.rowspan):n<0?(f[t].row=d.row,f[c].row=d.row+o.rowspan):r>0?(f[c].col=o.col,f[t].col=o.col+d.colspan):(f[t].col=d.col,f[c].col=d.col+o.colspan),Rt(f,s,t)}const mc=(e,t)=>e?.col===void 0?t:Math.max(1,t-e.col+1);function Kf(e){return Ce(e)||e.rowspan===void 0?e:k.isChartPick(e.chart)&&e.chart!=="big_value"&&e.rowspan<k.MIN_TILE_ROWS?{...e,rowspan:k.MIN_TILE_ROWS}:e}const vc=k.createSvgIcon(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"})),yc=k.createSvgIcon(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"})),Vf=k.createSvgIcon(m.jsx("path",{d:"M12 5V2L8 6l4 4V7c3.31 0 6 2.69 6 6 0 2.97-2.17 5.43-5 5.91v2.02c3.95-.49 7-3.85 7-7.93 0-4.42-3.58-8-8-8m-6 8c0-1.65.67-3.15 1.76-4.24L6.34 7.34C4.9 8.79 4 10.79 4 13c0 4.08 3.05 7.44 7 7.93v-2.02c-2.83-.48-5-2.94-5-5.91"}));function xc(e){const{theme:t}=be.usePublisherTheme(),n=t.ui,[r,s]=S.useState(null),{status:o,draftKeptAt:i,discard:a,restored:l,dismissRestored:u}=e,c=l!==void 0&&!l.pending&&o==="unsaved"?l:void 0,d=o==="saved"?"Saved":o==="saving"?"Saving…":i!==void 0?"Draft saved":"Unsaved changes",f=c?`Restored your unsaved edits from ${qo(c.savedAt)}`:void 0,h=o==="unsaved"&&i!==void 0?"Your edits are kept in this browser. Done saves them to the report.":e.saveTarget,y=a!==void 0&&o==="unsaved",g=()=>{s(null),c&&u?.()},w=v=>({display:"inline-flex",alignItems:"center",justifyContent:"flex-end",gap:.75,minWidth:132,height:n.size.control,px:1,borderRadius:n.radius.control,font:"inherit",...n.type.control,whiteSpace:"nowrap",color:o==="saved"?v.palette.text.secondary:v.palette.text.primary,transition:`color ${k.MOTION_FAST}, background-color ${k.MOTION_FAST}`,...y?{"&:hover":{bgcolor:v.palette.action.hover}}:{}}),x=m.jsxs(m.Fragment,{children:[m.jsx($.Box,{component:"span","aria-hidden":!0,sx:{width:16,height:16,flex:"none",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:o==="saved"?m.jsx(k.CheckIcon,{sx:{fontSize:16}}):m.jsx($.Box,{component:"span","data-restored":c?"true":void 0,sx:v=>({width:7,height:7,borderRadius:"50%",bgcolor:c?t.accent:o==="saving"||i!==void 0?v.palette.text.disabled:v.palette.warning.main,transition:`background-color ${k.MOTION_FAST}`})})}),m.jsx($.Box,{component:"span","aria-hidden":!0,children:d}),m.jsx(k.ExpandMoreIcon,{"aria-hidden":!0,sx:{fontSize:16,ml:-.25,visibility:y?"visible":"hidden"}})]}),p=m.jsx($.Box,{component:"span",role:"status","aria-live":"polite",sx:Xf,children:f?`${d}. ${f}.`:d});return m.jsxs(m.Fragment,{children:[p,m.jsx($.Tooltip,{title:f??h,describeChild:!0,children:y?m.jsx($.ButtonBase,{className:k.reportClasses.saveStatus,"aria-label":d,...f?{"aria-description":f}:{},"aria-haspopup":"menu","aria-expanded":r!==null,onClick:v=>s(v.currentTarget),sx:w,children:x}):m.jsx($.Box,{component:"span",className:k.reportClasses.saveStatus,sx:w,children:x})}),m.jsxs($.Menu,{className:k.reportClasses.menu,anchorEl:r,open:r!==null,onClose:g,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:-4,horizontal:"left"},slotProps:{paper:{sx:{minWidth:240,borderRadius:n.radius.menu,border:`1px solid ${k.edgeColor(t.cardBorder)}`,boxShadow:n.shadow.menu}}},MenuListProps:{dense:!0,sx:{py:.5}},children:[(f!==void 0||i!==void 0)&&m.jsx($.Box,{component:"li",role:"presentation",sx:{px:1.75,pt:.75,pb:1,...n.type.caption,color:"text.secondary"},children:f??`Kept in this browser at ${qo(i)}`}),m.jsxs($.MenuItem,{onClick:()=>{s(null),a?.()},sx:{mx:.5,borderRadius:n.radius.control,gap:1.25,color:"error.main","&.Mui-focusVisible":{outline:"none",bgcolor:"action.hover"}},children:[m.jsx(Vf,{fontSize:"small"}),"Discard edits"]})]})]})}function qo(e){const t=new Date(e);return new Date().toDateString()===t.toDateString()?t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):t.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}const Xf={position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0},Uo=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),cn=Uo?"⌘":"Ctrl+",Ya=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"},So=e=>e instanceof Element&&e.closest('[role="dialog"], .MuiPopover-root, .MuiDialog-root')!==null;function Yf(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 s=o=>{const i=t.current;if(i.paused)return;const a=Uo?o.metaKey:o.ctrlKey,l=o.key.toLowerCase();if(o.key==="Escape"){if(Ya(o.target)||So(o.target))return;i.escape();return}if(Ya(o.target)){if(a&&l==="s"){if(o.preventDefault(),!i.save||So(o.target))return;o.target.blur(),r(!0)}return}if(So(o.target)){a&&l==="s"&&o.preventDefault();return}if(a&&l==="z"){o.preventDefault(),o.shiftKey?i.redo():i.undo();return}if(!Uo&&a&&l==="y"){o.preventDefault(),i.redo();return}if(a&&l==="s"){o.preventDefault(),i.save?.();return}if(i.move&&o.altKey&&!a&&!o.shiftKey){const u=o.key==="ArrowLeft"?[0,-1]:o.key==="ArrowRight"?[0,1]:o.key==="ArrowUp"?[-1,0]:o.key==="ArrowDown"?[1,0]:void 0;if(u&&i.move(u[0],u[1])){o.preventDefault();return}}i.nudge&&!a&&!o.altKey&&!o.shiftKey&&(o.key==="ArrowLeft"||o.key==="ArrowRight")&&(o.preventDefault(),i.nudge(o.key==="ArrowRight"?1:-1))};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[])}const Mr=(e,t,n=be.DEFAULT_UI)=>({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}}}),Nr=(e=be.DEFAULT_UI)=>({width:e.size.control,height:e.size.control,borderRadius:e.radius.control,"& svg":{fontSize:18}}),Bs={height:20,alignSelf:"center",mx:.5,my:0},Fs=(e,t=be.DEFAULT_UI)=>({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"}}}),Ko={package:"Saves to the package file",browser:"Saves in this browser",host:"Saves to the app this is embedded in"};function Qf({canUndo:e,canRedo:t,onUndo:n,onRedo:r,dirty:s,saving:o,onSave:i,savesTo:a="package",saveLabel:l,saveButton:u,actions:c,onAddTile:d,arrange:f,onExit:h,saveStatus:y}){const{theme:g}=be.usePublisherTheme(),w=k.edgeColor(g.cardBorder),x=k.hoverEdgeColor(g.cardBorder,g.tileTitle);return m.jsxs($.Stack,{direction:"row","aria-label":"Builder actions",sx:{alignItems:"center",gap:.5,flexShrink:0,"& .MuiButton-root":{whiteSpace:"nowrap"}},children:[f,d&&m.jsx($.Button,{variant:"outlined",startIcon:m.jsx(k.AddIcon,{}),onClick:d,"aria-label":"Add tile",sx:Mr(w,x,g.ui),children:"Tile"}),d&&m.jsx($.Divider,{orientation:"vertical",sx:Bs}),m.jsx($.Tooltip,{title:`Undo (${cn}Z)`,children:m.jsx("span",{children:m.jsx($.IconButton,{"aria-label":"Undo",disabled:!e,onClick:n,sx:Nr(g.ui),children:m.jsx(yc,{fontSize:"small"})})})}),m.jsx($.Tooltip,{title:`Redo (${cn}⇧Z)`,children:m.jsx("span",{children:m.jsx($.IconButton,{"aria-label":"Redo",disabled:!t,onClick:r,sx:Nr(g.ui),children:m.jsx(vc,{fontSize:"small"})})})}),(c||i||h)&&m.jsx($.Divider,{orientation:"vertical",sx:Bs}),c,i&&y&&m.jsx(xc,{...y}),i?m.jsx($.Tooltip,{title:s?`Save (${cn}S) · ${l??Ko[a]}`:l??Ko[a],children:m.jsx("span",{children:m.jsx($.Button,{ref:u,variant:s?"contained":"outlined",disabled:!s||o,onClick:i,sx:{...Mr(w,x,g.ui),minWidth:88},children:o?"Saving…":s?"Save":"Saved"})})}):null,i&&m.jsx($.Box,{component:"span","aria-live":"polite",sx:{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"},children:o?"Saving":s?"Unsaved changes":"All changes saved"}),h&&m.jsx(k.SecondaryButton,{label:"Close",icon:m.jsx(k.CheckIcon,{}),onClick:h})]})}const Zf=e=>`This view has no field for the x-axis: ${e.toLowerCase()} needs a group by, such as a date or a category`,Qa={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map",combo_chart:"Bar and line"};function bc(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this tile's details":n==="unlisted"?"Not in the model's list, so its shape is unknown":void 0,s=e?.shape,o=a=>{if(t===a)return;if(a==="big_value")return e?.aggregateOnly===!0?void 0:s&&s.groupBys>0?"This view has a group by, so it is more than one row; big numbers need a view of totals only":r??"Needs results that are only totals (no group by)";if(a==="shape_map"||a==="segment_map")return e?.chart===a?void 0:r??"Needs a map chart set in the model";if(e?.chart===a)return;if(!s)return a==="combo_chart"?r??"Needs a view with a group by and exactly two totals: the first is drawn as bars, the second as a line":void 0;const l=`A ${Qa[a].toLowerCase()} chart`;switch(k.chartShapeGap(a,s)){case"no_x_axis":return Zf(l);case"combo_totals":return`A bar and line chart needs exactly two totals, the first drawn as bars and the second as a line; this view has ${s.totals}`;case"no_y_axis":return`This view has no total for the y-axis: ${l.toLowerCase()} needs at least one aggregate`;default:return}};return[{value:"default",label:"Default",hint:"As set in the model"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map","combo_chart"].map(a=>{const l=o(a);return{value:a,label:Qa[a],...l?{disabled:!0,reason:l}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Za(e){return e.description??k.readableName(e.name)}const Jf={bar_chart:"a bar chart",line_chart:"a line chart",scatter_chart:"a scatter chart",combo_chart:"a bar and line chart",shape_map:"a shape map",segment_map:"a segment map",big_value:"a big value",sparkline:"a sparkline"},ls=(e,t)=>`${e}\0${t}`;function eh({open:e,document:t,catalog:n,columns:r,onClose:s,onAdd:o,onAddText:i,renderPreview:a}){const{theme:l}=be.usePublisherTheme(),u=l.ui,c=k.edgeColor(l.cardBorder),d=S.useMemo(()=>n?.sources??[],[n]),[f,h]=S.useState(""),[y,g]=S.useState(),[w,x]=S.useState(""),[p,v]=S.useState("default"),_=S.useRef(null),b=S.useMemo(()=>{const j=new Set(t.sources.map(z=>z.base));return[...d].sort((z,D)=>Number(j.has(D.name))-Number(j.has(z.name)))},[d,t]),E=b.filter(j=>j.views.length>0),T=b.filter(j=>j.views.length===0),M=S.useMemo(()=>new Map(E.flatMap(j=>j.views.map(z=>[ls(j.name,z.name),{source:j,view:z,key:ls(j.name,z.name)}]))),[E]),O=S.useMemo(()=>E.map(j=>({key:j.name,label:j.name,...j.description?{detail:j.description}:{},entries:j.views.map(z=>({key:ls(j.name,z.name),name:z.name,title:Za(z),...z.chart?{chart:z.chart}:{}}))})),[E]),C=y===void 0?void 0:M.get(y);S.useEffect(()=>{if(!e)return;h(""),x(""),v("default");const j=E[0]?.views[0];g(j&&E[0]?ls(E[0].name,j.name):void 0)},[e]);const A=C?[C.source.name,C.view.name].filter(j=>!me.isBareName(j)).map(j=>`"${j}" is not a plain Malloy name, so a tile cannot be written for it.`)[0]:void 0,R=C!==void 0&&A===void 0,L=C?Za(C.view):"",G=p!=="default"&&C?{chart:p,chartCarried:C.view.chart?[C.view.chart]:[]}:{},N=(j=C)=>{if(!j||![j.source.name,j.view.name].every(me.isBareName))return;const z=j.key===C?.key,D=k.writtenSpan(Math.ceil(r/2),r);o({base:j.source.name,modelPath:j.source.modelPath,...j.source.exporters?{exporters:j.source.exporters}:{},view:j.view.name,...z&&w.trim()?{label:w.trim()}:{},...z?G:{},...D!==void 0?{colspan:D}:{}})},X=C?bc(C.view,p).filter(j=>j.value!=="custom"&&j.disabled!==!0):[];return m.jsx(k.AppDialog,{className:`${k.reportClasses.dialog} ${k.reportClasses.addTileDialog}`,open:e,onClose:s,maxWidth:"md",initialFocus:_,title:"Add a tile",description:"Pick what the tile shows from the model. You can change its title and chart now or later.",actions:m.jsxs(m.Fragment,{children:[m.jsx($.Button,{onClick:i,sx:{mr:"auto"},children:"Add text instead"}),m.jsx($.Button,{onClick:s,children:"Cancel"}),m.jsx($.Button,{variant:"contained",disabled:!R,onClick:()=>N(),children:"Add tile"})]}),children:m.jsxs($.Box,{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($.Box,{sx:{display:"flex",flexDirection:"column",minHeight:0,borderRight:{md:`1px solid ${c}`},maxHeight:{xs:280,md:"none"}},children:m.jsx(k.ViewPicker,{groups:O,query:f,onQuery:h,picked:C?.key,onPick:j=>{g(j),v("default")},onTake:j=>N(M.get(j)),searchRef:_,empty:m.jsx($.Typography,{variant:"body2",sx:{color:l.tileTitle,p:2},children:n?"This package's models have nothing to put on a tile yet.":"The package's sources are still loading."}),footer:T.length>0&&m.jsxs($.Typography,{variant:"caption",component:"p",sx:{color:"text.secondary",px:2,pt:1.5},children:["Also in this package, with no views to show:"," ",T.map(j=>j.name).join(", "),"."]})})}),m.jsx($.Box,{sx:j=>({p:2.5,display:"flex",flexDirection:"column",gap:2,minHeight:0,overflowY:"auto",bgcolor:`color-mix(in srgb, ${j.palette.text.primary} 3%, ${j.palette.background.paper})`}),children:C?m.jsxs(m.Fragment,{children:[m.jsx($.Box,{"aria-label":"Preview",role:"region",sx:j=>({height:240,flex:"none",display:"flex",position:"relative",overflow:"hidden",borderRadius:u.radius.tile,border:`1px solid ${c}`,bgcolor:j.palette.background.paper,"&::after":{content:'""',position:"absolute",left:0,right:0,bottom:0,height:40,pointerEvents:"none",background:`linear-gradient(to bottom, transparent, ${j.palette.background.paper})`}}),children:a?m.jsx($.Box,{sx:{flex:1,minWidth:0,px:2,pt:1.5},children:a({base:C.source.name,modelPath:C.source.modelPath,view:C.view.name,label:w.trim()||L,...p!=="default"?G:{},givens:C.source.givens})}):m.jsxs($.Box,{sx:j=>({flex:1,border:`1px solid ${c}`,borderRadius:u.radius.tile,bgcolor:j.palette.background.paper,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,color:"text.secondary"}),children:[m.jsx(k.ChartGlyph,{chart:C.view.chart}),m.jsxs($.Typography,{variant:"body2",children:[C.source.name," → ",C.view.name]})]})}),m.jsx($.TextField,{size:"small",label:"Title",placeholder:L,value:w,onChange:j=>x(j.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Tile title"}}),m.jsxs($.Box,{children:[m.jsx($.Typography,{component:"div",sx:{...u.type.label,color:"text.secondary",mb:.75},children:"Chart"}),m.jsx($.ToggleButtonGroup,{size:"small",exclusive:!0,value:p,"aria-label":"Chart",onChange:(j,z)=>{z!==null&&v(z)},sx:{...Fs(c,u),"& .MuiToggleButton-root":{...Fs(c,u)["& .MuiToggleButton-root"],textTransform:"none"}},children:X.map(j=>m.jsx($.ToggleButton,{value:j.value,children:j.label},j.value))}),m.jsx($.Typography,{variant:"caption",component:"p",sx:{color:"text.secondary",mt:.75},children:C.view.chart?`The model sets ${Jf[C.view.chart]??"a chart"}.`:"The model sets no chart, so it shows as a table."})]}),A&&m.jsx($.Typography,{variant:"body2",color:"error",children:A})]}):m.jsx($.Typography,{variant:"body2",sx:{color:"text.secondary",m:"auto"},children:"Pick a view to see it here."})})]})})}function th(e,t,{modelPath:n,textHeld:r,widths:s,insertAt:o}){t.modelPath&&!r&&(e.imports=k.withSource(e,t.base,t.modelPath,n,t.exporters??[t.modelPath]));const i=wc(e,t.base),a=Vo(e,i.name,t.view);e.tiles.splice(o??e.tiles.length,0,{name:a,source:i.name,declaration:{kind:"reference",from:t.view},...s&&t.colspan!==void 0?{colspan:t.colspan}:{},...t.label?{label:t.label}:{},...t.chart?{chart:t.chart}:{},...t.chartCarried?{chartCarried:t.chartCarried}:{}})}function wc(e,t,{unscoped:n=!1}={}){const r=e.sources.find(a=>a.base===t&&(!n||!a.scopedBy?.length));if(r)return r;const s=new Set(e.sources.map(a=>a.name));let o=`${t}_tiles`;for(let a=2;s.has(o);a++)o=`${t}_tiles_${a}`;const i={name:o,base:t};return e.sources.push(i),i}function Vo(e,t,n){const r=new Set(e.tiles.filter(ce).filter(o=>o.source===t).map(o=>o.name));let s=`${n}_tile`;for(let o=2;r.has(s);o++)s=`${n}_tile_${o}`;return s}function Ws(e){switch(e.declaration.kind){case"inline":return"Its query is written in this file, and the builder does not copy a query's body.";case"opaque":return`Its query is ${e.declaration.why}, which the builder does not copy.`;case"query":return"It names a query, and a copy could not be told apart from it: the builder writes nothing about such a tile but its place.";default:return e.chart==="custom"?"Its chart line is one the builder does not write, so a copy would lose it.":void 0}}function nh(e,t){const n=e.tiles[t];if(!n||!ce(n)||Ws(n)!==void 0)return;let r;if(n.declaration.kind==="reference"){const{break:o,...i}=structuredClone(n);r={...i,name:Vo(e,n.source,n.declaration.from)}}else{const i=e.sources.find(a=>a.name===n.source)??wc(e,n.source,{unscoped:!0});r={name:Vo(e,i.name,n.name),source:i.name,declaration:{kind:"reference",from:n.name},...n.colspan!==void 0?{colspan:n.colspan}:{}}}const s=n.row!==void 0&&n.col!==void 0;return s&&(r={...r,row:(n.row??1)+Fr(n),col:n.col,...n.rowspan!==void 0?{rowspan:n.rowspan}:{}}),e.tiles.splice(t+1,0,r),s&&(e.tiles=Rt(e.tiles,e.columns??k.DEFAULT_COLUMNS,t+1)),t+1}const cs="self";function rh({open:e,document:t,source:n,givenNames:r,dashboards:s,tileLabel:o,onClose:i,onApply:a}){const{theme:l}=be.usePublisherTheme(),u=l.ui,[c,d]=S.useState([]);S.useEffect(()=>{if(!e||!n)return;const p=(t.drills??[]).filter(v=>v.source===n.name);d((n.dimensions??[]).map(v=>{const _=p.find(b=>b.name===v.name);return{name:v.name,expression:v.expression,to:_?.to??[],given:_?.given??""}}))},[e,n,t]);const f=(p,v)=>d(_=>_.map((b,E)=>{if(E!==p)return b;const T={...b};return v(T),T})),h=[cs,...s.filter(p=>p!==cs)],y=p=>p===cs?"This report":p,g=()=>{n&&(a(c.filter(p=>p.to.length>0).map(p=>({source:n.name,name:p.name,expression:p.expression,to:p.to,...p.given?{given:p.given}:{}}))),i())},w=k.edgeColor(l.cardBorder),x=(p,v)=>f(p,_=>{v?_.to=_.lastTo?.length?_.lastTo:[cs]:(_.lastTo=_.to,_.to=[])});return m.jsx(k.AppDialog,{className:`${k.reportClasses.dialog} ${k.reportClasses.clickableCellsDialog}`,open:e,onClose:i,title:"Clickable cells",description:m.jsxs(m.Fragment,{children:[o&&m.jsxs($.Box,{component:"span",sx:{fontWeight:u.type.label.fontWeight},children:[o," ·"," "]}),"A click on a table cell sets a filter to its value, on this report or on the one it opens. Bars, lines and points on a chart do not respond to a click. Clicks work in the report, not while you edit it."]}),actions:m.jsxs(m.Fragment,{children:[m.jsx($.Button,{onClick:i,children:"Cancel"}),m.jsx($.Button,{variant:"contained",onClick:g,disabled:c.length===0,children:"Apply"})]}),children:c.length===0?m.jsx($.Typography,{variant:"body2",sx:{color:l.tileTitle,pt:1},children:n?m.jsxs(m.Fragment,{children:[m.jsx($.Box,{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($.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):m.jsx($.Box,{role:"list","aria-label":"Dimensions",children:c.map((p,v)=>{const _=p.to.length>0;return m.jsxs($.Box,{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:v===0?"none":`1px solid ${w}`},children:[m.jsx($.Switch,{size:"small",checked:_,onChange:b=>x(v,b.target.checked),slotProps:{input:{"aria-label":`${p.name} is clickable`}}}),m.jsxs($.Box,{sx:{minWidth:0},children:[m.jsx($.Box,{sx:{...u.type.control,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:sh(p.name)}),m.jsxs($.Box,{title:p.expression,sx:{...u.type.code,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[p.name," is ",p.expression]})]}),_?m.jsxs($.Stack,{direction:"row",sx:{gridColumn:{xs:"1 / -1",sm:"auto"},alignItems:"center",gap:1,justifyContent:"flex-end",...u.type.control},children:[m.jsx($.Box,{component:"span",sx:{color:"text.secondary"},children:"Opens"}),m.jsx($.TextField,{select:!0,size:"small",value:p.to,inputProps:{"aria-label":`Where ${p.name} goes`},SelectProps:{multiple:!0,renderValue:b=>b.map(y).join(", ")},onChange:b=>f(v,E=>{const T=b.target.value,M=Array.isArray(T)?T:String(T).split(",").filter(Boolean);M.length===0&&(E.lastTo=E.to),E.to=M}),sx:{flex:"1 1 150px",minWidth:0,maxWidth:200},children:h.map(b=>m.jsxs($.MenuItem,{value:b,children:[m.jsx($.Checkbox,{size:"small",checked:p.to.includes(b),sx:{p:0,mr:1}}),m.jsx($.ListItemText,{primary:y(b)})]},b))}),m.jsx($.Box,{component:"span",sx:{color:"text.secondary"},children:"sets"}),m.jsxs($.TextField,{select:!0,size:"small",value:p.given,inputProps:{"aria-label":`Control ${p.name} sets`},SelectProps:{displayEmpty:!0,renderValue:b=>b===""?p.name:String(b)},onChange:b=>f(v,E=>{E.given=b.target.value}),sx:{flex:"1 1 120px",minWidth:0,maxWidth:170},children:[m.jsx($.MenuItem,{value:"",children:m.jsx($.ListItemText,{primary:p.name,secondary:"Named like the dimension"})}),r.map(b=>m.jsx($.MenuItem,{value:b,children:b},b))]})]}):m.jsx($.Typography,{variant:"body2",sx:{color:"text.secondary",textAlign:"right",display:{xs:"none",sm:"block"}},children:"Not clickable"})]},p.name)})})})}function sh(e){const t=e.replace(/_+/g," ").trim();return t.charAt(0).toUpperCase()+t.slice(1)}const oh=k.createSvgIcon(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"})),ih=k.createSvgIcon(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"})),ah=k.createSvgIcon(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"})),lh=k.createSvgIcon(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"})),ch=k.createSvgIcon(m.jsx("path",{d:"M4 9h16v2H4zm0 4h10v2H4z"})),dh=k.createSvgIcon(m.jsx("path",{d:"M3 5v14h18V5zm5.33 12H5V7h3.33zm5.34 0h-3.33v-4h3.33zM19 17h-3.33v-4H19zm0-6h-8.67V7H19z"}));function uh(e,t=[]){const n=new Map;for(const o of e.tiles)for(const i of ce(o)?o.filters??[]:[])n.set(i.given,(n.get(i.given)??0)+1);const r=[],s=new Set;for(const o of e.localGivens??[])s.add(o.name),r.push({name:o.name,...o.label===void 0?{}:{label:o.label},type:o.type,...o.suggest?{field:o.suggest.dimension}:{},origin:"dashboard",local:o,boundTiles:n.get(o.name)??0});for(const o of t)s.has(o.name)||(s.add(o.name),r.push({...o,origin:"model",boundTiles:n.get(o.name)??0}));for(const[o,i]of n)s.has(o)||r.push({name:o,origin:"model",boundTiles:i});return r}function Ns(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function fh(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function Ir(e,t){const n=fh(e),r=t?.replace(/_type$/,"");if(!n||!r)return!0;const s=new Set(["date","timestamp"]);return s.has(n)?s.has(r):n===r}function Xo(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 hh(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const ph=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function gh(e,t){const r=(e.split(".").at(-1)??"").split(/[^A-Za-z0-9]+/).filter(Boolean).join("_").toUpperCase()||"FILTER",s=/^[A-Z_]/.test(r)?r:`F_${r}`,o=me.isStrictName(s)?s:`${s}_FILTER`,i=new Set(t);if(!i.has(o))return o;for(let a=2;;a++)if(!i.has(`${o}_${a}`))return`${o}_${a}`}const mh=[{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 fr(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 Yo=e=>ce(e)&&!Hn(e)&&e.declaration.kind!=="opaque";function vh(e,t){return e.tiles.map(n=>{const r=(ce(n)?n.filters??[]:[]).find(s=>s.given===t.name);return{include:r!==void 0,field:r?.field??t.field??t.name.toLowerCase(),...r?.op!==void 0?{op:r.op}:Ns(t.type)!==void 0?{op:Ns(t.type)}:{}}})}function yh(e,t,n){n.forEach((r,s)=>{const o=e.tiles[s];if(!o||!Yo(o))return;const i=(o.filters??[]).filter(l=>l.given!==t),a=r.include?[...i,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:i;a.length>0?o.filters=a:delete o.filters})}function xh(e,t){const n=(e.localGivens??[]).filter(o=>o.name!==t.name),r=(e.localGivens??[]).findIndex(o=>o.name===t.name),s=[...n];s.splice(r>=0?r:s.length,0,t),e.localGivens=s}function bh(e,t){for(const r of e.tiles){if(!ce(r))continue;const s=(r.filters??[]).filter(o=>o.given!==t);s.length>0?r.filters=s:delete r.filters}const n=(e.localGivens??[]).filter(r=>r.name!==t);n.length>0?e.localGivens=n:delete e.localGivens}const Qo=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function wh({open:e,document:t,control:n,available:r,takenNames:s=[],fieldsFor:o,onApply:i}){const a=S.useRef(n);e&&(a.current=n);const l=e?n:a.current,u=l!==void 0,[c,d]=S.useState({kind:"new"}),[f,h]=S.useState(""),[y,g]=S.useState("select"),[w,x]=S.useState(""),[p,v]=S.useState(""),[_,b]=S.useState([]),[E,T]=S.useState(!1),[M,O]=S.useState(!1),C=P=>t.sources.find(F=>F.name===P.source)?.base??P.source;S.useEffect(()=>{if(e)if(O(n!==void 0),n){d({kind:"existing",name:n.name}),h(n.label??"");const P=vh(t,n);b(P);const F=P.filter(Y=>Y.include),U=new Set(F.map(Y=>Y.field));v(U.size===1?F[0].field:n.field??""),T(U.size>1)}else d({kind:"new"}),h(""),g("select"),v(""),x(new Date().toISOString().slice(0,10)),b(t.tiles.map(P=>({include:Yo(P),field:""}))),T(!1)},[e,n,t]);const A=S.useMemo(()=>[...(t.localGivens??[]).map(P=>P.name),...r.map(P=>P.name),...s],[t,r,s]),R=S.useMemo(()=>p.trim()?gh(p.trim(),A):"",[p,A]),L=c.kind==="existing"?n??r.find(P=>P.name===c.name):R?{name:R,type:fr({name:R,label:f,kind:y,field:p}).type}:void 0,G=L?.type!==void 0&&!L.type.startsWith("filter<"),N=_.find(P=>P.include)?.op??Ns(L?.type),X=(P,F)=>{O(!0),b(U=>U.map((Y,Se)=>Se===P?{...Y,...F}:Y))},j=P=>{O(!0),b(F=>F.map(U=>({...U,op:P})))},z=P=>{const F=Ns(P);b(U=>U.map(({op:Y,...Se})=>F?{...Se,op:F}:Se))},D=P=>{O(!0),d({kind:"existing",name:P.name}),v(P.field??""),z(P.type)},I=P=>{O(!0),g(P),z(fr({name:"X",label:f,kind:P,field:p}).type)},B=t.tiles.map(Yo),q=B.filter(Boolean).length,H=_.filter((P,F)=>P.include&&B[F]).length,K=t.tiles.filter((P,F)=>(_[F]?.include??!1)&&B[F]&&ce(P)),te=K.length>0?K:t.tiles.filter((P,F)=>B[F]&&ce(P)),ye=S.useMemo(()=>{const P=new Map;let F=!1;for(const U of te){const Y=o?.(U);if(Y){F=!0;for(const Se of Y)P.has(Se.name)||P.set(Se.name,Se)}}return F?[...P.values()]:void 0},[_,t.tiles,o]),_e=(()=>{const P=p.trim();for(const F of K){const U=o?.(F);if(!U||U.some(Y=>Y.name===P))return C(F)}return K[0]?C(K[0]):t.sources[0]?.base})(),re=P=>{O(!0),b(F=>F.map((U,Y)=>({...U,include:P&&B[Y]})))},De=S.useMemo(()=>E?_:_.map(P=>({...P,field:p})),[E,_,p]),ge=P=>{for(const F of te){const U=o?.(F)?.find(Y=>Y.name===P.trim());if(U?.type)return U.type}},ve=P=>Ir(L?.type,P.type),Ge=(P,F)=>{if(P.trim()==="")return"Pick the field this filter compares.";const U=F?o?.(F):void 0;if(!U)return;const Y=U.find(Se=>Se.name===P.trim());if(!Y)return`Not a field of ${F?C(F):"the tiles' source"}.`;if(Y.type&&!Ir(L?.type,Y.type))return`${P.trim()} is ${Xo(Y.type)}; this filter compares ${Xo(L?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},Z=P=>{if(O(!0),v(P),u||c.kind!=="new")return;const F=ge(P),U=fr({name:"X",label:f,kind:y,field:P}).type;F&&!Ir(U,F)&&I(hh(F))},Xe=P=>{const F=t.tiles[P];return F&&ce(F)?F:void 0},ke=De.map((P,F)=>P.include&&B[F]?Ge(P.field,Xe(F)):void 0),ue=ke.every(P=>P===void 0),Oe=M?ke:ke.map(()=>{}),Ae=M&&!E&&H>0?K.map(P=>Ge(p,P)).find(Boolean):void 0,ie=L!==void 0&&ue&&(c.kind==="existing"||p.trim()!==""&&R!==""),qe=()=>{if(!(!L||!ie))if(c.kind==="new")i(L.name,De,fr({name:L.name,label:f.trim()||Qo(L.name),kind:y,field:p.trim(),..._e?{source:_e}:{},...w?{dateDefault:w}:{}}));else if(n?.origin==="dashboard"&&n.local){const P=f.trim(),F=P!==(n.local.label??"");i(L.name,De,F?{...n.local,...P?{label:P}:{}}:void 0)}else i(L.name,De)},Ye=u&&l.origin==="model";return{editing:u,shown:l,fromModel:Ye,source:c,setSource:d,label:f,setLabel:h,kind:y,dateDefault:w,setDateDefault:x,field:p,rows:_,setRows:b,perTile:E,setPerTile:T,newName:R,target:L,valueTyped:G,commonOp:N,setRow:X,setCommonOp:j,pickExisting:D,pickKind:I,bindable:B,bindableCount:q,included:H,commonFields:ye,setAll:re,accepts:ve,pickField:Z,rowProblems:Oe,commonProblem:Ae,canApply:ie,apply:qe}}function Ja({value:e,onChange:t,fields:n,accepts:r,label:s,ariaLabel:o,error:i,helperText:a,disabled:l,autoFocus:u,placeholder:c,inputRef:d,sx:f}){const h=S.useMemo(()=>(n??[]).filter(g=>r?.(g)??!0).map(g=>g.name),[n,r]),y=S.useMemo(()=>new Map((n??[]).map(g=>[g.name,g.type])),[n]);return m.jsx($.Autocomplete,{freeSolo:!0,size:"small",options:h,inputValue:e,onInputChange:(g,w)=>t(w),value:e,onChange:(g,w)=>t(typeof w=="string"?w:""),disabled:l,disableClearable:!0,renderOption:(g,w)=>S.createElement("li",{...g,key:w},m.jsx(tl,{type:y.get(w)}),m.jsx($.Typography,{variant:"body2",sx:{flex:1,ml:1},children:w})),renderInput:g=>m.jsx($.TextField,{...g,label:s,placeholder:c,autoFocus:u,...d?{inputRef:d}:{},error:i,helperText:a,InputLabelProps:{...g.InputLabelProps,shrink:!0},InputProps:{...g.InputProps,startAdornment:y.get(e.trim())?m.jsx($.Box,{sx:{display:"flex",ml:.5,mr:-.25},children:m.jsx(tl,{type:y.get(e.trim())})}):void 0},inputProps:{...g.inputProps,"aria-label":o}}),sx:f})}const _h=e=>e&&ce(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:e&&ce(e)&&e.declaration.kind==="query"?{label:"Not bindable",reason:"It names a query, whose filters live in that query's own definition."}:{label:"From the model",reason:"Declared on its source, which this report does not write."};function kh({open:e,document:t,control:n,available:r,takenNames:s,fieldsFor:o,onClose:i,onApply:a,onRemove:l}){const{theme:u}=be.usePublisherTheme(),c=u.ui,{editing:d,shown:f,fromModel:h,source:y,setSource:g,label:w,setLabel:x,kind:p,dateDefault:v,setDateDefault:_,field:b,rows:E,setRows:T,perTile:M,setPerTile:O,newName:C,target:A,valueTyped:R,commonOp:L,setRow:G,setCommonOp:N,pickExisting:X,pickKind:j,bindable:z,bindableCount:D,included:I,commonFields:B,setAll:q,accepts:H,pickField:K,rowProblems:te,commonProblem:ye,canApply:_e,apply:re}=wh({open:e,document:t,control:n,available:r,...s?{takenNames:s}:{},fieldsFor:o,onApply:a}),De=S.useRef(null),ge=k.edgeColor(u.cardBorder),ve=k.hoverEdgeColor(u.cardBorder,u.tileTitle),[Ge,Z]=S.useState(!1),[Xe,ke]=S.useState(!1);S.useEffect(()=>{e?ke(!0):Z(!1)},[e]),S.useEffect(()=>{Xe&&(ke(!1),Z(d&&I<D))},[Xe]),S.useEffect(()=>{M&&Z(!0)},[M]);const ue=B?.find(P=>P.name===b.trim())?.type,Oe=P=>{if(!ue)return;const F=fr({name:"X",label:w,kind:P,field:b}).type;return Ir(F,ue)?void 0:`${b.trim()} is ${Xo(ue)}, which this control cannot filter.`},Ae=w.trim()||(C?Qo(C):"Filter"),ie=p==="number"?"Any":p==="date"?v?new Date(`${v}T00:00:00`).toLocaleDateString([],{month:"short",day:"numeric",year:"numeric"}):"Any":"All",qe={...Fs(ge,c),alignSelf:"flex-start","& .MuiToggleButton-root":{...Fs(ge,c)["& .MuiToggleButton-root"],textTransform:"none"}},Ye=(P,F,U)=>m.jsx($.TextField,{select:!0,size:"small",label:"Compares",value:P??">=",onChange:Y=>F(Y.target.value),inputProps:{"aria-label":U},sx:{width:130},children:ph.filter(Y=>Y.op!=="~").map(Y=>m.jsx($.MenuItem,{value:Y.op,children:Y.label},Y.op))});return m.jsx(k.AppDialog,{className:`${k.reportClasses.dialog} ${k.reportClasses.filterDialog}`,open:e,onClose:i,...d?{}:{initialFocus:De},title:d?f.label??f.name:"Add a filter",description:d?m.jsxs(m.Fragment,{children:[m.jsxs($.Box,{component:"span",sx:{fontFamily:c.font.mono},children:["$",f.name]}),h?" · 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:[d&&m.jsx($.Button,{color:"error",startIcon:m.jsx(k.DeleteOutlineIcon,{}),onClick:()=>l(f.name),sx:P=>({mr:"auto",color:k.dangerTextColor(P)}),children:"Remove filter"}),m.jsx($.Button,{onClick:i,children:"Cancel"}),m.jsx($.Tooltip,{title:_e||A===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:m.jsx("span",{children:m.jsx($.Button,{variant:"contained",onClick:re,disabled:!_e,children:d?"Apply":"Add filter"})})})]}),children:m.jsxs($.Stack,{sx:{gap:2.5,pt:1},children:[!d&&r.length>0&&m.jsxs($.ToggleButtonGroup,{exclusive:!0,size:"small",value:y.kind,onChange:(P,F)=>{F==="new"?g({kind:"new"}):F==="existing"&&r[0]&&X(r[0])},"aria-label":"Where the filter comes from",sx:qe,children:[m.jsx($.ToggleButton,{value:"new",children:"New in this report"}),m.jsx($.ToggleButton,{value:"existing",children:"From the model"})]}),!d&&y.kind==="existing"?m.jsx($.TextField,{select:!0,size:"small",label:"Filter",value:y.name,onChange:P=>{const F=r.find(U=>U.name===P.target.value);F&&X(F)},children:r.map(P=>m.jsxs($.MenuItem,{value:P.name,children:[P.label??P.name,m.jsxs($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",P.name]})]},P.name))}):null,m.jsxs($.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:h?"1fr":"minmax(0, 1.4fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[!M&&m.jsx(Ja,{value:b,onChange:K,fields:B,accepts:H,label:"Field",ariaLabel:"Field to filter",placeholder:"category",inputRef:De,error:ye!==void 0,helperText:ye??(!d&&C?`Declared as $${C}`:void 0)}),!h&&m.jsx($.TextField,{size:"small",label:"Label",placeholder:C?Qo(C):"",value:w,onChange:P=>x(P.target.value),InputLabelProps:{shrink:!0},inputProps:{"aria-label":"Filter label"}})]}),R&&!M&&Ye(L,N,"Comparison"),!d&&y.kind==="new"&&m.jsxs($.Box,{children:[m.jsx(el,{children:"Control"}),m.jsx($.Box,{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:mh.map(P=>{const F=P.kind===p,U=Oe(P.kind);return m.jsx($.Tooltip,{title:U??P.hint,describeChild:!0,children:m.jsxs($.ButtonBase,{role:"radio","aria-checked":F,"aria-label":P.label,"aria-disabled":U!==void 0,onClick:()=>{U===void 0&&j(P.kind)},sx:Y=>({flexDirection:"column",gap:.5,px:1,py:1.25,borderRadius:c.radius.tile,border:`1px solid ${F?u.accent:ge}`,boxShadow:F?`0 0 0 1px ${u.accent}`:"none",bgcolor:F?`color-mix(in srgb, ${u.accent} 6%, ${Y.palette.background.paper})`:Y.palette.background.paper,color:F?u.accent:Y.palette.text.secondary,opacity:U?.45:1,cursor:U?"default":"pointer",transition:`border-color ${k.MOTION_FAST}, background-color ${k.MOTION_FAST}`,"&:hover":U||F?{}:{borderColor:ve}}),children:[m.jsx($h,{kind:P.kind}),m.jsx($.Box,{component:"span",sx:{...c.type.caption,fontWeight:F?600:500,color:F?u.accent:"text.primary",textAlign:"center"},children:Sh[P.kind]})]})},P.kind)})}),p==="date"&&m.jsx($.TextField,{size:"small",type:"date",label:"Starts at",value:v,onChange:P=>_(P.target.value),InputLabelProps:{shrink:!0},sx:{mt:1.5,width:200}})]}),m.jsxs($.Box,{sx:{border:`1px solid ${ge}`,borderRadius:c.radius.tile,overflow:"hidden"},children:[m.jsxs($.Stack,{direction:"row",sx:{alignItems:"center",gap:1.25,px:1.5,py:1},children:[m.jsx(dh,{"aria-hidden":!0,sx:{fontSize:18,color:"text.secondary"}}),m.jsxs($.Typography,{variant:"body2",sx:{flex:1,minWidth:0},children:[m.jsx($.Box,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:I===D&&D>0?`Applies to all ${I} tile${I===1?"":"s"}`:`Applies to ${I} of ${D} tile${D===1?"":"s"}`}),!M&&b.trim()!==""&&I>0&&m.jsxs($.Box,{component:"span",sx:{color:"text.secondary"},children:[" · each filters on ",m.jsx($.Box,{component:"span",sx:{...c.type.code},children:b.trim()})]})]}),!M&&m.jsx($.Button,{size:"small","aria-expanded":Ge,onClick:()=>Z(P=>!P),children:Ge?"Done choosing":"Choose tiles"})]}),m.jsx($.Collapse,{in:Ge,unmountOnExit:!0,children:m.jsxs($.Box,{sx:{borderTop:`1px solid ${ge}`,px:.5,pb:1},children:[m.jsxs($.Stack,{direction:"row",sx:{alignItems:"center",gap:.5,pt:.5},children:[m.jsx($.Checkbox,{size:"small",checked:D>0&&I===D,indeterminate:I>0&&I<D,disabled:D===0,onChange:P=>q(P.target.checked),inputProps:{"aria-label":"All tiles"}}),m.jsx($.Typography,{variant:"body2",sx:{flex:1,color:"text.secondary"},children:"All tiles"}),m.jsx($.Button,{size:"small",onClick:()=>{M||T(P=>P.map(F=>({...F,field:b}))),O(P=>!P)},children:M?"Same field for all":"Adjust per tile"})]}),m.jsx($.Stack,{sx:{gap:M?1:0},children:t.tiles.map((P,F)=>{if(!ce(P))return null;const U=E[F],Y=P.label??P.name,Se=M?te[F]:void 0;return m.jsxs($.Stack,{direction:"row",sx:{gap:1,alignItems:M?"flex-start":"center",opacity:z[F]?1:.6},children:[m.jsx($.Checkbox,{size:"small",disabled:!z[F],checked:(U?.include??!1)&&z[F],inputProps:{"aria-label":`Filter ${Y}`},onChange:we=>G(F,{include:we.target.checked})}),m.jsx($.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:M?1:0},noWrap:!0,children:Y}),z[F]?M&&m.jsxs(m.Fragment,{children:[R&&Ye(U?.op,we=>G(F,{op:we}),`Comparison for ${Y}`),m.jsx(Ja,{value:U?.field??"",onChange:we=>G(F,{field:we}),fields:o?.(P),accepts:H,label:"Field",ariaLabel:`Field for ${Y}`,disabled:!U?.include,error:Se!==void 0,helperText:Se,sx:{width:220,pr:1}})]}):m.jsx($.Typography,{variant:"caption",sx:{color:u.tileTitle,pr:1,maxWidth:260,textAlign:"right"},children:_h(t.tiles[F]).reason})]},fe(P))})})]})})]}),I===0&&m.jsx($.Typography,{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."}),!h&&m.jsxs($.Box,{children:[m.jsx(el,{children:"Preview"}),m.jsx($.Box,{sx:P=>({display:"flex",alignItems:"center",gap:1,p:1.5,borderRadius:c.radius.tile,bgcolor:P.palette.action.hover}),children:m.jsxs($.Box,{"aria-hidden":!0,sx:P=>({display:"inline-flex",alignItems:"center",gap:.75,height:30,px:1.25,borderRadius:c.radius.control,border:`1px solid ${ge}`,bgcolor:P.palette.background.paper,...c.type.control}),children:[m.jsx($.Box,{component:"span",sx:{color:"text.secondary"},children:Ae}),m.jsx($.Box,{component:"span",sx:{fontWeight:c.type.label.fontWeight},children:ie}),m.jsx(k.ExpandMoreIcon,{sx:{fontSize:16,color:"text.secondary"}})]})})]})]})})}function el({children:e}){const t=be.usePublisherTheme().theme.ui;return m.jsx($.Typography,{component:"div",sx:{...t.type.label,color:"text.secondary",mb:.75},children:e})}const Sh={select:"Pick one",multiselect:"Pick several",text:"Text",number:"Range",date:"Date"};function $h({kind:e}){const t={fontSize:22};switch(e){case"select":return m.jsx(oh,{sx:t});case"multiselect":return m.jsx(ih,{sx:t});case"text":return m.jsx(ch,{sx:t});case"number":return m.jsx(lh,{sx:t});case"date":return m.jsx(ah,{sx:t})}}function tl({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=be.usePublisherTheme().theme.ui;return n?m.jsx($.Box,{component:"span","aria-hidden":!0,sx:s=>({fontFamily:r.font.mono,fontSize:10,fontWeight:r.type.label.fontWeight,color:s.palette.text.secondary,bgcolor:s.palette.action.hover,borderRadius:"4px",px:.5,py:.25,minWidth:22,textAlign:"center",flex:"none"}),children:n}):null}const nl=k.createSvgIcon(m.jsx("path",{d:"M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"}));function _c(e,t,n,r){const[s,o]=S.useState(void 0);return S.useEffect(()=>{t&&e!==void 0&&o(structuredClone(e))},[t,e]),{draft:s,patch:c=>o(d=>{if(d===void 0)return d;const f=structuredClone(d);return c(f),f}),apply:c=>{if(s===void 0)return;const d=structuredClone(s);c(d),o(d),JSON.stringify(d)!==JSON.stringify(e)&&n(d)},close:()=>{s!==void 0&&e!==void 0&&JSON.stringify(s)!==JSON.stringify(e)&&n(s),r()},discard:()=>o(void 0)}}const Th=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.`,Eh=new Set(["bar_chart","line_chart","scatter_chart","combo_chart"]),Ch="Its chart's bars, lines and points do not respond to a click; show it as a table to click its cells.",Oh="Declared on its source, so its chart is set in the model.",Mh="It names a query, so its chart is set where that query is declared.";function Ih({anchor:e,tile:t,onClose:n,onCommit:r,onDrills:s,onDuplicate:o,duplicateBlocked:i,view:a,viewStatus:l}){const{theme:u}=be.usePublisherTheme(),c=u.ui,{draft:d,apply:f,patch:h,close:y}=_c(t,e!==null,r,n),[g,w]=S.useState(void 0),x=d!==void 0&&ce(d)?d:void 0,p=x!==void 0&&!Hn(x),v=D=>f(I=>{ce(I)&&D(I)}),_=S.useRef(void 0),b=S.useRef(null),E=e!==null;S.useEffect(()=>{E?_.current=t&&ce(t)?t.chart:void 0:w(void 0)},[E]);const T=x?.chart??"default",M=bc(a,T,l),O=x?x.declaration.kind==="query"?Mh:p?x.chart==="custom"?Th(x.chartLines):void 0:Oh:void 0,C=D=>v(I=>{const B=_.current;D===(B??"default")?(B===void 0?delete I.chart:I.chart=B,delete I.chartCarried):(I.chart=D,a?I.chartCarried=a.chart?[a.chart]:[]:delete I.chartCarried)}),A=p?s?void 0:"Its source declares no dimension a click could filter by.":void 0,R=T==="default"?a?.chart:T,L=R!==void 0&&Eh.has(R)?Ch:void 0,G=D=>I=>w({kind:D,anchor:I.currentTarget}),N=O??(R===void 0||!Dh.has(R)?"Only a bar, line, scatter or bar and line chart has a color to set.":void 0),X=Array.from(new Set(u.series.map(k.seriesColorFrom).filter(D=>D!==void 0))).slice(0,8),j=D=>v(I=>{D===void 0?delete I.color:I.color=D.toLowerCase()}),z=(D,I,B)=>m.jsxs(m.Fragment,{children:[m.jsx($.ListItemText,{primary:D,...B?{secondary:B}:{},secondaryTypographyProps:{sx:{whiteSpace:"normal",maxWidth:240}}}),I&&m.jsx($.Typography,{variant:"body2",sx:{color:"text.secondary",ml:2},children:I})]});return m.jsxs(m.Fragment,{children:[m.jsxs($.Menu,{className:k.reportClasses.menu,open:e!==null&&d!==void 0,anchorEl:e,onClose:y,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":x?dt(x):"Tile"},slotProps:{paper:{sx:{minWidth:240,mt:.5,borderRadius:c.radius.menu,border:`1px solid ${k.edgeColor(u.cardBorder)}`,boxShadow:c.shadow.menu}}},children:[x&&m.jsxs($.MenuItem,{"aria-haspopup":"menu","aria-expanded":g?.kind==="chart",disabled:O!==void 0,onClick:G("chart"),onKeyDown:D=>{D.key==="ArrowRight"&&O===void 0&&w({kind:"chart",anchor:D.currentTarget})},children:[z("Chart",O?void 0:M.find(D=>D.value===T)?.label,O),m.jsx(nl,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),x&&O===void 0&&m.jsxs($.MenuItem,{"aria-haspopup":"menu","aria-expanded":g?.kind==="color",disabled:N!==void 0,onClick:G("color"),onKeyDown:D=>{D.key==="ArrowRight"&&N===void 0&&w({kind:"color",anchor:D.currentTarget})},children:[z("Color",N?void 0:x.color??"Theme",N),!N&&m.jsx($o,{color:x.color??u.series[0],trailing:!0}),m.jsx(nl,{fontSize:"small",sx:{ml:1,color:"text.secondary"}})]}),p&&m.jsx($.MenuItem,{"aria-haspopup":"dialog",disabled:A!==void 0,onClick:()=>{y(),s?.()},children:z("Clickable cells…",void 0,A??L)}),x&&o&&m.jsx($.MenuItem,{disabled:i!==void 0,onClick:()=>{y(),o()},children:z("Duplicate",void 0,i)}),x?.declaration.kind==="opaque"&&m.jsxs($.Typography,{variant:"body2",sx:{color:u.tileTitle,px:2,py:.75,maxWidth:260},children:["Its body is ",x.declaration.why,", so a filter has no single place to go."]}),x&&m.jsx($.Divider,{}),x&&m.jsx($.Box,{"aria-hidden":!0,sx:{px:2,py:.5,...c.type.code,color:"text.secondary"},children:dt(x).replace("->","→")})]}),m.jsx($.Menu,{className:k.reportClasses.menu,open:g?.kind==="chart",anchorEl:g?.anchor??null,onClose:()=>w(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,disabledItemsFocusable:!0,"aria-label":"Chart",onKeyDown:D=>{D.key==="ArrowLeft"&&(D.preventDefault(),w(void 0))}},children:M.filter(D=>D.value!=="custom").map(D=>m.jsxs($.MenuItem,{role:"menuitemradio","aria-checked":D.value===T,disabled:D.disabled===!0,onClick:()=>{C(D.value),w(void 0)},children:[m.jsx($.ListItemText,{primary:D.label,...D.reason??D.hint?{secondary:D.reason??D.hint}:{}}),D.value===T&&m.jsx($.ListItemIcon,{sx:{minWidth:0,ml:2},children:m.jsx(k.CheckIcon,{fontSize:"small",sx:{color:u.accent}})})]},D.value))}),m.jsxs($.Menu,{className:k.reportClasses.menu,open:g?.kind==="color",anchorEl:g?.anchor??null,onClose:()=>w(void 0),anchorOrigin:{vertical:"top",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"right"},MenuListProps:{dense:!0,"aria-label":"Color",onKeyDown:D=>{D.key==="ArrowLeft"&&(D.preventDefault(),w(void 0))}},children:[m.jsxs($.MenuItem,{role:"menuitemradio","aria-checked":x?.color===void 0,onClick:()=>{j(void 0),w(void 0)},children:[m.jsx($o,{color:u.series[0]}),m.jsx($.ListItemText,{primary:"Theme",secondary:"The page's own colors"}),x?.color===void 0&&m.jsx(rl,{color:u.accent})]}),X.map(D=>m.jsxs($.MenuItem,{role:"menuitemradio","aria-checked":x?.color===D.toLowerCase(),onClick:()=>{j(D),w(void 0)},children:[m.jsx($o,{color:D}),m.jsx($.ListItemText,{primary:D.toLowerCase()}),x?.color===D.toLowerCase()&&m.jsx(rl,{color:u.accent})]},D)),m.jsx($.Divider,{}),m.jsxs($.MenuItem,{component:"label","aria-checked":x?.color!==void 0&&!X.some(D=>D.toLowerCase()===x.color),role:"menuitemradio",onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),b.current?.click())},children:[m.jsx("input",{ref:b,type:"color","aria-label":"Other color",value:x?.color??Ph(u.series[0]),onChange:D=>{const I=D.target.value;k.isSeriesColor(I)&&h(B=>{ce(B)&&(B.color=I.toLowerCase())})},style:{width:18,height:18,padding:0,border:"none",background:"none",marginRight:12}}),m.jsx($.ListItemText,{primary:"Other color…"})]})]})]})}const Dh=new Set(["bar_chart","line_chart","scatter_chart","combo_chart"]),Ph=e=>(e&&k.seriesColorFrom(e))??"#000000";function $o({color:e,trailing:t=!1}){return m.jsx($.Box,{"aria-hidden":!0,"data-swatch":t?"trailing":"leading",sx:{width:14,height:14,borderRadius:"3px",bgcolor:e,border:"1px solid rgba(0,0,0,0.15)",...t?{ml:1}:{mr:1.5},flex:"none"}})}function rl({color:e}){return m.jsx($.ListItemIcon,{sx:{minWidth:0,ml:2},children:m.jsx(k.CheckIcon,{fontSize:"small",sx:{color:e}})})}const co=e=>e.label??k.tileTitle(dt(e));function jh({editor:e,catalog:t,columns:n,dashboards:r,bindings:s,tiles:o,drillSource:i,setDrillSource:a,exitDialog:l,renderViewPreview:u,takenGivenNames:c}){const{filterDialog:d,setFilterDialog:f}=s,{menu:h,setMenu:y}=o,[g,w]=S.useState(),x=h===void 0?void 0:e.document.tiles[h.index],p=x&&ce(x)?x:void 0,v=(()=>{if(!p||!t)return;const _=t.documentViews?.get(p.source??"")?.get(p.name);if(_&&e.document.sources.some(T=>T.name===p.source))return _;if(p.declaration.kind==="inline"||p.declaration.kind==="opaque")return;const b=e.document.sources.find(T=>T.name===p.source)?.base??p.source,E=p.declaration.kind==="reference"?p.declaration.from:p.name;return t.sources.find(T=>T.name===b)?.views.find(T=>T.name===E)})();return m.jsxs(m.Fragment,{children:[m.jsx(kh,{open:d!==void 0,document:e.document,...d?.control?{control:d.control}:{},available:s.available,...c?{takenNames:c}:{},...t?{fieldsFor:s.fieldsFor}:{},onClose:()=>f(void 0),onApply:s.applyFilter,onRemove:s.dropControl}),m.jsx(Ih,{anchor:h?.anchor??null,tile:h===void 0?void 0:e.document.tiles[h.index],onClose:()=>y(void 0),onCommit:_=>{const b=h?.index;if(b===void 0)return;const E=Kf(_);e.update(T=>{T.tiles[b]=E,E!==_&&k.isPlaced(T.tiles)&&(T.tiles=Rt(T.tiles,n,b))})},view:v,...v===void 0&&p?{viewStatus:t?"unlisted":"loading"}:{},onDuplicate:()=>{h&&o.duplicate(h.index)},...p&&Ws(p)!==void 0?{duplicateBlocked:Ws(p)}:{},...(e.document.sources.find(_=>_.name===p?.source)?.dimensions?.length??0)>0?{onDrills:()=>{w(p?co(p):void 0),a(p?.source)}}:{}}),m.jsx(rh,{open:i!==void 0,document:e.document,source:e.document.sources.find(_=>_.name===i),givenNames:s.controlList.map(_=>_.name),dashboards:r??[],...g?{tileLabel:g}:{},onClose:()=>a(void 0),onApply:_=>e.update(b=>{const T=[...(b.drills??[]).filter(M=>M.source!==i),..._];T.length===0?delete b.drills:b.drills=T})}),m.jsx(k.UnsavedChangesDialog,{...l}),m.jsx(eh,{open:o.addingTile,document:e.document,catalog:t,columns:n,onClose:o.closeAdd,onAdd:o.addTile,onAddText:o.addText,...u?{renderPreview:u}:{}})]})}var Rh=Symbol.for("preact-signals");function uo(){if(Pt>1)Pt--;else{var e,t=!1;for((function(){var s=Gs;for(Gs=void 0;s!==void 0;){var o=s.S;if(o.v===s.v)for(var i=o.t;i!==void 0;i=i.x)i.i===s.i&&(i.i=o.i);s=s.o}})();Pr!==void 0;){var n=Pr;for(Pr=void 0,zs++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Sc(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(zs=0,Pt--,t)throw e}}function Re(e){if(Pt>0)return e();Zo=++Ah,Pt++;try{return e()}finally{uo()}}var Dr,Te=void 0;function ae(e){var t=Te,n=Dr;Te=void 0,Dr=void 0;try{return e()}finally{Te=t,Dr=n}}var Pr=void 0,Pt=0,zs=0,Ah=0,Zo=0,Gs=void 0,Hs=0;function kc(e){if(Te!==void 0){var t=e.n;if(t===void 0||t.t!==Te)return t={i:0,S:e,p:Te.s,n:void 0,t:Te,e:void 0,x:void 0,r:t},Te.s!==void 0&&(Te.s.n=t),Te.s=t,e.n=t,32&Te.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=Te.s,t.n=void 0,Te.s.n=t,Te.s=t),t}}function it(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}it.prototype.brand=Rh;it.prototype.h=function(){return!0};it.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)}))};it.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 s;(s=t.Z)==null||s.call(t)}))}};it.prototype.subscribe=function(e){var t=this;return yt(function(){var n=t.value;ae(function(){return e(n)})},{name:"sub"})};it.prototype.valueOf=function(){return this.value};it.prototype.toString=function(){return this.value+""};it.prototype.toJSON=function(){return this.value};it.prototype.peek=function(){var e=this;return ae(function(){return e.value})};Object.defineProperty(it.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(zs>100)throw new Error("Cycle detected");(function(n){Pt!==0&&zs===0&&n.l!==Zo&&(n.l=Zo,Gs={S:n,v:n.v,i:n.i,o:Gs})})(this),this.v=e,this.i++,Hs++,Pt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{uo()}}}});function qn(e,t){return new it(e,t)}function Sc(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 $c(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 Tc(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 fn(e,t){it.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Hs-1,this.f=4}fn.prototype=new it;fn.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Hs))return!0;if(this.g=Hs,this.f|=1,this.i>0&&!Sc(this))return this.f&=-2,!0;var e=Te;try{$c(this),Te=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 Te=e,Tc(this),this.f&=-2,!0};fn.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)}it.prototype.S.call(this,e)};fn.prototype.U=function(e){if(this.t!==void 0&&(it.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)}};fn.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(fn.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 sl(e,t){return new fn(e,t)}function Ec(e){var t=e.m;if(e.m=void 0,typeof t=="function"){Pt++;var n=Te;Te=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,Wi(e),r}finally{Te=n,uo()}}}function Wi(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ec(e)}function Lh(e){if(Te!==this)throw new Error("Out-of-order effect");Tc(this),Te=e,this.f&=-2,8&this.f&&Wi(this),uo()}function Un(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,Dr&&Dr.push(this)}Un.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()}};Un.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Ec(this),$c(this),Pt++;var e=Te;return Te=this,Lh.bind(this,e)};Un.prototype.N=function(){2&this.f||(this.f|=2,this.u=Pr,Pr=this)};Un.prototype.d=function(){this.f|=8,1&this.f||Wi(this)};Un.prototype.dispose=function(){this.d()};function yt(e,t){var n=new Un(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Bh=Object.create,Ni=Object.defineProperty,Fh=Object.defineProperties,Wh=Object.getOwnPropertyDescriptor,Nh=Object.getOwnPropertyDescriptors,ol=Object.getOwnPropertySymbols,zh=Object.prototype.hasOwnProperty,Gh=Object.prototype.propertyIsEnumerable,Hh=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Kn=e=>{throw TypeError(e)},Jo=(e,t,n)=>t in e?Ni(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qh=(e,t)=>{for(var n in t||(t={}))zh.call(t,n)&&Jo(e,n,t[n]);if(ol)for(var n of ol(t))Gh.call(t,n)&&Jo(e,n,t[n]);return e},Uh=(e,t)=>Fh(e,Nh(t)),il=(e,t)=>Ni(e,"name",{value:t,configurable:!0}),Kh=e=>{var t;return[,,,Bh((t=void 0)!=null?t:null)]},Cc=["class","method","getter","setter","accessor","field","value","get","set"],hr=e=>e!==void 0&&typeof e!="function"?Kn("Function expected"):e,Vh=(e,t,n,r,s)=>({kind:Cc[e],name:t,metadata:r,addInitializer:o=>n._?Kn("Already initialized"):s.push(hr(o||null))}),Oc=(e,t)=>Jo(t,Hh("metadata"),e[3]),Qt=(e,t,n,r)=>{for(var s=0,o=e[t>>1],i=o&&o.length;s<i;s++)t&1?o[s].call(n):r=o[s].call(n,r);return r},Vn=(e,t,n,r,s,o)=>{var i,a,l,u,c,d=t&7,f=!!(t&8),h=!!(t&16),y=d>3?e.length+1:d?f?1:2:0,g=Cc[d+5],w=d>3&&(e[y-1]=[]),x=e[y]||(e[y]=[]),p=d&&(!h&&!f&&(s=s.prototype),d<5&&(d>3||!h)&&Wh(d<4?s:{get[n](){return pt(this,o)},set[n](_){return Nt(this,o,_)}},n));d?h&&d<4&&il(o,(d>2?"set ":d>1?"get ":"")+n):il(s,n);for(var v=r.length-1;v>=0;v--)u=Vh(d,n,l={},e[3],x),d&&(u.static=f,u.private=h,c=u.access={has:h?_=>Xh(s,_):_=>n in _},d^3&&(c.get=h?_=>(d^1?pt:Yh)(_,s,d^4?o:p.get):_=>_[n]),d>2&&(c.set=h?(_,b)=>Nt(_,s,b,d^4?o:p.set):(_,b)=>_[n]=b)),a=(0,r[v])(d?d<4?h?o:p[g]:d>4?void 0:{get:p.get,set:p.set}:s,u),l._=1,d^4||a===void 0?hr(a)&&(d>4?w.unshift(a):d?h?o=a:p[g]=a:s=a):typeof a!="object"||a===null?Kn("Object expected"):(hr(i=a.get)&&(p.get=i),hr(i=a.set)&&(p.set=i),hr(i=a.init)&&w.unshift(i));return d||Oc(e,s),p&&Ni(s,n,p),h?d^4?o:p:s},zi=(e,t,n)=>t.has(e)||Kn("Cannot "+n),Xh=(e,t)=>Object(t)!==t?Kn('Cannot use the "in" operator on this value'):e.has(t),pt=(e,t,n)=>(zi(e,t,"read from private field"),n?n.call(e):t.get(e)),pr=(e,t,n)=>t.has(e)?Kn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Nt=(e,t,n,r)=>(zi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Yh=(e,t,n)=>(zi(e,t,"access private method"),n);function ei(e,t){if(t){let n;return sl(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return sl(e)}function wt(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((r,s)=>!wt(r,t[s]));if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:!n.some(o=>!wt(e[o],t[o]))}return!1}function le({get:e},t){return{init(n){return qn(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function We(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=ei(e.bind(this)),n.set(this,r)),r.value}}function To(e=!0){return function(t,n){n.addInitializer(function(){const r=n.kind==="field"?this:n.static?this:Object.getPrototypeOf(this),s=Object.getOwnPropertyDescriptor(r,n.name);s&&Object.defineProperty(r,n.name,Uh(qh({},s),{enumerable:e}))})}}function Zr(...e){const t=e.map(n=>yt(n));return()=>t.forEach(n=>n())}var Mc,Ic,Dc,Pc,jc,Rc,nt,Gi,Eo,ti,ni,Je,Hi,Co,Ac,ri,qi,Oo,si,oi;Rc=[le],jc=[le],Pc=[le],Dc=[To()],Ic=[To()],Mc=[To()];var hn=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Qt(nt,5,this),pr(this,Je),pr(this,Gi,Qt(nt,8,this)),Qt(nt,11,this),pr(this,Hi,Qt(nt,12,this)),Qt(nt,15,this),pr(this,qi,Qt(nt,16,this)),Qt(nt,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return pt(this,Je,si)}get initial(){return pt(this,Je,ti)}get previous(){return pt(this,Je,Ac)}set current(e){const t=ae(()=>pt(this,Je,si));e&&t&&this.equals(t,e)||Re(()=>{pt(this,Je,ti)||Nt(this,Je,e,ni),Nt(this,Je,t,ri),Nt(this,Je,e,oi)})}reset(e=this.defaultValue){Re(()=>{Nt(this,Je,void 0,ri),Nt(this,Je,e,ni),Nt(this,Je,e,oi)})}};nt=Kh();Gi=new WeakMap;Je=new WeakSet;Hi=new WeakMap;qi=new WeakMap;Eo=Vn(nt,20,"#initial",Rc,Je,Gi),ti=Eo.get,ni=Eo.set;Co=Vn(nt,20,"#previous",jc,Je,Hi),Ac=Co.get,ri=Co.set;Oo=Vn(nt,20,"#current",Pc,Je,qi),si=Oo.get,oi=Oo.set;Vn(nt,2,"current",Dc,hn);Vn(nt,2,"initial",Ic,hn);Vn(nt,2,"previous",Mc,hn);Oc(nt,hn);function Mo(e){return ae(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Zt,Qh=class{constructor(){pr(this,Zt,new WeakMap)}get(e,t){var n;return e?(n=pt(this,Zt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return pt(this,Zt).has(e)||pt(this,Zt).set(e,new Map),(r=pt(this,Zt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=pt(this,Zt).get(e))==null?void 0:t.clear():void 0}};Zt=new WeakMap;var Zh=Object.create,Lc=Object.defineProperty,Jh=Object.getOwnPropertyDescriptor,al=Object.getOwnPropertySymbols,ep=Object.prototype.hasOwnProperty,tp=Object.prototype.propertyIsEnumerable,Bc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),fo=e=>{throw TypeError(e)},ll=Math.pow,ii=(e,t,n)=>t in e?Lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,np=(e,t)=>{for(var n in t||(t={}))ep.call(t,n)&&ii(e,n,t[n]);if(al)for(var n of al(t))tp.call(t,n)&&ii(e,n,t[n]);return e},rp=e=>{var t;return[,,,Zh((t=e?.[Bc("metadata")])!=null?t:null)]},Fc=["class","method","getter","setter","accessor","field","value","get","set"],Wc=e=>e!==void 0&&typeof e!="function"?fo("Function expected"):e,sp=(e,t,n,r,s)=>({kind:Fc[e],name:t,metadata:r,addInitializer:o=>n._?fo("Already initialized"):s.push(Wc(o||null))}),op=(e,t)=>ii(t,Bc("metadata"),e[3]),ip=(e,t,n,r)=>{for(var s=0,o=e[t>>1],i=o&&o.length;s<i;s++)o[s].call(n);return r},Nc=(e,t,n,r,s,o)=>{for(var i,a,l,u,c=t&7,d=!1,f=!1,h=2,y=Fc[c+5],g=e[h]||(e[h]=[]),w=(s=s.prototype,Jh(s,n)),x=r.length-1;x>=0;x--)l=sp(c,n,a={},e[3],g),l.static=d,l.private=f,u=l.access={has:p=>n in p},u.get=p=>p[n],i=(0,r[x])(w[y],l),a._=1,Wc(i)&&(w[y]=i);return w&&Lc(s,n,w),s},zc=(e,t,n)=>t.has(e)||fo("Cannot "+n),ap=(e,t,n)=>(zc(e,t,"read from private field"),t.get(e)),lp=(e,t,n)=>t.has(e)?fo("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),cp=(e,t,n,r)=>(zc(e,t,"write to private field"),t.set(e,n),n),gt=class ai{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ai(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 ai(t,n)}},Ct=class Jt{constructor(t,n,r,s){this.left=t,this.top=n,this.width=r,this.height=s,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:s,width:o,height:i,scale:a}=this,l=new Jt(s+t,r+n,o,i);return l.scale=np({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:o,bottom:i}=this;return{width:t,height:n,left:r,top:s,right:o,bottom:i}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new gt((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Jt))return!1;const{left:n,top:r,width:s,height:o}=this;return n===t.left&&r===t.top&&s===t.width&&o===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:o}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=o}intersectionArea(t){return t instanceof Jt?dp(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:s}){return new Jt(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(o,i)=>{const a=r[i],l=i==="x"?o.left:o.top,u=i==="x"?o.width:o.height;return a=="start"?l:a=="end"?l+u:l+u/2};return gt.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return Jt.from(t).intersectionRatio(Jt.from(n))}};function dp(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),s=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height),i=s-r,a=o-n;return r<s&&n<o?i*a:0}var Gc,Hc,li,_s,Jr,ho=class extends(li=hn,Hc=[We],Gc=[We],li){constructor(t){const n=gt.from(t);super(n,(r,s)=>gt.equals(r,s)),ip(Jr,5,this),lp(this,_s,0),this.velocity={x:0,y:0}}get delta(){return gt.delta(this.current,this.initial)}get direction(){const{current:t,previous:n}=this;if(!n)return null;const r={x:t.x-n.x,y:t.y-n.y};return!r.x&&!r.y?null:Math.abs(r.x)>Math.abs(r.y)?r.x>0?"right":"left":r.y>0?"down":"up"}get current(){return super.current}set current(t){const{current:n}=this,r=gt.from(t),s={x:r.x-n.x,y:r.y-n.y},o=Date.now(),i=o-ap(this,_s),a=l=>Math.round(l/i*100);Re(()=>{cp(this,_s,o),this.velocity={x:a(s.x),y:a(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(gt.from(t)),this.velocity={x:0,y:0}}};Jr=rp(li);_s=new WeakMap;Nc(Jr,2,"delta",Hc,ho);Nc(Jr,2,"direction",Gc,ho);op(Jr,ho);function ci({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(ll(r,2)+ll(s,2))>n:"x"in n&&"y"in n?r>n.x&&s>n.y:"x"in n?r>n.x:"y"in n?s>n.y:!1}var qc=(e=>(e.Horizontal="x",e.Vertical="y",e))(qc||{}),Uc=Object.values(qc),up=Object.create,Ui=Object.defineProperty,fp=Object.defineProperties,hp=Object.getOwnPropertyDescriptor,pp=Object.getOwnPropertyDescriptors,qs=Object.getOwnPropertySymbols,Kc=Object.prototype.hasOwnProperty,Vc=Object.prototype.propertyIsEnumerable,Xc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Xn=e=>{throw TypeError(e)},di=(e,t,n)=>t in e?Ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ki=(e,t)=>{for(var n in t||(t={}))Kc.call(t,n)&&di(e,n,t[n]);if(qs)for(var n of qs(t))Vc.call(t,n)&&di(e,n,t[n]);return e},Vi=(e,t)=>fp(e,pp(t)),cl=(e,t)=>Ui(e,"name",{value:t,configurable:!0}),Yc=(e,t)=>{var n={};for(var r in e)Kc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&qs)for(var r of qs(e))t.indexOf(r)<0&&Vc.call(e,r)&&(n[r]=e[r]);return n},Yn=e=>{var t;return[,,,up((t=e?.[Xc("metadata")])!=null?t:null)]},Qc=["class","method","getter","setter","accessor","field","value","get","set"],gr=e=>e!==void 0&&typeof e!="function"?Xn("Function expected"):e,gp=(e,t,n,r,s)=>({kind:Qc[e],name:t,metadata:r,addInitializer:o=>n._?Xn("Already initialized"):s.push(gr(o||null))}),pn=(e,t)=>di(t,Xc("metadata"),e[3]),ee=(e,t,n,r)=>{for(var s=0,o=e[t>>1],i=o&&o.length;s<i;s++)t&1?o[s].call(n):r=o[s].call(n,r);return r},de=(e,t,n,r,s,o)=>{var i,a,l,u,c,d=t&7,f=!!(t&8),h=!!(t&16),y=d>3?e.length+1:d?f?1:2:0,g=Qc[d+5],w=d>3&&(e[y-1]=[]),x=e[y]||(e[y]=[]),p=d&&(!h&&!f&&(s=s.prototype),d<5&&(d>3||!h)&&hp(d<4?s:{get[n](){return Fe(this,o)},set[n](_){return ut(this,o,_)}},n));d?h&&d<4&&cl(o,(d>2?"set ":d>1?"get ":"")+n):cl(s,n);for(var v=r.length-1;v>=0;v--)u=gp(d,n,l={},e[3],x),d&&(u.static=f,u.private=h,c=u.access={has:h?_=>mp(s,_):_=>n in _},d^3&&(c.get=h?_=>(d^1?Fe:Zc)(_,s,d^4?o:p.get):_=>_[n]),d>2&&(c.set=h?(_,b)=>ut(_,s,b,d^4?o:p.set):(_,b)=>_[n]=b)),a=(0,r[v])(d?d<4?h?o:p[g]:d>4?void 0:{get:p.get,set:p.set}:s,u),l._=1,d^4||a===void 0?gr(a)&&(d>4?w.unshift(a):d?h?o=a:p[g]=a:s=a):typeof a!="object"||a===null?Xn("Object expected"):(gr(i=a.get)&&(p.get=i),gr(i=a.set)&&(p.set=i),gr(i=a.init)&&w.unshift(i));return d||pn(e,s),p&&Ui(s,n,p),h?d^4?o:p:s},Xi=(e,t,n)=>t.has(e)||Xn("Cannot "+n),mp=(e,t)=>Object(t)!==t?Xn('Cannot use the "in" operator on this value'):e.has(t),Fe=(e,t,n)=>(Xi(e,t,"read from private field"),n?n.call(e):t.get(e)),pe=(e,t,n)=>t.has(e)?Xn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ut=(e,t,n,r)=>(Xi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Zc=(e,t,n)=>(Xi(e,t,"access private method"),n);function Jc(e,t){return{plugin:e,options:t}}function es(e){return t=>Jc(e,t)}function zr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var ed,Gr,Yi,ks;ed=[le];var et=class{constructor(e,t){this.manager=e,this.options=t,pe(this,Yi,ee(Gr,8,this,!1)),ee(Gr,11,this),pe(this,ks,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return ae(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=yt(e.bind(this));return Fe(this,ks).add(t),t}destroy(){Fe(this,ks).forEach(e=>e())}static configure(e){return Jc(this,e)}};Gr=Yn(null);Yi=new WeakMap;ks=new WeakMap;de(Gr,4,"disabled",ed,et,Yi);pn(Gr,et);var ts=class extends et{},Ss,Io=class{constructor(e){this.manager=e,this.instances=new Map,pe(this,Ss,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(zr).reduce((r,s)=>{const o=r.find(({plugin:i})=>i===s.plugin);return o?(o.options=s.options,r):[...r,s]},[]),n=t.map(({plugin:r})=>r);for(const r of Fe(this,Ss))if(!n.includes(r)){if(r.prototype instanceof ts)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);ut(this,Ss,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()}};Ss=new WeakMap;function vp(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var ds=[],Sn,$n,yp=class extends et{constructor(e){super(e),pe(this,Sn),pe(this,$n),this.computeCollisions=this.computeCollisions.bind(this),ut(this,$n,qn(ds)),this.destroy=Zr(()=>{const t=this.computeCollisions(),n=ae(()=>this.manager.dragOperation.position.current);if(t!==ds){const r=Fe(this,Sn);if(ut(this,Sn,n),r&&n.x==r.x&&n.y==r.y)return}else ut(this,Sn,void 0);Fe(this,$n).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){ae(()=>{e?Fe(this,$n).value=this.computeCollisions():ut(this,Sn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:o,status:i}=r;if(!i.initialized||!o)return ds;const a=[],l=[];for(const u of e??n.droppables){if(u.disabled||s&&!u.accepts(s))continue;const c=t??u.collisionDetector;if(!c)continue;l.push(u),u.shape;const d=ae(()=>c({droppable:u,dragOperation:r}));d&&(u.collisionPriority!=null&&(d.priority=u.collisionPriority),a.push(d))}return l.length===0?ds:(a.sort(vp),a)}get collisions(){return Fe(this,$n).value}};Sn=new WeakMap;$n=new WeakMap;var td,nd,rd,Qi,sd,_t,Zi,Dn,Ji,ea;rd=[le],nd=[le],td=[le];var At=class en{constructor(t,n){pe(this,Zi,ee(_t,8,this)),ee(_t,11,this),pe(this,Dn),pe(this,Ji,ee(_t,12,this)),ee(_t,15,this),pe(this,ea,ee(_t,16,this)),ee(_t,19,this);const{effects:r,id:s,data:o={},disabled:i=!1,register:a=!0}=t;let l=s;ut(this,Dn,qn(s)),this.manager=n,this.data=o,this.disabled=i,this.effects=()=>{var u;return[()=>{const{id:c,manager:d}=this;if(c!==l)return l=c,d?.registry.register(this),()=>d?.registry.unregister(this)},...(u=r?.())!=null?u:[]]},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=Fe(this,Dn).value;return(n=(t=en.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const s=(r=(n=en.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Fe(this,Dn).peek();t!==s&&(en.pendingIdChanges||(en.pendingIdChanges=new Map,queueMicrotask(()=>{var o;return Zc(o=en,Qi,sd).call(o)})),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)}};_t=Yn(null);Qi=new WeakSet;sd=function(){const e=At.pendingIdChanges;At.pendingIdChanges=null,e&&Re(()=>{for(const[t,n]of e)Fe(t,Dn).value=n})};Zi=new WeakMap;Dn=new WeakMap;Ji=new WeakMap;ea=new WeakMap;de(_t,4,"manager",rd,At,Zi);de(_t,4,"data",nd,At,Ji);de(_t,4,"disabled",td,At,ea);pe(At,Qi);pn(_t,At);At.pendingIdChanges=null;var po=At,dl=class{constructor(){this.map=qn(new Map),this.cleanupFunctions=new WeakMap,this.register=(e,t)=>{const n=this.map.peek(),r=n.get(e),s=()=>this.unregister(e,t);if(r===t)return s;if(r&&r.id===e){const a=this.cleanupFunctions.get(r);a?.(),this.cleanupFunctions.delete(r)}const o=new Map(n);for(const[a,l]of n)if(l===t&&a!==e){o.delete(a);break}o.set(e,t),this.map.value=o;const i=Zr(...t.effects());return this.cleanupFunctions.set(t,i),s},this.unregister=(e,t)=>{const n=this.map.peek();if(n.get(e)!==t)return;const r=this.cleanupFunctions.get(t);r?.(),this.cleanupFunctions.delete(t);const s=new Map(n);s.delete(e),this.map.value=s}}[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){const t=this.cleanupFunctions.get(e);t?.(),e.destroy()}this.map.value=new Map}},od,id,ad,ld,cd,dd,ui,rt,ta,na,ra,Ot=class extends(ui=po,dd=[le],cd=[le],ld=[le],ad=[We],id=[We],od=[We],ui){constructor(t,n){var r=t,{modifiers:s,type:o,sensors:i,plugins:a,effects:l}=r,u=Yc(r,["modifiers","type","sensors","plugins","effects"]);super(Vi(Ki({},u),{effects:()=>{var c;return[...(c=l?.())!=null?c:[],()=>{const{manager:d,plugins:f}=this;if(!(!d||!f))for(const h of f){const{plugin:y}=zr(h);d.registry.plugins.register(y)}}]}}),n),ee(rt,5,this),pe(this,ta,ee(rt,8,this)),ee(rt,11,this),pe(this,na,ee(rt,12,this)),ee(rt,15,this),pe(this,ra,ee(rt,16,this,this.isDragSource?"dragging":"idle")),ee(rt,19,this),this.type=o,this.sensors=i,this.modifiers=s,this.alignment=u.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=zr(n);if(r.plugin===t)return r.options}}get isDropping(){return this.status==="dropping"&&this.isDragSource}get isDragging(){return this.status==="dragging"&&this.isDragSource}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}};rt=Yn(ui);ta=new WeakMap;na=new WeakMap;ra=new WeakMap;de(rt,4,"type",dd,Ot,ta);de(rt,4,"modifiers",cd,Ot,na);de(rt,4,"status",ld,Ot,ra);de(rt,2,"isDropping",ad,Ot);de(rt,2,"isDragging",id,Ot);de(rt,2,"isDragSource",od,Ot);pn(rt,Ot);var ud,fd,hd,pd,gd,md,fi,Ke,sa,oa,ia,aa,la,Mt=class extends(fi=po,md=[le],gd=[le],pd=[le],hd=[le],fd=[le],ud=[We],fi){constructor(t,n){var r=t,{accept:s,collisionDetector:o,collisionPriority:i,type:a}=r,l=Yc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),ee(Ke,5,this),pe(this,sa,ee(Ke,8,this)),ee(Ke,11,this),pe(this,oa,ee(Ke,12,this)),ee(Ke,15,this),pe(this,ia,ee(Ke,16,this)),ee(Ke,19,this),pe(this,aa,ee(Ke,20,this)),ee(Ke,23,this),pe(this,la,ee(Ke,24,this)),ee(Ke,27,this),this.accept=s,this.collisionDetector=o,this.collisionPriority=i,this.type=a}accepts(t){const{accept:n}=this;return n?typeof n=="function"?n(t):t.type?Array.isArray(n)?n.includes(t.type):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}};Ke=Yn(fi);sa=new WeakMap;oa=new WeakMap;ia=new WeakMap;aa=new WeakMap;la=new WeakMap;de(Ke,4,"accept",md,Mt,sa);de(Ke,4,"type",gd,Mt,oa);de(Ke,4,"collisionDetector",pd,Mt,ia);de(Ke,4,"collisionPriority",hd,Mt,aa);de(Ke,4,"shape",fd,Mt,la);de(Ke,2,"isDropTarget",ud,Mt);pn(Ke,Mt);var xp=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 s of r)s(...t)}},bp=class extends xp{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function $s(e,t=!0){let n=!1;return Vi(Ki({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var wp=class extends ts{constructor(e){super(e);const t=(r,s)=>r.map(({id:o})=>o).join("")===s.map(({id:o})=>o).join("");let n=[];this.destroy=Zr(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:o}=r;if(r.isDisabled()||po.pendingIdChanges)return;const i=$s({collisions:o});if(s.dispatch("collision",i),i.defaultPrevented||t(o,n))return;n=o;const[a]=o;ae(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},Qn=(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))(Qn||{}),Zn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Zn||{}),vd,yd,xd,bd,wd,_d,kd,vt,ca;kd=[le],_d=[We],wd=[We],bd=[We],xd=[We],yd=[We],vd=[We];var Bt=class{constructor(){ee(vt,5,this),pe(this,ca,ee(vt,8,this,"idle")),ee(vt,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}};vt=Yn(null);ca=new WeakMap;de(vt,4,"value",kd,Bt,ca);de(vt,2,"current",_d,Bt);de(vt,2,"idle",wd,Bt);de(vt,2,"initializing",bd,Bt);de(vt,2,"initialized",xd,Bt);de(vt,2,"dragging",yd,Bt);de(vt,2,"dropped",vd,Bt);pn(vt,Bt);var _p=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=$s({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 r=new AbortController,{event:s,coordinates:o}=e;Re(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(o)});const i=$s({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",i),i.defaultPrevented?(t.reset(),r.abort(),r):(t.status.set("initializing"),t.controller=r,this.manager.renderer.rendering.then(()=>{if(r.signal.aborted)return;const{status:a}=t;a.current==="initializing"&&Re(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return ae(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:o}=r;if(!s.dragging||!o||o.signal.aborted)return;const i=$s({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",i),queueMicrotask(()=>{var a,l,u,c,d;if(i.defaultPrevented)return;const f=(d=e.to)!=null?d:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((c=(u=e.by)==null?void 0:u.y)!=null?c:0)};r.position.current=f})})}stop(e={}){return ae(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let o;const i=()=>{const l={resume:()=>{},abort:()=>{}};return o=new Promise((u,c)=>{l.resume=u,l.abort=c}),l};s.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=ae(()=>{var c;return((c=r.source)==null?void 0:c.status)==="dropping"}),u=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:c}=r,d=yt(()=>{c?.status==="idle"&&(d(),u())})}else this.manager.renderer.rendering.then(u)})};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:i}),o?o.then(a).catch(()=>r.reset()):a()})}},Bn=class extends et{constructor(e,t){super(e,t),this.manager=e,this.options=t}},kp=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)}},Ts,Sd=class{constructor(e){this.options=e,pe(this,Ts)}set controller(e){ut(this,Ts,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Fe(this,Ts))==null||t.activate(e)}};Ts=new WeakMap;var ul=class extends et{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},Sp=class{constructor(e){this.draggables=new dl,this.droppables=new dl,this.plugins=new Io(e),this.sensors=new Io(e),this.modifiers=new Io(e)}register(e,t){if(e instanceof Ot)return this.draggables.register(e.id,e);if(e instanceof Mt)return this.droppables.register(e.id,e);if(e.prototype instanceof ul)return this.modifiers.register(e,t);if(e.prototype instanceof Bn)return this.sensors.register(e,t);if(e.prototype instanceof et)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof po)return e instanceof Ot?this.draggables.unregister(e.id,e):e instanceof Mt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof ul)return this.modifiers.unregister(e);if(e.prototype instanceof Bn)return this.sensors.unregister(e);if(e.prototype instanceof et)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()}},$d,Td,Ed,Cd,Od,Md,Id,Dd,Pd,mr,Es,Tn,je,da,ua,fa,ha,pa,vr;Pd=[We],Dd=[le],Id=[le],Md=[le],Od=[le],Cd=[le],Ed=[We],Td=[We],$d=[We];var $t=class{constructor(e){ee(je,5,this),pe(this,mr),pe(this,Es),pe(this,Tn,new hn(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new Bt,pe(this,da,ee(je,8,this,!1)),ee(je,11,this),pe(this,ua,ee(je,12,this,null)),ee(je,15,this),pe(this,fa,ee(je,16,this,null)),ee(je,19,this),pe(this,ha,ee(je,20,this,null)),ee(je,23,this),pe(this,pa,ee(je,24,this,[])),ee(je,27,this),this.position=new ho({x:0,y:0}),pe(this,vr,{x:0,y:0}),ut(this,mr,e)}get shape(){const{current:e,initial:t,previous:n}=Fe(this,Tn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Fe(this,Tn).current=e:Fe(this,Tn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Fe(this,mr).registry.draggables.get(t);return n&&ut(this,Es,n),(e=n??Fe(this,Es))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Fe(this,mr).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(Vi(Ki({},this.snapshot()),{transform:n}));return ut(this,vr,n),n}snapshot(){return ae(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Fe(this,vr),shape:this.shape?Mo(this.shape):null,position:Mo(this.position),status:Mo(this.status),canceled:this.canceled}))}reset(){Re(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Fe(this,Tn).reset(),this.position.reset({x:0,y:0}),ut(this,vr,{x:0,y:0}),this.modifiers=[]})}};je=Yn(null);mr=new WeakMap;Es=new WeakMap;Tn=new WeakMap;da=new WeakMap;ua=new WeakMap;fa=new WeakMap;ha=new WeakMap;pa=new WeakMap;vr=new WeakMap;de(je,2,"shape",Pd,$t);de(je,4,"canceled",Dd,$t,da);de(je,4,"activatorEvent",Id,$t,ua);de(je,4,"sourceIdentifier",Md,$t,fa);de(je,4,"targetIdentifier",Od,$t,ha);de(je,4,"modifiers",Cd,$t,pa);de(je,2,"source",Ed,$t);de(je,2,"target",Td,$t);de(je,2,"transform",$d,$t);pn(je,$t);var $p={get rendering(){return Promise.resolve()}};function St(e,t){return typeof e=="function"?e(t):e??t}var Tp=class{constructor(t){this.destroy=()=>{this.dragOperation.status.idle||this.actions.stop({canceled:!0}),this.dragOperation.modifiers.forEach(f=>f.destroy()),this.registry.destroy(),this.collisionObserver.destroy()};var n;const r=t??{},s=St(r.plugins,[]),o=St(r.sensors,[]),i=St(r.modifiers,[]),a=(n=r.renderer)!=null?n:$p,l=new bp(this),u=new Sp(this);this.registry=u,this.monitor=l,this.renderer=a,this.actions=new _p(this),this.dragOperation=new $t(this),this.collisionObserver=new yp(this),this.plugins=[wp,...s],this.modifiers=i,this.sensors=o;const{destroy:c}=this,d=Zr(()=>{var f,h,y;const g=ae(()=>this.dragOperation.modifiers),w=this.modifiers;for(const x of g)w.includes(x)||x.destroy();this.dragOperation.modifiers=(y=(h=(f=this.dragOperation.source)==null?void 0:f.modifiers)==null?void 0:h.map(x=>{const{plugin:p,options:v}=zr(x);return new p(this,v)}))!=null?y:w});this.destroy=()=>{d(),c()}}get plugins(){return this.registry.plugins.values}set plugins(t){this.registry.plugins.values=t}get modifiers(){return this.registry.modifiers.values}set modifiers(t){this.registry.modifiers.values=t}get sensors(){return this.registry.sensors.values}set sensors(t){this.registry.sensors.values=t}},jd=e=>{throw TypeError(e)},ga=(e,t,n)=>t.has(e)||jd("Cannot "+n),J=(e,t,n)=>(ga(e,t,"read from private field"),t.get(e)),at=(e,t,n)=>t.has(e)?jd("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ct=(e,t,n,r)=>(ga(e,t,"write to private field"),t.set(e,n),n),Rd=(e,t,n)=>(ga(e,t,"access private method"),n);function go(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function Ad(e,t){const n=e.getAnimations();let r=null;for(const s of n){if(s.playState!=="running")continue;const{effect:o}=s,a=(go(o)?o.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],s])}return r}function mo(e){const{width:t,height:n,top:r,left:s,bottom:o,right:i}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:s,bottom:o,right:i}}function ma(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function ns(e){return"nodeType"in e}function ft(e){var t,n,r;return e?ma(e)?e:ns(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 va(e){const{Document:t}=ft(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function Kt(e){return!e||ma(e)?!1:e instanceof ft(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function Ld(e){return e instanceof ft(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function Jn(e){return e?ma(e)?e.document:ns(e)?va(e)?e:Kt(e)||Ld(e)?e.ownerDocument:document:document:document}function Ep(e){var t,n,r,s;const{documentElement:o}=Jn(e),i=ft(e).visualViewport,a=(t=i?.width)!=null?t:o.clientWidth,l=(n=i?.height)!=null?n:o.clientHeight,u=(r=i?.offsetTop)!=null?r:0,c=(s=i?.offsetLeft)!=null?s:0;return{top:u,left:c,right:c+a,bottom:u+l,width:a,height:l}}function Cp(e,t){if(Op(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function Op(e){return e.tagName==="DETAILS"}function Hr(e,t=e.getBoundingClientRect(),n=0){var r,s,o,i,a;let l=t;const{ownerDocument:u}=e,c=(r=u.defaultView)!=null?r:window;let d=e.parentElement;for(;d&&d!==u.documentElement;){if(!Cp(d)){const v=d.getBoundingClientRect(),_=n*(v.bottom-v.top),b=n*(v.right-v.left),E=n*(v.bottom-v.top),T=n*(v.right-v.left);l={top:Math.max(l.top,v.top-_),right:Math.min(l.right,v.right+b),bottom:Math.min(l.bottom,v.bottom+E),left:Math.max(l.left,v.left-T),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}d=d.parentElement}const f=c.visualViewport,h=(s=f?.offsetTop)!=null?s:0,y=(o=f?.offsetLeft)!=null?o:0,g=(i=f?.width)!=null?i:c.innerWidth,w=(a=f?.height)!=null?a:c.innerHeight,x=n*w,p=n*g;return l={top:Math.max(l.top,h-x),right:Math.min(l.right,y+g+p),bottom:Math.min(l.bottom,h+w+x),left:Math.max(l.left,y-p),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top,l.width<0&&(l.width=0),l.height<0&&(l.height=0),l}function Fn(e){return{x:e.clientX,y:e.clientY}}var Bd=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function hi(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 s=r.contentDocument;s&&!t.has(s)&&n.push(...hi(s,t))}catch{}try{const r=e.defaultView;if(r&&r!==window.top){const s=r.parent;s&&s.document&&s.document!==e&&n.push(...hi(s.document,t))}}catch{}return n}function ya(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Fd(){var e,t;const n=ya()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function xa(e){return!e||!ns(e)?!1:e instanceof ft(e).ShadowRoot}function Us(e){if(e&&ns(e)){let t=e.getRootNode();if(xa(t))return t;if(t instanceof Document)return t}return Jn(e)}function ba(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function Mp(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((o,i)=>{const a=r[i];if(fl(o)&&fl(a)&&(o.type!=="file"&&(o.value=a.value),o.type==="radio"&&o.name&&(o.name=`Cloned__${o.name}`)),hl(o)&&hl(a)&&a.width>0&&a.height>0){const l=o.getContext("2d");l?.drawImage(a,0,0)}}),n}function fl(e){return"value"in e}function hl(e){return e.tagName==="CANVAS"}function Wd(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(Ip(r)){const{contentDocument:s}=r;if(s){const{left:o,top:i}=r.getBoundingClientRect();return Wd(s,{x:t-o,y:n-i})}}return r}function Ip(e){return e?.tagName==="IFRAME"}var pi=new WeakMap;function Dp(e){return e.closest(`
2
2
  input:not([disabled]),
3
3
  select:not([disabled]),
4
4
  textarea:not([disabled]),
@@ -1,9 +1,9 @@
1
1
  import { jsx as _, jsxs as L, Fragment as Fe } from "react/jsx-runtime";
2
- import { M as lp, h as cp, i as di, P as Oa, j as Wi, G as bt, k as ui, n as wt, o as at, r as lt, p as gn, C as zi, E as Ca, q as Ni, A as $o, S as dp, s as up, t as Da, V as fp, u as hp, v as pp, w as gp, x as mp, y as vp, z as yp, B as bp, F as dd, H as wp, I as xp, J as dn, U as _p, K as On, L as kp, l as ud, N as Ma, O as Sp, Q as $p, W as Nn, X as jl, Y as es, Z as nr, _ as fd, $ as Ep, a0 as Tp, a1 as hd, a2 as Hl, a3 as to, a4 as pd, a5 as Op, a6 as Cp, a7 as gd, a8 as Dp, a9 as Mp, aa as _s, ab as ks, ac as Ip, ad as Ss, ae as Ap, af as md, ag as Pp, ah as Rp, ai as Lp, aj as Wp, ak as zp, al as rn, am as Np, an as $s, ao as Fp, ap as Bp, aq as jp, ar as vd, as as Hp, at as Gp, au as qp, av as Up, aw as Kp, ax as Vp, ay as Yp, az as Xp, aA as Qp, aB as Ia, aC as Zp, aD as Jp, aE as eg, aF as tg, aG as ng, aH as rg, aI as Es, aJ as Gl, aK as og, aL as ig, aM as sg, aN as ag, aO as lg, aP as cg, aQ as dg, aR as yd, aS as bd, aT as wd, aU as ug, aV as xd, aW as fg, aX as hg, aY as pg, aZ as gg, a_ as mg, a$ as vg, b0 as yg, b1 as bg, b2 as wg, b3 as xg, b4 as _g, b5 as kg, b6 as Sg, b7 as $g, b8 as Eg } from "../useCompiledDocument-BuX3gIP-.es.js";
3
- import { b9 as g_, ba as m_, bb as v_, bc as y_, bd as b_, be as w_, bf as x_, bg as __, bh as k_, bi as S_, bj as $_ } from "../useCompiledDocument-BuX3gIP-.es.js";
2
+ import { M as lp, h as cp, i as di, P as Oa, j as Wi, G as bt, k as ui, n as wt, o as at, r as lt, p as gn, C as zi, E as Ca, q as Ni, A as $o, S as dp, s as up, t as Da, V as fp, u as hp, v as pp, w as gp, x as mp, y as vp, z as yp, B as bp, F as dd, H as wp, I as xp, J as dn, U as _p, K as On, L as kp, l as ud, N as Ma, O as Sp, Q as $p, W as Nn, X as jl, Y as es, Z as nr, _ as fd, $ as Ep, a0 as Tp, a1 as hd, a2 as Hl, a3 as to, a4 as pd, a5 as Op, a6 as Cp, a7 as gd, a8 as Dp, a9 as Mp, aa as _s, ab as ks, ac as Ip, ad as Ss, ae as Ap, af as md, ag as Pp, ah as Rp, ai as Lp, aj as Wp, ak as zp, al as rn, am as Np, an as $s, ao as Fp, ap as Bp, aq as jp, ar as vd, as as Hp, at as Gp, au as qp, av as Up, aw as Kp, ax as Vp, ay as Yp, az as Xp, aA as Qp, aB as Ia, aC as Zp, aD as Jp, aE as eg, aF as tg, aG as ng, aH as rg, aI as Es, aJ as Gl, aK as og, aL as ig, aM as sg, aN as ag, aO as lg, aP as cg, aQ as dg, aR as yd, aS as bd, aT as wd, aU as ug, aV as xd, aW as fg, aX as hg, aY as pg, aZ as gg, a_ as mg, a$ as vg, b0 as yg, b1 as bg, b2 as wg, b3 as xg, b4 as _g, b5 as kg, b6 as Sg, b7 as $g, b8 as Eg } from "../useCompiledDocument-BNtiFhPK.es.js";
3
+ import { b9 as g_, ba as m_, bb as v_, bc as y_, bd as b_, be as w_, bf as x_, bg as __, bh as k_, bi as S_, bj as $_ } from "../useCompiledDocument-BNtiFhPK.es.js";
4
4
  import { Tooltip as Lt, ButtonBase as _d, Box as H, Menu as rr, MenuItem as it, Stack as yt, Button as Ne, Divider as lr, IconButton as Dn, Typography as we, TextField as on, ToggleButtonGroup as kd, ToggleButton as Ts, Switch as Tg, Checkbox as Os, ListItemText as Kt, Collapse as Og, Autocomplete as Cg, ListItemIcon as Sd, InputBase as $d, SvgIcon as Dg, useMediaQuery as Ed, Alert as vt } from "@mui/material";
5
5
  import { useState as j, useRef as q, useEffect as re, useMemo as V, createElement as Mg, useLayoutEffect as fi, useCallback as le, useInsertionEffect as Ig, createContext as Td, memo as Ag, forwardRef as Pg, startTransition as Rg, useImperativeHandle as Lg, useContext as Od, useId as Wg } from "react";
6
- import { br as Xe, bw as Aa, bs as Pa } from "../ServerProvider-D6tjQYPN.es.js";
6
+ import { br as Xe, bw as Aa, bs as Pa } from "../ServerProvider-BRGSDxay.es.js";
7
7
  import { i as Cs, a as Cd, m as zg, b as Ng, t as Fg, c as Dd, s as Bg, d as jg, e as Md, f as Ra, g as Hg, A as Gg, h as qg, r as Ug, j as Id, k as ql, l as La } from "../text-entry-YKJZbRPo.es.js";
8
8
  import { flushSync as Kg } from "react-dom";
9
9
  import { useQueries as Vg, useQueryClient as Yg } from "@tanstack/react-query";
@@ -1172,9 +1172,13 @@ export interface EntityField {
1172
1172
  */
1173
1173
  'annotations': Array<string>;
1174
1174
  /**
1175
- * The field\'s `#(doc)` text, when it has any.
1175
+ * The field\'s `#(doc)` text, when it has any. A dimension defined as exactly a one-hop join path (`region is account.region`) with no `#(doc)` of its own reports the joined field\'s, and names that path in `docInheritedFrom`.
1176
1176
  */
1177
1177
  'doc'?: string;
1178
+ /**
1179
+ * Present when `doc` is not the field\'s own: the one-hop join path whose `#(doc)` it reports, because the field is a dimension defined as exactly that path (or as exactly another such undocumented dimension of the source, `a_chain is a_res`) and has none of its own. Written in plain names, `join.field`, never backquoted, even for a join named by a reserved word (`source.region`). A `#(doc)` written on the dimension wins, and an expression over the path inherits nothing.
1180
+ */
1181
+ 'docInheritedFrom'?: string;
1178
1182
  'table': EntityTable;
1179
1183
  'join'?: EntityJoin;
1180
1184
  'indexFingerprint'?: IndexFingerprint;
@@ -3368,7 +3372,7 @@ export interface RefusedSource {
3368
3372
  */
3369
3373
  'tier': RefusedSourceTierEnum;
3370
3374
  /**
3371
- * The bounded refusal reason; `message` says the specifics. On every mechanism: `free_parameter`; a row-level gate the table could not keep, named by the gate\'s kind, `access_filter` for a row filter (`#(access_filter)`, any of the gates that refused it) and `authorize` for a lock (`#(authorize)`); `reads_given`, the one reason every mechanism gives for a stored result that would read a given, so its table would hold one caller\'s rows or could not be read per caller (a given in a `#@ persist` source\'s persisted query, in a field it declares, in a join\'s `on:` condition or in a source it joins that is not stored per caller; a persisted view or query whose result reads one; a rollup whose build reads one), with `message` naming where the given sits; `inherited_where_with_given` (a given-reading `where:` or dimension the declaration inherits from a source it is built from, in its own file or another, rather than writing it in its own declaration: only the declaration\'s own terms are re-applied over the stored table at read; move the `where:` onto the persisted source to serve it from a table); `given_where_over_unstored_field` (a given-reading `where:` of the declaration\'s own over a field its table does not store, so it cannot be re-applied over the table at read: a field the rollup\'s grain drops, which adding it to the grain fixes, or on `#(materialize)` a field that is not a stored dimension); `merge_key_scope_unresolved` (a `merge_key=` whose caller scope cannot be expressed over the stored table\'s own columns); `connection_cannot_hold_table` (a database build on a connection that cannot create tables; SQL Server today, whose connection reports `canPersist: false`: the same words as the serve verdict\'s reason for the same case); `needs_qualified_name` (a database table on BigQuery, where a table needs a dataset, whose `name=` names none: a `#@ persist` source, a persisted view or query, a `#(materialize)` source, or a rollup whose own `name=` and base\'s give no container; refused at plan, before any warehouse work); `storage_source_unsupported` (`storage=` on a source whose connection the build cannot pass through to a destination, e.g. the package\'s DuckDB sandbox; or a source that carries author SQL, an `.sql()` source, a `sql_*` expression or a file or URL read as a table, whose table would be built inside a catalog, which runs only SQL Malloy generated: a `storage=` source on a DuckLake connection, or a source of any tier on a connection configured `managed`); `table_name_collision` (under `PERSIST_COLLISION_ENFORCE=false`, a declaration whose `name=` puts it on one table with another, so neither is built; by default such a package does not load; a run also records it in its `metadata.refusedSources` for a source whose readable table name another source\'s table already takes in that run); `current_time` (the build reads the current time, `now`, or keeps rows older than a moving cut-off it cannot leave out, so its table would hold the rows as of the build; `now` in the source\'s own extend block is applied at every read and is admitted); `incremental_unsupported` (a valid incremental declaration this deployment\'s dialect or destination cannot honour); `upstream_unread` (a table its build reads could not be read from its warehouse\'s catalog when the package loaded, after retrying, and this process has no earlier reading of it, so its content address is not known: it is not built, no run builds it, and a host\'s instruction for it is refused, until a reload or a plan refresh reads the catalog and plans it at its address; the `*-not-built` warning names the table). `upstream_table_unusable` (a persisted source, view, named query or rollup that is built from its upstream\'s stored table, and never by recomputing the upstream from raw, in any build, when that table cannot be read where it is built: a database one over an upstream declared `storage=`, whose table lives in a storage destination a build in the warehouse cannot read; a `storage=` one over an upstream stored in another destination; or one over an upstream that declares a persisted table but is itself refused, or not planned, so it has none. `message` names the upstream and why. Terminal until the model changes; the declaration is answered live). A persisted view or named query: `materialization_off` (persisted named queries are built only with `PUBLISHER_MATERIALIZE` on), `multi_line_annotation` (its `#@` line spans more than one line), `build_name_collision` (its generated build source\'s name is one the model, or another persisted view, already takes), `run_target_unsupported` (its source is declared in another file, is not in the model\'s namespace, or cannot be read), `nested_result` (a result that nests, which its table cannot answer yet), `access_filter` or `authorize` (it reaches a row-level gate its stored result cannot keep, named by the gate\'s kind), `reads_given` (its result reads a given), `current_time` (its result reads `now`), `no_stored_columns` (it has no stage to store) and `generated_build_failed` (its build does not compile on its own). A `#(materialize)` source: `inherited_persist` (it inherits `#@ persist`, so it is already its base\'s table), `inline_unsupported` (an `inline=` join or pair-table layout the build cannot store), `no_stored_columns` (the source has no dimension to store), `needs_qualified_name` (as above), `time_zone` (the source sets its own time zone, which its stored columns cannot follow at read), and `generated_build_failed` (Publisher could not write or compile its generated build, a Publisher bug worth reporting). A rollup (`#(rollup)` or `#@ preaggregate`): `hidden_field` (a measure or grain dimension the published surface hides, which a rollup would publish), `access_filter` or `authorize` (a row-level gate a rollup cannot re-apply to its rows, named by the gate\'s kind as on every mechanism), `time_zone` (the source sets its own time zone, so no query reads the rollup), `unreadable_measure` (a measure definition outside what a rollup reads), `join_not_in_grain` (a measure that aggregates through a join its grain does not key, or through a fan-out join), `partial_name_collision` (a field already takes the name of the measure\'s stored partial), and `unreadable_grain` (a `storage=` rollup over a DuckDB source whose grain dimension is stored as a type no stored read declares, a BLOB, INTERVAL, MAP or JSON, so no query would read its table; database, it is built). Retained, no longer produced: `given` (replaced by the positional given reasons above), `given_in_persisted_query` (shipped in 0.14.0: a `#@ persist` source\'s persisted query, or a `#(materialize)` source, whose build reads a given; now `reads_given`, the one name every mechanism gives the case), `preaggregate_over_dynamic_source` (shipped in 0.14.0: a rollup over a caller-scoped source, now `reads_given`, `given_where_over_unstored_field` or `inherited_where_with_given`, as every mechanism names the same case), `dynamic_projection`, `dynamic_join` and `dynamic_joined_where` (a `storage=` `#@ persist` source\'s given in a field it declares, in a join\'s `on:` condition, or in a source it joins; now `reads_given`, whose `message` still names the position), `not_duckdb_portable` (a `storage=` table no column of which Malloy can type is now built, and its source is answered live), the three `partition_*` reasons (`partition=` is a retired key, which fails the publish and the load as `persist-retired-key` or `materialize-retired-key`), `env_reference` and `empty_storage` (invalid annotations, which fail the publish and the load, so no served package reports them; the plan keeps refusing such a source as a backstop, so a plan computed without the load\'s check can still carry one), and `rollup_name_collision` (a rollup\'s generated name digests its declaring source, so no two rollups share one). `read_only_dialect` (shipped in 0.14.0: now `connection_cannot_hold_table`). `public_surface_unknown` is raised by the build-time narrowing of a stored table to the source\'s public columns, never by a plan; it shares the enum with the eligibility metric.
3375
+ * The bounded refusal reason; `message` says the specifics. On every mechanism: `free_parameter`; a row-level gate the table could not keep, named by the gate\'s kind, `access_filter` for a row filter (`#(access_filter)`, any of the gates that refused it) and `authorize` for a lock (`#(authorize)`); `reads_given`, the one reason every mechanism gives for a stored result that would read a given, so its table would hold one caller\'s rows or could not be read per caller (a given in a `#@ persist` source\'s persisted query, in a field it declares, in a join\'s `on:` condition or in a source it joins that is not stored per caller; a persisted view or query whose result reads one; a rollup whose build reads one), with `message` naming where the given sits; `inherited_where_with_given` (a given-reading `where:` or dimension the declaration inherits from a source it is built from, in its own file or another, rather than writing it in its own declaration: only the declaration\'s own terms are re-applied over the stored table at read; move the `where:` onto the persisted source to serve it from a table); `given_where_over_unstored_field` (a given-reading `where:` of the declaration\'s own over a field its table does not store, so it cannot be re-applied over the table at read: a field the rollup\'s grain drops, which adding it to the grain fixes, or on `#(materialize)` a field that is not a stored dimension); `merge_key_scope_unresolved` (a `merge_key=` whose caller scope cannot be expressed over the stored table\'s own columns); `connection_cannot_hold_table` (a database build on a connection that cannot create tables; SQL Server today, whose connection reports `canPersist: false`: the same words as the serve verdict\'s reason for the same case); `needs_qualified_name` (a database table on BigQuery, where a table needs a dataset, whose `name=` names none: a `#@ persist` source, a persisted view or query, a `#(materialize)` source, or a rollup whose own `name=` and base\'s give no container; refused at plan, before any warehouse work); `storage_source_unsupported` (`storage=` on a source whose connection the build cannot pass through to a destination, e.g. the package\'s DuckDB sandbox; or a source that carries author SQL, an `.sql()` source, a `sql_*` expression or a file or URL read as a table, whose table would be built inside a catalog, which runs only SQL Malloy generated: a `storage=` source on a DuckLake connection, or a source of any tier on a connection configured `managed`); `table_name_collision` (under `PERSIST_COLLISION_ENFORCE=false`, a declaration whose `name=` puts it on one table with another, so neither is built; by default such a package does not load; a run also records it in its `metadata.refusedSources` for a source whose readable table name another source\'s table already takes in that run); `current_time` (the build reads the current time, `now`, or keeps rows older than a moving cut-off it cannot leave out, so its table would hold the rows as of the build; `now` in the source\'s own extend block is applied at every read and is admitted); `incremental_unsupported` (a valid incremental declaration this deployment\'s dialect or destination cannot honour); `upstream_unread` (a table its build reads could not be read from its warehouse\'s catalog when the package loaded, after retrying, and this process has no earlier reading of it, so its content address is not known: it is not built, no run builds it, and a host\'s instruction for it is refused, until a reload or a plan refresh reads the catalog and plans it at its address; the `*-not-built` warning names the table). `upstream_table_unusable` (a persisted source, view, named query or rollup that is built from its upstream\'s stored table, and never by recomputing the upstream from raw, in any build, when that table cannot be read where it is built: a database one over an upstream declared `storage=`, whose table lives in a storage destination a build in the warehouse cannot read; a `storage=` one over an upstream stored in another destination; or one over an upstream that declares a persisted table but is itself refused, or not planned, so it has none. `message` names the upstream and why. Terminal until the model changes; the declaration is answered live). `container_not_found` (a database table whose `name=` places it in a container its warehouse does not hold: a BigQuery dataset that does not exist in the project the `name=` names, else the connection\'s billing project, or one in another location than the connection declares; a Postgres, Snowflake or DuckDB schema that does not exist. Read once per connection and container when the package is planned; `message` names the container, and the location for a mismatch, and says to create it or change `name=`. A read that fails refuses nothing, and a build checks again before it writes anything. Planned again once a reload, or a plan refresh, finds the container; `storage=` declarations are never checked). A persisted view or named query: `materialization_off` (persisted named queries are built only with `PUBLISHER_MATERIALIZE` on), `multi_line_annotation` (its `#@` line spans more than one line), `build_name_collision` (its generated build source\'s name is one the model, or another persisted view, already takes), `run_target_unsupported` (its source is declared in another file, is not in the model\'s namespace, or cannot be read), `nested_result` (a result that nests, which its table cannot answer yet), `access_filter` or `authorize` (it reaches a row-level gate its stored result cannot keep, named by the gate\'s kind), `reads_given` (its result reads a given), `current_time` (its result reads `now`), `no_stored_columns` (it has no stage to store) and `generated_build_failed` (its build does not compile on its own). A `#(materialize)` source: `inherited_persist` (it inherits `#@ persist`, so it is already its base\'s table), `inline_unsupported` (an `inline=` join or pair-table layout the build cannot store), `no_stored_columns` (the source has no dimension to store), `needs_qualified_name` (as above), `time_zone` (the source sets its own time zone, which its stored columns cannot follow at read), and `generated_build_failed` (Publisher could not write or compile its generated build, a Publisher bug worth reporting). A rollup (`#(rollup)` or `#@ preaggregate`): `hidden_field` (a measure or grain dimension the published surface hides, which a rollup would publish), `access_filter` or `authorize` (a row-level gate a rollup cannot re-apply to its rows, named by the gate\'s kind as on every mechanism), `time_zone` (the source sets its own time zone, so no query reads the rollup), `unreadable_measure` (a measure definition outside what a rollup reads), `join_not_in_grain` (a measure that aggregates through a join its grain does not key, or through a fan-out join), `partial_name_collision` (a field already takes the name of the measure\'s stored partial), and `unreadable_grain` (a `storage=` rollup over a DuckDB source whose grain dimension is stored as a type no stored read declares, a BLOB, INTERVAL, MAP or JSON, so no query would read its table; database, it is built). Retained, no longer produced: `given` (replaced by the positional given reasons above), `given_in_persisted_query` (shipped in 0.14.0: a `#@ persist` source\'s persisted query, or a `#(materialize)` source, whose build reads a given; now `reads_given`, the one name every mechanism gives the case), `preaggregate_over_dynamic_source` (shipped in 0.14.0: a rollup over a caller-scoped source, now `reads_given`, `given_where_over_unstored_field` or `inherited_where_with_given`, as every mechanism names the same case), `dynamic_projection`, `dynamic_join` and `dynamic_joined_where` (a `storage=` `#@ persist` source\'s given in a field it declares, in a join\'s `on:` condition, or in a source it joins; now `reads_given`, whose `message` still names the position), `not_duckdb_portable` (a `storage=` table no column of which Malloy can type is now built, and its source is answered live), the three `partition_*` reasons (`partition=` is a retired key, which fails the publish and the load as `persist-retired-key` or `materialize-retired-key`), `env_reference` and `empty_storage` (invalid annotations, which fail the publish and the load, so no served package reports them; the plan keeps refusing such a source as a backstop, so a plan computed without the load\'s check can still carry one), and `rollup_name_collision` (a rollup\'s generated name digests its declaring source, so no two rollups share one). `read_only_dialect` (shipped in 0.14.0: now `connection_cannot_hold_table`). `public_surface_unknown` is raised by the build-time narrowing of a stored table to the source\'s public columns, never by a plan; it shares the enum with the eligibility metric.
3372
3376
  */
3373
3377
  'reason': RefusedSourceReasonEnum;
3374
3378
  /**
@@ -3441,6 +3445,7 @@ export declare const RefusedSourceReasonEnum: {
3441
3445
  readonly UnreadableGrain: "unreadable_grain";
3442
3446
  readonly UpstreamUnread: "upstream_unread";
3443
3447
  readonly UpstreamTableUnusable: "upstream_table_unusable";
3448
+ readonly ContainerNotFound: "container_not_found";
3444
3449
  };
3445
3450
  export type RefusedSourceReasonEnum = typeof RefusedSourceReasonEnum[keyof typeof RefusedSourceReasonEnum];
3446
3451
  /**