@malloy-publisher/sdk 0.9.8 → 0.9.9
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.
- package/dist/{RenderedResult-DZj-FnOJ.es.js → RenderedResult-BHuJpdSn.es.js} +2 -2
- package/dist/{RenderedResult-BrvrMDAP.cjs.js → RenderedResult-Bw7EQc42.cjs.js} +1 -1
- package/dist/ServerProvider-B0dUY8be.cjs.js +1 -0
- package/dist/{ServerProvider-B_bPAsu2.es.js → ServerProvider-CQy4jVYK.es.js} +1394 -1051
- package/dist/builder/index.cjs.js +1 -1
- package/dist/builder/index.es.js +3 -3
- package/dist/client/api.d.ts +412 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +125 -114
- package/dist/components/Package/ContentTypeIcon.d.ts +3 -3
- package/dist/index.cjs.js +9 -9
- package/dist/index.es.js +2112 -2063
- package/dist/{useCompiledDocument-x0B2RAH3.es.js → useCompiledDocument-1dgF5CC9.es.js} +2 -2
- package/dist/{useCompiledDocument-oocN5cGE.cjs.js → useCompiledDocument-BKyRnXmA.cjs.js} +2 -2
- package/package.json +1 -1
- package/src/components/Package/ContentTypeIcon.tsx +16 -3
- package/src/components/Package/Package.agents.spec.tsx +76 -0
- package/src/components/Package/Package.tsx +44 -1
- package/dist/ServerProvider-DuEOzwPc.cjs.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),O=require("../useCompiledDocument-oocN5cGE.cjs.js"),$=require("@mui/material"),k=require("react"),Be=require("../ServerProvider-DuEOzwPc.cjs.js"),ge=require("../text-entry-BJwltZiy.cjs.js"),nf=require("react-dom"),rf=require("@malloydata/malloy-tag"),ql=require("@tanstack/react-query"),sf={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function of(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this view's details":n==="unlisted"?"Not a view the catalog lists, so its shape is unknown":void 0,s=o=>{if(t!==o){if(o==="big_value")return e?.aggregateOnly===!0?void 0:r??"Needs a view with only totals (no group by)";if(o==="shape_map"||o==="segment_map")return e?.chart===o?void 0:r??"Needs a view that already carries a map chart"}};return[{value:"default",label:"From the view"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"].map(o=>{const a=s(o);return{value:o,label:sf[o],...a?{disabled:!0,reason:a}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Di({state:e,view:t,viewStatus:n,cellLabel:r,disabledReason:s,onOpen:i,onChange:o,variant:a="standard"}){const l=of(t,e,n),d=k.useId();return x.jsx($.TextField,{select:!0,size:"small",variant:a,label:"Viz type",value:e,disabled:s!==void 0,onChange:u=>{const c=u.target.value;l.find(f=>f.value===c)?.disabled||o(c)},helperText:s,FormHelperTextProps:{id:d},SelectProps:{...i?{onOpen:i}:{},renderValue:u=>l.find(c=>c.value===u)?.label??String(u),MenuProps:{MenuListProps:{disabledItemsFocusable:!0}},SelectDisplayProps:{"aria-label":`Viz type, ${r}`,"aria-labelledby":void 0,...s?{"aria-describedby":d}:{}}},sx:{minWidth:140},children:l.map(u=>x.jsx($.MenuItem,{value:u.value,disabled:u.value==="custom"||u.disabled===!0,children:x.jsx($.ListItemText,{primary:u.label,...u.reason?{secondary:u.reason}:{}})},u.value))})}function af({sources:e,source:t,view:n,onSource:r,onView:s}){const{theme:i}=Be.usePublisherTheme(),o=e.find(a=>a.name===t);return x.jsxs(x.Fragment,{children:[x.jsx($.TextField,{select:!0,size:"small",label:"Source",value:t,onChange:a=>r(a.target.value),inputProps:{"aria-label":"Source"},children:e.map(a=>x.jsxs($.MenuItem,{value:a.name,disabled:a.views.length===0,children:[a.name,a.views.length===0&&x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1},children:"declares no views"}),a.description&&x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:a.description})]},a.name))}),x.jsxs($.Box,{children:[x.jsx($.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),x.jsxs($.List,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:"min(280px, 30vh)",overflowY:"auto",border:i.border,borderRadius:1},children:[(o?.views??[]).map(a=>x.jsxs($.ListItemButton,{selected:n===a.name,onClick:()=>s(a.name),"aria-label":`View ${a.name}`,children:[x.jsx($.ListItemText,{primary:a.name,secondary:a.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),a.chart&&x.jsx($.Chip,{size:"small",variant:"outlined",label:a.chart.replace(/_chart$/,"")})]},a.name)),o&&o.views.length===0&&x.jsx($.Typography,{variant:"body2",sx:{p:1.5,color:i.tileTitle},children:"This source declares no views."})]})]})]})}function lf({open:e,document:t,catalog:n,columns:r,onClose:s,onAdd:i,onAddText:o}){const{theme:a}=Be.usePublisherTheme(),l=k.useMemo(()=>n?.sources??[],[n]),[d,u]=k.useState("query"),[c,f]=k.useState(""),[h,p]=k.useState(""),[m,b]=k.useState(""),[w,v]=k.useState("default"),[g,y]=k.useState(Math.ceil(r/2));k.useEffect(()=>{if(!e)return;u("query");const T=D=>l.some(q=>q.name===D&&q.views.length>0);f(t.sources.map(D=>D.base).find(T)??l.find(D=>D.views.length>0)?.name??""),p(""),b(""),v("default"),y(Math.ceil(r/2))},[e,t,l,r]);const _=c!==""&&h!=="",S=[c,h].filter(T=>T!==""&&!ge.isBareName(T)).map(T=>`"${T}" is not a plain Malloy name, so a tile cannot be written for it.`)[0],E=l.find(T=>T.name===c),A=E?.views.find(T=>T.name===h);return x.jsx(O.AppDialog,{open:e,onClose:s,title:"Add a tile",description:"A tile shows one view of a source in this package.",actions:x.jsxs(x.Fragment,{children:[x.jsx($.Button,{onClick:s,children:"Cancel"}),x.jsx($.Button,{variant:"contained",disabled:d==="query"&&(!_||S!==void 0),onClick:()=>d==="text"?o():i({base:c,modelPath:E?.modelPath??"",...E?.exporters?{exporters:E.exporters}:{},view:h,...m.trim()?{label:m.trim()}:{},...w!=="default"?{chart:w,...A?{chartCarried:A.chart?[A.chart]:[]}:{}}:{},colspan:g}),children:d==="text"?"Add text":"Add tile"})]}),children:x.jsxs($.Stack,{sx:{gap:2,pt:1},children:[x.jsxs($.ToggleButtonGroup,{size:"small",exclusive:!0,value:d,"aria-label":"Tile type",onChange:(T,D)=>{D!==null&&u(D)},children:[x.jsx($.ToggleButton,{value:"query",sx:{px:1.5},children:"Query"}),x.jsx($.ToggleButton,{value:"text",sx:{px:1.5},children:"Text"})]}),d==="text"?x.jsx($.Typography,{variant:"body2",sx:{color:a.tileTitle},children:"A text tile holds markdown: a heading, a paragraph, a list. It is added empty, and written on the tile itself."}):l.length===0?x.jsx($.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?"This package publishes no source with a view to put on a tile.":"The package's sources are still loading."}):x.jsxs(x.Fragment,{children:[x.jsx(af,{sources:l,source:c,view:h,onSource:T=>{f(T),p("")},onView:T=>{p(T),v("default")}}),S&&x.jsx($.Typography,{variant:"body2",color:"error",children:S}),x.jsx(Di,{state:w,view:A,cellLabel:"new tile",variant:"outlined",...A?{}:{disabledReason:"Pick a view to choose its chart."},onChange:T=>v(T)}),x.jsx($.Stack,{direction:"row",sx:{gap:1.5},children:x.jsx($.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:m,onChange:T=>b(T.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}})})]})]})})}const Re=e=>e.kind==="text",xe=e=>e.kind!=="text",Kr=e=>xe(e)?e.label??e.name:e.name,Fe=e=>Re(e)?`text.${e.name}`:`${e.source}.${e.name}`,ai="self";function cf({open:e,document:t,source:n,givenNames:r,dashboards:s,onClose:i,onApply:o}){const{theme:a}=Be.usePublisherTheme(),[l,d]=k.useState([]);k.useEffect(()=>{if(!e||!n)return;const p=(t.drills??[]).filter(m=>m.source===n.name);d((n.dimensions??[]).map(m=>{const b=p.find(w=>w.name===m.name);return{name:m.name,expression:m.expression,to:b?.to??[],given:b?.given??""}}))},[e,n,t]);const u=(p,m)=>d(b=>b.map((w,v)=>{if(v!==p)return w;const g={...w};return m(g),g})),c=[ai,...s.filter(p=>p!==ai)],f=p=>p===ai?"This report":p,h=()=>{n&&(o(l.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())};return x.jsx(O.AppDialog,{open:e,onClose:i,title:"Drill",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the report it opens.",actions:x.jsxs(x.Fragment,{children:[x.jsx($.Button,{onClick:i,children:"Cancel"}),x.jsx($.Button,{variant:"contained",onClick:h,disabled:l.length===0,children:"Apply"})]}),children:x.jsx($.Stack,{sx:{gap:2,pt:1},children:l.length===0?x.jsx($.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?x.jsxs(x.Fragment,{children:[x.jsx($.Box,{component:"code",children:n.name})," declares no dimensions of its own in this file. A drill 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"," ",x.jsx($.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((p,m)=>x.jsxs($.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[x.jsxs($.Box,{sx:{minWidth:0,pt:.75},children:[x.jsx($.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:p.name}),x.jsxs($.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:p.expression,children:["is ",p.expression]})]}),x.jsx($.TextField,{select:!0,size:"small",label:"Clicks go to",value:p.to,inputProps:{"aria-label":`Where ${p.name} goes`},SelectProps:{multiple:!0,renderValue:b=>b.length===0?"Not clickable":b.map(f).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:b=>u(m,w=>{const v=b.target.value;w.to=Array.isArray(v)?v:String(v).split(",").filter(Boolean)}),children:c.map(b=>x.jsxs($.MenuItem,{value:b,children:[x.jsx($.Checkbox,{size:"small",checked:p.to.includes(b),sx:{p:0,mr:1}}),x.jsx($.ListItemText,{primary:f(b)})]},b))}),x.jsxs($.TextField,{select:!0,size:"small",label:"Sets the filter",value:p.given,disabled:p.to.length===0,inputProps:{"aria-label":`Control ${p.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:p.given===""?`Named ${p.name}, like the dimension`:void 0,onChange:b=>u(m,w=>{w.given=b.target.value}),children:[x.jsx($.MenuItem,{value:"",children:x.jsx("em",{children:"Same name as the dimension"})}),r.map(b=>x.jsx($.MenuItem,{value:b,children:b},b))]})]},p.name))})})}function uf(e,t=[]){const n=new Map;for(const i of e.tiles)for(const o of xe(i)?i.filters??[]:[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],s=new Set;for(const i of e.localGivens??[])s.add(i.name),r.push({name:i.name,...i.label===void 0?{}:{label:i.label},type:i.type,...i.suggest?{field:i.suggest.dimension}:{},origin:"dashboard",local:i,boundTiles:n.get(i.name)??0});for(const i of t)s.has(i.name)||(s.add(i.name),r.push({...i,origin:"model",boundTiles:n.get(i.name)??0}));for(const[i,o]of n)s.has(i)||r.push({name:i,origin:"model",boundTiles:o});return r}function _s(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function df(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function as(e,t){const n=df(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 Ma(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 ff(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const hf=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function pf(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}`,i=ge.isStrictName(s)?s:`${s}_FILTER`,o=new Set(t);if(!o.has(i))return i;for(let a=2;;a++)if(!o.has(`${i}_${a}`))return`${i}_${a}`}const Pa=[{kind:"select",label:"Pick one",hint:"A dropdown of the field's values"},{kind:"multiselect",label:"Pick several",hint:"The same, taking more than one"},{kind:"text",label:"Text",hint:"A box taking Malloy filter syntax"},{kind:"number",label:"Number range",hint:"A slider over the field's values"},{kind:"date",label:"On or after a date",hint:"A date picker; tiles keep rows on or after it"}];function Vr(e){const t=e.label.trim()||e.name,n=e.field;switch(e.kind){case"select":case"multiselect":return{name:e.name,type:"filter<string>",default:"f''",label:t,control:e.kind,...e.source?{suggest:{source:e.source,dimension:n}}:{}};case"text":return{name:e.name,type:"filter<string>",default:"f''",label:t};case"number":return{name:e.name,type:"filter<number>",default:"f''",label:t,...e.range?{rangeMin:e.range.min,rangeMax:e.range.max}:{}};case"date":return{name:e.name,type:"date",default:`@${e.dateDefault??new Date().toISOString().slice(0,10)}`,label:t}}}const Ai=e=>xe(e)&&e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function gf(e,t){return e.tiles.map(n=>{const r=(xe(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}:_s(t.type)!==void 0?{op:_s(t.type)}:{}}})}function mf(e,t,n){n.forEach((r,s)=>{const i=e.tiles[s];if(!i||!Ai(i))return;const o=(i.filters??[]).filter(l=>l.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?i.filters=a:delete i.filters})}function vf(e,t){const n=(e.localGivens??[]).filter(i=>i.name!==t.name),r=(e.localGivens??[]).findIndex(i=>i.name===t.name),s=[...n];s.splice(r>=0?r:s.length,0,t),e.localGivens=s}function yf(e,t){for(const r of e.tiles){if(!xe(r))continue;const s=(r.filters??[]).filter(i=>i.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 Kl=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function bf({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:i}){const o=k.useRef(n);e&&(o.current=n);const a=e?n:o.current,l=a!==void 0,[d,u]=k.useState({kind:"new"}),[c,f]=k.useState(""),[h,p]=k.useState("select"),[m,b]=k.useState(""),[w,v]=k.useState(""),[g,y]=k.useState([]),[_,S]=k.useState(!1),[E,A]=k.useState(!1),T=j=>t.sources.find(F=>F.name===j.source)?.base??j.source;k.useEffect(()=>{if(e)if(A(n!==void 0),n){u({kind:"existing",name:n.name}),f(n.label??"");const j=gf(t,n);y(j);const F=j.filter(ue=>ue.include),re=new Set(F.map(ue=>ue.field));v(re.size===1?F[0].field:n.field??""),S(re.size>1)}else u({kind:"new"}),f(""),p("select"),v(""),b(new Date().toISOString().slice(0,10)),y(t.tiles.map(j=>({include:Ai(j),field:""}))),S(!1)},[e,n,t]);const D=k.useMemo(()=>[...(t.localGivens??[]).map(j=>j.name),...r.map(j=>j.name)],[t,r]),q=k.useMemo(()=>w.trim()?pf(w.trim(),D):"",[w,D]),P=d.kind==="existing"?n??r.find(j=>j.name===d.name):q?{name:q,type:Vr({name:q,label:c,kind:h,field:w}).type}:void 0,z=P?.type!==void 0&&!P.type.startsWith("filter<"),U=g.find(j=>j.include)?.op??_s(P?.type),K=(j,F)=>{A(!0),y(re=>re.map((ue,je)=>je===j?{...ue,...F}:ue))},Z=j=>{A(!0),y(F=>F.map(re=>({...re,op:j})))},J=j=>{const F=_s(j);y(re=>re.map(({op:ue,...je})=>F?{...je,op:F}:je))},ie=j=>{A(!0),u({kind:"existing",name:j.name}),v(j.field??""),J(j.type)},de=j=>{A(!0),p(j),J(Vr({name:"X",label:c,kind:j,field:w}).type)},I=t.tiles.map(Ai),V=I.filter(Boolean).length,B=g.filter((j,F)=>j.include&&I[F]).length,R=t.tiles.filter((j,F)=>(g[F]?.include??!1)&&I[F]&&xe(j)),G=R.length>0?R:t.tiles.filter((j,F)=>I[F]&&xe(j)),ne=k.useMemo(()=>{const j=new Map;let F=!1;for(const re of G){const ue=s?.(re);if(ue){F=!0;for(const je of ue)j.has(je.name)||j.set(je.name,je)}}return F?[...j.values()]:void 0},[g,t.tiles,s]),Y=(()=>{const j=w.trim();for(const F of R){const re=s?.(F);if(!re||re.some(ue=>ue.name===j))return T(F)}return R[0]?T(R[0]):t.sources[0]?.base})(),H=j=>{A(!0),y(F=>F.map((re,ue)=>({...re,include:j&&I[ue]})))},L=k.useMemo(()=>_?g:g.map(j=>({...j,field:w})),[_,g,w]),C=j=>{for(const F of G){const re=s?.(F)?.find(ue=>ue.name===j.trim());if(re?.type)return re.type}},W=j=>as(P?.type,j.type),M=(j,F)=>{if(j.trim()==="")return"Pick the field this filter compares.";const re=F?s?.(F):void 0;if(!re)return;const ue=re.find(je=>je.name===j.trim());if(!ue)return`Not a field of ${F?T(F):"the tiles' source"}.`;if(ue.type&&!as(P?.type,ue.type))return`${j.trim()} is ${Ma(ue.type)}; this filter compares ${Ma(P?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},ee=j=>{if(A(!0),v(j),l||d.kind!=="new")return;const F=C(j),re=Vr({name:"X",label:c,kind:h,field:j}).type;F&&!as(re,F)&&de(ff(F))},X=j=>{const F=t.tiles[j];return F&&xe(F)?F:void 0},le=L.map((j,F)=>j.include&&I[F]?M(j.field,X(F)):void 0),ce=le.every(j=>j===void 0),N=E?le:le.map(()=>{}),Q=E&&!_&&B>0?R.map(j=>M(w,j)).find(Boolean):void 0,me=P!==void 0&&ce&&(d.kind==="existing"||w.trim()!==""&&q!==""),se=()=>{if(!(!P||!me))if(d.kind==="new")i(P.name,L,Vr({name:P.name,label:c.trim()||Kl(P.name),kind:h,field:w.trim(),...Y?{source:Y}:{},...m?{dateDefault:m}:{}}));else if(n?.origin==="dashboard"&&n.local){const j=c.trim(),F=j!==(n.local.label??"");i(P.name,L,F?{...n.local,...j?{label:j}:{}}:void 0)}else i(P.name,L)},te=l&&a.origin==="model";return{editing:l,shown:a,fromModel:te,source:d,setSource:u,label:c,setLabel:f,kind:h,dateDefault:m,setDateDefault:b,field:w,rows:g,setRows:y,perTile:_,setPerTile:S,newName:q,target:P,valueTyped:z,commonOp:U,setRow:K,setCommonOp:Z,pickExisting:ie,pickKind:de,bindable:I,bindableCount:V,included:B,commonFields:ne,setAll:H,accepts:W,pickField:ee,rowProblems:N,commonProblem:Q,canApply:me,apply:se}}function Ra({value:e,onChange:t,fields:n,accepts:r,label:s,ariaLabel:i,error:o,helperText:a,disabled:l,autoFocus:d,placeholder:u,sx:c}){const f=k.useMemo(()=>(n??[]).filter(p=>r?.(p)??!0).map(p=>p.name),[n,r]),h=k.useMemo(()=>new Map((n??[]).map(p=>[p.name,p.type])),[n]);return x.jsx($.Autocomplete,{freeSolo:!0,size:"small",options:f,inputValue:e,onInputChange:(p,m)=>t(m),value:e,onChange:(p,m)=>t(typeof m=="string"?m:""),disabled:l,disableClearable:!0,renderOption:(p,m)=>k.createElement("li",{...p,key:m},x.jsx($.Typography,{variant:"body2",sx:{flex:1},children:m}),h.get(m)&&x.jsx($.Typography,{variant:"caption",sx:{opacity:.6},children:h.get(m)?.replace(/_type$/,"")})),renderInput:p=>x.jsx($.TextField,{...p,label:s,placeholder:u,autoFocus:d,error:o,helperText:a,inputProps:{...p.inputProps,"aria-label":i}}),sx:c})}const ja=e=>e&&xe(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:{label:"From the model",reason:"Declared on its source, which this report does not write."};function xf({open:e,document:t,control:n,available:r,fieldsFor:s,onClose:i,onApply:o,onRemove:a}){const{theme:l}=Be.usePublisherTheme(),{editing:d,shown:u,fromModel:c,source:f,setSource:h,label:p,setLabel:m,kind:b,dateDefault:w,setDateDefault:v,field:g,rows:y,setRows:_,perTile:S,setPerTile:E,newName:A,target:T,valueTyped:D,commonOp:q,setRow:P,setCommonOp:z,pickExisting:U,pickKind:K,bindable:Z,bindableCount:J,included:ie,commonFields:de,setAll:I,accepts:V,pickField:B,rowProblems:R,commonProblem:G,canApply:ne,apply:Y}=bf({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:o}),H=(L,C,W)=>x.jsx($.TextField,{select:!0,size:"small",label:"Compares",value:L??">=",onChange:M=>C(M.target.value),inputProps:{"aria-label":W},sx:{width:130},children:hf.filter(M=>M.op!=="~").map(M=>x.jsx($.MenuItem,{value:M.op,children:M.label},M.op))});return x.jsx(O.AppDialog,{open:e,onClose:i,title:d?u.label??u.name:"Add a filter",description:d?x.jsxs(x.Fragment,{children:[x.jsxs($.Box,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",u.name]}),c?" · 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:x.jsxs(x.Fragment,{children:[d&&x.jsx($.Button,{color:"error",startIcon:x.jsx(O.DeleteOutlineIcon,{}),onClick:()=>a(u.name),sx:L=>({mr:"auto",color:O.dangerTextColor(L)}),children:"Remove filter"}),x.jsx($.Button,{onClick:i,children:"Cancel"}),x.jsx($.Tooltip,{title:ne||T===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:x.jsx("span",{children:x.jsx($.Button,{variant:"contained",onClick:Y,disabled:!ne,children:d?"Apply":"Add filter"})})})]}),children:x.jsxs($.Stack,{sx:{gap:2.5,pt:1},children:[!d&&r.length>0&&x.jsxs($.ToggleButtonGroup,{exclusive:!0,size:"small",value:f.kind,onChange:(L,C)=>{C==="new"?h({kind:"new"}):C==="existing"&&r[0]&&U(r[0])},"aria-label":"Where the filter comes from",children:[x.jsx($.ToggleButton,{value:"new",children:"New in this report"}),x.jsx($.ToggleButton,{value:"existing",children:"From the model"})]}),!d&&f.kind==="existing"?x.jsx($.TextField,{select:!0,size:"small",label:"Filter",value:f.name,onChange:L=>{const C=r.find(W=>W.name===L.target.value);C&&U(C)},children:r.map(L=>x.jsxs($.MenuItem,{value:L.name,children:[L.label??L.name,x.jsxs($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",L.name]})]},L.name))}):null,x.jsxs($.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!S&&x.jsx(Ra,{value:g,onChange:B,fields:de,accepts:V,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!d,error:G!==void 0,helperText:G??(!d&&A?`Declared as $${A}`:void 0),sx:{flex:1,minWidth:200}}),!c&&x.jsx($.TextField,{size:"small",label:"Label",placeholder:A?Kl(A):"",value:p,onChange:L=>m(L.target.value),inputProps:{"aria-label":"Filter label"},sx:{flex:1,minWidth:160}}),D&&!S&&H(q,z,"Comparison")]}),!d&&f.kind==="new"&&x.jsxs($.Stack,{direction:"row",sx:{gap:1.5},children:[x.jsx($.TextField,{select:!0,size:"small",label:"Filter kind",value:b,onChange:L=>K(L.target.value),inputProps:{"aria-label":"Filter kind"},slotProps:{select:{renderValue:L=>Pa.find(C=>C.kind===L)?.label??String(L)}},sx:{flex:1},children:Pa.map(L=>x.jsxs($.MenuItem,{value:L.kind,children:[L.label,x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:L.hint})]},L.kind))}),b==="date"&&x.jsx($.TextField,{size:"small",type:"date",label:"Starts at",value:w,onChange:L=>v(L.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),x.jsxs($.Box,{children:[x.jsxs($.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[x.jsx($.Checkbox,{size:"small",checked:J>0&&ie===J,indeterminate:ie>0&&ie<J,disabled:J===0,onChange:L=>I(L.target.checked),inputProps:{"aria-label":"All tiles"}}),x.jsxs($.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",ie," of ",t.tiles.length," tiles"]}),x.jsx($.Button,{size:"small",onClick:()=>{S||_(L=>L.map(C=>({...C,field:g}))),E(L=>!L)},children:S?"Same field for all":"Adjust per tile"})]}),x.jsx($.Stack,{sx:{gap:S?1:0},children:t.tiles.map((L,C)=>{if(!xe(L))return null;const W=y[C],M=L.label??L.name,ee=S?R[C]:void 0;return x.jsxs($.Stack,{direction:"row",sx:{gap:1,alignItems:S?"flex-start":"center",opacity:Z[C]?1:.6},children:[x.jsx($.Checkbox,{size:"small",disabled:!Z[C],checked:(W?.include??!1)&&Z[C],inputProps:{"aria-label":`Filter ${M}`},onChange:X=>P(C,{include:X.target.checked})}),x.jsx($.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:S?1:0},noWrap:!0,children:M}),Z[C]?S&&x.jsxs(x.Fragment,{children:[D&&H(W?.op,X=>P(C,{op:X}),`Comparison for ${M}`),x.jsx(Ra,{value:W?.field??"",onChange:X=>P(C,{field:X}),fields:s?.(L),accepts:V,label:"Field",ariaLabel:`Field for ${M}`,disabled:!W?.include,error:ee!==void 0,helperText:ee,sx:{width:220}})]}):x.jsx($.Tooltip,{title:ja(t.tiles[C]).reason,children:x.jsx($.Typography,{variant:"caption",sx:{color:l.tileTitle},children:ja(t.tiles[C]).label})})]},`${L.source}.${L.name}`)})}),ie===0&&x.jsx($.Typography,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}const wf=O.createSvgIcon(x.jsx("path",{d:"M11.71 17.99C8.53 17.84 6 15.22 6 12c0-3.31 2.69-6 6-6 3.22 0 5.84 2.53 5.99 5.71l-2.1-.63C15.48 9.31 13.89 8 12 8c-2.21 0-4 1.79-4 4 0 1.89 1.31 3.48 3.08 3.89zM22 12c0 .3-.01.6-.04.9l-1.97-.59c.01-.1.01-.21.01-.31 0-4.42-3.58-8-8-8s-8 3.58-8 8 3.58 8 8 8c.1 0 .21 0 .31-.01l.59 1.97c-.3.03-.6.04-.9.04-5.52 0-10-4.48-10-10S6.48 2 12 2s10 4.48 10 10m-3.77 4.26L22 15l-10-3 3 10 1.26-3.77 4.27 4.27 1.98-1.98z"}));function Vl(e,t,n,r){const[s,i]=k.useState(void 0);return k.useEffect(()=>{t&&e!==void 0&&i(structuredClone(e))},[t,e]),{draft:s,patch:u=>i(c=>{if(c===void 0)return c;const f=structuredClone(c);return u(f),f}),apply:u=>{if(s===void 0)return;const c=structuredClone(s);u(c),i(c),JSON.stringify(c)!==JSON.stringify(e)&&n(c)},close:()=>{s!==void 0&&e!==void 0&&JSON.stringify(s)!==JSON.stringify(e)&&n(s),r()},discard:()=>i(void 0)}}const _f=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.`,kf="This tile's view is declared on its source, so its chart is set in the model.";function Sf({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:s,removeBlocked:i,onDrills:o,view:a}){const l=k.useId(),{theme:d}=Be.usePublisherTheme(),{draft:u,apply:c,close:f,discard:h}=Vl(t,e!==null,r,n),p=u!==void 0&&xe(u)?u:void 0,m=p!==void 0&&p.declaration.kind!=="inherited",b=g=>c(y=>{xe(y)&&g(y)}),w=k.useRef(void 0),v=e!==null;return k.useEffect(()=>{v&&(w.current=t&&xe(t)?t.chart:void 0)},[v]),x.jsx($.Popover,{open:e!==null&&u!==void 0,anchorEl:e,onClose:f,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:u&&x.jsxs($.Stack,{sx:{gap:1.5},children:[x.jsx($.Typography,{variant:"overline",sx:{color:d.tileTitle,lineHeight:1.5},children:p?`${p.source} → ${p.name}`:`Text · ${u.name}`}),p&&m&&x.jsx(x.Fragment,{children:x.jsx(Di,{state:p.chart??"default",view:a,cellLabel:`${p.source} ${p.name}`,...p.chart==="custom"?{disabledReason:_f(p.chartLines)}:{},onChange:g=>b(y=>{const _=w.current;g===(_??"default")?(_===void 0?delete y.chart:y.chart=_,delete y.chartCarried):(y.chart=g,a?y.chartCarried=a.chart?[a.chart]:[]:delete y.chartCarried)})})}),p&&!m&&x.jsxs(x.Fragment,{children:[x.jsx($.Typography,{variant:"body2",sx:{color:d.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),x.jsx(Di,{state:"default",view:a,cellLabel:`${p.source} ${p.name}`,disabledReason:kf,onChange:()=>{}})]}),p?.declaration.kind==="opaque"&&x.jsxs($.Typography,{variant:"body2",sx:{color:d.tileTitle},children:["Its body is ",p.declaration.why,", so a filter has no single place to go. Everything else here is editable."]}),x.jsxs($.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[m?x.jsx($.Button,{size:"small",startIcon:x.jsx(wf,{}),"aria-haspopup":"dialog",onClick:()=>{f(),o()},children:"Drill"}):x.jsx("span",{}),x.jsx($.Button,{color:"error",size:"small",startIcon:x.jsx(O.DeleteOutlineIcon,{}),"aria-disabled":i!==void 0||void 0,"aria-describedby":i!==void 0?l:void 0,disableRipple:i!==void 0,sx:g=>({color:O.dangerTextColor(g),...i!==void 0?{opacity:.5,cursor:"default"}:{}}),onClick:()=>{i===void 0&&(h(),s())},children:"Delete"})]}),i!==void 0&&x.jsx($.Typography,{id:l,variant:"caption",sx:{color:d.tileTitle},children:i})]})})}function $f({editor:e,catalog:t,columns:n,dashboards:r,bindings:s,tiles:i,drillSource:o,setDrillSource:a,confirmConversion:l,exitDialog:d}){const{filterDialog:u,setFilterDialog:c}=s,{menu:f,setMenu:h}=i,p=f===void 0?void 0:e.document.tiles[f.index],m=p&&xe(p)?p:void 0,b=(()=>{if(!m||!t)return;const w=e.document.sources.find(g=>g.name===m.source)?.base??m.source,v=m.declaration.kind==="reference"?m.declaration.from:m.name;return t.sources.find(g=>g.name===w)?.views.find(g=>g.name===v)})();return x.jsxs(x.Fragment,{children:[x.jsx(xf,{open:u!==void 0,document:e.document,...u?.control?{control:u.control}:{},available:s.available,...t?{fieldsFor:s.fieldsFor}:{},onClose:()=>c(void 0),onApply:s.applyFilter,onRemove:s.dropControl}),x.jsx(Sf,{anchor:f?.anchor??null,tile:f===void 0?void 0:e.document.tiles[f.index],onClose:()=>h(void 0),onCommit:w=>{const v=f?.index;v!==void 0&&e.update(g=>{g.tiles[v]=w})},onRemove:()=>{f!==void 0&&i.removeTile(f.index)},...e.document.tiles.length===1&&e.saved.tiles.length>0?{removeBlocked:"A saved report needs at least one tile."}:{},view:b,onDrills:()=>{a(m?.source)}}),x.jsx(cf,{open:o!==void 0,document:e.document,source:e.document.sources.find(w=>w.name===o),givenNames:s.controlList.map(w=>w.name),dashboards:r??[],onClose:()=>a(void 0),onApply:w=>e.update(v=>{const y=[...(v.drills??[]).filter(_=>_.source!==o),...w];y.length===0?delete v.drills:v.drills=y})}),x.jsx(O.AppDialog,{open:l!==void 0,onClose:()=>l?.stop(),title:"Convert this report?",description:"Saving rewrites this report in the tile layout. The builder cannot take that back; the file's history in your repository can.",actions:x.jsxs(x.Fragment,{children:[x.jsx($.Button,{onClick:()=>l?.stop(),children:"Cancel"}),x.jsx($.Button,{variant:"contained",onClick:()=>l?.go(),children:"Convert and save"})]}),children:null}),x.jsx(O.UnsavedChangesDialog,{...d}),x.jsx(lf,{open:i.addingTile,document:e.document,catalog:t,columns:n,onClose:i.closeAdd,onAdd:i.addTile,onAddText:i.addText})]})}var Tf=Symbol.for("preact-signals");function qs(){if(vt>1)vt--;else{var e,t=!1;for((function(){var s=Ss;for(Ss=void 0;s!==void 0;){var i=s.S;if(i.v===s.v)for(var o=i.t;o!==void 0;o=o.x)o.i===s.i&&(o.i=i.i);s=s.o}})();dr!==void 0;){var n=dr;for(dr=void 0,ks++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Hl(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(ks=0,vt--,t)throw e}}function Te(e){if(vt>0)return e();Mi=++Of,vt++;try{return e()}finally{qs()}}var ur,we=void 0;function fe(e){var t=we,n=ur;we=void 0,ur=void 0;try{return e()}finally{we=t,ur=n}}var dr=void 0,vt=0,ks=0,Of=0,Mi=0,Ss=void 0,$s=0;function Ul(e){if(we!==void 0){var t=e.n;if(t===void 0||t.t!==we)return t={i:0,S:e,p:we.s,n:void 0,t:we,e:void 0,x:void 0,r:t},we.s!==void 0&&(we.s.n=t),we.s=t,e.n=t,32&we.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=we.s,t.n=void 0,we.s.n=t,we.s=t),t}}function Ve(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}Ve.prototype.brand=Tf;Ve.prototype.h=function(){return!0};Ve.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:fe(function(){var r;(r=t.W)==null||r.call(t)}))};Ve.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&&fe(function(){var s;(s=t.Z)==null||s.call(t)}))}};Ve.prototype.subscribe=function(e){var t=this;return rt(function(){var n=t.value;fe(function(){return e(n)})},{name:"sub"})};Ve.prototype.valueOf=function(){return this.value};Ve.prototype.toString=function(){return this.value+""};Ve.prototype.toJSON=function(){return this.value};Ve.prototype.peek=function(){var e=this;return fe(function(){return e.value})};Object.defineProperty(Ve.prototype,"value",{get:function(){var e=Ul(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ks>100)throw new Error("Cycle detected");(function(n){vt!==0&&ks===0&&n.l!==Mi&&(n.l=Mi,Ss={S:n,v:n.v,i:n.i,o:Ss})})(this),this.v=e,this.i++,$s++,vt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{qs()}}}});function En(e,t){return new Ve(e,t)}function Hl(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 Xl(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 Yl(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 Yt(e,t){Ve.call(this,void 0,t),this.x=e,this.s=void 0,this.g=$s-1,this.f=4}Yt.prototype=new Ve;Yt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===$s))return!0;if(this.g=$s,this.f|=1,this.i>0&&!Hl(this))return this.f&=-2,!0;var e=we;try{Xl(this),we=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 we=e,Yl(this),this.f&=-2,!0};Yt.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)}Ve.prototype.S.call(this,e)};Yt.prototype.U=function(e){if(this.t!==void 0&&(Ve.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)}};Yt.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(Yt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Ul(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function La(e,t){return new Yt(e,t)}function Zl(e){var t=e.m;if(e.m=void 0,typeof t=="function"){vt++;var n=we;we=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,_o(e),r}finally{we=n,qs()}}}function _o(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Zl(e)}function Ef(e){if(we!==this)throw new Error("Out-of-order effect");Yl(this),we=e,this.f&=-2,8&this.f&&_o(this),qs()}function Cn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,ur&&ur.push(this)}Cn.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()}};Cn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Zl(this),Xl(this),vt++;var e=we;return we=this,Ef.bind(this,e)};Cn.prototype.N=function(){2&this.f||(this.f|=2,this.u=dr,dr=this)};Cn.prototype.d=function(){this.f|=8,1&this.f||_o(this)};Cn.prototype.dispose=function(){this.d()};function rt(e,t){var n=new Cn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Cf=Object.create,ko=Object.defineProperty,If=Object.defineProperties,Df=Object.getOwnPropertyDescriptor,Af=Object.getOwnPropertyDescriptors,Na=Object.getOwnPropertySymbols,Mf=Object.prototype.hasOwnProperty,Pf=Object.prototype.propertyIsEnumerable,Rf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),In=e=>{throw TypeError(e)},Pi=(e,t,n)=>t in e?ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jf=(e,t)=>{for(var n in t||(t={}))Mf.call(t,n)&&Pi(e,n,t[n]);if(Na)for(var n of Na(t))Pf.call(t,n)&&Pi(e,n,t[n]);return e},Lf=(e,t)=>If(e,Af(t)),Fa=(e,t)=>ko(e,"name",{value:t,configurable:!0}),Nf=e=>{var t;return[,,,Cf((t=void 0)!=null?t:null)]},Ql=["class","method","getter","setter","accessor","field","value","get","set"],Hn=e=>e!==void 0&&typeof e!="function"?In("Function expected"):e,Ff=(e,t,n,r,s)=>({kind:Ql[e],name:t,metadata:r,addInitializer:i=>n._?In("Already initialized"):s.push(Hn(i||null))}),Jl=(e,t)=>Pi(t,Rf("metadata"),e[3]),Lt=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},Dn=(e,t,n,r,s,i)=>{var o,a,l,d,u,c=t&7,f=!!(t&8),h=!!(t&16),p=c>3?e.length+1:c?f?1:2:0,m=Ql[c+5],b=c>3&&(e[p-1]=[]),w=e[p]||(e[p]=[]),v=c&&(!h&&!f&&(s=s.prototype),c<5&&(c>3||!h)&&Df(c<4?s:{get[n](){return Qe(this,i)},set[n](y){return Tt(this,i,y)}},n));c?h&&c<4&&Fa(i,(c>2?"set ":c>1?"get ":"")+n):Fa(s,n);for(var g=r.length-1;g>=0;g--)d=Ff(c,n,l={},e[3],w),c&&(d.static=f,d.private=h,u=d.access={has:h?y=>zf(s,y):y=>n in y},c^3&&(u.get=h?y=>(c^1?Qe:Wf)(y,s,c^4?i:v.get):y=>y[n]),c>2&&(u.set=h?(y,_)=>Tt(y,s,_,c^4?i:v.set):(y,_)=>y[n]=_)),a=(0,r[g])(c?c<4?h?i:v[m]:c>4?void 0:{get:v.get,set:v.set}:s,d),l._=1,c^4||a===void 0?Hn(a)&&(c>4?b.unshift(a):c?h?i=a:v[m]=a:s=a):typeof a!="object"||a===null?In("Object expected"):(Hn(o=a.get)&&(v.get=o),Hn(o=a.set)&&(v.set=o),Hn(o=a.init)&&b.unshift(o));return c||Jl(e,s),v&&ko(s,n,v),h?c^4?i:v:s},So=(e,t,n)=>t.has(e)||In("Cannot "+n),zf=(e,t)=>Object(t)!==t?In('Cannot use the "in" operator on this value'):e.has(t),Qe=(e,t,n)=>(So(e,t,"read from private field"),n?n.call(e):t.get(e)),Xn=(e,t,n)=>t.has(e)?In("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Tt=(e,t,n,r)=>(So(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Wf=(e,t,n)=>(So(e,t,"access private method"),n);function Ri(e,t){if(t){let n;return La(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return La(e)}function it(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)=>!it(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(i=>!it(e[i],t[i]))}return!1}function he({get:e},t){return{init(n){return En(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Ee(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Ri(e.bind(this)),n.set(this,r)),r.value}}function li(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,Lf(jf({},s),{enumerable:e}))})}}function Dr(...e){const t=e.map(n=>rt(n));return()=>t.forEach(n=>n())}var ec,tc,nc,rc,sc,ic,Ge,$o,ci,ji,Li,ze,To,ui,oc,Ni,Oo,di,Fi,zi;ic=[he],sc=[he],rc=[he],nc=[li()],tc=[li()],ec=[li()];var Zt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Lt(Ge,5,this),Xn(this,ze),Xn(this,$o,Lt(Ge,8,this)),Lt(Ge,11,this),Xn(this,To,Lt(Ge,12,this)),Lt(Ge,15,this),Xn(this,Oo,Lt(Ge,16,this)),Lt(Ge,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Qe(this,ze,Fi)}get initial(){return Qe(this,ze,ji)}get previous(){return Qe(this,ze,oc)}set current(e){const t=fe(()=>Qe(this,ze,Fi));e&&t&&this.equals(t,e)||Te(()=>{Qe(this,ze,ji)||Tt(this,ze,e,Li),Tt(this,ze,t,Ni),Tt(this,ze,e,zi)})}reset(e=this.defaultValue){Te(()=>{Tt(this,ze,void 0,Ni),Tt(this,ze,e,Li),Tt(this,ze,e,zi)})}};Ge=Nf();$o=new WeakMap;ze=new WeakSet;To=new WeakMap;Oo=new WeakMap;ci=Dn(Ge,20,"#initial",ic,ze,$o),ji=ci.get,Li=ci.set;ui=Dn(Ge,20,"#previous",sc,ze,To),oc=ui.get,Ni=ui.set;di=Dn(Ge,20,"#current",rc,ze,Oo),Fi=di.get,zi=di.set;Dn(Ge,2,"current",nc,Zt);Dn(Ge,2,"initial",tc,Zt);Dn(Ge,2,"previous",ec,Zt);Jl(Ge,Zt);function fi(e){return fe(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Nt,Bf=class{constructor(){Xn(this,Nt,new WeakMap)}get(e,t){var n;return e?(n=Qe(this,Nt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Qe(this,Nt).has(e)||Qe(this,Nt).set(e,new Map),(r=Qe(this,Nt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Qe(this,Nt).get(e))==null?void 0:t.clear():void 0}};Nt=new WeakMap;var Gf=Object.create,ac=Object.defineProperty,qf=Object.getOwnPropertyDescriptor,za=Object.getOwnPropertySymbols,Kf=Object.prototype.hasOwnProperty,Vf=Object.prototype.propertyIsEnumerable,lc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ks=e=>{throw TypeError(e)},Wa=Math.pow,Wi=(e,t,n)=>t in e?ac(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Uf=(e,t)=>{for(var n in t||(t={}))Kf.call(t,n)&&Wi(e,n,t[n]);if(za)for(var n of za(t))Vf.call(t,n)&&Wi(e,n,t[n]);return e},Hf=e=>{var t;return[,,,Gf((t=e?.[lc("metadata")])!=null?t:null)]},cc=["class","method","getter","setter","accessor","field","value","get","set"],uc=e=>e!==void 0&&typeof e!="function"?Ks("Function expected"):e,Xf=(e,t,n,r,s)=>({kind:cc[e],name:t,metadata:r,addInitializer:i=>n._?Ks("Already initialized"):s.push(uc(i||null))}),Yf=(e,t)=>Wi(t,lc("metadata"),e[3]),Zf=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)i[s].call(n);return r},dc=(e,t,n,r,s,i)=>{for(var o,a,l,d,u=t&7,c=!1,f=!1,h=2,p=cc[u+5],m=e[h]||(e[h]=[]),b=(s=s.prototype,qf(s,n)),w=r.length-1;w>=0;w--)l=Xf(u,n,a={},e[3],m),l.static=c,l.private=f,d=l.access={has:v=>n in v},d.get=v=>v[n],o=(0,r[w])(b[p],l),a._=1,uc(o)&&(b[p]=o);return b&&ac(s,n,b),s},fc=(e,t,n)=>t.has(e)||Ks("Cannot "+n),Qf=(e,t,n)=>(fc(e,t,"read from private field"),t.get(e)),Jf=(e,t,n)=>t.has(e)?Ks("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),eh=(e,t,n,r)=>(fc(e,t,"write to private field"),t.set(e,n),n),Je=class Bi{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Bi(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 Bi(t,n)}},ht=class Ft{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:i,height:o,scale:a}=this,l=new Ft(s+t,r+n,i,o);return l.scale=Uf({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:i,bottom:o}=this;return{width:t,height:n,left:r,top:s,right:i,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new Je((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Ft))return!1;const{left:n,top:r,width:s,height:i}=this;return n===t.left&&r===t.top&&s===t.width&&i===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:i}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=i}intersectionArea(t){return t instanceof Ft?th(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 Ft(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(i,o)=>{const a=r[o],l=o==="x"?i.left:i.top,d=o==="x"?i.width:i.height;return a=="start"?l:a=="end"?l+d:l+d/2};return Je.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return Ft.from(t).intersectionRatio(Ft.from(n))}};function th(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),i=Math.min(t.top+t.height,e.top+e.height),o=s-r,a=i-n;return r<s&&n<i?o*a:0}var hc,pc,Gi,ls,Ar,Vs=class extends(Gi=Zt,pc=[Ee],hc=[Ee],Gi){constructor(t){const n=Je.from(t);super(n,(r,s)=>Je.equals(r,s)),Zf(Ar,5,this),Jf(this,ls,0),this.velocity={x:0,y:0}}get delta(){return Je.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=Je.from(t),s={x:r.x-n.x,y:r.y-n.y},i=Date.now(),o=i-Qf(this,ls),a=l=>Math.round(l/o*100);Te(()=>{eh(this,ls,i),this.velocity={x:a(s.x),y:a(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Je.from(t)),this.velocity={x:0,y:0}}};Ar=Hf(Gi);ls=new WeakMap;dc(Ar,2,"delta",pc,Vs);dc(Ar,2,"direction",hc,Vs);Yf(Ar,Vs);function qi({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(Wa(r,2)+Wa(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 gc=(e=>(e.Horizontal="x",e.Vertical="y",e))(gc||{}),mc=Object.values(gc),nh=Object.create,Eo=Object.defineProperty,rh=Object.defineProperties,sh=Object.getOwnPropertyDescriptor,ih=Object.getOwnPropertyDescriptors,Ts=Object.getOwnPropertySymbols,vc=Object.prototype.hasOwnProperty,yc=Object.prototype.propertyIsEnumerable,bc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),An=e=>{throw TypeError(e)},Ki=(e,t,n)=>t in e?Eo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Co=(e,t)=>{for(var n in t||(t={}))vc.call(t,n)&&Ki(e,n,t[n]);if(Ts)for(var n of Ts(t))yc.call(t,n)&&Ki(e,n,t[n]);return e},Io=(e,t)=>rh(e,ih(t)),Ba=(e,t)=>Eo(e,"name",{value:t,configurable:!0}),xc=(e,t)=>{var n={};for(var r in e)vc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ts)for(var r of Ts(e))t.indexOf(r)<0&&yc.call(e,r)&&(n[r]=e[r]);return n},Mn=e=>{var t;return[,,,nh((t=e?.[bc("metadata")])!=null?t:null)]},wc=["class","method","getter","setter","accessor","field","value","get","set"],Yn=e=>e!==void 0&&typeof e!="function"?An("Function expected"):e,oh=(e,t,n,r,s)=>({kind:wc[e],name:t,metadata:r,addInitializer:i=>n._?An("Already initialized"):s.push(Yn(i||null))}),Qt=(e,t)=>Ki(t,bc("metadata"),e[3]),ae=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},pe=(e,t,n,r,s,i)=>{var o,a,l,d,u,c=t&7,f=!!(t&8),h=!!(t&16),p=c>3?e.length+1:c?f?1:2:0,m=wc[c+5],b=c>3&&(e[p-1]=[]),w=e[p]||(e[p]=[]),v=c&&(!h&&!f&&(s=s.prototype),c<5&&(c>3||!h)&&sh(c<4?s:{get[n](){return Oe(this,i)},set[n](y){return Ye(this,i,y)}},n));c?h&&c<4&&Ba(i,(c>2?"set ":c>1?"get ":"")+n):Ba(s,n);for(var g=r.length-1;g>=0;g--)d=oh(c,n,l={},e[3],w),c&&(d.static=f,d.private=h,u=d.access={has:h?y=>ah(s,y):y=>n in y},c^3&&(u.get=h?y=>(c^1?Oe:_c)(y,s,c^4?i:v.get):y=>y[n]),c>2&&(u.set=h?(y,_)=>Ye(y,s,_,c^4?i:v.set):(y,_)=>y[n]=_)),a=(0,r[g])(c?c<4?h?i:v[m]:c>4?void 0:{get:v.get,set:v.set}:s,d),l._=1,c^4||a===void 0?Yn(a)&&(c>4?b.unshift(a):c?h?i=a:v[m]=a:s=a):typeof a!="object"||a===null?An("Object expected"):(Yn(o=a.get)&&(v.get=o),Yn(o=a.set)&&(v.set=o),Yn(o=a.init)&&b.unshift(o));return c||Qt(e,s),v&&Eo(s,n,v),h?c^4?i:v:s},Do=(e,t,n)=>t.has(e)||An("Cannot "+n),ah=(e,t)=>Object(t)!==t?An('Cannot use the "in" operator on this value'):e.has(t),Oe=(e,t,n)=>(Do(e,t,"read from private field"),n?n.call(e):t.get(e)),ve=(e,t,n)=>t.has(e)?An("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ye=(e,t,n,r)=>(Do(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),_c=(e,t,n)=>(Do(e,t,"access private method"),n);function kc(e,t){return{plugin:e,options:t}}function Mr(e){return t=>kc(e,t)}function vr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Sc,yr,Ao,cs;Sc=[he];var We=class{constructor(e,t){this.manager=e,this.options=t,ve(this,Ao,ae(yr,8,this,!1)),ae(yr,11,this),ve(this,cs,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return fe(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=rt(e.bind(this));return Oe(this,cs).add(t),t}destroy(){Oe(this,cs).forEach(e=>e())}static configure(e){return kc(this,e)}};yr=Mn(null);Ao=new WeakMap;cs=new WeakMap;pe(yr,4,"disabled",Sc,We,Ao);Qt(yr,We);var Pr=class extends We{},us,hi=class{constructor(e){this.manager=e,this.instances=new Map,ve(this,us,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(vr).reduce((r,s)=>{const i=r.find(({plugin:o})=>o===s.plugin);return i?(i.options=s.options,r):[...r,s]},[]),n=t.map(({plugin:r})=>r);for(const r of Oe(this,us))if(!n.includes(r)){if(r.prototype instanceof Pr)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);Ye(this,us,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()}};us=new WeakMap;function lh(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Ur=[],cn,un,ch=class extends We{constructor(e){super(e),ve(this,cn),ve(this,un),this.computeCollisions=this.computeCollisions.bind(this),Ye(this,un,En(Ur)),this.destroy=Dr(()=>{const t=this.computeCollisions(),n=fe(()=>this.manager.dragOperation.position.current);if(t!==Ur){const r=Oe(this,cn);if(Ye(this,cn,n),r&&n.x==r.x&&n.y==r.y)return}else Ye(this,cn,void 0);Oe(this,un).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){fe(()=>{e?Oe(this,un).value=this.computeCollisions():Ye(this,cn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:i,status:o}=r;if(!o.initialized||!i)return Ur;const a=[],l=[];for(const d of e??n.droppables){if(d.disabled||s&&!d.accepts(s))continue;const u=t??d.collisionDetector;if(!u)continue;l.push(d),d.shape;const c=fe(()=>u({droppable:d,dragOperation:r}));c&&(d.collisionPriority!=null&&(c.priority=d.collisionPriority),a.push(c))}return l.length===0?Ur:(a.sort(lh),a)}get collisions(){return Oe(this,un).value}};cn=new WeakMap;un=new WeakMap;var $c,Tc,Oc,Mo,Ec,ot,Po,mn,Ro,jo;Oc=[he],Tc=[he],$c=[he];var bt=class zt{constructor(t,n){ve(this,Po,ae(ot,8,this)),ae(ot,11,this),ve(this,mn),ve(this,Ro,ae(ot,12,this)),ae(ot,15,this),ve(this,jo,ae(ot,16,this)),ae(ot,19,this);const{effects:r,id:s,data:i={},disabled:o=!1,register:a=!0}=t;let l=s;Ye(this,mn,En(s)),this.manager=n,this.data=i,this.disabled=o,this.effects=()=>{var d;return[()=>{const{id:u,manager:c}=this;if(u!==l)return l=u,c?.registry.register(this),()=>c?.registry.unregister(this)},...(d=r?.())!=null?d:[]]},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=Oe(this,mn).value;return(n=(t=zt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const s=(r=(n=zt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Oe(this,mn).peek();t!==s&&(zt.pendingIdChanges||(zt.pendingIdChanges=new Map,queueMicrotask(()=>{var i;return _c(i=zt,Mo,Ec).call(i)})),zt.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)}};ot=Mn(null);Mo=new WeakSet;Ec=function(){const e=bt.pendingIdChanges;bt.pendingIdChanges=null,e&&Te(()=>{for(const[t,n]of e)Oe(t,mn).value=n})};Po=new WeakMap;mn=new WeakMap;Ro=new WeakMap;jo=new WeakMap;pe(ot,4,"manager",Oc,bt,Po);pe(ot,4,"data",Tc,bt,Ro);pe(ot,4,"disabled",$c,bt,jo);ve(bt,Mo);Qt(ot,bt);bt.pendingIdChanges=null;var Us=bt,Ga=class{constructor(){this.map=En(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 i=new Map(n);for(const[a,l]of n)if(l===t&&a!==e){i.delete(a);break}i.set(e,t),this.map.value=i;const o=Dr(...t.effects());return this.cleanupFunctions.set(t,o),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}},Cc,Ic,Dc,Ac,Mc,Pc,Vi,qe,Lo,No,Fo,pt=class extends(Vi=Us,Pc=[he],Mc=[he],Ac=[he],Dc=[Ee],Ic=[Ee],Cc=[Ee],Vi){constructor(t,n){var r=t,{modifiers:s,type:i,sensors:o,plugins:a,effects:l}=r,d=xc(r,["modifiers","type","sensors","plugins","effects"]);super(Io(Co({},d),{effects:()=>{var u;return[...(u=l?.())!=null?u:[],()=>{const{manager:c,plugins:f}=this;if(!(!c||!f))for(const h of f){const{plugin:p}=vr(h);c.registry.plugins.register(p)}}]}}),n),ae(qe,5,this),ve(this,Lo,ae(qe,8,this)),ae(qe,11,this),ve(this,No,ae(qe,12,this)),ae(qe,15,this),ve(this,Fo,ae(qe,16,this,this.isDragSource?"dragging":"idle")),ae(qe,19,this),this.type=i,this.sensors=o,this.modifiers=s,this.alignment=d.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=vr(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}};qe=Mn(Vi);Lo=new WeakMap;No=new WeakMap;Fo=new WeakMap;pe(qe,4,"type",Pc,pt,Lo);pe(qe,4,"modifiers",Mc,pt,No);pe(qe,4,"status",Ac,pt,Fo);pe(qe,2,"isDropping",Dc,pt);pe(qe,2,"isDragging",Ic,pt);pe(qe,2,"isDragSource",Cc,pt);Qt(qe,pt);var Rc,jc,Lc,Nc,Fc,zc,Ui,Me,zo,Wo,Bo,Go,qo,gt=class extends(Ui=Us,zc=[he],Fc=[he],Nc=[he],Lc=[he],jc=[he],Rc=[Ee],Ui){constructor(t,n){var r=t,{accept:s,collisionDetector:i,collisionPriority:o,type:a}=r,l=xc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),ae(Me,5,this),ve(this,zo,ae(Me,8,this)),ae(Me,11,this),ve(this,Wo,ae(Me,12,this)),ae(Me,15,this),ve(this,Bo,ae(Me,16,this)),ae(Me,19,this),ve(this,Go,ae(Me,20,this)),ae(Me,23,this),ve(this,qo,ae(Me,24,this)),ae(Me,27,this),this.accept=s,this.collisionDetector=i,this.collisionPriority=o,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}};Me=Mn(Ui);zo=new WeakMap;Wo=new WeakMap;Bo=new WeakMap;Go=new WeakMap;qo=new WeakMap;pe(Me,4,"accept",zc,gt,zo);pe(Me,4,"type",Fc,gt,Wo);pe(Me,4,"collisionDetector",Nc,gt,Bo);pe(Me,4,"collisionPriority",Lc,gt,Go);pe(Me,4,"shape",jc,gt,qo);pe(Me,2,"isDropTarget",Rc,gt);Qt(Me,gt);var uh=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)}},dh=class extends uh{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function ds(e,t=!0){let n=!1;return Io(Co({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var fh=class extends Pr{constructor(e){super(e);const t=(r,s)=>r.map(({id:i})=>i).join("")===s.map(({id:i})=>i).join("");let n=[];this.destroy=Dr(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:i}=r;if(r.isDisabled()||Us.pendingIdChanges)return;const o=ds({collisions:i});if(s.dispatch("collision",o),o.defaultPrevented||t(i,n))return;n=i;const[a]=i;fe(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},Pn=(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))(Pn||{}),Rn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Rn||{}),Wc,Bc,Gc,qc,Kc,Vc,Uc,nt,Ko;Uc=[he],Vc=[Ee],Kc=[Ee],qc=[Ee],Gc=[Ee],Bc=[Ee],Wc=[Ee];var wt=class{constructor(){ae(nt,5,this),ve(this,Ko,ae(nt,8,this,"idle")),ae(nt,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}};nt=Mn(null);Ko=new WeakMap;pe(nt,4,"value",Uc,wt,Ko);pe(nt,2,"current",Vc,wt);pe(nt,2,"idle",Kc,wt);pe(nt,2,"initializing",qc,wt);pe(nt,2,"initialized",Gc,wt);pe(nt,2,"dragging",Bc,wt);pe(nt,2,"dropped",Wc,wt);Qt(nt,wt);var hh=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 fe(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=ds({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return fe(()=>{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:i}=e;Te(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(i)});const o=ds({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.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"&&Te(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return fe(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:i}=r;if(!s.dragging||!i||i.signal.aborted)return;const o=ds({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,l,d,u,c;if(o.defaultPrevented)return;const f=(c=e.to)!=null?c:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((u=(d=e.by)==null?void 0:d.y)!=null?u:0)};r.position.current=f})})}stop(e={}){return fe(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let i;const o=()=>{const l={resume:()=>{},abort:()=>{}};return i=new Promise((d,u)=>{l.resume=d,l.abort=u}),l};s.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=fe(()=>{var u;return((u=r.source)==null?void 0:u.status)==="dropping"}),d=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:u}=r,c=rt(()=>{u?.status==="idle"&&(c(),d())})}else this.manager.renderer.rendering.then(d)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),i?i.then(a).catch(()=>r.reset()):a()})}},_n=class extends We{constructor(e,t){super(e,t),this.manager=e,this.options=t}},ph=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)}},fs,Hc=class{constructor(e){this.options=e,ve(this,fs)}set controller(e){Ye(this,fs,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Oe(this,fs))==null||t.activate(e)}};fs=new WeakMap;var qa=class extends We{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},gh=class{constructor(e){this.draggables=new Ga,this.droppables=new Ga,this.plugins=new hi(e),this.sensors=new hi(e),this.modifiers=new hi(e)}register(e,t){if(e instanceof pt)return this.draggables.register(e.id,e);if(e instanceof gt)return this.droppables.register(e.id,e);if(e.prototype instanceof qa)return this.modifiers.register(e,t);if(e.prototype instanceof _n)return this.sensors.register(e,t);if(e.prototype instanceof We)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Us)return e instanceof pt?this.draggables.unregister(e.id,e):e instanceof gt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof qa)return this.modifiers.unregister(e);if(e.prototype instanceof _n)return this.sensors.unregister(e);if(e.prototype instanceof We)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()}},Xc,Yc,Zc,Qc,Jc,eu,tu,nu,ru,Zn,hs,dn,$e,Vo,Uo,Ho,Xo,Yo,Qn;ru=[Ee],nu=[he],tu=[he],eu=[he],Jc=[he],Qc=[he],Zc=[Ee],Yc=[Ee],Xc=[Ee];var ct=class{constructor(e){ae($e,5,this),ve(this,Zn),ve(this,hs),ve(this,dn,new Zt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new wt,ve(this,Vo,ae($e,8,this,!1)),ae($e,11,this),ve(this,Uo,ae($e,12,this,null)),ae($e,15,this),ve(this,Ho,ae($e,16,this,null)),ae($e,19,this),ve(this,Xo,ae($e,20,this,null)),ae($e,23,this),ve(this,Yo,ae($e,24,this,[])),ae($e,27,this),this.position=new Vs({x:0,y:0}),ve(this,Qn,{x:0,y:0}),Ye(this,Zn,e)}get shape(){const{current:e,initial:t,previous:n}=Oe(this,dn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Oe(this,dn).current=e:Oe(this,dn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Oe(this,Zn).registry.draggables.get(t);return n&&Ye(this,hs,n),(e=n??Oe(this,hs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Oe(this,Zn).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(Io(Co({},this.snapshot()),{transform:n}));return Ye(this,Qn,n),n}snapshot(){return fe(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Oe(this,Qn),shape:this.shape?fi(this.shape):null,position:fi(this.position),status:fi(this.status),canceled:this.canceled}))}reset(){Te(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Oe(this,dn).reset(),this.position.reset({x:0,y:0}),Ye(this,Qn,{x:0,y:0}),this.modifiers=[]})}};$e=Mn(null);Zn=new WeakMap;hs=new WeakMap;dn=new WeakMap;Vo=new WeakMap;Uo=new WeakMap;Ho=new WeakMap;Xo=new WeakMap;Yo=new WeakMap;Qn=new WeakMap;pe($e,2,"shape",ru,ct);pe($e,4,"canceled",nu,ct,Vo);pe($e,4,"activatorEvent",tu,ct,Uo);pe($e,4,"sourceIdentifier",eu,ct,Ho);pe($e,4,"targetIdentifier",Jc,ct,Xo);pe($e,4,"modifiers",Qc,ct,Yo);pe($e,2,"source",Zc,ct);pe($e,2,"target",Yc,ct);pe($e,2,"transform",Xc,ct);Qt($e,ct);var mh={get rendering(){return Promise.resolve()}};function lt(e,t){return typeof e=="function"?e(t):e??t}var vh=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=lt(r.plugins,[]),i=lt(r.sensors,[]),o=lt(r.modifiers,[]),a=(n=r.renderer)!=null?n:mh,l=new dh(this),d=new gh(this);this.registry=d,this.monitor=l,this.renderer=a,this.actions=new hh(this),this.dragOperation=new ct(this),this.collisionObserver=new ch(this),this.plugins=[fh,...s],this.modifiers=o,this.sensors=i;const{destroy:u}=this,c=Dr(()=>{var f,h,p;const m=fe(()=>this.dragOperation.modifiers),b=this.modifiers;for(const w of m)b.includes(w)||w.destroy();this.dragOperation.modifiers=(p=(h=(f=this.dragOperation.source)==null?void 0:f.modifiers)==null?void 0:h.map(w=>{const{plugin:v,options:g}=vr(w);return new v(this,g)}))!=null?p:b});this.destroy=()=>{c(),u()}}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}},su=e=>{throw TypeError(e)},Zo=(e,t,n)=>t.has(e)||su("Cannot "+n),oe=(e,t,n)=>(Zo(e,t,"read from private field"),t.get(e)),Ue=(e,t,n)=>t.has(e)?su("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Xe=(e,t,n,r)=>(Zo(e,t,"write to private field"),t.set(e,n),n),iu=(e,t,n)=>(Zo(e,t,"access private method"),n);function Hs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function ou(e,t){const n=e.getAnimations();let r=null;for(const s of n){if(s.playState!=="running")continue;const{effect:i}=s,a=(Hs(i)?i.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],s])}return r}function Xs(e){const{width:t,height:n,top:r,left:s,bottom:i,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:s,bottom:i,right:o}}function Qo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Rr(e){return"nodeType"in e}function Ze(e){var t,n,r;return e?Qo(e)?e:Rr(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 Jo(e){const{Document:t}=Ze(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function At(e){return!e||Qo(e)?!1:e instanceof Ze(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function au(e){return e instanceof Ze(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function jn(e){return e?Qo(e)?e.document:Rr(e)?Jo(e)?e:At(e)||au(e)?e.ownerDocument:document:document:document}function yh(e){var t,n,r,s;const{documentElement:i}=jn(e),o=Ze(e).visualViewport,a=(t=o?.width)!=null?t:i.clientWidth,l=(n=o?.height)!=null?n:i.clientHeight,d=(r=o?.offsetTop)!=null?r:0,u=(s=o?.offsetLeft)!=null?s:0;return{top:d,left:u,right:u+a,bottom:d+l,width:a,height:l}}function bh(e,t){if(xh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function xh(e){return e.tagName==="DETAILS"}function br(e,t=e.getBoundingClientRect(),n=0){var r,s,i,o,a;let l=t;const{ownerDocument:d}=e,u=(r=d.defaultView)!=null?r:window;let c=e.parentElement;for(;c&&c!==d.documentElement;){if(!bh(c)){const g=c.getBoundingClientRect(),y=n*(g.bottom-g.top),_=n*(g.right-g.left),S=n*(g.bottom-g.top),E=n*(g.right-g.left);l={top:Math.max(l.top,g.top-y),right:Math.min(l.right,g.right+_),bottom:Math.min(l.bottom,g.bottom+S),left:Math.max(l.left,g.left-E),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}c=c.parentElement}const f=u.visualViewport,h=(s=f?.offsetTop)!=null?s:0,p=(i=f?.offsetLeft)!=null?i:0,m=(o=f?.width)!=null?o:u.innerWidth,b=(a=f?.height)!=null?a:u.innerHeight,w=n*b,v=n*m;return l={top:Math.max(l.top,h-w),right:Math.min(l.right,p+m+v),bottom:Math.min(l.bottom,h+b+w),left:Math.max(l.left,p-v),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 kn(e){return{x:e.clientX,y:e.clientY}}var lu=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 ea(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function cu(){var e,t;const n=ea()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function ta(e){return!e||!Rr(e)?!1:e instanceof Ze(e).ShadowRoot}function Os(e){if(e&&Rr(e)){let t=e.getRootNode();if(ta(t))return t;if(t instanceof Document)return t}return jn(e)}function na(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function wh(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((i,o)=>{const a=r[o];if(Ka(i)&&Ka(a)&&(i.type!=="file"&&(i.value=a.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),Va(i)&&Va(a)&&a.width>0&&a.height>0){const l=i.getContext("2d");l?.drawImage(a,0,0)}}),n}function Ka(e){return"value"in e}function Va(e){return e.tagName==="CANVAS"}function uu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(_h(r)){const{contentDocument:s}=r;if(s){const{left:i,top:o}=r.getBoundingClientRect();return uu(s,{x:t-i,y:n-o})}}return r}function _h(e){return e?.tagName==="IFRAME"}var Xi=new WeakMap;function kh(e){return e.closest(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),O=require("../useCompiledDocument-BKyRnXmA.cjs.js"),$=require("@mui/material"),k=require("react"),Be=require("../ServerProvider-B0dUY8be.cjs.js"),ge=require("../text-entry-BJwltZiy.cjs.js"),nf=require("react-dom"),rf=require("@malloydata/malloy-tag"),ql=require("@tanstack/react-query"),sf={line_chart:"Line",bar_chart:"Bar",big_value:"Big value",scatter_chart:"Scatter",shape_map:"Shape map",segment_map:"Segment map"};function of(e,t,n){const r=e!==void 0?void 0:n==="loading"?"Still loading this view's details":n==="unlisted"?"Not a view the catalog lists, so its shape is unknown":void 0,s=o=>{if(t!==o){if(o==="big_value")return e?.aggregateOnly===!0?void 0:r??"Needs a view with only totals (no group by)";if(o==="shape_map"||o==="segment_map")return e?.chart===o?void 0:r??"Needs a view that already carries a map chart"}};return[{value:"default",label:"From the view"},{value:"none",label:"Table"},...["line_chart","bar_chart","big_value","scatter_chart","shape_map","segment_map"].map(o=>{const a=s(o);return{value:o,label:sf[o],...a?{disabled:!0,reason:a}:{}}}),...t==="custom"?[{value:"custom",label:"As written"}]:[]]}function Di({state:e,view:t,viewStatus:n,cellLabel:r,disabledReason:s,onOpen:i,onChange:o,variant:a="standard"}){const l=of(t,e,n),d=k.useId();return x.jsx($.TextField,{select:!0,size:"small",variant:a,label:"Viz type",value:e,disabled:s!==void 0,onChange:u=>{const c=u.target.value;l.find(f=>f.value===c)?.disabled||o(c)},helperText:s,FormHelperTextProps:{id:d},SelectProps:{...i?{onOpen:i}:{},renderValue:u=>l.find(c=>c.value===u)?.label??String(u),MenuProps:{MenuListProps:{disabledItemsFocusable:!0}},SelectDisplayProps:{"aria-label":`Viz type, ${r}`,"aria-labelledby":void 0,...s?{"aria-describedby":d}:{}}},sx:{minWidth:140},children:l.map(u=>x.jsx($.MenuItem,{value:u.value,disabled:u.value==="custom"||u.disabled===!0,children:x.jsx($.ListItemText,{primary:u.label,...u.reason?{secondary:u.reason}:{}})},u.value))})}function af({sources:e,source:t,view:n,onSource:r,onView:s}){const{theme:i}=Be.usePublisherTheme(),o=e.find(a=>a.name===t);return x.jsxs(x.Fragment,{children:[x.jsx($.TextField,{select:!0,size:"small",label:"Source",value:t,onChange:a=>r(a.target.value),inputProps:{"aria-label":"Source"},children:e.map(a=>x.jsxs($.MenuItem,{value:a.name,disabled:a.views.length===0,children:[a.name,a.views.length===0&&x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1},children:"declares no views"}),a.description&&x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:a.description})]},a.name))}),x.jsxs($.Box,{children:[x.jsx($.Typography,{variant:"subtitle2",sx:{mb:.5},children:"View"}),x.jsxs($.List,{dense:!0,disablePadding:!0,"aria-label":"Views",sx:{maxHeight:"min(280px, 30vh)",overflowY:"auto",border:i.border,borderRadius:1},children:[(o?.views??[]).map(a=>x.jsxs($.ListItemButton,{selected:n===a.name,onClick:()=>s(a.name),"aria-label":`View ${a.name}`,children:[x.jsx($.ListItemText,{primary:a.name,secondary:a.description,primaryTypographyProps:{fontFamily:"ui-monospace, monospace",fontSize:13}}),a.chart&&x.jsx($.Chip,{size:"small",variant:"outlined",label:a.chart.replace(/_chart$/,"")})]},a.name)),o&&o.views.length===0&&x.jsx($.Typography,{variant:"body2",sx:{p:1.5,color:i.tileTitle},children:"This source declares no views."})]})]})]})}function lf({open:e,document:t,catalog:n,columns:r,onClose:s,onAdd:i,onAddText:o}){const{theme:a}=Be.usePublisherTheme(),l=k.useMemo(()=>n?.sources??[],[n]),[d,u]=k.useState("query"),[c,f]=k.useState(""),[h,p]=k.useState(""),[m,b]=k.useState(""),[w,v]=k.useState("default"),[g,y]=k.useState(Math.ceil(r/2));k.useEffect(()=>{if(!e)return;u("query");const T=D=>l.some(q=>q.name===D&&q.views.length>0);f(t.sources.map(D=>D.base).find(T)??l.find(D=>D.views.length>0)?.name??""),p(""),b(""),v("default"),y(Math.ceil(r/2))},[e,t,l,r]);const _=c!==""&&h!=="",S=[c,h].filter(T=>T!==""&&!ge.isBareName(T)).map(T=>`"${T}" is not a plain Malloy name, so a tile cannot be written for it.`)[0],E=l.find(T=>T.name===c),A=E?.views.find(T=>T.name===h);return x.jsx(O.AppDialog,{open:e,onClose:s,title:"Add a tile",description:"A tile shows one view of a source in this package.",actions:x.jsxs(x.Fragment,{children:[x.jsx($.Button,{onClick:s,children:"Cancel"}),x.jsx($.Button,{variant:"contained",disabled:d==="query"&&(!_||S!==void 0),onClick:()=>d==="text"?o():i({base:c,modelPath:E?.modelPath??"",...E?.exporters?{exporters:E.exporters}:{},view:h,...m.trim()?{label:m.trim()}:{},...w!=="default"?{chart:w,...A?{chartCarried:A.chart?[A.chart]:[]}:{}}:{},colspan:g}),children:d==="text"?"Add text":"Add tile"})]}),children:x.jsxs($.Stack,{sx:{gap:2,pt:1},children:[x.jsxs($.ToggleButtonGroup,{size:"small",exclusive:!0,value:d,"aria-label":"Tile type",onChange:(T,D)=>{D!==null&&u(D)},children:[x.jsx($.ToggleButton,{value:"query",sx:{px:1.5},children:"Query"}),x.jsx($.ToggleButton,{value:"text",sx:{px:1.5},children:"Text"})]}),d==="text"?x.jsx($.Typography,{variant:"body2",sx:{color:a.tileTitle},children:"A text tile holds markdown: a heading, a paragraph, a list. It is added empty, and written on the tile itself."}):l.length===0?x.jsx($.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?"This package publishes no source with a view to put on a tile.":"The package's sources are still loading."}):x.jsxs(x.Fragment,{children:[x.jsx(af,{sources:l,source:c,view:h,onSource:T=>{f(T),p("")},onView:T=>{p(T),v("default")}}),S&&x.jsx($.Typography,{variant:"body2",color:"error",children:S}),x.jsx(Di,{state:w,view:A,cellLabel:"new tile",variant:"outlined",...A?{}:{disabledReason:"Pick a view to choose its chart."},onChange:T=>v(T)}),x.jsx($.Stack,{direction:"row",sx:{gap:1.5},children:x.jsx($.TextField,{size:"small",label:"Title",placeholder:"Uses the view's name",value:m,onChange:T=>b(T.target.value),inputProps:{"aria-label":"Tile title"},sx:{flex:1}})})]})]})})}const Re=e=>e.kind==="text",xe=e=>e.kind!=="text",Kr=e=>xe(e)?e.label??e.name:e.name,Fe=e=>Re(e)?`text.${e.name}`:`${e.source}.${e.name}`,ai="self";function cf({open:e,document:t,source:n,givenNames:r,dashboards:s,onClose:i,onApply:o}){const{theme:a}=Be.usePublisherTheme(),[l,d]=k.useState([]);k.useEffect(()=>{if(!e||!n)return;const p=(t.drills??[]).filter(m=>m.source===n.name);d((n.dimensions??[]).map(m=>{const b=p.find(w=>w.name===m.name);return{name:m.name,expression:m.expression,to:b?.to??[],given:b?.given??""}}))},[e,n,t]);const u=(p,m)=>d(b=>b.map((w,v)=>{if(v!==p)return w;const g={...w};return m(g),g})),c=[ai,...s.filter(p=>p!==ai)],f=p=>p===ai?"This report":p,h=()=>{n&&(o(l.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())};return x.jsx(O.AppDialog,{open:e,onClose:i,title:"Drill",description:"A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the report it opens.",actions:x.jsxs(x.Fragment,{children:[x.jsx($.Button,{onClick:i,children:"Cancel"}),x.jsx($.Button,{variant:"contained",onClick:h,disabled:l.length===0,children:"Apply"})]}),children:x.jsx($.Stack,{sx:{gap:2,pt:1},children:l.length===0?x.jsx($.Typography,{variant:"body2",sx:{color:a.tileTitle},children:n?x.jsxs(x.Fragment,{children:[x.jsx($.Box,{component:"code",children:n.name})," declares no dimensions of its own in this file. A drill 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"," ",x.jsx($.Box,{component:"code",children:n.name})," and group by it."]}):"This tile's source is not declared in this file."}):l.map((p,m)=>x.jsxs($.Box,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)"},gap:1.5,alignItems:"start"},children:[x.jsxs($.Box,{sx:{minWidth:0,pt:.75},children:[x.jsx($.Typography,{variant:"body2",sx:{fontFamily:"ui-monospace, monospace",fontSize:13},children:p.name}),x.jsxs($.Typography,{variant:"caption",sx:{color:a.tileTitle,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:p.expression,children:["is ",p.expression]})]}),x.jsx($.TextField,{select:!0,size:"small",label:"Clicks go to",value:p.to,inputProps:{"aria-label":`Where ${p.name} goes`},SelectProps:{multiple:!0,renderValue:b=>b.length===0?"Not clickable":b.map(f).join(", "),displayEmpty:!0},InputLabelProps:{shrink:!0},onChange:b=>u(m,w=>{const v=b.target.value;w.to=Array.isArray(v)?v:String(v).split(",").filter(Boolean)}),children:c.map(b=>x.jsxs($.MenuItem,{value:b,children:[x.jsx($.Checkbox,{size:"small",checked:p.to.includes(b),sx:{p:0,mr:1}}),x.jsx($.ListItemText,{primary:f(b)})]},b))}),x.jsxs($.TextField,{select:!0,size:"small",label:"Sets the filter",value:p.given,disabled:p.to.length===0,inputProps:{"aria-label":`Control ${p.name} sets`},SelectProps:{displayEmpty:!0},InputLabelProps:{shrink:!0},helperText:p.given===""?`Named ${p.name}, like the dimension`:void 0,onChange:b=>u(m,w=>{w.given=b.target.value}),children:[x.jsx($.MenuItem,{value:"",children:x.jsx("em",{children:"Same name as the dimension"})}),r.map(b=>x.jsx($.MenuItem,{value:b,children:b},b))]})]},p.name))})})}function uf(e,t=[]){const n=new Map;for(const i of e.tiles)for(const o of xe(i)?i.filters??[]:[])n.set(o.given,(n.get(o.given)??0)+1);const r=[],s=new Set;for(const i of e.localGivens??[])s.add(i.name),r.push({name:i.name,...i.label===void 0?{}:{label:i.label},type:i.type,...i.suggest?{field:i.suggest.dimension}:{},origin:"dashboard",local:i,boundTiles:n.get(i.name)??0});for(const i of t)s.has(i.name)||(s.add(i.name),r.push({...i,origin:"model",boundTiles:n.get(i.name)??0}));for(const[i,o]of n)s.has(i)||r.push({name:i,origin:"model",boundTiles:o});return r}function _s(e){if(!(e===void 0||e.startsWith("filter<")))return e==="string"||e==="boolean"?"=":">="}function df(e){if(e)return/^filter<(.+)>$/.exec(e)?.[1]??e}function as(e,t){const n=df(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 Ma(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 ff(e){switch(e?.replace(/_type$/,"")){case"number":return"number";case"date":case"timestamp":return"date";default:return"select"}}const hf=[{op:"~",label:"matches"},{op:"=",label:"equals"},{op:">=",label:"at least"},{op:"<=",label:"at most"},{op:">",label:"more than"},{op:"<",label:"less than"}];function pf(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}`,i=ge.isStrictName(s)?s:`${s}_FILTER`,o=new Set(t);if(!o.has(i))return i;for(let a=2;;a++)if(!o.has(`${i}_${a}`))return`${i}_${a}`}const Pa=[{kind:"select",label:"Pick one",hint:"A dropdown of the field's values"},{kind:"multiselect",label:"Pick several",hint:"The same, taking more than one"},{kind:"text",label:"Text",hint:"A box taking Malloy filter syntax"},{kind:"number",label:"Number range",hint:"A slider over the field's values"},{kind:"date",label:"On or after a date",hint:"A date picker; tiles keep rows on or after it"}];function Vr(e){const t=e.label.trim()||e.name,n=e.field;switch(e.kind){case"select":case"multiselect":return{name:e.name,type:"filter<string>",default:"f''",label:t,control:e.kind,...e.source?{suggest:{source:e.source,dimension:n}}:{}};case"text":return{name:e.name,type:"filter<string>",default:"f''",label:t};case"number":return{name:e.name,type:"filter<number>",default:"f''",label:t,...e.range?{rangeMin:e.range.min,rangeMax:e.range.max}:{}};case"date":return{name:e.name,type:"date",default:`@${e.dateDefault??new Date().toISOString().slice(0,10)}`,label:t}}}const Ai=e=>xe(e)&&e.declaration.kind!=="inherited"&&e.declaration.kind!=="opaque";function gf(e,t){return e.tiles.map(n=>{const r=(xe(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}:_s(t.type)!==void 0?{op:_s(t.type)}:{}}})}function mf(e,t,n){n.forEach((r,s)=>{const i=e.tiles[s];if(!i||!Ai(i))return;const o=(i.filters??[]).filter(l=>l.given!==t),a=r.include?[...o,{field:r.field.trim()||t.toLowerCase(),given:t,...r.op&&r.op!=="~"?{op:r.op}:{}}]:o;a.length>0?i.filters=a:delete i.filters})}function vf(e,t){const n=(e.localGivens??[]).filter(i=>i.name!==t.name),r=(e.localGivens??[]).findIndex(i=>i.name===t.name),s=[...n];s.splice(r>=0?r:s.length,0,t),e.localGivens=s}function yf(e,t){for(const r of e.tiles){if(!xe(r))continue;const s=(r.filters??[]).filter(i=>i.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 Kl=e=>e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g," ");function bf({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:i}){const o=k.useRef(n);e&&(o.current=n);const a=e?n:o.current,l=a!==void 0,[d,u]=k.useState({kind:"new"}),[c,f]=k.useState(""),[h,p]=k.useState("select"),[m,b]=k.useState(""),[w,v]=k.useState(""),[g,y]=k.useState([]),[_,S]=k.useState(!1),[E,A]=k.useState(!1),T=j=>t.sources.find(F=>F.name===j.source)?.base??j.source;k.useEffect(()=>{if(e)if(A(n!==void 0),n){u({kind:"existing",name:n.name}),f(n.label??"");const j=gf(t,n);y(j);const F=j.filter(ue=>ue.include),re=new Set(F.map(ue=>ue.field));v(re.size===1?F[0].field:n.field??""),S(re.size>1)}else u({kind:"new"}),f(""),p("select"),v(""),b(new Date().toISOString().slice(0,10)),y(t.tiles.map(j=>({include:Ai(j),field:""}))),S(!1)},[e,n,t]);const D=k.useMemo(()=>[...(t.localGivens??[]).map(j=>j.name),...r.map(j=>j.name)],[t,r]),q=k.useMemo(()=>w.trim()?pf(w.trim(),D):"",[w,D]),P=d.kind==="existing"?n??r.find(j=>j.name===d.name):q?{name:q,type:Vr({name:q,label:c,kind:h,field:w}).type}:void 0,z=P?.type!==void 0&&!P.type.startsWith("filter<"),U=g.find(j=>j.include)?.op??_s(P?.type),K=(j,F)=>{A(!0),y(re=>re.map((ue,je)=>je===j?{...ue,...F}:ue))},Z=j=>{A(!0),y(F=>F.map(re=>({...re,op:j})))},J=j=>{const F=_s(j);y(re=>re.map(({op:ue,...je})=>F?{...je,op:F}:je))},ie=j=>{A(!0),u({kind:"existing",name:j.name}),v(j.field??""),J(j.type)},de=j=>{A(!0),p(j),J(Vr({name:"X",label:c,kind:j,field:w}).type)},I=t.tiles.map(Ai),V=I.filter(Boolean).length,B=g.filter((j,F)=>j.include&&I[F]).length,R=t.tiles.filter((j,F)=>(g[F]?.include??!1)&&I[F]&&xe(j)),G=R.length>0?R:t.tiles.filter((j,F)=>I[F]&&xe(j)),ne=k.useMemo(()=>{const j=new Map;let F=!1;for(const re of G){const ue=s?.(re);if(ue){F=!0;for(const je of ue)j.has(je.name)||j.set(je.name,je)}}return F?[...j.values()]:void 0},[g,t.tiles,s]),Y=(()=>{const j=w.trim();for(const F of R){const re=s?.(F);if(!re||re.some(ue=>ue.name===j))return T(F)}return R[0]?T(R[0]):t.sources[0]?.base})(),H=j=>{A(!0),y(F=>F.map((re,ue)=>({...re,include:j&&I[ue]})))},L=k.useMemo(()=>_?g:g.map(j=>({...j,field:w})),[_,g,w]),C=j=>{for(const F of G){const re=s?.(F)?.find(ue=>ue.name===j.trim());if(re?.type)return re.type}},W=j=>as(P?.type,j.type),M=(j,F)=>{if(j.trim()==="")return"Pick the field this filter compares.";const re=F?s?.(F):void 0;if(!re)return;const ue=re.find(je=>je.name===j.trim());if(!ue)return`Not a field of ${F?T(F):"the tiles' source"}.`;if(ue.type&&!as(P?.type,ue.type))return`${j.trim()} is ${Ma(ue.type)}; this filter compares ${Ma(P?.type?.replace(/^filter<(.+)>$/,"$1"))}.`},ee=j=>{if(A(!0),v(j),l||d.kind!=="new")return;const F=C(j),re=Vr({name:"X",label:c,kind:h,field:j}).type;F&&!as(re,F)&&de(ff(F))},X=j=>{const F=t.tiles[j];return F&&xe(F)?F:void 0},le=L.map((j,F)=>j.include&&I[F]?M(j.field,X(F)):void 0),ce=le.every(j=>j===void 0),N=E?le:le.map(()=>{}),Q=E&&!_&&B>0?R.map(j=>M(w,j)).find(Boolean):void 0,me=P!==void 0&&ce&&(d.kind==="existing"||w.trim()!==""&&q!==""),se=()=>{if(!(!P||!me))if(d.kind==="new")i(P.name,L,Vr({name:P.name,label:c.trim()||Kl(P.name),kind:h,field:w.trim(),...Y?{source:Y}:{},...m?{dateDefault:m}:{}}));else if(n?.origin==="dashboard"&&n.local){const j=c.trim(),F=j!==(n.local.label??"");i(P.name,L,F?{...n.local,...j?{label:j}:{}}:void 0)}else i(P.name,L)},te=l&&a.origin==="model";return{editing:l,shown:a,fromModel:te,source:d,setSource:u,label:c,setLabel:f,kind:h,dateDefault:m,setDateDefault:b,field:w,rows:g,setRows:y,perTile:_,setPerTile:S,newName:q,target:P,valueTyped:z,commonOp:U,setRow:K,setCommonOp:Z,pickExisting:ie,pickKind:de,bindable:I,bindableCount:V,included:B,commonFields:ne,setAll:H,accepts:W,pickField:ee,rowProblems:N,commonProblem:Q,canApply:me,apply:se}}function Ra({value:e,onChange:t,fields:n,accepts:r,label:s,ariaLabel:i,error:o,helperText:a,disabled:l,autoFocus:d,placeholder:u,sx:c}){const f=k.useMemo(()=>(n??[]).filter(p=>r?.(p)??!0).map(p=>p.name),[n,r]),h=k.useMemo(()=>new Map((n??[]).map(p=>[p.name,p.type])),[n]);return x.jsx($.Autocomplete,{freeSolo:!0,size:"small",options:f,inputValue:e,onInputChange:(p,m)=>t(m),value:e,onChange:(p,m)=>t(typeof m=="string"?m:""),disabled:l,disableClearable:!0,renderOption:(p,m)=>k.createElement("li",{...p,key:m},x.jsx($.Typography,{variant:"body2",sx:{flex:1},children:m}),h.get(m)&&x.jsx($.Typography,{variant:"caption",sx:{opacity:.6},children:h.get(m)?.replace(/_type$/,"")})),renderInput:p=>x.jsx($.TextField,{...p,label:s,placeholder:u,autoFocus:d,error:o,helperText:a,inputProps:{...p.inputProps,"aria-label":i}}),sx:c})}const ja=e=>e&&xe(e)&&e.declaration.kind==="opaque"?{label:"Not bindable",reason:`Its body is ${e.declaration.why}, so a filter has no single place to go.`}:{label:"From the model",reason:"Declared on its source, which this report does not write."};function xf({open:e,document:t,control:n,available:r,fieldsFor:s,onClose:i,onApply:o,onRemove:a}){const{theme:l}=Be.usePublisherTheme(),{editing:d,shown:u,fromModel:c,source:f,setSource:h,label:p,setLabel:m,kind:b,dateDefault:w,setDateDefault:v,field:g,rows:y,setRows:_,perTile:S,setPerTile:E,newName:A,target:T,valueTyped:D,commonOp:q,setRow:P,setCommonOp:z,pickExisting:U,pickKind:K,bindable:Z,bindableCount:J,included:ie,commonFields:de,setAll:I,accepts:V,pickField:B,rowProblems:R,commonProblem:G,canApply:ne,apply:Y}=bf({open:e,document:t,control:n,available:r,fieldsFor:s,onApply:o}),H=(L,C,W)=>x.jsx($.TextField,{select:!0,size:"small",label:"Compares",value:L??">=",onChange:M=>C(M.target.value),inputProps:{"aria-label":W},sx:{width:130},children:hf.filter(M=>M.op!=="~").map(M=>x.jsx($.MenuItem,{value:M.op,children:M.label},M.op))});return x.jsx(O.AppDialog,{open:e,onClose:i,title:d?u.label??u.name:"Add a filter",description:d?x.jsxs(x.Fragment,{children:[x.jsxs($.Box,{component:"span",sx:{fontFamily:"ui-monospace, monospace"},children:["$",u.name]}),c?" · 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:x.jsxs(x.Fragment,{children:[d&&x.jsx($.Button,{color:"error",startIcon:x.jsx(O.DeleteOutlineIcon,{}),onClick:()=>a(u.name),sx:L=>({mr:"auto",color:O.dangerTextColor(L)}),children:"Remove filter"}),x.jsx($.Button,{onClick:i,children:"Cancel"}),x.jsx($.Tooltip,{title:ne||T===void 0?"":"A ticked tile has no field, or names one its source does not have.",children:x.jsx("span",{children:x.jsx($.Button,{variant:"contained",onClick:Y,disabled:!ne,children:d?"Apply":"Add filter"})})})]}),children:x.jsxs($.Stack,{sx:{gap:2.5,pt:1},children:[!d&&r.length>0&&x.jsxs($.ToggleButtonGroup,{exclusive:!0,size:"small",value:f.kind,onChange:(L,C)=>{C==="new"?h({kind:"new"}):C==="existing"&&r[0]&&U(r[0])},"aria-label":"Where the filter comes from",children:[x.jsx($.ToggleButton,{value:"new",children:"New in this report"}),x.jsx($.ToggleButton,{value:"existing",children:"From the model"})]}),!d&&f.kind==="existing"?x.jsx($.TextField,{select:!0,size:"small",label:"Filter",value:f.name,onChange:L=>{const C=r.find(W=>W.name===L.target.value);C&&U(C)},children:r.map(L=>x.jsxs($.MenuItem,{value:L.name,children:[L.label??L.name,x.jsxs($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:["$",L.name]})]},L.name))}):null,x.jsxs($.Stack,{direction:"row",sx:{gap:1.5,flexWrap:"wrap"},children:[!S&&x.jsx(Ra,{value:g,onChange:B,fields:de,accepts:V,label:"Field to filter",ariaLabel:"Field to filter",placeholder:"category",autoFocus:!d,error:G!==void 0,helperText:G??(!d&&A?`Declared as $${A}`:void 0),sx:{flex:1,minWidth:200}}),!c&&x.jsx($.TextField,{size:"small",label:"Label",placeholder:A?Kl(A):"",value:p,onChange:L=>m(L.target.value),inputProps:{"aria-label":"Filter label"},sx:{flex:1,minWidth:160}}),D&&!S&&H(q,z,"Comparison")]}),!d&&f.kind==="new"&&x.jsxs($.Stack,{direction:"row",sx:{gap:1.5},children:[x.jsx($.TextField,{select:!0,size:"small",label:"Filter kind",value:b,onChange:L=>K(L.target.value),inputProps:{"aria-label":"Filter kind"},slotProps:{select:{renderValue:L=>Pa.find(C=>C.kind===L)?.label??String(L)}},sx:{flex:1},children:Pa.map(L=>x.jsxs($.MenuItem,{value:L.kind,children:[L.label,x.jsx($.Typography,{component:"span",variant:"caption",sx:{ml:1,opacity:.6},children:L.hint})]},L.kind))}),b==="date"&&x.jsx($.TextField,{size:"small",type:"date",label:"Starts at",value:w,onChange:L=>v(L.target.value),InputLabelProps:{shrink:!0},sx:{flex:1}})]}),x.jsxs($.Box,{children:[x.jsxs($.Stack,{direction:"row",sx:{alignItems:"center",gap:.5},children:[x.jsx($.Checkbox,{size:"small",checked:J>0&&ie===J,indeterminate:ie>0&&ie<J,disabled:J===0,onChange:L=>I(L.target.checked),inputProps:{"aria-label":"All tiles"}}),x.jsxs($.Typography,{variant:"subtitle2",sx:{flex:1},children:["Applies to ",ie," of ",t.tiles.length," tiles"]}),x.jsx($.Button,{size:"small",onClick:()=>{S||_(L=>L.map(C=>({...C,field:g}))),E(L=>!L)},children:S?"Same field for all":"Adjust per tile"})]}),x.jsx($.Stack,{sx:{gap:S?1:0},children:t.tiles.map((L,C)=>{if(!xe(L))return null;const W=y[C],M=L.label??L.name,ee=S?R[C]:void 0;return x.jsxs($.Stack,{direction:"row",sx:{gap:1,alignItems:S?"flex-start":"center",opacity:Z[C]?1:.6},children:[x.jsx($.Checkbox,{size:"small",disabled:!Z[C],checked:(W?.include??!1)&&Z[C],inputProps:{"aria-label":`Filter ${M}`},onChange:X=>P(C,{include:X.target.checked})}),x.jsx($.Typography,{variant:"body2",sx:{flex:1,minWidth:0,pt:S?1:0},noWrap:!0,children:M}),Z[C]?S&&x.jsxs(x.Fragment,{children:[D&&H(W?.op,X=>P(C,{op:X}),`Comparison for ${M}`),x.jsx(Ra,{value:W?.field??"",onChange:X=>P(C,{field:X}),fields:s?.(L),accepts:V,label:"Field",ariaLabel:`Field for ${M}`,disabled:!W?.include,error:ee!==void 0,helperText:ee,sx:{width:220}})]}):x.jsx($.Tooltip,{title:ja(t.tiles[C]).reason,children:x.jsx($.Typography,{variant:"caption",sx:{color:l.tileTitle},children:ja(t.tiles[C]).label})})]},`${L.source}.${L.name}`)})}),ie===0&&x.jsx($.Typography,{variant:"caption",sx:{color:"warning.main",display:"block",mt:1},children:"No tile is ticked, so this control will not appear on the dashboard."})]})]})})}const wf=O.createSvgIcon(x.jsx("path",{d:"M11.71 17.99C8.53 17.84 6 15.22 6 12c0-3.31 2.69-6 6-6 3.22 0 5.84 2.53 5.99 5.71l-2.1-.63C15.48 9.31 13.89 8 12 8c-2.21 0-4 1.79-4 4 0 1.89 1.31 3.48 3.08 3.89zM22 12c0 .3-.01.6-.04.9l-1.97-.59c.01-.1.01-.21.01-.31 0-4.42-3.58-8-8-8s-8 3.58-8 8 3.58 8 8 8c.1 0 .21 0 .31-.01l.59 1.97c-.3.03-.6.04-.9.04-5.52 0-10-4.48-10-10S6.48 2 12 2s10 4.48 10 10m-3.77 4.26L22 15l-10-3 3 10 1.26-3.77 4.27 4.27 1.98-1.98z"}));function Vl(e,t,n,r){const[s,i]=k.useState(void 0);return k.useEffect(()=>{t&&e!==void 0&&i(structuredClone(e))},[t,e]),{draft:s,patch:u=>i(c=>{if(c===void 0)return c;const f=structuredClone(c);return u(f),f}),apply:u=>{if(s===void 0)return;const c=structuredClone(s);u(c),i(c),JSON.stringify(c)!==JSON.stringify(e)&&n(c)},close:()=>{s!==void 0&&e!==void 0&&JSON.stringify(s)!==JSON.stringify(e)&&n(s),r()},discard:()=>i(void 0)}}const _f=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.`,kf="This tile's view is declared on its source, so its chart is set in the model.";function Sf({anchor:e,tile:t,onClose:n,onCommit:r,onRemove:s,removeBlocked:i,onDrills:o,view:a}){const l=k.useId(),{theme:d}=Be.usePublisherTheme(),{draft:u,apply:c,close:f,discard:h}=Vl(t,e!==null,r,n),p=u!==void 0&&xe(u)?u:void 0,m=p!==void 0&&p.declaration.kind!=="inherited",b=g=>c(y=>{xe(y)&&g(y)}),w=k.useRef(void 0),v=e!==null;return k.useEffect(()=>{v&&(w.current=t&&xe(t)?t.chart:void 0)},[v]),x.jsx($.Popover,{open:e!==null&&u!==void 0,anchorEl:e,onClose:f,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{width:320,p:2}}},children:u&&x.jsxs($.Stack,{sx:{gap:1.5},children:[x.jsx($.Typography,{variant:"overline",sx:{color:d.tileTitle,lineHeight:1.5},children:p?`${p.source} → ${p.name}`:`Text · ${u.name}`}),p&&m&&x.jsx(x.Fragment,{children:x.jsx(Di,{state:p.chart??"default",view:a,cellLabel:`${p.source} ${p.name}`,...p.chart==="custom"?{disabledReason:_f(p.chartLines)}:{},onChange:g=>b(y=>{const _=w.current;g===(_??"default")?(_===void 0?delete y.chart:y.chart=_,delete y.chartCarried):(y.chart=g,a?y.chartCarried=a.chart?[a.chart]:[]:delete y.chartCarried)})})}),p&&!m&&x.jsxs(x.Fragment,{children:[x.jsx($.Typography,{variant:"body2",sx:{color:d.tileTitle},children:"Declared on its source, so its title and layout are set in the model. It can still be moved."}),x.jsx(Di,{state:"default",view:a,cellLabel:`${p.source} ${p.name}`,disabledReason:kf,onChange:()=>{}})]}),p?.declaration.kind==="opaque"&&x.jsxs($.Typography,{variant:"body2",sx:{color:d.tileTitle},children:["Its body is ",p.declaration.why,", so a filter has no single place to go. Everything else here is editable."]}),x.jsxs($.Stack,{direction:"row",sx:{justifyContent:"space-between"},children:[m?x.jsx($.Button,{size:"small",startIcon:x.jsx(wf,{}),"aria-haspopup":"dialog",onClick:()=>{f(),o()},children:"Drill"}):x.jsx("span",{}),x.jsx($.Button,{color:"error",size:"small",startIcon:x.jsx(O.DeleteOutlineIcon,{}),"aria-disabled":i!==void 0||void 0,"aria-describedby":i!==void 0?l:void 0,disableRipple:i!==void 0,sx:g=>({color:O.dangerTextColor(g),...i!==void 0?{opacity:.5,cursor:"default"}:{}}),onClick:()=>{i===void 0&&(h(),s())},children:"Delete"})]}),i!==void 0&&x.jsx($.Typography,{id:l,variant:"caption",sx:{color:d.tileTitle},children:i})]})})}function $f({editor:e,catalog:t,columns:n,dashboards:r,bindings:s,tiles:i,drillSource:o,setDrillSource:a,confirmConversion:l,exitDialog:d}){const{filterDialog:u,setFilterDialog:c}=s,{menu:f,setMenu:h}=i,p=f===void 0?void 0:e.document.tiles[f.index],m=p&&xe(p)?p:void 0,b=(()=>{if(!m||!t)return;const w=e.document.sources.find(g=>g.name===m.source)?.base??m.source,v=m.declaration.kind==="reference"?m.declaration.from:m.name;return t.sources.find(g=>g.name===w)?.views.find(g=>g.name===v)})();return x.jsxs(x.Fragment,{children:[x.jsx(xf,{open:u!==void 0,document:e.document,...u?.control?{control:u.control}:{},available:s.available,...t?{fieldsFor:s.fieldsFor}:{},onClose:()=>c(void 0),onApply:s.applyFilter,onRemove:s.dropControl}),x.jsx(Sf,{anchor:f?.anchor??null,tile:f===void 0?void 0:e.document.tiles[f.index],onClose:()=>h(void 0),onCommit:w=>{const v=f?.index;v!==void 0&&e.update(g=>{g.tiles[v]=w})},onRemove:()=>{f!==void 0&&i.removeTile(f.index)},...e.document.tiles.length===1&&e.saved.tiles.length>0?{removeBlocked:"A saved report needs at least one tile."}:{},view:b,onDrills:()=>{a(m?.source)}}),x.jsx(cf,{open:o!==void 0,document:e.document,source:e.document.sources.find(w=>w.name===o),givenNames:s.controlList.map(w=>w.name),dashboards:r??[],onClose:()=>a(void 0),onApply:w=>e.update(v=>{const y=[...(v.drills??[]).filter(_=>_.source!==o),...w];y.length===0?delete v.drills:v.drills=y})}),x.jsx(O.AppDialog,{open:l!==void 0,onClose:()=>l?.stop(),title:"Convert this report?",description:"Saving rewrites this report in the tile layout. The builder cannot take that back; the file's history in your repository can.",actions:x.jsxs(x.Fragment,{children:[x.jsx($.Button,{onClick:()=>l?.stop(),children:"Cancel"}),x.jsx($.Button,{variant:"contained",onClick:()=>l?.go(),children:"Convert and save"})]}),children:null}),x.jsx(O.UnsavedChangesDialog,{...d}),x.jsx(lf,{open:i.addingTile,document:e.document,catalog:t,columns:n,onClose:i.closeAdd,onAdd:i.addTile,onAddText:i.addText})]})}var Tf=Symbol.for("preact-signals");function qs(){if(vt>1)vt--;else{var e,t=!1;for((function(){var s=Ss;for(Ss=void 0;s!==void 0;){var i=s.S;if(i.v===s.v)for(var o=i.t;o!==void 0;o=o.x)o.i===s.i&&(o.i=i.i);s=s.o}})();dr!==void 0;){var n=dr;for(dr=void 0,ks++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Hl(n))try{n.c()}catch(s){t||(e=s,t=!0)}n=r}}if(ks=0,vt--,t)throw e}}function Te(e){if(vt>0)return e();Mi=++Of,vt++;try{return e()}finally{qs()}}var ur,we=void 0;function fe(e){var t=we,n=ur;we=void 0,ur=void 0;try{return e()}finally{we=t,ur=n}}var dr=void 0,vt=0,ks=0,Of=0,Mi=0,Ss=void 0,$s=0;function Ul(e){if(we!==void 0){var t=e.n;if(t===void 0||t.t!==we)return t={i:0,S:e,p:we.s,n:void 0,t:we,e:void 0,x:void 0,r:t},we.s!==void 0&&(we.s.n=t),we.s=t,e.n=t,32&we.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=we.s,t.n=void 0,we.s.n=t,we.s=t),t}}function Ve(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}Ve.prototype.brand=Tf;Ve.prototype.h=function(){return!0};Ve.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:fe(function(){var r;(r=t.W)==null||r.call(t)}))};Ve.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&&fe(function(){var s;(s=t.Z)==null||s.call(t)}))}};Ve.prototype.subscribe=function(e){var t=this;return rt(function(){var n=t.value;fe(function(){return e(n)})},{name:"sub"})};Ve.prototype.valueOf=function(){return this.value};Ve.prototype.toString=function(){return this.value+""};Ve.prototype.toJSON=function(){return this.value};Ve.prototype.peek=function(){var e=this;return fe(function(){return e.value})};Object.defineProperty(Ve.prototype,"value",{get:function(){var e=Ul(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(ks>100)throw new Error("Cycle detected");(function(n){vt!==0&&ks===0&&n.l!==Mi&&(n.l=Mi,Ss={S:n,v:n.v,i:n.i,o:Ss})})(this),this.v=e,this.i++,$s++,vt++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{qs()}}}});function En(e,t){return new Ve(e,t)}function Hl(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 Xl(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 Yl(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 Yt(e,t){Ve.call(this,void 0,t),this.x=e,this.s=void 0,this.g=$s-1,this.f=4}Yt.prototype=new Ve;Yt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===$s))return!0;if(this.g=$s,this.f|=1,this.i>0&&!Hl(this))return this.f&=-2,!0;var e=we;try{Xl(this),we=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 we=e,Yl(this),this.f&=-2,!0};Yt.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)}Ve.prototype.S.call(this,e)};Yt.prototype.U=function(e){if(this.t!==void 0&&(Ve.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)}};Yt.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(Yt.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Ul(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function La(e,t){return new Yt(e,t)}function Zl(e){var t=e.m;if(e.m=void 0,typeof t=="function"){vt++;var n=we;we=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,_o(e),r}finally{we=n,qs()}}}function _o(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Zl(e)}function Ef(e){if(we!==this)throw new Error("Out-of-order effect");Yl(this),we=e,this.f&=-2,8&this.f&&_o(this),qs()}function Cn(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,ur&&ur.push(this)}Cn.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()}};Cn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Zl(this),Xl(this),vt++;var e=we;return we=this,Ef.bind(this,e)};Cn.prototype.N=function(){2&this.f||(this.f|=2,this.u=dr,dr=this)};Cn.prototype.d=function(){this.f|=8,1&this.f||_o(this)};Cn.prototype.dispose=function(){this.d()};function rt(e,t){var n=new Cn(e,t);try{n.c()}catch(s){throw n.d(),s}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var Cf=Object.create,ko=Object.defineProperty,If=Object.defineProperties,Df=Object.getOwnPropertyDescriptor,Af=Object.getOwnPropertyDescriptors,Na=Object.getOwnPropertySymbols,Mf=Object.prototype.hasOwnProperty,Pf=Object.prototype.propertyIsEnumerable,Rf=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),In=e=>{throw TypeError(e)},Pi=(e,t,n)=>t in e?ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,jf=(e,t)=>{for(var n in t||(t={}))Mf.call(t,n)&&Pi(e,n,t[n]);if(Na)for(var n of Na(t))Pf.call(t,n)&&Pi(e,n,t[n]);return e},Lf=(e,t)=>If(e,Af(t)),Fa=(e,t)=>ko(e,"name",{value:t,configurable:!0}),Nf=e=>{var t;return[,,,Cf((t=void 0)!=null?t:null)]},Ql=["class","method","getter","setter","accessor","field","value","get","set"],Hn=e=>e!==void 0&&typeof e!="function"?In("Function expected"):e,Ff=(e,t,n,r,s)=>({kind:Ql[e],name:t,metadata:r,addInitializer:i=>n._?In("Already initialized"):s.push(Hn(i||null))}),Jl=(e,t)=>Pi(t,Rf("metadata"),e[3]),Lt=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},Dn=(e,t,n,r,s,i)=>{var o,a,l,d,u,c=t&7,f=!!(t&8),h=!!(t&16),p=c>3?e.length+1:c?f?1:2:0,m=Ql[c+5],b=c>3&&(e[p-1]=[]),w=e[p]||(e[p]=[]),v=c&&(!h&&!f&&(s=s.prototype),c<5&&(c>3||!h)&&Df(c<4?s:{get[n](){return Qe(this,i)},set[n](y){return Tt(this,i,y)}},n));c?h&&c<4&&Fa(i,(c>2?"set ":c>1?"get ":"")+n):Fa(s,n);for(var g=r.length-1;g>=0;g--)d=Ff(c,n,l={},e[3],w),c&&(d.static=f,d.private=h,u=d.access={has:h?y=>zf(s,y):y=>n in y},c^3&&(u.get=h?y=>(c^1?Qe:Wf)(y,s,c^4?i:v.get):y=>y[n]),c>2&&(u.set=h?(y,_)=>Tt(y,s,_,c^4?i:v.set):(y,_)=>y[n]=_)),a=(0,r[g])(c?c<4?h?i:v[m]:c>4?void 0:{get:v.get,set:v.set}:s,d),l._=1,c^4||a===void 0?Hn(a)&&(c>4?b.unshift(a):c?h?i=a:v[m]=a:s=a):typeof a!="object"||a===null?In("Object expected"):(Hn(o=a.get)&&(v.get=o),Hn(o=a.set)&&(v.set=o),Hn(o=a.init)&&b.unshift(o));return c||Jl(e,s),v&&ko(s,n,v),h?c^4?i:v:s},So=(e,t,n)=>t.has(e)||In("Cannot "+n),zf=(e,t)=>Object(t)!==t?In('Cannot use the "in" operator on this value'):e.has(t),Qe=(e,t,n)=>(So(e,t,"read from private field"),n?n.call(e):t.get(e)),Xn=(e,t,n)=>t.has(e)?In("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Tt=(e,t,n,r)=>(So(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Wf=(e,t,n)=>(So(e,t,"access private method"),n);function Ri(e,t){if(t){let n;return La(()=>{const r=e();return r&&n&&t(n,r)?n:(n=r,r)})}return La(e)}function it(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)=>!it(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(i=>!it(e[i],t[i]))}return!1}function he({get:e},t){return{init(n){return En(n)},get(){return e.call(this).value},set(n){const r=e.call(this);r.peek()!==n&&(r.value=n)}}}function Ee(e,t){const n=new WeakMap;return function(){let r=n.get(this);return r||(r=Ri(e.bind(this)),n.set(this,r)),r.value}}function li(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,Lf(jf({},s),{enumerable:e}))})}}function Dr(...e){const t=e.map(n=>rt(n));return()=>t.forEach(n=>n())}var ec,tc,nc,rc,sc,ic,Ge,$o,ci,ji,Li,ze,To,ui,oc,Ni,Oo,di,Fi,zi;ic=[he],sc=[he],rc=[he],nc=[li()],tc=[li()],ec=[li()];var Zt=class{constructor(e,t=Object.is){this.defaultValue=e,this.equals=t,Lt(Ge,5,this),Xn(this,ze),Xn(this,$o,Lt(Ge,8,this)),Lt(Ge,11,this),Xn(this,To,Lt(Ge,12,this)),Lt(Ge,15,this),Xn(this,Oo,Lt(Ge,16,this)),Lt(Ge,19,this),this.reset=this.reset.bind(this),this.reset()}get current(){return Qe(this,ze,Fi)}get initial(){return Qe(this,ze,ji)}get previous(){return Qe(this,ze,oc)}set current(e){const t=fe(()=>Qe(this,ze,Fi));e&&t&&this.equals(t,e)||Te(()=>{Qe(this,ze,ji)||Tt(this,ze,e,Li),Tt(this,ze,t,Ni),Tt(this,ze,e,zi)})}reset(e=this.defaultValue){Te(()=>{Tt(this,ze,void 0,Ni),Tt(this,ze,e,Li),Tt(this,ze,e,zi)})}};Ge=Nf();$o=new WeakMap;ze=new WeakSet;To=new WeakMap;Oo=new WeakMap;ci=Dn(Ge,20,"#initial",ic,ze,$o),ji=ci.get,Li=ci.set;ui=Dn(Ge,20,"#previous",sc,ze,To),oc=ui.get,Ni=ui.set;di=Dn(Ge,20,"#current",rc,ze,Oo),Fi=di.get,zi=di.set;Dn(Ge,2,"current",nc,Zt);Dn(Ge,2,"initial",tc,Zt);Dn(Ge,2,"previous",ec,Zt);Jl(Ge,Zt);function fi(e){return fe(()=>{const t={};for(const n in e)t[n]=e[n];return t})}var Nt,Bf=class{constructor(){Xn(this,Nt,new WeakMap)}get(e,t){var n;return e?(n=Qe(this,Nt).get(e))==null?void 0:n.get(t):void 0}set(e,t,n){var r;if(e)return Qe(this,Nt).has(e)||Qe(this,Nt).set(e,new Map),(r=Qe(this,Nt).get(e))==null?void 0:r.set(t,n)}clear(e){var t;return e?(t=Qe(this,Nt).get(e))==null?void 0:t.clear():void 0}};Nt=new WeakMap;var Gf=Object.create,ac=Object.defineProperty,qf=Object.getOwnPropertyDescriptor,za=Object.getOwnPropertySymbols,Kf=Object.prototype.hasOwnProperty,Vf=Object.prototype.propertyIsEnumerable,lc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ks=e=>{throw TypeError(e)},Wa=Math.pow,Wi=(e,t,n)=>t in e?ac(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Uf=(e,t)=>{for(var n in t||(t={}))Kf.call(t,n)&&Wi(e,n,t[n]);if(za)for(var n of za(t))Vf.call(t,n)&&Wi(e,n,t[n]);return e},Hf=e=>{var t;return[,,,Gf((t=e?.[lc("metadata")])!=null?t:null)]},cc=["class","method","getter","setter","accessor","field","value","get","set"],uc=e=>e!==void 0&&typeof e!="function"?Ks("Function expected"):e,Xf=(e,t,n,r,s)=>({kind:cc[e],name:t,metadata:r,addInitializer:i=>n._?Ks("Already initialized"):s.push(uc(i||null))}),Yf=(e,t)=>Wi(t,lc("metadata"),e[3]),Zf=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)i[s].call(n);return r},dc=(e,t,n,r,s,i)=>{for(var o,a,l,d,u=t&7,c=!1,f=!1,h=2,p=cc[u+5],m=e[h]||(e[h]=[]),b=(s=s.prototype,qf(s,n)),w=r.length-1;w>=0;w--)l=Xf(u,n,a={},e[3],m),l.static=c,l.private=f,d=l.access={has:v=>n in v},d.get=v=>v[n],o=(0,r[w])(b[p],l),a._=1,uc(o)&&(b[p]=o);return b&&ac(s,n,b),s},fc=(e,t,n)=>t.has(e)||Ks("Cannot "+n),Qf=(e,t,n)=>(fc(e,t,"read from private field"),t.get(e)),Jf=(e,t,n)=>t.has(e)?Ks("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),eh=(e,t,n,r)=>(fc(e,t,"write to private field"),t.set(e,n),n),Je=class Bi{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Bi(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 Bi(t,n)}},ht=class Ft{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:i,height:o,scale:a}=this,l=new Ft(s+t,r+n,i,o);return l.scale=Uf({},a),l}get boundingRectangle(){const{width:t,height:n,left:r,top:s,right:i,bottom:o}=this;return{width:t,height:n,left:r,top:s,right:i,bottom:o}}get center(){const{left:t,top:n,right:r,bottom:s}=this;return new Je((t+r)/2,(n+s)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Ft))return!1;const{left:n,top:r,width:s,height:i}=this;return n===t.left&&r===t.top&&s===t.width&&i===t.height}containsPoint(t){const{top:n,left:r,bottom:s,right:i}=this;return n<=t.y&&t.y<=s&&r<=t.x&&t.x<=i}intersectionArea(t){return t instanceof Ft?th(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 Ft(n,t,r,s)}static delta(t,n,r={x:"center",y:"center"}){const s=(i,o)=>{const a=r[o],l=o==="x"?i.left:i.top,d=o==="x"?i.width:i.height;return a=="start"?l:a=="end"?l+d:l+d/2};return Je.delta({x:s(t,"x"),y:s(t,"y")},{x:s(n,"x"),y:s(n,"y")})}static intersectionRatio(t,n){return Ft.from(t).intersectionRatio(Ft.from(n))}};function th(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),i=Math.min(t.top+t.height,e.top+e.height),o=s-r,a=i-n;return r<s&&n<i?o*a:0}var hc,pc,Gi,ls,Ar,Vs=class extends(Gi=Zt,pc=[Ee],hc=[Ee],Gi){constructor(t){const n=Je.from(t);super(n,(r,s)=>Je.equals(r,s)),Zf(Ar,5,this),Jf(this,ls,0),this.velocity={x:0,y:0}}get delta(){return Je.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=Je.from(t),s={x:r.x-n.x,y:r.y-n.y},i=Date.now(),o=i-Qf(this,ls),a=l=>Math.round(l/o*100);Te(()=>{eh(this,ls,i),this.velocity={x:a(s.x),y:a(s.y)},super.current=r})}reset(t=this.defaultValue){super.reset(Je.from(t)),this.velocity={x:0,y:0}}};Ar=Hf(Gi);ls=new WeakMap;dc(Ar,2,"delta",pc,Vs);dc(Ar,2,"direction",hc,Vs);Yf(Ar,Vs);function qi({x:e,y:t},n){const r=Math.abs(e),s=Math.abs(t);return typeof n=="number"?Math.sqrt(Wa(r,2)+Wa(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 gc=(e=>(e.Horizontal="x",e.Vertical="y",e))(gc||{}),mc=Object.values(gc),nh=Object.create,Eo=Object.defineProperty,rh=Object.defineProperties,sh=Object.getOwnPropertyDescriptor,ih=Object.getOwnPropertyDescriptors,Ts=Object.getOwnPropertySymbols,vc=Object.prototype.hasOwnProperty,yc=Object.prototype.propertyIsEnumerable,bc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),An=e=>{throw TypeError(e)},Ki=(e,t,n)=>t in e?Eo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Co=(e,t)=>{for(var n in t||(t={}))vc.call(t,n)&&Ki(e,n,t[n]);if(Ts)for(var n of Ts(t))yc.call(t,n)&&Ki(e,n,t[n]);return e},Io=(e,t)=>rh(e,ih(t)),Ba=(e,t)=>Eo(e,"name",{value:t,configurable:!0}),xc=(e,t)=>{var n={};for(var r in e)vc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ts)for(var r of Ts(e))t.indexOf(r)<0&&yc.call(e,r)&&(n[r]=e[r]);return n},Mn=e=>{var t;return[,,,nh((t=e?.[bc("metadata")])!=null?t:null)]},wc=["class","method","getter","setter","accessor","field","value","get","set"],Yn=e=>e!==void 0&&typeof e!="function"?An("Function expected"):e,oh=(e,t,n,r,s)=>({kind:wc[e],name:t,metadata:r,addInitializer:i=>n._?An("Already initialized"):s.push(Yn(i||null))}),Qt=(e,t)=>Ki(t,bc("metadata"),e[3]),ae=(e,t,n,r)=>{for(var s=0,i=e[t>>1],o=i&&i.length;s<o;s++)t&1?i[s].call(n):r=i[s].call(n,r);return r},pe=(e,t,n,r,s,i)=>{var o,a,l,d,u,c=t&7,f=!!(t&8),h=!!(t&16),p=c>3?e.length+1:c?f?1:2:0,m=wc[c+5],b=c>3&&(e[p-1]=[]),w=e[p]||(e[p]=[]),v=c&&(!h&&!f&&(s=s.prototype),c<5&&(c>3||!h)&&sh(c<4?s:{get[n](){return Oe(this,i)},set[n](y){return Ye(this,i,y)}},n));c?h&&c<4&&Ba(i,(c>2?"set ":c>1?"get ":"")+n):Ba(s,n);for(var g=r.length-1;g>=0;g--)d=oh(c,n,l={},e[3],w),c&&(d.static=f,d.private=h,u=d.access={has:h?y=>ah(s,y):y=>n in y},c^3&&(u.get=h?y=>(c^1?Oe:_c)(y,s,c^4?i:v.get):y=>y[n]),c>2&&(u.set=h?(y,_)=>Ye(y,s,_,c^4?i:v.set):(y,_)=>y[n]=_)),a=(0,r[g])(c?c<4?h?i:v[m]:c>4?void 0:{get:v.get,set:v.set}:s,d),l._=1,c^4||a===void 0?Yn(a)&&(c>4?b.unshift(a):c?h?i=a:v[m]=a:s=a):typeof a!="object"||a===null?An("Object expected"):(Yn(o=a.get)&&(v.get=o),Yn(o=a.set)&&(v.set=o),Yn(o=a.init)&&b.unshift(o));return c||Qt(e,s),v&&Eo(s,n,v),h?c^4?i:v:s},Do=(e,t,n)=>t.has(e)||An("Cannot "+n),ah=(e,t)=>Object(t)!==t?An('Cannot use the "in" operator on this value'):e.has(t),Oe=(e,t,n)=>(Do(e,t,"read from private field"),n?n.call(e):t.get(e)),ve=(e,t,n)=>t.has(e)?An("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Ye=(e,t,n,r)=>(Do(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),_c=(e,t,n)=>(Do(e,t,"access private method"),n);function kc(e,t){return{plugin:e,options:t}}function Mr(e){return t=>kc(e,t)}function vr(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Sc,yr,Ao,cs;Sc=[he];var We=class{constructor(e,t){this.manager=e,this.options=t,ve(this,Ao,ae(yr,8,this,!1)),ae(yr,11,this),ve(this,cs,new Set)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return fe(()=>this.disabled)}configure(e){this.options=e}registerEffect(e){const t=rt(e.bind(this));return Oe(this,cs).add(t),t}destroy(){Oe(this,cs).forEach(e=>e())}static configure(e){return kc(this,e)}};yr=Mn(null);Ao=new WeakMap;cs=new WeakMap;pe(yr,4,"disabled",Sc,We,Ao);Qt(yr,We);var Pr=class extends We{},us,hi=class{constructor(e){this.manager=e,this.instances=new Map,ve(this,us,[])}get values(){return Array.from(this.instances.values())}set values(e){const t=e.map(vr).reduce((r,s)=>{const i=r.find(({plugin:o})=>o===s.plugin);return i?(i.options=s.options,r):[...r,s]},[]),n=t.map(({plugin:r})=>r);for(const r of Oe(this,us))if(!n.includes(r)){if(r.prototype instanceof Pr)continue;this.unregister(r)}for(const{plugin:r,options:s}of t)this.register(r,s);Ye(this,us,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()}};us=new WeakMap;function lh(e,t){return e.priority===t.priority?e.type===t.type?t.value-e.value:t.type-e.type:t.priority-e.priority}var Ur=[],cn,un,ch=class extends We{constructor(e){super(e),ve(this,cn),ve(this,un),this.computeCollisions=this.computeCollisions.bind(this),Ye(this,un,En(Ur)),this.destroy=Dr(()=>{const t=this.computeCollisions(),n=fe(()=>this.manager.dragOperation.position.current);if(t!==Ur){const r=Oe(this,cn);if(Ye(this,cn,n),r&&n.x==r.x&&n.y==r.y)return}else Ye(this,cn,void 0);Oe(this,un).value=t},()=>{const{dragOperation:t}=this.manager;t.status.initialized&&this.forceUpdate()})}forceUpdate(e=!0){fe(()=>{e?Oe(this,un).value=this.computeCollisions():Ye(this,cn,void 0)})}computeCollisions(e,t){const{registry:n,dragOperation:r}=this.manager,{source:s,shape:i,status:o}=r;if(!o.initialized||!i)return Ur;const a=[],l=[];for(const d of e??n.droppables){if(d.disabled||s&&!d.accepts(s))continue;const u=t??d.collisionDetector;if(!u)continue;l.push(d),d.shape;const c=fe(()=>u({droppable:d,dragOperation:r}));c&&(d.collisionPriority!=null&&(c.priority=d.collisionPriority),a.push(c))}return l.length===0?Ur:(a.sort(lh),a)}get collisions(){return Oe(this,un).value}};cn=new WeakMap;un=new WeakMap;var $c,Tc,Oc,Mo,Ec,ot,Po,mn,Ro,jo;Oc=[he],Tc=[he],$c=[he];var bt=class zt{constructor(t,n){ve(this,Po,ae(ot,8,this)),ae(ot,11,this),ve(this,mn),ve(this,Ro,ae(ot,12,this)),ae(ot,15,this),ve(this,jo,ae(ot,16,this)),ae(ot,19,this);const{effects:r,id:s,data:i={},disabled:o=!1,register:a=!0}=t;let l=s;Ye(this,mn,En(s)),this.manager=n,this.data=i,this.disabled=o,this.effects=()=>{var d;return[()=>{const{id:u,manager:c}=this;if(u!==l)return l=u,c?.registry.register(this),()=>c?.registry.unregister(this)},...(d=r?.())!=null?d:[]]},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=Oe(this,mn).value;return(n=(t=zt.pendingIdChanges)==null?void 0:t.get(this))!=null?n:r}set id(t){var n,r;const s=(r=(n=zt.pendingIdChanges)==null?void 0:n.get(this))!=null?r:Oe(this,mn).peek();t!==s&&(zt.pendingIdChanges||(zt.pendingIdChanges=new Map,queueMicrotask(()=>{var i;return _c(i=zt,Mo,Ec).call(i)})),zt.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)}};ot=Mn(null);Mo=new WeakSet;Ec=function(){const e=bt.pendingIdChanges;bt.pendingIdChanges=null,e&&Te(()=>{for(const[t,n]of e)Oe(t,mn).value=n})};Po=new WeakMap;mn=new WeakMap;Ro=new WeakMap;jo=new WeakMap;pe(ot,4,"manager",Oc,bt,Po);pe(ot,4,"data",Tc,bt,Ro);pe(ot,4,"disabled",$c,bt,jo);ve(bt,Mo);Qt(ot,bt);bt.pendingIdChanges=null;var Us=bt,Ga=class{constructor(){this.map=En(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 i=new Map(n);for(const[a,l]of n)if(l===t&&a!==e){i.delete(a);break}i.set(e,t),this.map.value=i;const o=Dr(...t.effects());return this.cleanupFunctions.set(t,o),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}},Cc,Ic,Dc,Ac,Mc,Pc,Vi,qe,Lo,No,Fo,pt=class extends(Vi=Us,Pc=[he],Mc=[he],Ac=[he],Dc=[Ee],Ic=[Ee],Cc=[Ee],Vi){constructor(t,n){var r=t,{modifiers:s,type:i,sensors:o,plugins:a,effects:l}=r,d=xc(r,["modifiers","type","sensors","plugins","effects"]);super(Io(Co({},d),{effects:()=>{var u;return[...(u=l?.())!=null?u:[],()=>{const{manager:c,plugins:f}=this;if(!(!c||!f))for(const h of f){const{plugin:p}=vr(h);c.registry.plugins.register(p)}}]}}),n),ae(qe,5,this),ve(this,Lo,ae(qe,8,this)),ae(qe,11,this),ve(this,No,ae(qe,12,this)),ae(qe,15,this),ve(this,Fo,ae(qe,16,this,this.isDragSource?"dragging":"idle")),ae(qe,19,this),this.type=i,this.sensors=o,this.modifiers=s,this.alignment=d.alignment,this.plugins=a}pluginConfig(t){if(this.plugins)for(const n of this.plugins){const r=vr(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}};qe=Mn(Vi);Lo=new WeakMap;No=new WeakMap;Fo=new WeakMap;pe(qe,4,"type",Pc,pt,Lo);pe(qe,4,"modifiers",Mc,pt,No);pe(qe,4,"status",Ac,pt,Fo);pe(qe,2,"isDropping",Dc,pt);pe(qe,2,"isDragging",Ic,pt);pe(qe,2,"isDragSource",Cc,pt);Qt(qe,pt);var Rc,jc,Lc,Nc,Fc,zc,Ui,Me,zo,Wo,Bo,Go,qo,gt=class extends(Ui=Us,zc=[he],Fc=[he],Nc=[he],Lc=[he],jc=[he],Rc=[Ee],Ui){constructor(t,n){var r=t,{accept:s,collisionDetector:i,collisionPriority:o,type:a}=r,l=xc(r,["accept","collisionDetector","collisionPriority","type"]);super(l,n),ae(Me,5,this),ve(this,zo,ae(Me,8,this)),ae(Me,11,this),ve(this,Wo,ae(Me,12,this)),ae(Me,15,this),ve(this,Bo,ae(Me,16,this)),ae(Me,19,this),ve(this,Go,ae(Me,20,this)),ae(Me,23,this),ve(this,qo,ae(Me,24,this)),ae(Me,27,this),this.accept=s,this.collisionDetector=i,this.collisionPriority=o,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}};Me=Mn(Ui);zo=new WeakMap;Wo=new WeakMap;Bo=new WeakMap;Go=new WeakMap;qo=new WeakMap;pe(Me,4,"accept",zc,gt,zo);pe(Me,4,"type",Fc,gt,Wo);pe(Me,4,"collisionDetector",Nc,gt,Bo);pe(Me,4,"collisionPriority",Lc,gt,Go);pe(Me,4,"shape",jc,gt,qo);pe(Me,2,"isDropTarget",Rc,gt);Qt(Me,gt);var uh=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)}},dh=class extends uh{constructor(e){super(),this.manager=e}dispatch(e,t){const n=[t,this.manager];super.dispatch(e,...n)}};function ds(e,t=!0){let n=!1;return Io(Co({},e),{cancelable:t,get defaultPrevented(){return n},preventDefault(){t&&(n=!0)}})}var fh=class extends Pr{constructor(e){super(e);const t=(r,s)=>r.map(({id:i})=>i).join("")===s.map(({id:i})=>i).join("");let n=[];this.destroy=Dr(()=>{const{dragOperation:r,collisionObserver:s}=e;r.status.initializing&&(n=[],s.enable())},()=>{const{collisionObserver:r,monitor:s}=e,{collisions:i}=r;if(r.isDisabled()||Us.pendingIdChanges)return;const o=ds({collisions:i});if(s.dispatch("collision",o),o.defaultPrevented||t(i,n))return;n=i;const[a]=i;fe(()=>{var l;a?.id!==((l=e.dragOperation.target)==null?void 0:l.id)&&(r.disable(),e.actions.setDropTarget(a?.id).then(()=>{r.enable()}))})})}},Pn=(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))(Pn||{}),Rn=(e=>(e[e.Collision=0]="Collision",e[e.ShapeIntersection=1]="ShapeIntersection",e[e.PointerIntersection=2]="PointerIntersection",e))(Rn||{}),Wc,Bc,Gc,qc,Kc,Vc,Uc,nt,Ko;Uc=[he],Vc=[Ee],Kc=[Ee],qc=[Ee],Gc=[Ee],Bc=[Ee],Wc=[Ee];var wt=class{constructor(){ae(nt,5,this),ve(this,Ko,ae(nt,8,this,"idle")),ae(nt,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}};nt=Mn(null);Ko=new WeakMap;pe(nt,4,"value",Uc,wt,Ko);pe(nt,2,"current",Vc,wt);pe(nt,2,"idle",Kc,wt);pe(nt,2,"initializing",qc,wt);pe(nt,2,"initialized",Gc,wt);pe(nt,2,"dragging",Bc,wt);pe(nt,2,"dropped",Wc,wt);Qt(nt,wt);var hh=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 fe(()=>{const{dragOperation:t}=this.manager,n=e??null;if(t.targetIdentifier===n)return Promise.resolve(!1);t.targetIdentifier=n;const r=ds({operation:t.snapshot()});return t.status.dragging&&this.manager.monitor.dispatch("dragover",r),this.manager.renderer.rendering.then(()=>r.defaultPrevented)})}start(e){return fe(()=>{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:i}=e;Te(()=>{t.status.set("initialization-pending"),t.shape=null,t.canceled=!1,t.activatorEvent=s??null,t.position.reset(i)});const o=ds({operation:t.snapshot()});return this.manager.monitor.dispatch("beforedragstart",o),o.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"&&Te(()=>{t.status.set("dragging"),this.manager.monitor.dispatch("dragstart",{nativeEvent:s,operation:t.snapshot(),cancelable:!1})})}),r)})}move(e){return fe(()=>{var t,n;const{dragOperation:r}=this.manager,{status:s,controller:i}=r;if(!s.dragging||!i||i.signal.aborted)return;const o=ds({nativeEvent:e.event,operation:r.snapshot(),by:e.by,to:e.to},(t=e.cancelable)!=null?t:!0);((n=e.propagate)==null||n)&&this.manager.monitor.dispatch("dragmove",o),queueMicrotask(()=>{var a,l,d,u,c;if(o.defaultPrevented)return;const f=(c=e.to)!=null?c:{x:r.position.current.x+((l=(a=e.by)==null?void 0:a.x)!=null?l:0),y:r.position.current.y+((u=(d=e.by)==null?void 0:d.y)!=null?u:0)};r.position.current=f})})}stop(e={}){return fe(()=>{var t,n;const{dragOperation:r}=this.manager,{controller:s}=r;if(!s||s.signal.aborted)return;let i;const o=()=>{const l={resume:()=>{},abort:()=>{}};return i=new Promise((d,u)=>{l.resume=d,l.abort=u}),l};s.abort();const a=()=>{this.manager.renderer.rendering.then(()=>{r.status.set("dropped");const l=fe(()=>{var u;return((u=r.source)==null?void 0:u.status)==="dropping"}),d=()=>{r.controller===s&&(r.controller=void 0),r.reset()};if(l){const{source:u}=r,c=rt(()=>{u?.status==="idle"&&(c(),d())})}else this.manager.renderer.rendering.then(d)})};r.canceled=(t=e.canceled)!=null?t:!1,this.manager.monitor.dispatch("dragend",{nativeEvent:e.event,operation:r.snapshot(),canceled:(n=e.canceled)!=null?n:!1,suspend:o}),i?i.then(a).catch(()=>r.reset()):a()})}},_n=class extends We{constructor(e,t){super(e,t),this.manager=e,this.options=t}},ph=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)}},fs,Hc=class{constructor(e){this.options=e,ve(this,fs)}set controller(e){Ye(this,fs,e),e.signal.addEventListener("abort",()=>this.abort())}activate(e){var t;(t=Oe(this,fs))==null||t.activate(e)}};fs=new WeakMap;var qa=class extends We{constructor(e,t){super(e,t),this.manager=e,this.options=t}apply(e){return e.transform}},gh=class{constructor(e){this.draggables=new Ga,this.droppables=new Ga,this.plugins=new hi(e),this.sensors=new hi(e),this.modifiers=new hi(e)}register(e,t){if(e instanceof pt)return this.draggables.register(e.id,e);if(e instanceof gt)return this.droppables.register(e.id,e);if(e.prototype instanceof qa)return this.modifiers.register(e,t);if(e.prototype instanceof _n)return this.sensors.register(e,t);if(e.prototype instanceof We)return this.plugins.register(e,t);throw new Error("Invalid instance type")}unregister(e){if(e instanceof Us)return e instanceof pt?this.draggables.unregister(e.id,e):e instanceof gt?this.droppables.unregister(e.id,e):()=>{};if(e.prototype instanceof qa)return this.modifiers.unregister(e);if(e.prototype instanceof _n)return this.sensors.unregister(e);if(e.prototype instanceof We)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()}},Xc,Yc,Zc,Qc,Jc,eu,tu,nu,ru,Zn,hs,dn,$e,Vo,Uo,Ho,Xo,Yo,Qn;ru=[Ee],nu=[he],tu=[he],eu=[he],Jc=[he],Qc=[he],Zc=[Ee],Yc=[Ee],Xc=[Ee];var ct=class{constructor(e){ae($e,5,this),ve(this,Zn),ve(this,hs),ve(this,dn,new Zt(void 0,(t,n)=>t&&n?t.equals(n):t===n)),this.status=new wt,ve(this,Vo,ae($e,8,this,!1)),ae($e,11,this),ve(this,Uo,ae($e,12,this,null)),ae($e,15,this),ve(this,Ho,ae($e,16,this,null)),ae($e,19,this),ve(this,Xo,ae($e,20,this,null)),ae($e,23,this),ve(this,Yo,ae($e,24,this,[])),ae($e,27,this),this.position=new Vs({x:0,y:0}),ve(this,Qn,{x:0,y:0}),Ye(this,Zn,e)}get shape(){const{current:e,initial:t,previous:n}=Oe(this,dn);return!e||!t?null:{current:e,initial:t,previous:n}}set shape(e){e?Oe(this,dn).current=e:Oe(this,dn).reset()}get source(){var e;const t=this.sourceIdentifier;if(t==null)return null;const n=Oe(this,Zn).registry.draggables.get(t);return n&&Ye(this,hs,n),(e=n??Oe(this,hs))!=null?e:null}get target(){var e;const t=this.targetIdentifier;return t!=null&&(e=Oe(this,Zn).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(Io(Co({},this.snapshot()),{transform:n}));return Ye(this,Qn,n),n}snapshot(){return fe(()=>({source:this.source,target:this.target,activatorEvent:this.activatorEvent,transform:Oe(this,Qn),shape:this.shape?fi(this.shape):null,position:fi(this.position),status:fi(this.status),canceled:this.canceled}))}reset(){Te(()=>{this.status.set("idle"),this.sourceIdentifier=null,this.targetIdentifier=null,Oe(this,dn).reset(),this.position.reset({x:0,y:0}),Ye(this,Qn,{x:0,y:0}),this.modifiers=[]})}};$e=Mn(null);Zn=new WeakMap;hs=new WeakMap;dn=new WeakMap;Vo=new WeakMap;Uo=new WeakMap;Ho=new WeakMap;Xo=new WeakMap;Yo=new WeakMap;Qn=new WeakMap;pe($e,2,"shape",ru,ct);pe($e,4,"canceled",nu,ct,Vo);pe($e,4,"activatorEvent",tu,ct,Uo);pe($e,4,"sourceIdentifier",eu,ct,Ho);pe($e,4,"targetIdentifier",Jc,ct,Xo);pe($e,4,"modifiers",Qc,ct,Yo);pe($e,2,"source",Zc,ct);pe($e,2,"target",Yc,ct);pe($e,2,"transform",Xc,ct);Qt($e,ct);var mh={get rendering(){return Promise.resolve()}};function lt(e,t){return typeof e=="function"?e(t):e??t}var vh=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=lt(r.plugins,[]),i=lt(r.sensors,[]),o=lt(r.modifiers,[]),a=(n=r.renderer)!=null?n:mh,l=new dh(this),d=new gh(this);this.registry=d,this.monitor=l,this.renderer=a,this.actions=new hh(this),this.dragOperation=new ct(this),this.collisionObserver=new ch(this),this.plugins=[fh,...s],this.modifiers=o,this.sensors=i;const{destroy:u}=this,c=Dr(()=>{var f,h,p;const m=fe(()=>this.dragOperation.modifiers),b=this.modifiers;for(const w of m)b.includes(w)||w.destroy();this.dragOperation.modifiers=(p=(h=(f=this.dragOperation.source)==null?void 0:f.modifiers)==null?void 0:h.map(w=>{const{plugin:v,options:g}=vr(w);return new v(this,g)}))!=null?p:b});this.destroy=()=>{c(),u()}}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}},su=e=>{throw TypeError(e)},Zo=(e,t,n)=>t.has(e)||su("Cannot "+n),oe=(e,t,n)=>(Zo(e,t,"read from private field"),t.get(e)),Ue=(e,t,n)=>t.has(e)?su("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Xe=(e,t,n,r)=>(Zo(e,t,"write to private field"),t.set(e,n),n),iu=(e,t,n)=>(Zo(e,t,"access private method"),n);function Hs(e){return e?e instanceof KeyframeEffect?!0:"getKeyframes"in e&&typeof e.getKeyframes=="function":!1}function ou(e,t){const n=e.getAnimations();let r=null;for(const s of n){if(s.playState!=="running")continue;const{effect:i}=s,a=(Hs(i)?i.getKeyframes():[]).filter(t);a.length>0&&(r=[a[a.length-1],s])}return r}function Xs(e){const{width:t,height:n,top:r,left:s,bottom:i,right:o}=e.getBoundingClientRect();return{width:t,height:n,top:r,left:s,bottom:i,right:o}}function Qo(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Rr(e){return"nodeType"in e}function Ze(e){var t,n,r;return e?Qo(e)?e:Rr(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 Jo(e){const{Document:t}=Ze(e);return e instanceof t||"nodeType"in e&&e.nodeType===Node.DOCUMENT_NODE}function At(e){return!e||Qo(e)?!1:e instanceof Ze(e).HTMLElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("html")}function au(e){return e instanceof Ze(e).SVGElement||"namespaceURI"in e&&typeof e.namespaceURI=="string"&&e.namespaceURI.endsWith("svg")}function jn(e){return e?Qo(e)?e.document:Rr(e)?Jo(e)?e:At(e)||au(e)?e.ownerDocument:document:document:document}function yh(e){var t,n,r,s;const{documentElement:i}=jn(e),o=Ze(e).visualViewport,a=(t=o?.width)!=null?t:i.clientWidth,l=(n=o?.height)!=null?n:i.clientHeight,d=(r=o?.offsetTop)!=null?r:0,u=(s=o?.offsetLeft)!=null?s:0;return{top:d,left:u,right:u+a,bottom:d+l,width:a,height:l}}function bh(e,t){if(xh(e)&&e.open===!1)return!1;const{overflow:n,overflowX:r,overflowY:s}=getComputedStyle(e);return n==="visible"&&r==="visible"&&s==="visible"}function xh(e){return e.tagName==="DETAILS"}function br(e,t=e.getBoundingClientRect(),n=0){var r,s,i,o,a;let l=t;const{ownerDocument:d}=e,u=(r=d.defaultView)!=null?r:window;let c=e.parentElement;for(;c&&c!==d.documentElement;){if(!bh(c)){const g=c.getBoundingClientRect(),y=n*(g.bottom-g.top),_=n*(g.right-g.left),S=n*(g.bottom-g.top),E=n*(g.right-g.left);l={top:Math.max(l.top,g.top-y),right:Math.min(l.right,g.right+_),bottom:Math.min(l.bottom,g.bottom+S),left:Math.max(l.left,g.left-E),width:0,height:0},l.width=l.right-l.left,l.height=l.bottom-l.top}c=c.parentElement}const f=u.visualViewport,h=(s=f?.offsetTop)!=null?s:0,p=(i=f?.offsetLeft)!=null?i:0,m=(o=f?.width)!=null?o:u.innerWidth,b=(a=f?.height)!=null?a:u.innerHeight,w=n*b,v=n*m;return l={top:Math.max(l.top,h-w),right:Math.min(l.right,p+m+v),bottom:Math.min(l.bottom,h+b+w),left:Math.max(l.left,p-v),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 kn(e){return{x:e.clientX,y:e.clientY}}var lu=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 ea(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function cu(){var e,t;const n=ea()?window.visualViewport:null;return{x:(e=n?.offsetLeft)!=null?e:0,y:(t=n?.offsetTop)!=null?t:0}}function ta(e){return!e||!Rr(e)?!1:e instanceof Ze(e).ShadowRoot}function Os(e){if(e&&Rr(e)){let t=e.getRootNode();if(ta(t))return t;if(t instanceof Document)return t}return jn(e)}function na(e){return e.matchMedia("(prefers-reduced-motion: reduce)").matches}function wh(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),r=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((i,o)=>{const a=r[o];if(Ka(i)&&Ka(a)&&(i.type!=="file"&&(i.value=a.value),i.type==="radio"&&i.name&&(i.name=`Cloned__${i.name}`)),Va(i)&&Va(a)&&a.width>0&&a.height>0){const l=i.getContext("2d");l?.drawImage(a,0,0)}}),n}function Ka(e){return"value"in e}function Va(e){return e.tagName==="CANVAS"}function uu(e,{x:t,y:n}){const r=e.elementFromPoint(t,n);if(_h(r)){const{contentDocument:s}=r;if(s){const{left:i,top:o}=r.getBoundingClientRect();return uu(s,{x:t-i,y:n-o})}}return r}function _h(e){return e?.tagName==="IFRAME"}var Xi=new WeakMap;function kh(e){return e.closest(`
|
|
2
2
|
input:not([disabled]),
|
|
3
3
|
select:not([disabled]),
|
|
4
4
|
textarea:not([disabled]),
|
package/dist/builder/index.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _, jsxs as K, Fragment as Be } from "react/jsx-runtime";
|
|
2
|
-
import { A as ds, f as Sc, g as Oc, h as Vr, U as nh, i as Gt, M as mt, j as Yo, l as Xo, k as Qt, P as rh, T as us, t as ih, B as Tc, G as Pn, n as Ur, N as Ec, o as Cc, p as sh, q as oh, s as Zo, S as ah, C as lh, u as ch, v as dh, w as Nt, x as uh, y as fh, z as hh, E as ph, F as gh, H as Qo, I as mh, J as vh, K as yh, L as bh, O as Ic, Q as wh, R as xh, V as _h, W as kh, X as $h, Y as Dc, Z as Ac, _ as Pc, $ as Sh, a0 as Mc, a1 as Oh, a2 as Th, a3 as Eh, a4 as Ch, a5 as Ih, a6 as Dh, a7 as Ah, a8 as Ph, a9 as Mh, aa as Rh, ab as Lh, ac as Nh, ad as zh } from "../useCompiledDocument-
|
|
3
|
-
import { ae as Q0, af as J0, ag as ew, ah as tw, ai as nw, aj as rw, ak as iw, al as sw, am as ow, an as aw, ao as lw } from "../useCompiledDocument-
|
|
2
|
+
import { A as ds, f as Sc, g as Oc, h as Vr, U as nh, i as Gt, M as mt, j as Yo, l as Xo, k as Qt, P as rh, T as us, t as ih, B as Tc, G as Pn, n as Ur, N as Ec, o as Cc, p as sh, q as oh, s as Zo, S as ah, C as lh, u as ch, v as dh, w as Nt, x as uh, y as fh, z as hh, E as ph, F as gh, H as Qo, I as mh, J as vh, K as yh, L as bh, O as Ic, Q as wh, R as xh, V as _h, W as kh, X as $h, Y as Dc, Z as Ac, _ as Pc, $ as Sh, a0 as Mc, a1 as Oh, a2 as Th, a3 as Eh, a4 as Ch, a5 as Ih, a6 as Dh, a7 as Ah, a8 as Ph, a9 as Mh, aa as Rh, ab as Lh, ac as Nh, ad as zh } from "../useCompiledDocument-1dgF5CC9.es.js";
|
|
3
|
+
import { ae as Q0, af as J0, ag as ew, ah as tw, ai as nw, aj as rw, ak as iw, al as sw, am as ow, an as aw, ao as lw } from "../useCompiledDocument-1dgF5CC9.es.js";
|
|
4
4
|
import { TextField as st, MenuItem as qt, ListItemText as Jo, Typography as ve, Box as ze, List as Wh, ListItemButton as Fh, Chip as to, Stack as Se, ToggleButtonGroup as ea, ToggleButton as zn, Button as Pe, Checkbox as no, Tooltip as zt, Autocomplete as Bh, Popover as jh, InputBase as Gh, IconButton as Wi, SvgIcon as qh, Divider as Is, Alert as ht } from "@mui/material";
|
|
5
5
|
import { useId as Rc, useMemo as ue, useState as U, useEffect as ye, useRef as J, createElement as Kh, useLayoutEffect as Fi, useCallback as he, useInsertionEffect as Vh, createContext as Lc, memo as Uh, forwardRef as Hh, startTransition as Yh, useImperativeHandle as Xh, useContext as Nc } from "react";
|
|
6
|
-
import {
|
|
6
|
+
import { b4 as rt, b5 as ta } from "../ServerProvider-CQy4jVYK.es.js";
|
|
7
7
|
import { i as na, a as zc, m as Zh, b as Qh, t as Jh, c as Wc, s as Fc, d as ep, e as Bc, f as fs, g as jc, A as Gc, h as tp, r as np, j as hl, k as rp, l as ra } from "../text-entry-72YFLeNk.es.js";
|
|
8
8
|
import { flushSync as ip } from "react-dom";
|
|
9
9
|
import { parseTag as sp } from "@malloydata/malloy-tag";
|