import{ay as S,az as w,r as h,A as k,j as l,w as C,J as L}from"./index-G4l7qcMm.js";import{B as g,e as Q}from"./browse-Ypk-yEjt.js";import{G as x,S as D,r as E}from"./index.esm-Dfo1uwtt.js";import{h as M}from"./Input-BJwdycW3.js";function $(e,a,t,r,n){const[s,m]=h.useState(()=>n&&t?t(e).matches:r?r(e).matches:a);return k(()=>{let u=!0;if(!t)return;const i=t(e),o=()=>{u&&m(i.matches)};return o(),i.addListener(o),()=>{u=!1,i.removeListener(o)}},[e,t]),s}const y=h.useSyncExternalStore;function A(e,a,t,r,n){const s=h.useCallback(()=>a,[a]),m=h.useMemo(()=>{if(n&&t)return()=>t(e).matches;if(r!==null){const{matches:c}=r(e);return()=>c}return s},[s,e,r,n,t]),[u,i]=h.useMemo(()=>{if(t===null)return[s,()=>()=>{}];const c=t(e);return[()=>c.matches,d=>(c.addListener(d),()=>{c.removeListener(d)})]},[s,t,e]);return y(i,u,m)}function b(e,a={}){const t=S(),r=typeof window<"u"&&typeof window.matchMedia<"u",{defaultMatches:n=!1,matchMedia:s=r?window.matchMedia:null,ssrMatchMedia:m=null,noSsr:u=!1}=w({name:"MuiUseMediaQuery",props:a,theme:t});let i=typeof e=="function"?e(t):e;return i=i.replace(/^@media( ?)/m,""),(y!==void 0?A:$)(i,n,s,m,u)}const B=e=>{const a=(s,m)=>{e.setValue(m)},t=s=>{e.setValue(s.target.value===""?e.value:Number(s.target.value))},r=()=>{e.value<e.min?e.setValue(e.min):e.value>e.max&&e.setValue(e.max)},n=[{value:e.min,label:e.min},{value:e.max,label:e.max}];return l.jsx(g,{children:l.jsxs(x,{container:!0,spacing:2,alignItems:"center",children:[l.jsx(x,{item:!0,xs:!0,children:l.jsx(D,{getAriaLabel:()=>"Array slice range",value:e.value,min:e.min,max:e.max,marks:n,onChange:a,valueLabelDisplay:"auto"})}),l.jsx(x,{item:!0,children:l.jsx(M,{value:e.value,size:"small",onChange:t,onBlur:r,inputProps:{step:1,min:e.min,max:e.max,type:"number","aria-labelledby":"min-input-slider"}})})]})})},U=e=>{const a=e.structure.shape,t=a.length,r=a.slice(0,t-2).map(d=>Math.floor(d/2)),n=Q(),s=b(n.breakpoints.down("sm")),m=b(n.breakpoints.down("md"));let u;s?u=n.breakpoints.values.sm:m?u=n.breakpoints.values.md:u=n.breakpoints.values.lg;const i=Math.ceil(Math.max(...a.slice(t-2,t))/u),[o,c]=h.useState(r);return l.jsxs(g,{children:[l.jsx(I,{link:e.link,cuts:o,stride:i}),a.length>2?l.jsxs(C,{id:"input-slider",gutterBottom:!0,children:["Choose a planar cut through this ",a.length,"-dimensional array."]}):"",i!==1?l.jsxs(L,{severity:"info",children:["This large array has been downsampled by a factor of ",i,".",l.jsx("br",{}),'Use the "Download" tab to access a full-resolution image.']}):"",a.slice(0,t-2).map((d,f)=>d>1?l.jsx(B,{min:0,max:d-1,value:o[f],setValue:E(j=>{const v=o.slice();v[f]=j,c(v)},100,{maxWait:200})},`slider-${f}`):"")]})},I=e=>{let a;return a=`${e.link}?format=image/png&slice=${e.cuts.join(",")}`,e.stride!==1&&(a=a.concat(`,::${e.stride},::${e.stride}`)),l.jsx(g,{component:"img",sx:{maxWidth:1},alt:"Data rendered",src:a,loading:"lazy"})};export{U as default};
