var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,i=(t,n,s)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s,o=(e,t)=>{for(var n in t||(t={}))a.call(t,n)&&i(e,n,t[n]);if(s)for(var n of s(t))l.call(t,n)&&i(e,n,t[n]);return e},r=(e,s)=>t(e,n(s)),c=(e,t)=>{var n={};for(var i in e)a.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&s)for(var i of s(e))t.indexOf(i)<0&&l.call(e,i)&&(n[i]=e[i]);return n};import{q as d,e as m,r as u,z as h,u as p,R as g,C as f,a as b,b as y,m as v,v as x,c as w,d as k,l as E,f as S,h as L,g as T,i as Z,j as C,k as P,n as R,o as I,p as W,s as M,t as X,w as N,S as G,_ as Y,M as V,x as F,G as K,y as D,A as O,B as z,D as H,E as U,K as j,F as A,H as B,I as J,J as _,L as Q,N as $,O as q,P as ee,Q as te,T as ne,U as se,V as ae,W as le,X as ie,Y as oe,Z as re,$ as ce,a0 as de,a1 as me,a2 as ue,a3 as he,a4 as pe,a5 as ge,a6 as fe,a7 as be,a8 as ye,a9 as ve,aa as xe,ab as we,ac as ke,ad as Ee,ae as Se,af as Le,ag as Te,ah as Ze,ai as Ce,aj as Pe,ak as Re,al as Ie,am as We,an as Me,ao as Xe,ap as Ne,aq as Ge,ar as Ye,as as Ve,at as Fe,au as Ke,av as De,aw as Oe,ax as ze,ay as He,az as Ue,aA as je,aB as Ae,aC as Be,aD as Je,aE as _e,aF as Qe,aG as $e}from"./vendor.4f1feadd.js";const qe=d("div")`
  position: fixed;
  z-index: 10000;
  width: 0 auto;
  bottom: ${e=>e.top?"unset":"2em"};
  margin: 0 auto;
  right: 2em;
  font-weight: bold;
  display: flex;
  flex-direction: ${e=>e.top?"column-reverse":"column"};
  align-items: ${e=>"center"===e.position?"center":`flex-${e.position||"end"}`};
  @media (max-width: 680px) {
    align-items: center;
  }
`,et=d(m.div)`
  margin-top: 1em;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  width: 40ch;
  @media (max-width: 680px) {
    width: 100%;
  }
`,tt=d.p`
  margin-bottom: 1.5em;
  color: ${({theme:e})=>e.fontDark};
`,nt=d.h3`
  font-size: 1.5em;
  color: ${({theme:e})=>e.font};
`,st=d.div`
  color: ${({theme:e})=>e.font};
  background: ${({theme:e})=>e.backgroundDark};
  border: 1px solid ${({theme:e})=>e.backgroundDarkBorder};
  box-shadow: 0 2px 40px ${({theme:e})=>e.backgroundDark};
  padding: 1em 2em 0 2em;
  font-size: 1em;
  overflow: hidden;
  height: auto;
  border-radius: 3px;
`,at=d.button`
  cursor: pointer;
  outline: 0;
  border: none;
  background: transparent;
  display: flex;
  align-self: flex-end;
  position: abo
  overflow: hidden;
  margin: 0;
  padding: 0;
  padding-bottom: 2em;
  color: ${({theme:e})=>e.fontDark};
  :hover {
    color: ${({theme:e})=>e.font};
  }
`,lt=d.div`
  display: flex;
  justify-content: space-between;
`,it=m(d.div`
  position: absolute;
  bottom: ${e=>e.top?"0.5em":"0"};
  left: 0px;
  width: auto;
  border-bottom-left-radius: 3px;
  border-bottom-right-radius: 3px;
  background-image: linear-gradient(
    130deg,
    ${({theme:e})=>e.brand},
    ${({theme:e})=>e.brandFullyTransparent}
  );
  height: 0.5em;
`);let ot=0;const rt={"Server Error":!1,"Dataset Created":!0},ct={"Server Error":"error","Dataset Created":"font"},dt=({config:e={tension:125,friction:20,precision:.1},children:t})=>{const n=u.exports.useContext(h),[s]=u.exports.useState((()=>new WeakMap)),[a]=u.exports.useState((()=>new WeakMap)),[l,i]=u.exports.useState([]),r=p(l,(e=>e.key),{from:{opacity:0,height:0,life:"100%"},enter:e=>async t=>{await t({opacity:1,height:s.get(e).offsetHeight})},leave:e=>async(t,n)=>{a.set(e,n),await t({life:"0%"}),await t({opacity:0}),await t({height:0}),e.onClose&&e.onClose()},onRest:e=>i((t=>t.filter((t=>t.key!==e.key)))),config:(t,n)=>"leave"===n?[{duration:rt[t.kind]?3e3:Number.POSITIVE_INFINITY},e,e]:e});return u.exports.useEffect((()=>t((e=>{const t=o({key:ot++},e);return i((e=>[...e,t])),()=>{t.onClose&&t.onClose(),a.has(t)&&a.get(t)()}}))),[]),g.createElement(qe,null,r.map((e=>{var{key:t,item:l,props:i}=e,o=i,{life:r}=o,d=c(o,["life"]);return g.createElement(et,{key:t,style:d},g.createElement(st,{ref:e=>e&&s.set(l,e)},g.createElement(it,{style:{right:r}}),g.createElement(lt,null,g.createElement(nt,{style:{color:n[ct[l.kind]]}},l.kind),g.createElement(at,{onClick:e=>{e.stopPropagation(),e.preventDefault(),a.has(l)&&a.get(l)()}},g.createElement(f,null))),g.createElement(tt,null,l.message),l.app_items&&l.app_items.map(((e,t)=>g.createElement(tt,{key:t},e))),l.children&&l.children))})))},mt=d.div`
  background-color: transparent;
  border: none;
  padding: 0.27rem 0.5rem 0.5rem 0;
  color: ${({theme:e})=>e.brand};
  height: 1rem;
  border: none;
  font-weight: bold;
`,ut=b({key:"modal",default:null}),ht=y({key:"sortFilterResults",default:{count:!0,asc:!1}}),pt=y({key:"cropToContent",default:!0}),gt=b({key:"fullscreen",default:!1}),ft=b({key:"connected",default:!1}),bt=b({key:"closeTeams",default:null}),yt=b({key:"teamsSubmitted",default:{submitted:!1,minimized:!1}}),vt=b({key:"activePlot",default:"labels"}),xt=b({key:"datasetStatsRaw",default:{view:null,stats:[]}}),wt=b({key:"extendedDatasetStatsRaw",default:{view:null,stats:[],filters:null}}),kt=b({key:"loading",default:!1}),Et=y({key:"tagging",default:!1}),St=b({key:"stateDescription",default:{}}),Lt=b({key:"selectedSamples",default:new Set}),Tt=b({key:"hiddenLabels",default:{}});b({key:"stageInfo",default:void 0});const Zt=b({key:"sidebarVisible",default:!0}),Ct=b({key:"viewCounter",default:0}),Pt=y({key:"colorByLabel",default:!1}),Rt=y({key:"alpha",default:.7}),It=b({key:"colorPool",default:[]}),Wt=y({key:"colorSeed",default:1}),Mt=b({key:"appTeamsIsOpen",default:!1}),Xt=b({key:"savedLookerOptions",default:{}}),Nt=["Classifications","Detections","Keypoints","Polylines","TemporalDetections"],Gt=["Detections","Polylines"],Yt=["TemporalDetection","TemporalDetections"],Vt=["Classifications","Detections","Keypoints","Polylines"],Ft=["Classification","Classifications","Regression","TemporalDetection","TemporalDetections","Detection","Detections","Keypoint","Keypoints","Polyline","Polylines","Heatmap","Segmentation"],Kt=["Classification","Classifications","Detection","Detections","Keypoints","Keypoint","Polylines","Polyline","Regression","TemporalDetection","TemporalDetections"],Dt=["Classification","Classifications","Detection","Detections","Keypoint","Keypoints","Polyline","Polylines","Regression","TemporalDetection","TemporalDetections"],Ot=["TemporalDetection","TemporalDetections"],zt=["Classifications","Detections","Keypoints","Polylines","TemporalDetections"],Ht=["TemporalDetection","TemporalDetections"],Ut={Classifications:"classifications",Detections:"detections",Keypoints:"keypoints",Polylines:"polylines",TemporalDetections:"detections"},jt="Bounds",At="Count",Bt="CountValues",Jt="fiftyone.core.fields.DateField",_t="fiftyone.core.fields.DateTimeField",Qt="fiftyone.core.fields.FloatField",$t="fiftyone.core.fields.FrameNumberField",qt="fiftyone.core.fields.FrameSupportField",en="fiftyone.core.fields.IntField",tn="fiftyone.core.fields.ObjectIdField",nn="fiftyone.core.fields.StringField",sn="fiftyone.core.fields.ListField",an=[qt,sn],ln=["fiftyone.core.fields.BooleanField",Jt,_t,Qt,$t,qt,en,tn,nn],on=[Jt,_t,Qt,$t,qt,en],rn=["_id","_rand","_media_type","metadata","tags","frames"],cn=[{name:"Size (bytes)",key:"size_bytes"},{name:"Type",key:"mime_type"},{name:"Media type",key:"_media_type"},{name:"Dimensions",value:e=>{if(!isNaN(e.width)&&!isNaN(e.height))return`${e.width} x ${e.height}`}},{name:"Channels",key:"num_channels"}];const dn=()=>window.process&&window.process.versions&&Boolean(window.process.versions.electron),mn=(e,t,n="middle")=>{if(e.length<=t)return e;const s=n.toLowerCase();if("first"===s)return"..."+e.slice(-(t-3));if("middle"===s){const n=Math.ceil(.5*(t-3)),s=Math.floor(.5*(t-3));return e.slice(0,n)+"..."+e.slice(-s)}if("last"===s)return e.slice(0,t-3)+"...";throw new Error(`Unsupported mode '${n}'`)},un=(e,t=!0,n=27)=>"string"==typeof e?t?mn(e,n):e:"number"==typeof e?Number(e.toFixed(3)).toLocaleString():!0===e?"True":!1===e?"False":[void 0,null].includes(e)?"None":Array.isArray(e)?(e=`[${e.join(", ")}]`,t?mn(e,n):e):null,hn=(e,t,n)=>e===t?0:null===e?1:null===t?-1:e>t?n?1:-1:n?-1:1,pn=e=>e.metadata&&e.metadata.mime_type||v.getType(e.filepath)||"image/jpg",gn=(e,t)=>{const n="2-digit",s={timeZone:t,year:"numeric",day:n,month:n,hour:n,hour12:!1,minute:n,second:n,fractionalSecondDigits:3};return e%1e3||delete s.fractionalSecondDigits,e%864e5||(delete s.second,delete s.minute,delete s.hour),new Intl.DateTimeFormat("en-ZA",s).format(e).replaceAll("/","-").replace(", "," ").replace(",",".")},fn=(()=>{const e="2-digit";let t="en-ZA";const n=36e5,s=24*n;return(a,l,i)=>{const o=Math.abs(l-i);let r={timeZone:a,hour12:!1},c={timeZone:a,hour12:!1};return l%s==0&&i%s==0?(r=null,c={year:"numeric",month:e,day:e},t="en-CA"):o<1e3?(r={year:"numeric",day:e,month:e},c={hour:e,minute:e,second:e,fractionalSecondDigits:3},t="en-ZA"):o<6e4?(r={year:"numeric",day:e,month:e,hour:e,minute:e},c={second:e,fractionalSecondDigits:3},t="en-ZA"):o<n?(r={year:"numeric",day:e,month:e},c={hour:e,minute:e,second:e},t="en-ZA"):(r=null,c={year:"numeric",month:e,day:e,hour:e,minute:e,second:e},t="en-ZA"),[r?new Intl.DateTimeFormat(t,r):null,new Intl.DateTimeFormat(t,c)]}})();const bn=new URLSearchParams(window.location.search).get("notebook"),yn=new URLSearchParams(window.location.search).get("fiftyoneColab"),vn=new URLSearchParams(window.location.search).get("handleId"),xn=x(),wn=window.location.host,kn=dn()?parseInt({}.FIFTYONE_SERVER_PORT)||5151:parseInt(window.location.port),En=dn()?"localhost":window.location.hostname,Sn=dn()?`http://${En}:${kn}`:window.location.protocol+"//"+wn,Ln=dn()?`ws://${En}:${kn}/state`:`${"https:"===window.location.protocol?"wss:":"ws:"}//${wn}/state`,Tn=dn()?"desktop":yn?"colab":bn?"notebook":"browser";var Zn=yn?new class{constructor(e){this.events={},this.readyState=WebSocket.CONNECTING,this.openTimeout=2e3,this.timeout=2e3,this.location=e,this.connect()}connect(){this.gather(),this.interval=setInterval((()=>this.gather()),this.timeout)}execute(e){[WebSocket.CLOSED,WebSocket.CONNECTING].includes(this.readyState)&&(this.events.open.forEach((e=>e(null))),this.timeout=this.openTimeout,clearInterval(this.interval),this.interval=setInterval((()=>this.gather()),this.timeout)),this.readyState=WebSocket.OPEN,e.forEach((e=>{fetch(this.location+"&mode=pull",{method:"post",body:JSON.stringify(e)}).then((e=>e.json())).then((e=>{this.events.message.forEach((t=>t({data:JSON.stringify(e)})))}))}))}gather(){fetch(this.location).then((e=>e.json())).then((({messages:e})=>this.execute(e))).catch((()=>{this.readyState===WebSocket.OPEN&&this.events.close&&this.events.close.forEach((e=>e(null))),this.readyState=WebSocket.CLOSED,clearInterval(this.interval),this.timeout=Math.min(2*this.timeout,5e3),this.interval=setInterval((()=>this.gather()),this.timeout)}))}addEventListener(e,t){this.events[e]||(this.events[e]=new Set),this.events[e].add(t)}removeEventListener(e,t){this.events[e].delete(t)}send(e){fetch(this.location+"&mode=push",{method:"post",body:e}).then((e=>e.json())).then((e=>{const{messages:t,type:n}=e;t&&this.execute(t),n&&this.events.message.forEach((t=>t({data:JSON.stringify(e)})))}))}}(`${Sn}/polling?sessionId=${xn}`):new w(Ln);const Cn=(e,t)=>JSON.stringify(r(o({},t),{type:e})),Pn=({type:e,args:t,uuid:n,responseType:s})=>new Promise((a=>{const l=((e,t)=>({data:n})=>{(n=JSON.parse(n)).type===e&&t(n)})(s||e,(e=>{var t=e,{uuid:s}=t,i=c(t,["uuid"]);n===s&&(Zn.removeEventListener("message",l),a(i))}));Zn.addEventListener("message",l),Zn.send(Cn(e,r(o({},t),{uuid:n})))})),Rn=e=>JSON.stringify(e.map((({kwargs:e,_cls:t})=>({kwargs:e.filter((e=>!e[0].startsWith("_"))),_cls:t})))),In=(e,t)=>Rn(e)===Rn(t),Wn="hsl(210, 11%, 11%)",Mn="hsl(210, 11%, 15%)",Xn="hsl(210, 5%, 24%)",Nn={background:"hsl(214, 7%, 19%)",backgroundDark:Mn,backgroundDarker:Wn,backgroundLight:Xn,backgroundLightBorder:Mn,backgroundDarkBorder:Wn,backgroundTransparent:"hsla(214, 7%, 19%, 0.5)",border:"hsl(200, 2%, 37%)",borderLight:Xn,button:"hsl(200, 2%, 37%)",buttonBorder:Xn,overlay:"hsla(208, 7%, 46%, 0.7)",overlayButton:"hsla(208, 7%, 46%, 0.3)",overlayButtonHover:"hsla(208, 7%, 46%, 0.7)",menuBackground:Mn,menuBorder:Wn,darkShadow:"hsla(0, 0%, 0%, 0.16)",darkerShadow:"hsla(0, 0%, 0%, 0.25)",brand:"hsl(27, 95%, 49%)",brandDark:"hsl(27, 95%, 45%)",brandTransparent:"hsla(27, 95%, 49%, 0.4)",brandMoreTransparent:"hsla(27, 95%, 49%, 0.1)",brandFullyTransparent:"hsla(27, 95%, 49%, 0)",font:"hsl(0, 0%, 100%)",fontDark:"hsl(220, 2%, 68%)",fontDarkest:"hsl(230, 3%, 60%)",secondary:"hsl(213, 100%, 53%)",secondaryLight:"hsl(211, 85%, 92%)",error:"hsl(0, 87%, 53%)"};r(o({},Nn),{background:"hsl(0, 0%, 100%)",border:"hsl(0, 0%, 85%)",font:"hsl(0, 0%, 20%)"});const Gn=new Set(["-inf","inf","nan"]),Yn=["Classification","Classifications","Regression"],Vn=["Classification","Classifications","Regression","TemporalDetection","TemporalDetections"],Fn={Classifications:"classifications",Detections:"detections",Keypoints:"Keypoints",Polylines:"polylines",TemporalDetections:"detections"},Kn=new Set(["Detection","Segmentation"]),Dn="Click to select sample, Shift+Click to select a range",On={keyColor:"rgb(138, 138, 138)",numberColor:"rgb(225, 100, 40)",stringColor:"rgb(238, 238, 238)",nullColor:"rgb(225, 100, 40)",trueColor:"rgb(225, 100, 40)",falseColor:"rgb(225, 100, 40)"},zn=(()=>{let e=new ArrayBuffer(4),t=new Uint32Array(e),n=new Uint8Array(e);return t[0]=3405691582,202===n[0]})(),Hn=new Blob([atob(" ")],{type:"text/javascript;charset=utf-8"});function Un(){const e=(window.URL||window.webkitURL).createObjectURL(Hn);try{return new Worker(e)}finally{(window.URL||window.webkitURL).revokeObjectURL(e)}}function jn(e,t,n,s){return Math.sqrt((n-e)*(n-e)+(s-t)*(s-t))}function An(e,t,n,s){return e*n+t*s}function Bn([e,t],[n,s],[a,l]){const i=jn(n,s,a,l),[o,r]=function(e,t,n,s,a,l){const i=a-n,o=l-s,r=An(e-n,t-s,i,o)/An(i,o,i,o);return[r*i+n,r*o+s]}(e,t,n,s,a,l);return jn(n,s,o,r)<i&&jn(a,l,o,r)<i?jn(e,t,o,r):Math.min(jn(e,t,n,s),jn(e,t,a,l))}const Jn=e=>{if(0===e.length)return[0,0,1,1];let t=Math.min(...e.map((([e])=>e))),n=Math.min(...e.map((([e,t])=>t))),s=Math.max(...e.map((([e])=>e)))-t,a=Math.max(...e.map((([e,t])=>t)))-n;return 0===s&&(t-=.05,s=.1),0===a&&(n-=.05,a+=.1),[t,n,s,a]},_n=([e,t],[n,s,a,l])=>{if(e/t>a/l){const n=a*t/e;s+=(l-n)/2,l+=n-l}else{const s=l*e/t;n+=(a-s)/2,a+=s-a}return[n,s,a,l]},Qn=e=>{const{top:t,left:n,width:s,height:a}=e.getBoundingClientRect();return[n,t,s,a]},$n=([e,t],[n,s])=>e/t<n/s?e/n:t/s,qn=(e,t,[n,s],[a,l],i=!0)=>{const o=n*e,r=s*e,c=a/l;n/s<c?l=(a=o*(i?1.1:1))/c:a=(l=r*(i?1.1:1))*c;const d=(r-l)/2-Math.max((s-l)/2,0);if(l>s){t[1]>-d&&(t[1]=-d);const e=-d-l;t[1]-s<e&&(t[1]-=t[1]-s-e)}else t[1]=-d;const m=(o-a)/2-Math.max((n-a)/2,0);if(a>n){t[0]>-m&&(t[0]=-m);const e=-m-a;t[0]-n<e&&(t[0]-=t[0]-n-e)}else t[0]=-m;return t},es=([e,t],[n,s],a,l)=>{const i=$n([e,t],[n,s]);return e*e/(n*i*a)<16&&(a=e*e/(n*i*16)),t*t/(s*i*a)<16&&(a=t*t/(s*i*16)),Math.max(a,1-l)},ts=(e,t)=>{const n=(e,t)=>Array.isArray(t)||t instanceof Function?t:"object"!=typeof t?void 0===t?e:t:null===t?t:k(n,e,t);return k(n,e,t)},ns=e=>{const t=new Un;return e?(t.addEventListener("message",(n=>{var{data:s}=n,a=s,{method:l}=a,i=c(a,["method"]);l in e&&e[l].forEach((e=>e(t,i)))})),t):t},ss=(e,t)=>t.reduce(((t,n)=>n[0]<=e&&n[1]>=e?n[0]===n[1]?t:n[0]===e?[...t,[e+1,n[1]]]:n[1]===e?[...t,[n[0],e-1]]:[...t,[n[0],e-1],[e+1,n[1]]]:[...t,n]),[]),as=(e,t)=>{(t=[...t]).push(e),t.sort(((e,t)=>e[0]-t[0]));let n=0;for(;n<t.length-1;){var s=t[n],a=t[n+1];s[1]>=a[0]-1?(s[1]=Math.max(s[1],a[1]),t.splice(n+1,1)):n++}return t},ls=(()=>{let e=null;return()=>(null==e&&(e=window.devicePixelRatio?window.devicePixelRatio:1),e)})(),is=()=>window.process&&window.process.versions&&Boolean(window.process.versions.electron),os=window.location.host,rs=is()?parseInt({}.FIFTYONE_SERVER_PORT)||5151:parseInt(window.location.port);class cs{constructor(e,t,n){if(this.children=[],this.events={},this.isShown(e)){this.element=this.createHTMLElement(t,n);for(const[e,s]of Object.entries(this.getEvents()))this.events[e]=e=>s({event:e,update:t,dispatchEvent:n}),this.element&&this.element.addEventListener(e,this.events[e])}}applyChildren(e){this.children=e||[]}isShown(e){return!0}render(e,t){const n=this.renderSelf(e,t);return this.children.forEach((s=>{if(!s.isShown(e.config))return;const a=s.render(e,t);a&&a.parentNode!==this.element&&n&&n.appendChild(a)})),n}getEvents(){return{}}removeEvents(){for(const[e,t]of Object.entries(this.events))this.element.removeEventListener(e,t)}attachEvents(){for(const[e,t]of Object.entries(this.events))this.element.addEventListener(e,t)}}const ds=(e,t=!1)=>(n,s)=>{if((!n.options.showTooltip||n.config.thumbnail||n.disableOverlays)&&!t)return;let a=s.length&&s[0].containsPoint(n)&&!t?s[0].getPointInfo(n):null;n.frameNumber&&a&&(a.frameNumber=n.frameNumber),e("tooltip",a?r(o({},a),{coordinates:n.cursorCoordinates}):null)},ms=function(e,t){const n=document.createElement("label");n.classList.add("_lookerLabel_rilxo_10"),n.innerHTML=e;const s=document.createElement("input");s.setAttribute("type","checkbox"),s.checked=t;const a=document.createElement("span");return a.classList.add("_lookerCheckbox_rilxo_18"),n.appendChild(s),n.appendChild(a),[n,s]},us="_invisible_m8b2r_16";class hs extends cs{constructor(){super(...arguments),this.width=0,this.height=0,this.mousedown=!1,this.hideControlsTimeout=null,this.start=[0,0],this.wheelTimeout=null,this.hide=!0}getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{t({showOptions:!1},((t,s)=>{if(t.config.thumbnail||t.disableOverlays)return;let a=!1;if(this.mousedownCoordinates&&(a=e.pageX!==this.mousedownCoordinates[0]||e.pageY!==(null==this?void 0:this.mousedownCoordinates[1])),!a&&s.length){const e=s[0];e.containsPoint(t)&&n("select",e.getSelectData(t))}}))},mouseleave:({dispatchEvent:e})=>{this.mousedown=!1,e("tooltip",null)},mousemove:({event:e,update:t,dispatchEvent:n})=>{this.hideControlsTimeout&&clearTimeout(this.hideControlsTimeout),this.hideControlsTimeout=setTimeout((()=>t((({showOptions:e,hoveringControls:t})=>(this.hideControlsTimeout=null,e||t?{}:{showControls:!1})))),3500),t((t=>{if(t.config.thumbnail)return{};const n={cursorCoordinates:[e.pageX,e.pageY],rotate:0,showControls:!0};return this.mousedown?(n.pan=this.getPan([e.pageX,e.pageY]),n.panning=!0,n):n}),ds(n))},mousedown:({event:e,update:t})=>{t((({config:{thumbnail:t},pan:[n,s]})=>(t||(e.preventDefault(),this.mousedown=!0,this.mousedownCoordinates=[e.pageX,e.pageY],this.start=[e.pageX-n,e.pageY-s]),{})))},mouseup:({event:e,update:t})=>{t((t=>(this.mousedown=!1,t.config.thumbnail||!t.panning?{}:(e.preventDefault(),{panning:!1,pan:this.getPan([e.pageX,e.pageY])}))))},wheel:({event:e,update:t,dispatchEvent:n})=>{requestAnimationFrame((()=>{t((({config:{thumbnail:s,dimensions:a},pan:[l,i],scale:o,windowBBox:[r,c,d,m],options:{zoomPad:u}})=>{if(s)return{};e.preventDefault(),e.stopImmediatePropagation();const h=e.x-r,p=e.y-c,g=(h-l)/o,f=(p-i)/o,b=es([d,m],a,e.deltaY<0?1.09*o:o/1.09,u);return o===b?{}:(this.wheelTimeout&&clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout((()=>{this.wheelTimeout=null,t((e=>({wheeling:!1,disableOverlays:Boolean(e.playing||e.seeking)})),((e,t)=>ds(n,e.disableOverlays)(e,t)))}),200),{pan:[h-g*b,p-f*b],scale:b,cursorCoordinates:[e.pageX,e.pageY],wheeling:!0,disableOverlays:!0})}),ds(n,!0))}))}}}createHTMLElement(e){const t=document.createElement("canvas");return t.classList.add("_lookerCanvas_m8b2r_5",us),this.hideControlsTimeout=setTimeout((()=>e((({showOptions:e,hoveringControls:t})=>(this.hideControlsTimeout=null,e||t?{}:{showControls:!1})))),3500),t}renderSelf({loaded:e,error:t,config:{thumbnail:n},disabled:s,reloading:a,panning:l,windowBBox:[i,o,r,c],mouseIsOnOverlay:d,disableOverlays:m}){if(this.width!==r){const e=ls();this.element.width=r*e,this.width=r}if(this.height!==c){const e=ls();this.element.height=c*e,this.height=c}const u=this.cursor;l?"all-scroll"!==u&&(this.cursor="all-scroll"):n||d&&!m?"pointer"!==u&&(this.cursor="pointer"):n?"unset"!==u&&(this.cursor="unset"):"default"!==u&&(this.cursor="default"),this.cursor!==u&&(this.element.style.cursor=this.cursor);const h=!e||s||a||t;return this.hide!==h&&(this.hide=h,this.hide?this.element.classList.add(us):this.element.classList.remove(us)),this.element}getPan([e,t]){const[n,s]=this.start;return[e-n,t-s]}}const ps=Object.freeze({arrowLeft:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='rgb(238, 238, 238)' d='M20,10V14H11L14.5,17.5L12.08,19.92L4.16,12L12.08,4.08L14.5,6.5L11,10H20Z' /%3E%3C/svg%3E",arrowRight:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='rgb(238, 238, 238)' d='M4,10V14H13L9.5,17.5L11.92,19.92L19.84,12L11.92,4.08L9.5,6.5L13,10H4Z' /%3E%3C/svg%3E",fullscreen:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24'%3E%3Cpath fill='rgb(238, 238, 238)' d='M5,5H10V7H7V10H5V5M14,5H19V10H17V7H14V5M17,14H19V19H14V17H17V14M10,17V19H5V14H7V17H10Z' /%3E%3C/svg%3E",fullscreenExit:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24'%3E%3Cpath fill='rgb(238, 238, 238)' d='M14,14H19V16H16V19H14V14M5,14H10V19H8V16H5V14M8,5H10V10H5V8H8V5M19,8V10H14V5H16V8H19Z' /%3E%3C/svg%3E",help:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='rgb(238, 238, 238)' d='M15.07,11.25L14.17,12.17C13.45,12.89 13,13.5 13,15H11V14.5C11,13.39 11.45,12.39 12.17,11.67L13.41,10.41C13.78,10.05 14,9.55 14,9C14,7.89 13.1,7 12,7A2,2 0 0,0 10,9H8A4,4 0 0,1 12,5A4,4 0 0,1 16,9C16,9.88 15.64,10.67 15.07,11.25M13,19H11V17H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z' /%3E%3C/svg%3E",minus:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24'%3E%3Cpath fill='rgb(238, 238, 238)' d='M20 14H4V10H20V14Z' /%3E%3C/svg%3E",plus:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24'%3E%3Cpath fill='rgb(238, 238, 238)' d='M20 14H14V20H10V14H4V10H10V4H14V10H20V14Z' /%3E%3C/svg%3E",options:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='rgb(238, 238, 238)' d='M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z' /%3E%3C/svg%3E"});function gs(e,t,n,s){const a=new t.node(e,n,s);if(!a.isShown(e))return a;let l=new Array;return l=t.children?t.children.map((t=>gs(e,t,n,s))):l,a.applyChildren(l),a}const fs=function(e,t=!1){let n="";return t&&e<=10?n+="0"+e:n=0===e?"0":`${e}`,n},bs=(e,t,n)=>(e===t&&(e-=.1*(1/n)),Math.floor(e*n+1)),ys=(e,t)=>((e-=1)+.01)/t,vs=(e,t,n)=>`${e} / ${bs(t,t,n)}`,xs=(e,t,n)=>{const s=Math.floor(n/3600)>0;let a=0,l=ys(e,t);s&&(a=Math.floor(l/3600)),l%=3600;const i=Math.floor(l/60),o=l%60;return s?fs(a)+":"+fs(i,!0)+":"+fs(+o.toFixed(0),!0):fs(i)+":"+fs(+o.toFixed(0),!0)};const ws=e=>{let t=[],n=[],s=[];const a=e=>{e.muted=!0,e.preload="metadata",e.loop=!1},l=e=>()=>{if(!e.paused)throw new Error("Release playing video");if(a(e),n.length){n.shift()([e,l(e)])}else s.push(e)};return[()=>{if(s.length){const e=s.shift();return Promise.resolve([e,l(e)])}if(t.length<e){const e=document.createElement("video");return e.preload="metadata",e.muted=!0,e.loop=!1,t.push(e),Promise.resolve([e,l(e)])}return new Promise((e=>{n.push(e)}))},()=>{n.forEach(a),s=[],n=[],t=[]}]},[ks,Es]=ws(1),[Ss,Ls]=ws(6);const Ts=e=>Object.fromEntries(Object.entries(e).reduce(((e,[t,n])=>Array.isArray(n.eventKeys)?[...e,...n.eventKeys.map((e=>[e,n]))]:[...e,[n.eventKeys||n.shortcut,n]]),[])),Zs={title:"Escape context",shortcut:"Esc",eventKeys:"Escape",detail:"Escape the current context",action:(e,t,n)=>{e((({hasDefaultZoom:s,showHelp:a,showOptions:l,options:{fullscreen:i,showJSON:o,selectedLabels:r}})=>a?{showHelp:!1}:l?{showOptions:!1}:o?(t("options",{showJSON:!1}),{options:{showJSON:!1}}):s?i?(Ns.action(e,t,n),{}):r.length?(t("clear"),{}):(t("close"),{}):{setZoom:!0}))}},Cs={title:"Next sample",shortcut:"&#8594;",eventKeys:"ArrowRight",detail:"Go to the next sample",action:(e,t)=>{t("next")}},Ps={title:"Previous sample",shortcut:"&#8592;",eventKeys:"ArrowLeft",detail:"Go to the previous sample",action:(e,t)=>{t("previous")}},Rs={title:"Display help",eventKeys:["/","?"],shortcut:"?",detail:"Display this help window",action:(e,t)=>{e((({showHelp:e,config:{thumbnail:n}})=>n?{}:e?{showHelp:!1}:(t("options",{showJSON:!1}),{showHelp:!0,options:{showJSON:!1}})))}},Is={title:"Zoom in",eventKeys:["+","="],shortcut:"+",detail:"Zoom in on the sample",action:e=>{e((({scale:e,windowBBox:[t,n,s,a],config:{dimensions:l},pan:[i,o],options:{zoomPad:r}})=>{const c=s/2,d=a/2,m=(c-i)/e,u=(d-o)/e,h=es([s,a],l,1.09*e,r);return{scale:h,pan:[c-m*h,d-u*h]}}))}},Ws={title:"Zoom  out",eventKeys:["-","_"],shortcut:"-",detail:"Zoom out on the sample",action:e=>{e((({scale:e,windowBBox:[t,n,s,a],config:{dimensions:l},pan:[i,o],options:{zoomPad:r}})=>{const c=s/2,d=a/2,m=(c-i)/e,u=(d-o)/e,h=es([s,a],l,e/1.09,r);return{scale:h,pan:[c-m*h,d-u*h]}}))}},Ms={title:"Crop to content",shortcut:"z",detail:"Crop on visible labels",action:e=>{e((({disableOverlays:e})=>({zoomToContent:!e})))}},Xs={title:"Settings",shortcut:"s",detail:"Toggle the settings panel",action:e=>{e((({showOptions:e,config:{thumbnail:t}})=>t?{}:e?{showOptions:!1,disableControls:!1}:{disableControls:!1,showControls:!0,showOptions:!0}))}},Ns={title:"Fullscreen",shortcut:"f",detail:"Toggle fullscreen mode",action:(e,t)=>{e((({config:{thumbnail:e},options:{fullscreen:t}})=>e?{}:{options:{fullscreen:!t}}),(({config:{thumbnail:e},options:{fullscreen:n}})=>{e||t("fullscreen",n)}))}},Gs={title:"JSON",shortcut:"j",detail:"View JSON",action:(e,t)=>{let n=null;e((({disableOverlays:e,config:{thumbnail:t},options:{showJSON:s}})=>t?{}:(n=!e&&!s,n?{showHelp:!1,options:{showJSON:n}}:{options:{showJSON:!1}}))),null!==n&&t("options",{showJSON:n})}},Ys={escape:Zs,next:Cs,previous:Ps,rotateNext:{title:"Rotate label backward",shortcut:"&#8593;",eventKeys:"ArrowDown",detail:"Rotate the current label to the back",action:(e,t)=>e((({disableOverlays:e,rotate:t})=>e?{}:{rotate:t+1}),((e,n)=>{ds(t)(e,n)}))},rotatePrevious:{title:"Rotate label forward",shortcut:"&#8595;",eventKeys:"ArrowUp",detail:"Rotate the bottom label to the back",action:(e,t)=>e((({disableOverlays:e,rotate:t})=>e?{}:{rotate:Math.max(0,t-1)}),((e,n)=>{ds(t)(e,n)}))},help:Rs,zoomIn:Is,zoomOut:Ws,cropToContent:Ms,resetZoom:{title:"Reset zoom",shortcut:"r",detail:"Reset zoom to default",action:e=>{e({setZoom:!0})}},controlsToggle:{title:"Controls",shortcut:"c",detail:"Toggle controls",action:e=>{e((({config:{thumbnail:e},showControls:t})=>e?{}:t?{showControls:!1,disableControls:!1}:{disableControls:!1,showControls:!0}))}},settings:Xs,fullscreen:Ns,json:Gs,wheel:{title:"Zoom",shortcut:"Wheel",eventKeys:null,detail:"Zoom in and out",action:()=>null}},Vs=Ts(Ys),Fs={title:"Next frame",eventKeys:[".",">"],shortcut:">",detail:"Seek to the next frame",action:(e,t)=>{e((({frameNumber:e,duration:t,playing:n,config:{frameRate:s,support:a,thumbnail:l},lockedToSupport:i})=>{if(n||l)return{};const o=i?a[1]:bs(t,t,s);return{frameNumber:Math.min(o,e+1)}}),((e,n)=>ds(t)(e,n)))}},Ks={title:"Previous frame",eventKeys:[",","<"],shortcut:"<",detail:"Seek to the previous frame",action:(e,t)=>{e((({frameNumber:e,playing:t,config:{support:n,thumbnail:s},lockedToSupport:a})=>t||s?{}:{frameNumber:Math.max(a?n[0]:1,e-1)}),((e,n)=>ds(t)(e,n)))}},Ds={title:"Play / pause",shortcut:"Space",eventKeys:" ",detail:"Play or pause the video",action:(e,t)=>{e((({frameNumber:e,playing:n,duration:s,config:{frameRate:a,support:l,thumbnail:i},lockedToSupport:o})=>{if(i)return{};const r=o?l[0]:1,c=o?l[1]:bs(s,s,a);return t("options",{showJSON:!1}),{playing:!n&&r!==c,frameNumber:c===e?o?l[0]:1:e,options:{showJSON:!1}}}))}},Os={title:"Mute / unmute",shortcut:"m",detail:"Mute or unmute the video",action:(e,t)=>{e((({options:{volume:e},config:{thumbnail:n}})=>n?{}:(t("options",{volume:e=0===e?.5:0}),{options:{volume:e}})))}},zs=(e,t)=>{e((({config:{thumbnail:e}})=>e?{}:(t("options",{playbackRate:1}),{options:{playbackRate:1}})))},Hs={title:"Seek to",detail:"Seek to 0%, 10%, 20%... of the video",shortcut:"0-9",eventKeys:["0","1","2","3","4","5","6","7","8","9"],action:(e,t,n)=>{e((({duration:e,config:{frameRate:s,support:a},lockedToSupport:l})=>{const i=bs(e,e,s),o=l?a[1]-a[0]:i,r=l?a[0]:1;return t("options",{showJSON:!1}),{frameNumber:Math.max(1,Math.round(parseInt(n,10)/10*o)+r),options:{showJSON:!1}}}))}},Us={title:"Support lock",filter:e=>Boolean(e.support),detail:"Toggle the lock on the support frame(s)",shortcut:"l",action:e=>{e((({lockedToSupport:e,config:{support:t},frameNumber:n})=>({lockedToSupport:!!t&&!e,frameNumber:n<t[0]||n>t[1]?t[0]:n})))}},js={title:"Escape context",shortcut:"Esc",eventKeys:"Escape",detail:"Escape the current context",action:(e,t,n)=>{e((({hasDefaultZoom:s,showHelp:a,showOptions:l,frameNumber:i,config:{support:o},options:{fullscreen:r,showJSON:c,selectedLabels:d},lockedToSupport:m})=>a?{showHelp:!1}:l?{showOptions:!1}:c?(t("options",{showJSON:!1}),{options:{showJSON:!1}}):!m&&Boolean(o)?{frameNumber:o[0],lockedToSupport:!0}:1!==i?{frameNumber:1,playing:!1}:s?r?(Ns.action(e,t,n),{}):d.length?(t("clear"),{}):(t("close"),{}):{setZoom:!0}))}},As=r(o({},Ys),{escape:js,muteUnmute:Os,playPause:Ds,nextFrame:Fs,previousFrame:Ks,seekTo:Hs,supportLock:Us}),Bs=Ts(As);class Js extends cs{getEvents(){return{click:({event:e,update:t})=>{e.stopPropagation(),e.preventDefault(),t({showHelp:!1})},dblclick:({event:e})=>{e.stopPropagation(),e.preventDefault()}}}createHTMLElement(e){return this.createHelpPanel(e,Ys)}isShown({thumbnail:e}){return!e}renderSelf({showHelp:e}){return this.showHelp===e||(e?(this.element.style.opacity="0.9",this.element.style.display="flex"):(this.element.style.opacity="0.0",this.element.style.display="none"),this.showHelp=e),this.element}createHelpPanel(e,t){const n=document.createElement("div"),s=document.createElement("div");s.innerText="Help",s.classList.add("_lookerPanelHeader_gkq4n_44"),n.classList.add("_lookerPanel_gkq4n_5");const a=document.createElement("div");a.classList.add("_lookerPanelContainer_gkq4n_29");const l=document.createElement("div");l.classList.add("_lookerPanelVerticalContainer_gkq4n_38"),l.appendChild(n),a.appendChild(l);const i=document.createElement("div");i.classList.add("_lookerPanelFlex_gkq4n_69");const o=document.createElement("div");o.classList.add("_lookerHelpPanelItems_a2ufi_5"),this.items=o;const r=document.createElement("img");r.src="assets/close.47fb979b.svg",r.classList.add("_lookerPanelClose_gkq4n_50"),r.onclick=()=>e({showHelp:!1}),n.appendChild(r);const c=["Wheel","Esc"];return Object.values(t).sort(((e,t)=>e.shortcut.length!==t.shortcut.length?c.includes(t.shortcut)?1:c.includes(e.shortcut)?-1:t.shortcut.length-e.shortcut.length:e.shortcut>t.shortcut?1:-1)).forEach(Qs(o)),i.appendChild(s),i.appendChild(o),n.append(i),a}}class _s extends Js{createHTMLElement(e){let t=null;return e((({config:e})=>(t=e,{}))),this.createHelpPanel(e,Object.fromEntries(Object.entries(As).filter((([e,n])=>!n.filter||n.filter(t)))))}}const Qs=e=>t=>{const n=document.createElement("div");n.classList.add("_lookerShortcutValue_a2ufi_32"),n.innerHTML=t.shortcut;const s=document.createElement("div");s.classList.add("_lookerShortcutTitle_a2ufi_37"),s.innerText=t.title;const a=document.createElement("div");a.classList.add("_lookerShortcutDetail_a2ufi_42"),a.innerText=t.detail,e.appendChild(n),e.appendChild(s),e.appendChild(a)};const $s="_lookerControlActive_aetrq_54",qs="_lookerClickable_aetrq_130",ea="_lookerArrow_aetrq_134",ta="_lookerTime_aetrq_149";class na extends cs{getEvents(){return{click:({update:e,event:t,dispatchEvent:n})=>{t.stopPropagation(),t.preventDefault(),Cs.action(e,n,null,!0)},mouseenter:({update:e})=>{e({hoveringControls:!0})},mouseleave:({update:e})=>{e({hoveringControls:!1})}}}createHTMLElement(){const e=document.createElement("img");return e.classList.add(ea),e.src=ps.arrowRight,e.style.right="0.5rem",e}isShown({thumbnail:e}){return!e}renderSelf({showControls:e,disableControls:t,options:{hasNext:n}}){return e=e&&!t&&n,this.showControls===e||(e?(this.element.style.opacity="0.9",this.element.style.height="unset",this.element.style.display="block"):(this.element.style.opacity="0.0",this.element.style.height="0",this.element.style.display="none"),this.showControls=e),this.element}}class sa extends cs{getEvents(){return{click:({update:e,event:t,dispatchEvent:n})=>{t.stopPropagation(),t.preventDefault(),Ps.action(e,n,null,!0)},mouseenter:({update:e})=>{e({hoveringControls:!0})},mouseleave:({update:e})=>{e({hoveringControls:!1})}}}createHTMLElement(){const e=document.createElement("img");return e.src=ps.arrowLeft,e.classList.add(ea),e.style.left="0.5rem",e}isShown({thumbnail:e}){return!e}renderSelf({showControls:e,disableControls:t,options:{hasPrevious:n}}){return e=e&&!t&&n,this.showControls===e||(e?(this.element.style.opacity="0.9",this.element.style.height="unset",this.element.style.display="block"):(this.element.style.opacity="0.0",this.element.style.height="0",this.element.style.display="none"),this.showControls=e),this.element}}class aa extends cs{constructor(){super(...arguments),this.showControls=!1}getEvents(){return{mouseenter:({update:e})=>{e({hoveringControls:!0})},mouseleave:({update:e})=>{e({hoveringControls:!1})}}}createHTMLElement(){const e=document.createElement("div");return e.classList.add("_lookerControls_aetrq_5"),e}isShown({thumbnail:e}){return!e}renderSelf({showControls:e,disableControls:t,error:n,loaded:s}){return e=e&&!t&&!n&&s,this.showControls===e||(e?(this.element.style.opacity="0.9",this.element.style.height="unset"):(this.element.style.opacity="0.0",this.element.style.height="0"),this.showControls=e),this.element}}class la extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),Ns.action(t,n)}}}createHTMLElement(){const e=document.createElement("img");return e.classList.add(qs),e.style.padding="2px",e.style.gridArea="2 / 12 / 2 / 12",e}renderSelf({options:{fullscreen:e}}){return this.fullscreen!==e&&(this.fullscreen=e,e?this.element.classList.add($s):this.element.classList.remove($s),this.element.src=e?ps.fullscreenExit:ps.fullscreen,this.element.title="Toggle fullscreen (f)"),this.element}}class ia extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),Is.action(t,n)}}}createHTMLElement(){const e=document.createElement("img");return e.classList.add(qs),e.style.padding="2px",e.src=ps.plus,e.title="Zoom in (+)",e.style.gridArea="2 / 10 / 2 / 10",e}renderSelf(){return this.element}}class oa extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),Ws.action(t,n)}}}createHTMLElement(){const e=document.createElement("img");return e.classList.add(qs),e.style.padding="2px",e.src=ps.minus,e.title="Zoom out (-)",e.style.gridArea="2 / 9 / 2 / 9",e}renderSelf(){return this.element}}class ra extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),Rs.action(t,n)}}}createHTMLElement(){const e=document.createElement("img");return e.classList.add(qs),e.style.padding="2px",e.src=ps.help,e.title="Help (?)",e.style.gridArea="2 / 14 / 2 / 14",e}renderSelf({showHelp:e}){return this.active!==e&&(e?this.element.classList.add($s):this.element.classList.remove($s),this.active=e),this.element}}class ca extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),Xs.action(t,n)}}}createHTMLElement(){const e=document.createElement("img");return e.classList.add(qs),e.style.padding="2px",e.src=ps.options,e.title="Settings (s)",e.style.gridArea="2 / 15 / 2 / 15",e}renderSelf({showOptions:e}){return this.active!==e&&(e?this.element.classList.add($s):this.element.classList.remove($s),this.active=e),this.element}}class da extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),Ms.action(t,n)}}}createHTMLElement(){const e=document.createElement("img");return e.style.padding="2px",e.src="assets/crop.607519b3.svg",e.title=`${Ms.title} (${Ms.shortcut})`,e.style.gridArea="2 / 11 / 2 / 11",e}renderSelf({disableOverlays:e}){return this.disabled!==e&&(this.element.style.opacity=e?"0.5":"1",this.element.style.cursor=e?"unset":"pointer",this.disabled=e),this.element}}class ma extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),Gs.action(t,n)}}}createHTMLElement(){const e=document.createElement("img");return e.style.padding="2px",e.src="assets/json.9847d1d5.svg",e.title=`${Gs.title} (${Gs.shortcut})`,e.style.gridArea="2 / 13 / 2 / 13",e}renderSelf({disableOverlays:e,options:{showJSON:t}}){return this.disabled!==e&&(this.element.style.opacity=e?"0.5":"1",this.element.style.cursor=e?"unset":"pointer",this.disabled=e),this.active!==t&&(t?this.element.classList.add($s):this.element.classList.remove($s),this.active=t),this.element}}class ua extends cs{constructor(){super(...arguments),this.errorElement=null}createHTMLElement(){return null}renderSelf({error:e,config:{thumbnail:t},options:{mimetype:n}}){if(e&&!this.errorElement){this.errorElement=document.createElement("div"),this.errorElement.classList.add("_lookerErrorPage_sfdgp_5");const s=document.createElement("img");if(s.src="assets/error.3f1a5768.svg",this.errorElement.appendChild(s),t)this.errorElement.style.cursor="pointer";else if(!0===e){const e=n.startsWith("video/"),t=document.createElement("p"),s=document.createElement("div");if(t.innerText=`This ${e?"video":"image"} failed to load. The file may not exist, or its type (${n}) may be unsupported.`,s.appendChild(t),this.errorElement.appendChild(s),e){const e=document.createElement("p");e.innerHTML="You can use\n              <code>\n                <a>\n                  fiftyone.utils.video.reencode_videos()\n                </a>\n              </code>\n              to re-encode videos in a supported format.",e.querySelector("a").addEventListener("click",(()=>ha("https://voxel51.com/docs/fiftyone/api/fiftyone.utils.video.html#fiftyone.utils.video.reencode_videos"))),s.appendChild(e)}}else{const e=document.createElement("p"),t=document.createElement("div");e.innerText="Something went wrong",t.appendChild(e),this.errorElement.appendChild(t)}}return this.errorElement}}const ha=e=>{let t;if(pa())try{t=require("electron").shell.openExternal}catch{}return t?n=>{n.preventDefault(),t(e)}:null},pa=()=>window.process&&window.process.versions&&Boolean(window.process.versions.electron);class ga extends cs{getEvents(){return{click:({event:e,update:t})=>{e.stopPropagation(),e.preventDefault(),t({options:{showJSON:!1}})},dblclick:({event:e})=>{e.stopPropagation(),e.preventDefault()}}}createHTMLElement(e,t){const n=document.createElement("div");n.classList.add("_lookerPanel_gkq4n_5");const s=document.createElement("div");s.classList.add("_lookerJSONPanel_p3yv7_5"),s.classList.add("_lookerPanelContainer_gkq4n_29");const a=document.createElement("div");a.classList.add("_lookerPanelVerticalContainer_gkq4n_38"),a.appendChild(n),s.appendChild(a),n.appendChild(document.createElement("pre")),n.onclick=e=>e.stopPropagation();const l=document.createElement("img");l.src="assets/close.47fb979b.svg",l.classList.add("_lookerPanelClose_gkq4n_50"),l.onclick=()=>{e({options:{showJSON:!1}}),t("options",{showJSON:!1})},l.title="Close JSON",a.appendChild(l);const i=document.createElement("img");return i.src="assets/clipboard.35e8b8b9.svg",i.classList.add("_lookerCopyJSON_p3yv7_24"),i.onclick=e=>{e.stopPropagation(),t("copy")},i.title="Copy JSON to clipboard",a.appendChild(i),s}isShown({thumbnail:e}){return!e}renderSelf({options:{showJSON:e}}){return this.json===e||(e?(this.element.style.opacity="0.9",this.element.style.display="flex"):(this.element.style.opacity="0.0",this.element.style.display="none"),this.json=e),this.element}}const fa="_lookerFullscreen_zwgek_38";class ba extends cs{getEvents(){return{keydown:({event:e,update:t,dispatchEvent:n})=>{if(e.altKey||e.ctrlKey||e.metaKey)return;const s=e;t((({SHORTCUTS:e,error:a})=>(!a&&s.key in e&&e[s.key].action(t,n,s.key,s.shiftKey),{})))},mouseenter:({update:e,dispatchEvent:t})=>{t("mouseenter"),e((({config:{thumbnail:e}})=>e?{hovering:!0}:{hovering:!0,showControls:!0}))},mouseleave:({update:e,dispatchEvent:t})=>{t("mouseleave"),e({hovering:!1,disableControls:!1,showControls:!1,showOptions:!1,panning:!1})}}}createHTMLElement(){const e=document.createElement("div");return e.classList.add("_looker_zwgek_16"),e.tabIndex=-1,e}renderSelf({hovering:e,error:t,config:{thumbnail:n},options:{fullscreen:s,inSelectionMode:a}}){!n&&e&&this.element!==document.activeElement&&this.element.focus(),t&&!n&&this.element.classList.add("_lookerError_zwgek_31");const l=this.element.classList.contains(fa);return s&&!l?this.element.classList.add(fa):!s&&l&&this.element.classList.remove(fa),n&&a!==this.selection&&(this.selection=a,this.element.title=a?Dn:"Click to expand"),this.element}}class ya extends cs{constructor(){super(...arguments),this.showOptions=!1}getEvents(){return{click:({event:e})=>{e.stopPropagation(),e.preventDefault()},dblclick:({event:e})=>{e.stopPropagation(),e.preventDefault()},mouseenter:({update:e})=>{e({hoveringControls:!0})},mouseleave:({update:e})=>{e({hoveringControls:!1})}}}createHTMLElement(){const e=document.createElement("div");return e.classList.add("_lookerOptionsPanel_ym7lk_5"),e}isShown({thumbnail:e}){return!e}renderSelf({showOptions:e}){return this.showOptions===e||(e?(this.element.style.opacity="0.9",this.element.style.display="grid"):(this.element.style.opacity="0.0",this.element.style.display="none"),this.showOptions=e),this.element}}class va extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),t((({options:{loop:e}})=>(n("options",{loop:!e}),{options:{loop:!e}})))}}}createHTMLElement(){return[this.label,this.checkbox]=ms("Loop video",!1),La([this.label])}renderSelf({options:{loop:e}}){return this.checkbox.checked=e,this.element}}class xa extends cs{getEvents(){return{click:({event:e,update:t})=>{e.stopPropagation(),e.preventDefault(),t((({options:{onlyShowHoveredLabel:e}})=>({options:{onlyShowHoveredLabel:!e}})))}}}createHTMLElement(){return[this.label,this.checkbox]=ms("Only show hovered label",!1),La([this.label])}renderSelf({options:{onlyShowHoveredLabel:e}}){return this.checkbox.checked=e,this.element}}class wa extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),t((({options:{showConfidence:e}})=>(n("options",{showConfidence:!e}),{options:{showConfidence:!e}})))}}}createHTMLElement(){return[this.label,this.checkbox]=ms("Show confidence",!1),La([this.label])}renderSelf({options:{showConfidence:e}}){return this.checkbox.checked=e,this.element}}class ka extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),t((({options:{showIndex:e}})=>(n("options",{showIndex:!e}),{options:{showIndex:!e}})))}}}createHTMLElement(){return[this.label,this.checkbox]=ms("Show index",!1),La([this.label])}renderSelf({options:{showIndex:e}}){return this.checkbox.checked=e,this.element}}class Ea extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),t((({options:{showLabel:e}})=>(n("options",{showLabel:!e}),{options:{showLabel:!e}})))}}}createHTMLElement(){return[this.label,this.checkbox]=ms("Show label",!1),La([this.label])}renderSelf({options:{showLabel:e}}){return this.checkbox.checked=e,this.element}}class Sa extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),t((({options:{showTooltip:e}})=>(n("options",{showTooltip:!e}),{options:{showTooltip:!e}})))}}}createHTMLElement(){return[this.label,this.checkbox]=ms("Show tooltip",!1),La([this.label])}renderSelf({options:{showTooltip:e}}){return this.checkbox.checked=e,this.element}}const La=function(e){const t=document.createElement("div");t.classList.add("_lookerOptionsInput_ym7lk_39");for(const n of e)t.appendChild(n);return t};class Ta extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),t((({options:{useFrameNumber:e}})=>(n("options",{useFrameNumber:!e}),{options:{useFrameNumber:!e}})))}}}createHTMLElement(){return[this.label,this.checkbox]=ms("Use frame number",!1),La([this.label])}renderSelf({options:{useFrameNumber:e}}){return this.checkbox.checked=e,this.element}}const Za={},Ca=(e,t=1)=>{const n=`${e}${t=Math.round(255*t)}`;if(n in Za)return Za[n];let s,a,l;return[s,a,l]="string"==typeof e?(e=>{let t,n,s;if(e.startsWith("#"))[t,n,s]=Ia(e);else if(e.startsWith("rgb")){let a=e.indexOf(",")>-1?",":" ";[t,n,s]=e.slice(4).split(")")[0].split(a)}else e.startsWith("hsl")&&([t,n,s]=Wa(e));return[t,n,s]})(e):e,Za[n]=zn?s<<24|a<<16|l<<8|t:t<<24|l<<16|a<<8|s,Za[n]},Pa=e=>{const t=new Uint32Array(1);return t[0]=e,[...new Uint8Array(t.buffer)]},Ra=([e,t,n,s])=>`rgba(${e},${t},${n},${s/255})`,Ia=e=>{let t=0,n=0,s=0;return 4==e.length?(t=+("0x"+e[1]+e[1]),n=+("0x"+e[2]+e[2]),s=+("0x"+e[3]+e[3])):7==e.length&&(t=+("0x"+e[1]+e[2]),n=+("0x"+e[3]+e[4]),s=+("0x"+e[5]+e[6])),[t,n,s]},Wa=e=>{let t,n,s,a=e.indexOf(",")>-1?",":" ",[l,i,o]=e.slice(4).split(")")[0].split(a);if(l/=360,i/=100,o/=100,0===i)t=n=s=o;else{const e=(e,t,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e),a=o<.5?o*(1+i):o+i-o*i,r=2*o-a;t=e(r,a,l+1/3),n=e(r,a,l),s=e(r,a,l-1/3)}return[t,n,s]},Ma=(()=>{let e=null;const t=e=>{const t=1e4*Math.sin(e+1);return t-Math.floor(t)};let n={};return(s,a)=>{if(JSON.stringify(e)!==JSON.stringify(s)&&(n={},e=s),a in n)return n[a];s=[...s],a>0&&(s=((e,n)=>{let s,a,l=e.length;for(;l;)a=Math.floor(t(n)*l--),s=e[l],e[l]=e[a],e[a]=s,++n;return e})(s,a));let l={},i=0;return n[a]=e=>(e in l||(l[e]=s[i%s.length],i++),l[e]),n[a]}})(),Xa=(e,t,n)=>Ma(e,t)(n);class Na extends cs{constructor(){super(...arguments),this.activePaths=[]}createHTMLElement(){const e=document.createElement("div");return e.classList.add("_lookerTags_ejznv_5"),e}isShown({thumbnail:e}){return e}renderSelf({config:{fieldSchema:e},options:{filter:t,activePaths:n,coloring:s,fieldsMap:a,mimetype:l,timeZone:i}},o){if(Ga(n,this.activePaths)&&this.colorByValue===s.byLabel&&this.colorSeed===s.seed)return this.element;const r=n.reduce(((n,r)=>{if(r.startsWith("tags.")&&Array.isArray(o.tags)&&o.tags.includes(r.slice(5))){const e=r.slice(5);n.push({color:Xa(s.pool,s.seed,r),title:e,value:e})}else if(r.startsWith("_label_tags.")){const e=r.slice("_label_tags.".length),t=o._label_tags[e]||0;if(t>0){const a=`${e}: ${t}`;n=[...n,{color:Xa(s.pool,s.seed,r),title:a,value:a}]}}else if(o[r]&&Vn.includes(o[r]._cls)){const e=o[r]._cls,a=e in Fn;let i=(a?o[r][Fn[e]]:[o[r]]).filter((e=>t[r](e)&&(l.includes("video")||Yn.includes(e._cls)))).map((e=>"Regression"===e._cls?e.value:e.label));"Regression"!==e?(i=Object.entries(i.reduce(((e,t)=>(e[t]||(e[t]=0),e[t]+=1,e)),{})),n=[...n,...i.map((([e,t])=>({color:Xa(s.pool,s.seed,s.byLabel?e:r),title:`${r}: ${e}`,value:a?`${Ya(e)}: ${t.toLocaleString()}`:Ya(e)})))]):n=[...n,...i.map((e=>({color:Xa(s.pool,s.seed,r),title:`${r}: ${e}`,value:Ya(e)})))]}else if(Fa(e[r])){let l=r;!o[r]&&a&&a[r]&&(l=a[r]);let c=o[l];const d=e[r],m=Ka(d,["fiftyone.core.fields.DateField"]),u=Ka(d,["fiftyone.core.fields.DateTimeField"]),h=Ka(d,["fiftyone.core.fields.FrameSupportField"]);if([void 0,null].includes(c))return n;const p=e=>{u&&e?e=((e,t)=>{const n="2-digit",s=36e5,a={timeZone:t,year:"numeric",day:n,month:n,hour:n,minute:n,second:n};return e%6e4||delete a.second,e%s||delete a.minute,e%864e5||delete a.hour,new Intl.DateTimeFormat("en-ZA",a).format(e).replaceAll("/","-")})(e,i):m&&e?e=(e=>{const t="2-digit",n={timeZone:"UTC",year:"numeric",day:t,month:t};return new Intl.DateTimeFormat("en-ZA",n).format(e).replaceAll("/","-")})(e):h&&Array.isArray(e)&&(e=`[${e.map(Ya).join(", ")}]`);const t=Ya(e);n=[...n,{color:Xa(s.pool,s.seed,s.byLabel?e:r),title:e,value:t}]};Array.isArray(c)&&!h||h&&"number"!=typeof c[0]||(c=[c]),(u||m)&&(c=c.map((e=>e.datetime)));const g=!t[r]||h||u||m?c:c.filter((e=>t[r](e))),f=[...g].sort().slice(0,3);f.forEach((e=>p(e)));const b=g.length-f.length;b>0&&p(`+${b} more`)}return n}),[]);return this.colorByValue=s.byLabel,this.colorSeed=s.seed,this.activePaths=[...n],this.element.innerHTML="",r.forEach((({value:e,color:t,title:n})=>{const s=document.createElement("div");s.innerHTML=e,s.title=n,s.style.backgroundColor=t,this.element.appendChild(s)})),this.element}}const Ga=(e,t)=>{if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0},Ya=e=>"string"==typeof e?e:"number"==typeof e?(e=e%1==0?e.toFixed(0):e<.001?e.toFixed(6):e.toFixed(3),Number(e).toLocaleString()):!0===e?"True":!1===e?"False":[void 0,null].includes(e)?"None":null,Va=new Set(["fiftyone.core.fields.BooleanField","fiftyone.core.fields.DateField","fiftyone.core.fields.DateTimeField","fiftyone.core.fields.FloatField","fiftyone.core.fields.FrameNumberField","fiftyone.core.fields.FrameSupportField","fiftyone.core.fields.IntField","fiftyone.core.fields.ObjectIdField","fiftyone.core.fields.StringField"]),Fa=e=>e&&(Va.has(e.ftype)||Va.has(e.subfield)),Ka=(e,t)=>e&&t.some((t=>t===e.ftype||t===e.subfield));class Da extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{t((({options:{selected:t,inSelectionMode:s}})=>s&&e.shiftKey?{}:(e.stopPropagation(),e.preventDefault(),n("selectthumbnail"),{options:{selected:!t}})))}}}createHTMLElement(){[this.label,this.checkbox]=ms("",!1),this.checkbox.checked=!1;const e=document.createElement("div");return e.classList.add("_lookerThumbnailSelector_h26h6_5"),e.appendChild(this.label),e.title=Dn,e}isShown({thumbnail:e}){return e}renderSelf({hovering:e,options:{selected:t,inSelectionMode:n}}){const s=e||t||n;return this.shown!==s&&(s?this.element.classList.add("_showSelector_h26h6_30"):this.element.classList.remove("_showSelector_h26h6_30"),this.shown=s),this.selected!==t&&(this.selected=t,this.checkbox.checked=t),this.element}}class Oa extends cs{createHTMLElement(){const e=document.createElement("div");return e.classList.add(ta),e.style.gridArea="2 / 3 / 2 / 3",e}renderSelf({duration:e,config:{frameRate:t,frameNumber:n}}){return e&&(this.element.innerHTML=vs(n,e,t)),this.element}}class za extends cs{getEvents(){return{error:({event:e,dispatchEvent:t})=>{t("error",{event:e})},loadedmetadata:({update:e})=>{e((({config:{frameNumber:e,frameRate:t}})=>(this.element.currentTime=ys(e,t),{duration:this.element.duration})))},seeked:({update:e,dispatchEvent:t})=>{e({loaded:!0}),t("loaded")}}}createHTMLElement(e){return this.imageSource=document.createElement("canvas"),this.imageSource.style.imageRendering="pixelated",e((({config:{thumbnail:t,dimensions:n,src:s,frameRate:a,frameNumber:l}})=>{this.imageSource.width=n[0],this.imageSource.height=n[1],this.src=s;return(t?Ss:ks)().then((([t,n])=>{const i=()=>{requestAnimationFrame((()=>{requestAnimationFrame((()=>{setTimeout((()=>{const s=this.imageSource.getContext("2d");s.imageSmoothingEnabled=!1,s.drawImage(t,0,0),n(),t.removeEventListener("seeked",i),e({loaded:!0,duration:t.duration})}),20)}))}))};t.addEventListener("seeked",i);const o=s=>{s.path&&s.path[0]&&(s=s.path[0].error),s.originalTarget&&(s=s.originalTarget.error),t.removeEventListener("error",o),n(),e({error:!0})},r=()=>{t.currentTime=ys(l,a),e({duration:t.duration}),t.removeEventListener("error",o),t.removeEventListener("loadedmetadata",r)};t.src=s,t.addEventListener("error",o),t.addEventListener("loadedmetadata",r)})),{}})),null}renderSelf(){return null}}class Ha extends cs{constructor(){super(...arguments),this.src=""}getEvents(){return{load:({update:e})=>{this.imageSource=this.element,e({loaded:!0})},error:({event:e,dispatchEvent:t})=>{t("error",{event:e})}}}createHTMLElement(){const e=new Image;return e.loading="eager",e}renderSelf({config:{src:e}}){return this.src!==e&&(this.src=e,this.element.setAttribute("src",e)),null}}class Ua extends cs{constructor(){super(...arguments),this.buffering=!1}isShown({thumbnail:e}){return e}createHTMLElement(){const e=document.createElement("div");return e.style.height="5px",e.style.position="absolute",e.style.bottom="0",e.style.width="100%",e.style.backgroundImage="linear-gradient(\n      130deg,\n      rgba(225, 100, 40, 0) 0%,\n      rgb(225, 100, 40) 50%,\n      rgba(225, 100, 40, 0) 100%\n    )",e.classList.add("_lookerLoader_zwgek_16"),e}renderSelf({duration:e,buffering:t,hovering:n,waitingForVideo:s,error:a,lockedToSupport:l,config:{frameRate:i,support:o}}){if((t||s)&&n&&!a===this.buffering)return this.element;const r=l?o[0]:1,c=l?o[1]:bs(e,e,i);return this.buffering=(t||s)&&n&&!a&&r!==c,this.buffering?this.element.style.display="block":this.element.style.display="none",this.element}}class ja extends cs{constructor(){super(...arguments),this.locked=null,this.singleFrame=null}getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.preventDefault(),e.stopPropagation(),Ds.action(t,n)}}}createHTMLElement(){this.pause=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.pause.setAttribute("height","24"),this.pause.setAttribute("width","24"),this.pause.setAttribute("viewBox","0 0 24 24");let e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("fill","rgb(238, 238, 238)"),e.setAttribute("d","M6 19h4V5H6v14zm8-14v14h4V5h-4z"),this.pause.appendChild(e),e=document.createElementNS("http://www.w3.org/2000/svg","path"),e.setAttribute("fill","none"),e.setAttribute("d","M0 0h24v24H0z"),this.pause.appendChild(e),this.play=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.play.setAttribute("height","24"),this.play.setAttribute("width","24"),this.play.setAttribute("viewBox","0 0 24 24"),e=document.createElementNS("http://www.w3.org/2000/svg","path"),e.setAttribute("fill","rgb(238, 238, 238)"),e.setAttribute("d","M8 5v14l11-7z"),this.play.appendChild(e),e=document.createElementNS("http://www.w3.org/2000/svg","path"),e.setAttribute("fill","none"),e.setAttribute("d","M0 0h24v24H0z"),this.buffering=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.buffering.classList.add("_bufferingCircle_wynh6_5"),this.buffering.setAttribute("viewBox","12 12 24 24");const t=document.createElementNS("http://www.w3.org/2000/svg","circle");t.setAttribute("cx","24"),t.setAttribute("cy","24"),t.setAttribute("r","9"),t.setAttribute("stroke-width","2"),t.setAttribute("stroke","rgb(238, 238, 238)"),t.setAttribute("fill","none"),t.classList.add("_bufferingPath_wynh6_21"),this.buffering.appendChild(t);const n=document.createElement("div");return n.style.marginTop="2px",n.style.position="relative",n.style.height="24px",n.style.width="24px",n.style.gridArea="2 / 2 / 2 / 2",n}renderSelf({playing:e,buffering:t,loaded:n,duration:s,lockedToSupport:a,config:{frameRate:l,support:i}}){let o=!1;if(null===this.singleFrame&&n&&this.locked!==a&&(this.singleFrame=a?i[0]===i[1]:1===bs(s,s,l),this.locked=a,o=!0),e===this.isPlaying&&this.isBuffering===t&&n||(this.element.innerHTML="",t||!n?(this.element.appendChild(this.buffering),this.element.title="Loading",this.element.style.cursor="default"):e?(this.element.appendChild(this.pause),this.element.title="Pause (space)",this.element.style.cursor="pointer"):(this.element.appendChild(this.play),this.element.title="Play (space)",this.element.style.cursor="pointer"),this.isPlaying=e,this.isBuffering=t||!n),o){this.play.children[0].setAttribute("fill",this.singleFrame?"rgb(138, 138, 138)":"rgb(238, 238, 238)"),this.element.style.cursor=this.singleFrame?"unset":"pointer",this.element.title=this.singleFrame?"Only one frame":"Play (space)"}return this.element}}class Aa extends cs{getEvents(){return{mouseenter:({update:e})=>{e({seekBarHovering:!0})},mousedown:({update:e})=>{e({seeking:!0,seekBarHovering:!0,options:{showJSON:!1}})},mouseleave:({update:e})=>{e((({seeking:e})=>({seekBarHovering:e})))}}}createHTMLElement(){const e=document.createElement("div");return e.classList.add("_lookerThumb_wynh6_94"),e}renderSelf({seeking:e,seekBarHovering:t,frameNumber:n,duration:s,config:{frameRate:a}}){if(null!==s){const e=(n-1)/(bs(s,s,a)-1)*100;this.element.style.setProperty("--progress",`${Math.max(0,e-.5)}%`),this.element.value=e}const l=e||t;return l!==this.active&&(this.active=l,l?this.element.classList.add("_lookerThumbSeeking_wynh6_111"):this.element.classList.remove("_lookerThumbSeeking_wynh6_111")),this.element}}class Ba extends cs{getEvents(){return{mousedown:({update:e})=>{e({seeking:!0,options:{showJSON:!1}})},mouseenter:({update:e})=>{e({seekBarHovering:!0})},mouseleave:({update:e})=>{e((({seeking:e})=>({seekBarHovering:e})))}}}createHTMLElement(){const e=document.createElement("input");return e.setAttribute("type","range"),e.setAttribute("min","0"),e.setAttribute("max","100"),e.classList.add("_lookerSeekBar_wynh6_84"),e}renderSelf({frameNumber:e,config:{frameRate:t,support:n,thumbnail:s},duration:a,buffers:l,lockedToSupport:i}){if(s)return this.element;if(null!==a){const s=bs(a,a,t),o=i?(n[0]-1)/(s-1)*100:0;this.element.style.setProperty("--start",`${o}%`);const r=i?(n[1]-1)/(s-1)*100:100;this.element.style.setProperty("--end",`${r}%`);let c=100;if(s-1>0){let t=0;for(let n=0;n<l.length;n++)if(l[n][0]<=e&&l[n][1]>=e){t=n;break}c=(l[t][1]-1)/(s-1)*100}this.element.style.setProperty("--buffer-progress",`${Math.min(c,r)}%`);const d=(e-1)/(s-1)*100;this.element.style.display="block",this.element.style.setProperty("--progress",`${d}%`),this.element.value=d}else this.element.style.display="none";return this.element}}class Ja extends cs{createHTMLElement(){const e=document.createElement("div");return e.classList.add(ta),e.style.gridArea="2 / 5 / 2 / 5",e}renderSelf({frameNumber:e,duration:t,config:{frameRate:n},options:{useFrameNumber:s}}){if("number"!=typeof t)return this.element.innerHTML="",this.element;const a=s?vs(e,t,n):((e,t,n)=>`${xs(e,t,n)} / ${xs(bs(n,n,t),t,n)}`)(e,n,t);return this.element.innerHTML=a,this.element}}class _a extends cs{constructor(){super(...arguments),this.loop=!1,this.playbackRate=1,this.waitingToPause=!1,this.waitingToPlay=!1,this.waitingToRelease=!1}getEvents(){return{error:({update:e,event:t,dispatchEvent:n})=>{this.releaseVideo(),e({error:!0}),n("error",{event:t})},loadedmetadata:({update:e})=>{e((({config:{frameRate:e},frameNumber:t})=>(this.element.currentTime=ys(t,e),{duration:this.element.duration})))},seeked:({update:e,dispatchEvent:t})=>{requestAnimationFrame((()=>{requestAnimationFrame((()=>{e((({loaded:e,playing:t,options:{autoplay:n}})=>e?{waitingForVideo:!1}:{loaded:!0,playing:n||t,waitingForVideo:!1})),t("load")}))}))},play:({update:e,dispatchEvent:t})=>{const n=t=>{e((({duration:e,playing:n,options:{loop:s},config:{frameRate:a,support:l},lockedToSupport:i})=>{let o=bs(t,e,a);const r=i?l[1]:bs(e,e,a);if(o>=r){const e=i?l[0]:1;n=s,o=s?e:r}else this.frameNumber=o;return{frameNumber:o,playing:n}}),(({playing:e,seeking:t,buffering:s})=>{!e||t||s||this.requestCallback(n)}))};e((({frameNumber:e})=>({playing:!0,disableOverlays:!0,frameNumber:e,rotate:0})),((e,s)=>{ds(t,e.playing)(e,s),this.requestCallback(n)}))},pause:({update:e,dispatchEvent:t})=>{e({disableOverlays:!1},((e,n)=>ds(t,!1)(e,n)))},timeupdate:({dispatchEvent:e,update:t})=>{t((({duration:t,config:{frameRate:n}})=>(e("timeupdate",{frameNumber:bs(this.element.currentTime,t,n)}),{})))}}}createHTMLElement(e){return this.update=e,this.element=null,e((({config:{thumbnail:t,dimensions:n,src:s,frameRate:a,support:l}})=>(this.src=s,this.posterFrame=l?l[0]:1,t?(this.canvas=document.createElement("canvas"),this.canvas.width=n[0],this.canvas.height=n[1],this.canvas.style.imageRendering="pixelated",Ss().then((([t,n])=>{const i=s=>{s.path&&s.path[0]&&(s=s.path[0].error),s.originalTarget&&(s=s.originalTarget.error),t.removeEventListener("error",i),t.removeEventListener("seeked",o),n(),e({error:!0})},o=()=>{requestAnimationFrame((()=>{requestAnimationFrame((()=>{setTimeout((()=>{const e=this.canvas.getContext("2d");e.imageSmoothingEnabled=!1,e.drawImage(t,0,0),n(),t.removeEventListener("seeked",o),t.removeEventListener("error",i),this.update({hasPoster:!0,duration:t.duration,loaded:!0})}),20)}))}))},r=()=>{t.addEventListener("seeked",o),t.currentTime=l?ys(l[0],a):0,t.removeEventListener("loadedmetadata",r)};t.addEventListener("error",i),t.addEventListener("loadedmetadata",r),t.src=s}))):(this.element=document.createElement("video"),this.element.preload="metadata",this.element.src=s),{}))),this.requestCallback=e=>{requestAnimationFrame((()=>{this.element&&e(this.element.currentTime)}))},this.element}acquireVideo(){let e=!1;return this.update((({waitingForVideo:t,error:n})=>t||n?{}:(ks().then((([e,t])=>{this.update((({frameNumber:n,hovering:s,config:{frameRate:a,thumbnail:l}})=>(this.element=e,this.release=t,!s&&l||this.waitingToRelease?this.releaseVideo():(this.attachEvents(),this.frameNumber=ys(n,a),this.element.currentTime=ys(n,a),this.element.src=this.src),{})))})),e=!0,{waitingForVideo:!0}))),e}releaseVideo(){if(this.waitingToPause||this.waitingToPlay||!this.element)return this.waitingToRelease=!0,this.imageSource=this.canvas,void(this.canvas&&this.update((({waitingForVideo:e})=>e?{waitingForVideo:!1}:{})));!this.element.paused&&this.element.pause(),this.waitingToRelease=!1,this.removeEvents(),this.element=null,this.release&&this.release(),this.release=null,this.update({waitingForVideo:!1,frameNumber:this.posterFrame,playing:!1})}renderSelf({options:{loop:e,volume:t,playbackRate:n},config:{frameRate:s,thumbnail:a},frameNumber:l,seeking:i,playing:o,loaded:r,buffering:c,hovering:d,hasPoster:m,destroyed:u}){if(u&&this.releaseVideo(),this.element){if(a&&!d)return this.releaseVideo(),null}else if(d&&a){if(this.acquireVideo())return null}return m&&l===this.posterFrame?this.imageSource=this.canvas:this.imageSource=this.element,this.element?(r&&o&&!i&&!c&&this.element.paused&&(this.waitingToPlay=!0,this.element.play().then((()=>{if(this.waitingToPlay=!1,this.waitingToPause&&this.element&&this.element.pause(),this.waitingToPause=!1,this.waitingToRelease)return this.releaseVideo(),null}))),!r||o&&!i&&!c||this.element.paused||(this.waitingToPlay?this.waitingToPause=!0:this.element.pause()),this.loop!==e&&(this.element.loop=e,this.loop=e),this.playbackRate!==n&&(this.element.playbackRate=n,this.playbackRate=n),this.volume!==t&&(this.element.volume=t,this.volume=t),this.frameNumber!==l&&(this.element.currentTime=ys(l,s),this.frameNumber=l),null):null}}const Qa=({seeking:e,duration:t,config:{frameRate:n,support:s},lockedToSupport:a},l)=>{if(t&&e){const e=l.currentTarget,{width:i,left:o}=e.getBoundingClientRect(),r=bs(t,t,n),c=Math.min(Math.max(1,Math.round((l.clientX+6-o)/i*r)),r);return{frameNumber:c,lockedToSupport:!!s&&(a&&c>=s[0]&&c<=s[1])}}return{}};const $a={node:class extends cs{getEvents(){return{}}createHTMLElement(){const e=document.createElement("div");return e.classList.add("_lookerVolume_wynh6_31"),e}renderSelf(){return this.element}},children:[{node:class extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),Os.action(t,n)}}}createHTMLElement(){const e=document.createElement("img");return e.classList.add(qs),e.style.padding="2px",e}renderSelf({options:{volume:e}}){return 0===e===this.muted||(this.muted=0===e,this.muted?(this.element.title="Unmute (m)",this.element.src="assets/volumeOff.453beb30.svg"):(this.element.title="Mute (m)",this.element.src="assets/volume.603995f5.svg")),this.element}}},{node:class extends cs{getEvents(){return{click:({event:e})=>{e.stopPropagation()},input:({update:e,dispatchEvent:t})=>{const n=this.element.valueAsNumber;t("options",{volume:n}),e({options:{volume:n}})}}}createHTMLElement(){const e=document.createElement("input");return e.setAttribute("type","range"),e.setAttribute("min","0"),e.setAttribute("max","1"),e.setAttribute("step","0.01"),e}renderSelf({options:{volume:e}}){return this.volume!==e&&(this.element.style.setProperty("--volume",100*e+"%"),this.element.value=e.toFixed(4),this.element.title=`Volume ${(100*e).toFixed(0)}%`,this.volume=e),this.element}}}]};const qa={node:class extends cs{getEvents(){return{}}createHTMLElement(){const e=document.createElement("div");return e.classList.add("_lookerPlaybackRate_wynh6_30"),e}renderSelf(){return this.element}},children:[{node:class extends cs{getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),zs(t,n)}}}createHTMLElement(){const e=document.createElement("img");return e.classList.add(qs),e.style.padding="2px",e.title="Reset playback rate (p)",e.src="assets/playbackRate.c6d444cb.svg",e}renderSelf(){return this.element}}},{node:class extends cs{getEvents(){return{click:({event:e})=>{e.stopPropagation()},input:({update:e,dispatchEvent:t})=>{t("options",{playbackRate:this.element.valueAsNumber}),e({options:{playbackRate:this.element.valueAsNumber}})}}}createHTMLElement(){const e=document.createElement("input");return e.setAttribute("type","range"),e.setAttribute("min","0.1"),e.setAttribute("max","2"),e.setAttribute("step","0.1"),e}renderSelf({options:{playbackRate:e},config:{frameRate:t}}){return this.playbackRate!==e&&(this.element.title=`${e.toFixed(1)}x ${(t*e).toFixed(2)} fps`,this.element.style.setProperty("--playback",e/2*100+"%"),this.element.value=e.toFixed(4),this.playbackRate=e),this.element}}}]};class el extends cs{isShown(e){return Boolean(e.support)}getEvents(){return{click:({event:e,update:t,dispatchEvent:n})=>{e.stopPropagation(),e.preventDefault(),Us.action(t,n)}}}createHTMLElement(){const e=document.createElement("img");return e.style.padding="2px",e.title=`${Us.title} (${Us.shortcut})`,e.style.gridArea="2 / 8 / 2 / 8",e.style.cursor="pointer",e}renderSelf({lockedToSupport:e}){return this.active!==e&&(e?this.element.classList.add($s):this.element.classList.remove($s),this.element.src=e?"assets/lock.ec7ff80a.svg":"assets/lockOpen.26f88635.svg",this.active=e),this.element}}const tl=(e,t,n)=>{var s,a;return gs(e,{node:(s=ba,a=function(){return{mouseenter:({update:e})=>{e((({config:{thumbnail:e}})=>e?{playing:!0}:{}))},mouseleave:({update:e})=>{e((({config:{thumbnail:e,support:t}})=>e?{frameNumber:Boolean(t)?t[0]:1,playing:!1}:{seeking:!1,seekBarHovering:!1}))},mousemove:({event:e,update:t})=>{t((t=>Qa(t,e)))},mouseup:({event:e,update:t})=>{t((t=>r(o({},Qa(t,e)),{seeking:!1})))}}},class extends s{getEvents(){const e=super.getEvents(),t=a();return Object.entries(t).forEach((([t,n])=>{const s=e[t];e[t]=e=>{s&&s(e),n&&n(e)}})),e}}),children:[{node:_a},{node:hs},{node:ua},{node:Na},{node:Da},{node:ga},{node:Ua},{node:_s},{node:aa,children:[{node:Ba},{node:Aa},{node:ja},{node:Ja},qa,$a,{node:el},{node:ia},{node:oa},{node:da},{node:la},{node:ma},{node:ca},{node:ra}]},{node:sa},{node:na},{node:ya,children:[{node:va},{node:xa},{node:wa},{node:ka},{node:Ea},{node:Sa},{node:Ta}]}]},t,n)},nl=(e,t,n)=>{const[s,a,l,i]=e.canvasBBox;return[s+l*t,a+i*n]},sl=e=>{let t=0;const n=e=>{if(e instanceof ArrayBuffer)t+=e.byteLength;else if(null!=e)switch(typeof e){case"number":t+=8;break;case"string":t+=2*e.length;break;case"boolean":t+=4;break;case"object":var s=Object.prototype.toString.call(e).slice(8,-1);if("Object"===s||"Array"===s)for(var a in e)e.hasOwnProperty(a)&&n(e[a]);else t+=2*e.toString().length}};return n(e),t},al=(e,t,n)=>{e.strokeStyle=n,e.beginPath(),e.moveTo(...nl(t,0,0)),e.lineTo(...nl(t,1,0)),e.lineTo(...nl(t,1,1)),e.lineTo(...nl(t,0,1)),e.closePath(),e.stroke()},ll=(e,t,n)=>{e.lineWidth=t.strokeWidth,e.setLineDash([]),al(e,t,n),e.setLineDash([t.dashLength]),al(e,t,"#ffffff"),e.setLineDash([])};var il,ol;(ol=il||(il={}))[ol.NONE=0]="NONE",ol[ol.CONTENT=1]="CONTENT",ol[ol.BORDER=2]="BORDER";const rl=(e,t,n)=>!(e.options.activePaths&&!e.options.activePaths.includes(t))&&(!e.options.filter||!e.options.filter[t]||e.options.filter[t](n));class cl{constructor(e,t){this.field=e,this.label=t}isShown(e){return rl(e,this.field,this.label)}isSelected(e){return e.options.selectedLabels.includes(this.label.id)}getColor({options:e}){if(!this.color){const t=e.coloring.byLabel?this.label.label:this.field;this.color=Xa(e.coloring.pool,e.coloring.seed,t)}return this.color}getSizeBytes(){return sl(this.label)}getSelectData(e){return{id:this.label.id,field:this.field,frameNumber:e.frameNumber}}}class dl{constructor(e){this.labels=e,this.labelBoundingBoxes={}}getColor(e,t,n){const s="Regression"===n._cls?t:e.options.coloring.byLabel?n.label:t;return Xa(e.options.coloring.pool,e.options.coloring.seed,s)}isShown(e){return this.getFiltered(e).length>0}getSelectData(e){const{label:{id:t},field:n}=this.getPointInfo(e);return{id:t,field:n}}getMouseDistance(e){return this.getPointInfo(e)?0:1/0}containsPoint(e){return this.getPointInfo(e)?il.CONTENT:il.NONE}getPointInfo(e){const t=this.getFilteredAndFlat(e),[n,s]=e.config.dimensions;let a;for(const[l,i]of t){const t=this.labelBoundingBoxes[i.id];if(t){let[o,r,c,d]=t;[o,r,c,d]=[o*n,r*s,c*n,d*s];const[m,u]=e.pixelCoordinates;m>=o&&u>=r&&m<=o+c&&u<=r+d&&(a={field:l,label:i,type:i._cls,color:this.getColor(e,l,i)})}}return a}draw(e,t){const n=this.getFilteredAndFlat(t),s=Math.max(...n.map((([n,s])=>e.measureText(this.getLabelText(t,s)).width))),a={};let l=t.textPad;n.forEach((([n,i])=>{const o=this.strokeClassification(e,t,l,s,n,i);l=o.top,o.box&&(a[i.id]=o.box)})),this.labelBoundingBoxes=a}getPoints(e){return this.getFilteredAndFlat(e).length?ul():[]}getSizeBytes(){let e=100;return this.labels.forEach((([t,n])=>{n.forEach((t=>{e+=sl(t)}))})),e}getFiltered(e){return this.labels.map((([t,n])=>[t,n.filter((n=>Yn.includes(n._cls)&&rl(e,t,n)))]))}getFilteredAndFlat(e,t=!0){let n=[];if(this.getFiltered(e).forEach((([e,t])=>{n=[...n,...t.map((t=>[e,t]))]})),t){const t=Object.fromEntries(e.options.activePaths.map((e=>[e,[]])));n.forEach((([e,n])=>{t[e].push(n)})),n=e.options.activePaths.reduce(((e,n)=>[...e,...t[n].map((e=>[n,e]))]),[]),n.sort(((e,t)=>e[0]===t[0]?e[1].label&&t[1].label&&e[1].label<t[1].label?-1:e[1].label>t[1].label?1:0:-1))}return n}isSelected(e,t){return e.options.selectedLabels.includes(t.id)}strokeClassification(e,t,n,s,a,l){const i=this.getLabelText(t,l);if(0===i.length)return{top:n};const o=this.getColor(t,a,l),[r,c]=t.canvasBBox,d=e.globalAlpha;e.globalAlpha=t.options.alpha;let[m,u,h,p]=[t.textPad+r,n+c,3*t.textPad+s,t.fontSize+3*t.textPad];return e.beginPath(),e.fillStyle=o,e.moveTo(m,u),e.lineTo(m+h,u),e.lineTo(m+h,u+p),e.lineTo(m,u+p),e.closePath(),e.fill(),e.globalAlpha=d,e.fillStyle="#ffffff",e.fillText(i,m+t.textPad,u+p-t.textPad),this.strokeBorder(e,t,[m,u,h,p],o),this.isSelected(t,l)&&this.strokeBorder(e,t,[m,u,h,p],"#ffffff",t.dashLength),m-=r,u-=c,{top:u+p+2*t.textPad,box:[(m-t.textPad/2)/t.canvasBBox[2],u/t.canvasBBox[3],(h+t.textPad/2)/t.canvasBBox[2],(p+t.textPad)/t.canvasBBox[3]]}}getLabelText(e,t){let n=e.options.showLabel?`${hl(t)}`:"";return e.options.showConfidence&&!isNaN(t.confidence)&&(n.length&&(n+=" "),n+=`(${Number(t.confidence).toFixed(2)})`),n}strokeBorder(e,t,[n,s,a,l],i,o){e.beginPath(),e.lineWidth=t.strokeWidth,e.strokeStyle=i,e.setLineDash(o?[o]:[]),e.moveTo(n,s),e.lineTo(n+a,s),e.lineTo(n+a,s+l),e.lineTo(n,s+l),e.closePath(),e.stroke()}needsLabelUpdate(){return!1}getLabelData(){return[]}updateLabelData(){}}class ml extends dl{getFiltered(e){return this.labels.map((([t,n])=>[t,n.filter((n=>{const s=rl(e,t,n)&&n.label;return"TemporalDetection"===n._cls?s&&n.support[0]<=e.frameNumber&&n.support[1]>=e.frameNumber:s}))]))}}const ul=e=>[],hl=e=>"Regression"===e._cls?e.value:e.label,pl=(e,t)=>{const n=e.options.activePaths,s=Object.fromEntries(n.map((e=>[e,[]])));let a=null;for(const h of t)h instanceof dl?a=h:h.field&&h.field in s&&h.isShown(e)&&s[h.field].push(h);let l=n.reduce(((e,t)=>[...e,...s[t]]),[]);if(a&&!e.config.thumbnail&&(l=[a,...l]),t.length<1)return[l,0];if(e.config.thumbnail||!e.cursorCoordinates)return[l,0];const[i,o]=e.pixelCoordinates;let r=l.filter((t=>t.containsPoint(e,[i,o])>il.NONE)).sort(((t,n)=>t.getMouseDistance(e,[i,o])-n.getMouseDistance(e,[i,o])));const c=l.filter((t=>t instanceof dl||t.containsPoint(e,[i,o])===il.NONE));let d=e.rotate;var m,u;return 0!==e.rotate&&([r,d]=(m=r,u=e.rotate,u=Math.min(u,m.length-1),[[...m.slice(u),...m.slice(0,u)],u])),e.options.onlyShowHoveredLabel?[r.length?[r[0]]:[],d]:[[...r,...c],d]};class gl extends cl{constructor(e,t){if(super(e,t),this.label.mask){const[e,t]=this.label.mask.data.shape;this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=e,this.imageData=new ImageData(new Uint8ClampedArray(this.label.mask.image),t,e);const n=this.canvas.getContext("2d");n.imageSmoothingEnabled=!1,n.clearRect(0,0,this.label.mask.data.shape[1],this.label.mask.data.shape[0]),n.putImageData(this.imageData,0,0)}}containsPoint(e){const[t,n,s,a]=this.getDrawnBBox(e),[l,i]=e.pixelCoordinates;return l>=t&&i>=n&&l<=t+s&&i<=n+a?il.CONTENT:this.isInHeader(e)?il.BORDER:il.NONE}draw(e,t){this.label.mask&&this.drawMask(e,t),!t.config.thumbnail&&this.drawLabelText(e,t),this.strokeRect(e,t,this.getColor(t)),this.isSelected(t)&&this.strokeRect(e,t,"#ffffff",t.dashLength)}getMouseDistance(e){const[t,n]=e.pixelCoordinates,[s,a,l,i]=this.getDrawnBBox(e);if(this.isInHeader(e))return 0;const o=[Bn([t,n],[s,a],[s+l,a]),Bn([t,n],[s+l,a],[s+l,a+i]),Bn([t,n],[s+l,a+i],[s,a+i]),Bn([t,n],[s,a+i],[s,a])];return Math.min(...o)}getPointInfo(e){return{color:this.getColor(e),field:this.field,label:this.label,type:"Detection"}}getPoints(){return fl([this.label])}drawLabelText(e,t){const n=this.getLabelText(t);if(!n.length)return void(this.labelBoundingBox=null);const s=this.getColor(t),[a,l,i,o]=this.label.bounding_box;e.beginPath(),e.fillStyle=s;let[r,c]=nl(t,a,l);[r,c]=[r-t.strokeWidth/2,c],e.moveTo(r,c);const{width:d}=e.measureText(n),m=t.fontSize,u=3*t.textPad+t.strokeWidth,h=r+d+u,p=c-m-u;e.lineTo(h,c),e.lineTo(h,p),e.lineTo(r,p),e.closePath(),e.fill(),e.fillStyle="#ffffff";const g=t.textPad+t.strokeWidth;e.fillText(n,r+g,c-g);const f=(m+u)/t.canvasBBox[3];this.labelBoundingBox=[a-t.strokeWidth/t.canvasBBox[2],l-f,(d+u+t.strokeWidth/2)/t.canvasBBox[2],f+t.strokeWidth/t.canvasBBox[3]]}drawMask(e,t){const[n,s,a,l]=this.label.bounding_box,[i,o]=nl(t,n,s),r=e.globalAlpha;e.globalAlpha=t.options.alpha,e.drawImage(this.canvas,i,o,a*t.canvasBBox[2],l*t.canvasBBox[3]),e.globalAlpha=r}getLabelText(e){let t=this.label.label&&e.options.showLabel?`${this.label.label}`:"";return e.options.showIndex&&!isNaN(this.label.index)&&(t.length&&(t+=" "),t+=`${Number(this.label.index).toLocaleString()}`),!e.options.showConfidence||isNaN(this.label.confidence)&&!Gn.has(this.label.confidence)||(t.length&&(t+=" "),t+=`(${"number"==typeof this.label.confidence?Number(this.label.confidence).toFixed(2):this.label.confidence})`),t}isInHeader(e){if(!this.labelBoundingBox)return!1;const[t,n]=e.config.dimensions,[s,a]=e.pixelCoordinates;let[l,i,o,r]=this.labelBoundingBox;return[l,i,o,r]=[l*t,i*n,o*t,r*n],s>=l&&a>=i&&s<=l+o&&a<=i+r}strokeRect(e,t,n,s){const[a,l,i,o]=this.label.bounding_box;e.beginPath(),e.lineWidth=t.strokeWidth,e.strokeStyle=n,e.setLineDash(s?[s]:[]),e.moveTo(...nl(t,a,l)),e.lineTo(...nl(t,a+i,l)),e.lineTo(...nl(t,a+i,l+o)),e.lineTo(...nl(t,a,l+o)),e.closePath(),e.stroke()}getDrawnBBox(e){const[t,n]=e.config.dimensions;let[s,a,l,i]=this.label.bounding_box;const o=e.strokeWidth/e.canvasBBox[2],r=e.strokeWidth/e.canvasBBox[3];return[(s-o)*t,(a-r)*n,(l+2*o)*t,(i+2*r)*n]}}const fl=e=>{let t=[];return e.forEach((e=>{const[n,s,a,l]=e.bounding_box;t=[...t,[n,s],[n+a,s],[n+a,s+l],[n,s+l]]})),t},bl={exports:{}},yl=bl.exports;!function(e){if("object"==typeof yl&&void 0!==bl)bl.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).pako=e()}}((function(){return function e(t,n,s){function a(i,o){if(!n[i]){if(!t[i]){var r="function"==typeof require&&require;if(!o&&r)return r(i,!0);if(l)return l(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[i]={exports:{}};t[i][0].call(d.exports,(function(e){return a(t[i][1][e]||e)}),d,d.exports,e,t,n,s)}return n[i].exports}for(var l="function"==typeof require&&require,i=0;i<s.length;i++)a(s[i]);return a}({1:[function(e,t,n){var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function a(e,t){return Object.prototype.hasOwnProperty.call(e,t)}n.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(var s in n)a(n,s)&&(e[s]=n[s])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var l={arraySet:function(e,t,n,s,a){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+s),a);else for(var l=0;l<s;l++)e[a+l]=t[n+l]},flattenChunks:function(e){var t,n,s,a,l,i;for(s=0,t=0,n=e.length;t<n;t++)s+=e[t].length;for(i=new Uint8Array(s),a=0,t=0,n=e.length;t<n;t++)l=e[t],i.set(l,a),a+=l.length;return i}},i={arraySet:function(e,t,n,s,a){for(var l=0;l<s;l++)e[a+l]=t[n+l]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,l)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,i))},n.setTyped(s)},{}],2:[function(e,t,n){var s=e("./common"),a=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch(c){a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(c){l=!1}for(var i=new s.Buf8(256),o=0;o<256;o++)i[o]=o>=252?6:o>=248?5:o>=240?4:o>=224?3:o>=192?2:1;function r(e,t){if(t<65534&&(e.subarray&&l||!e.subarray&&a))return String.fromCharCode.apply(null,s.shrinkBuf(e,t));for(var n="",i=0;i<t;i++)n+=String.fromCharCode(e[i]);return n}i[254]=i[254]=1,n.string2buf=function(e){var t,n,a,l,i,o=e.length,r=0;for(l=0;l<o;l++)55296==(64512&(n=e.charCodeAt(l)))&&l+1<o&&56320==(64512&(a=e.charCodeAt(l+1)))&&(n=65536+(n-55296<<10)+(a-56320),l++),r+=n<128?1:n<2048?2:n<65536?3:4;for(t=new s.Buf8(r),i=0,l=0;i<r;l++)55296==(64512&(n=e.charCodeAt(l)))&&l+1<o&&56320==(64512&(a=e.charCodeAt(l+1)))&&(n=65536+(n-55296<<10)+(a-56320),l++),n<128?t[i++]=n:n<2048?(t[i++]=192|n>>>6,t[i++]=128|63&n):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|63&n):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=128|63&n);return t},n.buf2binstring=function(e){return r(e,e.length)},n.binstring2buf=function(e){for(var t=new s.Buf8(e.length),n=0,a=t.length;n<a;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,s,a,l,o=t||e.length,c=new Array(2*o);for(s=0,n=0;n<o;)if((a=e[n++])<128)c[s++]=a;else if((l=i[a])>4)c[s++]=65533,n+=l-1;else{for(a&=2===l?31:3===l?15:7;l>1&&n<o;)a=a<<6|63&e[n++],l--;l>1?c[s++]=65533:a<65536?c[s++]=a:(a-=65536,c[s++]=55296|a>>10&1023,c[s++]=56320|1023&a)}return r(c,s)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+i[e[n]]>t?n:t}},{"./common":1}],3:[function(e,t,n){t.exports=function(e,t,n,s){for(var a=65535&e|0,l=e>>>16&65535|0,i=0;0!==n;){n-=i=n>2e3?2e3:n;do{l=l+(a=a+t[s++]|0)|0}while(--i);a%=65521,l%=65521}return a|l<<16|0}},{}],4:[function(e,t,n){t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],5:[function(e,t,n){var s=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,a){var l=s,i=a+n;e^=-1;for(var o=a;o<i;o++)e=e>>>8^l[255&(e^t[o])];return-1^e}},{}],6:[function(e,t,n){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],7:[function(e,t,n){t.exports=function(e,t){var n,s,a,l,i,o,r,c,d,m,u,h,p,g,f,b,y,v,x,w,k,E,S,L,T;n=e.state,s=e.next_in,L=e.input,a=s+(e.avail_in-5),l=e.next_out,T=e.output,i=l-(t-e.avail_out),o=l+(e.avail_out-257),r=n.dmax,c=n.wsize,d=n.whave,m=n.wnext,u=n.window,h=n.hold,p=n.bits,g=n.lencode,f=n.distcode,b=(1<<n.lenbits)-1,y=(1<<n.distbits)-1;e:do{p<15&&(h+=L[s++]<<p,p+=8,h+=L[s++]<<p,p+=8),v=g[h&b];t:for(;;){if(h>>>=x=v>>>24,p-=x,0===(x=v>>>16&255))T[l++]=65535&v;else{if(!(16&x)){if(0==(64&x)){v=g[(65535&v)+(h&(1<<x)-1)];continue t}if(32&x){n.mode=12;break e}e.msg="invalid literal/length code",n.mode=30;break e}w=65535&v,(x&=15)&&(p<x&&(h+=L[s++]<<p,p+=8),w+=h&(1<<x)-1,h>>>=x,p-=x),p<15&&(h+=L[s++]<<p,p+=8,h+=L[s++]<<p,p+=8),v=f[h&y];n:for(;;){if(h>>>=x=v>>>24,p-=x,!(16&(x=v>>>16&255))){if(0==(64&x)){v=f[(65535&v)+(h&(1<<x)-1)];continue n}e.msg="invalid distance code",n.mode=30;break e}if(k=65535&v,p<(x&=15)&&(h+=L[s++]<<p,(p+=8)<x&&(h+=L[s++]<<p,p+=8)),(k+=h&(1<<x)-1)>r){e.msg="invalid distance too far back",n.mode=30;break e}if(h>>>=x,p-=x,k>(x=l-i)){if((x=k-x)>d&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(E=0,S=u,0===m){if(E+=c-x,x<w){w-=x;do{T[l++]=u[E++]}while(--x);E=l-k,S=T}}else if(m<x){if(E+=c+m-x,(x-=m)<w){w-=x;do{T[l++]=u[E++]}while(--x);if(E=0,m<w){w-=x=m;do{T[l++]=u[E++]}while(--x);E=l-k,S=T}}}else if(E+=m-x,x<w){w-=x;do{T[l++]=u[E++]}while(--x);E=l-k,S=T}for(;w>2;)T[l++]=S[E++],T[l++]=S[E++],T[l++]=S[E++],w-=3;w&&(T[l++]=S[E++],w>1&&(T[l++]=S[E++]))}else{E=l-k;do{T[l++]=T[E++],T[l++]=T[E++],T[l++]=T[E++],w-=3}while(w>2);w&&(T[l++]=T[E++],w>1&&(T[l++]=T[E++]))}break}}break}}while(s<a&&l<o);s-=w=p>>3,h&=(1<<(p-=w<<3))-1,e.next_in=s,e.next_out=l,e.avail_in=s<a?a-s+5:5-(s-a),e.avail_out=l<o?o-l+257:257-(l-o),n.hold=h,n.bits=p}},{}],8:[function(e,t,n){var s=e("../utils/common"),a=e("./adler32"),l=e("./crc32"),i=e("./inffast"),o=e("./inftrees"),r=-2,c=12,d=30;function m(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function u(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function h(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new s.Buf32(852),t.distcode=t.distdyn=new s.Buf32(592),t.sane=1,t.back=-1,0):r}function p(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,h(e)):r}function g(e,t){var n,s;return e&&e.state?(s=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?r:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=n,s.wbits=t,p(e))):r}function f(e,t){var n,s;return e?(s=new u,e.state=s,s.window=null,0!==(n=g(e,t))&&(e.state=null),n):r}var b,y,v=!0;function x(e){if(v){var t;for(b=new s.Buf32(512),y=new s.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(o(1,e.lens,0,288,b,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;o(2,e.lens,0,32,y,0,e.work,{bits:5}),v=!1}e.lencode=b,e.lenbits=9,e.distcode=y,e.distbits=5}function w(e,t,n,a){var l,i=e.state;return null===i.window&&(i.wsize=1<<i.wbits,i.wnext=0,i.whave=0,i.window=new s.Buf8(i.wsize)),a>=i.wsize?(s.arraySet(i.window,t,n-i.wsize,i.wsize,0),i.wnext=0,i.whave=i.wsize):((l=i.wsize-i.wnext)>a&&(l=a),s.arraySet(i.window,t,n-a,l,i.wnext),(a-=l)?(s.arraySet(i.window,t,n-a,a,0),i.wnext=a,i.whave=i.wsize):(i.wnext+=l,i.wnext===i.wsize&&(i.wnext=0),i.whave<i.wsize&&(i.whave+=l))),0}n.inflateReset=p,n.inflateReset2=g,n.inflateResetKeep=h,n.inflateInit=function(e){return f(e,15)},n.inflateInit2=f,n.inflate=function(e,t){var n,u,h,p,g,f,b,y,v,k,E,S,L,T,Z,C,P,R,I,W,M,X,N,G,Y=0,V=new s.Buf8(4),F=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return r;(n=e.state).mode===c&&(n.mode=13),g=e.next_out,h=e.output,b=e.avail_out,p=e.next_in,u=e.input,f=e.avail_in,y=n.hold,v=n.bits,k=f,E=b,X=0;e:for(;;)switch(n.mode){case 1:if(0===n.wrap){n.mode=13;break}for(;v<16;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}if(2&n.wrap&&35615===y){n.check=0,V[0]=255&y,V[1]=y>>>8&255,n.check=l(n.check,V,2,0),y=0,v=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&y)<<8)+(y>>8))%31){e.msg="incorrect header check",n.mode=d;break}if(8!=(15&y)){e.msg="unknown compression method",n.mode=d;break}if(v-=4,M=8+(15&(y>>>=4)),0===n.wbits)n.wbits=M;else if(M>n.wbits){e.msg="invalid window size",n.mode=d;break}n.dmax=1<<M,e.adler=n.check=1,n.mode=512&y?10:c,y=0,v=0;break;case 2:for(;v<16;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}if(n.flags=y,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=d;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=d;break}n.head&&(n.head.text=y>>8&1),512&n.flags&&(V[0]=255&y,V[1]=y>>>8&255,n.check=l(n.check,V,2,0)),y=0,v=0,n.mode=3;case 3:for(;v<32;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}n.head&&(n.head.time=y),512&n.flags&&(V[0]=255&y,V[1]=y>>>8&255,V[2]=y>>>16&255,V[3]=y>>>24&255,n.check=l(n.check,V,4,0)),y=0,v=0,n.mode=4;case 4:for(;v<16;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}n.head&&(n.head.xflags=255&y,n.head.os=y>>8),512&n.flags&&(V[0]=255&y,V[1]=y>>>8&255,n.check=l(n.check,V,2,0)),y=0,v=0,n.mode=5;case 5:if(1024&n.flags){for(;v<16;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}n.length=y,n.head&&(n.head.extra_len=y),512&n.flags&&(V[0]=255&y,V[1]=y>>>8&255,n.check=l(n.check,V,2,0)),y=0,v=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&((S=n.length)>f&&(S=f),S&&(n.head&&(M=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),s.arraySet(n.head.extra,u,p,S,M)),512&n.flags&&(n.check=l(n.check,u,S,p)),f-=S,p+=S,n.length-=S),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===f)break e;S=0;do{M=u[p+S++],n.head&&M&&n.length<65536&&(n.head.name+=String.fromCharCode(M))}while(M&&S<f);if(512&n.flags&&(n.check=l(n.check,u,S,p)),f-=S,p+=S,M)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===f)break e;S=0;do{M=u[p+S++],n.head&&M&&n.length<65536&&(n.head.comment+=String.fromCharCode(M))}while(M&&S<f);if(512&n.flags&&(n.check=l(n.check,u,S,p)),f-=S,p+=S,M)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;v<16;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}if(y!==(65535&n.check)){e.msg="header crc mismatch",n.mode=d;break}y=0,v=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=c;break;case 10:for(;v<32;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}e.adler=n.check=m(y),y=0,v=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=g,e.avail_out=b,e.next_in=p,e.avail_in=f,n.hold=y,n.bits=v,2;e.adler=n.check=1,n.mode=c;case c:if(5===t||6===t)break e;case 13:if(n.last){y>>>=7&v,v-=7&v,n.mode=27;break}for(;v<3;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}switch(n.last=1&y,v-=1,3&(y>>>=1)){case 0:n.mode=14;break;case 1:if(x(n),n.mode=20,6===t){y>>>=2,v-=2;break e}break;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=d}y>>>=2,v-=2;break;case 14:for(y>>>=7&v,v-=7&v;v<32;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}if((65535&y)!=(y>>>16^65535)){e.msg="invalid stored block lengths",n.mode=d;break}if(n.length=65535&y,y=0,v=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(S=n.length){if(S>f&&(S=f),S>b&&(S=b),0===S)break e;s.arraySet(h,u,p,S,g),f-=S,p+=S,b-=S,g+=S,n.length-=S;break}n.mode=c;break;case 17:for(;v<14;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}if(n.nlen=257+(31&y),y>>>=5,v-=5,n.ndist=1+(31&y),y>>>=5,v-=5,n.ncode=4+(15&y),y>>>=4,v-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=d;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;v<3;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}n.lens[F[n.have++]]=7&y,y>>>=3,v-=3}for(;n.have<19;)n.lens[F[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,N={bits:n.lenbits},X=o(0,n.lens,0,19,n.lencode,0,n.work,N),n.lenbits=N.bits,X){e.msg="invalid code lengths set",n.mode=d;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;C=(Y=n.lencode[y&(1<<n.lenbits)-1])>>>16&255,P=65535&Y,!((Z=Y>>>24)<=v);){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}if(P<16)y>>>=Z,v-=Z,n.lens[n.have++]=P;else{if(16===P){for(G=Z+2;v<G;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}if(y>>>=Z,v-=Z,0===n.have){e.msg="invalid bit length repeat",n.mode=d;break}M=n.lens[n.have-1],S=3+(3&y),y>>>=2,v-=2}else if(17===P){for(G=Z+3;v<G;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}v-=Z,M=0,S=3+(7&(y>>>=Z)),y>>>=3,v-=3}else{for(G=Z+7;v<G;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}v-=Z,M=0,S=11+(127&(y>>>=Z)),y>>>=7,v-=7}if(n.have+S>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=d;break}for(;S--;)n.lens[n.have++]=M}}if(n.mode===d)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=d;break}if(n.lenbits=9,N={bits:n.lenbits},X=o(1,n.lens,0,n.nlen,n.lencode,0,n.work,N),n.lenbits=N.bits,X){e.msg="invalid literal/lengths set",n.mode=d;break}if(n.distbits=6,n.distcode=n.distdyn,N={bits:n.distbits},X=o(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,N),n.distbits=N.bits,X){e.msg="invalid distances set",n.mode=d;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(f>=6&&b>=258){e.next_out=g,e.avail_out=b,e.next_in=p,e.avail_in=f,n.hold=y,n.bits=v,i(e,E),g=e.next_out,h=e.output,b=e.avail_out,p=e.next_in,u=e.input,f=e.avail_in,y=n.hold,v=n.bits,n.mode===c&&(n.back=-1);break}for(n.back=0;C=(Y=n.lencode[y&(1<<n.lenbits)-1])>>>16&255,P=65535&Y,!((Z=Y>>>24)<=v);){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}if(C&&0==(240&C)){for(R=Z,I=C,W=P;C=(Y=n.lencode[W+((y&(1<<R+I)-1)>>R)])>>>16&255,P=65535&Y,!(R+(Z=Y>>>24)<=v);){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}y>>>=R,v-=R,n.back+=R}if(y>>>=Z,v-=Z,n.back+=Z,n.length=P,0===C){n.mode=26;break}if(32&C){n.back=-1,n.mode=c;break}if(64&C){e.msg="invalid literal/length code",n.mode=d;break}n.extra=15&C,n.mode=22;case 22:if(n.extra){for(G=n.extra;v<G;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}n.length+=y&(1<<n.extra)-1,y>>>=n.extra,v-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;C=(Y=n.distcode[y&(1<<n.distbits)-1])>>>16&255,P=65535&Y,!((Z=Y>>>24)<=v);){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}if(0==(240&C)){for(R=Z,I=C,W=P;C=(Y=n.distcode[W+((y&(1<<R+I)-1)>>R)])>>>16&255,P=65535&Y,!(R+(Z=Y>>>24)<=v);){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}y>>>=R,v-=R,n.back+=R}if(y>>>=Z,v-=Z,n.back+=Z,64&C){e.msg="invalid distance code",n.mode=d;break}n.offset=P,n.extra=15&C,n.mode=24;case 24:if(n.extra){for(G=n.extra;v<G;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}n.offset+=y&(1<<n.extra)-1,y>>>=n.extra,v-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=d;break}n.mode=25;case 25:if(0===b)break e;if(S=E-b,n.offset>S){if((S=n.offset-S)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=d;break}S>n.wnext?(S-=n.wnext,L=n.wsize-S):L=n.wnext-S,S>n.length&&(S=n.length),T=n.window}else T=h,L=g-n.offset,S=n.length;S>b&&(S=b),b-=S,n.length-=S;do{h[g++]=T[L++]}while(--S);0===n.length&&(n.mode=21);break;case 26:if(0===b)break e;h[g++]=n.length,b--,n.mode=21;break;case 27:if(n.wrap){for(;v<32;){if(0===f)break e;f--,y|=u[p++]<<v,v+=8}if(E-=b,e.total_out+=E,n.total+=E,E&&(e.adler=n.check=n.flags?l(n.check,h,E,g-E):a(n.check,h,E,g-E)),E=b,(n.flags?y:m(y))!==n.check){e.msg="incorrect data check",n.mode=d;break}y=0,v=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;v<32;){if(0===f)break e;f--,y+=u[p++]<<v,v+=8}if(y!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=d;break}y=0,v=0}n.mode=29;case 29:X=1;break e;case d:X=-3;break e;case 31:return-4;case 32:default:return r}return e.next_out=g,e.avail_out=b,e.next_in=p,e.avail_in=f,n.hold=y,n.bits=v,(n.wsize||E!==e.avail_out&&n.mode<d&&(n.mode<27||4!==t))&&w(e,e.output,e.next_out,E-e.avail_out),k-=e.avail_in,E-=e.avail_out,e.total_in+=k,e.total_out+=E,n.total+=E,n.wrap&&E&&(e.adler=n.check=n.flags?l(n.check,h,E,e.next_out-E):a(n.check,h,E,e.next_out-E)),e.data_type=n.bits+(n.last?64:0)+(n.mode===c?128:0)+(20===n.mode||15===n.mode?256:0),(0===k&&0===E||4===t)&&0===X&&(X=-5),X},n.inflateEnd=function(e){if(!e||!e.state)return r;var t=e.state;return t.window&&(t.window=null),e.state=null,0},n.inflateGetHeader=function(e,t){var n;return e&&e.state?0==(2&(n=e.state).wrap)?r:(n.head=t,t.done=!1,0):r},n.inflateSetDictionary=function(e,t){var n,s=t.length;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?r:11===n.mode&&a(1,t,s,0)!==n.check?-3:w(e,t,s,s)?(n.mode=31,-4):(n.havedict=1,0):r},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,n){var s=e("../utils/common"),a=15,l=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],i=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],o=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],r=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(e,t,n,c,d,m,u,h){var p,g,f,b,y,v,x,w,k,E=h.bits,S=0,L=0,T=0,Z=0,C=0,P=0,R=0,I=0,W=0,M=0,X=null,N=0,G=new s.Buf16(16),Y=new s.Buf16(16),V=null,F=0;for(S=0;S<=a;S++)G[S]=0;for(L=0;L<c;L++)G[t[n+L]]++;for(C=E,Z=a;Z>=1&&0===G[Z];Z--);if(C>Z&&(C=Z),0===Z)return d[m++]=20971520,d[m++]=20971520,h.bits=1,0;for(T=1;T<Z&&0===G[T];T++);for(C<T&&(C=T),I=1,S=1;S<=a;S++)if(I<<=1,(I-=G[S])<0)return-1;if(I>0&&(0===e||1!==Z))return-1;for(Y[1]=0,S=1;S<a;S++)Y[S+1]=Y[S]+G[S];for(L=0;L<c;L++)0!==t[n+L]&&(u[Y[t[n+L]]++]=L);if(0===e?(X=V=u,v=19):1===e?(X=l,N-=257,V=i,F-=257,v=256):(X=o,V=r,v=-1),M=0,L=0,S=T,y=m,P=C,R=0,f=-1,b=(W=1<<C)-1,1===e&&W>852||2===e&&W>592)return 1;for(;;){x=S-R,u[L]<v?(w=0,k=u[L]):u[L]>v?(w=V[F+u[L]],k=X[N+u[L]]):(w=96,k=0),p=1<<S-R,T=g=1<<P;do{d[y+(M>>R)+(g-=p)]=x<<24|w<<16|k|0}while(0!==g);for(p=1<<S-1;M&p;)p>>=1;if(0!==p?(M&=p-1,M+=p):M=0,L++,0==--G[S]){if(S===Z)break;S=t[n+u[L]]}if(S>C&&(M&b)!==f){for(0===R&&(R=C),y+=T,I=1<<(P=S-R);P+R<Z&&!((I-=G[P+R])<=0);)P++,I<<=1;if(W+=1<<P,1===e&&W>852||2===e&&W>592)return 1;d[f=M&b]=C<<24|P<<16|y-m|0}}return 0!==M&&(d[y+M]=S-R<<24|64<<16|0),h.bits=C,0}},{"../utils/common":1}],10:[function(e,t,n){t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],11:[function(e,t,n){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/lib/inflate.js":[function(e,t,n){var s=e("./zlib/inflate"),a=e("./utils/common"),l=e("./utils/strings"),i=e("./zlib/constants"),o=e("./zlib/messages"),r=e("./zlib/zstream"),c=e("./zlib/gzheader"),d=Object.prototype.toString;function m(e){if(!(this instanceof m))return new m(e);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new r,this.strm.avail_out=0;var n=s.inflateInit2(this.strm,t.windowBits);if(n!==i.Z_OK)throw new Error(o[n]);if(this.header=new c,s.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=l.string2buf(t.dictionary):"[object ArrayBuffer]"===d.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=s.inflateSetDictionary(this.strm,t.dictionary))!==i.Z_OK))throw new Error(o[n])}function u(e,t){var n=new m(t);if(n.push(e,!0),n.err)throw n.msg||o[n.err];return n.result}m.prototype.push=function(e,t){var n,o,r,c,m,u=this.strm,h=this.options.chunkSize,p=this.options.dictionary,g=!1;if(this.ended)return!1;o=t===~~t?t:!0===t?i.Z_FINISH:i.Z_NO_FLUSH,"string"==typeof e?u.input=l.binstring2buf(e):"[object ArrayBuffer]"===d.call(e)?u.input=new Uint8Array(e):u.input=e,u.next_in=0,u.avail_in=u.input.length;do{if(0===u.avail_out&&(u.output=new a.Buf8(h),u.next_out=0,u.avail_out=h),(n=s.inflate(u,i.Z_NO_FLUSH))===i.Z_NEED_DICT&&p&&(n=s.inflateSetDictionary(this.strm,p)),n===i.Z_BUF_ERROR&&!0===g&&(n=i.Z_OK,g=!1),n!==i.Z_STREAM_END&&n!==i.Z_OK)return this.onEnd(n),this.ended=!0,!1;u.next_out&&(0!==u.avail_out&&n!==i.Z_STREAM_END&&(0!==u.avail_in||o!==i.Z_FINISH&&o!==i.Z_SYNC_FLUSH)||("string"===this.options.to?(r=l.utf8border(u.output,u.next_out),c=u.next_out-r,m=l.buf2string(u.output,r),u.next_out=c,u.avail_out=h-c,c&&a.arraySet(u.output,u.output,r,c,0),this.onData(m)):this.onData(a.shrinkBuf(u.output,u.next_out)))),0===u.avail_in&&0===u.avail_out&&(g=!0)}while((u.avail_in>0||0===u.avail_out)&&n!==i.Z_STREAM_END);return n===i.Z_STREAM_END&&(o=i.Z_FINISH),o===i.Z_FINISH?(n=s.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===i.Z_OK):o!==i.Z_SYNC_FLUSH||(this.onEnd(i.Z_OK),u.avail_out=0,!0)},m.prototype.onData=function(e){this.chunks.push(e)},m.prototype.onEnd=function(e){e===i.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=m,n.inflate=u,n.inflateRaw=function(e,t){return(t=t||{}).raw=!0,u(e,t)},n.ungzip=u},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")}));const vl={Uint8Array:Uint8Array,Int8Array:Int8Array,Uint16Array:Uint16Array,Int16Array:Int16Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Float32Array:Float32Array,Float64Array:Float64Array};const xl=e=>[[0,0],[0,1],[1,0],[1,1]];class wl extends cl{constructor(e,t){super(e,t)}containsPoint(e){return this.getDistanceAndPoint(e)[0]<=e.pointRadius?il.BORDER:il.NONE}draw(e,t){const n=this.getColor(t),s=this.isSelected(t);e.lineWidth=0;for(const a of this.label.points){e.fillStyle=n,e.beginPath();const[l,i]=nl(t,...a);e.arc(l,i,s?2*t.pointRadius:t.pointRadius,0,2*Math.PI),e.fill(),s&&(e.fillStyle="#ffffff",e.beginPath(),e.arc(l,i,t.pointRadius,0,2*Math.PI),e.fill())}}getMouseDistance(e){return this.getDistanceAndPoint(e)[0]}getPointInfo(e){return{color:this.getColor(e),field:this.field,label:this.label,point:this.getDistanceAndPoint(e)[1],type:"Keypoint"}}getPoints(){return kl([this.label])}getDistanceAndPoint(e){const t=[];let{canvasBBox:[n,s,a,l],pointRadius:i,relativeCoordinates:[o,r]}=e;i=this.isSelected(e)?2*i:i;for(const[c,d]of this.label.points){const e=jn(o*a,r*l,c*a,d*l);e<=1.15*i?t.push([0,[c,d]]):t.push([e,[c,d]])}return t.sort(((e,t)=>e[0]-t[0]))[0]}}const kl=e=>{let t=[];return e.forEach((e=>{t=[...t,...e.points]})),t};class El extends cl{containsPoint(e){const t=1.15*e.strokeWidth/$n([e.windowBBox[2],e.windowBBox[3]],e.config.dimensions);return this.getMouseDistance(e)<=t?il.BORDER:(this.label.closed||this.label.filled)&&this.label.points.some((t=>this.isPointInPath(e,t)))?il.CONTENT:il.NONE}draw(e,t){const n=this.getColor(t),s=this.isSelected(t);for(const a of this.label.points)a.length<2||(this.strokePath(e,t,a,n,this.label.filled),s&&this.strokePath(e,t,a,"#ffffff",!1,t.dashLength))}getMouseDistance(e){const t=[],[n,s]=e.config.dimensions,a=e.pixelCoordinates;for(const l of this.label.points){for(let e=0;e<l.length-1;e++)t.push(Bn(a,[n*l[e][0],s*l[e][1]],[n*l[e+1][0],s*l[e+1][1]]));this.label.closed&&t.push(Bn(a,[n*l[0][0],s*l[0][1]],[n*l[l.length-1][0],s*l[l.length-1][1]]))}return Math.min(...t)}getPointInfo(e){return{field:this.field,label:this.label,type:"Polyline",color:this.getColor(e)}}getPoints(){return Sl([this.label])}strokePath(e,t,n,s,a,l){e.beginPath(),e.lineWidth=t.strokeWidth,e.strokeStyle=s,e.setLineDash(l?[l]:[]),e.moveTo(...nl(t,n[0][0],n[0][1]));for(const[i,o]of n.slice(1))e.lineTo(...nl(t,i,o));if(a){e.fillStyle=s;const n=e.globalAlpha;e.globalAlpha=t.options.alpha,e.fill(),e.globalAlpha=n}this.label.closed&&e.closePath(),e.stroke()}isPointInPath(e,t){const[n,s]=e.config.dimensions,[a,l]=e.pixelCoordinates;let i=!1;this.label.closed&&(t=[...t,t[0]]);for(let o=0,r=t.length-1;o<t.length;r=o++){let e=t[o][0],c=t[o][1],d=t[r][0],m=t[r][1];[e,c]=[e*n,c*s],[d,m]=[d*n,m*s];c>l!=m>l&&a<(d-e)*(l-c)/(m-c)+e&&(i=!i)}return i}}const Sl=e=>{let t=[];return e.forEach((e=>{e.points.forEach((e=>{t=[...t,...e]}))})),t};const Ll=e=>[[0,0],[0,1],[1,0],[1,1]],Tl=e=>(t,n)=>[new e(t,n)],Zl=(e,t)=>(n,s)=>s[t].map((t=>new e(n,t))),Cl={Detection:Tl(gl),Detections:Zl(gl,"detections"),Heatmap:Tl(class{constructor(e,t){if(this.field=e,this.label=t,this.label.map){this.targets=new vl[this.label.map.data.arrayType](this.label.map.data.buffer),this.range=this.label.range?t.range:(n=this.targets)instanceof Float32Array||n instanceof Float64Array?[0,1]:[0,255];const[e,s]=this.label.map.data.shape;this.canvas=document.createElement("canvas"),this.canvas.width=s,this.canvas.height=e,this.imageData=new ImageData(new Uint8ClampedArray(this.label.map.image),s,e);const a=this.canvas.getContext("2d");a.imageSmoothingEnabled=!1,a.clearRect(0,0,this.label.map.data.shape[1],this.label.map.data.shape[0]),a.putImageData(this.imageData,0,0)}var n}containsPoint(e){const{pixelCoordinates:[t,n],config:{dimensions:[s,a]}}=e;return t>=0&&t<=s&&n>=0&&n<=a&&this.getTarget(e)?il.CONTENT:il.NONE}draw(e,t){const n=this.canvas.getContext("2d");n.imageSmoothingEnabled=!1,n.clearRect(0,0,this.label.map.data.shape[1],this.label.map.data.shape[0]),n.putImageData(this.imageData,0,0);const[s,a]=nl(t,0,0),[l,i]=nl(t,1,1),o=e.globalAlpha;e.globalAlpha=t.options.alpha,e.drawImage(this.canvas,s,a,l-s,i-a),e.globalAlpha=o,this.isSelected(t)&&ll(e,t,Xa(t.options.coloring.pool,t.options.coloring.seed,this.field))}getMouseDistance(e){return this.containsPoint(e)?0:1/0}getPointInfo(e){const t=this.getTarget(e);return{color:Ra(Pa(this.getColor(e,t))),label:r(o({},this.label),{map:{shape:this.label.map?this.label.map.data.shape:null}}),field:this.field,target:t,type:"Heatmap"}}getSelectData(){return{id:this.label.id,field:this.field}}isSelected(e){return e.options.selectedLabels.includes(this.label.id)}isShown(e){return e.options.activePaths.includes(this.field)}getPoints(){return xl()}getSizeBytes(){return sl(this.label)}getIndex(e){const[t,n]=this.getMapCoordinates(e);return t<0||n<0?-1:this.label.map.data.shape[1]*n+t}getMapCoordinates({pixelCoordinates:[e,t],config:{dimensions:[n,s]}}){const[a,l]=this.label.map.data.shape;return[Math.floor(e*(l/n)),Math.floor(t*(a/s))]}getColor(e,t){const[n,s]=this.range;if(0===t)return 0;if(e.options.coloring.byLabel){const a=Math.round(Math.max(t-n,0)/(s-n)*(e.options.coloring.scale.length-1));return Ca(e.options.coloring.scale[a])}const a=Xa(e.options.coloring.pool,e.options.coloring.seed,this.field),l=Math.max(Math.abs(n),Math.abs(s));return t=Math.min(l,Math.abs(t))/l,Ca(a,t/l)}getTarget(e){const t=this.getIndex(e);return t<0?null:this.targets[t]}}),Keypoint:Tl(wl),Keypoints:Zl(wl,"keypoints"),Polyline:Tl(El),Polylines:Zl(El,"polylines"),Segmentation:Tl(class{constructor(e,t){if(this.field=e,this.label=t,this.label.mask){this.targets=new vl[this.label.mask.data.arrayType](this.label.mask.data.buffer);const[e,t]=this.label.mask.data.shape;this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=e,this.imageData=new ImageData(new Uint8ClampedArray(this.label.mask.image),t,e);const n=this.canvas.getContext("2d");n.imageSmoothingEnabled=!1,n.clearRect(0,0,this.label.mask.data.shape[1],this.label.mask.data.shape[0]),n.putImageData(this.imageData,0,0)}}containsPoint(e){const{pixelCoordinates:[t,n],config:{dimensions:[s,a]}}=e;return t>=0&&t<=s&&n>=0&&n<=a&&this.getTarget(e)?il.CONTENT:il.NONE}draw(e,t){if(!this.targets)return;const[n,s]=nl(t,0,0),[a,l]=nl(t,1,1),i=e.globalAlpha;e.globalAlpha=t.options.alpha,e.drawImage(this.canvas,n,s,a-n,l-s),e.globalAlpha=i,this.isSelected(t)&&ll(e,t,Xa(t.options.coloring.pool,t.options.coloring.seed,this.field))}getMouseDistance(e){return this.containsPoint(e)?0:1/0}getPointInfo(e){const t=this.getTarget(e),n=e.options.coloring;let s=n.maskTargets[this.field];s&&s[this.field],s||(s=n.defaultMaskTargets);return{color:s&&1===Object.keys(s).length?Xa(e.options.coloring.pool,e.options.coloring.seed,this.field):n.targets[Math.round(Math.abs(t))%n.targets.length],label:r(o({},this.label),{mask:{shape:this.label.mask.data.shape?this.label.mask.data.shape:null}}),field:this.field,target:t,type:"Segmentation"}}getSelectData(){return{id:this.label.id,field:this.field}}isSelected(e){return e.options.selectedLabels.includes(this.label.id)}isShown(e){return e.options.activePaths.includes(this.field)}getPoints(){return Ll()}getSizeBytes(){return sl(this.label)}getIndex(e){const[t,n]=this.getMaskCoordinates(e);return t<0||n<0?-1:this.label.mask.data.shape[1]*n+t}getMaskCoordinates({pixelCoordinates:[e,t],config:{dimensions:[n,s]}}){const[a,l]=this.label.mask.data.shape;return[Math.floor(e*(l/n)),Math.floor(t*(a/s))]}getTarget(e){const t=this.getIndex(e);return t<0?null:this.targets[t]}})},Pl={Detection:e=>fl([e]),Detections:e=>fl(e.detections),Heatmap:e=>xl(),Keypoint:e=>kl([e]),Keypoints:e=>kl(e.keypoints),Polyline:e=>Sl([e]),Poylines:e=>Sl(e.polylines),Segmentation:e=>Ll()},Rl=(e,t=!1)=>{const n=[];let s=[];for(const a in e){const t=e[a];if(t)if(t._cls in Cl){const e=Cl[t._cls](a,t,void 0);s=[...s,...e]}else Vn.includes(t._cls)&&n.push([a,t._cls in Fn?t[Fn[t._cls]]:[t]])}if(n.length>0){const e=t?new ml(n):new dl(n);s.push(e)}return s},Il={activePaths:[],selectedLabels:[],showConfidence:!1,showIndex:!1,showJSON:!1,showLabel:!1,showTooltip:!1,onlyShowHoveredLabel:!1,filter:null,coloring:{byLabel:!1,pool:["#000000"],scale:null,seed:0,maskTargets:{},defaultMaskTargets:null,targets:["#000000"]},smoothMasks:!0,hasNext:!1,hasPrevious:!1,fullscreen:!1,zoomPad:.1,selected:!1,fieldsMap:{},inSelectionMode:!1,timeZone:"UTC",mimetype:"",alpha:.7},Wl=r(o({},Il),{useFrameNumber:!0,zoom:!1}),Ml=r(o({},Il),{zoom:!1}),Xl=r(o({},Il),{autoplay:!1,loop:!1,playbackRate:1,useFrameNumber:!1,volume:0,frameFieldsMap:{}}),Nl=(e,t)=>{const n=t.map((t=>t.getPoints(e))).flat();let[s,a]=e.config.dimensions,[l,i]=[s,a];const o=l/i,{center:[r,c],box:[d,m,u,h]}=(([e,t],[n,s,a,l])=>{const i=a/l;let[o,r,c,d]=[n,s,a,l];return c*e<16&&(c=16/e,d=c/i,o=n+a/2-c/2,r=s+l/2-d/2),d*t<16&&(d=16/t,c=d*i,o=n+a/2-c/2,r=s+l/2-d/2),{center:[n+a/2,s+l/2],box:[o,r,c,d]}})([l,i],Jn(n)),[p,g,f,b]=e.windowBBox;let y=f/b,v=1,x=[0,0];const w=1-e.options.zoomPad;y<o?(v=Math.max(1,1/u),l=f*v,i=l/o,!e.config.thumbnail&&h*i>b&&(v=Math.max(1,b*v/(h*i)),l=f*v,i=l/o)):(v=Math.max(1,1/h),i=b*v,l=i*o,!e.config.thumbnail&&u*l>f&&(v=Math.max(1,f*v/(u*l)),i=b*v,l=i*o));return x=[-l*r-(v*f-l)/2+f/2,-i*c-(v*b-i)/2+b/2],(l*w>f&&i*w>b||!e.config.thumbnail)&&(v*=w,x[0]=x[0]*w+u*l*(1-w)/2,x[1]=x[1]*w+h*i*(1-w)/2),x=qn(v,x,[f,b],[s,a],!e.config.thumbnail),ts(e,{scale:v,pan:x})},Gl={requestColor:[(e,{key:t,pool:n,seed:s})=>{e.postMessage({method:"resolveColor",key:t,seed:s,color:Xa(n,s,t)})}]},Yl=(()=>{const e=[];for(let n=0;n<1;n++)e.push(ns(Gl));let t=-1;return()=>(t++,t%=1,e[t])})();class Vl{constructor(e,t,n={}){this.eventTarget=new EventTarget,this.updater=this.makeUpdate(),this.state=this.getInitialState(t,n),this.loadSample(e),this.state.options.mimetype=(e=>e.metadata&&e.metadata.mime_type||v.getType(e.filepath)||"image/jpg")(e),this.state.config.thumbnail||(this.state.showControls=!0),this.pluckedOverlays=[],this.currentOverlays=[],this.lookerElement=this.getElements(t),this.canvas=this.lookerElement.children[1].element,this.ctx=this.canvas.getContext("2d"),this.resizeObserver=new ResizeObserver((()=>{const e=Qn(this.lookerElement.element);e[2]&&e[3]&&this.lookerElement&&this.updater({windowBBox:e})}))}loadOverlays(e){this.sampleOverlays=Rl(e)}pluckOverlays(e){return this.sampleOverlays}dispatchEvent(e,t){"error"===e&&this.updater({error:t.error||!0}),this.eventTarget.dispatchEvent(new CustomEvent(e,{detail:t}))}dispatchImpliedEvents(e,t){}getDispatchEvent(){return(e,t)=>{"copy"!==e?"selectthumbnail"!==e?this.dispatchEvent(e,t):this.dispatchEvent(e,this.sample.id):this.getSample().then((e=>S(JSON.stringify(e,null,4))))}}makeUpdate(){return(e,t)=>{const n=e instanceof Function?e(this.state):e;if(!this.lookerElement||0===Object.keys(n).length&&!t)return;if(this.previousState=this.state,this.state=ts(this.state,n),!this.state.windowBBox||this.state.destroyed||!this.state.overlaysPrepared)return;if(this.pluckedOverlays=this.pluckOverlays(this.state),this.state=this.postProcess(),[this.currentOverlays,this.state.rotate]=pl(this.state,this.pluckedOverlays),this.state.mouseIsOnOverlay=Boolean(this.currentOverlays.length)&&this.currentOverlays[0].containsPoint(this.state)>il.NONE,t&&t(this.state,this.currentOverlays),this.dispatchImpliedEvents(this.previousState,this.state),this.state.options.showJSON){const e=this.lookerElement.element.querySelectorAll("pre")[0];this.getSample().then((t=>{e.innerHTML=L(t,On)}))}const s=this.ctx;if(this.lookerElement.render(this.state,this.sample),!this.state.loaded||this.state.destroyed||this.waiting)return;s.lineWidth=this.state.strokeWidth,s.font=`bold ${this.state.fontSize.toFixed(2)}px Palanquin`,s.textAlign="left",s.textBaseline="bottom",s.imageSmoothingEnabled=!1,s.setTransform(1,0,0,1,0,0);const a=ls();s.clearRect(0,0,this.state.windowBBox[2]*a,this.state.windowBBox[3]*a),s.translate(this.state.pan[0]*a,this.state.pan[1]*a);const l=this.state.scale*a;s.scale(l,l);const[i,o,r,c]=this.state.canvasBBox;s.drawImage(this.getImageSource(),0,0,this.state.config.dimensions[0],this.state.config.dimensions[1],i,o,r,c),s.globalAlpha=Math.min(1,this.state.options.alpha/.7);for(let d=this.currentOverlays.length-1;d>=0;d--)this.currentOverlays[d].draw(s,this.state);s.globalAlpha=1}}addEventListener(e,t,...n){this.eventTarget.addEventListener(e,t,...n)}removeEventListener(e,t,...n){this.eventTarget.removeEventListener(e,t,...n)}attach(e,t){"string"==typeof e&&(e=document.getElementById(e)),e!==this.lookerElement.element.parentElement?(this.lookerElement.element.parentElement&&(this.resizeObserver.disconnect(),this.lookerElement.element.parentElement.removeChild(this.lookerElement.element)),this.updater({windowBBox:t?[0,0,...t]:Qn(e)}),e.appendChild(this.lookerElement.element),!t&&this.resizeObserver.observe(e)):this.state.disabled&&this.updater({disabled:!1})}resize(e){this.updater({windowBBox:[0,0,...e]})}detach(){this.resizeObserver.disconnect(),this.lookerElement.element.parentNode&&this.lookerElement.element.parentNode.removeChild(this.lookerElement.element)}updateSample(e){this.loadSample(e)}getSample(){let e=o({},this.sample);return Promise.resolve(jl(this.state,e,this.state.options.fieldsMap))}getCurrentSampleLabels(){const e=[];return this.currentOverlays.forEach((t=>{if(t instanceof dl)t.getFilteredAndFlat(this.state).forEach((([t,n])=>{e.push({field:t,label_id:n.id,sample_id:this.sample.id})}));else{const{id:n,field:s}=t.getSelectData(this.state);e.push({label_id:n,field:s,sample_id:this.sample.id})}})),e}get waiting(){return!1}destroy(){this.resizeObserver.disconnect(),this.lookerElement.element.parentElement&&this.lookerElement.element.parentElement.removeChild(this.lookerElement.element),this.updater({destroyed:!0})}disable(){this.updater({disabled:!0})}getImageSource(){return this.lookerElement.children[0].imageSource}getInitialBaseState(){return{disabled:!1,cursorCoordinates:[0,0],pixelCoordinates:[0,0],relativeCoordinates:[0,0],disableControls:!1,hovering:!1,hoveringControls:!1,showControls:!1,showHelp:!1,showOptions:!1,loaded:!1,scale:1,pan:[0,0],rotate:0,panning:!1,strokeWidth:3,dashLength:8,fontSize:16,wheeling:!1,transformedWindowBBox:null,windowBBox:null,transformedMediaBBox:null,mediaBBox:null,canvasBBox:null,textPad:4,pointRadius:4,mouseIsOnOverlay:!1,overlaysPrepared:!1,disableOverlays:!1,zoomToContent:!1,setZoom:!0,hasDefaultZoom:!0,SHORTCUTS:Vs,error:null,destroyed:!1,reloading:!1}}postProcess(){let[e,t,n,s]=this.state.windowBBox;return this.state.pan=qn(this.state.scale,this.state.pan,[n,s],this.state.config.dimensions),this.state.mediaBBox=_n(this.state.config.dimensions,this.state.windowBBox),this.state.transformedWindowBBox=[e+this.state.pan[0],t+this.state.pan[1],this.state.scale*n,this.state.scale*s],this.state.transformedMediaBBox=_n(this.state.config.dimensions,this.state.transformedWindowBBox),this.state.canvasBBox=[this.state.mediaBBox[0]-this.state.windowBBox[0],this.state.mediaBBox[1]-this.state.windowBBox[1],this.state.mediaBBox[2],this.state.mediaBBox[3]],this.state.relativeCoordinates=[(this.state.cursorCoordinates[0]-this.state.transformedMediaBBox[0])/this.state.transformedMediaBBox[2],(this.state.cursorCoordinates[1]-this.state.transformedMediaBBox[1])/this.state.transformedMediaBBox[3]],this.state.pixelCoordinates=[this.state.relativeCoordinates[0]*this.state.config.dimensions[0],this.state.relativeCoordinates[1]*this.state.config.dimensions[1]],this.state.fontSize=16/this.state.scale,this.state.pointRadius=4/this.state.scale,this.state.strokeWidth=3/this.state.scale,this.state.dashLength=8/this.state.scale,this.state.config.thumbnail&&(this.state.strokeWidth/=3),this.state.textPad=4/this.state.scale,this.state.hasDefaultZoom=this.hasDefaultZoom(this.state,this.pluckedOverlays),this.state}hasResized(){var e,t;return Boolean(!(null==(e=this.previousState)?void 0:e.windowBBox)||!(null==(t=this.state)?void 0:t.windowBBox)||this.previousState.windowBBox.some(((e,t)=>e!==this.state.windowBBox[t])))}loadSample(e){const t=x(),n=Yl(),s=({data:{sample:e,uuid:a}})=>{a===t&&(this.sample=e,this.loadOverlays(e),this.updater({overlaysPrepared:!0,disabled:!1,reloading:!1}),n.removeEventListener("message",s))};n.addEventListener("message",s),n.postMessage({method:"processSample",coloring:this.state.options.coloring,sample:e,uuid:t})}}class Fl extends Vl{getElements(e){return((e,t,n)=>gs(e,{node:ba,children:[{node:za},{node:hs},{node:ua},{node:Na},{node:Da},{node:ga},{node:Js},{node:aa,children:[{node:Oa},{node:ia},{node:oa},{node:da},{node:la},{node:ma},{node:ca},{node:ra}]},{node:sa},{node:na},{node:ya,children:[{node:xa},{node:wa},{node:ka},{node:Ea},{node:Sa}]}]},t,n))(e,this.updater,this.getDispatchEvent())}getInitialState(e,t){return t=o(o({},this.getDefaultOptions()),t),r(o({duration:null},this.getInitialBaseState()),{config:o({},e),options:t,SHORTCUTS:Vs})}getDefaultOptions(){return Wl}hasDefaultZoom(e,t){let n=[0,0],s=1;if(e.options.zoom){const a=Nl(e,t);n=a.pan,s=a.scale}return s===e.scale&&n[0]===e.pan[0]&&n[1]===e.pan[1]}postProcess(){return this.state.setZoom||(this.state.setZoom=this.hasResized()),this.state.zoomToContent?Ul(this.state,this.currentOverlays):this.state.setZoom&&this.state.overlaysPrepared&&(this.state.options.zoom?this.state=Nl(this.state,this.pluckedOverlays):(this.state.pan=[0,0],this.state.scale=1),this.state.setZoom=!1),super.postProcess()}updateOptions(e){const t=Al(this.state.options,e),n={options:e};void 0!==e.zoom&&(n.setZoom=this.state.options.zoom!==e.zoom),t?(this.updater(r(o({},n),{reloading:this.state.disabled})),this.updateSample(this.sample)):this.updater(r(o({},n),{disabled:!1}))}}class Kl extends Vl{getElements(e){return((e,t,n)=>gs(e,{node:ba,children:[{node:Ha},{node:hs},{node:ua},{node:Na},{node:Da},{node:ga},{node:Js},{node:aa,children:[{node:Oa},{node:ia},{node:oa},{node:da},{node:la},{node:ma},{node:ca},{node:ra}]},{node:sa},{node:na},{node:ya,children:[{node:xa},{node:wa},{node:ka},{node:Ea},{node:Sa}]}]},t,n))(e,this.updater,this.getDispatchEvent())}getInitialState(e,t){return t=o(o({},this.getDefaultOptions()),t),r(o({},this.getInitialBaseState()),{config:o({},e),options:t,SHORTCUTS:Vs})}getDefaultOptions(){return Ml}hasDefaultZoom(e,t){let n=[0,0],s=1;if(e.options.zoom){const a=Nl(e,t);n=a.pan,s=a.scale}return s===e.scale&&n[0]===e.pan[0]&&n[1]===e.pan[1]}postProcess(){return this.state.setZoom||(this.state.setZoom=this.hasResized()),this.state.zoomToContent?Ul(this.state,this.currentOverlays):this.state.setZoom&&this.state.overlaysPrepared&&(this.state.options.zoom?this.state=Nl(this.state,this.pluckedOverlays):(this.state.pan=[0,0],this.state.scale=1),this.state.setZoom=!1),super.postProcess()}updateOptions(e){const t=Al(this.state.options,e),n={options:e};void 0!==e.zoom&&(n.setZoom=this.state.options.zoom!==e.zoom||this.state.config.thumbnail),t?(this.updater(r(o({},n),{reloading:this.state.disabled})),this.updateSample(this.sample)):this.updater(r(o({},n),{disabled:!1}))}}const{aquireReader:Dl,addFrame:Ol}=(()=>{let e,t=new E({max:1e9,length:e=>{let t=1;return e.overlays.forEach((e=>{t+=e.getSizeBytes()})),t},dispose:(e,t)=>{const n=e.deref();n&&n(t.sample.frame_number)}}),n=0,s=null,a=!1,l=null;const i=({addFrame:l,addFrameBuffers:i,removeFrame:o,frameNumber:r,frameCount:c,sampleId:d,update:m,dispatchEvent:u,coloring:h})=>{n=0,s=[r,Math.min(c,20+r)];const p=x();return e&&e.terminate(),e=ns(Gl),e.onmessage=({data:r})=>{if(r.error&&u("error",{error:"Frames"}),r.uuid!==p||"frameChunk"!==r.method)return;const{frames:d,range:[h,g]}=r;i([h,g]);for(let e=h;e<=g;e++){const n={sample:{frame_number:e},overlays:[]};t.set(new WeakRef(o),n),l(e,n)}for(let e=0;e<d.length;e++){const s=d[e],a=Object.fromEntries(Object.entries(s).map((([e,t])=>["frames."+e,t]))),i=Rl(a);i.forEach((e=>{n+=e.getSizeBytes()}));const r={sample:s,overlays:i};t.set(new WeakRef(o),r),l(s.frame_number,r)}n<1e9&&g<c?(s=[g+1,Math.min(c,g+1+20)],a=!0,e.postMessage({method:"requestFrameChunk",uuid:p})):(a=!1,s=null),m((e=>(e.buffering&&u("buffering",!1),{buffering:!1})))},a=!0,e.postMessage({method:"setStream",sampleId:d,frameCount:c,frameNumber:r,uuid:p,url:is()?`http://localhost:${rs}`:window.location.protocol+"//"+os,coloring:h}),p};return{aquireReader:n=>{l=n;let c=i(l);return(n,d)=>{d||!s||n<s[0]&&n>s[1]?(d&&t.reset(),s=[n,n+20],c=i(r(o({},l),{frameNumber:n}))):a||e.postMessage({method:"requestFrameChunk",uuid:c}),a=!0}},addFrame:(e,n)=>{t.set(new WeakRef(e),n)}}})();let zl=null;class Hl extends Vl{constructor(){super(...arguments),this.frames=new Map}get frameNumber(){return this.state.frameNumber}get playing(){return this.state.playing}get waiting(){const e=this.lookerElement.children[0].element;return e&&(e.seeking||e.readyState<2||!this.hasFrame(this.state.frameNumber))}destroy(){this.pause(),super.destroy()}dispatchImpliedEvents(e,t){const n=e.playing&&!e.buffering,s=t.playing&&!t.buffering;n!==s&&(s&&this.dispatchEvent("play",null),!s&&this.dispatchEvent("pause",{buffering:t.buffering}))}getCurrentSampleLabels(){const e=[];return pl(this.state,this.sampleOverlays)[0].forEach((t=>{if(t instanceof dl)t.getFilteredAndFlat(this.state).forEach((([t,n])=>{e.push({field:t,label_id:n.id,sample_id:this.sample.id})}));else{const{id:n,field:s}=t.getSelectData(this.state);e.push({label_id:n,field:s,sample_id:this.sample.id})}})),e}getCurrentFrameLabels(){const e=this.frames.get(this.frameNumber).deref(),t=[];return e&&pl(this.state,e.overlays)[0].forEach((e=>{if(e instanceof dl)e.getFilteredAndFlat(this.state).forEach((([e,n])=>{t.push({field:e,label_id:n.id,frame_number:this.frameNumber,sample_id:this.sample.id})}));else{const{id:n,field:s}=e.getSelectData(this.state);t.push({label_id:n,field:s,sample_id:this.sample.id,frame_number:this.frameNumber})}})),t}getElements(e){return tl(e,this.updater,this.getDispatchEvent())}getInitialState(e,t){const n=e.support?e.support[0]:1;return r(o({duration:null,seeking:!1,fragment:null,playing:!1,frameNumber:n,buffering:!1},this.getInitialBaseState()),{config:o({},e),options:o(o({},this.getDefaultOptions()),t),buffers:[[n,n]],seekBarHovering:!1,SHORTCUTS:Bs,hasPoster:!1,waitingForVideo:!1,lockedToSupport:Boolean(e.support)})}hasDefaultZoom(e,t){let n=[0,0];return 1===e.scale&&n[0]===e.pan[0]&&n[1]===e.pan[1]}loadOverlays(e){this.sampleOverlays=Rl(Object.fromEntries(Object.entries(e).filter((([e])=>"frames"!==e))),!0);const t=e.frames.length?e.frames:[{frame_number:1}],n=t.map((e=>Rl(Object.fromEntries(Object.entries(e).map((([e,t])=>["frames."+e,t]))))));t.map(((e,t)=>({sample:e,overlays:n[t]}))).forEach((e=>{const t=e.sample.frame_number;Ol((e=>ss(e,this.state.buffers)),e),this.frames.set(e.sample.frame_number,new WeakRef(e)),as([t,t],this.state.buffers)}))}pluckOverlays(e){var t;const n=e.frameNumber;let s=!1;if(e.config.support&&!e.lockedToSupport){const[t,a]=e.config.support;s=n<t||n>a}let a=s?[]:this.sampleOverlays;if(this.hasFrame(e.frameNumber)){const n=null==(t=this.frames.get(e.frameNumber))?void 0:t.deref();void 0!==n&&(a=[...a,...n.overlays])}let l=null;return null!==this.state.duration&&(l=bs(this.state.duration,this.state.duration,this.state.config.frameRate)),e.config.thumbnail&&!e.playing||zl===this||null===l?zl!==this&&l&&(this.state.buffering&&this.dispatchEvent("buffering",!1),this.state.playing=!1,this.state.buffering=!1):(zl&&zl.pause(),this.setReader(),zl=this,this.state.buffers=[[1,1]]),zl===this&&(this.hasFrame(Math.min(l,e.frameNumber+1))?(this.state.buffering&&this.dispatchEvent("buffering",!1),this.state.buffering=!1):(this.state.buffering=!0,this.dispatchEvent("buffering",!0),this.requestFrames(e.frameNumber))),a}setReader(){this.requestFrames=Dl({addFrame:(e,t)=>this.frames.set(e,new WeakRef(t)),addFrameBuffers:e=>this.state.buffers=as(e,this.state.buffers),removeFrame:e=>ss(e,this.state.buffers),getCurrentFrame:()=>this.frameNumber,sampleId:this.state.config.sampleId,frameCount:bs(this.state.duration,this.state.duration,this.state.config.frameRate),frameNumber:this.state.frameNumber,update:this.updater,dispatchEvent:(e,t)=>this.dispatchEvent(e,t),coloring:this.state.options.coloring})}getSample(){return new Promise((e=>{const t=n=>{this.hasFrame(this.state.frameNumber)?e(r(o({},n),{frames:[o({frame_number:this.frameNumber},jl(this.state,o({},this.frames.get(this.frameNumber).deref().sample),this.state.options.frameFieldsMap,"frames."))]})):setTimeout(t,200)};super.getSample().then(t)}))}getDefaultOptions(){return Xl}play(){this.updater((({playing:e})=>e?{}:{playing:!0}))}pause(){this.updater((({playing:e})=>e?{playing:!1}:{}))}postProcess(){return this.state.seeking?this.state.disableOverlays=!0:this.state.playing||this.state.buffering||(this.state.disableOverlays=!1),this.state.setZoom||(this.state.setZoom=this.hasResized()),this.state.setZoom||(this.state.setZoom=this.hasResized()),this.state.zoomToContent?Ul(this.state,this.currentOverlays):this.state.setZoom&&(this.state.pan=[0,0],this.state.scale=1,this.state.setZoom=!1),super.postProcess()}updateOptions(e){Al(this.state.options,e)?(this.updater({options:e,reloading:this.state.disabled}),this.updateSample(this.sample)):this.updater({options:e,disabled:!1})}updateSample(e){this.state.buffers=[[1,1]],this.frames.clear(),super.updateSample(e),this.setReader()}hasFrame(e){var t;return this.frames.has(e)&&void 0!==(null==(t=this.frames.get(e))?void 0:t.deref())}}const Ul=(e,t)=>{if(e.options.selectedLabels){const n=new Set(e.options.selectedLabels),s=t.filter((t=>!(t instanceof dl)&&n.has(t.getSelectData(e).id)));s.length&&(t=s)}const{pan:n,scale:s}=Nl(e,t);e.pan[0]===n[0]&&e.pan[1]===n[1]&&e.scale===s?(e.pan=[0,0],e.scale=1):(e.pan=n,e.scale=s),e.zoomToContent=!1},jl=(e,t,n,s="")=>{for(let a in t)if(n.hasOwnProperty(a))t[n[a]]=t[a],a!==n[a]&&delete t[a];else if(a.startsWith("_"))delete t[a];else if(t[a]&&"DateTime"===t[a]._cls)t[a]=new Date(t[a].datetime);else if(Array.isArray(t[a]))t[a]=t[a].map((e=>e&&"DateTime"===e._cls?new Date(t[a].datetime):e));else if(t[a]&&t[a]._cls&&Cl.hasOwnProperty(t[a]._cls)){if(!e.options.activePaths.includes(s+a)){delete t[a];continue}Fn[t[a]._cls]?t[a]=r(o({},t[a]),{[Fn[t[a]._cls]]:t[a][Fn[t[a]._cls]].filter((t=>e.options.filter[s+a](t))).map((e=>(Kn.has(e._cls)&&e.mask&&(e.mask={shape:e.mask.shape}),e)))}):e.options.filter[s+a](t[a])?Kn.has(t[a]._cls)&&t[a].mask&&t[a].mask.data?t[a]=r(o({},t[a]),{mask:{shape:t[a].mask.data.shape}}):"Heatmap"===t[a]._cls&&t[a].map&&t[a].map.data&&(t[a]=r(o({},t[a]),{map:{shape:t[a].map.data.shape}})):delete t[a]}return t},Al=(e,t)=>{let n=!1;return(t.coloring&&e.coloring.seed!==t.coloring.seed||t.coloring&&t.coloring.byLabel!==e.coloring.byLabel)&&(n=!0),n},Bl=T({key:"isModalActive",get:({get:e})=>Boolean(e(ut))}),Jl=T({key:"refresh",get:({get:e})=>e(St).refresh});T({key:"deactivated",get:({get:e})=>{var t;const n=vn,s=null==(t=e(St))?void 0:t.active_handle;return!!bn&&(n!==s&&"string"==typeof s)}});const _l=T({key:"fiftyone",get:async()=>{let e=null;do{try{e=await(await fetch(`${Sn}/fiftyone`)).json()}catch{}if(e)break;await new Promise((e=>setTimeout(e,2e3)))}while(null===e);return e}}),Ql=T({key:"showTeamsButton",get:({get:e})=>{const t=e(_l).teams,n=e(yt),s=window.localStorage.getItem("fiftyone-teams");return s&&(window.localStorage.removeItem("fiftyone-teams"),fetch(`${Sn}/teams?submitted=true`,{method:"post"})),t.submitted||n.submitted||"submitted"===s?"hidden":t.minimized||n.minimized?"minimized":"shown"}}),$l=T({key:"datasetName",get:({get:e})=>{const t=e(St);return t.dataset?t.dataset.name:null}}),ql=T({key:"viewCls",get:({get:e})=>e(St).view_cls}),ei=T({key:"isRootView",get:({get:e})=>[void 0,null,"fiftyone.core.view.DatasetView"].includes(e(ql))}),ti=["fiftyone.core.patches.PatchesView","fiftyone.core.patches.EvaluationPatchesView"];var ni,si,ai,li;(si=ni||(ni={})).CLIP="clip",si.FRAME="frame",si.PATCH="patch",si.SAMPLE="sample",(li=ai||(ai={})).CLIP="clips",li.FRAME="frames",li.PATCH="patches",li.SAMPLE="samples";const ii=T({key:"rootElementName",get:({get:e})=>{const t=e(ql);return ti.includes(t)?ni.PATCH:"fiftyone.core.clips.ClipsView"===t?ni.CLIP:"fiftyone.core.video.FramesView"===t?ni.FRAME:ni.SAMPLE}}),oi=T({key:"rootElementNamePlural",get:({get:e})=>{switch(e(ii)){case ni.CLIP:return ai.CLIP;case ni.FRAME:return ai.FRAME;case ni.PATCH:return ai.PATCH;default:return ai.SAMPLE}}}),ri=T({key:"elementNames",get:({get:e})=>({plural:e(oi),singular:e(ii)})}),ci=T({key:"isClipsView",get:({get:e})=>e(ii)===ni.CLIP}),di=T({key:"isPatchesView",get:({get:e})=>e(ii)===ni.PATCH}),mi=T({key:"isFramesView",get:({get:e})=>e(ii)===ni.FRAME}),ui=T({key:"datasets",get:({get:e})=>{var t;return null!=(t=e(St).datasets)?t:[]}}),hi=T({key:"hasDataset",get:({get:e})=>Boolean(e($l))}),pi=T({key:"mediaType",get:({get:e})=>{const t=e(St);return t.dataset?t.dataset.media_type:null}}),gi=T({key:"isVideoDataset",get:({get:e})=>"video"===e(pi)}),fi=T({key:"view",get:({get:e})=>e(St).view||[],set:({get:e,set:t},n)=>{const s=e(St),a=r(o({},s),{view:n,selected:[],selected_labels:[],filters:{}});t(St,a),Zn.send(Cn("update",{state:a}))}}),bi=T({key:"datasetStats",get:({get:e})=>{const t=e(xt),n=e(fi);return t.view&&In(t.view,n)?t.stats:null}}),yi=e=>{const t=Object.keys(e).sort(),n=t.map((t=>e[t]));return JSON.stringify([t,n])},vi=(e,t)=>yi(e)===yi(t),xi=T({key:"extendedDatasetStats",get:({get:e})=>{const t=e(wt),n=e(fi);if(!t.view)return null;if(!In(t.view,n))return null;const s=e(wi);return vi(t.filters,s)?t.stats:null}}),wi=T({key:"filterStages",get:({get:e})=>e(St).filters,set:({get:e,set:t},n)=>{const s=r(o({},e(St)),{filters:n});s.selected=[],t(Lt,new Set),Zn.send(Cn("filters_update",{filters:n})),t(St,s)}}),ki=T({key:"totalCount",get:({get:e})=>(e(bi)||[]).reduce(((e,t)=>null===t.name?t.result:e),null)}),Ei=T({key:"filteredCount",get:({get:e})=>(e(xi)||[]).reduce(((e,t)=>null===t.name?t.result:e),null)});T({key:"currentCount",get:({get:e})=>e(Ei)||e(ki)});const Si=T({key:"labelTagsPaths",get:({get:e})=>{const t=e(Ni);return e(Xi).map((e=>`${e=Nt.includes(t[e])?`${e}.${t[e].toLocaleLowerCase()}`:e}.tags`))}}),Li=Z({key:"fieldSchema",get:e=>({get:t})=>(t(St).dataset||{})[e+"_fields"]||[]}),Ti=e=>!e.name.startsWith("_")&&"tags"!==e.name&&(!!ln.includes(e.ftype)||!(!an.includes(e.ftype)||!ln.includes(e.subfield))),Zi=Z({key:"fields",get:e=>({get:t})=>t(Li(e)).reduce(((e,t)=>(e[t.name]=t,e)),{})}),Ci=Z({key:"selectedFields",get:e=>({get:t})=>{const n=t(fi),s=o({},t(Zi(e))),a=t(gi);return n.forEach((({_cls:t,kwargs:n})=>{if("fiftyone.core.stages.SelectFields"===t){const t=n[0][1]?n[0][1]:[];let l=new Set([...t,...rn]);a&&"frame"===e&&(l=new Set(Array.from(l).map((e=>e.slice("frames.".length))))),Object.keys(s).forEach((e=>{l.has(e)||delete s[e]}))}else if("fiftyone.core.stages.ExcludeFields"===t){const t=n[0][1]?n[0][1]:[];let l=Array.from(t);a&&"frame"===e?l=l.map((e=>e.slice("frames.".length))):a&&(l=l.filter((e=>e.startsWith("frames.")))),l.forEach((e=>{delete s[e]}))}})),s}}),Pi=T({key:"gridZoom",get:({get:e})=>e(ji).grid_zoom,set:({get:e,set:t},n)=>{const s=e(St),a=r(o({},s),{config:r(o({},s.config),{grid_zoom:n})});t(St,a),Zn.send(Cn("update",{state:a}))}}),Ri=T({key:"timeZone",get:({get:e})=>e(ji).timezone||"UTC"}),Ii=T({key:"fieldPaths",get:({get:e})=>{const t=e=>!e.startsWith("_"),n=Object.keys(e(Ci("sample"))).filter(t);return"video"===e(pi)?n.concat(Object.keys(e(Ci("frame"))).filter(t).map((e=>"frames."+e))).sort():n.sort()}}),Wi=Z({key:"labels",get:e=>({get:t})=>{const n=t(Ci(e)),s=t(gi)&&t(ei);return Object.keys(n).map((e=>n[e])).filter(((e,t)=>n=>{if(!n.embedded_doc_type)return!1;const s=n.embedded_doc_type.split(".").slice(-1)[0];return("frame"!==t&&e||!Ht.includes(s))&&Ft.includes(s)})(s,e)).sort(((e,t)=>e.name<t.name?-1:1))}}),Mi=Z({key:"labelNames",get:e=>({get:t})=>t(Wi(e)).map((e=>e.name))}),Xi=T({key:"labelPaths",get:({get:e})=>{const t=e(Mi("sample")),n=e(Mi("frame"));return t.concat(n.map((e=>"frames."+e)))}}),Ni=T({key:"labelTypesMap",get:({get:e})=>{const t=e(Mi("sample")),n=e(Gi("sample")),s=e(Mi("frame")),a=e(Gi("frame")),l=t.map(((e,t)=>[e,n[t]])),i=s.map(((e,t)=>[`frames.${e}`,a[t]]));return Object.fromEntries(l.concat(i))}}),Gi=Z({key:"labelTypes",get:e=>({get:t})=>t(Wi(e)).map((e=>e.embedded_doc_type.split(".").slice(-1)[0]))}),Yi=Z({key:"primitives",get:e=>({get:t})=>{const n=t(Ci(e));return Object.keys(n).map((e=>n[e])).filter(Ti)}}),Vi=Z({key:"primitiveNames",get:e=>({get:t})=>t(Yi(e)).map((e=>e.name))}),Fi=Z({key:"primitiveTypes",get:e=>({get:t})=>t(Yi(e)).map((e=>e.ftype))}),Ki=Z({key:"primitiveSubfields",get:e=>({get:t})=>t(Yi(e)).map((e=>e.subfield))}),Di=Z({key:"primitivesSchema",get:e=>({get:t})=>Object.fromEntries(t(Yi(e)).map((e=>[e.name,e])))}),Oi=Z({key:"labelTuples",get:e=>({get:t})=>{const n=t(Gi(e));return t(Mi(e)).map(((e,t)=>[e,n[t]]))}});Z({key:"labelMap",get:e=>({get:t})=>t(Oi(e)).reduce(((e,t)=>o({[t[0]]:t[1]},e)),{})});const zi=Z({key:"primitivesMap",get:e=>({get:t})=>{const n=t(Fi(e));return t(Vi(e)).reduce(((e,t,s)=>r(o({},e),{[t]:n[s]})),{})}}),Hi=Z({key:"primitivesSubfieldMap",get:e=>({get:t})=>{const n=t(Ki(e));return t(Vi(e)).reduce(((e,t,s)=>r(o({},e),{[t]:n[s]})),{})}}),Ui=Z({key:"primitivesDbMap",get:e=>({get:t})=>{const n=t(Yi(e));return t(Vi(e)).reduce(((e,t,s)=>r(o({},e),{[t]:n[s].db_field})),{media_type:"_media_type"})}}),ji=T({key:"appConfig",get:({get:e})=>e(St).config||{}}),Ai=Z({key:"colorMap",get:e=>({get:t})=>{t(Pt(e));let n=t(It);n=n.length?n:[Nn.brand];const s=t(Wt(e));return Ma(n,s)}}),Bi=Z({key:"coloring",get:e=>({get:t})=>{const n=t(It),s=t(Wt(e));return{seed:s,pool:n,scale:t(St).colorscale,byLabel:t(Pt(e)),defaultMaskTargets:t(Ji),maskTargets:t(_i).fields,targets:new Array(n.length).fill(0).map(((e,t)=>Xa(n,s,t)))}}});Z({key:"labelNameGroups",get:e=>({get:t})=>function(e,t,n){const s={labels:[],scalars:[],unsupported:[]};for(let a=0;a<t.length;a++){const e=t[a],l=n[a];Ft.includes(l)&&s.labels.push({name:e,type:l})}for(const a in e)rn.includes(a)||t.includes(a)||(ln.includes(e[a].ftype)?s.scalars.push({name:a}):s.unsupported.push({name:a}));return s}(t(Ci(e)),t(Mi(e)),t(Gi(e)))});const Ji=T({key:"defaultTargets",get:({get:e})=>{var t;const n=(null==(t=e(St).dataset)?void 0:t.default_mask_targets)||{};return Object.fromEntries(Object.entries(n).map((([e,t])=>[parseInt(e,10),t])))}}),_i=T({key:"targets",get:({get:e})=>{var t,n;return{defaults:(null==(t=e(St).dataset)?void 0:t.default_mask_targets)||{},fields:(null==(n=e(St).dataset)?void 0:n.mask_targets)||{}}}}),Qi=T({key:"getTarget",get:({get:e})=>{const{defaults:t,fields:n}=e(_i);return(e,s)=>e in n?n[e][s]:t[s]}}),$i=T({key:"selectedLabelIds",get:({get:e})=>{const t=e(eo);return new Set(Object.keys(t))}}),qi=T({key:"anyTagging",get:({get:e})=>{let t=[];return[!0,!1].forEach((n=>[!0,!1].forEach((s=>{t.push(e(Et({modal:n,labels:s})))})))),t.some((e=>e))},set:({set:e},t)=>{[!0,!1].forEach((n=>[!0,!1].forEach((s=>{e(Et({modal:n,labels:s}),t)}))))}});T({key:"hiddenLabelIds",get:({get:e})=>new Set(Object.keys(e(Tt)))});const eo=T({key:"selectedLabels",get:({get:e})=>{const t=e(St).selected_labels;return t?Object.fromEntries(t.map((e=>[e.label_id,e]))):{}},set:({get:e,set:t},n)=>{const s=e(St),a=Object.entries(n).map((([e,t])=>r(o({},t),{label_id:e}))),l=r(o({},s),{selected_labels:a});Zn.send(Cn("set_selected_labels",{selected_labels:a})),t(St,l)}}),to=Z({key:"hiddenFieldLabels",get:e=>({get:t})=>{const n=t(Tt),{sampleId:s}=t(ut);return s?Object.entries(n).filter((([t,{sample_id:n,field:a}])=>s===n&&a===e)).map((([e])=>e)):[]}}),no=Z({key:"fieldType",get:e=>({get:t})=>{const n=e.startsWith("frames.")&&t(gi),s=t(Zi(n?"frame":"sample"));return n?s[e.slice("frames.".length)].ftype:s[e].ftype}}),so=Z({key:"subfieldType",get:e=>({get:t})=>{const n=e.startsWith("frames.")&&t(gi),s=t(Zi(n?"frame":"sample"));return n?s[e.slice("frames.".length)].subfield:s[e].subfield}}),ao=T({key:"similarityKeys",get:({get:e})=>{var t;const n=e(St),s=(null==(t=null==n?void 0:n.dataset)?void 0:t.brain_methods)||{};return Object.entries(s).filter((([e,{config:{method:t}}])=>"similarity"===t)).reduce((({patches:e,samples:t},[n,{config:{patches_field:s}}])=>(s?e.push([n,s]):t.push(n),{patches:e,samples:t})),{patches:[],samples:[]})}});var lo={app_ids:{prod:"UA-141773487-6",dev:"UA-141773487-7"},dimensions:{dev:"dimension1",version:"dimension2",context:"dimension3"}};const io=(e,t,n)=>{const s=u.exports.useRef(n);u.exports.useEffect((()=>{s.current=n})),u.exports.useEffect((()=>{if(!e)return;const n=e=>s.current(e);return e.addEventListener(t,n),()=>{e.removeEventListener(t,n)}}),[e,t])},oo=(e,t)=>{const n=u.exports.useCallback((({data:n})=>{(n=JSON.parse(n)).type===e&&t(n)}),[e,t]);io(Zn,"message",n)},ro=(e,t,n=null,s=[])=>{u.exports.useEffect((()=>{!n&&Zn.send(JSON.stringify(r(o({},t),{type:e})))}),[n,...s])},co=(e,t)=>{const n=u.exports.useRef(t),s=u.exports.useRef(new C((()=>n.current())));u.exports.useEffect((()=>{n.current=t})),u.exports.useEffect((()=>{if(e)return s.current.observe(e),()=>s.current.unobserve(e)}),[e])},mo=(e,t)=>{io(document,"mousedown",(n=>{e.current&&!e.current.contains(n.target)&&t(n)}))},uo=(e,t,n)=>{const s=()=>{if(!(e&&e.current&&t&&t.current))return;const{x:s,y:a}=t.current.getBoundingClientRect(),{x:l,width:i}=e.current.getBoundingClientRect();n({left:s,top:a,opacity:s-l<0||s>l+i?0:1})};io(window,"scroll",s),io(e?e.current:null,"scroll",s),co(t?t.current:null,s)},ho=()=>{const[e,t]=u.exports.useState({width:0,height:0}),n=()=>{t({width:window.innerWidth,height:window.innerHeight})};return io(window,"resize",n),u.exports.useEffect((()=>{n()}),[]),e},po=()=>{const[e,t]=u.exports.useState(!1),n=P(_l);u.exports.useEffect((()=>{if(n.do_not_track)return;const e=n.dev_install,s=e?"dev":"prod";R.initialize(lo.app_ids[s],{debug:e,gaOptions:{storage:"none",cookieDomain:"none",clientId:n.user_id}}),R.set({userId:n.user_id,checkProtocolTask:null,[lo.dimensions.dev]:s,[lo.dimensions.version]:n.version,[lo.dimensions.context]:Tn}),t(!0),R.pageview(window.location.pathname+window.location.search)}),[]),io(window,"hashchange",(()=>{n.do_not_track||e&&R.pageview(window.location.pathname+window.location.search)}))},go=()=>u.exports.useContext(h),fo=m(d.div`
  box-sizing: border-box;
  border-radius: 3px;
  background-color: ${({theme:e})=>e.backgroundDarker};
  box-shadow: 0 2px 25px 0 ${({theme:e})=>e.darkShadow};
  color: ${({theme:e})=>e.fontDark};
  border-radius: 2px;
  padding: 0.5rem;
  line-height: 1rem;
  margin-top: 2.5rem;
  font-weight: bold;
  position: fixed;
  width: auto;
  z-index: 802;
`),bo=d.div`
  color: ${({theme:e})=>e.font};
  display: flex;
  padding-bottom: 0.5rem;
`,yo=g.memo((({barRef:e,followRef:t,serviceRef:n,style:s,machine:a})=>{const l=u.exports.useContext(h);let i,c;[i,c]=a||W(n);const d=u.exports.useRef(),[m,p]=u.exports.useState(null),{error:f,errorId:b}=i.context,[y,v]=M((()=>{const e=t?{left:t.current.getBoundingClientRect().x,top:t.current.getBoundingClientRect().y}:{};return r(o({},e),{opacity:b?1:0,from:{opacity:0},config:X.stiff})}));return u.exports.useEffect((()=>{m&&clearTimeout(m),!b&&p(setTimeout((()=>c("CLEAR_ERROR")),1e3)),v({opacity:b?1:0})}),[b]),mo(d,(()=>c("CLEAR_ERROR_ID"))),uo(e,t,v),g.createElement(fo,{ref:d,style:o(r(o({},y),{display:f?"block":"none"}),s)},f?g.createElement(g.Fragment,null,g.createElement(bo,null,g.createElement(N,{style:{color:l.error,marginRight:"0.5rem"}}),g.createElement("div",{style:{marginTop:"0.25rem"}},`Invalid ${f.name}.`)),f.error):null)})),vo=(e,t)=>{t=t||"";const n=e.filter((e=>e.toLowerCase().startsWith(t.toLowerCase())))[0];return n&&t.length?{placeholder:n.slice(t.length),value:n}:{placeholder:"",value:null}},xo=(e,t)=>{const n=e.filter((e=>e.toLowerCase()===t.toLowerCase()));return 1===n.length?n[0]:null},wo=m(d.div`
  cursor: pointer;
  margin: 0.25rem 0.25rem;
  padding: 0.1rem 0.25rem;
  font-weight: bold;
  color: ${({theme:e})=>e.fontDark};
`),ko=g.memo((({result:e,isActive:t,send:n,highlight:s})=>{const a=u.exports.useRef(null),l=u.exports.useContext(h),[i,o]=M((()=>({backgroundColor:t?l.backgroundLight:l.backgroundDark,color:t?l.font:l.fontDark})));u.exports.useEffect((()=>{o({backgroundColor:t?l.backgroundLight:l.backgroundDark,color:t?l.font:l.fontDark}),t&&a.current&&a.current.scrollIntoView()}),[t,a.current]);return g.createElement(wo,{ref:a,onClick:e=>n({type:"COMMIT",value:e.target.dataset.result,click:!0}),onMouseEnter:()=>o({backgroundColor:l.backgroundLight,color:l.font}),onMouseLeave:()=>!t&&o({backgroundColor:l.backgroundDark,color:l.fontDark}),style:i,"data-result":e},[null,void 0].includes(e)?g.createElement("code",{style:{color:s}},"None"):e)})),Eo=m(d.div`
  background-color: ${({theme:e})=>e.backgroundDark};
  border: 1px solid ${({theme:e})=>e.backgroundDarkBorder};
  border-radius: 2px;
  box-shadow: 0 2px 20px ${({theme:e})=>e.backgroundDark};
  box-sizing: border-box;
  margin-top: 2.5rem;
  position: fixed;
  width: auto;
  z-index: 801;
  max-height: 328px;
  overflow-y: scroll;
  scrollbar-width: none;

  &::-webkit-scrollbar {
    width: 0px;
    background: transparent;
    display: none;
  }
  &::-webkit-scrollbar-thumb {
    width: 0px;
    display: none;
  }
`),So=g.memo((e=>{var t=e,{results:n,send:s,currentResult:a,barRef:l,followRef:i,bestMatch:d,highlight:m}=t,u=c(t,["results","send","currentResult","barRef","followRef","bestMatch","highlight"]);const[h,p]=M((()=>{const e=i?{left:i.current.getBoundingClientRect().x,top:i.current.getBoundingClientRect().y}:{};return r(o({},e),{opacity:1,from:{opacity:0},config:X.stiff})}));return uo(l,i,p),n.length?g.createElement(Eo,o({style:h,onMouseEnter:()=>s("MOUSEENTER"),onMouseLeave:()=>s("MOUSELEAVE")},u),n.map(((e,t)=>g.createElement(ko,{key:e,result:e,isActive:a===t||d===e,send:s,highlight:m})))):null})),Lo=d.a`
  color: ${({theme:e})=>e.font};
`,To=e=>{let t;if(dn())try{t=require("electron").shell.openExternal}catch{}return t?n=>{n.preventDefault(),t(e)}:null},Zo=e=>{var t=e,{href:n}=t,s=c(t,["href"]);const a=To(n);return g.createElement(Lo,r(o({},s),{href:n,target:"_blank",onClick:a}))},Co=e=>g.createElement(G,o({},e),g.createElement("path",{d:"M6 15a2 2 0 0 1-2 2a2 2 0 0 1-2-2a2 2 0 0 1 2-2h2v2m1 0a2 2 0 0 1 2-2a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2a2 2 0 0 1-2-2v-5m2-8a2 2 0 0 1-2-2a2 2 0 0 1 2-2a2 2 0 0 1 2 2v2H9m0 1a2 2 0 0 1 2 2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2a2 2 0 0 1 2-2h5m8 2a2 2 0 0 1 2-2a2 2 0 0 1 2 2a2 2 0 0 1-2 2h-2v-2m-1 0a2 2 0 0 1-2 2a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2a2 2 0 0 1 2 2v5m-2 8a2 2 0 0 1 2 2a2 2 0 0 1-2 2a2 2 0 0 1-2-2v-2h2m0-1a2 2 0 0 1-2-2a2 2 0 0 1 2-2h5a2 2 0 0 1 2 2a2 2 0 0 1-2 2h-5z"}));var Po="assets/logo.c7dc2f64.png";const Ro=d.div`
  font-size: 1.2rem;
  display: flex;
  border-bottom: 1px ${({theme:e})=>e.brand} solid;
`,Io=d(Y)`
  & input {
    background-color: transparent;
    border: none;
    color: ${({theme:e})=>e.font};
    height: 40px;
    font-size: 1.2rem;
    border: none;
    align-items: center;
    font-weight: bold;
  }

  & input:focus {
    border: none;
    outline: none;
    font-weight: bold;
  }

  & ::placeholder {
    color: ${({theme:e})=>e.font};
    font-weight: bold;
  }
`,Wo=d.div`
  background-color: ${({theme:e})=>e.backgroundDark};
  display: flex;
  flex-shrink: 0;
  justify-content: space-between;
  width: 100%;
  border-bottom: 1px ${({theme:e})=>e.backgroundDarkBorder} solid;
`,Mo=d.div`
  margin-right: 1rem;
  cursor: pointer;
  height: 40px;
  display: flex;
`,Xo=m(d.img`
  height: 100%;
  width: auto;
  cursor: pointer;
  margin-right: 1rem;
  will-change: transform;
`),No=d.div`
  display: flex;
  padding: 1rem;
`,Go=d.div`
  margin-left: auto;
  padding-right: 0.5rem;
  display: flex;
`,Yo=d.div`
  color: ${e=>e.font};
  font-weight: bold;
  font-size: 1.8rem;
  align-items: center;
  display: flex;
`,Vo=d.div`
  font-weight: bold;
  padding-left: 1rem;
  border-left-width: 1px;
  border-color: ${({theme:e})=>e.backgroundDarkBorder};
  border-left-style: solid;
`,Fo=d.div`
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;

  a {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 0.5em;
  }

  svg:focus {
    outline: none;
  }
`,Ko=d.div`
  font-weight: bold;
  cursor: pointer;
  font-size: 1rem;
  border-radius: 3px;
  text-align: center;
  padding: 0 0.5rem;
  border: 1px solid ${({theme:e})=>e.brand};

  &.disabled {
    border: 1px solid ${({theme:e})=>e.fontDark};
    cursor: default;
  }
`,Do=V({id:"selectorMachine",initial:"reading",context:{error:void 0,values:[],value:"",selected:[],currentResult:null,errorId:null,results:[],prevValue:"",bestMatch:{},onCommit:()=>{}},states:{reading:{entry:F({errorId:null}),on:{EDIT:{target:"editing"}}},editing:{entry:[F({errorId:null,currentResult:({values:e,value:t})=>e.indexOf(t),prevValue:({value:e})=>e,results:({values:e})=>e,bestMatch:({values:e,value:t})=>vo(e,t)})],type:"parallel",states:{input:{initial:"focused",states:{focused:{on:{UNFOCUS_INPUT:"unfocused"}},unfocused:{on:{FOCUS_INPUT:"focused"}}}},searchResults:{initial:"notHovering",states:{hovering:{on:{MOUSELEAVE:"notHovering"}},notHovering:{on:{MOUSEENTER:"hovering"}}}}},on:{NEXT_RESULT:{actions:F({currentResult:({currentResult:e,results:t})=>null===e?0:Math.min(e+1,t.length-1),value:({currentResult:e,results:t})=>null===e?t[0]:t[Math.min(e+1,t.length-1)],bestMatch:{}})},PREVIOUS_RESULT:{actions:F({currentResult:({currentResult:e})=>0===e||null===e?null:e-1,value:({currentResult:e,prevValue:t,results:n})=>0===e||null===e?t:n[e-1],bestMatch:{}})},BLUR:{target:"reading",actions:[F({value:({value:e,prevValue:t,values:n})=>t})]},COMMIT:[{target:"reading",actions:[F({value:(e,{value:t})=>t,valid:!0}),({onCommit:e,prevValue:t},{value:n})=>{n!==t&&e(n)}],cond:({values:e},{value:t})=>e.some((e=>e===t))},{actions:F({error:(e,{value:t})=>({name:"name",error:`${""===t?'""':t} does not exist`}),errorId:x(),valid:!1})}],CHANGE:{actions:[F({value:(e,{value:t})=>t,results:({values:e})=>e,errorId:null,currentResult:({values:e},{value:t})=>{const n=e.indexOf(t);return n>0?n:null},bestMatch:({values:e},{value:t})=>vo(e,t)})]}}}},on:{SET_VALUES:{target:"reading",actions:[F({value:(e,{value:t})=>t,values:(e,{values:t})=>t,onCommit:(e,{onCommit:t})=>t})]}}}),Oo=d.input`
  width: 100%;
  background-color: transparent;
  border: none;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
  border
  color: ${({theme:e})=>e.font};
  line-height: 1rem;
  border: none;
  border-bottom: 1px solid ${({theme:e})=>e.brand};
  font-weight: bold;

  &:focus {
    border-bottom: 1px solid ${({theme:e})=>e.brand};
    outline: none;
    font-weight: bold;
  }

  &::placeholder {
    color: ${({theme:e})=>e.fontDark};
    font-weight: bold;
  }
`,zo=()=>{var e,t,n,s,a,l,i,c,d;const[m,h]=u.exports.useState({email:"",firstname:"",lastname:"",company:"",role:"",discover:""}),[p,f]=u.exports.useState("Submit"),[b,y]=H(yt),v=P(bt),x=e=>t=>h(r(o({},m),{[e]:t.target.value})),w=!((null==(e=m.email)?void 0:e.length)&&(null==(t=m.firstname)?void 0:t.length)&&(null==(n=m.lastname)?void 0:n.length))||b.submitted;return g.createElement(g.Fragment,null,g.createElement(Oo,{key:"firstname",placeholder:"First name*",value:null!=(s=m.firstname)?s:"",maxLength:40,onChange:x("firstname")}),g.createElement(Oo,{key:"lastname",placeholder:"Last name*",value:null!=(a=m.lastname)?a:"",maxLength:40,onChange:x("lastname")}),g.createElement(Oo,{key:"email",placeholder:"Email*",type:"email",value:null!=(l=m.email)?l:"",onChange:x("email")}),g.createElement(Oo,{key:"company",placeholder:"Company",value:null!=(i=m.company)?i:"",maxLength:100,onChange:x("company")}),g.createElement(Oo,{key:"role",placeholder:"Role",value:null!=(c=m.role)?c:"",maxLength:100,onChange:x("role")}),g.createElement(Oo,{key:"discover",placeholder:"How did you hear about FiftyOne?",value:null!=(d=m.discover)?d:"",maxLength:100,onChange:x("discover")}),g.createElement(Ko,{key:"submit",onClick:()=>{if(w)return;f("Submitting...");const e=new Headers;e.append("Content-Type","application/json");fetch("https://api.hsforms.com/submissions/v3/integration/submit/4972700/87aa5367-a8f1-4ed4-9e23-1fdf8448d807",{method:"post",headers:e,mode:"cors",body:JSON.stringify({submittedAt:Date.now(),fields:[{name:"firstname",value:m.firstname},{name:"lastname",value:m.lastname},{name:"email",value:m.email},{name:"company",value:m.company},{name:"role",value:m.role},{name:"app_how_did_you_hear_about_us",value:m.discover}],context:{pageName:"FiftyOne App"}})}).then((e=>{if(200!==e.status)throw new Error("Failed submission");return e.json()})).then((()=>{f("Submitted. Thank you!"),y(r(o({},b),{submitted:!0})),fetch(`${Sn}/teams?submitted=true`,{method:"post"}),setTimeout((()=>v&&v.close()),2e3)})).catch((e=>{f("Something went wrong")}))},style:{marginBottom:"1rem"},className:w?"disabled":""},p))},Ho=()=>{const e=P($l),t=P(ui),[n,s]=O(Do),a=P(ft),l=z(xt),i=z(wt),o=u.exports.useRef(),{results:r,currentResult:c,value:d,bestMatch:m,values:h}=n.context;u.exports.useEffect((()=>{s({type:"SET_VALUES",value:null!=e?e:"",values:t,onCommit:e=>{l(),i(),Zn.send(Cn("set_dataset",{dataset_name:e}))}})}),[e,t,Zn]);const p=n.matches("editing");return u.exports.useEffect((()=>{p&&o.current&&o.current.focus(),!p&&o.current&&o.current.blur()}),[p,o.current]),g.createElement(Vo,null,g.createElement(Ro,null,g.createElement(Io,{placeholder:t.length>0?"Select a dataset":"No datasets available",disabled:!t.length,value:a?d:"Not connected",onFocus:()=>n.matches("reading")&&s("EDIT"),onBlur:e=>{n.matches("editing.searchResults.notHovering")&&s("BLUR")},ref:o,onChange:e=>s({type:"CHANGE",value:e.target.value}),onKeyPress:e=>{if("Enter"===e.key){const t=xo(h,e.target.value);s({type:"COMMIT",value:t||(m.value?m.value:e.target.value)})}},onKeyDown:e=>{switch(e.key){case"Escape":s("BLUR");break;case"ArrowDown":s("NEXT_RESULT");break;case"ArrowUp":s("PREVIOUS_RESULT");break;case"ArrowRight":e.target.selectionStart===e.target.value.length&&m.value&&s({type:"CHANGE",value:m.value})}}}),n.matches("editing")||""===d?g.createElement(mt,{style:{height:"40px",margin:"-1px 0 0 -2px",fontSize:"1.2rem",alignItems:"center"}},m?m.placeholder:""):null),n.matches("editing")&&g.createElement(So,{results:r,send:s,currentResult:c,bestMatch:m.value,style:{marginTop:8,fontSize:"1.2rem",maxHeight:212,overflowY:"scroll"}}),g.createElement(yo,{machine:[n,s],style:{marginTop:8}}))},Uo=({addNotification:e})=>{const[t,n]=H(Mt),[s,a]=H(yt),[l,i]=H(bt),c=g.createElement("span",null,"FiftyOne is and will always be open source software that is freely available to individual users, all 35,000 and counting. However, if you’re part of a team, you may need more. That’s why we’ve begun deploying team-based versions of FiftyOne with multi-user collaboration features to early adopters.",g.createElement("br",null),g.createElement("br",null),"Are you interested in a team-based deployment of FiftyOne? Let us know how to contact you and our founders will reach out to make it happen!"),d=u.exports.useContext(h),m=P(Ql),p=()=>{if(!t){n(!0);const t=e.current({kind:"Get FiftyOne for your team",message:c,children:[g.createElement(zo,{key:"teams"})],onClose:()=>n(!1)});i({close:t})}};return"shown"===m?g.createElement(Ko,{onClick:p,style:{marginRight:"0.5rem",position:"relative"}},"Have a team?",g.createElement("div",{style:{position:"absolute",top:"-0.8rem",right:"-0.8rem"}},g.createElement(f,{style:{borderRadius:"1rem",background:d.brand},onClick:e=>{e.stopPropagation(),a(r(o({},s),{minimized:!0})),fetch(`${Sn}/teams`,{method:"post"}),l&&l.close()}}))):"minimized"===m?g.createElement(U,{style:{cursor:"pointer",marginRight:"0.5em"},onClick:p}):null},jo=({addNotification:e})=>{const t=P(Jl),n=M({transform:t?"rotate(0turn)":"rotate(1turn)"});return g.createElement(Wo,null,g.createElement(No,null,g.createElement(Mo,{onClick:()=>Zn.send(Cn("refresh",{}))},g.createElement(Xo,{style:n,src:Po}),g.createElement(Yo,{className:"fix-me"},"FiftyOne")),g.createElement(Ho,null)),g.createElement(Go,null,g.createElement(Fo,null,g.createElement(u.exports.Suspense,{fallback:null},g.createElement(Uo,{addNotification:e})),g.createElement(Zo,{title:"Slack",href:"https://join.slack.com/t/fiftyone-users/shared_invite/zt-s6936w7b-2R5eVPJoUw008wP7miJmPQ"},g.createElement(Co,null)),g.createElement(Zo,{title:"GitHub",href:"https://github.com/voxel51/fiftyone"},g.createElement(K,null)),g.createElement(Zo,{title:"Documentation",href:"https://voxel51.com/docs/fiftyone/user_guide/app.html"},g.createElement(D,null)))))},Ao=d.div`
  padding: 1em;
  box-sizing: border-box;
  border: 2px solid ${({theme:e})=>e.border};
  background-color: ${({theme:e})=>e.background};
`;d.div`
  height: ${({height:e})=>"number"==typeof e?e+"px":e};
  background-color: ${({opaque:e,theme:t})=>e?t.background:void 0};
`,d.button`
  display: flex;
  align-items: center;
  background-color: ${({theme:e})=>e.button};
  color: ${({theme:e})=>e.font};
  border: 1px solid ${({theme:e})=>e.buttonBorder};
  border-radius: 1px;
  margin: 0 3px;
  padding: 3px 10px;
  font-weight: bold;
  cursor: pointer;

  svg.MuiSvgIcon-root {
    font-size: 1.25em;
    margin-left: -3px;
    margin-right: 3px;
  }
`;const Bo=d.div`
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: ${({theme:e})=>e.overlay};
`,Jo=d.div`
  display: block;
  border-top: 2px solid ${({theme:e})=>e.border};
  padding: 1em;
  background-color: ${({theme:e})=>e.backgroundLight};
  z-index: 9000;
  position: absolute;
  right: 0;
  bottom: 0;
  width: 100%;
  min-height: 64.5px;
`,_o=({theme:e})=>`\n::-webkit-scrollbar {\n  width: 16px;\n}\n\nscrollbar-color: ${({theme:e})=>e.fontDarkest} ${({theme:e})=>e.background};\n\n::-webkit-scrollbar-track {\n  border: solid 4px transparent ${e.fontDarkest};\n}\n\n::-webkit-scrollbar-thumb {\n  box-shadow: inset 0 0 10px 10px transparent;\n  border: solid 4px transparent;\n  border-radius: 16px;\n  transition: box-shadow linear 0.5s;\n}\n&:hover::-webkit-scrollbar-thumb {\n  box-shadow: inset 0 0 10px 10px ${e.fontDarkest};\n}\n`,Qo=d.div`
  box-sizing: border-box;
  border-radius: 3px;
  background-color: ${({theme:e})=>e.backgroundDarker};
  color: ${({theme:e})=>e.fontDark};
  border: 1px solid #191c1f;
  box-shadow: 0 8px 15px 0 rgba(0, 0, 0, 0.43);
  border-radius: 2px;
  padding: 0.5rem;
  line-height: 1rem;
  margin-top: 2.5rem;
  font-weight: bold;
  width: auto;
  z-index: 802;
`,$o=d.div`
  color: ${({theme:e})=>e.font};
  display: flex;
  padding-bottom: 0.5rem;
`,qo=m(d.div`
  line-height: 1.5rem;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  background-color: ${({theme:e})=>e.button};
  height: 2rem;
  border-radius: 1rem;
  border: none;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  opacity: 1;

  & > span {
    margin: 0 0.25rem;
  }
  & > svg {
    display: inline-block;
    height: 100%;
  }
`),er=g.memo(g.forwardRef((({onClick:e,open:t,text:n,icon:s,highlight:a,arrow:l=!1,style:i,title:r},c)=>{const d=go(),m=M({backgroundColor:a?d.brand:d.button});return g.createElement(qo,{onClick:e,ref:c,style:o(o({},m),i),title:r},n&&g.createElement("span",null,n),s,l&&(t?g.createElement(j,null):g.createElement(A,null)))}))),tr=m(d.div`
  background-color: ${({theme:e})=>e.backgroundDark};
  border: 1px solid ${({theme:e})=>e.backgroundDarkBorder};
  border-radius: 2px;
  box-shadow: 0 2px 20px ${({theme:e})=>e.backgroundDark};
  box-sizing: border-box;
  margin-top: 0.6rem;
  position: absolute;
  width: auto;
  z-index: 801;
  font-size: 14px;
  padding: 0 0.5rem 0 0.5rem;
  min-width: 14rem;
`),nr=d.div`
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
  border-bottom: 1px solid ${({theme:e})=>e.backgroundLight};
  font-size: 1rem;
  line-height: 2;
  font-weight: bold;
`,sr=m(d.div`
  display: flex;
  font-weight: bold;
  cursor: pointer;
  justify-content: space-between;
  margin: 0.5rem -0.5rem;
  height: 2rem;

  & > div {
    display: flex;
    justify-content: center;
    align-content: center;
    flex-direction: column;
    cursor: inherit;
    flex-grow: 1;
    flex-basis: 0;
    text-align: center;Checkbox
    overflow: hidden;
  }
`),ar=m(d.div``),lr=({active:e,options:t,color:n})=>{const s=go(),[a,l]=u.exports.useState(t.map((e=>!1))),i=B(t.length,t.map(((t,l)=>({backgroundColor:t.text===e?n||s.brand:a[l]?s.background:s.backgroundLight,color:a?s.font:s.fontDark})))),[c,d]=M((()=>({background:s.backgroundLight})));return g.createElement(sr,{style:c,onMouseEnter:()=>d({background:s.background}),onMouseLeave:()=>d({background:s.backgroundLight})},t.map((({text:t,title:n,onClick:s},c)=>g.createElement(ar,{onClick:s,title:n,style:r(o({},i[c]),{cursor:t===e?"default":"pointer"}),onMouseEnter:()=>l(a.map(((e,t)=>t===c||e))),onMouseLeave:()=>l(a.map(((e,t)=>t!==c&&e))),key:c},t))))},ir=d(Ao)`
  cursor: ${({clickable:e})=>e?"pointer":void 0};
  font-weight: bold;
  user-select: none;
  border-radius: 3px;

  .icon {
    float: right;
    order: 1;
  }
`,or=e=>{var t=e,{children:n,icon:s,onClick:a}=t,l=c(t,["children","icon","onClick"]);return g.createElement(ir,o({clickable:Boolean(a),onClick:()=>{if(a)return a()}},l),s?g.createElement("span",{className:"icon"},s):null,n)};or.Body=ir;const rr=d(or)`
  width: 100%;
  padding: 0.5rem;

  svg {
    font-size: 1.25em;
    vertical-align: middle;
  }
`,cr=e=>e?g.createElement(J,null):g.createElement(_,null),dr=e=>e?g.createElement(Q,null):g.createElement($,null),mr=e=>{var t=e,{label:n,expanded:s,onClick:a,icon:l=cr}=t,i=c(t,["label","expanded","onClick","icon"]);return g.createElement(rr,o({icon:l(s),onClick:a},i),n)};mr.Body=rr;const ur=d.div``,hr=d.div`
  margin-bottom: -2px;
`,pr=d(mr)`
  width: 100% !important;
`,gr=d(pr)`
  border-radius: 0;
  border-width: 0 0 1px 0;
  padding: 0.5em 0 0.5em 0;
  width: 100%;
`,fr=d.div`
  width: 100%;
  padding-top: 0.5em;
  margin-bottom: 1em;
`,br=d(Ao)`
  width: 100%;
  border-top: none;
`,yr=({children:e,label:t,title:n,expanded:s,onExpand:a,boxed:l=!1})=>{const i=a?()=>a(!s):void 0,o=l?hr:ur,r=l?pr:gr,c=l?br:fr;return g.createElement(o,null,g.createElement(r,{label:t,title:n,expanded:s,onClick:i,icon:dr}),s?g.createElement(c,null,e):null)},vr=(e,t,n)=>o({_CLS:"bool",true:!1,false:!1,none:!1},e(hc({modal:t,path:n}))),xr=(e,t,n,s,a,l)=>{const i=r(o({},vr(e,n,s)),{[a]:l});(e=>!1===e.true&&!1===e.false&&!1===e.none)(i)?t(hc({modal:n,path:s}),null):t(hc({modal:n,path:s}),i)},wr=Z({key:"filterBooleanFieldTrue",get:({modal:e,path:t})=>({get:n})=>vr(n,e,t).true,set:({modal:e,path:t})=>({get:n,set:s},a)=>xr(n,s,e,t,"true",a)}),kr=Z({key:"filterBooleanFieldFalse",get:({modal:e,path:t})=>({get:n})=>vr(n,e,t).false,set:({modal:e,path:t})=>({get:n,set:s},a)=>xr(n,s,e,t,"false",a)}),Er=Z({key:"filterBooleanFieldNone",get:({modal:e,path:t})=>({get:n})=>vr(n,e,t).none,set:({modal:e,path:t})=>({get:n,set:s},a)=>xr(n,s,e,t,"none",a)}),Sr=Z({key:"booleanFieldIsFiltered",get:({path:e,modal:t})=>({get:n})=>n(Er({path:e,modal:t}))||n(wr({path:e,modal:t}))||n(kr({path:e,modal:t}))}),Lr=Z({key:"booleanSelectedValues",get:({modal:e,path:t})=>({get:n})=>{const s=[];return n(Er({modal:e,path:t}))&&s.push(null),n(kr({modal:e,path:t}))&&s.push(!1),n(wr({modal:e,path:t}))&&s.push(!0),s},set:({path:e,modal:t})=>({get:n,set:s},a)=>{const l=Er({path:e,modal:t}),i=kr({path:e,modal:t}),o=wr({modal:t,path:e}),r=n(l),c=n(i),d=n(o);if(!Array.isArray(a))return r&&s(l,!1),c&&s(i,!1),void(d&&s(o,!1));const m=a.includes(null);m!==r&&s(l,m);const u=a.includes(!1);u!==c&&s(i,u);const h=a.includes(!0);h!==d&&s(o,h)}}),Tr=Z({key:"isBooleanField",get:e=>({get:t})=>{let n=t(zi("sample"));return an.includes(n[e])&&(n=t(Hi("sample"))),"fiftyone.core.fields.BooleanField"===n[e]}}),Zr=Z({key:"isDateTimeField",get:e=>({get:t})=>{let n=t(zi("sample"));return n[e]===sn&&(n=t(Hi("sample"))),_t===n[e]}}),Cr=Z({key:"isDateField",get:e=>({get:t})=>{let n=t(zi("sample"));return n[e]===sn&&(n=t(Hi("sample"))),Jt===n[e]}}),Pr=Z({key:"isNumericField",get:e=>({get:t})=>{let n=t(zi("sample"));return an.includes(n[e])&&(n=t(Hi("sample"))),on.includes(n[e])}}),Rr=Z({key:"isSupportField",get:e=>({get:t})=>{let n=t(zi("sample"));return qt===n[e]}});Z({key:"isIntField",get:e=>({get:t})=>{let n=t(zi("sample"));return an.includes(n[e])&&(n=t(Hi("sample"))),[qt,en].includes(n[e])}});const Ir=(e,t,n,s)=>{const a=e(Xr({path:n,defaultRange:s}));return o(o({_CLS:"numeric"},{range:a,none:!0,nan:!0,inf:!0,ninf:!0,exclude:!1}),e(hc({modal:t,path:n})))},Wr=(e,t)=>e.range.every(((e,n)=>e===t[n]))&&e.none&&e.nan&&e.inf&&e.ninf&&!e.exclude,Mr=(e,t,n,s,a,l,i=null)=>{const c=e(Xr({path:s,defaultRange:i})),d=r(o({range:c},Ir(e,n,s,i)),{[a]:l,_CLS:"numeric"}),m=r(o({},d),{[a]:l}),u=Wr(m,c);!u&&Wr(r(o({},m),{range:c}),c)?t(hc({modal:n,path:s}),{range:d.range,_CLS:"numeric"}):t(hc({modal:n,path:s}),u?null:d)},Xr=Z({key:"numericFieldBounds",get:({path:e,defaultRange:t})=>({get:n})=>{var s;const a=n(Zr(e))||n(Cr(e));let l=(null!=(s=n(bi))?s:[]).reduce(((t,n)=>n.name!==e||n._CLS!==jt?t:a?n.result.map((e=>e?e.datetime:e)):n.result.bounds?n.result.bounds:n.result),[null,null]);if(l.every((e=>null===e)))return l;let[i,o]=[null,null];return t&&([i,o]=t,l=[i<l[0]?i:l[0],o>l[1]?o:l[1]]),[l[0],l[1]]}}),Nr=Z({key:"filterNumericFieldRange",get:({defaultRange:e,modal:t,path:n})=>({get:s})=>Ir(s,t,n,e).range,set:({defaultRange:e,modal:t,path:n})=>({get:s,set:a},l)=>{Mr(s,a,t,n,"range",l,e)}}),Gr=Z({key:"otherAtom",get:({defaultRange:e,modal:t,path:n,key:s})=>({get:a})=>Ir(a,t,n,e)[s],set:({defaultRange:e,modal:t,path:n,key:s})=>({get:a,set:l},i)=>Mr(a,l,t,n,s,i,e)}),Yr=Z({key:"otherFilteredCounts",get:({modal:e,path:t})=>({get:n})=>{var s;const a=n(wc({modal:e,path:t}));let{inf:l,"-inf":i,nan:o}=(null!=(s=n(e?gc:bi))?s:[]).reduce(((e,n)=>n.name!==t||n._CLS!==jt?e:(n.result.bounds,n.result)),{nan:0,"-inf":0,inf:0});return{none:a,inf:l,ninf:i,nan:o}}}),Vr=Z({key:"otherFilteredCounts",get:({modal:e,path:t})=>({get:n})=>{var s;const a=n(xc(e))[t],l=n(mc(e)),i=null!=(s=n(e?bc:xi))?s:[];if(!l||!i.length)return n(Yr({modal:e,path:t}));let{inf:o,"-inf":r,nan:c}=i.reduce(((e,n)=>n.name!==t||n._CLS!==jt?e:(n.result.bounds,n.result)),{nan:0,"-inf":0,inf:0});return{none:a,inf:o,ninf:r,nan:c}}}),Fr=Z({key:"otherKeyedFilteredCount",get:e=>{var t=e,{key:n}=t,s=c(t,["key"]);return({get:e})=>e(Vr(s))[n]}}),Kr=Z({key:"filterNumericFieldExclude",get:({modal:e,path:t,defaultRange:n})=>({get:s})=>Ir(s,e,t,n).exclude,set:({modal:e,path:t,defaultRange:n})=>({get:s,set:a},l)=>{Mr(s,a,e,t,"exclude",l,n)}}),Dr=Z({key:"numericFieldIsFiltered",get:({path:e,defaultRange:t,modal:n})=>({get:s})=>!Wr(Ir(s,n,e,t),s(Xr({path:e,defaultRange:t})))}),Or=Z({key:"isDefaultNumericFieldRange",get:e=>({get:t})=>{const n=t(Nr(e));return t(Xr(e)).every(((e,t)=>e===n[t]))}}),zr=Z({key:"isStringField",get:e=>({get:t})=>{let n=t(zi("sample"));return an.includes(n[e])&&(n=t(Hi("sample"))),[tn,nn].includes(n[e])}}),Hr=(e,t,n)=>o({values:[],exclude:!1,_CLS:"str"},e(hc({modal:t,path:n}))),Ur=(e,t,n,s,a,l)=>{const i=r(o({},Hr(e,n,s)),{[a]:l});0===i.values.length&&(i.exclude=!1),(e=>0===e.values.length&&!1===e.exclude)(i)?t(hc({modal:n,path:s}),null):t(hc({modal:n,path:s}),i)},jr=Z({key:"filterStringFieldValues",get:({modal:e,path:t})=>({get:n})=>Hr(n,e,t).values,set:({modal:e,path:t})=>({get:n,set:s},a)=>Ur(n,s,e,t,"values",a)}),Ar=Z({key:"filterStringFieldExclude",get:({modal:e,path:t})=>({get:n})=>Hr(n,e,t).exclude,set:({modal:e,path:t})=>({get:n,set:s},a)=>Ur(n,s,e,t,"exclude",a)}),Br=Z({key:"stringFieldIsFiltered",get:({path:e,modal:t})=>({get:n})=>n(jr({modal:t,path:e})).length>0||Ar({modal:t,path:e})}),Jr=e=>Nt.includes(e)?`.${Ut[e]}`:"",_r=Z({key:"labelFilters",get:e=>({get:t})=>{const n=t(e?tc:ec),s={},a=t(Ni),l=e?t(Tt):null,i=t(Vi("sample"));for(const o of n){if(i.includes(o)){if(t(Pr(o))){let[n,a,l,i,r,c]=[t(Nr({modal:e,path:o})),t(Gr({modal:e,path:o,key:"none"})),t(Gr({modal:e,path:o,key:"inf"})),t(Gr({modal:e,path:o,key:"ninf"})),t(Gr({modal:e,path:o,key:"nan"})),t(Kr({modal:e,path:o}))];c&&(a=!a,l=!l,i=!i,r=!r),s[o]=e=>(c?n[0]-.005>e||e>n[1]+.005:n[0]-.005<=e&&e<=n[1]+.005)||a&&void 0===e||l&&"inf"===e||r&&"nan"===e||i&&"-inf"===e}else if(t(zr(o))){const[n,a]=[t(jr({modal:e,path:o})),t(Ar({modal:e,path:o}))];s[o]=e=>{let t=n.includes(e);return a&&(t=!t),t||0===n.length}}else if(t(Tr(o))){const[n,a,l]=[t(wr({modal:e,path:o})),t(kr({modal:e,path:o})),t(Er({modal:e,path:o}))];s[o]=n||a||l?e=>!(!0!==e||!n)||(!(!1!==e||!a)||!(null!==e||!l)):e=>!0}continue}const n=`${o}${Jr(a[o])}`,r=`${n}.confidence`,c=`${n}.label`,d=`${n}.value`;let[m,u,h,p,g,f,b,y,v,x,w,k,E,S]=[t(Nr({modal:e,path:r,defaultRange:[0,1]})),t(Gr({modal:e,path:r,defaultRange:[0,1],key:"none"})),t(Gr({modal:e,path:r,defaultRange:[0,1],key:"inf"})),t(Gr({modal:e,path:r,defaultRange:[0,1],key:"ninf"})),t(Gr({modal:e,path:r,defaultRange:[0,1],key:"nan"})),t(Kr({modal:e,path:r,defaultRange:[0,1]})),t(jr({modal:e,path:c})),t(Ar({modal:e,path:c})),t(Nr({modal:e,path:d})),t(Gr({modal:e,path:d,key:"none"})),t(Gr({modal:e,path:d,key:"inf"})),t(Gr({modal:e,path:d,key:"ninf"})),t(Gr({modal:e,path:d,key:"nan"})),t(Kr({modal:e,path:d}))];f&&(u=!u,h=!h,p=!p,g=!g),S&&(x=!x,w=!w,k=!k,E=!E);const L=t(uc({key:"label",modal:e}));s[o]=e=>{var t;if(l&&l[null!=(t=e.id)?t:e._id])return!1;const n=f?m[0]-.005>e.confidence||e.confidence>m[1]+.005:m[0]-.005<=e.confidence&&e.confidence<=m[1]+.005,s=u&&void 0===e.confidence;let a=e.label?e.label:e.value;void 0===a&&(a=null);let i=b.includes(a);y&&(i=!i);const o=0==L.size||e.tags&&e.tags.some((e=>L.has(e))),r=S?v[0]-.005>e.value||e.value>v[1]+.005:v[0]-.005<=e.value&&e.value<=v[1]+.005,c=x&&void 0===e.value;return(n||s||g&&"nan"===e.confidence||h&&"inf"===e.confidence||p&&"-inf"===e.confidence)&&(i||0===b.length)&&o&&(r||c||E&&"nan"===e.value||w&&"inf"===e.value||k&&"-inf"===e.value)}}return s},set:()=>({get:e,set:t},n)=>{t(tc,e(ec)),t(pt(!0),e(pt(!1))),t(dc,e(wi)),t(Pt(!0),e(Pt(!1))),t(Wt(!0),e(Wt(!1))),t(ht(!0),e(ht(!1))),t(Rt(!0),e(Rt(!1)))}}),Qr=Z({key:"fieldIsFiltered",get:({path:e,modal:t})=>({get:n})=>{const s={path:e,modal:t};if(n(Tr(e)))return n(Sr(s));if(n(Pr(e)))return n(Dr(s));if(n(zr(e)))return n(Br(s));if(e.startsWith("_label_tags."))return n(uc({modal:t,key:"label"})).has(e.slice("_label_tags.".length));if(e.startsWith("tags."))return n(uc({modal:t,key:"sample"})).has(e.slice("tags.".length));const a=`${e=`${e}${Jr(n(Ni)[e])}`}.confidence`,l=`${e}.label`,i=`${e}.value`,c=!!t&&n(to(e.split(".")[0])).length>0;return n(Dr(r(o({},s),{path:a,defaultRange:[0,1]})))||n(Br(r(o({},s),{path:l})))||n(Dr(r(o({},s),{path:i})))||c}}),$r=Z({key:"isLabelField",get:e=>({get:t})=>t(Mi("sample")).concat(t(Mi("frame")).map((e=>"frames."+e))).includes(e)}),qr=T({key:"unsupportedFields",get:({get:e})=>e(Ii).filter((t=>!(t.startsWith("frames.")||e($r(t))||e(Pr(t))||e(zr(t))||e(Tr(t))||["metadata","tags"].includes(t)||e(Vi("sample")).includes(t))))}),ec=b({key:"activeFields",default:Xi}),tc=b({key:"activeModalFields",default:[]}),nc=Z({key:"activeLabels",get:({modal:e,frames:t})=>({get:n})=>{const s=n(Xi);return n(e?tc:ec).filter((e=>s.includes(e))).filter((e=>t?e.startsWith("frames."):!e.startsWith("frames.")))},set:({modal:e,frames:t})=>({get:n,set:s},a)=>{if(Array.isArray(a)){let l=n(e?tc:ec).filter((e=>!(n($r(e))&&(t?e.startsWith("frames."):!e.startsWith("frames.")))||a.includes(e)));a.length&&(l=[a[0],...l.filter((e=>e!==a[0]))]),s(e?tc:ec,l)}}}),sc=Z({key:"activeLabelPaths",get:e=>({get:t})=>[...t(nc({modal:e,frames:!1})),...t(nc({modal:e,frames:!0}))]}),ac=Z({key:"activeScalars",get:e=>({get:t})=>{const n=t(Vi("sample"));return t(e?tc:ec).filter((e=>n.includes(e)))},set:e=>({get:t,set:n},s)=>{if(e)return[];if(Array.isArray(s)){const a=t(Vi("sample")),l=t(ac(e));let i=t(e?tc:ec).filter((e=>!a.includes(e)||s.includes(e)));s.length&&l.length<s.length&&(i=[s[0],...i.filter((e=>e!==s[0]))]),n(e?tc:ec,i)}}}),lc=Z({key:"activeTags",get:e=>({get:t})=>t(e?tc:ec).filter((e=>e.startsWith("tags."))).map((e=>e.slice(5))),set:e=>({get:t,set:n},s)=>{if(Array.isArray(s)){const a=s.map((e=>"tags."+e)),l=t(lc(e));let i=t(e?tc:ec).filter((e=>!e.startsWith("tags.")||a.includes(e)));a.length&&l.length<a.length&&(i=[a[0],...i.filter((e=>e!==a[0]))]),n(e?tc:ec,i)}}}),ic=Z({key:"activeLabelTags",get:e=>({get:t})=>t(e?tc:ec).filter((e=>e.startsWith("_label_tags."))).map((e=>e.slice("_label_tags.".length))),set:e=>({get:t,set:n},s)=>{if(Array.isArray(s)){const a=s.map((e=>"_label_tags."+e)),l=t(ic(e));let i=t(e?tc:ec).filter((e=>!e.startsWith("_label_tags.")||a.includes(e)));a.length&&l.length<a.length&&(i=[a[0],...i.filter((e=>e!==a[0]))]),n(e?tc:ec,i)}}}),oc=[!1,!0,null],rc=["False","True","None"],cc=e=>oc.includes(e)?[rc[oc.indexOf(e)],!0]:"number"==typeof e?[e.toLocaleString(),!0]:"string"!=typeof e||e.length?Array.isArray(e)?[`[${e.map((e=>cc(e)[0])).join(", ")}]`,!1]:[e,!1]:['""',!0],dc=b({key:"modalFilterStages",default:{}}),mc=Z({key:"hasFilters",get:e=>({get:t})=>Object.keys(t(e?dc:wi)).length>0}),uc=Z({key:"matchedTags",get:({key:e,modal:t})=>({get:n})=>{const s=n(t?dc:wi).tags;return s&&s[e]?new Set(s[e]):new Set},set:({key:e,modal:t})=>({get:n,set:s},a)=>{const l=o({},n(t?dc:wi)),i=o({},l.tags||{});a instanceof Set&&a.size?i[e]=Array.from(a):l.tags&&e in l.tags&&delete i[e],l.tags=i,0===Object.keys(l.tags).length&&delete l.tags,s(t?dc:wi,l)}}),hc=Z({key:"filterStage",get:({path:e,modal:t})=>({get:n})=>{var s,a;return null!=(a=null==(s=n(t?dc:wi))?void 0:s[e])?a:{}},set:({path:e,modal:t})=>({get:n,set:s},a)=>{const l=Object.assign({},n(t?dc:wi));null===a?delete l[e]:l[e]=a,s(t?dc:wi,l)}}),pc=T({key:"modalStatsRaw",get:async({get:e})=>{const t=x();return(await Pn({type:"modal_statistics",uuid:t,args:{sample_id:e(ut).sample._id}})).stats}}),gc=T({key:"modalStats",get:({get:e})=>e(pc)}),fc=T({key:"modalExtendedStatsRaw",get:async({get:e})=>{const t=x();return(await Pn({type:"modal_statistics",uuid:t,args:{sample_id:e(ut).sample._id,filters:e(dc)}})).stats}}),bc=T({key:"extendedModalStats",get:({get:e})=>e(fc)}),yc=(e,t=!1)=>{let n=null,s=null;const a=e.reduce(((e,a)=>(null===a.name&&(n=a.result),"frames"===a.name&&t&&(s=a.result),e[a.name]||(e[a.name]={}),e[a.name][a._CLS]=a.result,e)),{}),l={};for(let i in a){if(t&&i.startsWith("frames.")){i=i.slice("frames.".length);let e=i.includes(".")?i.split(".").slice(0,-1).join("."):i;const t=i;i="frames."+i,e="frames."+e,i===e?l[i]=s-a[i][At]:t.includes(".")&&a[e]&&a[i]&&(l[i]=a[e][At]-a[i][At]);continue}let e=i.includes(".")?i.split(".").slice(0,-1).join("."):i;i===e?l[i]=n-a[i][At]:i.includes(".")&&a[e]&&a[i]&&(l[i]=a[e][At]-a[i][At])}return l},vc=Z({key:"noneFieldCounts",get:e=>({get:t})=>{const n=t(e?pc:xt),s=t(gi),a=t(fi);return n.view&&In(n.view,a)?yc(n.stats,s):{}}}),xc=Z({key:"noneFilteredFieldCounts",get:e=>({get:t})=>{const n=t(e?fc:wt),s=t(gi),a=t(fi);if(!n.view)return{};if(!In(n.view,a))return{};const l=t(e?dc:wi);return vi(n.filters,l)?0===Object.entries(l).length?vc(e):yc(n.stats,s):{}}}),wc=Z({key:"noneCount",get:({path:e,modal:t})=>({get:n})=>n(vc(t))[e]}),kc=Z({key:"labelTagCounts",get:e=>({get:t})=>{const n=t(e?gc:bi),s=t(Si),a={};return n&&n.forEach((e=>{s.includes(e.name)&&Object.entries(e.result).forEach((([e,t])=>{e in a?a[e]+=t:a[e]=t}))})),a}}),Ec=Z({key:"filteredLabelTagCounts",get:e=>({get:t})=>{const n=t(e?bc:xi),s=t(Si),a={};return n&&n.forEach((e=>{s.includes(e.name)&&Object.entries(e.result).forEach((([e,t])=>{e in a?a[e]+=t:a[e]=t}))})),a}}),Sc=Z({key:"sampleTagCounts",get:e=>({get:t})=>{const n=t(e?gc:bi);return n?n.reduce(((e,t)=>"tags"===t.name&&t._CLS===Bt?Object.fromEntries(t.result[1]):e),{}):{}}}),Lc=Z({key:"filteredSampleTagCounts",get:e=>({get:t})=>{const n=t(e?bc:xi);return n?n.reduce(((e,t)=>"tags"===t.name&&t._CLS===Bt?Object.fromEntries(t.result[1]):e),{}):{}}}),Tc=(e,t,n,s,a)=>{if(!n.name)return;const l=n.name.slice(t.length).split(".")[0];let i=n.name;if(a&&zt.includes(a[t+l]))i=t+`${l}.${Ut[a[t+l]]}`;else if(a&&n.name!==t+l)return;e.includes(l)&&i===n.name&&n._CLS===At&&(s[t+l]=n.result)},Zc=Z({key:"labelCounts",get:({key:e,modal:t})=>({get:n})=>{const s=n(Mi(e)),a="sample"===e?"":"frames.",l=n(t?gc:bi),i=n(Ni);return null===l?null:l.reduce(((e,t)=>(Tc(s,a,t,e,i),e)),{})}}),Cc=Z({key:"filteredLabelCounts",get:({key:e,modal:t})=>({get:n})=>{const s=n(Mi(e)),a="sample"===e?"":"frames.",l=n(t?bc:xi),i=n(Ni);return null===l?null:l.reduce(((e,t)=>(Tc(s,a,t,e,i),e)),{})}}),Pc=Z({key:"scalarCounts",get:e=>({get:t})=>{if(e)return t(ut).sample;const n=t(Vi("sample")),s=t(bi);return null===s?null:s.reduce(((e,t)=>(Tc(n,"",t,e),e)),{})}}),Rc=Z({key:"filteredScalarCounts",get:e=>({get:t})=>{if(e)return null;const n=t(Vi("sample")),s=t(xi);return null===s?null:s.reduce(((e,t)=>(Tc(n,"",t,e),e)),{})}}),Ic=Z({key:"categoricalFieldCounts",get:({filtered:e,path:t,modal:n})=>({get:s})=>{const a=s(e?xc(n):vc(n))[t],l=s(Vi("sample"));if(n&&l.includes(t)){const e=s(ut).sample[t];if(!Array.isArray(e))return{count:0,results:[]};return{count:e.length,results:Array.from(e.reduce(((e,t)=>(e.has(t)||e.set(t,0),e.set(t,e.get(t)+1),e)),new Map).entries())}}const i=s(n?e?bc:gc:e?xi:bi);if(!i&&e)return null;const o=(null!=i?i:[]).reduce(((e,n)=>n.name===t&&n._CLS===Bt?{count:n.result[0],results:n.result[1]}:e),{count:0,results:[]});return a&&a>0&&(o.count=o.count+1,o.results=[...o.results,[null,a]]),o}}),Wc=Z({key:"categoricalFieldSubCountsValues",get:({path:e,modal:t,value:n})=>({get:s})=>{if(!s(mc(t)))return null;const a=s(Ic({path:e,modal:t,filtered:!0}));if(!a)return null;const l=a.results.filter((([e])=>e===n));return l.length?l[0][1]:0}}),Mc=Z({key:"labelCount",get:e=>({get:t})=>{const n=t(mc(e))?Cc:Zc;let s=0,a=t(n({modal:e,key:"sample"}));return a&&t(nc({modal:e,frames:!1})).forEach((e=>{e in a&&(s+=a[e])})),a=t(n({modal:e,key:"frame"})),a&&t(nc({modal:e,frames:!0})).forEach((e=>{e in a&&(s+=a[e])})),s}}),Xc=Z({key:"tagNames",get:e=>({get:t})=>{var n;return(null!=(n=t(e?gc:bi))?n:[]).reduce(((e,t)=>"tags"===t.name&&t._CLS===Bt?t.result[1].map((([e])=>e)).sort():e),[])}}),Nc=Z({key:"labelTagNames",get:e=>({get:t})=>{var n;const s=t(Si),a=new Set;return(null!=(n=t(e?gc:bi))?n:[]).forEach((e=>{s.includes(e.name)&&Object.keys(e.result).forEach((e=>a.add(e)))})),Array.from(a).sort()}}),Gc=({current:e,get:t,modal:n,paths:s,set:a})=>{const l=n?dc:wi,i=o({},t(l));e.forEach((e=>{s.includes(e)||delete i[e]})),a(l,i)},Yc=Z({key:"filteredScalars",get:e=>({get:t})=>{const n=t(Vi("sample"));let s=[];return n.forEach((n=>{t(Tr(n))?t(Sr({modal:e,path:n}))&&s.push(n):t(Pr(n))?t(Dr({modal:e,path:n}))&&s.push(n):t(zr(n))&&t(Br({modal:e,path:n}))&&s.push(n)})),s},set:e=>({get:t,set:n},s)=>{const a=t(Yc(e));let l=[];Array.isArray(s)&&(l=s),Gc({get:t,set:n,modal:e,paths:l,current:a})}}),Vc=Z({key:"numFilteredScalars",get:e=>({get:t})=>t(Yc(e)).length}),Fc=Z({key:"filteredLabels",get:e=>({get:t})=>{const n=t(Mi("sample"));let s=[];return n.forEach((n=>{t(Qr({modal:e,path:n}))&&s.push(n)})),s},set:e=>({get:t,set:n},s)=>{const a=t(Fc(e));let l=[];Array.isArray(s)&&(l=s),zc({get:t,set:n,modal:e,paths:l,current:a})}}),Kc=Z({key:"numFilteredScalars",get:e=>({get:t})=>t(Fc(e)).length}),Dc=Z({key:"filteredFrameLabels",get:e=>({get:t})=>{const n=t(Mi("frame"));let s=[];return n.forEach((n=>{t(Qr({modal:e,path:"frames."+n}))&&s.push("frames."+n)})),s},set:e=>({get:t,set:n},s)=>{const a=t(Dc(e));let l=[];Array.isArray(s)&&(l=s),zc({get:t,set:n,modal:e,paths:l,current:a})}}),Oc=Z({key:"numFilteredFrameLabels",get:e=>({get:t})=>t(Dc(e)).length}),zc=({get:e,set:t,modal:n,paths:s,current:a})=>{const l=t=>t.reduce(((t,n)=>[...t,`${n=`${n}${Jr(e(Ni)[n])}`}.confidence`,`${n}.label`]),[]);a=l(a),s=l(s),Gc({get:e,set:t,current:a,modal:n,paths:s})},Hc=e=>{const[t,{height:n}]=q(),s=M({height:e?n:0,from:{height:0},config:{duration:0}});return[t,r(o({},s),{overflow:"hidden"})]},Uc=d.div`
  border-bottom: 1px solid ${({theme:e})=>e.background};
  display: flex;
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
`,jc=m(d.div`
  flex-basis: 0;
  flex-grow: 1;
  font-size: 1rem;
  padding-left: 0.4rem;
  line-height: 2;
  font-weight: bold;
  border-bottom-color: ${({theme:e})=>e.brand};
  border-bottom-style: solid;
  border-bottom-width: 2px;
  text-transform: capitalize;
`),Ac=(e,t=null,n=null)=>{const[s,a]=u.exports.useState(!1),l=go(),i="boolean"==typeof t?t&&!e:s&&!e,c=M({backgroundColor:i?l.backgroundLight:l.backgroundDark,color:n||(i?l.font:l.fontDark)});return{style:r(o({},c),{cursor:e?"default":"pointer"}),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1)}};Z({key:"numTaggable",get:({modal:e,labels:t})=>({get:n})=>t?0:e?1:0});const Bc=T({key:"tagAggs",get:async({get:e})=>{const t=e(kc(!1)),n=e(Sc(!1));return t&&n?{label:Object.keys(t).sort(),sample:Object.keys(n).sort()}:null}}),Jc=Z({key:"tagStatistics",get:({modal:e,labels:t})=>async({get:n})=>{n(St),n(Lt);const s=n(sc(!1)),a=x(),{count:l,tags:i}=await Pn({type:"tag_statistics",uuid:a,args:{active_labels:s,sample_id:e?n(ut).sample._id:null,filters:n(e?dc:wi),labels:t}});return{count:l,tags:i}}}),_c=T({key:"numLabelsInSelectedSamples",get:({get:e})=>e(Jc({modal:!1,labels:!0})).count}),Qc=Z({key:"tagStats",get:({modal:e,labels:t})=>({get:n})=>{const s=n(Bc),a=s?Object.fromEntries(s[t?"label":"sample"].map((e=>[e,0]))):null;return a?o(o({},a),n(Jc({modal:e,labels:t})).tags):null}}),$c=m(d.a`
  cursor: pointer;
  margin: 0 -0.5rem;
  padding: 0.25rem 0.5rem;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-content: center;
  flex-direction: column;
  text-decoration: none;
  color: ${({theme:e})=>e.fontDark};

  & > span {
    display: flex;
    justify-content: space-between;
  }
`),qc=d.div`
  margin: 0 -0.5rem 0 -0.5rem;
`,ed=m(d($c)`
  display: flex;
  justify-content: space-between;
  flex-direction: row;
  flex-wrap: nowrap;
  margin: 0;
`),td=d.div`
  text-overflow: ellipsis;
  font-weight: bold;
  flex-grow: 1;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  display: flex;
  justify-content: space-between;
`,nd=({subCountAtom:e,count:t,text:n,color:s})=>{const a=((e=null,t=null)=>void 0===e||null===t?"":"number"==typeof e&&e!==t?`${e.toLocaleString()} of ${t.toLocaleString()}`:t.toLocaleString())(e?P(e):null,t),l=P(Ri);return g.createElement(td,null,g.createElement("span",{style:s?{color:s}:{}},mn(n&&"DateTime"===n._cls?gn(n.datetime,l):n,28-a.length,"middle")),t&&g.createElement("span",null,a))},sd=g.memo((({color:e,name:t,value:n,setValue:s,subCountAtom:a,count:l,disabled:i,forceColor:c})=>{const d=go();e=null!=e?e:d.brand;const m=Ac(i),[h,p]=cc(t);return g.createElement(qc,{title:h},g.createElement(ed,r(o({},m),{onClick:()=>s(!n)}),!i&&g.createElement(ee,{checked:n,title:h,style:{color:e,padding:"0 0.5rem 0 0"},onChange:e=>{e.preventDefault(),e.stopPropagation(),s(!n)},disableRipple:!0}),g.createElement(u.exports.Suspense,{fallback:g.createElement(nd,{count:l,color:p?e:null,text:h})},g.createElement(nd,{color:p||c?e:null,count:l,subCountAtom:a,text:h}))))})),ad=d.div`
  font-size: 14px;
  border-bottom: 1px ${({theme:e})=>e.brand} solid;
  position: relative;
  margin: 0.5rem 0;
`,ld=d.input`
  background-color: transparent;
  border: none;
  color: ${({theme:e})=>e.font};
  height: 2rem;
  font-size: 14px;
  border: none;
  align-items: center;
  font-weight: bold;
  width: 100%;

  &:focus {
    border: none;
    outline: none;
    font-weight: bold;
  }

  &::placeholder {
    color: ${({theme:e})=>e.fontDark};
    font-weight: bold;
  }
`,id=g.memo((({color:e=null,placeholder:t,validator:n=(()=>!0),setter:s,value:a,disabled:l=!1,onEnter:i,onFocus:o,onBlur:r,onKeyDown:c})=>{const d=go();return e=null!=e?e:d.brand,g.createElement(ad,{style:{borderBottom:`1px solid ${e}`}},g.createElement(ld,{placeholder:t,value:null===a?"":String(a),onChange:e=>{n(e.currentTarget.value)&&s(e.currentTarget.value)},onKeyPress:e=>{"Enter"===e.key&&i&&i()},onKeyDown:e=>{"Escape"===e.key&&e.currentTarget.blur(),c&&c(e)},style:l?{color:d.fontDark}:{},disabled:l,onFocus:e=>{o()},onBlur:r}))})),od=d.div`
  background-color: ${({theme:e})=>e.backgroundDark};
  border: 1px solid ${({theme:e})=>e.backgroundDarkBorder};
  border-radius: 2px;
  box-shadow: 0 2px 20px ${({theme:e})=>e.backgroundDark};
  box-sizing: border-box;
  margin-top: 0;
  position: absolute;
  width: auto;
  z-index: 801;
  padding: 0 0.5rem;
  width: calc(100% - 12px);
  left: 6px;
  margin-bottom: 1rem;
`,rd=d($c)`
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  text-overflow: ellipsis;
  margin: 0;
  justify-content: space-between;
  flex-direction: row;
`,cd=d.div`
  margin-left: -0.5rem;
  margin-right: -0.5rem;
  max-height: 330px;
  overflow-y: scroll;
  scrollbar-width: none;
  &::-webkit-scrollbar {
    width: 0px;
    background: transparent;
    display: none;
  }
  &::-webkit-scrollbar-thumb {
    width: 0px;
    display: none;
  }
`,dd=g.memo((({active:e,highlight:t,result:[n,s],onClick:a,maxLen:l,color:i})=>{const c=Ac(!1,e||null,null===n?t:null),d=u.exports.useRef(),m=u.exports.useRef(!1),[h,p]=cc(n);return u.exports.useEffect((()=>{e&&d.current&&!m.current?(d.current.scrollIntoView(!0),m.current=!0):e||(m.current=!1)}),[e]),g.createElement(rd,r(o({title:null===n?"None":n},c),{onClick:a,ref:d}),g.createElement("span",{style:p?{color:i}:{}},l?mn(h,l,"middle"):h),"number"==typeof s&&g.createElement("span",null,s.toLocaleString()))})),md=g.memo((({color:e,onSelect:t,results:n,highlight:s,active:a})=>g.createElement(cd,null,n.map((n=>g.createElement(dd,{key:String(n[0]),result:n,highlight:s,onClick:()=>t(n[0]),active:a===n[0],maxLen:26-n[1].toLocaleString().length,color:e})))))),ud=g.memo((({excludeAtom:e,valueName:t,color:n})=>{const[s,a]=H(e);return g.createElement(lr,{active:s?"Exclude":"Select",color:n,options:[{text:"Select",title:`Select ${t}`,onClick:()=>s&&a(!1)},{text:"Exclude",title:`Exclude ${t}`,onClick:()=>!s&&a(!0)}]})})),hd=d.div`
  background: ${({theme:e})=>e.backgroundDark};
  border: 1px solid #191c1f;
  border-radius: 2px;
  color: ${({theme:e})=>e.fontDark};
  margin-top: 0.25rem;
  padding: 0.25rem 0.5rem;
`,pd=d.div`
  padding-bottom: 0.5rem;
  margin: 3px;
  font-weight: bold;
`,gd=d.div`
  display: flex;
  justify-content: space-between;
`,fd=({color:e,results:t,totalCount:n,selectedValuesAtom:s,excludeAtom:a,valueName:l,modal:i,path:o,disableItems:r,selectedCounts:c})=>{const[d,m]=s?H(s):[[],null],u=new Set(d),h=a?ne(a):null,p=P(ht(i)),f=Object.fromEntries(t);let b=d.map((e=>{var t;return[e,null!=(t=f[String(e)])?t:0]}));const y=i&&P(Hi("sample"))[o]===qt;return(n<=20||r)&&(b=[...b,...t.filter((([e])=>r||!u.has(e)))]),0===n?g.createElement(g.Fragment,null,g.createElement(sd,{key:"No results",color:e,value:!1,disabled:!0,name:"No results",setValue:()=>{}})):(b=[...new Set(b)],g.createElement(g.Fragment,null,b.sort((({count:e,asc:t})=>(n,s)=>{let a=[...n],l=[...s];e&&(a.reverse(),l.reverse());let i=0;for(let e=0;e<a.length;e++)if(i=hn(a[e],l[e],t),0!==i)return i;return i})(p)).map((([t,n])=>g.createElement(sd,{key:String(t),color:e,value:u.has(t),disabled:i&&1===b.length||r,name:t,count:y?null:c.current.has(t)?c.current.get(t):n,subCountAtom:Wc({path:o,modal:i,value:t}),setValue:e=>{r||(e?u.add(t):u.delete(t),m([...u].sort()))}}))),Boolean(u.size)&&!r&&g.createElement(g.Fragment,null,n>3&&a&&g.createElement(ud,{excludeAtom:a,valueName:l,color:e}),g.createElement(em,{text:"Reset",color:e,onClick:()=>{m([]),h(!1)},style:{margin:"0.25rem -0.5rem",height:"2rem",borderRadius:0,textAlign:"center"}}))))},bd=({results:e,color:t,shown:n,onSelect:s,onMouseEnter:a,onMouseLeave:l,subCount:i,active:o})=>{const r=go();return g.createElement(g.Fragment,null,n&&e&&g.createElement(od,{onMouseEnter:a,onMouseLeave:l},e&&g.createElement(md,{color:t,active:o,onSelect:s,results:e,highlight:t}),g.createElement(nr,null),g.createElement($c,{style:{cursor:"default",textAlign:"right",color:r.font}},e&&null!==i&&e.length>0&&g.createElement(g.Fragment,null,e.length!==i&&g.createElement(g.Fragment,null,e.length," of"),i.toLocaleString()," results"),e&&0===e.length&&g.createElement(g.Fragment,null,"No results"))))},yd=()=>{const e=u.exports.useRef();return te((({snapshot:t})=>async({modal:n,path:s,search:a,selectedValuesAtom:l,setSearchResults:i,setSubCount:r,setActive:c,noneCount:d})=>{const m=x(),u=setTimeout((()=>i(null)),200),h=await t.getPromise(ht(n));let p=null;n&&(p=(await t.getPromise(ut)).sampleId);const g=await t.getPromise(l),f=new Promise((e=>{const t=(n=({count:n,results:s})=>{Zn.removeEventListener("message",t),e({count:n,results:s})},({data:e})=>{(e=JSON.parse(e)).uuid===m&&n(e)});var n;Zn.addEventListener("message",t),Zn.send(Cn("count_values",o({path:s,search:a,selected:g,limit:200,uuid:m,sample_id:p},h)))}));e.current=f,f.then((({count:t,results:n})=>{clearTimeout(u),e.current===f&&(d>0&&(n=[...n,[null,d]]),n.length&&c(n[0][0]),i(n),r(t))}))}),[])},vd=g.memo(g.forwardRef((({name:e,valueName:t,color:n,selectedValuesAtom:s,excludeAtom:a,countsAtom:l,path:i,modal:o,disableItems:r},c)=>{const d=s?P(s):[null,null],{count:m,results:h}=P(l),[p,f]=u.exports.useState(!1),[b,y]=u.exports.useState(!1),[v,x]=u.exports.useState(""),[w,k]=u.exports.useState(void 0),[E,S]=u.exports.useState(null),[L,T]=u.exports.useState(null),Z=u.exports.useRef(new Map),C=((e,t,n)=>te((({snapshot:s,set:a})=>async(l,i)=>{const o=new Set(await s.getPromise(e));t.current.set(l,i),o.add(l),a(e,[...o].sort()),n.forEach((e=>e()))})))(s,Z,[()=>T(null),()=>x(""),()=>k(void 0)]),R=h.filter((([e,t])=>null===e)),I=R.length?R[0][1]:0,W=yd();u.exports.useLayoutEffect((()=>{p&&W({modal:o,path:i,search:v,selectedValuesAtom:s,setSearchResults:T,setSubCount:S,setActive:k,noneCount:I})}),[p,v,d,I]);const M=(e,t)=>{const n=e.map((e=>e[0])).indexOf(t);return e[n][1]};return g.createElement(pd,{ref:c},g.createElement(gd,null,e&&g.createElement(g.Fragment,null,e)),g.createElement(hd,null,m>20&&!r&&g.createElement(g.Fragment,null,g.createElement(id,{key:"input",color:n,setter:e=>{x(e),k(void 0)},value:v,onKeyDown:e=>{if(null!==L)if("ArrowDown"===e.key)if(void 0===w)k(L[0]);else{const e=L.map((e=>e[0])).indexOf(w);e<L.length-1&&k(L[e+1][0])}else if("ArrowUp"===e.key){const e=L.map((e=>e[0])).indexOf(w);e>0&&k(L[e-1][0])}},onEnter:()=>{void 0!==w&&C(w,M(L,w)),h&&h.map((([e])=>e)).includes(v)&&C(v,M(L,w))},placeholder:null===h?"Loading...":`+ filter by ${t}`,onFocus:()=>{h.length&&k(h[0][0]),f(!0)},onBlur:()=>!b&&f(!1)}),g.createElement(bd,{key:"results",results:L,color:n,shown:p||b,onSelect:e=>{C(e,M(L,e)),y(!1),f(!1)},active:w,subCount:E,onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1)})),g.createElement(fd,{path:i,color:n,name:e,results:h,selectedValuesAtom:s,excludeAtom:a,valueName:t,modal:o,totalCount:m,disableItems:r,selectedCounts:Z})))}))),xd=d.div`
  font-weight: bold;
  display: flex;
  padding: 1.5rem 0 0.5rem;
  line-height: 1.9rem;
`,wd=d(se)`
  && {
    color: ${({theme:e})=>e.brand};
    margin: 0 1.5rem 0 1.3rem;
    height: 3px;
  }

  .rail {
    height: 7px;
    border-radius: 6px;
  }

  .track {
    height: 7px;
    border-radius: 6px;
    background: ${({theme:e})=>e.brand};
  }

  .thumb {
    height: 1rem;
    width: 1rem;
    border-radius: 0.5rem;
    background: ${({theme:e})=>e.brand};
    box-shadow: none;
    color: transparent;
  }

  .thumb:hover,
  .thumb:focus,
  .thumb.active {
    box-shadow: none;
  }

  .valueLabel {
    width: auto;
    margin-top: 0.5rem;
    font-weight: bold;
    font-family: "Palanquin", sans-serif;
    font-size: 14px;
    padding: 0.2rem;
    border-radius: 6rem;
    color: transparent;
    transform: none !important;
    margin-top: -4px;
  }

  .valueLabel > span > span {
    text-align: center;
    color: ${({theme:e})=>e.font};
    background: ${({theme:e})=>e.backgroundDark};
    border: 1px solid ${({theme:e})=>e.backgroundDarkBorder};
  }
`,kd=g.memo((({boundsAtom:e,color:t,fieldType:n,onChange:s,onCommit:a,persistValue:l=!0,showBounds:i=!0,value:c,style:d,showValue:m=!0})=>{const h=go(),p=P(e),f=n&&Zr(n)?P(Ri):null,[b,y]=u.exports.useState(!1);if(!p.every((e=>null!==e)))return null;const v=((e,t)=>{let n=(e[1]-e[0])/100;return[en,$t,qt].includes(t)?Math.ceil(n):n})(p,n),{formatter:x,hasTitle:w}=((e,t,n)=>{let s,a=!1;const l=[_t,Jt].includes(e);return l&&(s=fn(t,n[0],n[1]),a=null!==s[0]),{hasTitle:a,formatter:t=>{if(l){const e=s[1].format(t).split(",");if(1===e.length){const t=e[0].split("-");if(3===t.length){const[e,n,s]=t;return g.createElement("div",null,e,"‑",n,"‑",s)}return e[0]}let[n,a]=e;if(3===s[1].resolvedOptions().fractionalSecondDigits)return a+="ms",g.createElement(g.Fragment,null,g.createElement("div",null,n),g.createElement("div",null,a));const[l,i,o]=n.split("/");return g.createElement(g.Fragment,null,g.createElement("div",null,l,"‑",i,"‑",o),a&&g.createElement("div",null,a))}return ae(t).format([en,$t,qt].includes(e)?"0a":"0.00a")}}})(n,n===Jt?"UTC":f,p);return g.createElement(g.Fragment,null,w?g.createElement(g.Fragment,null,g.createElement("div",{style:{width:"100%",textAlign:"center",padding:"0.25rem",color:h.font}},fn(f,p[0],p[1])[0].format(p[0]).replaceAll("/","-"))):null,g.createElement(xd,{style:d},i&&x(p[0]),g.createElement(wd,{onMouseDown:()=>y(!0),onMouseUp:()=>y(!1),value:c,onChange:s,onChangeCommitted:(e,t)=>{a(e,t),y(!1)},classes:{thumb:"thumb",track:"track",rail:"rail",active:"active",valueLabel:"valueLabel"},valueLabelFormat:x,"aria-labelledby":"slider",valueLabelDisplay:(b||l)&&m?"on":"off",max:p[1],min:p[0],step:v,theme:r(o({},h),{brand:t})}),i&&x(p[1])))})),Ed=e=>{var t=e,{valueAtom:n,onChange:s}=t,a=c(t,["valueAtom","onChange"]);const[l,i]=H(n),[d,m]=u.exports.useState(null);return u.exports.useEffect((()=>{JSON.stringify(l)!==JSON.stringify(d)&&m(l)}),[l]),g.createElement(kd,r(o({},a),{onChange:(e,t)=>s?i(t):m(t),onCommit:(e,t)=>i(t),value:d}))},Sd=e=>{var t=e,{valueAtom:n}=t,s=c(t,["valueAtom"]);const[a,l]=H(n),[i,d]=u.exports.useState([null,null]);return u.exports.useEffect((()=>{JSON.stringify(a)!==JSON.stringify(i)&&d(a)}),[a]),g.createElement(kd,r(o({},s),{onChange:(e,t)=>d(t),onCommit:(e,t)=>l(t),value:[...i]}))},Ld=d.div`
  padding-bottom: 0.5rem;
  margin: 3px;
  font-weight: bold;
`,Td=d.div`
  display: flex;
  justify-content: space-between;
`,Zd=d.div`
  background: ${({theme:e})=>e.backgroundDark};
  border: 1px solid #191c1f;
  border-radius: 2px;
  color: ${({theme:e})=>e.fontDark};
  margin-top: 0.25rem;
  padding: 0.25rem 0.5rem 0 0.5rem;
`,Cd={nan:"nan",ninf:"-inf",inf:"inf",none:null},Pd=g.memo(g.forwardRef(((e,t)=>{var n=e,{color:s,name:a,fieldType:l}=n,i=c(n,["color","name","fieldType"]);const d=ne(hc({modal:i.modal,path:i.path})),m=P(Xr(i)),u=P(Or(i)),h=m.every((e=>null!==e)),p=P(Yr({modal:i.modal,path:i.path})),f=(e=>{var t=e,{fieldType:n,otherCounts:s}=t,a=c(t,["fieldType","otherCounts"]);const[l,i]=H(Gr(r(o({},a),{key:"none"})));return(n!==Qt?[["none",[l,i]]]:[["inf",H(Gr(r(o({},a),{key:"inf"})))],["ninf",H(Gr(r(o({},a),{key:"ninf"})))],["nan",H(Gr(r(o({},a),{key:"nan"})))],["none",[l,i]]]).filter((([e])=>s[e]>0))})(r(o({},i),{fieldType:l,otherCounts:p})),b=P(Dr(i));return h||1!==f.length||"none"!==f[0][0]?g.createElement(Ld,{ref:t},a&&g.createElement(Td,null,a),g.createElement(Zd,null,h&&g.createElement(Sd,r(o({},i),{showBounds:!1,fieldType:l,valueAtom:Nr(i),boundsAtom:Xr(i),color:s})),(u||f.some((([e,[t]])=>t!==f[0][1][0])))&&f.map((([e,[t,n]])=>g.createElement(sd,{color:s,name:Cd[e],value:t,setValue:n,count:p[e],subCountAtom:Fr({key:e,modal:i.modal,path:i.path}),forceColor:!0}))),b&&f.length>0&&h&&g.createElement(ud,{excludeAtom:Kr(i),valueName:"",color:s}),b&&g.createElement(em,{text:"Reset",color:s,onClick:()=>d(null),style:{margin:"0.25rem -0.5rem",height:"2rem",borderRadius:0,textAlign:"center"}}))):null})));var Rd=g.memo((({expanded:e,entry:t,modal:n,fieldType:s})=>{const[a,l]=Hc(e);if(!s){const e=P(no(t.path)),n=P(so(t.path));s=e===sn?n:e}return g.createElement(m.div,{style:l},n?g.createElement(vd,{valueName:t.path,color:t.color,countsAtom:Ic({modal:n,path:t.path,filtered:!1}),path:t.path,modal:n,disableItems:t.disableList,ref:a}):g.createElement(Pd,{color:t.color,modal:n,path:t.path,fieldType:s,ref:a}))}));const Id=d.div`
  display: flex;
  justify-content: space-between;
  margin: 3px;

  a {
    cursor: pointer;
    text-decoration: underline;
  }
`,Wd=({entry:e})=>{const t=P(to(e.name)).length,n=te((({snapshot:t,set:n})=>async()=>{const s=await t.getPromise(to(e.name)),a=await t.getPromise(Tt);n(Tt,Object.fromEntries(Object.entries(a).filter((([e])=>!s.includes(e)))))}),[e.name]);return t<1?null:g.createElement(Id,null,"Hidden: ",t,g.createElement("a",{onClick:n},"reset"))};var Md=g.memo((({expanded:e,entry:t,modal:n})=>{const[s,a]=Hc(e),l=`${t.path}${Jr(t.labelType)}`,i=`${l}.confidence`,r=`${l}.label`,c=`${l}.support`,d=`${l}.value`;return g.createElement(m.div,{style:o({},a)},g.createElement("div",{ref:s},g.createElement("div",{style:{margin:3}},n&&g.createElement(Wd,{entry:t}),"Regression"!==t.labelType&&g.createElement(vd,{color:t.color,name:"Labels",valueName:"label",selectedValuesAtom:jr({modal:n,path:r}),countsAtom:Ic({modal:n,path:r,filtered:!1}),excludeAtom:Ar({modal:n,path:r}),modal:n,path:r}),Dt.includes(t.labelType)&&g.createElement(Pd,{modal:n,color:t.color,name:"Confidence",path:i,defaultRange:[0,1],fieldType:Qt}),"Regression"===t.labelType&&g.createElement(Pd,{color:t.color,name:"Value",noneAtom:numericField.noneAtom({modal:n,path:d}),noneCountAtom:noneCount({path:d,modal:n}),boundsAtom:numericField.boundsAtom({path:d}),valueAtom:numericField.rangeAtom({modal:n,path:d}),fieldType:Qt}),Ot.includes(t.labelType)&&g.createElement(Pd,{modal:n,color:t.color,name:"Support",path:c,fieldType:qt}))))}));var Xd=g.memo((({expanded:e,entry:t,modal:n})=>{const[s,a]=Hc(e);return g.createElement(m.div,{style:a},g.createElement(vd,{valueName:t.path,color:t.color,selectedValuesAtom:jr({modal:n,path:t.path}),excludeAtom:Ar({modal:n,path:t.path}),countsAtom:Ic({modal:n,path:t.path,filtered:!1}),path:t.path,modal:n,disableItems:t.disableList,ref:s}))}));var Nd=g.memo((({expanded:e,entry:t,modal:n})=>{const[s,a]=Hc(e);return g.createElement(m.div,{style:a},g.createElement(vd,{valueName:t.path,color:t.color,selectedValuesAtom:Lr({path:t.path,modal:n}),countsAtom:Ic({path:t.path,modal:n,filtered:!1}),disableItems:t.disableList,path:t.path,modal:n,ref:s}))}));const Gd=d.div`
  vertical-align: middle;
  font-weight: bold;
  overflow: visible;

  & > div {
    margin-top: 3px;
    margin-left: 0;
    margin-right: 0;
    border-radius: 2px;
  }

  label {
    margin: 0;
    width: 100%;
    height: 32px;
    display: flex;
    justify-content: space-between;

    .MuiTypography-body1 {
      flex: 1;
      font-size: unset;
      align-items: center;
      padding-right: 3px;
      max-width: 100%;
    }

    .MuiTypography-body1.with-checkbox {
      max-width: calc(100% - 36px);
    }
    overflow: "hidden", .MuiCheckbox-root {
      padding: 0;

      .MuiIconButton-label {
        position: relative;
        svg {
          z-index: 2;
        }
      }
    }

    .MuiFormControlLabel-label {
      display: flex;
      font-weight: bold;
      color: unset;
      line-height: 29px;
      height: 29px;
      justify-content; space-between;
      max-width: 100%;

      span {
        white-space: nowrap;
      }

      span.name {
        display: block;
        padding: 0 4px;
        overflow: hidden;
        text-overflow: ellipsis;
        flex-grow: 1;
        max-width: 100%;
        line-height: 29px;
        height: 29px;
        align-items: center;
        vertical-align: middle;
      }
      span.count {
        display: block;
        height: 29px;
        line-height: 29px;
        vertical-align: middle;
        max-width: 100%;
      }

      span.data {
        display: block;
        margin-left: 0.5em;
        line-height: 29px;
        display: flex;
        vertical-align: middle;
        align-items: center;
      }
    }
  }

  && .Mui-disabled {
    cursor: not-allowed;
    color: ${({theme:e})=>e.fontDarkest};

    svg,
    input[type="checkbox"] {
      display: none;
    }
  }

  && .no-checkbox {
    cursor: default;
  }
`,Yd=m(d.div`
  position: relative;
  overflow: visible;
`),Vd=({count:e,subCountAtom:t,value:n,title:s,path:a,hasDropdown:l,expanded:i,setExpanded:o})=>{const r=go(),c=t?P(t):null,d=c?c[a]:null,m=i?oe:re;return n||"string"==typeof n?g.createElement("span",{className:"count",title:s,style:{marginRight:4}},un(n)):"number"!=typeof e?g.createElement(ie,{style:{color:r.font,height:16,width:16,minWidth:16}}):g.createElement(g.Fragment,null,g.createElement("span",{className:"count",title:s},"number"==typeof d&&d!==e?`${d.toLocaleString()} of ${e.toLocaleString()}`:e.toLocaleString()),l&&e>0&&g.createElement(m,{onClick:e=>{e.preventDefault(),o(!i)},style:{marginRight:-4,cursor:"pointer"}}))},Fd=g.memo((({entry:e,onCheck:t,modal:n})=>{let{disabled:s,color:a,hasDropdown:l,hideCheckbox:i,name:c,path:d,selected:m,title:h,canFilter:p,type:f,count:b,subCountAtom:y,value:v,icon:x,key:w}=e;const[k,E]=u.exports.useState(!1),S=go(),L=P(Tr(d)),T=P(Pr(d)),Z=P(zr(d)),C=P(Qr({path:d,modal:n}))&&p&&!((T||L||Z)&&n),R=P(Rr(d));l=l&&(!R||!n);const I=i?"no-checkbox":"with-checkbox",W=M({backgroundColor:C?"#6C757D":S.backgroundLight});return g.createElement(Yd,{style:W},g.createElement(le,{disabled:s,label:g.createElement(g.Fragment,null,g.createElement("span",{className:"name",title:c,style:{marginLeft:i?4:0}},c),g.createElement(u.exports.Suspense,{fallback:g.createElement(Vd,{path:w||d,value:v,count:b,title:h,hasDropdown:l,expanded:k,setExpanded:E})},g.createElement(Vd,{path:w||d,value:v,subCountAtom:y,count:b,title:h,hasDropdown:l,expanded:k,setExpanded:E})),x||null),classes:{root:I,label:I},style:{width:"100%",color:m||i?S.font:e.disabled?S.fontDarkest:S.fontDark},control:g.createElement(ee,{disableRipple:!0,checked:m,title:`Show ${c} ${f}`,onClick:()=>t(r(o({},e),{selected:!e.selected})),onMouseDown:null,style:{display:i?"none":"block",color:m||i?a:s?S.fontDarkest:S.fontDark}})}),T&&g.createElement(Rd,{expanded:k,entry:e,modal:n}),Z&&g.createElement(Xd,{expanded:k,entry:e,modal:n}),L&&g.createElement(Nd,{expanded:k,entry:e,modal:n}),e.labelType&&(X=e.labelType,Kt.includes(X))?g.createElement(Md,{expanded:k,entry:e,modal:n}):null);var X})),Kd=g.memo((({entries:e,onCheck:t,modal:n,sort:s=!0})=>{const a=(e=>{const{count:t,asc:n}=P(ht(e));return e=>e.sort(((e,s)=>{let a=[e.name,e.count],l=[s.name,s.count];t&&(a.reverse(),l.reverse());let i=0;for(let t=0;t<a.length;t++)if(i=hn(a[t],l[t],n),0!==i)return i;return i}))})(n);return s&&(e=a(e)),g.createElement(Gd,null,e.map((e=>g.createElement(Fd,{key:e.name,entry:e,onCheck:t,modal:n}))))})),Dd=d.div`
  .MuiCheckbox-root {
    padding: 4px 8px 4px 4px;
  }

  ${or.Body} {
    display: flex;
    align-items: center;
    color: ${({theme:e})=>e.fontDark};

    span {
    }

    .label {
      text-transform: uppercase;
      flex-grow: 1;
      display: flex;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .icon {
      margin-left: 2px;
    }
  }

  .left-icon {
    margin-right: 4px;
  }
`,Od=g.memo((({label:e,icon:t,entries:n,handleClear:s,onSelect:a,title:l,modal:i,children:o,pills:r=[],sort:c})=>{const[d,m]=u.exports.useState(!0),h=n.filter((e=>e.selected)).length,p=go();return g.createElement(yr,{label:g.createElement(g.Fragment,null,t?g.createElement("span",{className:"left-icon"},t):null,g.createElement("span",{className:"label"},e),h?g.createElement(er,{onClick:s,highlight:!1,open:!1,icon:g.createElement(ce,null),title:"Clear displayed",text:ae(h).format("0,0"),style:{height:"1.5rem",fontSize:"0.8rem",lineHeight:"1rem",color:p.font}}):null,r),title:l,expanded:d,onExpand:m},n.length?g.createElement(Kd,{entries:n,onCheck:a,modal:i,sort:c}):g.createElement("span",null,"No ",l.toLocaleLowerCase()),o)})),zd=(e,t,n,s,a)=>{const l=e.has(t)?n.font:n.fontDark;return g.createElement("span",{title:`Only show ${a?"labels":"samples"} with the "${t}" tag ${e.size?"or other selected tags":""}`,onClick:s,style:{cursor:"pointer",height:20,width:20,marginLeft:8}},g.createElement(me,{style:{color:l,height:20,width:20}}))},Hd=(e,t,n)=>t.size?[g.createElement(er,{key:"clear-match",highlight:!1,icon:g.createElement(me,null),text:ae(t.size).format("0,0"),onClick:e=>{e.stopPropagation(),e.preventDefault(),n(new Set)},title:"Clear matching",open:!1,style:{marginLeft:"0.25rem",height:"1.5rem",fontSize:"0.8rem",lineHeight:"1rem",color:e}})]:[],Ud=({modal:e})=>{const{tags:t,activeTags:n,setActiveTags:s,matchedTags:a,setMatchedTags:l}=(e=>{const t=P(Xc(!1)),n=P(Xc(e)),[s,a]=H(lc(e)),[l,i]=H(uc({modal:e,key:"sample"}));return u.exports.useEffect((()=>{const e=new Set;l.forEach((t=>{n.includes(t)&&e.add(t)})),e.size!==l.size&&i(e)}),[l,t]),{tags:n,activeTags:s,setActiveTags:a,matchedTags:l,setMatchedTags:i}})(e),i=P(Ai(e)),[o,r]=[Lc(e),P(Sc(e))],{singular:c}=P(ri),d=go();return g.createElement(Od,{label:`${c} tags`,icon:g.createElement(de,null),pills:!e&&Hd(d.font,a,l),entries:t.filter((e=>r[e])).map((t=>{const s=i("tags."+t);return{name:t,disabled:!1,hideCheckbox:e,hasDropdown:!1,selected:n.includes(t),color:s,title:t,canFilter:!e,path:`tags.${t}`,key:t,type:"tags",count:e?null:r[t],value:e?r[t]>0?g.createElement(ce,{style:{marginTop:3,color:s}}):g.createElement(f,{style:{marginTop:3,color:s}}):null,subCountAtom:o,icon:e?null:zd(a,t,d,(e=>{e.stopPropagation(),e.preventDefault();const n=new Set(a);a.has(t)?n.delete(t):n.add(t),l(n)}),!1),modal:e}})),onSelect:({name:t,selected:a})=>!e&&s(a?[t,...n]:n.filter((e=>e!==t))),handleClear:e=>{e.stopPropagation(),s([])},modal:e,title:`${c} tags`})},jd=({modal:e})=>{const t=P(Ai(e)),[n,s]=[Ec(e),P(kc(e))],{tags:a,activeTags:l,setActiveTags:i,matchedTags:o,setMatchedTags:r}=((e,t)=>{const n=P(Nc(!1));let s=P(Nc(e));const[a,l]=H(ic(e)),[i,o]=H(uc({modal:e,key:"label"}));return u.exports.useEffect((()=>{const e=new Set;i.forEach((t=>{s.includes(t)&&e.add(t)})),e.size!==i.size&&o(e)}),[i,n]),!e&&(s=s.filter((e=>t[e]))),{tags:s,activeTags:a,setActiveTags:l,matchedTags:i,setMatchedTags:o}})(e,s),c=go();return g.createElement(Od,{label:"Label tags",icon:g.createElement(ue,null),pills:Hd(c.font,o,r),entries:a.map((a=>{const i=t("_label_tags."+a);return{canFilter:!0,name:a,disabled:!1,hideCheckbox:e,hasDropdown:!1,selected:l.includes(a),color:i,title:a,type:"label tags",path:"_label_tags."+a,key:a,modal:e,count:s[a]||0,subCountAtom:n,icon:zd(o,a,c,(e=>{e.stopPropagation(),e.preventDefault();const t=new Set(o);o.has(a)?t.delete(a):t.add(a),r(t)}),!0)}})),onSelect:({name:t,selected:n})=>{!e&&i(n?[t,...l]:l.filter((e=>e!==t)))},handleClear:e=>{e.stopPropagation(),i([])},modal:e,title:"Label tags"})},Ad=({modal:e,frames:t})=>{const n=t?"frame":"sample",s=P(Mi(n)),[a,l]=H(nc({modal:e,frames:t})),i=P(gi),o=P(Ni),r=P(Ai(e)),[c,d]=[Cc({key:n,modal:e}),P(Zc({key:n,modal:e}))],m=P(Pt(e)),u=go();return g.createElement(Od,{label:t?"Frame labels":"Labels",icon:t?g.createElement(he,null):i?g.createElement(pe,null):g.createElement(ge,null),pills:Bd(t?Oc(e):Kc(e),t?Dc(e):Fc(e)),sort:!1,entries:s.map((n=>{const s=t?"frames."+n:n;return{name:n,disabled:!1,hideCheckbox:!1,hasDropdown:Kt.includes(o[s]),selected:a.includes(s),color:m?u.brand:r(s),title:n,path:s,type:"labels",modal:e,count:d?d[s]:null,subCountAtom:c,labelType:o[s],canFilter:!0}})),onSelect:({name:e,selected:n})=>{t&&(e="frames."+e),l(n?[e,...a]:a.filter((t=>t!==e)))},handleClear:e=>{e.stopPropagation(),l([])},modal:e,title:t?"Frame label fields":"Label fields"})},Bd=(e,t)=>{const n=go(),s=te((({set:e})=>async()=>{e(t,[])}),[t]),a=P(e);return a>0?[g.createElement(er,{key:"clear-match",highlight:!1,icon:g.createElement(fe,null),text:ae(a).format("0,0"),onClick:e=>{e.stopPropagation(),e.preventDefault(),s()},title:"Clear filters",open:!1,style:{marginLeft:"0.25rem",height:"1.5rem",fontSize:"0.8rem",lineHeight:"1rem",color:n.font}})]:null},Jd=({modal:e})=>{const t=P(Vi("sample")),[n,s]=H(ac(e)),a=P(Pt(e)),l=go(),i=P(Ui("sample")),o=P(Ai(e)),[r,c]=[Rc(e),P(Pc(e))],d=P(zi("sample")),m=P(Ri),u=P(Ki("sample")),h=[_t,Jt];return g.createElement(Od,{label:"Other fields",icon:g.createElement(be,null),pills:e?null:Bd(Vc(e),Yc(e)),sort:!1,entries:t.filter((t=>!(["filepath","id"].includes(t)&&e))).map((t=>{let s=e?c[i[t]]:null;return s&&(h.includes(d[t])||h.includes(u[t]))&&(s=gn(s.datetime,d[t]===Jt||u[t]===_t?"UTC":m)),{name:t,disabled:!1,hideCheckbox:e,hasDropdown:!e||Array.isArray(s),selected:n.includes(t),color:a?l.brand:o(t),title:!e||Array.isArray(s)&&d[t]!==qt?t:un(s,!1),value:!e||Array.isArray(s)&&d[t]!==qt?null:un(s,!1),path:t,count:null===c?null:e&&Array.isArray(s)&&d[t]!==qt?s.length:c[t],type:"values",modal:e,subCountAtom:r,disableList:e,canFilter:!e||Array.isArray(s)}})),onSelect:e?null:({name:e,selected:t})=>{s(t?[e,...n]:n.filter((t=>t!==e)))},handleClear:e=>{e.stopPropagation(),s([])},modal:e,title:"Other fields"})},_d=({modal:e})=>{const t=P(qr);return t.length?g.createElement(Od,{label:"Unsupported fields",icon:g.createElement(ye,null),entries:t.map((e=>({name:e,path:e,title:e,data:null,disabled:!0,hideCheckbox:!0,selected:!1}))),title:"Unsupported fields",modal:e}):null},Qd=m(d.div`
  cursor: pointer;
  margin-left: 0;
  margin-right: 0;
  padding: 2.5px 0.5rem;
  border-radius: 3px;
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
`),$d=m(d.div`
  padding-right: 0.25rem;
  display: flex;
  justify-content: center;
  align-content: center;
  flex-direction: column;
  color: inherit;
  line-height: 1.7;
  & > span {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
`),qd=({style:e,children:t})=>g.createElement($d,{style:e},g.createElement("span",null,t)),em=({onClick:e,text:t,children:n=null,style:s,color:a=null,title:l=null})=>{const i=go(),[c,d]=u.exports.useState(!1);a=null!=a?a:i.brand;const m=M({backgroundColor:c?a:i.background,color:c?i.font:i.fontDark,config:{duration:150}});return g.createElement(Qd,{style:o(r(o({},m),{userSelect:"none"}),s),onClick:e,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),title:null!=l?l:t},g.createElement(qd,{style:{fontWeight:"bold",width:"100%"}},t),n)},tm=g.forwardRef((({modal:e,style:t},n)=>{const s="video"===P(pi),a=e?{height:"auto",overflow:"unset"}:{};return g.createElement(Dd,{ref:n,style:o(o({},t),a)},g.createElement(Ud,{modal:e}),g.createElement(jd,{modal:e}),g.createElement(Ad,{modal:e,frames:!1}),s&&g.createElement(Ad,{modal:e,frames:!0}),g.createElement(Jd,{modal:e}),g.createElement(_d,{modal:e}))}));var nm=g.memo((({modal:e,children:t,style:n={},bounds:s})=>{const a=M({opacity:1,from:{opacity:0},config:{duration:100}}),{width:l}=ho(),i=e&&s?{position:"fixed",right:l-s.right,top:s.bottom+8}:{};return g.createElement(tr,{style:o(o(o({},a),i),n)},t)}));const sm=({modal:e})=>{const[t,n]=H(Wt(Boolean(e)));return g.createElement(g.Fragment,null,g.createElement(em,{text:g.createElement("span",{style:{display:"flex",justifyContent:"center"}},"Refresh colors"," ",g.createElement(ve,{style:{marginLeft:"0.25rem",color:"inherit"}})),title:"Refresh colors",onClick:()=>n(t+1),style:{margin:"0.25rem -0.5rem",height:"2rem",borderRadius:0,textAlign:"center"}}))},am=({modal:e})=>{const[t,n]=H(Pt(e));return g.createElement(g.Fragment,null,g.createElement(nr,null,"Color by"),g.createElement(lr,{active:t?"value":"field",options:[{text:"field",title:"Color by field",onClick:()=>t&&n(!1)},{text:"value",title:"Color by value",onClick:()=>!t&&n(!0)}]}))},lm=({modal:e})=>{const t=go(),[n,s]=H(Rt(e));return g.createElement(g.Fragment,null,g.createElement(nr,{style:{display:"flex",height:33}},g.createElement("span",null,"Label opacity"),.7!==n&&g.createElement("span",{onClick:()=>s(.7),style:{cursor:"pointer",margin:"0.25rem"},title:"Reset label opacity"},g.createElement(xe,null))),g.createElement(Ed,{valueAtom:Rt(e),boundsAtom:we([0,1]),color:t.brand,showBounds:!1,persistValue:!1,showValue:!1,onChange:!0,style:{padding:0},int:!1}))},im=({modal:e})=>{const[{count:t,asc:n},s]=H(ht(e));return g.createElement(g.Fragment,null,g.createElement(nr,null,"Sort sidebar contents by"),g.createElement(lr,{active:t?"count":"value",options:[{text:"count",title:"Sort by count",onClick:()=>!t&&s({count:!0,asc:n})},{text:"value",title:"Sort by value",onClick:()=>t&&s({count:!1,asc:n})}]}),g.createElement(sd,{name:"Reverse",value:!n,setValue:e=>s({count:t,asc:!e})}))},om=({modal:e})=>{const t=P(di),[n,s]=H(pt(e));return t?g.createElement(g.Fragment,null,g.createElement(nr,null,"Patches"),g.createElement(sd,{name:"Crop to patch",value:n,setValue:e=>s(e)})):null};var rm=g.memo((({modal:e,bounds:t})=>g.createElement(nm,{modal:e,bounds:t},g.createElement(am,{modal:e}),g.createElement(sm,{modal:e}),g.createElement(lm,{modal:e}),g.createElement(im,{modal:e}),g.createElement(om,{modal:e}))));const cm=g.memo((({onClick:e,text:t,href:n,title:s,disabled:a=!1,hidden:l=!1,style:i,svgStyles:d={height:"1rem",marginTop:4.5}})=>{const m=Ac(a),{style:u}=m,h=c(m,["style"]);return e=n?To(n):e,l?null:g.createElement($c,r(o({title:s||t,onClick:a?null:e},h),{style:null!=i?i:u,href:n,target:n?"_blank":null}),g.createElement("span",{style:n?{textDecoration:"underline"}:{}},t,n&&g.createElement(ke,{style:d})))})),dm=b({key:"patching",default:!1}),mm=T({key:"patchesFields",get:({get:e})=>{const t=e(Xi),n=e(Ni);return t.filter((e=>Gt.includes(n[e])))}}),um=T({key:"clipsFields",get:({get:e})=>{const t=e(Xi),n=e(Ni),s=e(Di("sample"));return[...t.filter((e=>e.startsWith("frames.")?Vt.includes(n[e]):Yt.includes(n[e]))),...Object.entries(s).filter((([e,t])=>t.ftype===qt||t.subfield===qt)).map((([e])=>e))].sort()}}),hm=T({key:"evaluationKeys",get:({get:e})=>Object.keys(e(St).dataset.evaluations||{})}),pm=({close:e})=>{const t=P(um),n=te((({set:e})=>async t=>{e(dm,!0),Zn.send(Cn("save_filters",{add_stages:[{_cls:"fiftyone.core.stages.ToClips",kwargs:[["field_or_expr",t],["_state",null]]}],with_selected:!0}))}),[]);return g.createElement(g.Fragment,null,t.map((t=>g.createElement(cm,{key:t,text:t,title:`Switch to clips view for the "${t}" field`,onClick:()=>{e(),n(t)}}))),g.createElement(cm,{key:0,text:"About clips views",title:"About clips views",href:"https://voxel51.com/docs/fiftyone/user_guide/app.html#viewing-video-clips"}))},gm=({close:e})=>{const t=P(mm),n=te((({set:e})=>async t=>{e(dm,!0),Zn.send(Cn("save_filters",{add_stages:[{_cls:"fiftyone.core.stages.ToPatches",kwargs:[["field",t],["_state",null]]}],with_selected:!0}))}),[]);return g.createElement(g.Fragment,null,t.map((t=>g.createElement(cm,{key:t,text:t,title:`Switch to patches view for the "${t}" field`,onClick:()=>{e(),n(t)}}))),g.createElement(cm,{key:0,text:"About patch views",title:"About patch views",href:"https://voxel51.com/docs/fiftyone/user_guide/app.html#viewing-object-patches"}))},fm=({close:e})=>{const t=P(hm),n=te((({set:e})=>async t=>{e(dm,!0),Zn.send(Cn("save_filters",{add_stages:[{_cls:"fiftyone.core.stages.ToEvaluationPatches",kwargs:[["eval_key",t],["_state",null]]}],with_selected:!0}))}),[]);return g.createElement(g.Fragment,null,t.map((t=>g.createElement(cm,{key:t,text:t,title:`Switch to evaluation patches view for the "${t}" evaluation`,onClick:()=>{e(),n(t)}}))),g.createElement(cm,{key:0,text:"About evaluation views",title:"About evaluation views",href:"https://voxel51.com/docs/fiftyone/user_guide/app.html#viewing-evaluation-patches"}))};var bm=g.memo((({bounds:e,close:t})=>{const n=go(),s=P(gi)&&P(ei),a=P(ci),[l,i]=u.exports.useState(!0),o=M({borderBottomColor:l?n.brand:n.backgroundDark,cursor:l?"default":"pointer"}),r=M({borderBottomColor:l?n.backgroundDark:n.brand,cursor:l?"pointer":"default"});return g.createElement(nm,{modal:!1,bounds:e},g.createElement(Uc,null,g.createElement(jc,{style:o,onClick:()=>!l&&i(!0)},"Labels"),!s&&g.createElement(jc,{style:r,onClick:()=>l&&i(!1)},"Evaluations")),l&&(s||a)&&g.createElement(pm,{close:t}),l&&!s&&!a&&g.createElement(gm,{close:t}),!l&&g.createElement(fm,{close:t}))}));const ym=e=>Object.fromEntries(e.map((e=>{var t=e,{label_id:n}=t;return[n,c(t,["label_id"])]}))),vm=(e,t)=>te((({snapshot:n,set:s})=>async()=>{const a=await n.getPromise(eo);t=e?await n.getPromise(e):t,s(eo,o(o({},a),ym(t)))})),xm=(e,t)=>te((({snapshot:n,set:s})=>async()=>{const a=await n.getPromise(eo);t=e?await n.getPromise(e):t;const l=Object.entries(a).filter((([e])=>!t.has(e)));s(eo,Object.fromEntries(l))})),wm=(e,t)=>te((({snapshot:n,set:s})=>async()=>{const a=await n.getPromise($i);t=e?await n.getPromise(e):t;const l=await n.getPromise(Tt);s(Tt,o(o({},l),ym(t.filter((({label_id:e})=>!a.has(e))))))})),km=(e,t)=>new Set([...e].filter((e=>!t.has(e)))).size>0,Em=e=>new Set([...e].map((({label_id:e})=>e))),Sm=(e,t)=>{const n=P($i),s=e.current.getCurrentSampleLabels(),a=P(gi)&&P(ei),l=e.current instanceof Hl?e.current.getCurrentFrameLabels():new Array,i=e=>g.useCallback((()=>{t(),e()}),[]),r=P(ri),c=km(Em(s),n),d=km(Em(l),n),m=(u=n,h=Em(s),new Set([...u].filter((e=>h.has(e)))).size>0);var u,h;return[{text:`Select visible (current ${r.singular})`,hidden:!c,onClick:i(vm(null,s))},{text:`Unselect visible (current ${r.singular})`,hidden:!m,onClick:i(xm(null,Em(s)))},a&&{text:"Select visible (current frame)",hidden:!d,onClick:i(vm(null,l))},a&&{text:"Unselect visible (current frame)",hidden:!m,onClick:i(xm(null,Em(l)))},{text:"Clear selection",hidden:!n.size,onClick:i(te((({set:e})=>async()=>e(eo,{}))))},{text:"Hide selected",hidden:!n.size,onClick:i(te((({snapshot:e,set:t})=>async()=>{const n=await e.getPromise(eo),s=await e.getPromise(Tt);t(eo,{}),t(Tt,o(o({},s),n))})))},{text:`Hide unselected (current ${r.singular})`,hidden:!c,onClick:i(wm(null,s))},a&&{text:"Hide unselected (current frame)",hidden:!d,onClick:i(wm(null,l))}].filter(Boolean)};var Lm=g.memo((({modal:e,close:t,lookerRef:n,bounds:s})=>{u.exports.useLayoutEffect((()=>{n&&n.current instanceof Hl&&n.current.pause&&n.current.pause()}));const a=e?Sm(n,t):(e=>{const t=P(ri),n=te((({set:t})=>async()=>{t(Lt,new Set),Zn.send(Cn("clear_selection",{})),e()}),[e]),s=te((({snapshot:t})=>async n=>{e();const s=await t.getPromise(St),a=JSON.parse(JSON.stringify(s)),l=await t.getPromise(Lt),i=a.view||[];i.push({_cls:`fiftyone.core.stages.${n}`,kwargs:[["sample_ids",Array.from(l)]]}),a.view=i,a.selected=[],Zn.send(Cn("update",{state:a}))}));return[{text:`Clear selected ${t.plural}`,title:`Deselect all selected ${t.plural}`,onClick:n},{text:`Only show selected ${t.plural}`,title:`Hide all other ${t.plural}`,onClick:()=>s("Select")},{text:`Hide selected ${t.plural}`,title:`Show only unselected ${t.plural}`,onClick:()=>s("Exclude")}]})(t);return n&&io(n.current,"play",t),g.createElement(nm,{modal:e,bounds:s},a.map(((e,t)=>g.createElement(cm,r(o({},e),{key:t})))))}));const Tm=m(d($c)`
  display: flex;
  justify-content: space-between;
  flex-direction: row;
  margin: 0;
`),Zm=d.div`
  display: flex;
  justify-content: space-between;
  flex: 1;
  width: calc(100% - 33px);
`,Cm=d.span`
  display: block;
  white-space: nowrap;
`,Pm=({name:e,count:t,checkmark:n,onCheck:s,active:a,setActive:l,edited:i,disabled:o})=>{const r=go(),{style:c,onMouseEnter:d,onMouseLeave:m}=Ac(!1,a===e),h=u.exports.useRef();return g.createElement(Tm,{onMouseEnter:()=>{l(e),d()},onMouseLeave:m,style:c,onClick:e=>!o&&!(e.target===h.current||h.current.contains(e.target))&&s()},g.createElement(ee,{disableRipple:!0,ref:h,indeterminate:null===n,disabled:o,onChange:()=>!o&&s(),checked:n===Rm.ADD||null===n,style:{color:i?r.brand:r.fontDark,padding:"0 0.5rem 0 0"}}),g.createElement(Zm,{title:e},g.createElement(Cm,{style:{flexGrow:1,maxWidth:"100%",paddingRight:"0.5rem",textOverflow:"ellipsis",overflow:"hidden"}},e),g.createElement(Cm,null,t>0?ae(t).format("0,0"):"0")))};var Rm,Im;(Im=Rm||(Rm={}))[Im.ADD=0]="ADD",Im[Im.REMOVE=1]="REMOVE";const Wm=d.div`
  margin: 0 -0.5rem 0.25rem -0.5rem;
  max-height: 346px;
  overflow-y: auto;
  scrollbar-width: none;

  &::-webkit-scrollbar {
    width: 0px;
    background: transparent;
    display: none;
  }
  &::-webkit-scrollbar-thumb {
    width: 0px;
    display: none;
  }
`,Mm=({name:e,items:t,changes:n,count:s,setChange:a,value:l})=>()=>{a(e,e in t&&e in n?1===l||0===t[e]?null:1:e in t?s===t[e]?1:0:0===l?l in t?1:null:0)};var Xm=g.memo((({items:e,changes:t,setChange:n,count:s,active:a,setActive:l,disabled:i})=>{const c=Object.entries(o(o({},e),t)).sort((([e],[t])=>e<t?-1:1)),d=c.map((([e])=>e));var m;return m=i=>{if(0===d.length)return;let o=null;"ArrowDown"===i.key?o=null===a?0:d.indexOf(a)+1:"ArrowUp"===i.key&&(o=null===a?d.length-1:d.indexOf(a)-1),o<0?o=d.length-1:o>d.length-1&&(o=0),null!==o&&l(d[o]),"Enter"===i.key&&a.length&&Mm({name:a,changes:t,items:e,count:s,value:c.filter((([e])=>e===a))[0][1],setChange:n})()},io(document.body,"keydown",m),g.createElement(Wm,{onMouseLeave:()=>l(null)},c.map((([c,d])=>{const m=Mm({name:c,value:d,items:e,changes:t,setChange:n,count:s}),u=0===t[c]?s:1===t[c]?null:e[c];return g.createElement(Pm,r(o({},{name:c,count:u,active:a,disabled:i}),{onCheck:m,checkmark:c in t?t[c]:s===e[c]?0:0===e[c]?1:null,edited:c in t,setActive:l,key:c}))})))}));const Nm=d.div`
  position: absolute;
  top: 0.25rem;
  right: -0.75rem;
  height: 2rem;
  width: 2rem;

  & > svg {
    margin-top: 0.5rem;
    margin-right: 0.25rem;
    color: ${({theme:e})=>e.font};
  }
`,Gm=g.memo((({loading:e})=>{const t=go();return g.createElement(Nm,null,e&&g.createElement(ie,{style:{color:t.font,height:16,width:16,marginTop:"0.25rem"}}))})),Ym=d.div`
  font-size: 14px;
  border-bottom: 1px ${({theme:e})=>e.brand} solid;
  position: relative;
  margin: 0.5rem 0;
`,Vm=d.input`
  background-color: transparent;
  border: none;
  color: ${({theme:e})=>e.font};
  height: 2rem;
  font-size: 14px;
  border: none;
  align-items: center;
  font-weight: bold;
  width: 100%;

  &:focus {
    border: none;
    outline: none;
    font-weight: bold;
  }

  &::placeholder {
    color: ${({theme:e})=>e.fontDark};
    font-weight: bold;
  }
`,Fm=({countAndPlaceholder:e,submit:t,taggingAtom:n,itemsAtom:s,close:a,labels:l})=>{const i=P(s),c=P(ri),[d,m]=H(n),[h,p]=u.exports.useState(""),[f,b]=e(),y=d||"number"!=typeof f,[v,x]=u.exports.useState({}),[w,k]=u.exports.useState(null),[E,S]=u.exports.useState(!1);u.exports.useLayoutEffect((()=>{x({})}),[n]),u.exports.useLayoutEffect((()=>{d&&S(!0),!d&&E&&a()}),[d,E]);const L=e=>Object.fromEntries(Object.entries(e).filter((([e])=>e.toLowerCase().includes(h.toLowerCase()))));if(!i)return g.createElement(Um,null);const T=Object.keys(v).length>0,Z=h.length>0&&!(h in v||h in i);return g.createElement(g.Fragment,null,g.createElement(Ym,null,g.createElement(Vm,{placeholder:0==f?`No ${l?"labels":c.plural}`:y?null===f?"loading...":"saving...":b,value:h,onChange:e=>{if(p(e.target.value),e.target.value.length){const t=Array.from(new Set(Object.keys(o(o({},i),v)))).sort().filter((t=>t.toLocaleLowerCase().includes(e.target.value.toLowerCase())));t.length&&k(t[0])}},title:Z?`Enter to add "${h}" tag to ${f} ${l&&f>1?"labels":l?"label":f>1?c.plural:c.singular}`:null,onKeyPress:e=>{"Enter"===e.key&&Z&&(p(""),x(r(o({},v),{[h]:Rm.ADD})))},focused:!y,disabled:y||0===f,autoFocus:!0,onBlur:({target:e})=>e.focus(),type:"text"}),g.createElement(Gm,{loading:Boolean(d||"number"!=typeof f)})),f>0&&g.createElement(Xm,{active:w,disabled:y,items:L(i),changes:L(v),count:f,setActive:k,setChange:(e,t)=>{const n=o({},v);null===t?delete n[e]:n[e]=t,x(n)}}),y||!T&&!Z?null:g.createElement(g.Fragment,null,g.createElement(nr,null),Z&&g.createElement(em,{text:`Add "${h}" tag to ${f>1?ae(f).format("0,0")+" ":""}${l&&f>1?"labels":l?"label":f>1?c.plural:c.singular}`,onClick:()=>{p(""),x(r(o({},v),{[h]:Rm.ADD}))},style:{margin:"0.25rem -0.5rem",paddingLeft:"0.5rem",height:"2rem",borderRadius:0}}),T&&!h.length&&g.createElement(em,{text:"Apply",onClick:()=>{return e=v,t({changes:Object.fromEntries(Object.entries(e).map((([e,t])=>[e,t===Rm.ADD])))}),void m(!0);var e},style:{margin:"0.25rem -0.5rem",height:"2rem",borderRadius:0,textAlign:"center"}})))},Km=(e,t,n,s)=>{if(0===n)return`no ${s.plural}`;const a=ae(t).format("0,0");return 0===t?"no labels":e?`+ tag ${t>1?`${a} `:""}selected label${t>1?"s":""}`:`+ tag ${a} label${t>1?"s":""}`},Dm=(e,t)=>{if(e){const n=ae(t=e).format("0,0");return`+ tag ${t>1?`${n} `:""}selected label${1===t?"":"s"}`}const n=ae(t).format("0,0");return`+ tag ${t>1?`${n} `:""} label${1===t?"":"s"}`},Om=(e,t,n,s)=>{if(0===n)return`no ${s.plural}`;if(e){const t=ae(n=e).format("0,0");return`+ tag ${n>1?`${t} `:""}selected ${1===n?s.singular:s.plural}`}const a=ae(n).format("0,0");return`+ tag ${n>1?`${a} `:""}${1===n?s.singular:s.plural}`},zm=e=>`+ tag ${e.singular}`,Hm=(e,t,n=null)=>te((({snapshot:s})=>async({changes:a})=>{const l=(await s.getPromise(sc(e))).filter((e=>!(e.startsWith("tags.")||e.startsWith("_label_tags."))));e?Zn.send((({labels:e,sample_id:t,changes:n,activeLabels:s,frameNumber:a=null})=>Cn("tag_modal",{changes:n,labels:e,sample_id:t,active_labels:s,frame_number:a}))({sample_id:(await s.getPromise(ut)).sample._id,changes:a,labels:t,activeLabels:l,frameNumber:n&&n.current?n.current.frameNumber:null})):Zn.send((({targetLabels:e,activeLabels:t,changes:n})=>Cn("tag",{target_labels:e,active_labels:t,changes:n}))({changes:a,targetLabels:t,activeLabels:l}))}),[e,t,n]),Um=()=>{const e=go();return g.createElement("div",{style:{display:"flex",justifyContent:"center"}},g.createElement(ie,{style:{color:e.fontDark,margin:"1rem 0"}}))};var jm=g.memo((({modal:e,bounds:t,close:n,lookerRef:s})=>{const[a,l]=u.exports.useState(e),i=P(ri),o=go(),r=M({borderBottomColor:a?o.backgroundDark:o.brand,cursor:a?"pointer":"default"}),c=M({borderBottomColor:a?o.brand:o.backgroundDark,cursor:a?"default":"pointer"}),d=Hm(e,a,s),m=((e,t,n)=>()=>{const s=P(e?$i:Lt).size;if(e&&t){const t=s>0?s:P(Mc(e));return[t,Dm(s,t)]}if(e)return[1,zm(n)];{const a=P(ki),l=P(Ei),i=null!=l?l:a,o=P(_c),r=s?o:P(Mc(e));return t?[r,Km(s,r,i,n)]:[s>0?s:i,Om(s,0,i,n)]}})(e,a,i);return g.createElement(nm,{style:{width:"12rem"},modal:e,bounds:t},g.createElement(Uc,null,g.createElement(jc,{style:r,onClick:()=>a&&l(!1)},e?i.singular:i.plural),g.createElement(jc,{style:c,onClick:()=>!a&&l(!0)},"Labels")),a&&g.createElement(u.exports.Suspense,{fallback:g.createElement(Um,null),key:"labels"},g.createElement(Fm,{countAndPlaceholder:m,submit:d,taggingAtom:Et({modal:e,labels:a}),itemsAtom:Qc({modal:e,labels:a}),close:n,labels:!0})),!a&&g.createElement(u.exports.Suspense,{fallback:g.createElement(Um,null),key:i.plural},g.createElement(Fm,{countAndPlaceholder:m,submit:d,taggingAtom:Et({modal:e,labels:a}),itemsAtom:Qc({modal:e,labels:a}),close:n,labels:!1})))}));const Am=d.div``,Bm=m(d($c)`
  display: flex;
  justify-content: space-between;
  flex-direction: row;
  margin: 0;
`),Jm=d.div`
  text-overflow: ellipses;
  font-weight: bold;
  flex-grow: 1;
`,_m=g.memo((({color:e,currentValue:t,setValue:n,value:s})=>{const a=Ac(!1);return g.createElement(Am,null,g.createElement(Bm,r(o({},a),{onClick:()=>n(s)}),g.createElement(Ee,{style:{color:e,padding:"0 0.5rem 0 0"},checked:s===t,disableRipple:!0}),g.createElement(Jm,null,s)))})),Qm=d.div`
  overflow: auto visible;
  max-height: 165px;
  margin: 0 -0.5rem;
  scrollbar-width: none;

  &::-webkit-scrollbar {
    width: 0px;
    background: transparent;
    display: none;
  }
  &::-webkit-scrollbar-thumb {
    width: 0px;
    display: none;
  }
`,$m=g.memo((({choices:e,color:t=null,value:n,setValue:s})=>{const a=go();return t=null!=t?t:a.brand,u.exports.useLayoutEffect((()=>{e.length>=1&&!n&&s(e[0])}),[n,e]),n?g.createElement(Qm,null,e.map((e=>g.createElement(_m,{value:e,setValue:s,color:t,currentValue:n,key:e})))):null}));class qm{constructor(e,t,n,s,a){this.attached=!1,this.section=document.createElement("div"),this.index=e,this.itemIndex=t,this.render=s,this.section.classList.add("_flashlightSection_1nu3i_103"),this.rows=n.map((({aspectRatio:e,extraMargins:t,items:n})=>[{aspectRatio:e,extraMargins:t},n.map((e=>{const t=document.createElement("div");return a&&t.addEventListener("click",(t=>{t.preventDefault(),a(t,e.id)})),this.section.appendChild(t),[t,e]}))]))}getItems(){return this.rows.map((([e,t])=>t.map((([e,t])=>t)))).flat()}set(e,t){if(this.top!==e&&(this.section.style.top=`${e}px`,this.top=e),this.width!==t){let e=0;this.rows.forEach((([{extraMargins:n,aspectRatio:s},a])=>{n=n||0;const l=(t-3*(a.length-1+n))/s;let i=0;a.forEach((([t,{aspectRatio:n}])=>{const s=l*n;t.style.height=`${l}px`,t.style.width=`${s}px`,t.style.left=`${i}px`,t.style.top=`${e}px`,i+=s+3})),e+=l+3})),this.width!==t&&(this.section.style.height=`${e}px`,this.section.style.width=`${t}px`),this.width=t,this.height=e}}getHeight(){return this.height}getBottom(){return this.top+this.height}getTop(){return this.top}hide(){this.attached&&(this.section.remove(),this.rows.forEach((([{aspectRatio:e,extraMargins:t},n])=>{!t&&(t=0);const s=(this.width-3*(n.length-1+t))/e;n.forEach((([e,{id:t,aspectRatio:n}])=>{const a=s*n;this.render(t,e,[a,s],!1,!0)}))})),this.attached=!1)}isShown(){return this.attached}show(e,t,n){t!==this.hidden&&(t?this.section.classList.add("_flashlightSectionHidden_1nu3i_116"):this.section.classList.remove("_flashlightSectionHidden_1nu3i_116"),this.hidden=t),this.attached||(e.appendChild(this.section),this.attached=!0),!this.hidden&&this.rows.forEach((([{aspectRatio:e,extraMargins:t},s])=>{!t&&(t=0);const a=(this.width-3*(s.length-1+t))/e;s.forEach((([e,{id:t,aspectRatio:s}])=>{const l=a*s;this.render(t,e,[l,a],n,!1)}))}))}resizeItems(e){this.rows.forEach((([{extraMargins:t,aspectRatio:n},s])=>{t=t||0;const a=(this.width-3*(s.length-1+t))/n;s.forEach((([t,{aspectRatio:n,id:s}])=>{e(s,[a*n,a])}))}))}}function eu(e,t,n){const s=[];let a=[],l=null;for(const o in e){const n=e[o];null!==l?l>=t?(s.push({items:a,aspectRatio:l}),a=[n],l=n.aspectRatio):(l+=n.aspectRatio,a.push(n)):(l=n.aspectRatio,a.push(n))}let i=[];return n?i=a:a.length&&s.push((({items:e},t)=>{const n=e.map((({aspectRatio:e})=>e));if(n.length&&1===new Set(n).size){let s=n[0],a=s,l=1;for(;s<t;)s+=a,l+=1;return{items:e,aspectRatio:s,extraMargins:l-e.length}}return{items:e,aspectRatio:Math.max(t,n.reduce(((e,t)=>e+t),0))}})({items:a,aspectRatio:l},t)),{rows:s,remainder:i}}class tu{constructor(e){this.loading=!1,this.ctx=0,this.config=e,this.container=this.createContainer(),this.showPixels(),this.element=document.createElement("div"),this.element.classList.add("_flashlight_1nu3i_45"),this.state=this.getEmptyState(e);let t=!1;document.addEventListener("visibilitychange",(()=>this.render())),this.resizeObserver=new ResizeObserver((([{contentRect:{width:e,height:n}}])=>{this.state.containerHeight=n,t?(e-=16,requestAnimationFrame((()=>{const t=this.state.width!==e&&this.state.onResize?this.state.onResize(e):{},n=this.state.width!==e;this.state.width=e,n?this.updateOptions(t,n):this.render(!1)}))):t=!0})),((e,t,n)=>{let s,a=!1,l=!1,i=0;e.addEventListener("scroll",(()=>{l=!0,o()&&!a&&t(a)}));const o=()=>{const o=n();return o!==1/0&&(i?(Math.abs(e.scrollTop-i)>o?(a=!0,void 0!==s&&(clearTimeout(s),s=void 0),s=setTimeout((function(){a=!1,s=void 0,t(!1)}),350)):void 0===s&&(l=!1),i=e.scrollTop):i=e.scrollTop,!0)},r=()=>{requestAnimationFrame(r),l&&o()&&a&&t(a)};r()})(this.element,(e=>this.render(e)),(()=>this.state.resizing?1/0:this.state.width/(this.state.containerHeight*this.state.options.rowAspectRatioThreshold)*500)),this.element.appendChild(this.container)}reset(){this.ctx++,this.loading=!1;const e=this.createContainer();this.container.replaceWith(e),this.container=e,this.state=this.getEmptyState(this.config),this.showPixels();const{width:t,height:n}=this.container.parentElement.getBoundingClientRect();this.state.width=t-16,this.state.containerHeight=n,this.get()}isAttached(){return Boolean(this.container.parentElement)}showPixels(){!this.pixelsSet&&this.container.classList.add("_flashlightPixels_1nu3i_99"),this.pixelsSet=!0}hidePixels(){this.pixelsSet&&this.container.classList.remove("_flashlightPixels_1nu3i_99"),this.pixelsSet=!1}attach(e){"string"==typeof e&&(e=document.getElementById(e));const{width:t,height:n}=e.getBoundingClientRect();this.state.width=t-16,this.state.containerHeight=n;const s=this.state.onResize?this.state.onResize(t):{};e.appendChild(this.element),this.resizeObserver.observe(e),this.updateOptions(s,!1),this.get()}updateOptions(e,t){const n=Object.entries(e).some((([e,t])=>this.state.options[e]!=t));if(this.state.options=o(o({},this.state.options),e),n&&this.state.sections.length){this.resetResize();const e=this.createContainer();this.container.replaceWith(e),this.container=e;const t=[...this.state.sections.map((e=>e.getItems())).flat(),...this.state.currentRowRemainder.map((({items:e})=>e)).flat()],n=this.state.activeSection,s=this.state.sections[n].itemIndex;let a=this.tile(t);const l=a[a.length-1];a.length&&Boolean(this.state.currentRequestKey)&&1!==l.length?(this.state.currentRowRemainder=l,a=a.slice(0,-1)):this.state.currentRowRemainder=[],this.state.height=0,this.state.sections=[],this.state.shownSections=new Set,this.state.clean=new Set,a.forEach(((e,t)=>{const n=new qm(t,this.state.itemIndexMap[e[0].items[0].id],e,this.state.render,this.getOnItemClick());n.set(this.state.height,this.state.width),this.state.sections.push(n),this.state.height+=n.getHeight()})),e.style.height=`${this.state.height}px`;for(const i of this.state.sections)if(i.itemIndex>=s)return this.container.parentElement.scrollTop=i.getTop(),void this.render()}else if(t){this.resetResize(),this.state.sections.forEach((e=>{e.set(this.state.height,this.state.width),this.state.height+=e.getHeight()})),this.container.style.height=`${this.state.height}px`;const e=this.state.sections[this.state.activeSection];e&&(this.container.parentElement.scrollTop=e.getTop()),this.render()}}updateItems(e){this.state.clean=new Set,this.state.shownSections.forEach((t=>{this.state.sections[t].getItems().map((({id:e})=>e)).forEach((t=>e(t)))})),this.state.updater=e}get(){if(this.loading||null===this.state.currentRequestKey)return null;this.loading=!0;let e=this.ctx;return this.state.get(this.state.currentRequestKey).then((({items:t,nextRequestKey:n})=>{if(e!==this.ctx)return;this.state.currentRequestKey=n;for(const{id:e}of t)this.state.itemIndexMap[e]=this.state.nextItemIndex,this.state.nextItemIndex++;t=[...this.state.currentRemainder,...t];let s=this.tile(t,!0);const a=s[s.length-1];Boolean(n)&&a&&1!==a.length?(this.state.currentRowRemainder=a,s=s.slice(0,-1)):this.state.currentRowRemainder=[],s.forEach((e=>{const t=new qm(this.state.sections.length,this.state.itemIndexMap[e[0].items[0].id],e,this.state.render,this.getOnItemClick());t.set(this.state.height,this.state.width),this.state.sections.push(t),this.state.height+=t.getHeight(),this.state.clean.add(t.index)})),s.length&&(this.container.style.height=`${this.state.height}px`);const l=this.state.sections[this.state.sections.length-1];this.state.currentRequestKey=n,this.loading=!1,(this.state.height<=this.state.containerHeight||!s.length&&n||l&&this.state.shownSections.has(l.index))&&this.requestMore(),(this.state.height>=this.state.containerHeight||null===n)&&(this.hidePixels(),this.render())}))}requestMore(){this.state.currentRequestKey&&this.get()}hideSection(e){const t=this.state.sections[e];t&&t.isShown()&&(t.hide(),this.state.shownSections.delete(t.index))}showSections(e){this.state.shownSections.forEach((t=>{const n=this.state.sections[t];if(!n)return;!this.state.resized||this.state.resized.has(n.index)||e||this.state.resizing||(this.state.onItemResize&&n.resizeItems(this.state.onItemResize),this.state.resized.add(n.index)),this.state.clean.has(n.index)||e||(this.state.updater&&n.getItems().map((({id:e})=>e)).forEach((e=>this.state.updater(e))),this.state.clean.add(n.index));const s=this.state.clean.has(n.index)||!this.state.updater;n.show(this.container,!s&&e||this.state.resizing,e),this.state.shownSections.add(n.index)}))}render(e=!1){if(0===this.state.sections.length&&null===this.state.currentRequestKey)return void this.hidePixels();const t=this.element.scrollTop,n=(s=this.state.sections.map((e=>Math.abs(e.getTop()-t)))).map(((e,t)=>[e,t])).reduce(((e,t)=>t[0]<e[0]?t:e),[s[0],0])[1];var s;this.state.firstSection=Math.max(n-2,0);let a=this.state.sections[this.state.firstSection],l=this.state.firstSection;for(;a&&a.getTop()<=t+this.state.containerHeight;)l=a.index+1,a=this.state.sections[l];this.state.lastSection=a?l:l-1,this.state.activeSection=this.state.firstSection;let i=this.state.sections[this.state.activeSection];if(!i)return;for(;i.getBottom()-3<=t&&this.state.sections[this.state.activeSection+1];)this.state.activeSection+=1,i=this.state.sections[this.state.activeSection];let o=this.state.firstSection;for(;o<=this.state.lastSection;)this.state.shownSections.add(o),o++;[...Array.from(this.state.shownSections)].forEach((e=>{(e<this.state.firstSection||e>this.state.lastSection)&&this.hideSection(e)})),this.showSections(e),this.state.lastSection===this.state.sections.length-1&&this.requestMore()}tile(e,t=!1){let{rows:n,remainder:s}=eu(e,this.state.options.rowAspectRatioThreshold,Boolean(this.state.currentRequestKey));return this.state.currentRemainder=s,t&&(n=[...this.state.currentRowRemainder,...n]),new Array(Math.ceil(n.length/1)).fill(0).map((e=>n.splice(0,1)))}getEmptyState(e){return r(o({currentRequestKey:e.initialRequestKey,containerHeight:null,width:null,height:0},e),{currentRemainder:[],currentRowRemainder:[],items:[],sections:[],activeSection:0,firstSection:0,lastSection:0,options:o({rowAspectRatioThreshold:5},e.options),clean:new Set,shownSections:new Set,onItemClick:e.onItemClick,onItemResize:e.onItemResize,onResize:e.onResize,itemIndexMap:{},nextItemIndex:0,resized:null,resizing:!1})}getOnItemClick(){return this.state.onItemClick?(e,t)=>this.state.onItemClick(e,t,o({},this.state.itemIndexMap)):null}createContainer(){const e=document.createElement("div");return e.classList.add("_flashlightContainer_1nu3i_78"),e.tabIndex=-1,e.addEventListener("mouseenter",(()=>e.focus())),e.removeEventListener("mouseleaver",(()=>e.blur())),e}resetResize(){this.state.resized=new Set,this.state.height=0,this.state.resizing=!0,this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout((()=>{this.state.resizing=!1,this.resizeTimeout=null,this.render()}),500)}}const nu=(e,t)=>`${Sn}/filepath/${encodeURIComponent(e)}?id=${t}`,su=T({key:"lookerType",get:({get:e})=>{const t=e(mi),n=e(di);return e=>{const s=e.startsWith("video/");return s&&(t||n)?Fl:s?Hl:Kl}}}),au=()=>te((({set:e,snapshot:t})=>async()=>{if(await t.getPromise(gt))return;const n=await t.getPromise(Xt);e(Xt,r(o({},n),{showJSON:!1})),e(ut,null),e(eo,{}),e(Tt,{})}),[]),lu=b({key:"gridZoomRange",default:[0,10]});let iu=new Map,ou=new Map,ru=0,cu=new E({max:500,dispose:(e,t)=>t.destroy()});const du=(()=>{window.location.origin;try{0}catch{}return`${Sn}/page?`})(),mu=d.div`
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
`,uu=T({key:"flashlightOptions",get:({get:e})=>({rowAspectRatioThreshold:11-Math.max(e(Pi),e(lu)[0])})}),hu=T({key:"flashlightLookerOptions",get:({get:e})=>({coloring:e(Bi(!1)),filter:e(_r(!1)),activePaths:e(ec),zoom:e(di)&&e(pt(!1)),loop:!0,inSelectionMode:e(Lt).size>0,fieldsMap:e(Ui("sample")),frameFieldsMap:e(Ui("frame")),timeZone:e(Ri),alpha:e(Rt(!1)),disabled:!1})}),pu=(gu=(e,t)=>t[0]<e[0]?t:e,e=>e.map(((e,t)=>[e,t])).reduce(gu)[1]);var gu;const fu=e=>{const t=au();return te((({set:n,snapshot:s})=>async(a,l,i)=>{const c=i[l],d=Object.fromEntries(Object.entries(i).map((([e,t])=>[t,e])));let m=new Set(await s.getPromise(Lt));if(!m.size)return void(()=>{const s=a=>{var l;const i=ou.has(a)?Promise.resolve(iu.get(ou.get(a))):null==(l=e.current.get())?void 0:l.then((()=>ou.has(a)?iu.get(ou.get(a)):null));i?i.then((e=>{e?n(ut,r(o({},e),{index:a,getIndex:s})):t()})):t()};n(ut,r(o({},iu.get(l)),{index:c,getIndex:s})),n(_r(!0),{})})();const u=[...m];a.shiftKey&&!m.has(l)?(()=>{const e=i[u[pu(u.map((e=>Math.abs(i[e]-c))))]],[t,n]=c<e?[c,e]:[e,c],s=new Array(n-t+1).fill(0).map(((e,n)=>d[n+t]));m=new Set([...u,...s])})():a.shiftKey?(()=>{let e=c;for(;m.has(d[e]);)e--;e+=1;let t=c;for(;m.has(d[t]);)t++;t-=1;const[n,s]=c-e<=t-c?c-e==0?[c,t]:[e,c]:t-c==0?[e,c]:[c,t];m=new Set(u.filter((e=>i[e]<n||i[e]>s)))})():m.has(l)?m.delete(l):m.add(l),n(Lt,m),Zn.send(Cn("set_selection",{_ids:Array.from(m)}))}),[])};var bu=g.memo((()=>{const[e]=u.exports.useState((()=>x())),t=P(uu),n=P(hu),s=P(su),a=u.exports.useRef(),l=P(Li("sample")),i=P(ci);a.current=({sample:e,dimensions:t,frameNumber:a,frameRate:c})=>{const d=s(pn(e)),m=i?{support:e.support}:{};return new d(e,o({src:nu(e.filepath,e._id),thumbnail:!0,dimensions:t,sampleId:e._id,frameRate:c,frameNumber:d===Fl?a:null,fieldSchema:Object.fromEntries(l.map((e=>[e.name,e])))},m),r(o({},n),{selected:w.has(e._id)}))};const c=u.exports.useRef();c.current=({sample:e,dimensions:[t,s]})=>{const a=t/s;return n.zoom?((e,t)=>{let n=[];Object.entries(e).forEach((([e,t])=>{t&&t._cls in Pl&&(n=[...n,...Pl[t._cls](t)])}));let[s,a,l,i]=Jn(n);return 0!==l&&0!==i||(l===i?(l=1,i=1):0===i?i=l:l=i),l/i*t})(e,a):a};const[d,m]=u.exports.useState(null),h=u.exports.useRef(),p=P(pt(!1)),f=P(wi),b=P($l),y=P(fi),v=P(Jl),w=P(Lt),k=fu(h),E=te((({set:e,snapshot:t})=>async n=>{const s=new Set(await t.getPromise(Lt));s.has(n)?s.delete(n):s.add(n),e(Lt,s),Zn.send(Cn("set_selection",{_ids:Array.from(s)}))}),[]),S=ne(lu);(()=>{const e=te((({set:e,snapshot:t})=>async({samples:n})=>{n.forEach((e=>{iu.set(e._id,r(o({},iu.get(e._id)),{sample:e})),cu.has(e._id)&&cu.get(e._id).updateSample(e)})),e(ut,o({},await t.getPromise(ut))),e(qi,!1)}),[]);oo("samples_update",e)})();const L=u.exports.useRef(),T=P(Pi);var Z;if(L.current=T,io(document,"keydown",te((({snapshot:e,set:t})=>async n=>{if("Escape"!==n.key)return;await e.getPromise(ut)||(t(Lt,new Set),Zn.send(Cn("set_selection",{_ids:[]})))}),[])),u.exports.useLayoutEffect((()=>{h.current&&h.current.isAttached()&&(iu=new Map,cu.reset(),Es(),Ls(),ou=new Map,ru=0,h.current.reset())}),[h,(Z=f,"object"!=typeof Z||Array.isArray(Z)?Z:JSON.stringify(Object.keys(Z).map((e=>[e,Z[e]])).sort(((e,t)=>e[0]-t[0])))),b,Rn(y),v,p]),d)throw d;return u.exports.useLayoutEffect((()=>{h.current?(h.current.updateOptions(t),h.current.updateItems((e=>{const t=cu.get(e);t&&t.updateOptions(r(o({},n),{selected:w.has(e),inSelectionMode:w.size>0}))}))):(h.current=new tu({initialRequestKey:1,options:t,onItemClick:k,onResize:e=>{let t=7;e>=1200?t=0:e>=1e3?t=2:e>=800&&(t=4);const n=Math.max(t,L.current);return S([t,10]),{rowAspectRatioThreshold:11-n}},onItemResize:(e,t)=>{cu.has(e)&&cu.get(e).resize(t)},get:async e=>{try{const{results:t,more:n}=await fetch(`${du}page=${e}`).then((e=>e.json())),s=t.map((e=>{const t={sample:e.sample,dimensions:[e.width,e.height],frameRate:e.frame_rate,frameNumber:e.sample.frame_number};return iu.set(e.sample._id,t),ou.set(ru,e.sample._id),ru++,t}));return{items:s.map((e=>({id:e.sample._id,aspectRatio:c.current(e)}))),nextRequestKey:n?e+1:null}}catch(t){m(t)}},render:(e,t,n,s,l)=>{try{const i=iu.get(e);if(cu.has(e)){const s=cu.get(e);return l?s.disable():s.attach(t,n),null}if(!s){const s=a.current(i);s.addEventListener("selectthumbnail",(({detail:e})=>E(e))),cu.set(e,s),s.attach(t,n)}return null}catch(i){m(i)}}}),h.current.attach(e))}),[e,t,n,w,L]),g.createElement(mu,{id:e})}));const yu=b({key:"similaritySorting",default:!1}),vu=()=>te((({snapshot:e,set:t})=>async()=>{const n=await e.getPromise(Tu),s=await(async(e,t)=>{const n=await e.getPromise($i),s=await e.getPromise(eo),a=(await e.getPromise(ao)).patches.filter((([e,n])=>e===t)).map((([e,t])=>t))[0];if(n.size)return[...n].filter((e=>s[e].field===a));const l=await e.getPromise(Lt),i=await e.getPromise(di),o=await e.getPromise(ut);return i?l.size?[...l].map((e=>iu.get(e).sample[a]._id)):o.sample[a]._id:l.size?[...l]:o.sample._id})(e,n.brainKey);t(yu,!0),t(ut,null),Zn.send(Cn("save_filters",{add_stages:[{_cls:"fiftyone.core.stages.SortBySimilarity",kwargs:[["query_ids",s],["k",n.k],["reverse",n.reverse],["brain_key",n.brainKey],["_state",null]]}]}))}),[]),xu=b({key:"kValue",default:null}),wu=b({key:"reverseValue",default:!1}),ku=b({key:"brainKeyValue",default:null}),Eu=b({key:"searchBrainKeyValue",default:""}),Su=Z({key:"availableSimilarityKeys",get:e=>({get:t})=>{const n=t(di),s=t(ao);if(!n&&!e)return s.samples;if(!e)return s.patches.reduce(((e,[n,s])=>(t(Xi).includes(s)&&(e=[...e,n]),e)),[]);if(e){const e=t(eo);if(Object.keys(e).length){const t=new Set(Object.values(e).map((({field:e})=>e)));return s.patches.filter((([e,n])=>t.has(n))).reduce(((e,[t])=>[...e,t]),[])}if(n){const{sample:e}=t(ut);return s.patches.filter((([t,n])=>e[n])).reduce(((e,[t])=>[...e,t]),[])}return s.samples}return[]}}),Lu=Z({key:"currentSimilarityKeys",get:e=>({get:t})=>{const n=t(Eu),s=t(Su(e)),a=s.filter((e=>e.includes(n))).sort();return{total:s.length,choices:a.slice(0,11)}}}),Tu=T({key:"sortBySimilarityParameters",get:({get:e})=>({k:e(xu),brainKey:e(ku),reverse:e(wu)})}),Zu=Z({key:"sortBySimilarityType",get:e=>({get:t})=>{const n=t(ei);return e?"labels":n?"images":"patches"}}),Cu=g.memo((({modal:e,bounds:t,close:n})=>{const[s,a]=H(ku),l=P(Su(e)).length>0,i=P(Lu(e)),o=vu(),[r,c]=H(wu),[d,m]=H(xu),h=P(Zu(e)),p=go();return u.exports.useLayoutEffect((()=>{1===i.choices.length&&a(i.choices[0])}),[i]),g.createElement(nm,{modal:e,bounds:t},g.createElement(nr,null,g.createElement(cm,{href:"https://voxel51.com/docs/fiftyone/user_guide/app.html#sorting-by-visual-similarity",text:"Sort by similarity",title:"About sorting by similarity",style:{background:"unset",color:p.font,paddingTop:0,paddingBottom:0},svgStyles:{height:"1rem",marginTop:7.5}})),l&&g.createElement(g.Fragment,null,g.createElement(id,{placeholder:"k (default = None)",validator:e=>""===e||/^[0-9\b]+$/.test(e),value:null===d?"":String(d),setter:e=>{m(""===e?null:Number(e))}}),g.createElement(sd,{name:"reverse",value:r,setValue:c}),g.createElement(nr,{style:{fontSize:14}},"Brain key"),g.createElement($m,{choices:i.choices,value:s,setValue:a}),s&&g.createElement(g.Fragment,null,g.createElement(nr,null),g.createElement(em,{text:"Apply",title:`Sort by similarity to the selected ${h}`,onClick:()=>{n(),o()},style:{margin:"0.25rem -0.5rem",height:"2rem",borderRadius:0,textAlign:"center"}}))))})),Pu=()=>{const e=go();return g.createElement(ie,{style:{padding:2,height:22,width:22,color:e.font}})},Ru=d.div`
  position: relative;
`,Iu=()=>{const[e,t]=u.exports.useState(!1),n=P(dm),s=P(gi),a=u.exports.useRef();mo(a,(()=>e&&t(!1)));const l=P(mm);return u.exports.useLayoutEffect((()=>{close&&t(!1)}),[close]),g.createElement(Ru,{ref:a},g.createElement(er,{icon:n?g.createElement(Pu,null):g.createElement(Se,null),open:e,onClick:()=>!n&&t(!e),highlight:e||Boolean(l.length),title:s?"Clips":"Patches",style:{cursor:n?"default":"pointer"}}),e&&g.createElement(bm,{close:()=>t(!1)}))},Wu=Z({key:"hasSimilarityKeys",get:e=>({get:t})=>!!e||Boolean(t(Lt).size)}),Mu=({modal:e})=>{const[t,n]=u.exports.useState(!1),s=u.exports.useRef(),a=P(yu);mo(s,(()=>t&&n(!1)));const l=P(Wu(e)),[i,o]=q();return u.exports.useLayoutEffect((()=>{}),[!1]),l?g.createElement(Ru,{ref:s},g.createElement(er,{icon:a?g.createElement(Pu,null):g.createElement(Le,null),open:t,onClick:()=>!a&&n(!t),highlight:!0,ref:i,title:"Sort by similarity",style:{cursor:a?"default":"pointer"}}),t&&g.createElement(Cu,{modal:e,close:()=>n(!1),bounds:o})):null},Xu=({modal:e,lookerRef:t})=>{const[n,s]=u.exports.useState(!1),[a,l]=u.exports.useState(!0),i=P(e?$i:Lt),o=P(qi),r=u.exports.useRef();mo(r,(()=>n&&s(!1)));const[c,d]=q(),m=o;return u.exports.useLayoutEffect((()=>{}),[false]),t&&io(t.current,"play",(()=>{n&&s(!1),l(!1)})),t&&io(t.current,"pause",(()=>l(!0))),g.createElement(Ru,{ref:r},g.createElement(er,{style:{cursor:m||!a?"default":"pointer"},icon:m?g.createElement(Pu,null):g.createElement(ue,null),open:n,onClick:()=>!m&&a&&s(!n),highlight:(Boolean(i.size)||n)&&a,ref:c,title:`Tag sample${e?"":"s"} or labels`}),n&&a&&g.createElement(jm,{modal:e,bounds:d,close:()=>s(!1),lookerRef:t&&t.current instanceof Hl?t:null}))},Nu=({modal:e,lookerRef:t})=>{const[n,s]=u.exports.useState(!1),[a,l]=u.exports.useState(!1),i=P(Lt),o=P(eo),r=u.exports.useRef();mo(r,(()=>n&&s(!1)));const[c,d]=q(),m=e?Object.keys(o).length:i.size;return t&&io(t.current,"buffering",(e=>l(e.detail))),m<1&&!e?null:g.createElement(Ru,{ref:r},g.createElement(er,{icon:a?g.createElement(Pu,null):g.createElement(ce,null),open:n,style:{cursor:a?"default":"pointer"},onClick:()=>{a||s(!n)},highlight:m>0||n,text:`${m}`,ref:c,title:`Manage selected ${e?"label":"sample"}${m>1?"s":""}`}),n&&g.createElement(Lm,{modal:e,close:()=>s(!1),lookerRef:t,bounds:d}))},Gu=({modal:e})=>{const[t,n]=u.exports.useState(!1),s=u.exports.useRef();mo(s,(()=>t&&n(!1)));const[a,l]=q();return g.createElement(Ru,{ref:s},g.createElement(er,{icon:g.createElement(Te,null),open:t,onClick:()=>n(!t),highlight:t,ref:a,title:"Display options"}),t&&g.createElement(rm,{modal:e,bounds:l}))},Yu=()=>{const[e,t]=H(Tt),n=Object.keys(e).length;return n<1?null:g.createElement(er,{icon:g.createElement(Ze,null),open:!0,onClick:()=>t({}),highlight:!0,text:`${n}`,title:"Clear hidden labels"})},Vu=b({key:"savingFilters",default:!1}),Fu=()=>{const e=P(mc(!1)),[t,n]=H(Vu);return e?g.createElement(er,{open:!1,highlight:!0,icon:t?g.createElement(Pu,null):g.createElement(Ce,null),style:{cursor:t?"default":"pointer"},onClick:()=>{t||(n(!0),Zn.send(Cn("save_filters",{})))},title:"Convert current field filters to view stages"}):null},Ku=d.div`
  display: flex;
  justify-content: ltr;
  margin-top: 2.5px;
  row-gap: 0.5rem;
  column-gap: 0.5rem;
`;var Du=g.memo((({modal:e,lookerRef:t})=>{const n=P(gi);P(ci);const s=e?{overflowX:"auto",overflowY:"hidden",margin:"0 -1em",padding:"0 1em",flexWrap:"wrap"}:{flexWrap:"no-wrap"};return g.createElement(Ku,{style:s},g.createElement(Gu,{modal:e}),g.createElement(Xu,{modal:e,lookerRef:e?t:null}),!e&&g.createElement(Iu,null),!n&&g.createElement(Mu,{modal:e}),e&&g.createElement(Yu,null),!e&&g.createElement(Fu,null),g.createElement(Nu,{modal:e,lookerRef:t}))}));const Ou=d.div`
  background: ${({theme:e})=>e.background};
  display: flex;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
  padding: 0 1rem;

  ${mr.Body} {
    width: 264px;
  }
`,zu=d.div`
  display: flex;
  justify-content: space-between;
  overflow: visible;
  margin-left: 1rem;
  margin-right: -1rem;
  margin-bottom: -0.5rem;
  flex-grow: 1;
  height: 37px;
`,Hu=d.div`
  display: flex;
  justify-content: center;
  align-content: center;
  flex-direction: column;
  border-color: ${({theme:e})=>e.backgroundDarkBorder};
  border-right-style: solid;
  border-right-width: 1px;
  margin: 0 0.25rem;
  padding-right: 1rem;
  font-weight: bold;
`,Uu=d.div`
  display: flex;
`,ju=d.div`
  display: flex;
  width: 8rem;
  padding-right: 1rem;
  margin: 0.25rem 0;
`,Au=({showSidebar:e,onShowSidebar:t})=>{const n=P(ki),s=P(ri),a=P(Ei),l=ne(Pi),i=P(lu),o=go();let r=null;return"number"==typeof a&&a!==n&&"number"==typeof n?r=`${a.toLocaleString()} of ${n.toLocaleString()}`:"number"==typeof n&&(r=n.toLocaleString()),g.createElement(Ou,null,g.createElement(mr,{label:"Filters",expanded:e,onClick:t&&(()=>t(!e)),style:{width:256,padding:"0.25rem 0.5rem"}}),g.createElement(zu,null,g.createElement(Du,{modal:!1}),g.createElement(Uu,null,null!==r?g.createElement(Hu,null,r," ",1===n?s.singular:s.plural):g.createElement(Hu,null,g.createElement(ie,{style:{color:o.font,height:16,width:16,minWidth:16}})),g.createElement(ju,null,g.createElement("div",{style:{flexGrow:1},title:"Zoom"},g.createElement(Ed,{valueAtom:Pi,boundsAtom:lu,color:o.brand,showBounds:!1,persistValue:!1,style:{padding:0}})),g.createElement("div",{title:"Reset zoom",onClick:()=>{l(Math.max(i[0],5))},style:{cursor:"pointer"}},g.createElement(Pe,{style:{marginTop:2.5}}))))))},{assign:Bu}=Ie,Ju=e=>"string"!=typeof e?String(e):e,_u=e=>e.includes("|")?["Union[",e.split("|").map((e=>_u(e))).join(", "),"]"].join(""):"list<str>"===e?"List[str]":"list<id>"===e?"List[id]":e,Qu={bool:{castFrom:e=>e?"True":"False",castTo:e=>0===["true","false"].indexOf(e.toLowerCase()),parse:e=>e.toLowerCase().charAt(0).toUpperCase()+e.toLowerCase().slice(1),validate:e=>["true","false"].indexOf(Ju(e).toLowerCase())>=0},float:{castFrom:e=>String(e),castTo:e=>+e,parse:e=>{const t=e.replace(/[\s]/g,""),[n,s]=t.split(".");return n.replace(/\B(?=(\d{3})+(?!\d))/g,",")+(s?"."+s:"")},validate:e=>{const t=Ju(e).replace(/[\s]/g,"");return""!==t&&!isNaN(+t)}},field:{castFrom:e=>e,castTo:e=>e,parse:(e,t)=>t.filter((t=>t.toLowerCase()===e.toLowerCase()))[0],validate:(e,t)=>"string"==typeof e&&t.includes(e.toLowerCase())},dict:{castFrom:e=>JSON.stringify(e,null,2),castTo:e=>"string"==typeof e?JSON.parse(e):e,parse:e=>e,validate:e=>{try{return("string"==typeof e?JSON.parse(e):e)instanceof Object&&!Array.isArray(e)}catch{return!1}}},id:{castFrom:e=>e,castTo:e=>e,parse:e=>e,validate:e=>/[0-9A-Fa-f]{24}/g.test(e)},int:{castFrom:e=>String(e).replace(/\B(?=(\d{3})+(?!\d))/g,","),castTo:e=>+e.replace(/[,\s]/g,""),parse:e=>String(+e.replace(/[,\s]/g,"")).replace(/\B(?=(\d{3})+(?!\d))/g,","),validate:e=>/^\d+$/.test(Ju(e).replace(/[,\s]/g,""))},json:{castFrom:e=>JSON.stringify(e,null,2),castTo:e=>"string"==typeof e?JSON.parse(e):e,parse:e=>e,validate:e=>{try{return JSON.parse(e),!0}catch{return!1}}},"list<field>":{castFrom:e=>e.join(","),castTo:e=>e.split(","),parse:e=>e.replace(/[\s\'\"\[\]]/g,""),validate:(e,t)=>{const n=e.replace(/[\s]/g,"");let s=null;try{s=JSON.parse(n)}catch{s=n.split(",")}return Array.isArray(s)&&s.every((e=>Qu.field.validate(e,t)))}},"list<id>":{castFrom:e=>e.join(","),castTo:e=>e.split(","),parse:e=>e.replace(/[\s\'\"\[\]]/g,""),validate:e=>{const t=e.replace(/[\s]/g,"");let n=null;try{n=JSON.parse(t)}catch{n=t.split(",")}return Array.isArray(n)&&n.every((e=>Qu.id.validate(e)))}},"list<str>":{castFrom:e=>e.join(","),castTo:e=>e.split(","),parse:e=>e.replace(/[\s\'\"\[\]]/g,""),validate:e=>{const t=e.replace(/[\s]/g,"");let n=null;try{n=JSON.parse(t)}catch{n=t.split(",")}return Array.isArray(n)&&n.every((e=>Qu.str.validate(e)))}},NoneType:{castFrom:e=>null===e?"None":e,castTo:()=>null,parse:()=>"None",validate:e=>[null,"None",""].some((t=>e===t))},str:{castFrom:e=>e,castTo:e=>e,parse:e=>e,validate:e=>{if("string"!=typeof e)return!1;try{return JSON.parse(e),!1}catch{return!0}}}};var $u=V({id:"viewStageParameter",initial:"decide",context:{id:void 0,defaultValue:void 0,parameter:void 0,stage:void 0,type:void 0,value:"",submitted:void 0,tail:void 0,focusOnInit:void 0,error:void 0,fieldNames:[]},states:{decide:{always:[{target:"editing",cond:e=>e.focusOnInit},{target:"reading.submitted",cond:e=>e.submitted},{target:"reading.pending"}]},reading:{initial:"pending",entry:"blurInput",states:{pending:{},submitted:{}},on:{EDIT:"editing"}},editing:{entry:[Re("PARAMETER.EDIT"),Bu({bestMatch:({fieldNames:e,value:t,type:n})=>"field"===n?vo(e,t):{},currentResult:null,prevValue:({value:e})=>e,focusOnInit:!1,results:({type:e,fieldNames:t,value:n})=>"field"===e?t.filter((e=>e.toLowerCase().startsWith(n.toLowerCase()))):[]}),"focusInput"],initial:"notHovering",states:{hovering:{on:{MOUSELEAVE:"notHovering"}},notHovering:{on:{MOUSEENTER:"hovering"}}},on:{CHANGE:{actions:[Bu({bestMatch:({fieldNames:e,type:t},{value:n})=>"field"===t?vo(e,n):{},currentResult:null,value:(e,{value:t})=>t,errorId:void 0,results:({type:e,fieldNames:t},{value:n})=>"field"===e?t.filter((e=>e.toLowerCase().startsWith(n.toLowerCase()))):[]})]},COMMIT:[{target:"decide",actions:[Bu({submitted:!0,value:({type:e,value:t,defaultValue:n,fieldNames:s,bestMatch:a},{value:l})=>{const i="field"===e?xo(s,t):null;return t=l||t,""===(t=i||(a.value?a.value:t))&&n?n:e.split("|").reduce(((e,n)=>{if(void 0!==e)return e;const a=Qu[n];return a.validate(t,s)?a.parse(t,s):e}),void 0)},errorId:void 0,bestMatch:{}}),"blurInput",Re((e=>({type:"PARAMETER.COMMIT",parameter:e})))],cond:({type:e,fieldNames:t,value:n,defaultValue:s,bestMatch:a},{value:l})=>{n=l||n;const i="field"===e?xo(t,n):null;return""===(n=i||(a.value?a.value:n))&&s||e.split("|").some((e=>Qu[e].validate(n,t)))}},{actions:[Bu({error:({type:e})=>({name:"value",error:`Expected type "${_u(e)}"`}),errorId:x()})]}],CANCEL:{target:"reading.pending",actions:[Bu({value:({prevValue:e})=>e,errorId:void 0})]},NEXT_RESULT:{actions:Bu({currentResult:({currentResult:e,results:t})=>null===e?0:Math.min(e+1,t.length-1),value:({currentResult:e,results:t})=>null===e?t[0]:t[Math.min(e+1,t.length-1)],bestMatch:{}})},PREVIOUS_RESULT:{actions:Bu({currentResult:({currentResult:e})=>0===e||null===e?null:e-1,value:({currentResult:e,prevValue:t,results:n})=>0===e||null===e?t:n[e-1],bestMatch:{}})}}}},on:{BLUR:[{target:"reading.pending",cond:({submitted:e,prevValue:t})=>!e&&""!==t,actions:[Bu({value:({prevValue:e})=>e})]},{target:"reading.submitted",cond:({submitted:e})=>e}],FOCUS:{actions:"focusInput"},CLEAR_ERROR:{actions:[Bu({error:void 0})]},CLEAR_ERROR_ID:{actions:[Bu({errorId:void 0})]},UPDATE:{actions:Bu({active:(e,{active:t})=>t})}}},{actions:{blurInput:()=>{},focusInput:()=>{}}});const qu=d.div`
  display: flex;
  overflow: visible;
  z-index: 800;
`,eh=m(d.div`
  box-sizing: border-box;
  border: 1px solid ${({theme:e})=>e.brand};
  display: flex;
  overflow: visible;
`),th=m(d(Y)`
  & > input {
    background-color: transparent;
    border: none;
    padding: 0.5rem 0 0.5rem 0.5rem;
    color: ${({theme:e})=>e.font};
    height: 1rem;
    font-weight: bold;
  }

  & > input:focus {
    border: none;
    outline: none;
  }

  & ::placeholder {
    color: ${({theme:e})=>e.font};
  }
`),nh=m(d.div`
  font-weight: bold;
  position: fixed;
  line-height: 1rem;
  font-size: 14px;
  margin-left: -1px;
  overflow: visible;
  display: flex;
  border: 1px solid pink;
  border-style: solid;
  z-index: 800;
  will-change: transform;
  min-width: 2rem;
`),sh=m(d.textarea`
  background-color: transparent;
  overflow: visible;
  line-height: 1rem;
  border: none;
  color: ${({theme:e})=>e.font};
  height: 100%;
  font-size: 14px;
  will-change: tranform;
  resize: none;

  &::-webkit-scrollbar {
    width: 0px;
    background: transparent;
    display: none;
  }
  &::-webkit-scrollbar-thumb {
    width: 0px;
    display: none;
  }

  &:focus {
    border: none;
    outline: none;
  }
`),ah=m(d.button`
  box-sizing: border-box;
  border: 1px solid ${({theme:e})=>e.brand};
  color: ${({theme:e})=>e.font};
  background-color: ${({theme:e})=>e.backgroundLight};
  border-radius: 3px;
  position: relative;
  line-height: 1rem;
  cursor: pointer;
  font-weight: bold;
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;

  :focus {
    outline: none;
  }
`),lh=g.memo((({send:e})=>{const t=M({opacity:1,from:{opacity:0}});return g.createElement(ah,{style:t,onClick:()=>e("COMMIT")},"Submit")})),ih=({placeholder:e,parameter:t})=>void 0!==e?e:t;let oh;const rh=({barRef:e,parameterRef:t,followRef:n,inputRef:s,stageRef:a,onClose:l,hasExpansion:i})=>{const[r,c]=W(t),[d]=W(a),p=u.exports.useContext(h),f=u.exports.useRef(null),{active:b,value:y}=r.context,[v,x]=M((()=>({height:r.matches("editing")?200:36,position:r.matches("editing")?"fixed":"relative",backgroundColor:r.matches("editing")?p.backgroundDark:r.matches("reading.submitted")?p.backgroundLight:p.background,borderColor:b&&d.matches("focusedViewBar.yes")?p.brand:p.fontDarkest,opacity:1,from:{opacity:0}}))),w=M({width:r.matches("editing")?400:0});mo(f,(e=>{e.stopPropagation(),c("BLUR"),l()})),u.exports.useEffect((()=>{x({position:r.matches("editing")?"fixed":"relative",backgroundColor:r.matches("editing")?p.backgroundDark:r.matches("reading.submitted")?p.backgroundLight:p.background,borderColor:b&&d.matches("focusedViewBar.yes")?p.brand:p.fontDarkest,height:r.matches("editing")?200:34,opacity:1})}),[r.matches("editing"),b,d.matches("focusedViewBar.yes")]);const k=()=>{oh&&window.cancelAnimationFrame(oh),oh=window.requestAnimationFrame((()=>{const{x:t,y:s}=r.matches("editing")?n.current.getBoundingClientRect():{x:0,y:0};f.current.style.top=r.matches("editing")?`${s}px`:"unset",f.current.style.left=r.matches("editing")?`${t}px`:"unset";const{x:a,width:l}=e.current.getBoundingClientRect(),i=a+l;f.current.style.width=r.matches("editing")?`${Math.min(i-t,400)}px`:"auto"}))};return io(e.current?e.current:null,"scroll",k),io(window,"scroll",k),co(f?f.current:null,k),g.createElement(g.Fragment,null,r.matches("editing")&&g.createElement(m.div,{style:o({height:"100%"},w)}),g.createElement(nh,{style:v,onClick:()=>r.matches("reading")&&c("EDIT"),ref:f},r.matches("reading")?g.createElement("div",{style:{padding:"0.5em",whiteSpace:"nowrap"}},((e,t)=>Qu.dict.validate(e)?"  . . .  ":""===e?t:e)(y,ih(r.context))):g.createElement(g.Fragment,null,g.createElement(sh,{key:"textarea",autoFocus:r.matches("editing"),style:w,onChange:e=>{c({type:"CHANGE",value:e.target.value.replace(/&#13/g,"\n")})},onKeyDown:e=>{["Escape","Tab"].includes(e.key)&&(c("COMMIT"),l())},value:y,ref:s}),i&&g.createElement(oe,{style:{cursor:"pointer",color:p.font,marginTop:"0.2em",position:"absolute",right:"0.2rem"},onClick:l}),g.createElement(lh,{key:"submit",send:c})),g.createElement(yo,{key:"error",serviceRef:t,style:{marginTop:"12.5rem",marginLeft:0}})))},ch=g.memo((({parameterRef:e,barRef:t,stageRef:n})=>{const s=u.exports.useContext(h),[a,l]=W(e),[i]=W(n),o=u.exports.useRef(),[r,c]=u.exports.useState({}),[d,m]=u.exports.useState(!1),{type:p,value:f,active:b,currentResult:y,results:v,bestMatch:x}=a.context,w=p.split("|").some((e=>["dict","json"].includes(e))),k="dict|str"===p,E=w&&(!k||d);let S=!1;try{const e=JSON.parse(f);S=!Array.isArray(e)&&"object"==typeof e}catch{}u.exports.useEffect((()=>{k&&!d&&S&&m(!0)}),[f]);const L=M({backgroundColor:a.matches("editing")?s.backgroundDark:a.matches("reading.submitted")?s.backgroundLight:s.background,borderStyle:"solid",borderColor:b&&i.matches("focusedViewBar.yes")?s.brand:s.fontDarkest,height:E&&a.matches("editing")?200:34,borderWidth:E?0:1,borderRightWidth:0,opacity:1,from:{opacity:0}}),T=a.matches("editing");return u.exports.useEffect((()=>{T&&o.current&&o.current.focus(),!T&&o.current&&o.current.blur()}),[T,o.current]),g.createElement(g.Fragment,null,g.createElement(qu,{ref:e=>e&&e!==r.current&&c({current:e})},E?g.createElement(rh,{parameterRef:e,barRef:t,followRef:r,inputRef:o,stageRef:n,onClose:()=>{k&&(m(!1),S&&l("BLUR"))},hasExpansion:k}):g.createElement(eh,{style:L},g.createElement(th,{placeholder:ih(a.context),autoFocus:a.matches("editing"),value:S?". . .":a.matches("reading")&&f.length>24?f.slice(0,25)+"...":f,onFocus:()=>!T&&l({type:"EDIT"}),onBlur:()=>a.matches("editing.notHovering")&&l({type:"COMMIT"}),onChange:e=>{l({type:"CHANGE",value:e.target.value})},onKeyPress:e=>{"Enter"===e.key&&T&&l({type:"COMMIT"})},onKeyDown:e=>{switch(e.key){case"Tab":l("COMMIT");case"Escape":l("COMMIT");break;case"ArrowDown":l("NEXT_RESULT");break;case"ArrowUp":l("PREVIOUS_RESULT");break;case"ArrowRight":e.target.selectionStart===e.target.value.length&&x.value&&l({type:"CHANGE",value:x.value})}},ref:o}),g.createElement(mt,null,x?x.placeholder:""),k&&T&&g.createElement(re,{style:{cursor:"pointer",color:s.font,marginTop:"0.2em"},onMouseEnter:()=>l("MOUSEENTER"),onMouseLeave:()=>l("MOUSELEAVE"),onClick:()=>m(!0)}))),a.matches("editing")&&t.current&&r.current&&g.createElement(So,{results:v,send:l,currentResult:y,bestMatch:x.value,followRef:r,barRef:t}),!w&&r.current&&g.createElement(yo,{key:"error",serviceRef:e,barRef:t,followRef:r}))})),dh=m(d.div`
  margin: 0.5rem 0.25rem;
  display: flex;
  position: relative;
`),mh=m(d.div`
  box-sizing: border-box;
  border: 1px solid ${({theme:e})=>e.brand};
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
  border-right-width: 0;
  position: relative;
  display: flex;
`),uh=d(Y)`
  & input {
    background-color: transparent;
    border: none;
    padding: 0.5rem;
    color: ${({theme:e})=>e.font};
    height: 1rem;
    border: none;
    font-weight: bold;
  }

  & input:focus {
    border: none;
    outline: none;
    font-weight: bold;
    padding-right: 0;
  }

  & ::placeholder {
    color: ${({theme:e})=>e.font};
    font-weight: bold;
  }
`,hh=m(d.div`
  box-sizing: border-box;
  border: 1px dashed ${({theme:e})=>e.fontDarkest};
  color: ${({theme:e})=>e.fontDarkest};
  border-radius: 3px;
  position: relative;
  margin: 0.5rem;
  cursor: pointer;
  font-weight: bold;

  padding: 0 0.25rem;

  :focus {
    outline: none;
  }
`),ph=d.div`
  width: 14px;
  height: 32px;
  display: block;
  position: relative;
  overflow: hidden;
`;m(d($)`
  display: block;
  font-size: 14px;
`),m(d(We)`
  position: absolute;
`);const gh=g.memo((({send:e,index:t,active:n})=>{const s=u.exports.useContext(h),[a,l]=u.exports.useState(!1),[i,c]=M((()=>({background:s.background,color:n?s.font:s.fontDarkest,borderColor:n?s.brand:s.fontDarkest,top:n?-3:0,opacity:1,from:{opacity:0},config:X.stiff})));u.exports.useEffect((()=>{c({top:n?-3:0,color:n?s.font:s.fontDarkest,borderColor:n?s.brand:s.fontDarkest}),n?y():v()}),[n]);const[d,p]=M((()=>({marginTop:n?0:31}))),[f,b]=M((()=>({marginTop:n?-31:0}))),y=()=>{c({background:s.background}),p({marginTop:0}),b({marginTop:-31})},v=()=>{c({background:s.backgroundDark}),p({marginTop:31}),b({marginTop:0})};return u.exports.useEffect((()=>{(n||a)&&y(),!n&&!a&&v()}),[n,a]),g.createElement(hh,{style:i,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onClick:()=>e({type:"STAGE.ADD",index:t})},g.createElement(ph,null,g.createElement(m.div,{style:r(o({},f),{textAlign:"center",height:"100%",lineHeight:"2rem"})},">"),g.createElement(m.div,{style:r(o({},d),{textAlign:"center",height:"100%",lineHeight:"2rem"})},"+")))})),fh=m(d.div`
  box-sizing: border-box;
  border: 1px solid ${({theme:e})=>e.brand};
  position: relative;
  border-top-right-radius: 3px;
  border-bottom-right-radius: 3px;
  cursor: pointer;
`),bh=m(d.button`
  background-color: ${({theme:e})=>e.backgroundLight};
  border: none;
  padding: 0.5rem;
  color: ${({theme:e})=>e.font};
  height: 1rem;
  display: block;
  height: 100%;
  border: none;
  cursor: pointer;
  font-weight: bold;
  margin: 0;

  :focus {
    outline: none;
  }
`),yh=g.memo((({send:e,spring:t})=>g.createElement(fh,{style:t,onClick:()=>e("STAGE.DELETE")},g.createElement(bh,null,g.createElement(f,{style:{fontSize:"14px",display:"block"}}))))),vh=g.memo((({barRef:e,stageRef:t})=>{const n=u.exports.useContext(h),[s,a]=W(t),l=u.exports.useRef(),[i,o]=u.exports.useState({}),{stage:r,stageInfo:c,parameters:d,results:m,currentResult:p,focusOnInit:f,active:b,bestMatch:y}=s.context,v=["input.reading.selected","input.reading.submitted"].some(s.matches),x=M({borderColor:b&&s.matches("focusedViewBar.yes")?n.brand:n.fontDarkest,opacity:1,from:{opacity:0}}),w=M({backgroundColor:v?n.backgroundLight:n.background,borderRightWidth:s.matches("delible.yes")&&d.length?0:1,borderColor:b&&s.matches("focusedViewBar.yes")?n.brand:n.fontDarkest,borderTopRightRadius:d.length?0:3,borderBottomRightRadius:d.length?0:3,opacity:1,from:{opacity:0}}),k=M({top:s.matches("focusedViewBar.yes")&&s.context.active?-3:0,config:X.stiff}),E=s.matches("input.editing");return u.exports.useEffect((()=>{E&&l.current&&l.current.focus(),!E&&l.current&&l.current.blur()}),[E,l.current]),g.createElement(g.Fragment,null,g.createElement(dh,{style:k,ref:e=>e&&e!==i.current&&o({current:e})},g.createElement(mh,{style:w},g.createElement(uh,{placeholder:0===r.length?"+ add stage":"",value:r,autoFocus:f,onFocus:()=>!E&&a("EDIT"),onBlur:e=>{s.matches("input.editing.searchResults.notHovering")&&a("BLUR")},onChange:e=>a({type:"CHANGE",value:e.target.value}),onKeyPress:e=>{if("Enter"===e.key){const t=xo(c.map((e=>e.name)),e.target.value);a({type:"COMMIT",value:t||(y.value?y.value:e.target.value)})}},onKeyDown:e=>{switch(e.key){case"Escape":a("BLUR");break;case"ArrowDown":a("NEXT_RESULT");break;case"ArrowUp":a("PREVIOUS_RESULT");break;case"ArrowRight":e.target.selectionStart===e.target.value.length&&y.value&&a({type:"CHANGE",value:y.value})}},style:{fontSize:"1rem"},ref:l}),s.matches("input.editing")?g.createElement(mt,null,y?y.placeholder:""):null,v&&g.createElement("div",{style:{width:"1rem",height:"1rem",margin:"0.4rem 0.5rem 0.5rem 0"}},g.createElement(Zo,{href:`https://voxel51.com/docs/fiftyone/api/fiftyone.core.stages.html#fiftyone.core.stages.${r}`,style:{maxHeight:"1rem",width:"1rem",display:"block"}},g.createElement(ye,{style:{width:"1rem",height:"1rem"}})))),d.filter((e=>!e.parameter.startsWith("_"))).map((n=>g.createElement(ch,{key:n.parameter,parameterRef:n.ref,barRef:e,stageRef:t}))),d.length?g.createElement(yh,{spring:x,send:a}):null,s.matches("input.editing")&&e.current&&i.current&&g.createElement(So,{results:m,send:a,currentResult:p,bestMatch:y.value,followRef:i,barRef:e}),i.current&&g.createElement(yo,{serviceRef:t,followRef:i,barRef:e})))})),{choose:xh}=Ie,wh=(e,t,n,s,a,l,i,o,r,c,d)=>({id:x(),defaultValue:a,parameter:n,type:s,stage:t,value:l||"",submitted:i,focusOnInit:o,inputRef:{},tail:r,currentResult:null,results:[],active:c,placeholder:d,fieldNames:e}),kh=V({id:"viewStage",context:{id:void 0,stage:void 0,parameters:[],prevStage:"",stageInfo:void 0,index:void 0,focusOnInit:void 0,length:void 0,inputRef:{},fieldNames:[]},type:"parallel",states:{input:{initial:"decide",states:{hist:{type:"history"},decide:{always:[{target:"initializing",cond:e=>e.parameters.length&&!e.parameters[0].ref},{target:"waiting",cond:e=>!e.inputRef},{target:"editing",cond:({focusOnInit:e})=>e},{target:"reading"}]},initializing:{entry:F({parameters:e=>e.parameters.map((e=>r(o({},e),{ref:Me($u.withContext(e))})))}),always:"decide"},waiting:{on:{FOCUS:{target:"decide",actions:F({inputRef:(e,{inputRef:t})=>t})}}},reading:{entry:"blurInput",initial:"decide",states:{decide:{always:[{target:"pending",cond:e=>{return t=e.stageInfo,n=e.stage,!t.map((e=>e.name)).some((e=>e.toLowerCase()===n.toLowerCase()));var t,n}},{target:"selected"}]},hist:{type:"history"},pending:{},selected:{},submitted:{}},on:{EDIT:{target:"editing",actions:Re((({index:e})=>({type:"STAGE.EDIT",index:e})))},DELETE:{target:"deleted"}}},editing:{entry:[F({prevStage:e=>e.stage,prevSubmitted:e=>e.submitted,results:({stageInfo:e,stage:t})=>e.map((e=>e.name)).filter((e=>e.toLowerCase().startsWith(t.toLowerCase()))),currentResult:null,focusOnInit:!0,bestMatch:({stageInfo:e,stage:t})=>vo(e.map((e=>e.name)),t)})],type:"parallel",states:{input:{initial:"focused",states:{focused:{entry:"focusInput",on:{UNFOCUS_INPUT:"unfocused"}},unfocused:{on:{FOCUS_INPUT:"focused"}}}},searchResults:{initial:"notHovering",states:{hovering:{on:{MOUSELEAVE:"notHovering"}},notHovering:{on:{MOUSEENTER:"hovering"}}}}},on:{CHANGE:{actions:F({stage:(e,t)=>t.value,results:({stageInfo:e},t)=>e.map((e=>e.name)).filter((e=>e.toLowerCase().startsWith(t.value.toLowerCase()))),currentResult:null,errorId:void 0,bestMatch:({stageInfo:e},{value:t})=>vo(e.map((e=>e.name)),t)})},COMMIT:[{target:"reading.selected",actions:[F({focusOnInit:!1,stage:(e,{value:t})=>e.stageInfo.filter((e=>e.name.toLowerCase().startsWith(t.toLowerCase())))[0].name,parameters:(e,{value:t})=>{const n=e.stageInfo.filter((e=>e.name.toLowerCase().startsWith(t.toLowerCase())))[0].params;return n.map(((s,a)=>wh(e.fieldNames,t,s.name,s.type,s.default,s.name.startsWith("_")?s.default:"",s.name.startsWith("_"),0===a,a===n.length-1,e.active,s.placeholder))).map((e=>r(o({},e),{ref:Me($u.withContext(e))})))},errorId:void 0}),Xe("UPDATE_DELIBLE"),"blurInput"],cond:({stageInfo:e},{value:t})=>xo(e.map((e=>e.name)),t)},{actions:[F({submitted:()=>!1,error:(e,{value:t})=>({name:"stage",error:`${""===t?'""':t} is not a valid stage`}),errorId:x()})]}],BLUR:[{target:"deleted",cond:e=>0===e.parameters.length},{target:"reading.pending",actions:[F({focusOnInit:!1}),"blurInput"]}]}},deleted:{onEntry:[F({stage:"",submitted:!1,parameters:[]}),Re((e=>({type:"STAGE.DELETE",stage:e})))],always:"reading.pending"}}},delible:{initial:"decide",states:{decide:{always:[{target:"yes",cond:e=>e.length>1||e.submitted||""!==e.stage},{target:"no"}]},yes:{},no:{}}},draggable:{initial:"decide",states:{decide:{always:[{target:"yes",cond:e=>1===e.length},{target:"no"}]},yes:{},no:{}}},focusedViewBar:{initial:"decide",states:{decide:{always:[{target:"yes",cond:e=>e.focusOnInit},{target:"no"}]},yes:{},no:{}}}},on:{CLEAR_ERROR:{actions:[F({error:void 0})]},CLEAR_ERROR_ID:{actions:[F({errorId:void 0})]},NEXT_RESULT:{actions:F({currentResult:({currentResult:e,results:t})=>null===e?0:Math.min(e+1,t.length-1),stage:({currentResult:e,results:t})=>null===e?t[0]:t[Math.min(e+1,t.length-1)],bestMatch:{}})},PREVIOUS_RESULT:{actions:F({currentResult:({currentResult:e})=>0===e||null===e?null:e-1,stage:({currentResult:e,prevStage:t,results:n})=>0===e||null===e?t:n[e-1],bestMatch:{}})},BAR_FOCUS:"focusedViewBar.yes",BAR_BLUR:"focusedViewBar.no",UPDATE_DELIBLE:"delible","STAGE.UPDATE":{target:["draggable","delible","input"],actions:[F({index:(e,{index:t})=>t,length:(e,{length:t})=>t,active:(e,{active:t})=>t,fieldNames:(e,{fieldNames:t})=>t}),(e,{active:t})=>{e.parameters.forEach((e=>e.ref.send({type:"UPDATE",active:t})))}]},"STAGE.DELETE":[{target:"input.deleted"}],"PARAMETER.COMMIT":{target:"input",actions:[F({parameters:(e,t)=>e.parameters.map((e=>e.id===t.parameter.id?r(o({},t.parameter),{ref:e.ref}):e))}),xh([{cond:e=>e.parameters.reduce(((e,t)=>t.submitted?e:e+1),0)>0,actions:Xe("EDIT",{to:(e,t)=>{const n=e.parameters.reduce(((e,n,s)=>n.id===t.parameter.id?s:e),void 0);let s=n+1;for(;s<e.parameters.length;){if(!e.parameters[s].submitted)return e.parameters[s].ref;s+=1}for(s=n-1;s>=0;){if(!e.parameters[s].submitted)return e.parameters[s].ref;s-=1}}})},{cond:e=>0===e.parameters.reduce(((e,t)=>t.submitted?e:e+1),0),actions:[F({submitted:!0,focusOnInit:!1,active:!1}),e=>{e.parameters.forEach((e=>e.ref.send({type:"UPDATE",active:!1})))},Re((e=>({type:"STAGE.COMMIT",stage:e})))]}])]},"PARAMETER.EDIT":{actions:[Re((e=>({type:"STAGE.EDIT",index:e.index})))]}}},{actions:{focusInput:()=>{},blurInput:()=>{}}}),{choose:Eh}=Ie,Sh=(e,t,n,s,a,l,i,o,r,c,d)=>({id:t||x(),stage:n,parameters:r,stageInfo:a,index:s,focusOnInit:l,length:i,active:o,inputRef:{},submitted:c,loaded:d,fieldNames:e});function Lh(e,t,n,s=!0,a){return e.split("|").reduce(((e,l)=>{if(void 0!==e)return e;const i=Qu[l];return i.validate(s?n:i.castFrom(n,a),a)?i[t](n,a):e}),void 0)}function Th(e,t,n){return 1===e.length&&""===e[0].stage?[]:e.map((e=>function(e,t,n){return{kwargs:e.parameters.map(((s,a)=>[s.parameter,Lh(t[e.stage][a].type,"castTo",s.value,!0,n)])),_uuid:e.id,_cls:`fiftyone.core.stages.${e.stage}`}}(e,t,n)))}function Zh(e,t){const n=Sh(e,null,"",0,t,!1,1,!0,[],!1);return[r(o({},n),{ref:Me(kh.withContext(n))})]}function Ch(e,t){const n=e.view,s=Object.fromEntries(t.map((e=>[e.name,e.params])));return In(n,Th(e.stages,s,e.fieldNames))?e.stages:0===n.length?Zh(e.fieldNames,t):n.map(((s,a)=>{let l=s._cls.split(".");l=l[l.length-1];const i=Sh(e.fieldNames,s._uuid,l,a,t,!1,e.stages.length,a===Math.min(n.length-1,e.activeStage),s.kwargs.map(((s,i)=>{const o=t.filter((e=>e.name===l))[0];return wh(e.fieldNames,l,s[0],o.params[i].type,o.params[i].default,Lh(o.params[i].type,"castFrom",s[1],!1,e.fieldNames),!0,!1,i===o.params.length-1,a===Math.min(n.length-1,e.activeStage),o.params[i].placeholder)})),!0,!0);return r(o({},i),{ref:Me(kh.withContext(i))})}))}const Ph=V({id:"stages",context:{stages:[],stageInfo:void 0,activeStage:0,view:void 0,setView:void 0,http:void 0,fieldNames:[]},initial:"initializing",states:{decide:{always:[{target:"running.hist",cond:e=>e.stageInfo&&e.view,actions:[F({stages:e=>Ch(e,e.stageInfo)})]},{target:"loading"}]},initializing:{},loading:{invoke:{src:function(e){return fetch(`${e.http}/stages`).then((e=>e.json()))},onDone:{target:"running",actions:F({stageInfo:(e,t)=>t.data.stages,stages:(e,t)=>0===e.view.length?Zh(e.fieldNames,t.data.stages):Ch(e,t.data.stages)})}}},running:{type:"parallel",states:{focus:{initial:"blurred",states:{focused:{entry:[({stages:e})=>e.forEach((e=>e.ref.send({type:"BAR_FOCUS"})))],exit:[({stages:e})=>e.forEach((e=>e.ref.send({type:"BAR_BLUR"})))],on:{TOGGLE_FOCUS:{target:"blurred"},NEXT:{actions:[F({activeStage:({stages:e,activeStage:t})=>{const n=t;return n===e.length-.5?n:n%1!=0?Math.ceil(n):e[n].submitted&&(n===e.length-1||e[n+1].submitted)?n+.5:Math.min(e.length-1,n+1)}}),"sendStagesUpdate"]},PREVIOUS:{actions:[F({activeStage:({stages:e,activeStage:t})=>{const n=t;return-.5===n?n:n%1!=0?Math.floor(n):e[n].submitted&&(0===n||e[n-1].submitted)?n-.5:Math.max(0,n-1)}}),"sendStagesUpdate"]},NEXT_STAGE:{actions:[F({activeStage:({stages:e,activeStage:t})=>Math.min(Math.floor(t+1),e.length-1)}),"sendStagesUpdate"]},PREVIOUS_STAGE:{actions:[F({activeStage:({stages:e,activeStage:t})=>Math.max(Math.ceil(t-1),0)}),"sendStagesUpdate"]},NEXT_RESULT:{actions:Xe((({stages:e,activeStage:t})=>({type:"NEXT_RESULT",to:e[t].ref})))},PREVIOUS_RESULT:{actions:Xe((({stages:e,activeStage:t})=>({type:"PREVIOUS_RESULT",to:e[t].ref})))},DELETE_ACTIVE_STAGE:{actions:Xe((({activeStage:e,stages:t})=>({type:"STAGE.DELETE",stage:t[e]})))},ENTER:{actions:[Eh([{actions:Xe((({activeStage:e})=>({type:"STAGE.ADD",index:Math.ceil(e)}))),cond:({activeStage:e})=>.5===Math.abs(e%1)},{actions:Xe((({stages:e,activeStage:t})=>{e[t].ref.send({type:"EDIT"})}))}])]}}},blurred:{on:{TOGGLE_FOCUS:{target:"focused"}}}}},hovering:{initial:"no",states:{yes:{on:{MOUSELEAVE:"no"}},no:{on:{MOUSEENTER:"yes"}}}},hist:{type:"history",history:"deep"}}}},on:{"STAGE.EDIT":{actions:[F({activeStage:(e,t)=>t.index}),"sendStagesUpdate"]},"STAGE.ADD":{actions:[F({activeStage:(e,{index:t})=>t,stages:(e,{index:t})=>{const n=Sh(e.fieldNames,null,"",t,e.stageInfo,!0,e.stages.length+1,!0,[],!1);return n.added=!0,[...e.stages.slice(0,t),r(o({},n),{ref:Me(kh.withContext(n))}),...e.stages.slice(t)].map(((t,n)=>r(o({},t),{index:n,active:n==n,length:e.stages.length+1})))}}),"sendStagesUpdate"]},"STAGE.COMMIT":{actions:[F({stages:({stages:e},t)=>(e[t.stage.index]=r(o({},t.stage),{ref:e[t.stage.index].ref}),e),activeStage:({activeStage:e})=>e+.5}),"submit"]},CLEAR:{actions:[F({stages:e=>{const t=Sh(e.fieldNames,null,"",0,e.stageInfo,!1,0,!0,[],!1);return[r(o({},t),{ref:Me(kh.withContext(t))})]}}),"submit"]},"STAGE.DELETE":{actions:[F({activeStage:({activeStage:e})=>Math.max(e-1,0),stages:({fieldNames:e,stages:t,stageInfo:n},s)=>{if(1===t.length&&t[0].id===s.stage.id){const t=Sh(e,null,"",0,n,!1,0,!0,[],!1);return[r(o({},t),{ref:Me(kh.withContext(t))})]}return t.filter((e=>e.id!==s.stage.id||1===t.length)).map(((e,n)=>{const a=e.id===s.stage.id?s.stage:e;return a.index=n,a.length=Math.max(t.length-1,1),a}))}}),"submit"]},UPDATE:{target:"decide",actions:[F({http:(e,{http:t})=>t,view:(e,{view:t})=>t,setView:(e,{setView:t})=>t,fieldNames:(e,{fieldNames:t})=>t}),"sendStagesUpdate"]}}},{actions:{sendStagesUpdate:e=>{e.stages.forEach((t=>t.ref.send({type:"STAGE.UPDATE",index:t.index,length:e.stages.length,active:t.index===e.activeStage,stage:t.stage,fieldNames:e.fieldNames})))},submit:({stages:e,stageInfo:t,fieldNames:n,setView:s,view:a})=>{const l=Th(e,Object.fromEntries(t.map((e=>[e.name,e.params]))),n);In(l,a)||s(l)}}}),Rh=d.div`
  display: block;
  position: relative;
  width: 100%;
  background-color: ${({theme:e})=>e.background};
  padding: 1rem 0;
`,Ih=d.div`
  background-color: ${({theme:e})=>e.backgroundDark};
  border-radius: 3px;
  border: 1px solid ${({theme:e})=>e.backgroundDarkBorder};
  box-sizing: border-box;
  height: 52px;
  width: 100%;
  padding: 0 0.25rem;
  display: flex;
  overflow-x: scroll;
  scrollbar-width: none;

  &::-webkit-scrollbar {
    width: 0px;
    background: transparent;
    display: none;
  }
  &::-webkit-scrollbar-thumb {
    width: 0px;
    display: none;
  }
`,Wh=d.div`
  position: absolute;
  z-index: 904;
  top: 1rem;
  padding: 14px 0.5rem;
  height: 52px;
  border-radius: 3px;
  right: 0;
  background-image: linear-gradient(
    to right,
    rgba(0, 0, 0, 0),
    5%,
    ${({theme:e})=>e.backgroundDark}
  );

  & > * {
    height: 100%;
  }

  & > * > {
    display: flex;
    justify-content: center;
    align-content: center;
    flex-direction: column;
  }
`,Mh={VIEW_BAR_NEXT:"right",VIEW_BAR_PREVIOUS:"left",VIEW_BAR_NEXT_STAGE:"shift+right",VIEW_BAR_PREVIOUS_STAGE:"shift+left",VIEW_BAR_DELETE:["del","backspace"],VIEW_BAR_ENTER:"enter"},Xh=g.memo((()=>{const[e,t]=O(Ph),[n,s]=H(fi),a=P(Ii);u.exports.useEffect((()=>{t({type:"UPDATE",http:Sn,view:n,setView:s,fieldNames:a})}),[Sn,n]);const{stages:l,activeStage:i}=e.context,o=u.exports.useRef(null),r={VIEW_BAR_NEXT:u.exports.useCallback((()=>t("NEXT")),[]),VIEW_BAR_PREVIOUS:u.exports.useCallback((()=>t("PREVIOUS")),[]),VIEW_BAR_NEXT_STAGE:u.exports.useCallback((()=>t("NEXT_STAGE")),[]),VIEW_BAR_PREVIOUS_STAGE:u.exports.useCallback((()=>t("PREVIOUS_STAGE")),[]),VIEW_BAR_DELETE:u.exports.useCallback((()=>t("DELETE_ACTIVE_STAGE")),[]),VIEW_BAR_ENTER:u.exports.useCallback((e=>{e.preventDefault(),t("ENTER")}),[])};return mo(o,(()=>e.matches("running.focus.focused")&&t("TOGGLE_FOCUS"))),g.createElement("div",{style:{padding:"0 1rem"}},g.createElement(Rh,null,g.createElement(Ne.exports.GlobalHotKeys,{handlers:r,keyMap:Mh}),g.createElement(Ih,{onClick:()=>e.matches("running.focus.blurred")&&t("TOGGLE_FOCUS"),ref:o},e.matches("running")?l.map(((n,s)=>g.createElement(g.Fragment,{key:n.id},n.submitted&&(0===s||l[s-1].submitted)?g.createElement(gh,{key:`insert-button-${n.id}`,send:t,index:s,active:i===s-.5&&e.matches("running.focus.focused")}):null,g.createElement(vh,{key:n.id,stageRef:n.ref,barRef:o})))):null,e.matches("running")&&l[l.length-1].submitted?g.createElement(gh,{key:"insert-button-tail",send:t,index:l.length,active:i===l.length-.5&&e.matches("running.focus.focused")}):null,g.createElement("div",{style:{display:"block",minWidth:64,maxWidth:64,height:"100%"}})),g.createElement(Wh,null,g.createElement(f,{onClick:()=>t("CLEAR"),style:{cursor:"pointer"}}),g.createElement(Zo,{href:"https://voxel51.com/docs/fiftyone/user_guide/app.html#using-the-view-bar"},g.createElement(ye,null)))))})),Nh=d.div`
  display: block;
  height: 100%;
  width 286px;
  padding-left: 1rem;
  overflow: visible;
`,Gh=d.div`
  max-height: 100%;
  height: 100%;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-color: ${({theme:e})=>e.fontDarkest}
    ${({theme:e})=>e.background};

  ${_o}
`,Yh=d.div`
  flex-grow: 1;
  width: 1px;
`,Vh=d.div`
  display: flex;
  justify-content: space-between;
  flex-grow: 1;
  overflow: hidden;
`,Fh=g.memo((()=>{const[e,t]=H(Zt);return g.createElement(g.Fragment,null,g.createElement(Xh,{key:"bar"}),g.createElement(Au,{showSidebar:e,onShowSidebar:t,key:"header"}),g.createElement(Vh,null,e?g.createElement(Nh,null,g.createElement(Gh,null,g.createElement(tm,{modal:!1}))):null,g.createElement(Yh,{style:{paddingLeft:e?0:"1rem"}},g.createElement(bu,null))))})),Kh=m(d.img`
  width: 4rem;
  height: 4rem;
  margin: auto;
  display: block;
  transform-origin: 50% 50%;
  border-color: ${({theme:e})=>e.backgroundDarkBorder};
`),Dh=d.div`
  display: flex;
  padding: 2rem;
  width: 100%;
  height: 100%;
`,Oh=d.div`
  padding-top: 1rem;
  font-weight: bold;
  text-align: center;

  & a {
    color: ${({theme:e})=>e.brand};
    text-decoration: underline;
    cursor: pointer;
  }
`,zh=g.memo((({text:e=null,onClick:t=null})=>{const[n,s]=u.exports.useState(!1),a=M({from:{transform:"rotate(0deg)"},transform:"rotate(360deg)",onRest:()=>s((e=>!e)),reset:n,config:{duration:3e3}}),l=t?{onClick:t}:{};return g.createElement(Dh,null,g.createElement("div",o({style:{margin:"auto",width:"100%",cursor:t?"pointer":"default"}},l),g.createElement(Kh,{style:a,src:Po}),e&&g.createElement(Oh,null,e)))})),Hh=d.div`
  ${_o}
  overflow-y: hidden;
  overflow-x: scroll;
  width: 100%;
  height: 100%;
  padding-left: 1rem;
`,Uh=({title:e,count:t})=>g.createElement(Qo,null,g.createElement($o,null,e),"Count: ",t),jh=(e,t)=>class extends u.exports.PureComponent{render(){const{x:n,y:s,payload:a,fill:l}=this.props,i=a.value;return g.createElement("g",{transform:`translate(${n},${s})`},g.createElement("text",{x:0,y:0,dy:16,textAnchor:"end",fill:l,transform:"rotate(-80)"},e?gn(i,t):(o=i,Number(o)===o&&o%1!=0?i.toFixed(3):i.length>24?i.slice(0,21)+"...":i)));var o}},Ah=d.div`
  font-weight: bold;
  font-size: 1rem;
  line-height: 2rem;
`,Bh=({distribution:e})=>{const{name:t,data:n,ticks:s,type:a}=e,[l,{height:i}]=q(),d=u.exports.useRef(null),m="hsl(210, 20%, 90%)",h=m,p=P(Zr(t)),f=P(Cr(t)),b=P(Ri),y=0===s?{interval:s}:{ticks:s},v=n.map((e=>{var t=e,{key:n}=t,s=c(t,["key"]);return r(o({},s),{key:p||f?n:un(n,!1)})})),x=n.length>=200,w=v.reduce(((e,t)=>r(o({},e),{[t.key]:t.edges})),{}),k=jh(p||f,f?"UTC":b);return g.createElement(Hh,{ref:l},g.createElement(Ah,null,`${t}${x?` (first ${n.length})`:""}`),g.createElement(Ge,{ref:d,height:i-37,width:28*n.length+50,barCategoryGap:"4px",data:v,margin:{top:0,left:0,bottom:5,right:5}},g.createElement(Ye,o({dataKey:"key",height:.2*i,axisLine:!1,tick:g.createElement(k,o({},{fill:h})),tickLine:{stroke:m}},y)),g.createElement(Ve,{dataKey:"count",axisLine:!1,tick:{fill:h},tickLine:{stroke:m}}),g.createElement(Fe,{cursor:!1,content:e=>{var t,n,s,l;const i=null==(n=null==(t=null==e?void 0:e.payload[0])?void 0:t.payload)?void 0:n.key,o=null==(l=null==(s=null==e?void 0:e.payload[0])?void 0:s.payload)?void 0:l.count;if("number"!=typeof o)return null;let r=`Value: ${i}`;if(w[i])if(p||f){const[{$date:e},{$date:t}]=w[i],[n,s]=fn(f?"UTC":b,e,t);let a=s.formatRange(e,t).replaceAll("/","-");3===s.resolvedOptions().fractionalSecondDigits&&(a=a.replaceAll(",",".")),r=`Range: ${n?n.format(e).replaceAll("/","-"):""} ${a.replaceAll("/","-")}`}else r=`Range: [${w[i].map((e=>"IntField"===a?e:e.toFixed(3))).join(", ")})`;return g.createElement(Uh,{title:r,count:o})},contentStyle:{background:"hsl(210, 20%, 23%)",borderColor:"rgb(255, 109, 4)"}}),g.createElement(Ke,{dataKey:"count",fill:"rgb(255, 109, 4)",barCategoryGap:0,barSize:24})))},Jh=d.div`
  overflow-y: scroll;
  overflow-x: hidden;
  width: 100%;
  height: calc(100% - 3rem);
  ${_o}
`,_h=({group:e})=>{const t=P(fi),n=P(wi),s=P($l),[a,l]=u.exports.useState(!0),i=P(Jl),[o,r]=u.exports.useState([]);return ro("distributions",{group:e.toLowerCase()},null,[JSON.stringify(t),JSON.stringify(n),s,i]),oo("distributions",(({results:e})=>{l(!1),r(e)})),u.exports.useEffect((()=>{r([]),l(!0)}),[JSON.stringify(t),JSON.stringify(n),s,i,e]),a?g.createElement(zh,null):0===o.length?g.createElement(zh,{text:`No ${e.toLowerCase()}`}):g.createElement(Jh,null,o.map(((e,t)=>g.createElement(Bh,{key:t,distribution:e}))))},Qh=d(De)`
  position: absolute;
  bottom: -0.8rem;
  height: 1rem;
  width: 1rem;
  left: 50%;
  margin-left: -0.5rem;
  z-index: 1000;
  pointer-events: none;
`,$h=d(Oe)`
  padding: 1rem 0 0;
  background-color: ${({theme:e})=>e.backgroundDark};
  border-bottom: 1px ${({theme:e})=>e.backgroundDarkBorder} solid;
`,qh=d.div`
  padding: 0 1rem;
  width: 100%;
  display: flex;
  justify-content: space-between;
`,ep=d.div`
  display: flex;
  justify-content: space-between;
`,tp=d.div`
  padding-bottom: 1rem;
`,np=d.div`
  height: 1.5rem;
  line-height: 1.5rem;
  margin: 0.25rem 0.25rem 0.25rem 0;
  cursor: pointer;
  display: inline-block;
  margin-right: 5px;
  padding: 0 1em;
  color: ${({theme:e})=>e.font};
  background-color: ${({theme:e})=>e.backgroundLight};
  text-decoration: none;
  border-radius: 2px;
  font-weight: bold;

  &.active {
    background-color: ${({theme:e})=>e.secondary};
  }
`,sp=d.div`
  cursor: pointer;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0.25rem;
`,ap=g.memo((({maximized:e,setMaximized:t})=>g.createElement(sp,{onClick:()=>t(!e)},e?g.createElement(ze,null):g.createElement(He,null)))),lp=({entries:e})=>{const{height:t}=ho(),[n,s]=H(vt),[a,l]=u.exports.useState(!1),[i,o]=u.exports.useState(392),[r,c]=u.exports.useState(!1),d=a?i:64,m=P(ri);return g.createElement($h,{size:{height:r?t-73:d},minHeight:64,enable:{top:!1,right:!1,bottom:a&&!r,left:!1,topRight:!1,bottomRight:!1,bottomLeft:!1,topLeft:!1},onResizeStop:(e,t,n,s)=>{o(d+s.height)}},g.createElement(qh,null,g.createElement(tp,null,e.map((e=>g.createElement(np,{key:e,className:e===n&&a?"active":"",onClick:()=>{a&&n===e?l(!1):(l(!0),s(e))}},"Sample tags"===e?`${Ue(m.singular)} tags`:e)))),g.createElement(ep,null,a&&g.createElement(ap,{maximized:r,setMaximized:()=>{c(!r),l(!0)}}),g.createElement(er,{onClick:()=>{l(!a),a&&c(!1)},text:a?"Hide":"Show",open:a,icon:g.createElement(je,null),highlight:!a,arrow:!0}))),a&&g.createElement(_h,{key:n,group:n}),a&&!r&&g.createElement(Qh,null))},ip=d.div`
  margin: 0;
`,op=d.div`
  border-top: 2px solid ${({theme:e})=>e.font};
  width: 100%;
  padding: 0.5rem 0 0;
`,rp=d.div`
  padding: 0.1rem 0 0 0;
  margin: 0;
`,cp=m(d(Qo)`
  position: absolute;
  margin-top: 0;
  left: -1000;
  top: -1000;
  z-index: 20000;
  pointer-events: none;
`),dp=d.div`
  margin: 0;
  padding: 0;
  max-width: 10rem;
  word-wrap: break-word;
`,mp=d.div`
  font-size: 0.8rem;
  font-weight: bold;
  color: ${({theme:e})=>e.font};
`,up=d.div`
  font-size: 0.7rem;
  font-weight: bold;
  padding-bottom: 0.3rem;
  color: ${({theme:e})=>e.fontDark};
`,hp=({name:e,value:t,style:n})=>"object"==typeof t?null:g.createElement(dp,{style:n},g.createElement(mp,null,(()=>{switch(typeof t){case"number":return Number.isInteger(t)?t:t.toFixed(3);case"string":return t.length?t:'""';case"boolean":return t?"True":"False";default:return"None"}})()),g.createElement(up,null,e)),pp=({label:e,children:t=null})=>{let n=Object.entries(e).filter((([e,t])=>"tags"!==e&&!e.startsWith("_")));if(!n||!n.length)return null;const s=n.filter((([e])=>["label","confidence"].includes(e))),a=n.filter((([e])=>!["label","confidence"].includes(e))),l=([e,t])=>g.createElement(hp,{key:e,name:e,value:t}),i="object"==typeof e.attributes?Object.entries(e.attributes).map((([e,t])=>["attributes."+e,t.value])):null;return g.createElement(g.Fragment,null,s.map(l),t,a.map(l),i&&i.map(l))},gp=({color:e,id:t})=>{const n=P($i);return g.createElement(op,{style:{borderTop:`2px ${n.has(t)?"dashed":"solid"} ${e}`}})},fp={Classification:({detail:e})=>g.createElement(rp,{style:{borderColor:e.color}},g.createElement(pp,{label:e.label})),Detection:({detail:e})=>g.createElement(rp,{style:{borderColor:e.color}},g.createElement(pp,{label:e.label})),Heatmap:({detail:e})=>g.createElement(rp,{style:{borderColor:e.color}},g.createElement(hp,{key:"pixel-value",name:"pixel",value:e.target}),g.createElement(pp,{label:e.label})),Keypoint:({detail:e})=>g.createElement(rp,{style:{borderColor:e.color}},g.createElement(pp,{label:e.label})),Polyline:({detail:e})=>g.createElement(rp,{style:{borderColor:e.color}},g.createElement(pp,{label:e.label})),Regression:({detail:e})=>g.createElement(rp,{style:{borderColor:e.color}},g.createElement(pp,{label:e.label})),Segmentation:({detail:e})=>{const t=(n=e.field,s=e.target,P(Qi)(n,s));var n,s;return g.createElement(rp,{style:{borderColor:e.color}},t?g.createElement(hp,{key:"target-value",name:"label",value:t}):g.createElement(hp,{key:"pixel-value",name:"pixel",value:e.target}),g.createElement(pp,{label:e.label}))}},bp=({tags:e})=>e?g.createElement(ip,null,g.createElement(hp,{key:"tags",name:"tags",value:e.length?e.join(", "):"No tags",style:{maxWidth:"20rem"}})):null,yp=g.memo((({looker:e})=>{var t;const[n,s]=u.exports.useState(null),[a,l]=u.exports.useState({top:-1e3,left:-1e3,bottom:"unset"}),i=M(r(o({},n?a:{top:-1e3,left:-1e3,bottom:"unset"}),{config:{duration:0}})),c=u.exports.useRef(null);io(e,"tooltip",(e=>{s(e.detail?e.detail:null),e.detail&&l((([e,t])=>{let n=t,s="unset";return t>window.innerHeight/2&&(s=window.innerHeight-t,n="unset"),{bottom:s,top:n,left:e<=window.innerWidth/2?e+24:"unset",right:e>window.innerWidth/2?window.innerWidth-e+24:"unset"}})(e.detail.coordinates))}));const d=M({display:n?"block":"none",opacity:n?1:0}),m=n?fp[n.type]:null;return m?Ae.createPortal(g.createElement(cp,{style:r(o(o({},i),d),{position:"fixed"}),ref:c},g.createElement($o,{key:"header"},n.field),g.createElement(gp,{color:n.color,id:n.label.id}),n.label.tags&&n.label.tags.length>0&&g.createElement(bp,{key:"tags",tags:null==(t=n.label)?void 0:t.tags}),g.createElement(m,{key:"attrs",detail:n})),document.body):null})),vp=e=>Object.fromEntries(Object.entries(e).map((([e,t])=>[t,e]))),xp=T({key:"lookerOptions",get:({get:e})=>{const t=e(ji).show_confidence,n=e(ji).show_index,s=e(ji).show_label,a=e(ji).show_tooltip,l=e(ji).use_frame_number,i=e(gi)?{loop:e(ji).loop_videos}:{},c=!!e(di)&&e(pt(!0));return r(o(r(o({showConfidence:t,showIndex:n,showLabel:s,useFrameNumber:l,showTooltip:a},i),{zoom:c,filter:e(_r(!0))}),e(Xt)),{selectedLabels:[...e($i)],fullscreen:e(gt),fieldsMap:vp(e(Ui("sample"))),frameFieldsMap:vp(e(Ui("frame"))),timeZone:e(Ri),coloring:e(Bi(!0)),alpha:e(Rt(!0))})}});var wp=g.memo((({lookerRef:e,onClose:t,onNext:n,onPrevious:s,onSelectLabel:a,style:l})=>{const[i]=u.exports.useState((()=>x())),{sample:c,dimensions:d,frameRate:m,frameNumber:h}=P(ut),p=P(gt),f=P(ci),b=pn(c),y=P(Li("sample")),v=nu(c.filepath,c._id),w=P(xp),k=P(tc),E=go(),S=P(su),L=u.exports.useRef(!0),[T]=u.exports.useState((()=>{const e=S(b),t=f?{support:c.support}:{};return new e(c,o({src:v,dimensions:d,frameRate:m,frameNumber:h,sampleId:c._id,thumbnail:!1,fieldSchema:Object.fromEntries(y.map((e=>[e.name,e])))},t),r(o({activePaths:k},w),{hasNext:Boolean(n),hasPrevious:Boolean(s)}))}));return u.exports.useEffect((()=>{!L.current&&T.updateOptions(r(o({},w),{activePaths:k}))}),[w,k]),u.exports.useEffect((()=>{!L.current&&T.updateSample(c)}),[c]),u.exports.useEffect((()=>()=>T&&T.destroy()),[T]),e&&(e.current=T),io(T,"options",te((({snapshot:e,set:t})=>async n=>{const s=await e.getPromise(Xt);t(Xt,o(o({},s),n.detail))}))),io(T,"fullscreen",te((({set:e})=>async t=>{e(gt,t.detail)}))),n&&io(T,"next",n),s&&io(T,"previous",s),t&&io(T,"close",t),a&&io(T,"select",a),u.exports.useEffect((()=>{L.current=!1}),[]),u.exports.useEffect((()=>{T.attach(p?"root":i)}),[i,p]),io(T,"clear",te((({set:e})=>async()=>e(eo,{})),[])),g.createElement("div",{id:i,style:o({width:"100%",height:"100%",background:E.backgroundDark},l)},g.createElement(yp,{looker:T}))}));const kp=d.div`
  position: relative;
  display: grid;
  grid-template-columns: auto 296px;
  width: 90vw;
  height: 80vh;
  max-height: 80vh;
  background-color: ${({theme:e})=>e.backgroundDark};

  h2 {
    margin: 0.5rem -1rem;
    padding: 0 1rem;
    border-bottom: 2px solid ${({theme:e})=>e.backgroundLight};
    clear: both;
  }

  h2,
  h2 span {
    display: flex;
    align-items: center;
  }

  h2 .push-right {
    margin-left: auto;
  }

  h2 svg {
    cursor: pointer;
    margin-left: 5px;
  }

  h2 .close-wrapper {
    position: absolute;
    top: 1em;
    right: 1em;
    background-color: ${({theme:e})=>e.backgroundTransparent};
  }

  .nav-button {
    position: absolute;
    z-index: 1000;
    top: 50%;
    width: 2em;
    height: 5em;
    margin-top: -2.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: ${({theme:e})=>e.overlayButton};
    cursor: pointer;
    font-size: 150%;
    font-weight: bold;
    user-select: none;

    &.left {
      left: 0;
    }
    &.right {
      right: 0;
    }
    &:hover {
      background-color: ${({theme:e})=>e.overlayButtonHover};
    }
  }

  .sidebar {
    position: relative;
    height: 100%;
    max-height: 100%;
    overflow-y: scroll;
    height: 100%;
    background: ${({theme:e})=>e.background};
    border-left: 2px solid ${({theme:e})=>e.border};
    scrollbar-width: none;

    .sidebar-content {
      padding-left: 1rem;
      padding-right: 1rem;
      flex-grow: 1;
    }
  }

  .sidebar::-webkit-scrollbar {
    width: 0px;
    background: transparent;
    display: none;
  }
  .sidebar::-webkit-scrollbar-thumb {
    width: 0px;
    display: none;
  }

  .row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    flex-wrap: wrap;

    > label {
      font-weight: bold;
      display: block;
      padding-right: 0.5rem;
      width: auto;
    }
    > div {
      display: block;
      max-width: 100%;
    }
    span {
      flex-grow: 2;
      overflow-wrap: break-word;
      vertical-align: middle;
    }
  }

  .select-objects-wrapper {
    margin-top: -1em;
  }

  .looker-element {
    width: 100%;
    height: 100%;
    position: relative;
    max-height: 100%;
    max-width: 100%;
    overflow: hidden;
    background: ${({theme:e})=>e.backgroundDark};
  }
`,Ep=e=>{var t=e,{name:n,value:s,children:a}=t,l=c(t,["name","value","children"]);return g.createElement("div",o({className:"row"},l),g.createElement("label",null,n," "),g.createElement("div",null,g.createElement("span",{title:s},s)),a)};var Sp=g.forwardRef((({onClose:e},t)=>{const{sample:{filepath:n,_id:s,_media_type:a,metadata:l},index:i,getIndex:r}=P(ut),c=nu(n,s),d=u.exports.useRef(),m=te((({snapshot:e,set:t})=>async({detail:{id:n,field:s,frameNumber:a}})=>{const{sample:l}=await e.getPromise(ut);let i=o({},await e.getPromise(eo));i[n]?delete i[n]:i[n]={field:s,sample_id:l._id,frame_number:a},t(eo,i)}),[]);P(Ei),P(ki),(e=>{const t=te((({set:t,snapshot:n})=>async({samples:s})=>{const a=await n.getPromise(ut);s.forEach((t=>{a.sample._id===t._id&&e.current&&e.current.updateSample(t)})),t(ut,o({},await n.getPromise(ut))),t(qi,!1)}),[]);oo("samples_update",t)})(d);const h=go();return g.createElement(kp,{style:{zIndex:10001},ref:t},g.createElement("div",{className:"looker-element"},g.createElement(wp,{key:`modal-${c}`,lookerRef:d,onSelectLabel:m,onClose:e,onPrevious:i>0?()=>r(i-1):null,onNext:()=>r(i+1)})),g.createElement("div",{className:"sidebar"},g.createElement(Jo,{style:{width:"100%",borderTop:"none",borderBottom:`2px solid ${h.border}`,position:"relative"}},g.createElement(Du,{modal:!0,lookerRef:d})),g.createElement("div",{className:"sidebar-content"},g.createElement("h2",null,"Metadata",g.createElement("span",{className:"push-right"})),g.createElement(Ep,{name:"id",value:s}),g.createElement(Ep,{name:"filepath",value:n}),g.createElement(Ep,{name:"media type",value:a}),(e=>e?cn.map((t=>({name:t.name,value:t.value?t.value(e):e[t.key]}))).filter((({value:e})=>void 0!==e)):[])(l).map((({name:e,value:t})=>g.createElement(Ep,{key:"metadata-"+e,name:e,value:t}))),g.createElement(u.exports.Suspense,{fallback:g.createElement("h2",null,"Fields",g.createElement("span",{className:"push-right"}))},g.createElement("h2",null,"Fields",g.createElement("span",{className:"push-right"})),g.createElement(tm,{modal:!0,style:{overflowY:"auto",overflowX:"hidden",height:"auto"}})))))}));const Lp=["Sample tags","Label tags","Labels","Other fields"],Tp=d.div`
  height: calc(100% - 74px);
  display: flex;
  flex-direction: column;
`,Zp=d.div`
  width: 100%;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
`;var Cp=g.memo((function(){const e=u.exports.useRef(),t=P(Bl),n=go(),s=P(gt)?{background:n.backgroundDark}:{},a=P(hi);po(),(()=>{const e=P(gi),t=u.exports.useCallback((()=>{document.body.querySelectorAll("svg").forEach((e=>{e.setAttribute("width",e.getBoundingClientRect().width),e.setAttribute("height",e.getBoundingClientRect().height)}))}),[]),n=u.exports.useCallback((()=>{const e=document.body.querySelectorAll("img"),t=[];return e.forEach((e=>{!e.classList.contains("fo-captured")&&t.push(fetch(e.src).then((e=>e.blob())).then((e=>new Promise(((t,n)=>{const s=new FileReader;s.onloadend=()=>{t(s.result)},s.onerror=e=>n(e),s.readAsDataURL(e)})))).then((t=>new Promise(((n,s)=>{e.onload=n,e.onerror=s,e.src=t})))))})),Promise.all(t)}),[]),s=u.exports.useCallback((()=>{const e=[];return document.querySelectorAll("link").forEach((t=>{"stylesheet"===t.rel&&e.push(fetch(t.href).then((e=>e.text())).then((e=>{const t=document.createElement("style");t.appendChild(document.createTextNode(e)),document.head.appendChild(t)})))})),Promise.all(e)}),[]),a=u.exports.useCallback((()=>{const e=document.body.querySelectorAll("video"),t=[];return e.forEach((e=>{const n=document.createElement("canvas"),s=e.getBoundingClientRect();n.width=s.width,n.height=s.height,n.getContext("2d").drawImage(e,0,0,n.width,n.height);const a=n.toDataURL("image/png"),l=new Image(s.width,s.height);l.className="p51-contained-image fo-captured",e.parentNode.replaceChild(l,e),t.push(new Promise(((e,t)=>{l.onload=e,l.onerror=t,l.src=a})))})),Promise.all(t)}),[]),l=u.exports.useCallback((()=>{I(document.body).then((e=>{const t=e.toDataURL("image/png");yn&&window.parent.postMessage({src:t,handleId:vn,width:e.width},"*"),Zn.send(Cn("capture",{src:t,width:e.width}))}))}),[]);oo("deactivate",(()=>{t();let i=Promise.resolve(null);e&&(i=i.then(a)),yn?i.then(n).then(s).then(l):i.then(l)}))})(),(()=>{const e=P($l),t=z(ec);u.exports.useEffect((()=>{t()}),[e])})();const l=au();return mo(e,l),u.exports.useEffect((()=>{document.body.classList.toggle("noscroll",t)}),[t]),g.createElement(g.Fragment,null,t?g.createElement(Bo,{key:0,style:s},g.createElement(Sp,{onClose:l,ref:e})):null,g.createElement(Tp,{key:1},a&&g.createElement(lp,{entries:Lp,key:"nav"}),a?g.createElement(Zp,{key:"body"},g.createElement(Fh,{key:"samples"})):g.createElement(zh,{text:"No dataset selected",key:"loading"})))}));const Pp=d.div`
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
`,Rp=d.div``,Ip=d.div`
  font-weight: bold;
  text-align: center;
`,Wp=d.code`
  background: ${({theme:e})=>e.backgroundDark};
  border-bottom: 1px ${({theme:e})=>e.backgroundDarkBorder} solid;
  color: ${({theme:e})=>e.secondary};
  padding: 0.5rem;
`,Mp=d.button`
  display: inline-block;
  margin: 1rem 0.5rem;
  padding: 0.5rem;
  background: ${({theme:e})=>e.backgroundDark};
  color: ${({theme:e})=>e.fontDark};
  border: none;
  border-radius: 2px;
  font-weight: bold;
  color: ${({theme:e})=>e.font};
  cursor: pointer;

  &:focus {
    outline: none;
  }
`,Xp=d.img`
  width: 5rem;
  height: 5rem;
  margin: 0 auto 1rem;
  display: block;
`,Np=({resetErrorBoundary:e})=>g.createElement(Pp,null,g.createElement(Rp,null,g.createElement(Xp,{src:Po}),g.createElement(Ip,null,g.createElement("p",null,"Oops! Something went wrong."),g.createElement("p",null,"If you just changed your view, try reverting your changes:"),g.createElement(Wp,null,"session.view = old_view"),g.createElement("div",null,"And then"," ",g.createElement(Mp,{onClick:e},"Reload the App")," ","to try again.")))),Gp=d.div`
  font-size: 2rem;
  line-height: 3rem;
  color: ${({theme:e})=>e.font};
  font-weight: bold;
`,Yp=d.p`
  font-size: 1rem;
  line-height: 1.5rem;
  margin: 0;
  padding: 0;
  color: ${({theme:e})=>e.fontDark};

  & > a {
    color: ${({theme:e})=>e.brand};
  }
`,Vp=d.pre`
  padding: 2rem;
  background-color: ${({theme:e})=>e.backgroundDark};
  border: 1px solid ${({theme:e})=>e.backgroundDarkBorder};
  color: ${({theme:e})=>e.font};
  border-radius: 3px;
`,Fp=()=>{const e=`import fiftyone as fo\n\n# Load your FiftyOne dataset\ndataset = fo.load_dataset(...)\n\n# Launch the app\nsession = fo.launch_app(dataset, port=${kn})\n`;return g.createElement(g.Fragment,null,g.createElement(Gp,null,"Local sessions"),g.createElement(Yp,null,"Here's how to connect to a local session from Python:"),g.createElement(Vp,null,e))},Kp=()=>{const e=`# Option 1: Configure port forwaring\n# Then open http://localhost:${kn} in your web browser\nssh -N -L ${kn}:127.0.0.1:XXXX [<username>@]<hostname>\n\n# Option 2: Use the CLI\nfiftyone app connect --destination [<username>@]<hostname> \\\n    --port XXXX --local-port ${kn}\n`;return g.createElement(g.Fragment,null,g.createElement(Gp,null,"Remote sessions"),g.createElement(Yp,null,"You can work with data on a remote machine by launching a remote App session and connecting to it from your local machine. See"," ",g.createElement("a",{target:"_blank",href:"https://voxel51.com/docs/fiftyone/user_guide/app.html#remote-sessions"},"this page")," ","for more information."),g.createElement(Hp,null,"On your remote machine"),g.createElement(Vp,null,"import fiftyone as fo\n\n# Load your FiftyOne dataset\ndataset = fo.load_dataset(...)\n\n# Launch a remote App instance that you'll connect to from your local machine\nsession = fo.launch_app(dataset, remote=True, port=XXXX)\n"),g.createElement(Hp,null,"On your local machine"),g.createElement(Vp,null,e))},Dp=()=>g.createElement(g.Fragment,null,g.createElement(Gp,null,"Notebook sessions"),g.createElement(Yp,null,"Re-run the cell that created the session shown here.")),Op=d.div`
  width: 800px;
  padding: 3rem 1rem;
  margin: 0 auto;
`,zp=d.div`
  font-size: 2.5rem;
  line-height: 3.5rem;
  color: ${({theme:e})=>e.font};
  font-weight: bold;
`,Hp=d.div`
  font-size: 1.5rem;
  color: ${({theme:e})=>e.fontDark};
  font-weight: 500;
`,Up=d.div`
  display: flex;
  justify-content: flex-start;
  margin: 1em 0 3em 0;
  border-bottom-width: 2px;
  border-bottom-style: solid;
  border-bottom-color: ${({theme:e})=>e.backgroundDarkBorder};
  height: 53px;
`,jp=m(d.div`
  font-size: 1rem;
  line-height: 3em;
  font-weight: bold;
  padding: 0 0.5em;
  cursor: pointer;
  border-bottom-width: 3px;
  border-bottom-style: solid;
`),Ap=()=>{const e=go(),[t,n]=u.exports.useState("local"),s=M({borderBottomColor:"local"===t?e.brand:e.background,color:"local"===t?e.font:e.fontDark}),a=M({borderBottomColor:"remote"===t?e.brand:e.background,color:"remote"===t?e.font:e.fontDark});return g.createElement(Op,null,g.createElement(zp,null,"Welcome to FiftyOne!"),g.createElement(Hp,null,"It looks like you are not connected to a session"),bn?g.createElement(Dp,null):g.createElement(g.Fragment,null,g.createElement(Up,null,g.createElement(jp,{onClick:()=>n("local"),style:s},"Local sessions"),g.createElement(jp,{onClick:()=>n("remote"),style:a},"Remote sessions")),"remote"===t?g.createElement(Kp,null):g.createElement(Fp,null)))};function Bp(){const e=u.exports.useRef(null),[t,n]=u.exports.useState(!1);return oo("statistics",te((({set:e})=>async({stats:t,view:n,extended:s,filters:a})=>{s&&e(wt,{stats:t,view:n,filters:a}),!s&&e(xt,{stats:t,view:n})}),[])),io(Zn,"open",te((({set:e,snapshot:t})=>async()=>{e(kt,!0),!(await t.getPromise(kt))&&e(ft,!0)}),[])),io(Zn,"close",(()=>{const e=au();return te((({reset:t,set:n})=>async()=>{e(),n(ft,!1),t(St)}),[])})()),oo("update",te((({snapshot:e,set:t})=>async({state:n})=>{const s=new Set(n.selected),a=await e.getPromise(Ct);t(Ct,a+1),t(kt,!1),t(Lt,s),t(St,n),t(qi,!1),t(dm,!1),t(yu,!1),t(Vu,!1);const l=await e.getPromise(It);JSON.stringify(n.config.color_pool)!==JSON.stringify(l)&&t(It,n.config.color_pool)}),[])),oo("notification",(t=>e.current(t))),ro("as_app",{notebook:bn,handle:vn}),g.createElement(Be,{FallbackComponent:Np,onReset:()=>n(!0),resetKeys:[t]},g.createElement(jo,{addNotification:e}),g.createElement(u.exports.Suspense,{fallback:g.createElement(Ap,null)},g.createElement(Cp,null)),g.createElement(dt,{children:t=>e.current=t}))}const Jp=_e`
   ${Je`
  body,
  input,
  button {
    font-family: "Palanquin", sans-serif;
    font-size: 14px;
    color: ${({theme:e})=>e.font};
  }

  body,
  html {
    height: 100%;
    margin: 0 !important;
    padding: 0 !important;
    background-color: ${({theme:e})=>e.background};
  }

  body {
    ${_o};
    ::-webkit-scrollbar {
      background-color: ${({theme:e})=>e.background};
    }
  }

  input {
    padding: 0;
  }

  #root {
    height: 100%;
    position: relative;
  }
`}
`,_p=()=>g.createElement(Qe,{theme:Nn},g.createElement(Jp,null),g.createElement($e,null,g.createElement(Bp,null)));document.addEventListener("DOMContentLoaded",(()=>Ae.render(g.createElement(u.exports.Fragment,null,g.createElement(_p,null)),document.getElementById("root"))));
