diff --git a/assets/index-b3bdfabd.js b/assets/index-b3337a1f.js similarity index 99% rename from assets/index-b3bdfabd.js rename to assets/index-b3337a1f.js index 1b682cd..e49ed65 100644 --- a/assets/index-b3bdfabd.js +++ b/assets/index-b3337a1f.js @@ -2410,7 +2410,7 @@ void main(void)\r src: url('${oe.dataSrc}'); font-weight: ${oe.weight}; font-style: ${oe.style}; - }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(ne){this._stylesheet!==ne&&(this._stylesheet=ne,this.styleID++)}normalizeColor(ne){return Array.isArray(ne)&&(ne=rgb2hex(ne)),typeof ne=="number"?hex2string(ne):ne}dropShadowToCSS(){let ne=this.normalizeColor(this.dropShadowColor);const oe=this.dropShadowAlpha,ce=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),ue=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);ne.startsWith("#")&&oe<1&&(ne+=(oe*255|0).toString(16).padStart(2,"0"));const pe=`${ce}px ${ue}px`;return this.dropShadowBlur>0?`text-shadow: ${pe} ${this.dropShadowBlur}px ${ne}`:`text-shadow: ${pe} ${ne}`}reset(){Object.assign(this,_HTMLTextStyle.defaultOptions)}onBeforeDraw(){const{fontsDirty:ne}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&ne?new Promise(oe=>setTimeout(oe,100)):Promise.resolve()}get isSafari(){const{userAgent:ne}=settings.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(ne)}set fillGradientStops(ne){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(ne){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(ne){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(ne){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(ne){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(ne){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(ne){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};let HTMLTextStyle=_HTMLTextStyle;HTMLTextStyle.availableFonts={};HTMLTextStyle.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};const _HTMLText=class extends Sprite{constructor(ne="",oe={}){super(Texture.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this._loading=!1,this.localStyleID=-1,this.dirty=!1,this.ownsStyle=!1;const ce=new Image,ue=Texture.from(ce,{scaleMode:settings.SCALE_MODE,resourceOptions:{autoLoad:!1}});ue.orig=new Rectangle,ue.trim=new Rectangle,this.texture=ue;const pe="http://www.w3.org/2000/svg",me="http://www.w3.org/1999/xhtml",ge=document.createElementNS(pe,"svg"),ye=document.createElementNS(pe,"foreignObject"),ve=document.createElementNS(me,"div"),xe=document.createElementNS(me,"style");ye.setAttribute("width","10000"),ye.setAttribute("height","10000"),ye.style.overflow="hidden",ge.appendChild(ye),this.maxWidth=_HTMLText.defaultMaxWidth,this.maxHeight=_HTMLText.defaultMaxHeight,this._domElement=ve,this._styleElement=xe,this._svgRoot=ge,this._foreignObject=ye,this._foreignObject.appendChild(xe),this._foreignObject.appendChild(ve),this._image=ce,this._loadImage=new Image,this._autoResolution=_HTMLText.defaultAutoResolution,this._resolution=_HTMLText.defaultResolution??settings.RESOLUTION,this.text=ne,this.style=oe}measureText(ne){var ye,ve;const{text:oe,style:ce,resolution:ue}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},ne);Object.assign(this._domElement,{innerHTML:oe,style:ce.toCSS(ue)}),this._styleElement.textContent=ce.toGlobalCSS(),document.body.appendChild(this._svgRoot);const pe=this._domElement.getBoundingClientRect();this._svgRoot.remove();const me=Math.min(this.maxWidth,Math.ceil(pe.width)),ge=Math.min(this.maxHeight,Math.ceil(pe.height));return this._svgRoot.setAttribute("width",me.toString()),this._svgRoot.setAttribute("height",ge.toString()),oe!==this._text&&(this._domElement.innerHTML=this._text),ce!==this._style&&(Object.assign(this._domElement,{style:(ye=this._style)==null?void 0:ye.toCSS(ue)}),this._styleElement.textContent=(ve=this._style)==null?void 0:ve.toGlobalCSS()),{width:me+ce.padding*2,height:ge+ce.padding*2}}async updateText(ne=!0){const{style:oe,_image:ce,_loadImage:ue}=this;if(this.localStyleID!==oe.styleID&&(this.dirty=!0,this.localStyleID=oe.styleID),!this.dirty&&ne)return;const{width:pe,height:me}=this.measureText();ce.width=ue.width=Math.ceil(Math.max(1,pe)),ce.height=ue.height=Math.ceil(Math.max(1,me)),this._loading||(this._loading=!0,await new Promise(ge=>{ue.onload=async()=>{await oe.onBeforeDraw(),this._loading=!1,ce.src=ue.src,ue.onload=null,ue.src="",this.updateTexture(),ge()};const ye=new XMLSerializer().serializeToString(this._svgRoot);ue.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(ye)}`}))}get source(){return this._image}updateTexture(){const{style:ne,texture:oe,_image:ce,resolution:ue}=this,{padding:pe}=ne,{baseTexture:me}=oe;oe.trim.width=oe._frame.width=ce.width/ue,oe.trim.height=oe._frame.height=ce.height/ue,oe.trim.x=-pe,oe.trim.y=-pe,oe.orig.width=oe._frame.width-pe*2,oe.orig.height=oe._frame.height-pe*2,this._onTextureUpdate(),me.setRealSize(ce.width,ce.height,ue),this.dirty=!1}_render(ne){this._autoResolution&&this._resolution!==ne.resolution&&(this._resolution=ne.resolution,this.dirty=!0),this.updateText(!0),super._render(ne)}_renderCanvas(ne){this._autoResolution&&this._resolution!==ne.resolution&&(this._resolution=ne.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(ne)}getLocalBounds(ne){return this.updateText(!0),super.getLocalBounds(ne)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(ne){var ce,ue,pe,me,ge;typeof ne=="boolean"&&(ne={children:ne}),ne=Object.assign({},_HTMLText.defaultDestroyOptions,ne),super.destroy(ne);const oe=null;this.ownsStyle&&((ce=this._style)==null||ce.cleanFonts()),this._style=oe,(ue=this._svgRoot)==null||ue.remove(),this._svgRoot=oe,(pe=this._domElement)==null||pe.remove(),this._domElement=oe,(me=this._foreignObject)==null||me.remove(),this._foreignObject=oe,(ge=this._styleElement)==null||ge.remove(),this._styleElement=oe,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=oe,this._image.src="",this._image=oe}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(ne){this.updateText(!0);const oe=sign$2(this.scale.x)||1;this.scale.x=oe*ne/this._image.width/this.resolution,this._width=ne}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(ne){this.updateText(!0);const oe=sign$2(this.scale.y)||1;this.scale.y=oe*ne/this._image.height/this.resolution,this._height=ne}get style(){return this._style}set style(ne){this._style!==ne&&(ne=ne||{},ne instanceof HTMLTextStyle?(this.ownsStyle=!1,this._style=ne):ne instanceof TextStyle?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=HTMLTextStyle.from(ne)):(this.ownsStyle=!0,this._style=new HTMLTextStyle(ne)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(ne){ne=String(ne===""||ne===null||ne===void 0?" ":ne),ne=this.sanitiseText(ne),this._text!==ne&&(this._text=ne,this.dirty=!0)}get resolution(){return this._resolution}set resolution(ne){this._autoResolution=!1,this._resolution!==ne&&(this._resolution=ne,this.dirty=!0)}sanitiseText(ne){return ne.replace(/
/gi,"
").replace(/
/gi,"
").replace(/ /gi," ")}};let HTMLText=_HTMLText;HTMLText.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0};HTMLText.defaultMaxWidth=2024;HTMLText.defaultMaxHeight=2024;HTMLText.defaultAutoResolution=!0;function makeRenderer(ne,oe){return{constructor:ne,meta:oe}}function quickselect(ne,oe,ce,ue,pe){quickselectStep(ne,oe,ce||0,ue||ne.length-1,pe||defaultCompare)}function quickselectStep(ne,oe,ce,ue,pe){for(;ue>ce;){if(ue-ce>600){var me=ue-ce+1,ge=oe-ce+1,ye=Math.log(me),ve=.5*Math.exp(2*ye/3),xe=.5*Math.sqrt(ye*ve*(me-ve)/me)*(ge-me/2<0?-1:1),_e=Math.max(ce,Math.floor(oe-ge*ve/me+xe)),Se=Math.min(ue,Math.floor(oe+(me-ge)*ve/me+xe));quickselectStep(ne,oe,_e,Se,pe)}var $e=ne[oe],Re=ce,Ae=ue;for(swap(ne,ce,oe),pe(ne[ue],$e)>0&&swap(ne,ce,ue);Re0;)Ae--}pe(ne[ce],$e)===0?swap(ne,ce,Ae):(Ae++,swap(ne,Ae,ue)),Ae<=oe&&(ce=Ae+1),oe<=Ae&&(ue=Ae-1)}}function swap(ne,oe,ce){var ue=ne[oe];ne[oe]=ne[ce],ne[ce]=ue}function defaultCompare(ne,oe){return neoe?1:0}class RBush{constructor(oe=9){this._maxEntries=Math.max(4,oe),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(oe){let ce=this.data;const ue=[];if(!intersects(oe,ce))return ue;const pe=this.toBBox,me=[];for(;ce;){for(let ge=0;ge=0&&me[ce].children.length>this._maxEntries;)this._split(me,ce),ce--;this._adjustParentBBoxes(pe,me,ce)}_split(oe,ce){const ue=oe[ce],pe=ue.children.length,me=this._minEntries;this._chooseSplitAxis(ue,me,pe);const ge=this._chooseSplitIndex(ue,me,pe),ye=createNode(ue.children.splice(ge,ue.children.length-ge));ye.height=ue.height,ye.leaf=ue.leaf,calcBBox(ue,this.toBBox),calcBBox(ye,this.toBBox),ce?oe[ce-1].children.push(ye):this._splitRoot(ue,ye)}_splitRoot(oe,ce){this.data=createNode([oe,ce]),this.data.height=oe.height+1,this.data.leaf=!1,calcBBox(this.data,this.toBBox)}_chooseSplitIndex(oe,ce,ue){let pe,me=1/0,ge=1/0;for(let ye=ce;ye<=ue-ce;ye++){const ve=distBBox(oe,0,ye,this.toBBox),xe=distBBox(oe,ye,ue,this.toBBox),_e=intersectionArea(ve,xe),Se=bboxArea(ve)+bboxArea(xe);_e=ce;xe--){const _e=oe.children[xe];extend$1(ye,oe.leaf?me(_e):_e),ve+=bboxMargin(ye)}return ve}_adjustParentBBoxes(oe,ce,ue){for(let pe=ue;pe>=0;pe--)extend$1(ce[pe],oe)}_condense(oe){for(let ce=oe.length-1,ue;ce>=0;ce--)oe[ce].children.length===0?ce>0?(ue=oe[ce-1].children,ue.splice(ue.indexOf(oe[ce]),1)):this.clear():calcBBox(oe[ce],this.toBBox)}}function findItem(ne,oe,ce){if(!ce)return oe.indexOf(ne);for(let ue=0;ue=ne.minX&&oe.maxY>=ne.minY}function createNode(ne){return{children:ne,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function multiSelect(ne,oe,ce,ue,pe){const me=[oe,ce];for(;me.length;){if(ce=me.pop(),oe=me.pop(),ce-oe<=ue)continue;const ge=oe+Math.ceil((ce-oe)/ue/2)*ue;quickselect(ne,ge,oe,ce,pe),me.push(oe,ge,ge,ce)}}class Bush extends RBush{toBBox(oe){return{minX:oe.left,minY:oe.top,maxX:oe.right,maxY:oe.bottom}}compareMinX(oe,ce){return oe.left-ce.left}compareMinY(oe,ce){return oe.top-ce.top}}const defaultD2RendererOptions={screenSize:{width:1,height:1},workerCount:4,workerIndex:0,tileResolution:{width:64,height:64},tileSubdivision:0,refreshInterval:1e3/60,animationDuration:150,debounceInterval:1e3/60,errorColor:"#f44336",backgroundColor:"#ffffff",accentColor:"#333333",dynamicResolution:{intervalMs:500,increment:.5,maxScale:1.5,minScale:1,dtMax:1.5,dtMin:1.1}};var dist$1={},__assign=commonjsGlobal&&commonjsGlobal.__assign||function(){return __assign=Object.assign||function(ne){for(var oe,ce=1,ue=arguments.length;ce0?1:-1}),shim$4}var sign$1=isImplemented$6()?Math.sign:requireShim$4(),sign=sign$1,abs=Math.abs,floor$1=Math.floor,toInteger$1=function(ne){return isNaN(ne)?0:(ne=Number(ne),ne===0||!isFinite(ne)?ne:sign(ne)*floor$1(abs(ne)))},toInteger=toInteger$1,max$3=Math.max,toPosInteger=function(ne){return max$3(0,toInteger(ne))},validCallable=function(ne){if(typeof ne!="function")throw new TypeError(ne+" is not a function");return ne},isValue$4=isValue$6,validValue=function(ne){if(!isValue$4(ne))throw new TypeError("Cannot use null or undefined");return ne},custom={exports:{}},isImplemented$5=function(){var ne=Object.assign,oe;return typeof ne!="function"?!1:(oe={foo:"raz"},ne(oe,{bar:"dwa"},{trzy:"trzy"}),oe.foo+oe.bar+oe.trzy==="razdwatrzy")},isImplemented$4,hasRequiredIsImplemented$3;function requireIsImplemented$3(){return hasRequiredIsImplemented$3||(hasRequiredIsImplemented$3=1,isImplemented$4=function(){try{return Object.keys("primitive"),!0}catch{return!1}}),isImplemented$4}var shim$3,hasRequiredShim$3;function requireShim$3(){if(hasRequiredShim$3)return shim$3;hasRequiredShim$3=1;var ne=isValue$6,oe=Object.keys;return shim$3=function(ce){return oe(ne(ce)?Object(ce):ce)},shim$3}var keys,hasRequiredKeys;function requireKeys(){return hasRequiredKeys||(hasRequiredKeys=1,keys=requireIsImplemented$3()()?Object.keys:requireShim$3()),keys}var shim$2,hasRequiredShim$2;function requireShim$2(){if(hasRequiredShim$2)return shim$2;hasRequiredShim$2=1;var ne=requireKeys(),oe=validValue,ce=Math.max;return shim$2=function(ue,pe){var me,ge,ye=ce(arguments.length,2),ve;for(ue=Object(oe(ue)),ve=function(xe){try{ue[xe]=pe[xe]}catch(_e){me||(me=_e)}},ge=1;ge-1},shim$1}var contains$1=isImplemented$3()?String.prototype.contains:requireShim$1(),isValue$1=is$5,isPlainFunction=is$1,assign$1=assign$2,normalizeOpts=normalizeOptions,contains=contains$1,d$1=d$2.exports=function(ne,oe){var ce,ue,pe,me,ge;return arguments.length<2||typeof ne!="string"?(me=oe,oe=ne,ne=null):me=arguments[2],isValue$1(ne)?(ce=contains.call(ne,"c"),ue=contains.call(ne,"e"),pe=contains.call(ne,"w")):(ce=pe=!0,ue=!1),ge={value:oe,configurable:ce,enumerable:ue,writable:pe},me?assign$1(normalizeOpts(me),ge):ge};d$1.gs=function(ne,oe,ce){var ue,pe,me,ge;return typeof ne!="string"?(me=ce,ce=oe,oe=ne,ne=null):me=arguments[3],isValue$1(oe)?isPlainFunction(oe)?isValue$1(ce)?isPlainFunction(ce)||(me=ce,ce=void 0):ce=void 0:(me=oe,oe=ce=void 0):oe=void 0,isValue$1(ne)?(ue=contains.call(ne,"c"),pe=contains.call(ne,"e")):(ue=!0,pe=!1),ge={get:oe,set:ce,configurable:ue,enumerable:pe},me?assign$1(normalizeOpts(me),ge):ge};var dExports=d$2.exports,eventEmitter={exports:{}};(function(ne,oe){var ce=dExports,ue=validCallable,pe=Function.prototype.apply,me=Function.prototype.call,ge=Object.create,ye=Object.defineProperty,ve=Object.defineProperties,xe=Object.prototype.hasOwnProperty,_e={configurable:!0,enumerable:!1,writable:!0},Se,$e,Re,Ae,Ie,ke,Be;Se=function(Ne,Fe){var Ue;return ue(Fe),xe.call(this,"__ee__")?Ue=this.__ee__:(Ue=_e.value=ge(null),ye(this,"__ee__",_e),_e.value=null),Ue[Ne]?typeof Ue[Ne]=="object"?Ue[Ne].push(Fe):Ue[Ne]=[Ue[Ne],Fe]:Ue[Ne]=Fe,this},$e=function(Ne,Fe){var Ue,We;return ue(Fe),We=this,Se.call(this,Ne,Ue=function(){Re.call(We,Ne,Ue),pe.call(Fe,this,arguments)}),Ue.__eeOnceListener__=Fe,this},Re=function(Ne,Fe){var Ue,We,qe,ze;if(ue(Fe),!xe.call(this,"__ee__"))return this;if(Ue=this.__ee__,!Ue[Ne])return this;if(We=Ue[Ne],typeof We=="object")for(ze=0;qe=We[ze];++ze)(qe===Fe||qe.__eeOnceListener__===Fe)&&(We.length===2?Ue[Ne]=We[ze?0:1]:We.splice(ze,1));else(We===Fe||We.__eeOnceListener__===Fe)&&delete Ue[Ne];return this},Ae=function(Ne){var Fe,Ue,We,qe,ze;if(xe.call(this,"__ee__")&&(qe=this.__ee__[Ne],!!qe))if(typeof qe=="object"){for(Ue=arguments.length,ze=new Array(Ue-1),Fe=1;Fe=55296&&Ue<=56319&&(Ge+=$e[++ke])),Ge=Re?xe.call(Re,Ae,Ge,Be):Ge,Ie?(_e.value=Ge,Se(Ne,Be,_e)):Ne[Be]=Ge,++Be;Fe=Be}}if(Fe===void 0)for(Fe=ue($e.length),Ie&&(Ne=new Ie(Fe)),ke=0;ke=6&&(ce-=6),G(ce<1?255*((oe-ne)*ce+ne):ce<3?255*oe:ce<4?255*((oe-ne)*(4-ce)+ne):255*ne)},X=function(ne,oe,ce){oe/=100;var ue=(ce/=100)<=.5?ce*(oe+1):ce+oe-ce*oe,pe=2*ce-ue;return{r:O(pe,ue,(ne/=60)+2),g:O(pe,ue,ne),b:O(pe,ue,ne-2)}},Y=function(ne,oe,ce,ue){return{r:G(255*(1-ne)*(ue=1-ue)),g:G(255*(1-oe)*ue),b:G(255*(1-ce)*ue)}},j=function(ne,oe,ce){ne/=255,oe/=255,ce/=255;var ue=1-Math.max(ne,oe,ce),pe=1-ue,me=pe&&(pe-oe)/pe,ge=pe&&(pe-ce)/pe;return{c:G(100*(pe&&(pe-ne)/pe)),m:G(100*me),y:G(100*ge),k:G(100*ue)}},K=function(ne,oe,ce,ue){ue===void 0&&(ue=1),ne/=255,oe/=255,ce/=255,ue=Math.min(ue,1);var pe=Math.max(ne,oe,ce),me=Math.min(ne,oe,ce),ge=pe-me,ye=0,ve=0,xe=(pe+me)/2;if(ge!==0){switch(pe){case ne:ye=(oe-ce)/ge%6;break;case oe:ye=(ce-ne)/ge+2;break;case ce:ye=(ne-oe)/ge+4}(ye=G(60*ye))<0&&(ye+=360),ve=ge/(1-Math.abs(2*xe-1))}return{h:ye,s:G(100*ve),l:G(100*xe),a:ue}},I=function(ne,oe){if(ne<0&&(ne+=360),ne>360&&(ne-=360),ne===360||ne===0)return ne;var ce=[[0,120],[120,180],[180,240],[240,360]],ue=[[0,60],[60,120],[120,240],[240,360]],pe=oe?ue:ce,me=0,ge=0,ye=0,ve=0;return(oe?ce:ue).find(function(xe,_e){return ne>=xe[0]&&ne360||ne<0)&&(ne-=360*Math.floor(ne/360)),ne},N=function(ne){return typeof ne=="string"&&(ne=m.test(ne)?B(ne)/100:+ne),isNaN(+ne)||ne>1?1:G(ne)},V=function(ne,oe,ce){return oe.reduce(function(ue,pe){return e(e([],ue,!0),[t(t({},ne),{h:ce===i.ADDITIVE?x(ne.h+pe):x(I(I(ne.h,!1)+pe,!0))})],!1)},[t({},ne)])},U=function(ne,oe){return V(ne,[30,-30],oe)},q=function(ne,oe){return V(ne,[180],oe)},$=function(ne,oe){return V(ne,[150,-150],oe)},_=function(ne,oe){return V(ne,[120,-120],oe)},Q=function(ne,oe){return V(ne,[60,-120,180],oe)},z$1=function(ne,oe){return V(ne,[90,-90,180],oe)},J=function(ne){return typeof ne=="string"?function(oe){var ce;if(Object.keys(r).some(function(ue){if(b[ue].test(oe))return ce=ue,!0}),!ce&&~f.indexOf(oe)&&(ce=r.HEX),!ce)throw new Error(E);return ce}(ne):function(oe){var ce,ue=!1,pe=L(Object.keys(oe));if(p[pe]&&(ce=p[pe]),ce&&ce===r.RGB){var me=Object.entries(oe).some(function(ye){return!y.test("".concat(ye[1]))}),ge=Object.entries(oe).some(function(ye){return!(m.test("".concat(ye[1]))||!y.test("".concat(ye[1]))&&!isNaN(+ye[1])&&+ye[1]<=255)});me&&ge&&(ue=!0),me||(ce=r.HEX)}if(!ce||ue)throw new Error(v);return ce}(ne)},W=((c={})[r.HEX]=function(ne){var oe=(~f.indexOf(ne)?o[ne]:ne).match(b.HEX),ce={r:M(oe[1]||oe[5]),g:M(oe[2]||oe[6]),b:M(oe[3]||oe[7])},ue=oe[4]||oe[8];return ue!==void 0&&(ce.a=M(ue)/255),ce},c[r.RGB]=function(ne){var oe=ne.match(b.RGB),ce=D(oe[1]||oe[5]),ue=D(oe[2]||oe[6]),pe=D(oe[3]||oe[7]),me=oe[4]||oe[8],ge={r:Math.min(ce,255),g:Math.min(ue,255),b:Math.min(pe,255)};return me!==void 0&&(ge.a=N(me)),ge},c[r.HSL]=function(ne){var oe=ne.match(b.HSL),ce=x(oe[1]||oe[5]),ue=C(oe[2]||oe[6]),pe=C(oe[3]||oe[7]),me=oe[4]||oe[8],ge=X(ce,ue,pe);return me!==void 0&&(ge.a=N(me)),ge},c[r.CMYK]=function(ne){var oe=ne.match(b.CMYK),ce=S(oe[1]||oe[6]),ue=S(oe[2]||oe[7]),pe=S(oe[3]||oe[8]),me=S(oe[4]||oe[9]),ge=oe[5]||oe[10],ye=Y(ce,ue,pe,me);return ge!==void 0&&(ye.a=N(ge)),ye},c),Z=((s={})[r.HEX]=function(ne){var oe={r:D("".concat(ne.r)),g:D("".concat(ne.g)),b:D("".concat(ne.b))};return H(ne,"a")&&(oe.a=Math.min(D("".concat(ne.a),!0),1)),oe},s[r.RGB]=function(ne){return this.HEX(ne)},s[r.HSL]=function(ne){var oe=C("".concat(ne.s)),ce=C("".concat(ne.l)),ue=X(x(ne.h),oe,ce);return H(ne,"a")&&(ue.a=N(ne.a)),ue},s[r.CMYK]=function(ne){var oe=S("".concat(ne.c)),ce=S("".concat(ne.m)),ue=S("".concat(ne.y)),pe=S("".concat(ne.k)),me=Y(oe,ce,ue,pe);return H(ne,"a")&&(me.a=N(ne.a)),me},s),tt=function(ne,oe){return oe===void 0&&(oe=J(ne)),typeof ne=="string"?W[oe](ne):Z[oe](ne)},et=((d={})[r.HEX]=function(ne){return{r:R(ne.r),g:R(ne.g),b:R(ne.b)}},d.HEXA=function(ne){var oe=et.HEX(ne);return oe.a=H(ne,"a")?R(255*ne.a):"0xFF",oe},d[r.RGB]=function(ne,oe){return H(ne,"a")&&delete ne.a,ot(ne,oe)},d.RGBA=function(ne,oe){return ne.a=H(ne,"a")?G(ne.a):1,ot(ne,oe)},d[r.HSL]=function(ne,oe){var ce=K(ne.r,ne.g,ne.b);return delete ce.a,at(ce,oe)},d.HSLA=function(ne,oe){var ce=et.HSL(ne,oe);return ce.a=H(ne,"a")?G(ne.a,oe):1,ce},d[r.CMYK]=function(ne,oe){return ut(j(ne.r,ne.g,ne.b),oe)},d.CMYKA=function(ne,oe){var ce=et.CMYK(ne,oe);return ce.a=H(ne,"a")?G(ne.a,oe):1,ce},d),rt=function(ne,oe,ce,ue){var pe=J(ne),me=typeof ne=="string",ge=tt(ne,pe),ye=typeof ne=="string"&&H(ge,"a")||typeof ne!="string"&&H(ne,"a"),ve=K(ge.r,ge.g,ge.b,ge.a);ye||delete ve.a;var xe=ce?ve.l/(oe+1):(100-ve.l)/(oe+1),_e=Array(oe).fill(null).map(function(Se,$e){return t(t({},ve),{l:ve.l+xe*($e+1)*(1-2*+ce)})});switch(pe){case r.HEX:default:return _e.map(function(Se){var $e=X(Se.h,Se.s,Se.l);return ye&&($e.a=Se.a),me?ye?w.HEX(ot(t(t({},$e),{a:G(255*$e.a)}),ue)):w.HEX(ot($e,ue)):ye?et.HEXA($e):et.HEX($e)});case r.RGB:return _e.map(function(Se){var $e=X(Se.h,Se.s,Se.l);return ye&&($e.a=Se.a),me?w.RGB(ot($e,ue)):ye?et.RGBA($e,ue):et.RGB($e,ue)});case r.HSL:return _e.map(function(Se){return me?w.HSL(at(Se,ue)):ye?et.HSLA(t(t({},X(Se.h,Se.s,Se.l)),{a:Se.a}),ue):et.HSL(X(Se.h,Se.s,Se.l),ue)})}},nt=((h={buildHarmony:function(ne,oe,ce,ue){var pe=J(ne),me=tt(ne,pe),ge=K(me.r,me.g,me.b,me.a),ye=typeof ne=="string"&&H(me,"a")||typeof ne!="string"&&H(ne,"a"),ve=typeof ne=="string";switch(pe){case r.HEX:default:return ye?this.HEXA(at(ge,0),oe,ce,ve):this.HEX(at(ge,0),oe,ce,ve);case r.HSL:return ye?this.HSLA(ge,oe,ce,ve,ue):this.HSL(ge,oe,ce,ve,ue);case r.RGB:return ye?this.RGBA(ge,oe,ce,ve,ue):this.RGB(ge,oe,ce,ve,ue)}}})[r.HEX]=function(ne,oe,ce,ue){return oe(ne,ce).map(function(pe){return ue?w.HEX(X(pe.h,pe.s,pe.l)):et.HEX(X(pe.h,pe.s,pe.l))})},h.HEXA=function(ne,oe,ce,ue){return oe(ne,ce).map(function(pe){return ue?w.HEX(t(t({},X(pe.h,pe.s,pe.l)),{a:255*N(pe.a)})):et.HEXA(t(t({},X(pe.h,pe.s,pe.l)),{a:N(pe.a)}))})},h[r.RGB]=function(ne,oe,ce,ue,pe){return oe(ne,ce).map(function(me){return ue?w.RGB(ot(X(me.h,me.s,me.l),pe)):et.RGB(X(me.h,me.s,me.l),pe)})},h.RGBA=function(ne,oe,ce,ue,pe){return oe(ne,ce).map(function(me){return ue?w.RGB(ot(t(t({},X(me.h,me.s,me.l)),{a:N(me.a)}),pe)):et.RGBA(t(t({},X(me.h,me.s,me.l)),{a:N(me.a)}),pe)})},h[r.HSL]=function(ne,oe,ce,ue,pe){return oe(ne,ce).map(function(me){return ue?w.HSL(at({h:me.h,s:me.s,l:me.l},pe)):et.HSL(X(me.h,me.s,me.l),pe)})},h.HSLA=function(ne,oe,ce,ue,pe){return oe(ne,ce).map(function(me){return ue?w.HSL(at(t(t({},me),{a:N(me.a)}),pe)):et.HSLA(t(t({},X(me.h,me.s,me.l)),{a:N(me.a)}),pe)})},h),it=((l={mix:function(ne,oe){var ce,ue,pe,me,ge,ye,ve,xe,_e,Se,$e,Re,Ae,Ie,ke,Be=ne.map(function(We){var qe=J(We);return tt(We,qe)}),Ne=oe===i.SUBTRACTIVE?Be.map(function(We){var qe,ze,Ge,Ze,Dt,Je,Ut,jt,Ke,an,Zt,en,Kt,Wt,un=(qe=We.r,ze=We.g,Ge=We.b,Ze=Math.min(qe,ze,Ge),Dt=Math.min(255-qe,255-ze,255-Ge),Je=qe-Ze,Ut=ze-Ze,jt=Ge-Ze,Ke=Math.min(Je,Ut),an=Je-Ke,Zt=(Ut+Ke)/2,en=(jt+Ut-Ke)/2,Kt=Math.max(an,Zt,en)/Math.max(Je,Ut,jt),Wt=isNaN(Kt)||Kt===1/0||Kt<=0?1:Kt,{r:an/Wt+Dt,y:Zt/Wt+Dt,b:en/Wt+Dt});return H(We,"a")&&(un.a=We.a),un}):null;function Fe(We){var qe=oe===i.ADDITIVE?{r:0,g:0,b:0,a:0}:{r:0,y:0,b:0,a:0};return We.reduce(function(ze,Ge){var Ze=H(Ge,"a")?Ge.a:1,Dt={r:Math.min(ze.r+Ge.r*Ze,255),b:Math.min(ze.b+Ge.b*Ze,255),a:1-(1-Ze)*(1-ze.a)},Je="g"in ze?ze.g:ze.y,Ut="g"in Ge?Ge.g:Ge.y;return t(t({},Dt),oe===i.ADDITIVE?{g:Math.min(Je+Ut*Ze,255)}:{y:Math.min(Je+Ut*Ze,255)})},qe)}if(oe===i.ADDITIVE)ce=Fe(Be);else{var Ue=Fe(Ne);ue=Ue.r,pe=Ue.y,me=Ue.b,ge=Math.min(ue,pe,me),ye=Math.min(255-ue,255-pe,255-me),ve=ue-ge,xe=pe-ge,_e=me-ge,Se=Math.min(xe,_e),$e=ve+xe-Se,Re=xe+Se,Ae=2*(_e-Se),Ie=Math.max($e,Re,Ae)/Math.max(ve,xe,_e),ke=isNaN(Ie)||Ie===1/0||Ie<=0?1:Ie,(ce={r:$e/ke+ye,g:Re/ke+ye,b:Ae/ke+ye}).a=Ue.a}return{r:G(ce.r),g:G(ce.g),b:G(ce.b),a:k(ce.a,0,1)}}})[r.HEX]=function(ne,oe,ce){var ue=this.mix(ne,oe);return delete ue.a,ce?w.HEX(ue):et.HEX(ue)},l.HEXA=function(ne,oe,ce){var ue=this.mix(ne,oe);return ue.a=ce?255*N(ue.a):N(ue.a),ce?w.HEX(ue):et.HEXA(ue)},l[r.RGB]=function(ne,oe,ce,ue){var pe=this.mix(ne,oe);return delete pe.a,ce?w.RGB(pe):et.RGB(pe,ue)},l.RGBA=function(ne,oe,ce,ue){var pe=this.mix(ne,oe);return ce?w.RGB(pe):et.RGBA(pe,ue)},l[r.HSL]=function(ne,oe,ce,ue){var pe=this.mix(ne,oe),me=K(pe.r,pe.g,pe.b);return delete pe.a,delete me.a,ce?w.HSL(me):et.HSL(pe,ue)},l.HSLA=function(ne,oe,ce,ue){var pe=this.mix(ne,oe),me=K(pe.r,pe.g,pe.b,pe.a);return ce?w.HSL(me):et.HSLA(pe,ue)},l),ot=function(ne,oe){return t({r:G(ne.r,oe),g:G(ne.g,oe),b:G(ne.b,oe)},H(ne,"a")?{a:G(ne.a,oe)}:{})},at=function(ne,oe){return t({h:G(ne.h,oe),s:G(ne.s,oe),l:G(ne.l,oe)},H(ne,"a")?{a:G(ne.a,oe)}:{})},ut=function(ne,oe){return{c:G(ne.c,oe),m:G(ne.m,oe),y:G(ne.y,oe),k:G(ne.k,oe)}},ct=function(ne,oe,ce,ue,pe,me){var ge=pe(tt(ne,oe),ue);return ce?me(ge):ge},st=function(ne,oe,ce,ue,pe,me,ge){ce<1&&(ce=5);var ye=function(ve,xe,_e){var Se=_e-1,$e=(xe.r-ve.r)/Se,Re=(xe.g-ve.g)/Se,Ae=(xe.b-ve.b)/Se,Ie=N(ve.a),ke=(N(xe.a)-Ie)/Se;return Array(_e).fill(null).map(function(Be,Ne){return Ne===0?ve:Ne===Se?xe:{r:G(ve.r+$e*Ne),g:G(ve.g+Re*Ne),b:G(ve.b+Ae*Ne),a:G(Ie+ke*Ne)}})}(tt(ne),tt(oe),ce);return ye.map(function(ve){var xe=me(ve,pe);return ue?ge(xe):xe})},dt=function(){function ne(oe,ce){ce===void 0&&(ce=6),this.rgb=tt(oe),this._decimals=ce,this.updateHSL(),this.updateCMYK()}return ne.prototype.updateRGB=function(){this.rgb=t(t({},X(this.hsl.h,this.hsl.s,this.hsl.l)),{a:this.hsl.a})},ne.prototype.updateRGBFromCMYK=function(){this.rgb=t(t({},Y(this.cmyk.c,this.cmyk.m,this.cmyk.y,this.cmyk.k)),{a:this.rgb.a})},ne.prototype.updateHSL=function(){this.hsl=K(this.rgb.r,this.rgb.g,this.rgb.b,this.rgb.a)},ne.prototype.updateCMYK=function(){this.cmyk=j(this.rgb.r,this.rgb.g,this.rgb.b)},ne.prototype.updateRGBAndCMYK=function(){return this.updateRGB(),this.updateCMYK(),this},ne.prototype.updateHSLAndCMYK=function(){return this.updateHSL(),this.updateCMYK(),this},ne.prototype.updateRGBAndHSL=function(){return this.updateRGBFromCMYK(),this.updateHSL(),this},ne.prototype.setDecimals=function(oe){return this._decimals=oe,this},ne.prototype.setH=function(oe){return this.hsl.h=x(oe),this.updateRGBAndCMYK()},ne.prototype.setS=function(oe){return this.hsl.s=k(oe,0,100),this.updateRGBAndCMYK()},ne.prototype.setL=function(oe){return this.hsl.l=k(oe,0,100),this.updateRGBAndCMYK()},ne.prototype.setR=function(oe){return this.rgb.r=k(oe,0,255),this.updateHSLAndCMYK()},ne.prototype.setG=function(oe){return this.rgb.g=k(oe,0,255),this.updateHSLAndCMYK()},ne.prototype.setB=function(oe){return this.rgb.b=k(oe,0,255),this.updateHSLAndCMYK()},ne.prototype.setA=function(oe){return this.hsl.a=this.rgb.a=k(oe,0,1),this},ne.prototype.setC=function(oe){return this.cmyk.c=k(oe,0,100),this.updateRGBAndHSL()},ne.prototype.setM=function(oe){return this.cmyk.m=k(oe,0,100),this.updateRGBAndHSL()},ne.prototype.setY=function(oe){return this.cmyk.y=k(oe,0,100),this.updateRGBAndHSL()},ne.prototype.setK=function(oe){return this.cmyk.k=k(oe,0,100),this.updateRGBAndHSL()},Object.defineProperty(ne.prototype,"decimals",{get:function(){return this._decimals},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"H",{get:function(){return G(this.hsl.h,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"S",{get:function(){return G(this.hsl.s,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"L",{get:function(){return G(this.hsl.l,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"R",{get:function(){return G(this.rgb.r,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"G",{get:function(){return G(this.rgb.g,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"B",{get:function(){return G(this.rgb.b,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"A",{get:function(){return G(this.hsl.a,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"C",{get:function(){return G(this.cmyk.c,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"M",{get:function(){return G(this.cmyk.m,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"Y",{get:function(){return G(this.cmyk.y,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"K",{get:function(){return G(this.cmyk.k,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HEXObject",{get:function(){return et.HEX(this.rgb)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HEXAObject",{get:function(){return et.HEXA(this.rgb)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"RGBObject",{get:function(){return{r:this.R,g:this.G,b:this.B}},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"RGBAObject",{get:function(){return t(t({},this.RGBObject),{a:this.A})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HSLObject",{get:function(){return{h:this.H,s:this.S,l:this.L}},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HSLAObject",{get:function(){return t(t({},this.HSLObject),{a:this.A})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"CMYKObject",{get:function(){return{c:this.C,m:this.M,y:this.Y,k:this.K}},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"CMYKAObject",{get:function(){return t(t({},this.CMYKObject),{a:this.A})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HEX",{get:function(){return w.HEX({r:this.R,g:this.G,b:this.B})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HEXA",{get:function(){return w.HEX({r:this.R,g:this.G,b:this.B,a:255*this.A})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"RGB",{get:function(){return w.RGB({r:this.R,g:this.G,b:this.B})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"RGBA",{get:function(){return w.RGB({r:this.R,g:this.G,b:this.B,a:this.A})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HSL",{get:function(){return w.HSL({h:this.H,s:this.S,l:this.L})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HSLA",{get:function(){return w.HSL({h:this.H,s:this.S,l:this.L,a:this.A})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"CMYK",{get:function(){return w.CMYK({c:this.C,m:this.M,y:this.Y,k:this.K})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"CMYKA",{get:function(){return w.CMYK({c:this.C,m:this.M,y:this.Y,k:this.K,a:this.A})},enumerable:!1,configurable:!0}),ne.toHEX=function(oe,ce){ce===void 0&&(ce=!0);var ue=J(oe);return ct(oe,ue,ce,0,et.HEX,w.HEX)},ne.toHEXA=function(oe,ce){ce===void 0&&(ce=!0);var ue=J(oe);return ct(oe,ue,ce,0,et.HEXA,w.HEX)},ne.toRGB=function(oe,ce,ue){ce===void 0&&(ce=!0),ue===void 0&&(ue=6);var pe=J(oe);return ct(oe,pe,ce,ue,et.RGB,w.RGB)},ne.toRGBA=function(oe,ce,ue){ce===void 0&&(ce=!0),ue===void 0&&(ue=6);var pe=J(oe);return ct(oe,pe,ce,ue,et.RGBA,w.RGB)},ne.toHSL=function(oe,ce,ue){ce===void 0&&(ce=!0),ue===void 0&&(ue=6);var pe=J(oe);return ct(oe,pe,ce,ue,et.HSL,w.HSL)},ne.toHSLA=function(oe,ce,ue){ce===void 0&&(ce=!0),ue===void 0&&(ue=6);var pe=J(oe);return ct(oe,pe,ce,ue,et.HSLA,w.HSL)},ne.toCMYK=function(oe,ce,ue){ce===void 0&&(ce=!0),ue===void 0&&(ue=6);var pe=J(oe);return ct(oe,pe,ce,ue,et.CMYK,w.CMYK)},ne.toCMYKA=function(oe,ce,ue){ce===void 0&&(ce=!0),ue===void 0&&(ue=6);var pe=J(oe);return ct(oe,pe,ce,ue,et.CMYKA,w.CMYK)},ne.getBlendHEX=function(oe,ce,ue,pe,me){return ue===void 0&&(ue=5),pe===void 0&&(pe=!0),me===void 0&&(me=6),st(oe,ce,ue,pe,me,et.HEX,w.HEX)},ne.getBlendHEXA=function(oe,ce,ue,pe,me){return ue===void 0&&(ue=5),pe===void 0&&(pe=!0),me===void 0&&(me=6),st(oe,ce,ue,pe,me,et.HEXA,w.HEX)},ne.getBlendRGB=function(oe,ce,ue,pe,me){return ue===void 0&&(ue=5),pe===void 0&&(pe=!0),me===void 0&&(me=6),st(oe,ce,ue,pe,me,et.RGB,w.RGB)},ne.getBlendRGBA=function(oe,ce,ue,pe,me){return ue===void 0&&(ue=5),pe===void 0&&(pe=!0),me===void 0&&(me=6),st(oe,ce,ue,pe,me,et.RGBA,w.RGB)},ne.getBlendHSL=function(oe,ce,ue,pe,me){return ue===void 0&&(ue=5),pe===void 0&&(pe=!0),me===void 0&&(me=6),st(oe,ce,ue,pe,me,et.HSL,w.HSL)},ne.getBlendHSLA=function(oe,ce,ue,pe,me){return ue===void 0&&(ue=5),pe===void 0&&(pe=!0),me===void 0&&(me=6),st(oe,ce,ue,pe,me,et.HSLA,w.HSL)},ne.getMixHEX=function(oe,ce,ue){return ce===void 0&&(ce=i.ADDITIVE),ue===void 0&&(ue=!0),it.HEX(oe,ce,ue)},ne.getMixHEXA=function(oe,ce,ue){return ce===void 0&&(ce=i.ADDITIVE),ue===void 0&&(ue=!0),it.HEXA(oe,ce,ue)},ne.getMixRGB=function(oe,ce,ue,pe){return ce===void 0&&(ce=i.ADDITIVE),ue===void 0&&(ue=!0),pe===void 0&&(pe=6),it.RGB(oe,ce,ue,pe)},ne.getMixRGBA=function(oe,ce,ue,pe){return ce===void 0&&(ce=i.ADDITIVE),ue===void 0&&(ue=!0),pe===void 0&&(pe=6),it.RGBA(oe,ce,ue,pe)},ne.getMixHSL=function(oe,ce,ue,pe){return ce===void 0&&(ce=i.ADDITIVE),ue===void 0&&(ue=!0),pe===void 0&&(pe=6),it.HSL(oe,ce,ue,pe)},ne.getMixHSLA=function(oe,ce,ue,pe){return ce===void 0&&(ce=i.ADDITIVE),ue===void 0&&(ue=!0),pe===void 0&&(pe=6),it.HSLA(oe,ce,ue,pe)},ne.getShades=function(oe,ce,ue){return ue===void 0&&(ue=6),rt(oe,ce,!0,ue)},ne.getTints=function(oe,ce,ue){return ue===void 0&&(ue=6),rt(oe,ce,!1,ue)},ne.getHarmony=function(oe,ce,ue,pe){return ce===void 0&&(ce=n.COMPLEMENTARY),ue===void 0&&(ue=i.ADDITIVE),pe===void 0&&(pe=6),function(me,ge,ye,ve){var xe;return(xe={},xe[n.ANALOGOUS]=nt.buildHarmony(ge,U,ve,ye),xe[n.COMPLEMENTARY]=nt.buildHarmony(ge,q,ve,ye),xe[n.SPLIT_COMPLEMENTARY]=nt.buildHarmony(ge,$,ve,ye),xe[n.TRIADIC]=nt.buildHarmony(ge,_,ve,ye),xe[n.TETRADIC]=nt.buildHarmony(ge,Q,ve,ye),xe[n.SQUARE]=nt.buildHarmony(ge,z$1,ve,ye),xe)[me]}(ce,oe,pe,ue)},ne}();const defaultContext={current:void 0,parent:void 0,events:void 0,color:{source:2533018,destination:15753874,expanding:16733986,updating:16733986,generating:16771899,closing:11583173,end:15483002},scale:10,fill:"#000000",alpha:1};var earthRadius=63710088e-1,factors={centimeters:earthRadius*100,centimetres:earthRadius*100,degrees:earthRadius/111325,feet:earthRadius*3.28084,inches:earthRadius*39.37,kilometers:earthRadius/1e3,kilometres:earthRadius/1e3,meters:earthRadius,metres:earthRadius,miles:earthRadius/1609.344,millimeters:earthRadius*1e3,millimetres:earthRadius*1e3,nauticalmiles:earthRadius/1852,radians:1,yards:earthRadius*1.0936};function feature(ne,oe,ce){ce===void 0&&(ce={});var ue={type:"Feature"};return(ce.id===0||ce.id)&&(ue.id=ce.id),ce.bbox&&(ue.bbox=ce.bbox),ue.properties=oe||{},ue.geometry=ne,ue}function point(ne,oe,ce){if(ce===void 0&&(ce={}),!ne)throw new Error("coordinates is required");if(!Array.isArray(ne))throw new Error("coordinates must be an Array");if(ne.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!isNumber(ne[0])||!isNumber(ne[1]))throw new Error("coordinates must contain numbers");var ue={type:"Point",coordinates:ne};return feature(ue,oe,ce)}function lineString(ne,oe,ce){if(ce===void 0&&(ce={}),ne.length<2)throw new Error("coordinates must be an array of two or more positions");var ue={type:"LineString",coordinates:ne};return feature(ue,oe,ce)}function radiansToLength(ne,oe){oe===void 0&&(oe="kilometers");var ce=factors[oe];if(!ce)throw new Error(oe+" units is invalid");return ne*ce}function lengthToRadians(ne,oe){oe===void 0&&(oe="kilometers");var ce=factors[oe];if(!ce)throw new Error(oe+" units is invalid");return ne/ce}function degreesToRadians(ne){var oe=ne%360;return oe*Math.PI/180}function convertLength(ne,oe,ce){if(oe===void 0&&(oe="kilometers"),ce===void 0&&(ce="kilometers"),!(ne>=0))throw new Error("length must be a positive number");return radiansToLength(lengthToRadians(ne,oe),ce)}function isNumber(ne){return!isNaN(ne)&&ne!==null&&!Array.isArray(ne)}function getCoord(ne){if(!ne)throw new Error("coord is required");if(!Array.isArray(ne)){if(ne.type==="Feature"&&ne.geometry!==null&&ne.geometry.type==="Point")return ne.geometry.coordinates;if(ne.type==="Point")return ne.coordinates}if(Array.isArray(ne)&&ne.length>=2&&!Array.isArray(ne[0])&&!Array.isArray(ne[1]))return ne;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function featureOf(ne,oe,ce){if(!ne)throw new Error("No feature passed");if(!ce)throw new Error(".featureOf() requires a name");if(!ne||ne.type!=="Feature"||!ne.geometry)throw new Error("Invalid input to "+ce+", Feature with geometry required");if(!ne.geometry||ne.geometry.type!==oe)throw new Error("Invalid input to "+ce+": must be a "+oe+", given "+ne.geometry.type)}function distance(ne,oe,ce){ce===void 0&&(ce={});var ue=getCoord(ne),pe=getCoord(oe),me=degreesToRadians(pe[1]-ue[1]),ge=degreesToRadians(pe[0]-ue[0]),ye=degreesToRadians(ue[1]),ve=degreesToRadians(pe[1]),xe=Math.pow(Math.sin(me/2),2)+Math.pow(Math.sin(ge/2),2)*Math.cos(ye)*Math.cos(ve);return radiansToLength(2*Math.atan2(Math.sqrt(xe),Math.sqrt(1-xe)),ce.units)}function coordEach(ne,oe,ce){if(ne!==null)for(var ue,pe,me,ge,ye,ve,xe,_e=0,Se=0,$e,Re=ne.type,Ae=Re==="FeatureCollection",Ie=Re==="Feature",ke=Ae?ne.features.length:1,Be=0;Beve||Ae>xe||Ie>_e){ye=Se,ve=ue,xe=Ae,_e=Ie,me=0;return}var ke=lineString([ye,Se],ce.properties);if(oe(ke,ue,pe,Ie,me)===!1)return!1;me++,ye=Se})===!1)return!1}}})}function rhumbDistance(ne,oe,ce){ce===void 0&&(ce={});var ue=getCoord(ne),pe=getCoord(oe);pe[0]+=pe[0]-ue[0]>180?-360:ue[0]-pe[0]>180?360:0;var me=calculateRhumbDistance(ue,pe),ge=convertLength(me,"meters",ce.units);return ge}function calculateRhumbDistance(ne,oe,ce){ce=ce===void 0?earthRadius:Number(ce);var ue=ce,pe=ne[1]*Math.PI/180,me=oe[1]*Math.PI/180,ge=me-pe,ye=Math.abs(oe[0]-ne[0])*Math.PI/180;ye>Math.PI&&(ye-=2*Math.PI);var ve=Math.log(Math.tan(me/2+Math.PI/4)/Math.tan(pe/2+Math.PI/4)),xe=Math.abs(ve)>1e-11?ge/ve:Math.cos(pe),_e=Math.sqrt(ge*ge+xe*xe*ye*ye),Se=_e*ue;return Se}function pointToLineDistance(ne,oe,ce){if(ce===void 0&&(ce={}),ce.method||(ce.method="geodesic"),ce.units||(ce.units="kilometers"),!ne)throw new Error("pt is required");if(Array.isArray(ne)?ne=point(ne):ne.type==="Point"?ne=feature(ne):featureOf(ne,"Point","point"),!oe)throw new Error("line is required");Array.isArray(oe)?oe=lineString(oe):oe.type==="LineString"?oe=feature(oe):featureOf(oe,"LineString","line");var ue=1/0,pe=ne.geometry.coordinates;return segmentEach(oe,function(me){var ge=me.geometry.coordinates[0],ye=me.geometry.coordinates[1],ve=distanceToSegment(pe,ge,ye,ce);venew dt(ne).setA(oe??defaultContext.alpha).RGBA,getStrokeStyle=(ne,oe)=>getFillStyle(ne,oe);function transform(ne,oe){return{width:ne.width*oe.scale.x,height:ne.height*oe.scale.y,x:ne.x*oe.scale.x+oe.x,y:ne.y*oe.scale.y+oe.y}}const text={draw(ne,oe,ce){const ue=ne.label??ne.text;if(ue){const pe=transform(ne,{x:ne["label-x"]??ne.textX??0,y:ne["label-y"]??ne.textY??0,scale:{x:1,y:1}}),me=transform(pe,ce);oe.font=`${(ne["label-size"]??ne.fontSize??4)*ce.scale.x}px Inter`,oe.fillStyle=getFillStyle(ne["label-color"]??ne.fontColor??"grey",1),oe.fillText(ue,me.x,me.y)}},test(ne){return{left:-1/0,right:1/0,top:-1/0,bottom:1/0}},narrow(){return!0}},rect={draw(ne,oe,ce){const{x:ue,y:pe,width:me,height:ge}=transform(ne,ce);oe.fillStyle=getFillStyle(ne.fill,ne.alpha),oe.fillRect(ceil$1(ue),ceil$1(pe),ceil$1(me)||1,ceil$1(ge)||1)},test(ne){return{left:ne.x,right:ne.x+ne.width,top:ne.y,bottom:ne.y+ne.height}},narrow(){return!0}},circle={draw(ne,oe,ce){oe.fillStyle=getFillStyle(ne.fill,ne.alpha),oe.beginPath();const ue=transform({...ne,width:ne.radius,height:ne.radius},ce);oe.ellipse(ceil$1(ue.x),ceil$1(ue.y),ceil$1(ue.width),ceil$1(ue.height),0,0,2*PI),oe.fill()},test(ne){return{left:ne.x-ne.radius,right:ne.x+ne.radius,top:ne.y-ne.radius,bottom:ne.y+ne.radius}},narrow(){return!0}},polygon={draw(ne,oe,ce){const[ue,...pe]=ne.points;oe.beginPath(),oe.fillStyle=getFillStyle(ne.fill,ne.alpha);const{x:me,y:ge}=transform({...ue,width:0,height:0},ce);oe.moveTo(ceil$1(me),ceil$1(ge));for(const ye of pe){const{x:ve,y:xe}=transform({...ye,width:0,height:0},ce);oe.lineTo(ceil$1(ve),ceil$1(xe))}oe.closePath(),oe.fill()},test(ne){var oe,ce,ue,pe;return{left:((oe=lodashExports.minBy(ne.points,"x"))==null?void 0:oe.x)??0,right:((ce=lodashExports.maxBy(ne.points,"x"))==null?void 0:ce.x)??0,top:((ue=lodashExports.minBy(ne.points,"y"))==null?void 0:ue.y)??0,bottom:((pe=lodashExports.maxBy(ne.points,"y"))==null?void 0:pe.y)??0}},narrow(){return!0}},path={draw(ne,oe,ce){const[ue,...pe]=ne.points;oe.beginPath(),oe.lineCap="round",oe.lineJoin="round",oe.strokeStyle=getStrokeStyle(ne.fill,ne.alpha);const{x:me,y:ge,width:ye}=transform({...ue,width:ne["line-width"]??ne.lineWidth,height:0},ce);oe.lineWidth=ceil$1(ye),oe.moveTo(ceil$1(me),ceil$1(ge));for(const ve of pe){const{x:xe,y:_e}=transform({...ve,width:0,height:0},ce);oe.lineTo(ceil$1(xe),ceil$1(_e))}oe.stroke()},test(ne){var ce,ue,pe,me;const oe=ne["line-width"]??ne.lineWidth;return{left:(((ce=lodashExports.minBy(ne.points,"x"))==null?void 0:ce.x)??0-oe??0)-1,right:(((ue=lodashExports.maxBy(ne.points,"x"))==null?void 0:ue.x)??0+oe??0)+1,top:(((pe=lodashExports.minBy(ne.points,"y"))==null?void 0:pe.y)??0-oe??0)-1,bottom:(((me=lodashExports.maxBy(ne.points,"y"))==null?void 0:me.y)??0+oe??0)+1}},narrow(ne,oe){return pointToLineDistance(point([oe.x,oe.y]),lineString(ne.points.map(({x:ce,y:ue})=>[ce,ue])))<500*ne.lineWidth}},primitives={text,path,rect,polygon,circle};var rgb$1={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]},rgb=rgb$1;rgb.hsl=function(ne){var oe=ne[0]/255,ce=ne[1]/255,ue=ne[2]/255,pe=Math.min(oe,ce,ue),me=Math.max(oe,ce,ue),ge=me-pe,ye,ve,xe;return me===pe?ye=0:oe===me?ye=(ce-ue)/ge:ce===me?ye=2+(ue-oe)/ge:ue===me&&(ye=4+(oe-ce)/ge),ye=Math.min(ye*60,360),ye<0&&(ye+=360),xe=(pe+me)/2,me===pe?ve=0:xe<=.5?ve=ge/(me+pe):ve=ge/(2-me-pe),[ye,ve*100,xe*100]};const{log2,max:max$2}=Math,z=ne=>lodashExports.floor(log2(ne+1));function getTiles({right:ne,left:oe,bottom:ce,top:ue},pe){const me=max$2(z(ne-oe),z(ce-ue))-pe,ge=2**me,ye={left:lodashExports.floor(oe/ge),right:lodashExports.ceil((ne+1)/ge),top:lodashExports.floor(ue/ge),bottom:lodashExports.ceil((ce+1)/ge)};return{zoom:me,order:ge,tiles:lodashExports.shuffle(_default({x:lodashExports.range(ye.left,ye.right+1),y:lodashExports.range(ye.top,ye.bottom+1)}).map(ve=>{const xe=ve.x*ge,_e=ve.y*ge;return{tile:ve,bounds:{left:xe-ge/2,right:xe+ge/2,top:_e-ge/2,bottom:_e+ge/2}}}))}}const defaultBounds={top:0,left:0,right:1,bottom:1},isValue=ne=>lodashExports.isNumber(ne)&&!isNaN(ne),d2RendererWorkerUrl=""+new URL("D2Renderer.worker-32d1b7b8.js",import.meta.url).href;class D2RendererWorkerAdapter extends Worker{constructor(){super(d2RendererWorkerUrl,{type:"module"})}call(oe,ce,ue=[]){return this.postMessage({action:oe,payload:ce},ue)}on(oe,ce){const ue=pe=>{const{action:me,payload:ge}=pe.data;me===oe&&ce(ge)};return this.addEventListener("message",ue),()=>this.removeEventListener("message",ue)}}function intersect(ne,oe){return!(oe.left>=ne.right||oe.right<=ne.left||oe.top>=ne.bottom||oe.bottom<=ne.top)}const{max:max$1,min:min$1}=Math,_Tile=class K1 extends Sprite{constructor(oe,ce){super(oe),this.bounds=ce,this.destroying=!1,this.age=K1.age++}};_Tile.age=0;let Tile=_Tile;function handleNaN(ne,oe){return lodashExports.isNaN(ne)?oe:ne}var oa,wo,Bs,Ms,Fo,Wa,Ns,Fs,sd,ld,Z1,cd,Q1,Jl,td,ud,nd,dd,J1,hd,e0,fd,t0,pd,n0,rd,W1,od,q1,md,r0,ad,V1,gd,i0,yd,o0,bd,a0;class D2Renderer extends EventEmitter{constructor(){super(...arguments);ao(this,ld);ao(this,cd);ao(this,dd);ao(this,hd);ao(this,fd);ao(this,pd);ao(this,rd);ao(this,od);ao(this,md);ao(this,ad);ao(this,gd);ao(this,yd);ao(this,bd);ao(this,oa,void 0);ao(this,wo,void 0);ao(this,Bs,void 0);ao(this,Ms,void 0);ao(this,Fo,defaultD2RendererOptions);ao(this,Wa,[]);ao(this,Ns,new Bush(16));ao(this,Fs,void 0);ao(this,sd,0);ao(this,Jl,lodashExports.once(()=>lodashExports.debounce(()=>Ko(this,rd,W1).call(this),Vr(this,Fo).debounceInterval)));ao(this,td,lodashExports.once(()=>lodashExports.throttle(()=>Ko(this,od,q1).call(this),Vr(this,Fo).refreshInterval)));ao(this,ud,lodashExports.once(()=>lodashExports.throttle(ce=>Ko(this,md,r0).call(this,ce),Vr(this,Fo).refreshInterval)));ao(this,nd,lodashExports.once(()=>{if(typeof OffscreenCanvas>"u")return"OffscreenCanvas API is not supported by your system."}))}getInstance(){return{app:Vr(this,oa),viewport:Vr(this,wo)}}fitCamera(ce=lodashExports.constant(!0)){var pe,me,ge,ye;const ue=lodashExports.values(Vr(this,Ns).all()).flat().filter(ce);if(ue.length){const ve=lodashExports.reduce(ue,(xe,_e)=>({top:handleNaN(min$1(xe.top,_e.top),xe.top),left:handleNaN(min$1(xe.left,_e.left),xe.left),bottom:handleNaN(max$1(xe.bottom,_e.bottom),xe.bottom),right:handleNaN(max$1(xe.right,_e.right),xe.right)}),{bottom:-1/0,top:1/0,left:1/0,right:-1/0});(ye=(pe=Vr(this,wo))==null?void 0:pe.animate)==null||ye.call(pe,{position:new Point((ve.left+ve.right)/2,(ve.top+ve.bottom)/2),scale:((ge=(me=Vr(this,wo))==null?void 0:me.findFit)==null?void 0:ge.call(me,ve.right-ve.left,ve.bottom-ve.top))*.8,ease:"easeOutExpo",time:Vr(this,Fo).animationDuration*1.5,callbackOnComplete:()=>Vr(this,Jl).call(this)()})}}initialCamera(){var ce,ue;(ue=(ce=Vr(this,wo))==null?void 0:ce.animate)==null||ue.call(ce,{scale:1,ease:"easeOutExpo",time:Vr(this,Fo).animationDuration*1.5,callbackOnComplete:()=>Vr(this,Jl).call(this)()})}getView(){var ce;return(ce=Vr(this,oa))==null?void 0:ce.view}async toDataUrl(){var ce,ue,pe,me,ge;return(ue=(ce=Vr(this,oa))==null?void 0:ce.render)==null||ue.call(ce),(ge=(me=(pe=Vr(this,oa))==null?void 0:pe.view)==null?void 0:me.toDataURL)==null?void 0:ge.call(me)}setup(ce){if(Vr(this,nd).call(this))throw new Error(Vr(this,nd).call(this));const ue={...defaultD2RendererOptions,...ce};Ko(this,cd,Q1).call(this,ue),this.setOptions(ue),Ko(this,hd,e0).call(this,ue)}destroy(){lodashExports.map(Vr(this,Wa),ce=>ce.terminate()),Vr(this,oa).destroy()}add(ce){var me,ge;const ue=nanoid(),pe=ce.map(({component:ye,meta:ve})=>({...defaultBounds,...lodashExports.pickBy(primitives[ye.$].test(ye),isValue),component:ye,meta:ve,index:Ko(this,ld,Z1).call(this)}));return Vr(this,Ns).load(pe),(ge=(me=Vr(this,Wa))==null?void 0:me.forEach)==null||ge.call(me,ye=>ye.call("add",[ce,ue])),()=>requestIdleCallback(()=>{var ye,ve;for(const xe of pe)Vr(this,Ns).remove(xe);(ve=(ye=Vr(this,Wa))==null?void 0:ye.forEach)==null||ve.call(ye,xe=>xe.call("remove",[ue]))},{timeout:Vr(this,Fo).animationDuration})}setOptions(ce){const ue={...Vr(this,Fo),...ce};Ko(this,fd,t0).call(this,ue),Os(this,Fo,ue),Ko(this,rd,W1).call(this),Ko(this,od,q1).call(this)}}oa=new WeakMap,wo=new WeakMap,Bs=new WeakMap,Ms=new WeakMap,Fo=new WeakMap,Wa=new WeakMap,Ns=new WeakMap,Fs=new WeakMap,sd=new WeakMap,ld=new WeakSet,Z1=function(){return Y1(this,sd)._++},cd=new WeakSet,Q1=function(ce){Os(this,oa,new Application({backgroundAlpha:0,width:ce.screenSize.width,height:ce.screenSize.height,autoDensity:!0,resolution:2})),Os(this,wo,new ht({stopPropagation:!0,screenWidth:ce.screenSize.width,screenHeight:ce.screenSize.height,events:Vr(this,oa).renderer.events,passiveWheel:!1})),Vr(this,wo).on("clicked",ue=>{const{x:pe,y:me}=ue.world,ge=Vr(this,Ns).search({minX:pe,minY:me,maxX:pe+Number.MIN_VALUE,maxY:me+Number.MIN_VALUE}).filter(ye=>primitives[ye.component.$].narrow(ye.component,{x:pe,y:me}));this.emit("click",ue.event,{world:ue.world,components:ge})}),Vr(this,oa).stage.addChild(Vr(this,wo)),Vr(this,wo).drag().pinch().wheel().decelerate({friction:.98}).clampZoom({maxScale:300,minScale:1e-5}),Vr(this,wo).on("moved",()=>{Vr(this,Jl).call(this)(),Vr(this,td).call(this)()}),Vr(this,wo).on("mousemove",ue=>Vr(this,ud).call(this)(ue)),Os(this,Bs,new Container),Vr(this,wo).addChild(Vr(this,Bs)),Os(this,Ms,new Graphics),Vr(this,wo).addChild(Vr(this,Ms)),Os(this,Fs,new Graphics),Vr(this,wo).addChild(Vr(this,Fs)),Ko(this,dd,J1).call(this)},Jl=new WeakMap,td=new WeakMap,ud=new WeakMap,nd=new WeakMap,dd=new WeakSet,J1=function(){const{dynamicResolution:ce}=Vr(this,Fo),{dtMax:ue,dtMin:pe,increment:me,intervalMs:ge,maxScale:ye,minScale:ve}=ce,xe=lodashExports.floor(Ticker.targetFPMS*ge);let _e=0,Se=0,$e=1;Vr(this,oa).ticker.add(Re=>{const{tileResolution:Ae}=Vr(this,Fo);if(!(_e%xe)){const Ie=Se/xe;$e=lodashExports.clamp(Ie>=ue?$e+me:Ie<=pe?$e-me:$e,ve,ye),lodashExports.map(Vr(this,Wa),ke=>{ke.call("setTileResolution",[{width:lodashExports.ceil(Ae.width/$e),height:lodashExports.ceil(Ae.height/$e)}])}),Se=0}Se+=Re,_e++})},hd=new WeakSet,e0=function(ce){lodashExports.map(Vr(this,Wa),ue=>ue.terminate()),Os(this,Wa,lodashExports.times(ce.workerCount,ue=>{const pe=new D2RendererWorkerAdapter;return pe.on("update",me=>Ko(this,pd,n0).call(this,me)),pe.onerror=me=>{throw me},pe.call("setup",[{...ce,workerIndex:ue}]),pe}))},fd=new WeakSet,t0=function(ce){var me,ge,ye,ve;const{width:ue,height:pe}=ce.screenSize;(ye=(ge=(me=Vr(this,oa))==null?void 0:me.renderer)==null?void 0:ge.resize)==null||ye.call(ge,ue,pe),(ve=Vr(this,wo))==null||ve.resize(ue,pe),lodashExports.map(Vr(this,Wa),xe=>{xe.call("setTileResolution",[{width:lodashExports.ceil(ce.tileResolution.width),height:lodashExports.ceil(ce.tileResolution.height)}])})},pd=new WeakSet,n0=function({bounds:ce,bitmap:ue}){const pe=Texture.from(ue);Ko(this,gd,i0).call(this,pe,ce)},rd=new WeakSet,W1=function(){const{top:ce,bottom:ue,left:pe,right:me}=Vr(this,wo);lodashExports.map(Vr(this,Wa),ge=>ge.call("setFrustum",[{top:ce,bottom:ue,left:pe,right:me}]))},od=new WeakSet,q1=function(){var ge,ye,ve,xe,_e;const{tileSubdivision:ce,accentColor:ue}=Vr(this,Fo),{tiles:pe}=getTiles(Vr(this,wo),ce),me=Ko(this,ad,V1).call(this);(ge=Vr(this,Ms))==null||ge.clear(),(ye=Vr(this,Ms))==null||ye.lineStyle(1*me,ue,.5),(ve=Vr(this,Ms))==null||ve.beginFill(ue,.05);for(const{bounds:Se}of pe)lodashExports.find((xe=Vr(this,Bs))==null?void 0:xe.children,$e=>lodashExports.isEqual($e.bounds,Se))||(_e=Vr(this,Ms))==null||_e.drawRect(Se.left,Se.top,Se.right-Se.left,Se.bottom-Se.top)},md=new WeakSet,r0=function(ce){var ve;const{accentColor:ue}=Vr(this,Fo),pe=Ko(this,ad,V1).call(this),{x:me,y:ge}=Vr(this,wo).toWorld(ce.globalX,ce.globalY),ye=Vr(this,Ns).search({minX:me,minY:ge,maxX:me+Number.MIN_VALUE,maxY:ge+Number.MIN_VALUE}).filter(xe=>primitives[xe.component.$].narrow(xe.component,{x:me,y:ge}));Vr(this,Fs).clear();for(const xe of ye)Vr(this,Fs).lineStyle(2*pe,ue,"$info"in xe.component?1:.02),(ve=Vr(this,Fs))==null||ve.drawRect(xe.left,xe.top,xe.right-xe.left,xe.bottom-xe.top)},ad=new WeakSet,V1=function(){const{right:ce,left:ue}=Vr(this,wo),{width:pe}=Vr(this,Fo).screenSize;return(ce-ue)/pe},gd=new WeakSet,i0=async function(ce,ue){var ge,ye;const{tileSubdivision:pe}=Vr(this,Fo),{tiles:me}=getTiles(Vr(this,wo),pe);if(lodashExports.find(me,ve=>lodashExports.isEqual(ve.bounds,ue))){const ve={x:(ue.right-ue.left)/ce.width,y:(ue.bottom-ue.top)/ce.height},xe=new Tile(ce,ue);(ge=Vr(this,Bs))==null||ge.addChild(xe).setTransform(ue.left,ue.top,ve.x,ve.y),Vr(this,td).call(this)(),await Ko(this,yd,o0).call(this,xe),lodashExports.forEach((ye=Vr(this,Bs))==null?void 0:ye.children,async _e=>{intersect(_e.bounds,ue)&&_e.age{const me=ge=>{ce.alpha+=ge/Ticker.targetFPMS/Vr(this,Fo).animationDuration,ce.alpha>1&&(ue.remove(me),pe())};ce.alpha=0,ue.add(me)})},bd=new WeakSet,a0=function(ce){const ue=Vr(this,oa).ticker;return new Promise(pe=>{const me=ge=>{ce.alpha-=ge/Ticker.targetFPMS/Vr(this,Fo).animationDuration,ce.alpha<0&&(ue.remove(me),pe())};ce.alpha=1,ue.add(me)})};const D2Renderer$1=makeRenderer(D2Renderer,{components:["rect","circle","path","polygon"],id:"d2-renderer",name:"Pixel",description:"Comfortably performant 2D renderer",version:"1.0.0"}),renderers={"d2-renderer":D2Renderer$1};class NativeRendererTransport{constructor(oe){this.options=oe}async get(){const{hostname:oe}=url$2(this.options.url);return renderers[oe]}}const transports={native:{name:"Internal",constructor:NativeRendererTransport}};function RendererService(){const[{renderer:ne}]=useSettings(),[,oe]=useRenderers();return useAsync(async()=>{const ce=[];for(const{transport:ue,url:pe,key:me,disabled:ge}of ne??[])if(!ge){const ye=new transports[ue].constructor({url:pe});ce.push({key:me,url:pe,renderer:await ye.get()})}oe(()=>ce)},[JSON.stringify(ne),oe]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})}const statusColor$1={connected:"success.light",connecting:"warning.light",error:"error.light",disabled:"text.disabled"};function RendererEditor({value:ne,onValueChange:oe}){const[ce]=useRenderers(),ue=usePaper(),pe=lodashExports$1.find(ce,{key:ne.key});function me(ye){oe==null||oe(merge$4(ne,ye))}const ge=ne!=null&&ne.disabled?"disabled":pe?"connected":"error";return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Flex,{alignItems:"center",py:1,children:jsxRuntimeExports.jsx(ManagedModal,{slotProps:{paper:{sx:{width:480}},popover:{anchorOrigin:{horizontal:-18,vertical:"bottom"}}},popover:!0,trigger:ye=>{var ve;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(Box$1,{className:ne.key,onClick:ye,flex:1,sx:{width:0,overflow:"hidden","> *":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",children:pe?`${pe.renderer.meta.name} ${pe.renderer.meta.version}`:lodashExports$1.startCase(ge)}),!!pe&&jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"body2",color:"text.secondary",children:jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{children:pe.renderer.meta.description}),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsxs("span",{children:["Contributes"," ",lodashExports$1.join(pe.renderer.meta.components,", ")]})]})}),jsxRuntimeExports.jsxs(Type$2,{component:"div",variant:"body2",color:"text.secondary",children:[(ve=transports[ne==null?void 0:ne.transport])==null?void 0:ve.name,": ",(ne==null?void 0:ne.url)||"No URL"]})]}),jsxRuntimeExports.jsx(Chip$1,{sx:{minWidth:0,maxWidth:"fit-content",flex:1,mx:1,color:statusColor$1[ge],...lodashExports$1.omit(ue(1),"borderRadius")},size:"small",label:lodashExports$1.startCase(ge)}),jsxRuntimeExports.jsx(Tooltip$1,{title:`${ne.disabled?"Enable":"Disable"} Renderer`,children:jsxRuntimeExports.jsx(Box$1,{mr:-3,children:jsxRuntimeExports.jsx(Switch$2,{checked:!ne.disabled,onChange:(xe,_e)=>me({disabled:!_e})})})})]})},appBar:{children:jsxRuntimeExports.jsx(AppBarTitle,{children:"Edit Renderer"})},children:jsxRuntimeExports.jsxs(Box$1,{p:2.5,children:[jsxRuntimeExports.jsx(TextField$1,{autoFocus:!0,defaultValue:ne.url,onChange:ye=>me({url:ye.target.value}),fullWidth:!0,variant:"filled",label:"URL",sx:{mb:2}}),jsxRuntimeExports.jsx(SelectField,{placeholder:"Renderer Type",items:lodashExports$1.entries(transports).map(([ye,{name:ve}])=>({value:ye,label:ve})),fullWidth:!0,value:ne.transport,onChange:ye=>me({transport:ye})})]})})})})}function RendererListEditor(){const[{renderer:ne},oe]=useSettings();return jsxRuntimeExports.jsx(Box$1,{sx:{mx:-2},children:jsxRuntimeExports.jsx(ListEditor,{sortable:!0,editor:ce=>jsxRuntimeExports.jsx(RendererEditor,{value:ce}),icon:null,value:ne,onChange:lodashExports$1.debounce(ce=>oe(()=>({renderer:ce})),300),addItemLabel:"Add renderer",create:()=>({transport:defaultTransport,url:"",disabled:!0}),addItemExtras:jsxRuntimeExports.jsx(FeaturePickerButton,{icon:jsxRuntimeExports.jsx(ResetIcon,{}),onClick:()=>oe(()=>({renderer:defaultRenderers})),children:"Reset"}),onFocus:ce=>{const ue=lodashExports$1.head(document.getElementsByClassName(ce));ue&&"click"in ue&&typeof ue.click=="function"&&ue.click()}})})}function useConnectionStatus(ne){const[{connections:oe}]=useLoading(),ce=useConnectionResolver(),[{remote:ue}]=useSettings(),pe=lodashExports$1.find(ue,{url:ne});return pe&&!(pe!=null&&pe.disabled)?ce({url:ne})?"connected":oe?"connecting":ne?"error":"not-connected":"not-connected"}const statusColor={connected:"success.light",connecting:"warning.light",error:"error.light","not-connected":"text.disabled"};function ServerEditor({value:ne,onValueChange:oe}){const ce=useConnection(ne.url),ue=usePaper(),pe=useConnectionStatus(ne.url),me=reactExports.useMemo(()=>debounce$2(ge=>{oe==null||oe(merge$4(ne,ge))},300),[oe,ne]);return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Flex,{alignItems:"center",children:jsxRuntimeExports.jsx(ManagedModal,{slotProps:{paper:{sx:{width:480}},popover:{anchorOrigin:{horizontal:-18,vertical:"bottom"}}},popover:!0,trigger:ge=>{var ye;return jsxRuntimeExports.jsxs(Stack$1,{direction:"row",flex:1,alignItems:"center",sx:{py:1,mr:-3},children:[jsxRuntimeExports.jsxs(Stack$1,{className:ne.key,direction:"row",flex:1,alignItems:"center",onClick:ge,children:[jsxRuntimeExports.jsxs(Box$1,{flex:1,sx:{width:0,overflow:"hidden","> *":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",children:ce?`${ce.name} ${ce.version}`:lodashExports$1.startCase(pe)}),!!(ce!=null&&ce.description)&&jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"body2",color:"text.secondary",children:ce.description}),jsxRuntimeExports.jsxs(Type$2,{component:"div",variant:"body2",color:"text.secondary",children:[(ye=transports$1[ne==null?void 0:ne.transport])==null?void 0:ye.name,": ",(ne==null?void 0:ne.url)||"No URL"]})]}),jsxRuntimeExports.jsx(Chip$1,{sx:{flex:1,minWidth:0,maxWidth:"fit-content",mx:1,color:statusColor[pe],...lodashExports$1.omit(ue(1),"borderRadius")},size:"small",label:lodashExports$1.startCase(pe)})]}),jsxRuntimeExports.jsx(Tooltip$1,{title:`${ne.disabled?"Enable":"Disable"} adapter`,children:jsxRuntimeExports.jsx(Box$1,{children:jsxRuntimeExports.jsx(Switch$2,{defaultChecked:!ne.disabled,onChange:(ve,xe)=>me({disabled:!xe})})})})]})},appBar:{children:jsxRuntimeExports.jsx(AppBarTitle,{children:"Edit Adapter"})},children:jsxRuntimeExports.jsxs(Box$1,{p:2.5,children:[jsxRuntimeExports.jsx(TextField$1,{autoFocus:!0,defaultValue:ne.url,onChange:ge=>me({url:ge.target.value}),fullWidth:!0,variant:"filled",label:"URL",sx:{mb:2}}),jsxRuntimeExports.jsx(SelectField,{placeholder:"Connection Type",items:lodashExports$1.entries(transports$1).map(([ge,{name:ye}])=>({value:ge,label:ye})),fullWidth:!0,value:ne.transport,onChange:ge=>me({transport:ge})})]})})})})}function ServerListEditor(){const[{remote:ne},oe]=useSettings();return jsxRuntimeExports.jsx(Box$1,{sx:{mx:-2},children:jsxRuntimeExports.jsx(ListEditor,{sortable:!0,editor:ce=>jsxRuntimeExports.jsx(ServerEditor,{value:ce}),icon:null,value:ne,onChange:lodashExports$1.debounce(ce=>oe(()=>({remote:ce})),300),addItemLabel:"Add adapter",create:()=>({transport:defaultTransport,url:"",disabled:!0}),addItemExtras:jsxRuntimeExports.jsx(FeaturePickerButton,{icon:jsxRuntimeExports.jsx(ResetIcon,{}),onClick:()=>oe(()=>({remote:defaultRemotes})),children:"Reset"}),onFocus:ce=>{const ue=lodashExports$1.head(document.getElementsByClassName(ce));ue&&"click"in ue&&typeof ue.click=="function"&&ue.click()}})})}const logo$1=""+new URL("logo512-23eace97.png",import.meta.url).href,contacts=[{name:"Dr Daniel Harabor",email:"daniel.harabor@monash.edu"},{name:"Dr Michael Wybrow",email:"michael.wybrow@monash.edu"},{name:"Kevin Zheng",email:"kevin.zheng@monash.edu"},{name:"Francis Anthony",email:"fant0003@student.monash.edu"},{name:"Karan Batta",email:"krnbatta@gmail.com"},{name:"Jay Wingate",email:"jaypeterwingate@gmail.com"},{name:"Leo Whitehead",email:"leo@whiteheadsoftware.dev"},{name:"Can Wang",email:"camwang@outlook.com"},{name:"Rory Tobin-Underwood",email:"rorytu@gmail.com"}];function parseUrl(ne){const oe=new URL(ne);return lodashExports$1.trimEnd(`${oe.hostname}${oe.pathname}`,"/")}function AboutContent(){function ne(oe,ce){return jsxRuntimeExports.jsxs(Box$1,{sx:{pt:2},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"overline",color:"text.secondary",children:oe}),jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"body2",children:ce})]})}return jsxRuntimeExports.jsxs(Box$1,{children:[jsxRuntimeExports.jsx(Box$1,{sx:{pt:0,pb:2},children:jsxRuntimeExports.jsx("img",{src:logo$1,height:"64"})}),jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"h6",children:name}),ne("Build Info",jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:version_name})),ne("Team",jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(List$2,{sx:{mx:-2},children:contacts.map(({name:oe,email:ce},ue)=>jsxRuntimeExports.jsxs(ListItemButton$1,{href:`mailto:${ce}`,children:[jsxRuntimeExports.jsx(ListItemAvatar$1,{children:jsxRuntimeExports.jsx(Avatar$1,{children:lodashExports$1.head(oe)})}),jsxRuntimeExports.jsx(ListItemText$1,{primary:oe,secondary:ce})]},ue))})})),ne("Resources",jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs(List$2,{sx:{mx:-2},children:[jsxRuntimeExports.jsxs(ListItemButton$1,{target:"_blank",href:homepage,children:[jsxRuntimeExports.jsx(ListItemAvatar$1,{children:jsxRuntimeExports.jsx(Avatar$1,{sx:{width:24,height:24},src:logo$1})}),jsxRuntimeExports.jsx(ListItemText$1,{primary:"Home",secondary:parseUrl(homepage)})]}),jsxRuntimeExports.jsxs(ListItemButton$1,{target:"_blank",href:repository,children:[jsxRuntimeExports.jsx(ListItemIcon$1,{children:jsxRuntimeExports.jsx(GitHub,{})}),jsxRuntimeExports.jsx(ListItemText$1,{primary:"Repository",secondary:parseUrl(repository)})]})]})}))]})}const formatLabel=ne=>`${ne}x`;function SettingsPage({template:ne}){const{controls:oe,onChange:ce,state:ue,dragHandle:pe}=useViewTreeContext(),me=useSmallDisplay(),[ge,ye]=useUIState(),ve=useSnackbar(),xe=useBusyState("reset"),[{"playback/playbackRate":_e=1,"appearance/acrylic":Se,"appearance/theme":$e="light","appearance/accentColor":Re="teal","behaviour/showOnStart":Ae},Ie]=useSettings(),[ke,Be]=reactExports.useState("general");function Ne(Ue){return jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"overline",color:"text.secondary",children:Ue})}function Fe(Ue){return jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"body1",sx:{mr:4,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:Ue})}return jsxRuntimeExports.jsx(TabContext,{value:ke,children:jsxRuntimeExports.jsxs(ne,{onChange:ce,stack:ue,children:[jsxRuntimeExports.jsx(ne.Key,{children:"settings"}),jsxRuntimeExports.jsx(ne.Title,{children:"Settings"}),jsxRuntimeExports.jsx(ne.Handle,{children:pe}),jsxRuntimeExports.jsx(ne.Options,{children:jsxRuntimeExports.jsxs(TabList$1,{onChange:(Ue,We)=>Be(We),children:[jsxRuntimeExports.jsx(Tab$1,{label:"General",value:"general"}),jsxRuntimeExports.jsx(Tab$1,{label:"Extensions",value:"connections"}),jsxRuntimeExports.jsx(Tab$1,{label:"Security",value:"security"}),jsxRuntimeExports.jsx(Tab$1,{label:"About",value:"about"})]})}),jsxRuntimeExports.jsx(ne.Content,{children:jsxRuntimeExports.jsx(Flex,{vertical:!0,children:jsxRuntimeExports.jsx(Scroll,{y:!0,children:jsxRuntimeExports.jsxs(Flex,{vertical:!0,pt:6,children:[jsxRuntimeExports.jsx(TabPanel$1,{value:"general",sx:{p:2},children:jsxRuntimeExports.jsxs(Box$1,{children:[Ne("Playback"),jsxRuntimeExports.jsxs(Flex,{alignItems:"center",justifyContent:"space-between",children:[Fe("Playback rate"),jsxRuntimeExports.jsx(Slider$1,{sx:{maxWidth:320,mr:2},marks:[1,2,5,10].map(Ue=>({value:Ue*defaultPlaybackRate,label:formatLabel(Ue)})),step:1*defaultPlaybackRate,min:1*defaultPlaybackRate,max:10*defaultPlaybackRate,valueLabelFormat:Ue=>formatLabel(Ue/defaultPlaybackRate),valueLabelDisplay:"auto",defaultValue:_e,onChangeCommitted:(Ue,We)=>Ie(()=>({"playback/playbackRate":We}))})]}),Ne("Appearance"),jsxRuntimeExports.jsxs(Flex,{alignItems:"center",justifyContent:"space-between",children:[Fe("Acrylic"),jsxRuntimeExports.jsx(Switch$2,{defaultChecked:!!Se,onChange:(Ue,We)=>Ie(()=>({"appearance/acrylic":We}))})]}),jsxRuntimeExports.jsxs(Flex,{alignItems:"center",justifyContent:"space-between",children:[Fe("Dark mode"),jsxRuntimeExports.jsx(Space,{flex:1}),jsxRuntimeExports.jsx(Switch$2,{defaultChecked:$e==="dark",onChange:(Ue,We)=>Ie(()=>({"appearance/theme":We?"dark":"light"}))})]}),jsxRuntimeExports.jsxs(Flex,{alignItems:"center",justifyContent:"space-between",children:[Fe("Accent"),jsxRuntimeExports.jsx(Box$1,{sx:{p:1},children:jsxRuntimeExports.jsx(FeaturePicker,{paper:!0,value:Re,items:lodashExports$1.map(shades,Ue=>({id:Ue,name:lodashExports$1.startCase(Ue),icon:jsxRuntimeExports.jsx(Box$1,{children:jsxRuntimeExports.jsx(Box$1,{sx:{ml:.5,width:12,height:12,backgroundColor:getShade(Ue,$e),borderRadius:4}})})})),arrow:!0,onChange:Ue=>Ie(()=>({"appearance/accentColor":Ue}))})})]}),Ne("Behaviour"),jsxRuntimeExports.jsxs(Flex,{alignItems:"center",justifyContent:"space-between",children:[Fe("Show explore on start-up"),jsxRuntimeExports.jsx(Switch$2,{defaultChecked:!!Ae,onChange:(Ue,We)=>Ie(()=>({"behaviour/showOnStart":We?"explore":void 0}))})]}),Ne("Advanced"),jsxRuntimeExports.jsxs(Flex,{alignItems:"center",justifyContent:"space-between",children:[Fe("Reset settings and extensions"),jsxRuntimeExports.jsx(ManagedModal,{trigger:Ue=>jsxRuntimeExports.jsx(Button,{sx:{mx:1},color:"error",startIcon:jsxRuntimeExports.jsx(RestartAltOutlined,{}),onClick:Ue,children:"Reset now"}),appBar:{children:jsxRuntimeExports.jsx(AppBarTitle,{children:"Reset settings and extensions"})},children:({close:Ue})=>jsxRuntimeExports.jsxs(Stack$1,{sx:{p:me?2:3,pt:2,gap:4},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",color:"text.secondary",children:"If something's not working correctly, you can try to reset all settings and extensions. This cannot be undone."}),jsxRuntimeExports.jsxs(Stack$1,{direction:"row",justifyContent:"flex-end",gap:2,children:[jsxRuntimeExports.jsx(Button,{variant:"text",onClick:()=>{Ue()},children:"Cancel"}),jsxRuntimeExports.jsx(Button,{onClick:()=>{xe(async()=>{await wait(300),Ie(()=>defaults$3),Ue(),ye(()=>({sidebarOpen:!1,fullscreenModal:void 0})),ve("Reset complete")},"Resetting settings and extensions")},color:"error",startIcon:jsxRuntimeExports.jsx(RestartAltOutlined,{}),children:"Reset settings and extensions"})]})]})})]})]})}),jsxRuntimeExports.jsxs(TabPanel$1,{value:"connections",sx:{p:2},children:[jsxRuntimeExports.jsxs(Box$1,{children:[Ne("Adapters"),jsxRuntimeExports.jsx(ServerListEditor,{})]}),jsxRuntimeExports.jsxs(Box$1,{children:[jsxRuntimeExports.jsx(Divider$1,{sx:{mb:2}}),Ne("Renderers"),jsxRuntimeExports.jsx(RendererListEditor,{})]}),jsxRuntimeExports.jsxs(Box$1,{children:[jsxRuntimeExports.jsx(Divider$1,{sx:{mb:2}}),Ne("Map support"),jsxRuntimeExports.jsx(MapParserListEditor,{})]})]}),jsxRuntimeExports.jsxs(TabPanel$1,{value:"security",sx:{p:2},children:[Ne("Trusted origins"),jsxRuntimeExports.jsxs(Box$1,{sx:{maxWidth:480},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",color:"text.secondary",variant:"caption",sx:{pt:2},children:"Rendering traces in the viewport and using advanced debugger features sometimes requires running third-party code."}),jsxRuntimeExports.jsx(Type$2,{component:"div",color:"text.secondary",variant:"caption",sx:{pt:2},children:"You'll be prompted to add origins when necessary, and you can stop trusting origins by removing them from this list."})]}),jsxRuntimeExports.jsx(Box$1,{sx:{pt:2},children:jsxRuntimeExports.jsx(TrustedOriginListEditor,{})})]}),jsxRuntimeExports.jsx(TabPanel$1,{value:"about",sx:{p:2},children:jsxRuntimeExports.jsx(Box$1,{children:jsxRuntimeExports.jsx(AboutContent,{})})})]})})})}),jsxRuntimeExports.jsx(ne.Extras,{children:oe})]})})}const a=lodashExports$1.keys(mapParsers).map(ne=>({key:ne}));function Sink({children:ne}){return ne}function TrustedOriginListEditor(){const[{trustedOrigins:ne},oe]=useSettings(),ce=reactExports.useMemo(()=>lodashExports$1.map(ne,ue=>({key:ue})),[ne]);return jsxRuntimeExports.jsx(Box$1,{sx:{mx:-2},children:jsxRuntimeExports.jsx(ListEditor,{button:!1,sortable:!0,addable:!1,deletable:!0,editor:ue=>jsxRuntimeExports.jsx(Sink,{children:jsxRuntimeExports.jsx(ListItemText$1,{primary:ue.key})},ue.key),icon:null,value:ce,onChange:lodashExports$1.debounce(ue=>oe(()=>({trustedOrigins:lodashExports$1.map(ue,"key")})),300),create:()=>({key:""})})})}function MapParserListEditor(){return jsxRuntimeExports.jsx(Box$1,{sx:{mx:-2},children:jsxRuntimeExports.jsx(ListEditor,{button:!1,sortable:!0,addable:!1,deletable:!1,editor:ne=>jsxRuntimeExports.jsx(Sink,{children:jsxRuntimeExports.jsx(ListItemText$1,{primary:lodashExports$1.startCase(ne.key),secondary:`Support for *.${ne.key} maps`})},ne.key),icon:null,value:a,create:()=>({key:""})})})}const PUBLISH=0,SUBSCRIBE=1,RESET=2,VALUE=4;function compose(ne,oe){return ce=>ne(oe(ce))}function thrush(ne,oe){return oe(ne)}function curry2to1(ne,oe){return ce=>ne(oe,ce)}function curry1to0(ne,oe){return()=>ne(oe)}function tap(ne,oe){return oe(ne),ne}function tup(...ne){return ne}function call(ne){ne()}function always(ne){return()=>ne}function joinProc(...ne){return()=>{ne.map(call)}}function isDefined(ne){return ne!==void 0}function noop$4(){}function subscribe(ne,oe){return ne(SUBSCRIBE,oe)}function publish(ne,oe){ne(PUBLISH,oe)}function reset(ne){ne(RESET)}function getValue(ne){return ne(VALUE)}function connect(ne,oe){return subscribe(ne,curry2to1(oe,PUBLISH))}function handleNext(ne,oe){const ce=ne(SUBSCRIBE,ue=>{ce(),oe(ue)});return ce}function stream(){const ne=[];return(oe,ce)=>{switch(oe){case RESET:ne.splice(0,ne.length);return;case SUBSCRIBE:return ne.push(ce),()=>{const ue=ne.indexOf(ce);ue>-1&&ne.splice(ue,1)};case PUBLISH:ne.slice().forEach(ue=>{ue(ce)});return;default:throw new Error(`unrecognized action ${oe}`)}}}function statefulStream(ne){let oe=ne;const ce=stream();return(ue,pe)=>{switch(ue){case SUBSCRIBE:pe(oe);break;case PUBLISH:oe=pe;break;case VALUE:return oe}return ce(ue,pe)}}function eventHandler(ne){let oe,ce;const ue=()=>oe&&oe();return function(pe,me){switch(pe){case SUBSCRIBE:return me?ce===me?void 0:(ue(),ce=me,oe=subscribe(ne,me),oe):(ue(),noop$4);case RESET:ue(),ce=null;return;default:throw new Error(`unrecognized action ${pe}`)}}}function streamFromEmitter(ne){return tap(stream(),oe=>connect(ne,oe))}function statefulStreamFromEmitter(ne,oe){return tap(statefulStream(oe),ce=>connect(ne,ce))}function combineOperators(...ne){return oe=>ne.reduceRight(thrush,oe)}function pipe(ne,...oe){const ce=combineOperators(...oe);return(ue,pe)=>{switch(ue){case SUBSCRIBE:return subscribe(ne,ce(pe));case RESET:reset(ne);return}}}function defaultComparator(ne,oe){return ne===oe}function distinctUntilChanged(ne=defaultComparator){let oe;return ce=>ue=>{ne(oe,ue)||(oe=ue,ce(ue))}}function filter(ne){return oe=>ce=>{ne(ce)&&oe(ce)}}function map$1(ne){return oe=>compose(oe,ne)}function mapTo(ne){return oe=>()=>oe(ne)}function scan(ne,oe){return ce=>ue=>ce(oe=ne(oe,ue))}function skip(ne){return oe=>ce=>{ne>0?ne--:oe(ce)}}function throttleTime(ne){let oe=null,ce;return ue=>pe=>{oe=pe,!ce&&(ce=setTimeout(()=>{ce=void 0,ue(oe)},ne))}}function debounceTime(ne){let oe,ce;return ue=>pe=>{oe=pe,ce&&clearTimeout(ce),ce=setTimeout(()=>{ue(oe)},ne)}}function withLatestFrom(...ne){const oe=new Array(ne.length);let ce=0,ue=null;const pe=Math.pow(2,ne.length)-1;return ne.forEach((me,ge)=>{const ye=Math.pow(2,ge);subscribe(me,ve=>{const xe=ce;ce=ce|ye,oe[ge]=ve,xe!==pe&&ce===pe&&ue&&(ue(),ue=null)})}),me=>ge=>{const ye=()=>me([ge].concat(oe));ce===pe?ye():ue=ye}}function merge(...ne){return function(oe,ce){switch(oe){case SUBSCRIBE:return joinProc(...ne.map(ue=>subscribe(ue,ce)));case RESET:return;default:throw new Error(`unrecognized action ${oe}`)}}}function duc(ne,oe=defaultComparator){return pipe(ne,distinctUntilChanged(oe))}function combineLatest(...ne){const oe=stream(),ce=new Array(ne.length);let ue=0;const pe=Math.pow(2,ne.length)-1;return ne.forEach((me,ge)=>{const ye=Math.pow(2,ge);subscribe(me,ve=>{ce[ge]=ve,ue=ue|ye,ue===pe&&publish(oe,ce)})}),function(me,ge){switch(me){case SUBSCRIBE:return ue===pe&&ge(ce),subscribe(oe,ge);case RESET:return reset(oe);default:throw new Error(`unrecognized action ${me}`)}}}function system(ne,oe=[],{singleton:ce}={singleton:!0}){return{id:id(),constructor:ne,dependencies:oe,singleton:ce}}const id=()=>Symbol();function init(ne){const oe=new Map,ce=({id:ue,constructor:pe,dependencies:me,singleton:ge})=>{if(ge&&oe.has(ue))return oe.get(ue);const ye=pe(me.map(ve=>ce(ve)));return ge&&oe.set(ue,ye),ye};return ce(ne)}function omit(ne,oe){const ce={},ue={};let pe=0;const me=ne.length;for(;pe(Ne[Fe]=Ue=>{const We=Be[oe.methods[Fe]];publish(We,Ue)},Ne),{})}function _e(Be){return ge.reduce((Ne,Fe)=>(Ne[Fe]=eventHandler(Be[oe.events[Fe]]),Ne),{})}const Se=React$2.forwardRef((Be,Ne)=>{const{children:Fe,...Ue}=Be,[We]=React$2.useState(()=>tap(init(ne),ze=>ve(ze,Ue))),[qe]=React$2.useState(curry1to0(_e,We));return useIsomorphicLayoutEffect$2(()=>{for(const ze of ge)ze in Ue&&subscribe(qe[ze],Ue[ze]);return()=>{Object.values(qe).map(reset)}},[Ue,qe,We]),useIsomorphicLayoutEffect$2(()=>{ve(We,Ue)}),React$2.useImperativeHandle(Ne,always(xe(We))),React$2.createElement(ye.Provider,{value:We},ce?React$2.createElement(ce,omit([...ue,...pe,...ge],Ue),Fe):Fe)}),$e=Be=>React$2.useCallback(curry2to1(publish,React$2.useContext(ye)[Be]),[Be]),Re=Be=>{const Fe=React$2.useContext(ye)[Be],Ue=React$2.useCallback(We=>subscribe(Fe,We),[Fe]);return React$2.useSyncExternalStore(Ue,()=>getValue(Fe),()=>getValue(Fe))},Ae=Be=>{const Fe=React$2.useContext(ye)[Be],[Ue,We]=React$2.useState(curry1to0(getValue,Fe));return useIsomorphicLayoutEffect$2(()=>subscribe(Fe,qe=>{qe!==Ue&&We(always(qe))}),[Fe,Ue]),Ue},Ie=React$2.version.startsWith("18")?Re:Ae;return{Component:Se,usePublisher:$e,useEmitterValue:Ie,useEmitter:(Be,Ne)=>{const Ue=React$2.useContext(ye)[Be];useIsomorphicLayoutEffect$2(()=>subscribe(Ue,Ne),[Ne,Ue])}}}const useIsomorphicLayoutEffect=typeof document<"u"?React$2.useLayoutEffect:React$2.useEffect,useIsomorphicLayoutEffect$1=useIsomorphicLayoutEffect;var LogLevel=(ne=>(ne[ne.DEBUG=0]="DEBUG",ne[ne.INFO=1]="INFO",ne[ne.WARN=2]="WARN",ne[ne.ERROR=3]="ERROR",ne))(LogLevel||{});const CONSOLE_METHOD_MAP={0:"debug",1:"log",2:"warn",3:"error"},getGlobalThis=()=>typeof globalThis>"u"?window:globalThis,loggerSystem=system(()=>{const ne=statefulStream(3);return{log:statefulStream((ce,ue,pe=1)=>{var me;const ge=(me=getGlobalThis().VIRTUOSO_LOG_LEVEL)!=null?me:getValue(ne);pe>=ge&&console[CONSOLE_METHOD_MAP[pe]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",ce,ue)}),logLevel:ne}},[],{singleton:!0});function useSizeWithElRef(ne,oe=!0){const ce=React$2.useRef(null);let ue=pe=>{};if(typeof ResizeObserver<"u"){const pe=React$2.useMemo(()=>new ResizeObserver(me=>{const ge=me[0].target;ge.offsetParent!==null&&ne(ge)}),[ne]);ue=me=>{me&&oe?(pe.observe(me),ce.current=me):(ce.current&&pe.unobserve(ce.current),ce.current=null)}}return{ref:ce,callbackRef:ue}}function useSize(ne,oe=!0){return useSizeWithElRef(ne,oe).callbackRef}function useChangedListContentsSizes(ne,oe,ce,ue,pe,me,ge){const ye=React$2.useCallback(ve=>{const xe=getChangedChildSizes(ve.children,oe,"offsetHeight",pe);let _e=ve.parentElement;for(;!_e.dataset.virtuosoScroller;)_e=_e.parentElement;const Se=_e.lastElementChild.dataset.viewportType==="window",$e=ge?ge.scrollTop:Se?window.pageYOffset||document.documentElement.scrollTop:_e.scrollTop,Re=ge?ge.scrollHeight:Se?document.documentElement.scrollHeight:_e.scrollHeight,Ae=ge?ge.offsetHeight:Se?window.innerHeight:_e.offsetHeight;ue({scrollTop:Math.max($e,0),scrollHeight:Re,viewportHeight:Ae}),me==null||me(resolveGapValue$1("row-gap",getComputedStyle(ve).rowGap,pe)),xe!==null&&ne(xe)},[ne,oe,pe,me,ge,ue]);return useSizeWithElRef(ye,ce)}function getChangedChildSizes(ne,oe,ce,ue){const pe=ne.length;if(pe===0)return null;const me=[];for(let ge=0;ge{const $e=Se.target,Re=$e===window||$e===document,Ae=Re?window.pageYOffset||document.documentElement.scrollTop:$e.scrollTop,Ie=Re?document.documentElement.scrollHeight:$e.scrollHeight,ke=Re?window.innerHeight:$e.offsetHeight,Be=()=>{ne({scrollTop:Math.max(Ae,0),scrollHeight:Ie,viewportHeight:ke})};Se.suppressFlushSync?Be():ReactDOM$1.flushSync(Be),ge.current!==null&&(Ae===ge.current||Ae<=0||Ae===Ie-ke)&&(ge.current=null,oe(!0),ye.current&&(clearTimeout(ye.current),ye.current=null))},[ne,oe]);React$2.useEffect(()=>{const Se=pe||me.current;return ue(pe||me.current),ve({target:Se,suppressFlushSync:!0}),Se.addEventListener("scroll",ve,{passive:!0}),()=>{ue(null),Se.removeEventListener("scroll",ve)}},[me,ve,ce,ue,pe]);function xe(Se){const $e=me.current;if(!$e||"offsetHeight"in $e&&$e.offsetHeight===0)return;const Re=Se.behavior==="smooth";let Ae,Ie,ke;$e===window?(Ie=Math.max(correctItemSize(document.documentElement,"height"),document.documentElement.scrollHeight),Ae=window.innerHeight,ke=document.documentElement.scrollTop):(Ie=$e.scrollHeight,Ae=correctItemSize($e,"height"),ke=$e.scrollTop);const Be=Ie-Ae;if(Se.top=Math.ceil(Math.max(Math.min(Be,Se.top),0)),approximatelyEqual(Ae,Ie)||Se.top===ke){ne({scrollTop:ke,scrollHeight:Ie,viewportHeight:Ae}),Re&&oe(!0);return}Re?(ge.current=Se.top,ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{ye.current=null,ge.current=null,oe(!0)},1e3)):ge.current=null,$e.scrollTo(Se)}function _e(Se){me.current.scrollBy(Se)}return{scrollerRef:me,scrollByCallback:_e,scrollToCallback:xe}}const domIOSystem=system(()=>{const ne=stream(),oe=stream(),ce=statefulStream(0),ue=stream(),pe=statefulStream(0),me=stream(),ge=stream(),ye=statefulStream(0),ve=statefulStream(0),xe=statefulStream(0),_e=statefulStream(0),Se=stream(),$e=stream(),Re=statefulStream(!1);return connect(pipe(ne,map$1(({scrollTop:Ae})=>Ae)),oe),connect(pipe(ne,map$1(({scrollHeight:Ae})=>Ae)),ge),connect(oe,pe),{scrollContainerState:ne,scrollTop:oe,viewportHeight:me,headerHeight:ye,fixedHeaderHeight:ve,fixedFooterHeight:xe,footerHeight:_e,scrollHeight:ge,smoothScrollTargetReached:ue,scrollTo:Se,scrollBy:$e,statefulScrollTop:pe,deviation:ce,scrollingInProgress:Re}},[],{singleton:!0}),NIL_NODE={lvl:0};function newAANode(ne,oe,ce,ue=NIL_NODE,pe=NIL_NODE){return{k:ne,v:oe,lvl:ce,l:ue,r:pe}}function empty(ne){return ne===NIL_NODE}function newTree(){return NIL_NODE}function remove(ne,oe){if(empty(ne))return NIL_NODE;const{k:ce,l:ue,r:pe}=ne;if(oe===ce){if(empty(ue))return pe;if(empty(pe))return ue;{const[me,ge]=last(ue);return adjust(clone(ne,{k:me,v:ge,l:deleteLast(ue)}))}}else return oeoe&&(ye=ye.concat(walkWithin(me,oe,ce))),ue>=oe&&ue<=ce&&ye.push({k:ue,v:pe}),ue<=ce&&(ye=ye.concat(walkWithin(ge,oe,ce))),ye}function walk(ne){return empty(ne)?[]:[...walk(ne.l),{k:ne.k,v:ne.v},...walk(ne.r)]}function last(ne){return empty(ne.r)?[ne.k,ne.v]:last(ne.r)}function deleteLast(ne){return empty(ne.r)?ne.l:adjust(clone(ne,{r:deleteLast(ne.r)}))}function clone(ne,oe){return newAANode(oe.k!==void 0?oe.k:ne.k,oe.v!==void 0?oe.v:ne.v,oe.lvl!==void 0?oe.lvl:ne.lvl,oe.l!==void 0?oe.l:ne.l,oe.r!==void 0?oe.r:ne.r)}function isSingle(ne){return empty(ne)||ne.lvl>ne.r.lvl}function rebalance(ne){return split(skew(ne))}function adjust(ne){const{l:oe,r:ce,lvl:ue}=ne;if(ce.lvl>=ue-1&&oe.lvl>=ue-1)return ne;if(ue>ce.lvl+1){if(isSingle(oe))return skew(clone(ne,{lvl:ue-1}));if(!empty(oe)&&!empty(oe.r))return clone(oe.r,{l:clone(oe,{r:oe.r.l}),r:clone(ne,{l:oe.r.r,lvl:ue-1}),lvl:ue});throw new Error("Unexpected empty nodes")}else{if(isSingle(ne))return split(clone(ne,{lvl:ue-1}));if(!empty(ce)&&!empty(ce.l)){const pe=ce.l,me=isSingle(pe)?ce.lvl-1:ce.lvl;return clone(pe,{l:clone(ne,{r:pe.l,lvl:ue-1}),r:split(clone(ce,{l:pe.r,lvl:me})),lvl:pe.lvl+1})}else throw new Error("Unexpected empty nodes")}}function rangesWithin(ne,oe,ce){if(empty(ne))return[];const ue=findMaxKeyValue(ne,oe)[0];return toRanges(walkWithin(ne,ue,ce))}function arrayToRanges(ne,oe){const ce=ne.length;if(ce===0)return[];let{index:ue,value:pe}=oe(ne[0]);const me=[];for(let ge=1;ge({index:oe,value:ce}))}function split(ne){const{r:oe,lvl:ce}=ne;return!empty(oe)&&!empty(oe.r)&&oe.lvl===ce&&oe.r.lvl===ce?clone(oe,{l:clone(ne,{r:oe.l}),lvl:ce+1}):ne}function skew(ne){const{l:oe}=ne;return!empty(oe)&&oe.lvl===ne.lvl?clone(oe,{r:clone(ne,{l:oe.r})}):ne}function findIndexOfClosestSmallerOrEqual(ne,oe,ce,ue=0){let pe=ne.length-1;for(;ue<=pe;){const me=Math.floor((ue+pe)/2),ge=ne[me],ye=ce(ge,oe);if(ye===0)return me;if(ye===-1){if(pe-ue<2)return me-1;pe=me-1}else{if(pe===ue)return me;ue=me+1}}throw new Error(`Failed binary finding record in array - ${ne.join(",")}, searched for ${oe}`)}function findClosestSmallerOrEqual(ne,oe,ce){return ne[findIndexOfClosestSmallerOrEqual(ne,oe,ce)]}function findRange(ne,oe,ce,ue){const pe=findIndexOfClosestSmallerOrEqual(ne,oe,ue),me=findIndexOfClosestSmallerOrEqual(ne,ce,ue,pe);return ne.slice(pe,me+1)}const recalcSystem=system(()=>({recalcInProgress:statefulStream(!1)}),[],{singleton:!0});function rangeIncludes(ne){const{size:oe,startIndex:ce,endIndex:ue}=ne;return pe=>pe.start===ce&&(pe.end===ue||pe.end===1/0)&&pe.value===oe}function affectedGroupCount(ne,oe){let ce=0,ue=0;for(;ce=_e||pe===$e)&&(ne=remove(ne,_e)):(xe=$e!==pe,ve=!0),Se>ge&&ge>=_e&&$e!==pe&&(ne=insert(ne,ge+1,$e));xe&&(ne=insert(ne,me,pe))}return[ne,ce]}function initialSizeState(){return{offsetTree:[],sizeTree:newTree(),groupOffsetTree:newTree(),lastIndex:0,lastOffset:0,lastSize:0,groupIndices:[]}}function indexComparator({index:ne},oe){return oe===ne?0:oe0&&(oe=Math.max(oe,findClosestSmallerOrEqual(ne,ue,indexComparator).offset)),arrayToRanges(findRange(ne,oe,ce,offsetComparator),offsetPointParser)}function createOffsetTree(ne,oe,ce,ue){let pe=ne,me=0,ge=0,ye=0,ve=0;if(oe!==0){ve=findIndexOfClosestSmallerOrEqual(pe,oe-1,indexComparator),ye=pe[ve].offset;const _e=findMaxKeyValue(ce,oe-1);me=_e[0],ge=_e[1],pe.length&&pe[ve].size===findMaxKeyValue(ce,oe)[1]&&(ve-=1),pe=pe.slice(0,ve+1)}else pe=[];for(const{start:xe,value:_e}of rangesWithin(ce,oe,1/0)){const Se=xe-me,$e=Se*ge+ye+Se*ue;pe.push({offset:$e,size:_e,index:xe}),me=xe,ye=$e,ge=_e}return{offsetTree:pe,lastIndex:me,lastOffset:ye,lastSize:ge}}function sizeStateReducer(ne,[oe,ce,ue,pe]){oe.length>0&&ue("received item sizes",oe,LogLevel.DEBUG);const me=ne.sizeTree;let ge=me,ye=0;if(ce.length>0&&empty(me)&&oe.length===2){const $e=oe[0].size,Re=oe[1].size;ge=ce.reduce((Ae,Ie)=>insert(insert(Ae,Ie,$e),Ie+1,Re),ge)}else[ge,ye]=insertRanges(ge,oe);if(ge===me)return ne;const{offsetTree:ve,lastIndex:xe,lastSize:_e,lastOffset:Se}=createOffsetTree(ne.offsetTree,ye,ge,pe);return{sizeTree:ge,offsetTree:ve,lastIndex:xe,lastOffset:Se,lastSize:_e,groupOffsetTree:ce.reduce(($e,Re)=>insert($e,Re,offsetOf(Re,ve,pe)),newTree()),groupIndices:ce}}function offsetOf(ne,oe,ce){if(oe.length===0)return 0;const{offset:ue,index:pe,size:me}=findClosestSmallerOrEqual(oe,ne,indexComparator),ge=ne-pe,ye=me*ge+(ge-1)*ce+ue;return ye>0?ye+ce:ye}function isGroupLocation(ne){return typeof ne.groupIndex<"u"}function originalIndexFromLocation(ne,oe,ce){if(isGroupLocation(ne))return oe.groupIndices[ne.groupIndex]+1;{const ue=ne.index==="LAST"?ce:ne.index;let pe=originalIndexFromItemIndex(ue,oe);return pe=Math.max(0,pe,Math.min(ce,pe)),pe}}function originalIndexFromItemIndex(ne,oe){if(!hasGroups(oe))return ne;let ce=0;for(;oe.groupIndices[ce]<=ne+ce;)ce++;return ne+ce}function hasGroups(ne){return!empty(ne.groupOffsetTree)}function sizeTreeToRanges(ne){return walk(ne).map(({k:oe,v:ce},ue,pe)=>{const me=pe[ue+1],ge=me?me.k-1:1/0;return{startIndex:oe,endIndex:ge,size:ce}})}const SIZE_MAP={offsetHeight:"height",offsetWidth:"width"},sizeSystem=system(([{log:ne},{recalcInProgress:oe}])=>{const ce=stream(),ue=stream(),pe=statefulStreamFromEmitter(ue,0),me=stream(),ge=stream(),ye=statefulStream(0),ve=statefulStream([]),xe=statefulStream(void 0),_e=statefulStream(void 0),Se=statefulStream((We,qe)=>correctItemSize(We,SIZE_MAP[qe])),$e=statefulStream(void 0),Re=statefulStream(0),Ae=initialSizeState(),Ie=statefulStreamFromEmitter(pipe(ce,withLatestFrom(ve,ne,Re),scan(sizeStateReducer,Ae),distinctUntilChanged()),Ae),ke=statefulStreamFromEmitter(pipe(ve,distinctUntilChanged(),scan((We,qe)=>({prev:We.current,current:qe}),{prev:[],current:[]}),map$1(({prev:We})=>We)),[]);connect(pipe(ve,filter(We=>We.length>0),withLatestFrom(Ie,Re),map$1(([We,qe,ze])=>{const Ge=We.reduce((Ze,Dt,Je)=>insert(Ze,Dt,offsetOf(Dt,qe.offsetTree,ze)||Je),newTree());return{...qe,groupIndices:We,groupOffsetTree:Ge}})),Ie),connect(pipe(ue,withLatestFrom(Ie),filter(([We,{lastIndex:qe}])=>We[{startIndex:We,endIndex:qe,size:ze}])),ce),connect(xe,_e);const Be=statefulStreamFromEmitter(pipe(xe,map$1(We=>We===void 0)),!0);connect(pipe(_e,filter(We=>We!==void 0&&empty(getValue(Ie).sizeTree)),map$1(We=>[{startIndex:0,endIndex:0,size:We}])),ce);const Ne=streamFromEmitter(pipe(ce,withLatestFrom(Ie),scan(({sizes:We},[qe,ze])=>({changed:ze!==We,sizes:ze}),{changed:!1,sizes:Ae}),map$1(We=>We.changed)));subscribe(pipe(ye,scan((We,qe)=>({diff:We.prev-qe,prev:qe}),{diff:0,prev:0}),map$1(We=>We.diff)),We=>{const{groupIndices:qe}=getValue(Ie);if(We>0)publish(oe,!0),publish(me,We+affectedGroupCount(We,qe));else if(We<0){const ze=getValue(ke);ze.length>0&&(We-=affectedGroupCount(-We,ze)),publish(ge,We)}}),subscribe(pipe(ye,withLatestFrom(ne)),([We,qe])=>{We<0&&qe("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:ye},LogLevel.ERROR)});const Fe=streamFromEmitter(me);connect(pipe(me,withLatestFrom(Ie),map$1(([We,qe])=>{const ze=qe.groupIndices.length>0,Ge=[],Ze=qe.lastSize;if(ze){const Dt=find(qe.sizeTree,0);let Je=0,Ut=0;for(;Je{let Kt=an.ranges;return an.prevSize!==0&&(Kt=[...an.ranges,{startIndex:an.prevIndex,endIndex:Zt+We-1,size:an.prevSize}]),{ranges:Kt,prevIndex:Zt+We,prevSize:en}},{ranges:Ge,prevIndex:We,prevSize:0}).ranges}return walk(qe.sizeTree).reduce((Dt,{k:Je,v:Ut})=>({ranges:[...Dt.ranges,{startIndex:Dt.prevIndex,endIndex:Je+We-1,size:Dt.prevSize}],prevIndex:Je+We,prevSize:Ut}),{ranges:[],prevIndex:0,prevSize:Ze}).ranges})),ce);const Ue=streamFromEmitter(pipe(ge,withLatestFrom(Ie,Re),map$1(([We,{offsetTree:qe},ze])=>{const Ge=-We;return offsetOf(Ge,qe,ze)})));return connect(pipe(ge,withLatestFrom(Ie,Re),map$1(([We,qe,ze])=>{if(qe.groupIndices.length>0){if(empty(qe.sizeTree))return qe;let Ze=newTree();const Dt=getValue(ke);let Je=0,Ut=0,jt=0;for(;Je<-We;){jt=Dt[Ut];const an=Dt[Ut+1]-jt-1;Ut++,Je+=an+1}if(Ze=walk(qe.sizeTree).reduce((an,{k:Zt,v:en})=>insert(an,Math.max(0,Zt+We),en),Ze),Je!==-We){const an=find(qe.sizeTree,jt);Ze=insert(Ze,0,an);const Zt=findMaxKeyValue(qe.sizeTree,-We+1)[1];Ze=insert(Ze,1,Zt)}return{...qe,sizeTree:Ze,...createOffsetTree(qe.offsetTree,0,Ze,ze)}}else{const Ze=walk(qe.sizeTree).reduce((Dt,{k:Je,v:Ut})=>insert(Dt,Math.max(0,Je+We),Ut),newTree());return{...qe,sizeTree:Ze,...createOffsetTree(qe.offsetTree,0,Ze,ze)}}})),Ie),{data:$e,totalCount:ue,sizeRanges:ce,groupIndices:ve,defaultItemSize:_e,fixedItemSize:xe,unshiftWith:me,shiftWith:ge,shiftWithOffset:Ue,beforeUnshiftWith:Fe,firstItemIndex:ye,gap:Re,sizes:Ie,listRefresh:Ne,statefulTotalCount:pe,trackItemSizes:Be,itemSize:Se}},tup(loggerSystem,recalcSystem),{singleton:!0}),SUPPORTS_SCROLL_TO_OPTIONS=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function normalizeIndexLocation(ne){const oe=typeof ne=="number"?{index:ne}:ne;return oe.align||(oe.align="start"),(!oe.behavior||!SUPPORTS_SCROLL_TO_OPTIONS)&&(oe.behavior="auto"),oe.offset||(oe.offset=0),oe}const scrollToIndexSystem=system(([{sizes:ne,totalCount:oe,listRefresh:ce,gap:ue},{scrollingInProgress:pe,viewportHeight:me,scrollTo:ge,smoothScrollTargetReached:ye,headerHeight:ve,footerHeight:xe,fixedHeaderHeight:_e,fixedFooterHeight:Se},{log:$e}])=>{const Re=stream(),Ae=statefulStream(0);let Ie=null,ke=null,Be=null;function Ne(){Ie&&(Ie(),Ie=null),Be&&(Be(),Be=null),ke&&(clearTimeout(ke),ke=null),publish(pe,!1)}return connect(pipe(Re,withLatestFrom(ne,me,oe,Ae,ve,xe,$e),withLatestFrom(ue,_e,Se),map$1(([[Fe,Ue,We,qe,ze,Ge,Ze,Dt],Je,Ut,jt])=>{const Ke=normalizeIndexLocation(Fe),{align:an,behavior:Zt,offset:en}=Ke,Kt=qe-1,Wt=originalIndexFromLocation(Ke,Ue,Kt);let un=offsetOf(Wt,Ue.offsetTree,Je)+Ge;an==="end"?(un+=Ut+findMaxKeyValue(Ue.sizeTree,Wt)[1]-We+jt,Wt===Kt&&(un+=Ze)):an==="center"?un+=(Ut+findMaxKeyValue(Ue.sizeTree,Wt)[1]-We+jt)/2:un-=ze,en&&(un+=en);const Xt=nn=>{Ne(),nn?(Dt("retrying to scroll to",{location:Fe},LogLevel.DEBUG),publish(Re,Fe)):Dt("list did not change, scroll successful",{},LogLevel.DEBUG)};if(Ne(),Zt==="smooth"){let nn=!1;Be=subscribe(ce,vn=>{nn=nn||vn}),Ie=handleNext(ye,()=>{Xt(nn)})}else Ie=handleNext(pipe(ce,watchChangesFor(150)),Xt);return ke=setTimeout(()=>{Ne()},1200),publish(pe,!0),Dt("scrolling from index to",{index:Wt,top:un,behavior:Zt},LogLevel.DEBUG),{top:un,behavior:Zt}})),ge),{scrollToIndex:Re,topListHeight:Ae}},tup(sizeSystem,domIOSystem,loggerSystem),{singleton:!0});function watchChangesFor(ne){return oe=>{const ce=setTimeout(()=>{oe(!1)},ne);return ue=>{ue&&(oe(!0),clearTimeout(ce))}}}const UP="up",DOWN="down",NONE$1="none",INITIAL_BOTTOM_STATE={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollTop:0,viewportHeight:0,scrollHeight:0}},DEFAULT_AT_TOP_THRESHOLD=0,stateFlagsSystem=system(([{scrollContainerState:ne,scrollTop:oe,viewportHeight:ce,headerHeight:ue,footerHeight:pe,scrollBy:me}])=>{const ge=statefulStream(!1),ye=statefulStream(!0),ve=stream(),xe=stream(),_e=statefulStream(4),Se=statefulStream(DEFAULT_AT_TOP_THRESHOLD),$e=statefulStreamFromEmitter(pipe(merge(pipe(duc(oe),skip(1),mapTo(!0)),pipe(duc(oe),skip(1),mapTo(!1),debounceTime(100))),distinctUntilChanged()),!1),Re=statefulStreamFromEmitter(pipe(merge(pipe(me,mapTo(!0)),pipe(me,mapTo(!1),debounceTime(200))),distinctUntilChanged()),!1);connect(pipe(combineLatest(duc(oe),duc(Se)),map$1(([Ne,Fe])=>Ne<=Fe),distinctUntilChanged()),ye),connect(pipe(ye,throttleTime(50)),xe);const Ae=streamFromEmitter(pipe(combineLatest(ne,duc(ce),duc(ue),duc(pe),duc(_e)),scan((Ne,[{scrollTop:Fe,scrollHeight:Ue},We,qe,ze,Ge])=>{const Ze=Fe+We-Ue>-Ge,Dt={viewportHeight:We,scrollTop:Fe,scrollHeight:Ue};if(Ze){let Ut,jt;return Fe>Ne.state.scrollTop?(Ut="SCROLLED_DOWN",jt=Ne.state.scrollTop-Fe):(Ut="SIZE_DECREASED",jt=Ne.state.scrollTop-Fe||Ne.scrollTopDelta),{atBottom:!0,state:Dt,atBottomBecause:Ut,scrollTopDelta:jt}}let Je;return Dt.scrollHeight>Ne.state.scrollHeight?Je="SIZE_INCREASED":WeNe&&Ne.atBottom===Fe.atBottom))),Ie=statefulStreamFromEmitter(pipe(ne,scan((Ne,{scrollTop:Fe,scrollHeight:Ue,viewportHeight:We})=>{if(approximatelyEqual(Ne.scrollHeight,Ue))return{scrollTop:Fe,scrollHeight:Ue,jump:0,changed:!1};{const qe=Ue-(Fe+We)<1;return Ne.scrollTop!==Fe&&qe?{scrollHeight:Ue,scrollTop:Fe,jump:Ne.scrollTop-Fe,changed:!0}:{scrollHeight:Ue,scrollTop:Fe,jump:0,changed:!0}}},{scrollHeight:0,jump:0,scrollTop:0,changed:!1}),filter(Ne=>Ne.changed),map$1(Ne=>Ne.jump)),0);connect(pipe(Ae,map$1(Ne=>Ne.atBottom)),ge),connect(pipe(ge,throttleTime(50)),ve);const ke=statefulStream(DOWN);connect(pipe(ne,map$1(({scrollTop:Ne})=>Ne),distinctUntilChanged(),scan((Ne,Fe)=>getValue(Re)?{direction:Ne.direction,prevScrollTop:Fe}:{direction:FeNe.direction)),ke),connect(pipe(ne,throttleTime(50),mapTo(NONE$1)),ke);const Be=statefulStream(0);return connect(pipe($e,filter(Ne=>!Ne),mapTo(0)),Be),connect(pipe(oe,throttleTime(100),withLatestFrom($e),filter(([Ne,Fe])=>!!Fe),scan(([Ne,Fe],[Ue])=>[Fe,Ue],[0,0]),map$1(([Ne,Fe])=>Fe-Ne)),Be),{isScrolling:$e,isAtTop:ye,isAtBottom:ge,atBottomState:Ae,atTopStateChange:xe,atBottomStateChange:ve,scrollDirection:ke,atBottomThreshold:_e,atTopThreshold:Se,scrollVelocity:Be,lastJumpDueToItemResize:Ie}},tup(domIOSystem)),propsReadySystem=system(([{log:ne}])=>{const oe=statefulStream(!1),ce=streamFromEmitter(pipe(oe,filter(ue=>ue),distinctUntilChanged()));return subscribe(oe,ue=>{ue&&getValue(ne)("props updated",{},LogLevel.DEBUG)}),{propsReady:oe,didMount:ce}},tup(loggerSystem),{singleton:!0});function skipFrames(ne,oe){ne==0?oe():requestAnimationFrame(()=>skipFrames(ne-1,oe))}function getInitialTopMostItemIndexNumber(ne,oe){const ce=oe-1;return typeof ne=="number"?ne:ne.index==="LAST"?ce:ne.index}const initialTopMostItemIndexSystem=system(([{sizes:ne,listRefresh:oe,defaultItemSize:ce},{scrollTop:ue},{scrollToIndex:pe},{didMount:me}])=>{const ge=statefulStream(!0),ye=statefulStream(0),ve=statefulStream(!1);return connect(pipe(me,withLatestFrom(ye),filter(([xe,_e])=>!!_e),mapTo(!1)),ge),subscribe(pipe(combineLatest(oe,me),withLatestFrom(ge,ne,ce,ve),filter(([[,xe],_e,{sizeTree:Se},$e,Re])=>xe&&(!empty(Se)||isDefined($e))&&!_e&&!Re),withLatestFrom(ye)),([,xe])=>{publish(ve,!0),skipFrames(3,()=>{handleNext(ue,()=>publish(ge,!0)),publish(pe,xe)})}),{scrolledToInitialItem:ge,initialTopMostItemIndex:ye}},tup(sizeSystem,domIOSystem,scrollToIndexSystem,propsReadySystem),{singleton:!0});function normalizeFollowOutput(ne){return ne?ne==="smooth"?"smooth":"auto":!1}const behaviorFromFollowOutput=(ne,oe)=>typeof ne=="function"?normalizeFollowOutput(ne(oe)):oe&&normalizeFollowOutput(ne),followOutputSystem=system(([{totalCount:ne,listRefresh:oe},{isAtBottom:ce,atBottomState:ue},{scrollToIndex:pe},{scrolledToInitialItem:me},{propsReady:ge,didMount:ye},{log:ve},{scrollingInProgress:xe}])=>{const _e=statefulStream(!1),Se=stream();let $e=null;function Re(Ie){publish(pe,{index:"LAST",align:"end",behavior:Ie})}subscribe(pipe(combineLatest(pipe(duc(ne),skip(1)),ye),withLatestFrom(duc(_e),ce,me,xe),map$1(([[Ie,ke],Be,Ne,Fe,Ue])=>{let We=ke&&Fe,qe="auto";return We&&(qe=behaviorFromFollowOutput(Be,Ne||Ue),We=We&&!!qe),{totalCount:Ie,shouldFollow:We,followOutputBehavior:qe}}),filter(({shouldFollow:Ie})=>Ie)),({totalCount:Ie,followOutputBehavior:ke})=>{$e&&($e(),$e=null),$e=handleNext(oe,()=>{getValue(ve)("following output to ",{totalCount:Ie},LogLevel.DEBUG),Re(ke),$e=null})});function Ae(Ie){const ke=handleNext(ue,Be=>{Ie&&!Be.atBottom&&Be.notAtBottomBecause==="SIZE_INCREASED"&&!$e&&(getValue(ve)("scrolling to bottom due to increased size",{},LogLevel.DEBUG),Re("auto"))});setTimeout(ke,100)}return subscribe(pipe(combineLatest(duc(_e),ne,ge),filter(([Ie,,ke])=>Ie&&ke),scan(({value:Ie},[,ke])=>({refreshed:Ie===ke,value:ke}),{refreshed:!1,value:0}),filter(({refreshed:Ie})=>Ie),withLatestFrom(_e,ne)),([,Ie])=>{Ae(Ie!==!1)}),subscribe(Se,()=>{Ae(getValue(_e)!==!1)}),subscribe(combineLatest(duc(_e),ue),([Ie,ke])=>{Ie&&!ke.atBottom&&ke.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&Re("auto")}),{followOutput:_e,autoscrollToBottom:Se}},tup(sizeSystem,stateFlagsSystem,scrollToIndexSystem,initialTopMostItemIndexSystem,propsReadySystem,loggerSystem,domIOSystem));function groupCountsToIndicesAndCount(ne){return ne.reduce((oe,ce)=>(oe.groupIndices.push(oe.totalCount),oe.totalCount+=ce+1,oe),{totalCount:0,groupIndices:[]})}const groupedListSystem=system(([{totalCount:ne,groupIndices:oe,sizes:ce},{scrollTop:ue,headerHeight:pe}])=>{const me=stream(),ge=stream(),ye=streamFromEmitter(pipe(me,map$1(groupCountsToIndicesAndCount)));return connect(pipe(ye,map$1(ve=>ve.totalCount)),ne),connect(pipe(ye,map$1(ve=>ve.groupIndices)),oe),connect(pipe(combineLatest(ue,ce,pe),filter(([ve,xe])=>hasGroups(xe)),map$1(([ve,xe,_e])=>findMaxKeyValue(xe.groupOffsetTree,Math.max(ve-_e,0),"v")[0]),distinctUntilChanged(),map$1(ve=>[ve])),ge),{groupCounts:me,topItemsIndexes:ge}},tup(sizeSystem,domIOSystem));function tupleComparator(ne,oe){return!!(ne&&ne[0]===oe[0]&&ne[1]===oe[1])}function rangeComparator(ne,oe){return!!(ne&&ne.startIndex===oe.startIndex&&ne.endIndex===oe.endIndex)}const TOP="top",BOTTOM="bottom",NONE="none";function getOverscan(ne,oe,ce){return typeof ne=="number"?ce===UP&&oe===TOP||ce===DOWN&&oe===BOTTOM?ne:0:ce===UP?oe===TOP?ne.main:ne.reverse:oe===BOTTOM?ne.main:ne.reverse}function getViewportIncrease(ne,oe){return typeof ne=="number"?ne:ne[oe]||0}const sizeRangeSystem=system(([{scrollTop:ne,viewportHeight:oe,deviation:ce,headerHeight:ue,fixedHeaderHeight:pe}])=>{const me=stream(),ge=statefulStream(0),ye=statefulStream(0),ve=statefulStream(0),xe=statefulStreamFromEmitter(pipe(combineLatest(duc(ne),duc(oe),duc(ue),duc(me,tupleComparator),duc(ve),duc(ge),duc(pe),duc(ce),duc(ye)),map$1(([_e,Se,$e,[Re,Ae],Ie,ke,Be,Ne,Fe])=>{const Ue=_e-Ne,We=ke+Be,qe=Math.max($e-Ue,0);let ze=NONE;const Ge=getViewportIncrease(Fe,TOP),Ze=getViewportIncrease(Fe,BOTTOM);return Re-=Ne,Re+=$e+Be,Ae+=$e+Be,Ae-=Ne,Re>_e+We-Ge&&(ze=UP),Ae<_e-qe+Se+Ze&&(ze=DOWN),ze!==NONE?[Math.max(Ue-$e-getOverscan(Ie,TOP,ze)-Ge,0),Ue-qe-Be+Se+getOverscan(Ie,BOTTOM,ze)+Ze]:null}),filter(_e=>_e!=null),distinctUntilChanged(tupleComparator)),[0,0]);return{listBoundary:me,overscan:ve,topListHeight:ge,increaseViewportBy:ye,visibleRange:xe}},tup(domIOSystem),{singleton:!0});function probeItemSet(ne,oe,ce){if(hasGroups(oe)){const ue=originalIndexFromItemIndex(ne,oe);return[{index:findMaxKeyValue(oe.groupOffsetTree,ue)[0],size:0,offset:0},{index:ue,size:0,offset:0,data:ce&&ce[0]}]}return[{index:ne,size:0,offset:0,data:ce&&ce[0]}]}const EMPTY_LIST_STATE={items:[],topItems:[],offsetTop:0,offsetBottom:0,top:0,bottom:0,topListHeight:0,totalCount:0,firstItemIndex:0};function transposeItems(ne,oe,ce){if(ne.length===0)return[];if(!hasGroups(oe))return ne.map(xe=>({...xe,index:xe.index+ce,originalIndex:xe.index}));const ue=ne[0].index,pe=ne[ne.length-1].index,me=[],ge=rangesWithin(oe.groupOffsetTree,ue,pe);let ye,ve=0;for(const xe of ne){(!ye||ye.end0){xe=ne[0].offset;const Ie=ne[ne.length-1];_e=Ie.offset+Ie.size}const Se=ce-ve,$e=ye+Se*ge+(Se-1)*ue,Re=xe,Ae=$e-_e;return{items:transposeItems(ne,pe,me),topItems:transposeItems(oe,pe,me),topListHeight:oe.reduce((Ie,ke)=>ke.size+Ie,0),offsetTop:xe,offsetBottom:Ae,top:Re,bottom:_e,totalCount:ce,firstItemIndex:me}}function buildListStateFromItemCount(ne,oe,ce,ue,pe,me){let ge=0;if(ce.groupIndices.length>0)for(const _e of ce.groupIndices){if(_e-ge>=ne)break;ge++}const ye=ne+ge,ve=getInitialTopMostItemIndexNumber(oe,ye),xe=Array.from({length:ye}).map((_e,Se)=>({index:Se+ve,size:0,offset:0,data:me[Se+ve]}));return buildListState(xe,[],ye,pe,ce,ue)}const listStateSystem=system(([{sizes:ne,totalCount:oe,data:ce,firstItemIndex:ue,gap:pe},me,{visibleRange:ge,listBoundary:ye,topListHeight:ve},{scrolledToInitialItem:xe,initialTopMostItemIndex:_e},{topListHeight:Se},$e,{didMount:Re},{recalcInProgress:Ae}])=>{const Ie=statefulStream([]),ke=statefulStream(0),Be=stream();connect(me.topItemsIndexes,Ie);const Ne=statefulStreamFromEmitter(pipe(combineLatest(Re,Ae,duc(ge,tupleComparator),duc(oe),duc(ne),duc(_e),xe,duc(Ie),duc(ue),duc(pe),ce),filter(([qe,ze,,Ge,,,,,,,Ze])=>{const Dt=Ze&&Ze.length!==Ge;return qe&&!ze&&!Dt}),map$1(([,,[qe,ze],Ge,Ze,Dt,Je,Ut,jt,Ke,an])=>{const Zt=Ze,{sizeTree:en,offsetTree:Kt}=Zt,Wt=getValue(ke);if(Ge===0)return{...EMPTY_LIST_STATE,totalCount:Ge};if(qe===0&&ze===0)return Wt===0?{...EMPTY_LIST_STATE,totalCount:Ge}:buildListStateFromItemCount(Wt,Dt,Ze,jt,Ke,an||[]);if(empty(en))return Wt>0?null:buildListState(probeItemSet(getInitialTopMostItemIndexNumber(Dt,Ge),Zt,an),[],Ge,Ke,Zt,jt);const un=[];if(Ut.length>0){const Cn=Ut[0],Nt=Ut[Ut.length-1];let Yt=0;for(const Jt of rangesWithin(en,Cn,Nt)){const hn=Jt.value,Ye=Math.max(Jt.start,Cn),Xe=Math.min(Jt.end,Nt);for(let Pt=Ye;Pt<=Xe;Pt++)un.push({index:Pt,size:hn,offset:Yt,data:an&&an[Pt]}),Yt+=hn}}if(!Je)return buildListState([],un,Ge,Ke,Zt,jt);const Xt=Ut.length>0?Ut[Ut.length-1]+1:0,nn=rangesWithinOffsets(Kt,qe,ze,Xt);if(nn.length===0)return null;const vn=Ge-1,Sn=tap([],Cn=>{for(const Nt of nn){const Yt=Nt.value;let Jt=Yt.offset,hn=Nt.start;const Ye=Yt.size;if(Yt.offset=ze);Pt++)Cn.push({index:Pt,size:Ye,offset:Jt,data:an&&an[Pt]}),Jt+=Ye+Ke}});return buildListState(Sn,un,Ge,Ke,Zt,jt)}),filter(qe=>qe!==null),distinctUntilChanged()),EMPTY_LIST_STATE);connect(pipe(ce,filter(isDefined),map$1(qe=>qe==null?void 0:qe.length)),oe),connect(pipe(Ne,map$1(qe=>qe.topListHeight)),Se),connect(Se,ve),connect(pipe(Ne,map$1(qe=>[qe.top,qe.bottom])),ye),connect(pipe(Ne,map$1(qe=>qe.items)),Be);const Fe=streamFromEmitter(pipe(Ne,filter(({items:qe})=>qe.length>0),withLatestFrom(oe,ce),filter(([{items:qe},ze])=>qe[qe.length-1].originalIndex===ze-1),map$1(([,qe,ze])=>[qe-1,ze]),distinctUntilChanged(tupleComparator),map$1(([qe])=>qe))),Ue=streamFromEmitter(pipe(Ne,throttleTime(200),filter(({items:qe,topItems:ze})=>qe.length>0&&qe[0].originalIndex===ze.length),map$1(({items:qe})=>qe[0].index),distinctUntilChanged())),We=streamFromEmitter(pipe(Ne,filter(({items:qe})=>qe.length>0),map$1(({items:qe})=>{let ze=0,Ge=qe.length-1;for(;qe[ze].type==="group"&&zeze;)Ge--;return{startIndex:qe[ze].index,endIndex:qe[Ge].index}}),distinctUntilChanged(rangeComparator)));return{listState:Ne,topItemsIndexes:Ie,endReached:Fe,startReached:Ue,rangeChanged:We,itemsRendered:Be,initialItemCount:ke,...$e}},tup(sizeSystem,groupedListSystem,sizeRangeSystem,initialTopMostItemIndexSystem,scrollToIndexSystem,stateFlagsSystem,propsReadySystem,recalcSystem),{singleton:!0}),initialItemCountSystem=system(([{sizes:ne,firstItemIndex:oe,data:ce,gap:ue},{initialTopMostItemIndex:pe},{initialItemCount:me,listState:ge},{didMount:ye}])=>(connect(pipe(ye,withLatestFrom(me),filter(([,ve])=>ve!==0),withLatestFrom(pe,ne,oe,ue,ce),map$1(([[,ve],xe,_e,Se,$e,Re=[]])=>buildListStateFromItemCount(ve,xe,_e,Se,$e,Re))),ge),{}),tup(sizeSystem,initialTopMostItemIndexSystem,listStateSystem,propsReadySystem),{singleton:!0}),scrollSeekSystem=system(([{scrollVelocity:ne}])=>{const oe=statefulStream(!1),ce=stream(),ue=statefulStream(!1);return connect(pipe(ne,withLatestFrom(ue,oe,ce),filter(([pe,me])=>!!me),map$1(([pe,me,ge,ye])=>{const{exit:ve,enter:xe}=me;if(ge){if(ve(pe,ye))return!1}else if(xe(pe,ye))return!0;return ge}),distinctUntilChanged()),oe),subscribe(pipe(combineLatest(oe,ne,ce),withLatestFrom(ue)),([[pe,me,ge],ye])=>pe&&ye&&ye.change&&ye.change(me,ge)),{isSeeking:oe,scrollSeekConfiguration:ue,scrollVelocity:ne,scrollSeekRangeChanged:ce}},tup(stateFlagsSystem),{singleton:!0}),topItemCountSystem=system(([{topItemsIndexes:ne}])=>{const oe=statefulStream(0);return connect(pipe(oe,filter(ce=>ce>0),map$1(ce=>Array.from({length:ce}).map((ue,pe)=>pe))),ne),{topItemCount:oe}},tup(listStateSystem)),totalListHeightSystem=system(([{footerHeight:ne,headerHeight:oe,fixedHeaderHeight:ce,fixedFooterHeight:ue},{listState:pe}])=>{const me=stream(),ge=statefulStreamFromEmitter(pipe(combineLatest(ne,ue,oe,ce,pe),map$1(([ye,ve,xe,_e,Se])=>ye+ve+xe+_e+Se.offsetBottom+Se.bottom)),0);return connect(duc(ge),me),{totalListHeight:ge,totalListHeightChanged:me}},tup(domIOSystem,listStateSystem),{singleton:!0});function simpleMemoize(ne){let oe=!1,ce;return()=>(oe||(oe=!0,ce=ne()),ce)}const isMobileSafari=simpleMemoize(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),upwardScrollFixSystem=system(([{scrollBy:ne,scrollTop:oe,deviation:ce,scrollingInProgress:ue},{isScrolling:pe,isAtBottom:me,scrollDirection:ge,lastJumpDueToItemResize:ye},{listState:ve},{beforeUnshiftWith:xe,shiftWithOffset:_e,sizes:Se,gap:$e},{log:Re},{recalcInProgress:Ae}])=>{const Ie=streamFromEmitter(pipe(ve,withLatestFrom(ye),scan(([,Be,Ne,Fe],[{items:Ue,totalCount:We,bottom:qe,offsetBottom:ze},Ge])=>{const Ze=qe+ze;let Dt=0;return Ne===We&&Be.length>0&&Ue.length>0&&(Ue[0].originalIndex===0&&Be[0].originalIndex===0||(Dt=Ze-Fe,Dt!==0&&(Dt+=Ge))),[Dt,Ue,We,Ze]},[0,[],0,0]),filter(([Be])=>Be!==0),withLatestFrom(oe,ge,ue,me,Re,Ae),filter(([,Be,Ne,Fe,,,Ue])=>!Ue&&!Fe&&Be!==0&&Ne===UP),map$1(([[Be],,,,,Ne])=>(Ne("Upward scrolling compensation",{amount:Be},LogLevel.DEBUG),Be))));function ke(Be){Be>0?(publish(ne,{top:-Be,behavior:"auto"}),publish(ce,0)):(publish(ce,0),publish(ne,{top:-Be,behavior:"auto"}))}return subscribe(pipe(Ie,withLatestFrom(ce,pe)),([Be,Ne,Fe])=>{Fe&&isMobileSafari()?publish(ce,Ne-Be):ke(-Be)}),subscribe(pipe(combineLatest(statefulStreamFromEmitter(pe,!1),ce,Ae),filter(([Be,Ne,Fe])=>!Be&&!Fe&&Ne!==0),map$1(([Be,Ne])=>Ne),throttleTime(1)),ke),connect(pipe(_e,map$1(Be=>({top:-Be}))),ne),subscribe(pipe(xe,withLatestFrom(Se,$e),map$1(([Be,{lastSize:Ne,groupIndices:Fe,sizeTree:Ue},We])=>{function qe(ze){return ze*(Ne+We)}if(Fe.length===0)return qe(Be);{let ze=0;const Ge=find(Ue,0);let Ze=0,Dt=0;for(;ZeBe&&(ze-=Ge,Je=Be-Ze+1),Ze+=Je,ze+=qe(Je),Dt++}return ze}})),Be=>{publish(ce,Be),requestAnimationFrame(()=>{publish(ne,{top:Be}),requestAnimationFrame(()=>{publish(ce,0),publish(Ae,!1)})})}),{deviation:ce}},tup(domIOSystem,stateFlagsSystem,listStateSystem,sizeSystem,loggerSystem,recalcSystem)),initialScrollTopSystem=system(([{didMount:ne},{scrollTo:oe},{listState:ce}])=>{const ue=statefulStream(0);return subscribe(pipe(ne,withLatestFrom(ue),filter(([,pe])=>pe!==0),map$1(([,pe])=>({top:pe}))),pe=>{handleNext(pipe(ce,skip(1),filter(me=>me.items.length>1)),()=>{requestAnimationFrame(()=>{publish(oe,pe)})})}),{initialScrollTop:ue}},tup(propsReadySystem,domIOSystem,listStateSystem),{singleton:!0}),alignToBottomSystem=system(([{viewportHeight:ne},{totalListHeight:oe}])=>{const ce=statefulStream(!1),ue=statefulStreamFromEmitter(pipe(combineLatest(ce,ne,oe),filter(([pe])=>pe),map$1(([,pe,me])=>Math.max(0,pe-me)),throttleTime(0),distinctUntilChanged()),0);return{alignToBottom:ce,paddingTopAddition:ue}},tup(domIOSystem,totalListHeightSystem),{singleton:!0}),windowScrollerSystem=system(([{scrollTo:ne,scrollContainerState:oe}])=>{const ce=stream(),ue=stream(),pe=stream(),me=statefulStream(!1),ge=statefulStream(void 0);return connect(pipe(combineLatest(ce,ue),map$1(([{viewportHeight:ye,scrollTop:ve,scrollHeight:xe},{offsetTop:_e}])=>({scrollTop:Math.max(0,ve-_e),scrollHeight:xe,viewportHeight:ye}))),oe),connect(pipe(ne,withLatestFrom(ue),map$1(([ye,{offsetTop:ve}])=>({...ye,top:ye.top+ve}))),pe),{useWindowScroll:me,customScrollParent:ge,windowScrollContainerState:ce,windowViewportRect:ue,windowScrollTo:pe}},tup(domIOSystem)),defaultCalculateViewLocation=({itemTop:ne,itemBottom:oe,viewportTop:ce,viewportBottom:ue,locationParams:{behavior:pe,align:me,...ge}})=>neue?{...ge,behavior:pe,align:me??"end"}:null,scrollIntoViewSystem=system(([{sizes:ne,totalCount:oe,gap:ce},{scrollTop:ue,viewportHeight:pe,headerHeight:me,fixedHeaderHeight:ge,fixedFooterHeight:ye,scrollingInProgress:ve},{scrollToIndex:xe}])=>{const _e=stream();return connect(pipe(_e,withLatestFrom(ne,pe,oe,me,ge,ye,ue),withLatestFrom(ce),map$1(([[Se,$e,Re,Ae,Ie,ke,Be,Ne],Fe])=>{const{done:Ue,behavior:We,align:qe,calculateViewLocation:ze=defaultCalculateViewLocation,...Ge}=Se,Ze=originalIndexFromLocation(Se,$e,Ae-1),Dt=offsetOf(Ze,$e.offsetTree,Fe)+Ie+ke,Je=Dt+findMaxKeyValue($e.sizeTree,Ze)[1],Ut=Ne+ke,jt=Ne+Re-Be,Ke=ze({itemTop:Dt,itemBottom:Je,viewportTop:Ut,viewportBottom:jt,locationParams:{behavior:We,align:qe,...Ge}});return Ke?Ue&&handleNext(pipe(ve,filter(an=>an===!1),skip(getValue(ve)?1:2)),Ue):Ue&&Ue(),Ke}),filter(Se=>Se!==null)),xe),{scrollIntoView:_e}},tup(sizeSystem,domIOSystem,scrollToIndexSystem,listStateSystem,loggerSystem),{singleton:!0}),stateLoadSystem=system(([{sizes:ne,sizeRanges:oe},{scrollTop:ce},{initialTopMostItemIndex:ue},{didMount:pe},{useWindowScroll:me,windowScrollContainerState:ge,windowViewportRect:ye}])=>{const ve=stream(),xe=statefulStream(void 0),_e=statefulStream(null),Se=statefulStream(null);return connect(ge,_e),connect(ye,Se),subscribe(pipe(ve,withLatestFrom(ne,ce,me,_e,Se)),([$e,Re,Ae,Ie,ke,Be])=>{const Ne=sizeTreeToRanges(Re.sizeTree);Ie&&ke!==null&&Be!==null&&(Ae=ke.scrollTop-Be.offsetTop),$e({ranges:Ne,scrollTop:Ae})}),connect(pipe(xe,filter(isDefined),map$1(locationFromSnapshot)),ue),connect(pipe(pe,withLatestFrom(xe),filter(([,$e])=>$e!==void 0),distinctUntilChanged(),map$1(([,$e])=>$e.ranges)),oe),{getState:ve,restoreStateFrom:xe}},tup(sizeSystem,domIOSystem,initialTopMostItemIndexSystem,propsReadySystem,windowScrollerSystem));function locationFromSnapshot(ne){return{offset:ne.scrollTop,index:0,align:"start"}}const featureGroup1System=system(([ne,oe,ce,ue,pe,me,ge,ye,ve,xe])=>({...ne,...oe,...ce,...ue,...pe,...me,...ge,...ye,...ve,...xe}),tup(sizeRangeSystem,initialItemCountSystem,propsReadySystem,scrollSeekSystem,totalListHeightSystem,initialScrollTopSystem,alignToBottomSystem,windowScrollerSystem,scrollIntoViewSystem,loggerSystem)),listSystem=system(([{totalCount:ne,sizeRanges:oe,fixedItemSize:ce,defaultItemSize:ue,trackItemSizes:pe,itemSize:me,data:ge,firstItemIndex:ye,groupIndices:ve,statefulTotalCount:xe,gap:_e,sizes:Se},{initialTopMostItemIndex:$e,scrolledToInitialItem:Re},Ae,Ie,ke,{listState:Be,topItemsIndexes:Ne,...Fe},{scrollToIndex:Ue},We,{topItemCount:qe},{groupCounts:ze},Ge])=>(connect(Fe.rangeChanged,Ge.scrollSeekRangeChanged),connect(pipe(Ge.windowViewportRect,map$1(Ze=>Ze.visibleHeight)),Ae.viewportHeight),{totalCount:ne,data:ge,firstItemIndex:ye,sizeRanges:oe,initialTopMostItemIndex:$e,scrolledToInitialItem:Re,topItemsIndexes:Ne,topItemCount:qe,groupCounts:ze,fixedItemHeight:ce,defaultItemHeight:ue,gap:_e,...ke,statefulTotalCount:xe,listState:Be,scrollToIndex:Ue,trackItemSizes:pe,itemSize:me,groupIndices:ve,...Fe,...Ge,...Ae,sizes:Se,...Ie}),tup(sizeSystem,initialTopMostItemIndexSystem,domIOSystem,stateLoadSystem,followOutputSystem,listStateSystem,scrollToIndexSystem,upwardScrollFixSystem,topItemCountSystem,groupedListSystem,featureGroup1System)),WEBKIT_STICKY="-webkit-sticky",STICKY="sticky",positionStickyCssValue=simpleMemoize(()=>{if(typeof document>"u")return STICKY;const ne=document.createElement("div");return ne.style.position=WEBKIT_STICKY,ne.style.position===WEBKIT_STICKY?WEBKIT_STICKY:STICKY});function useWindowViewportRectRef(ne,oe){const ce=React$2.useRef(null),ue=React$2.useCallback(ye=>{if(ye===null||!ye.offsetParent)return;const ve=ye.getBoundingClientRect(),xe=ve.width;let _e,Se;if(oe){const $e=oe.getBoundingClientRect(),Re=ve.top-$e.top;_e=$e.height-Math.max(0,Re),Se=Re+oe.scrollTop}else _e=window.innerHeight-Math.max(0,ve.top),Se=ve.top+window.pageYOffset;ce.current={offsetTop:Se,visibleHeight:_e,visibleWidth:xe},ne(ce.current)},[ne,oe]),{callbackRef:pe,ref:me}=useSizeWithElRef(ue),ge=React$2.useCallback(()=>{ue(me.current)},[ue,me]);return React$2.useEffect(()=>{if(oe){oe.addEventListener("scroll",ge);const ye=new ResizeObserver(ge);return ye.observe(oe),()=>{oe.removeEventListener("scroll",ge),ye.unobserve(oe)}}else return window.addEventListener("scroll",ge),window.addEventListener("resize",ge),()=>{window.removeEventListener("scroll",ge),window.removeEventListener("resize",ge)}},[ge,oe]),pe}const VirtuosoMockContext=React$2.createContext(void 0),VirtuosoGridMockContext=React$2.createContext(void 0);function identity(ne){return ne}const listComponentPropsSystem=system(()=>{const ne=statefulStream(ve=>`Item ${ve}`),oe=statefulStream(null),ce=statefulStream(ve=>`Group ${ve}`),ue=statefulStream({}),pe=statefulStream(identity),me=statefulStream("div"),ge=statefulStream(noop$4),ye=(ve,xe=null)=>statefulStreamFromEmitter(pipe(ue,map$1(_e=>_e[ve]),distinctUntilChanged()),xe);return{context:oe,itemContent:ne,groupContent:ce,components:ue,computeItemKey:pe,headerFooterTag:me,scrollerRef:ge,FooterComponent:ye("Footer"),HeaderComponent:ye("Header"),TopItemListComponent:ye("TopItemList"),ListComponent:ye("List","div"),ItemComponent:ye("Item","div"),GroupComponent:ye("Group","div"),ScrollerComponent:ye("Scroller","div"),EmptyPlaceholder:ye("EmptyPlaceholder"),ScrollSeekPlaceholder:ye("ScrollSeekPlaceholder")}}),combinedSystem$2=system(([ne,oe])=>({...ne,...oe}),tup(listSystem,listComponentPropsSystem)),DefaultScrollSeekPlaceholder$1=({height:ne})=>React$2.createElement("div",{style:{height:ne}}),GROUP_STYLE={position:positionStickyCssValue(),zIndex:1,overflowAnchor:"none"},ITEM_STYLE$1={overflowAnchor:"none"},Items$1=React$2.memo(function({showTopList:oe=!1}){const ce=useEmitterValue$2("listState"),ue=usePublisher$2("sizeRanges"),pe=useEmitterValue$2("useWindowScroll"),me=useEmitterValue$2("customScrollParent"),ge=usePublisher$2("windowScrollContainerState"),ye=usePublisher$2("scrollContainerState"),ve=me||pe?ge:ye,xe=useEmitterValue$2("itemContent"),_e=useEmitterValue$2("context"),Se=useEmitterValue$2("groupContent"),$e=useEmitterValue$2("trackItemSizes"),Re=useEmitterValue$2("itemSize"),Ae=useEmitterValue$2("log"),Ie=usePublisher$2("gap"),{callbackRef:ke}=useChangedListContentsSizes(ue,Re,$e,oe?noop$4:ve,Ae,Ie,me),[Be,Ne]=React$2.useState(0);useEmitter$2("deviation",Ke=>{Be!==Ke&&Ne(Ke)});const Fe=useEmitterValue$2("EmptyPlaceholder"),Ue=useEmitterValue$2("ScrollSeekPlaceholder")||DefaultScrollSeekPlaceholder$1,We=useEmitterValue$2("ListComponent"),qe=useEmitterValue$2("ItemComponent"),ze=useEmitterValue$2("GroupComponent"),Ge=useEmitterValue$2("computeItemKey"),Ze=useEmitterValue$2("isSeeking"),Dt=useEmitterValue$2("groupIndices").length>0,Je=useEmitterValue$2("paddingTopAddition"),Ut=useEmitterValue$2("scrolledToInitialItem"),jt=oe?{}:{boxSizing:"border-box",paddingTop:ce.offsetTop+Je,paddingBottom:ce.offsetBottom,marginTop:Be,...Ut?{}:{visibility:"hidden"}};return!oe&&ce.totalCount===0&&Fe?React$2.createElement(Fe,contextPropIfNotDomElement(Fe,_e)):React$2.createElement(We,{...contextPropIfNotDomElement(We,_e),ref:ke,style:jt,"data-test-id":oe?"virtuoso-top-item-list":"virtuoso-item-list"},(oe?ce.topItems:ce.items).map(Ke=>{const an=Ke.originalIndex,Zt=Ge(an+ce.firstItemIndex,Ke.data,_e);return Ze?React$2.createElement(Ue,{...contextPropIfNotDomElement(Ue,_e),key:Zt,index:Ke.index,height:Ke.size,type:Ke.type||"item",...Ke.type==="group"?{}:{groupIndex:Ke.groupIndex}}):Ke.type==="group"?React$2.createElement(ze,{...contextPropIfNotDomElement(ze,_e),key:Zt,"data-index":an,"data-known-size":Ke.size,"data-item-index":Ke.index,style:GROUP_STYLE},Se(Ke.index,_e)):React$2.createElement(qe,{...contextPropIfNotDomElement(qe,_e),...itemPropIfNotDomElement(qe,Ke.data),key:Zt,"data-index":an,"data-known-size":Ke.size,"data-item-index":Ke.index,"data-item-group-index":Ke.groupIndex,style:ITEM_STYLE$1},Dt?xe(Ke.index,Ke.groupIndex,Ke.data,_e):xe(Ke.index,Ke.data,_e))}))}),scrollerStyle={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},viewportStyle={width:"100%",height:"100%",position:"absolute",top:0},topItemListStyle={width:"100%",position:positionStickyCssValue(),top:0,zIndex:1};function contextPropIfNotDomElement(ne,oe){if(typeof ne!="string")return{context:oe}}function itemPropIfNotDomElement(ne,oe){return{item:typeof ne=="string"?void 0:oe}}const Header$1=React$2.memo(function(){const oe=useEmitterValue$2("HeaderComponent"),ce=usePublisher$2("headerHeight"),ue=useEmitterValue$2("headerFooterTag"),pe=useSize(ge=>ce(correctItemSize(ge,"height"))),me=useEmitterValue$2("context");return oe?React$2.createElement(ue,{ref:pe},React$2.createElement(oe,contextPropIfNotDomElement(oe,me))):null}),Footer$1=React$2.memo(function(){const oe=useEmitterValue$2("FooterComponent"),ce=usePublisher$2("footerHeight"),ue=useEmitterValue$2("headerFooterTag"),pe=useSize(ge=>ce(correctItemSize(ge,"height"))),me=useEmitterValue$2("context");return oe?React$2.createElement(ue,{ref:pe},React$2.createElement(oe,contextPropIfNotDomElement(oe,me))):null});function buildScroller({usePublisher:ne,useEmitter:oe,useEmitterValue:ce}){return React$2.memo(function({style:me,children:ge,...ye}){const ve=ne("scrollContainerState"),xe=ce("ScrollerComponent"),_e=ne("smoothScrollTargetReached"),Se=ce("scrollerRef"),$e=ce("context"),{scrollerRef:Re,scrollByCallback:Ae,scrollToCallback:Ie}=useScrollTop(ve,_e,xe,Se);return oe("scrollTo",Ie),oe("scrollBy",Ae),React$2.createElement(xe,{ref:Re,style:{...scrollerStyle,...me},"data-test-id":"virtuoso-scroller","data-virtuoso-scroller":!0,tabIndex:0,...ye,...contextPropIfNotDomElement(xe,$e)},ge)})}function buildWindowScroller({usePublisher:ne,useEmitter:oe,useEmitterValue:ce}){return React$2.memo(function({style:me,children:ge,...ye}){const ve=ne("windowScrollContainerState"),xe=ce("ScrollerComponent"),_e=ne("smoothScrollTargetReached"),Se=ce("totalListHeight"),$e=ce("deviation"),Re=ce("customScrollParent"),Ae=ce("context"),{scrollerRef:Ie,scrollByCallback:ke,scrollToCallback:Be}=useScrollTop(ve,_e,xe,noop$4,Re);return useIsomorphicLayoutEffect$1(()=>(Ie.current=Re||window,()=>{Ie.current=null}),[Ie,Re]),oe("windowScrollTo",Be),oe("scrollBy",ke),React$2.createElement(xe,{style:{position:"relative",...me,...Se!==0?{height:Se+$e}:{}},"data-virtuoso-scroller":!0,...ye,...contextPropIfNotDomElement(xe,Ae)},ge)})}const Viewport$2=({children:ne})=>{const oe=React$2.useContext(VirtuosoMockContext),ce=usePublisher$2("viewportHeight"),ue=usePublisher$2("fixedItemHeight"),pe=useSize(compose(ce,me=>correctItemSize(me,"height")));return React$2.useEffect(()=>{oe&&(ce(oe.viewportHeight),ue(oe.itemHeight))},[oe,ce,ue]),React$2.createElement("div",{style:viewportStyle,ref:pe,"data-viewport-type":"element"},ne)},WindowViewport$2=({children:ne})=>{const oe=React$2.useContext(VirtuosoMockContext),ce=usePublisher$2("windowViewportRect"),ue=usePublisher$2("fixedItemHeight"),pe=useEmitterValue$2("customScrollParent"),me=useWindowViewportRectRef(ce,pe);return React$2.useEffect(()=>{oe&&(ue(oe.itemHeight),ce({offsetTop:0,visibleHeight:oe.viewportHeight,visibleWidth:100}))},[oe,ce,ue]),React$2.createElement("div",{ref:me,style:viewportStyle,"data-viewport-type":"window"},ne)},TopItemListContainer=({children:ne})=>{const oe=useEmitterValue$2("TopItemListComponent")||"div",ce=useEmitterValue$2("headerHeight"),ue={...topItemListStyle,marginTop:`${ce}px`},pe=useEmitterValue$2("context");return React$2.createElement(oe,{style:ue,...contextPropIfNotDomElement(oe,pe)},ne)},ListRoot=React$2.memo(function(oe){const ce=useEmitterValue$2("useWindowScroll"),ue=useEmitterValue$2("topItemsIndexes").length>0,pe=useEmitterValue$2("customScrollParent"),me=pe||ce?WindowScroller$2:Scroller$2,ge=pe||ce?WindowViewport$2:Viewport$2;return React$2.createElement(me,{...oe},ue&&React$2.createElement(TopItemListContainer,null,React$2.createElement(Items$1,{showTopList:!0})),React$2.createElement(ge,null,React$2.createElement(Header$1,null),React$2.createElement(Items$1,null),React$2.createElement(Footer$1,null)))}),{Component:List,usePublisher:usePublisher$2,useEmitterValue:useEmitterValue$2,useEmitter:useEmitter$2}=systemToComponent(combinedSystem$2,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},ListRoot),Scroller$2=buildScroller({usePublisher:usePublisher$2,useEmitterValue:useEmitterValue$2,useEmitter:useEmitter$2}),WindowScroller$2=buildWindowScroller({usePublisher:usePublisher$2,useEmitterValue:useEmitterValue$2,useEmitter:useEmitter$2}),Virtuoso=List,INITIAL_GRID_STATE={items:[],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},PROBE_GRID_STATE={items:[{index:0}],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},{round,ceil,floor,min,max}=Math;function buildProbeGridState(ne){return{...PROBE_GRID_STATE,items:ne}}function buildItems(ne,oe,ce){return Array.from({length:oe-ne+1}).map((ue,pe)=>{const me=ce===null?null:ce[pe+ne];return{index:pe+ne,data:me}})}function gapComparator(ne,oe){return ne&&ne.column===oe.column&&ne.row===oe.row}function dimensionComparator(ne,oe){return ne&&ne.width===oe.width&&ne.height===oe.height}const gridSystem=system(([{overscan:ne,visibleRange:oe,listBoundary:ce},{scrollTop:ue,viewportHeight:pe,scrollBy:me,scrollTo:ge,smoothScrollTargetReached:ye,scrollContainerState:ve,footerHeight:xe,headerHeight:_e},Se,$e,{propsReady:Re,didMount:Ae},{windowViewportRect:Ie,useWindowScroll:ke,customScrollParent:Be,windowScrollContainerState:Ne,windowScrollTo:Fe},Ue])=>{const We=statefulStream(0),qe=statefulStream(0),ze=statefulStream(INITIAL_GRID_STATE),Ge=statefulStream({height:0,width:0}),Ze=statefulStream({height:0,width:0}),Dt=stream(),Je=stream(),Ut=statefulStream(0),jt=statefulStream(null),Ke=statefulStream({row:0,column:0}),an=stream(),Zt=stream(),en=statefulStream(!1),Kt=statefulStream(0),Wt=statefulStream(!0),un=statefulStream(!1);subscribe(pipe(Ae,withLatestFrom(Kt),filter(([Nt,Yt])=>!!Yt)),()=>{publish(Wt,!1),publish(qe,0)}),subscribe(pipe(combineLatest(Ae,Wt,Ze,Ge,Kt,un),filter(([Nt,Yt,Jt,hn,,Ye])=>Nt&&!Yt&&Jt.height!==0&&hn.height!==0&&!Ye)),([,,,,Nt])=>{publish(un,!0),skipFrames(1,()=>{publish(Dt,Nt)}),handleNext(pipe(ue),()=>{publish(ce,[0,0]),publish(Wt,!0)})}),connect(pipe(Zt,filter(Nt=>Nt!=null&&Nt.scrollTop>0),mapTo(0)),qe),subscribe(pipe(Ae,withLatestFrom(Zt),filter(([,Nt])=>Nt!=null)),([,Nt])=>{Nt&&(publish(Ge,Nt.viewport),publish(Ze,Nt==null?void 0:Nt.item),publish(Ke,Nt.gap),Nt.scrollTop>0&&(publish(en,!0),handleNext(pipe(ue,skip(1)),Yt=>{publish(en,!1)}),publish(ge,{top:Nt.scrollTop})))}),connect(pipe(Ge,map$1(({height:Nt})=>Nt)),pe),connect(pipe(combineLatest(duc(Ge,dimensionComparator),duc(Ze,dimensionComparator),duc(Ke,(Nt,Yt)=>Nt&&Nt.column===Yt.column&&Nt.row===Yt.row),duc(ue)),map$1(([Nt,Yt,Jt,hn])=>({viewport:Nt,item:Yt,gap:Jt,scrollTop:hn}))),an),connect(pipe(combineLatest(duc(We),oe,duc(Ke,gapComparator),duc(Ze,dimensionComparator),duc(Ge,dimensionComparator),duc(jt),duc(qe),duc(en),duc(Wt),duc(Kt)),filter(([,,,,,,,Nt])=>!Nt),map$1(([Nt,[Yt,Jt],hn,Ye,Xe,Pt,sn,,yn,qt])=>{const{row:wn,column:Tn}=hn,{height:xn,width:Nn}=Ye,{width:zn}=Xe;if(sn===0&&(Nt===0||zn===0))return INITIAL_GRID_STATE;if(Nn===0){const bn=getInitialTopMostItemIndexNumber(qt,Nt),kn=bn===0?Math.max(sn-1,0):bn;return buildProbeGridState(buildItems(bn,kn,Pt))}const Yn=itemsPerRow(zn,Nn,Tn);let Kn,Rn;yn?Yt===0&&Jt===0&&sn>0?(Kn=0,Rn=sn-1):(Kn=Yn*floor((Yt+wn)/(xn+wn)),Rn=Yn*ceil((Jt+wn)/(xn+wn))-1,Rn=min(Nt-1,max(Rn,Yn-1)),Kn=min(Rn,max(0,Kn))):(Kn=0,Rn=-1);const Mn=buildItems(Kn,Rn,Pt),{top:Xn,bottom:Jn}=gridLayout(Xe,hn,Ye,Mn),pn=ceil(Nt/Yn),Gt=pn*xn+(pn-1)*wn-Jn;return{items:Mn,offsetTop:Xn,offsetBottom:Gt,top:Xn,bottom:Jn,itemHeight:xn,itemWidth:Nn}})),ze),connect(pipe(jt,filter(Nt=>Nt!==null),map$1(Nt=>Nt.length)),We),connect(pipe(combineLatest(Ge,Ze,ze,Ke),filter(([Nt,Yt,{items:Jt}])=>Jt.length>0&&Yt.height!==0&&Nt.height!==0),map$1(([Nt,Yt,{items:Jt},hn])=>{const{top:Ye,bottom:Xe}=gridLayout(Nt,hn,Yt,Jt);return[Ye,Xe]}),distinctUntilChanged(tupleComparator)),ce);const Xt=statefulStream(!1);connect(pipe(ue,withLatestFrom(Xt),map$1(([Nt,Yt])=>Yt||Nt!==0)),Xt);const nn=streamFromEmitter(pipe(duc(ze),filter(({items:Nt})=>Nt.length>0),withLatestFrom(We,Xt),filter(([{items:Nt},Yt,Jt])=>Jt&&Nt[Nt.length-1].index===Yt-1),map$1(([,Nt])=>Nt-1),distinctUntilChanged())),vn=streamFromEmitter(pipe(duc(ze),filter(({items:Nt})=>Nt.length>0&&Nt[0].index===0),mapTo(0),distinctUntilChanged())),Sn=streamFromEmitter(pipe(duc(ze),withLatestFrom(en),filter(([{items:Nt},Yt])=>Nt.length>0&&!Yt),map$1(([{items:Nt}])=>({startIndex:Nt[0].index,endIndex:Nt[Nt.length-1].index})),distinctUntilChanged(rangeComparator),throttleTime(0)));connect(Sn,$e.scrollSeekRangeChanged),connect(pipe(Dt,withLatestFrom(Ge,Ze,We,Ke),map$1(([Nt,Yt,Jt,hn,Ye])=>{const Xe=normalizeIndexLocation(Nt),{align:Pt,behavior:sn,offset:yn}=Xe;let qt=Xe.index;qt==="LAST"&&(qt=hn-1),qt=max(0,qt,min(hn-1,qt));let wn=itemTop(Yt,Ye,Jt,qt);return Pt==="end"?wn=round(wn-Yt.height+Jt.height):Pt==="center"&&(wn=round(wn-Yt.height/2+Jt.height/2)),yn&&(wn+=yn),{top:wn,behavior:sn}})),ge);const Cn=statefulStreamFromEmitter(pipe(ze,map$1(Nt=>Nt.offsetBottom+Nt.bottom)),0);return connect(pipe(Ie,map$1(Nt=>({width:Nt.visibleWidth,height:Nt.visibleHeight}))),Ge),{data:jt,totalCount:We,viewportDimensions:Ge,itemDimensions:Ze,scrollTop:ue,scrollHeight:Je,overscan:ne,scrollBy:me,scrollTo:ge,scrollToIndex:Dt,smoothScrollTargetReached:ye,windowViewportRect:Ie,windowScrollTo:Fe,useWindowScroll:ke,customScrollParent:Be,windowScrollContainerState:Ne,deviation:Ut,scrollContainerState:ve,footerHeight:xe,headerHeight:_e,initialItemCount:qe,gap:Ke,restoreStateFrom:Zt,...$e,initialTopMostItemIndex:Kt,gridState:ze,totalListHeight:Cn,...Se,startReached:vn,endReached:nn,rangeChanged:Sn,stateChanged:an,propsReady:Re,stateRestoreInProgress:en,...Ue}},tup(sizeRangeSystem,domIOSystem,stateFlagsSystem,scrollSeekSystem,propsReadySystem,windowScrollerSystem,loggerSystem));function gridLayout(ne,oe,ce,ue){const{height:pe}=ce;if(pe===void 0||ue.length===0)return{top:0,bottom:0};const me=itemTop(ne,oe,ce,ue[0].index),ge=itemTop(ne,oe,ce,ue[ue.length-1].index)+pe;return{top:me,bottom:ge}}function itemTop(ne,oe,ce,ue){const pe=itemsPerRow(ne.width,ce.width,oe.column),me=floor(ue/pe),ge=me*ce.height+max(0,me-1)*oe.row;return ge>0?ge+oe.row:ge}function itemsPerRow(ne,oe,ce){return max(1,floor((ne+ce)/(floor(oe)+ce)))}const gridComponentPropsSystem=system(()=>{const ne=statefulStream(xe=>`Item ${xe}`),oe=statefulStream({}),ce=statefulStream(null),ue=statefulStream("virtuoso-grid-item"),pe=statefulStream("virtuoso-grid-list"),me=statefulStream(identity),ge=statefulStream("div"),ye=statefulStream(noop$4),ve=(xe,_e=null)=>statefulStreamFromEmitter(pipe(oe,map$1(Se=>Se[xe]),distinctUntilChanged()),_e);return{context:ce,itemContent:ne,components:oe,computeItemKey:me,itemClassName:ue,listClassName:pe,headerFooterTag:ge,scrollerRef:ye,FooterComponent:ve("Footer"),HeaderComponent:ve("Header"),ListComponent:ve("List","div"),ItemComponent:ve("Item","div"),ScrollerComponent:ve("Scroller","div"),ScrollSeekPlaceholder:ve("ScrollSeekPlaceholder","div")}}),combinedSystem$1=system(([ne,oe])=>({...ne,...oe}),tup(gridSystem,gridComponentPropsSystem)),GridItems=React$2.memo(function(){const oe=useEmitterValue$1("gridState"),ce=useEmitterValue$1("listClassName"),ue=useEmitterValue$1("itemClassName"),pe=useEmitterValue$1("itemContent"),me=useEmitterValue$1("computeItemKey"),ge=useEmitterValue$1("isSeeking"),ye=usePublisher$1("scrollHeight"),ve=useEmitterValue$1("ItemComponent"),xe=useEmitterValue$1("ListComponent"),_e=useEmitterValue$1("ScrollSeekPlaceholder"),Se=useEmitterValue$1("context"),$e=usePublisher$1("itemDimensions"),Re=usePublisher$1("gap"),Ae=useEmitterValue$1("log"),Ie=useEmitterValue$1("stateRestoreInProgress"),ke=useSize(Be=>{const Ne=Be.parentElement.parentElement.scrollHeight;ye(Ne);const Fe=Be.firstChild;if(Fe){const{width:Ue,height:We}=Fe.getBoundingClientRect();$e({width:Ue,height:We})}Re({row:resolveGapValue("row-gap",getComputedStyle(Be).rowGap,Ae),column:resolveGapValue("column-gap",getComputedStyle(Be).columnGap,Ae)})});return Ie?null:React$2.createElement(xe,{ref:ke,className:ce,...contextPropIfNotDomElement(xe,Se),style:{paddingTop:oe.offsetTop,paddingBottom:oe.offsetBottom},"data-test-id":"virtuoso-item-list"},oe.items.map(Be=>{const Ne=me(Be.index,Be.data,Se);return ge?React$2.createElement(_e,{key:Ne,...contextPropIfNotDomElement(_e,Se),index:Be.index,height:oe.itemHeight,width:oe.itemWidth}):React$2.createElement(ve,{...contextPropIfNotDomElement(ve,Se),className:ue,"data-index":Be.index,key:Ne},pe(Be.index,Be.data,Se))}))}),Header=React$2.memo(function(){const oe=useEmitterValue$1("HeaderComponent"),ce=usePublisher$1("headerHeight"),ue=useEmitterValue$1("headerFooterTag"),pe=useSize(ge=>ce(correctItemSize(ge,"height"))),me=useEmitterValue$1("context");return oe?React$2.createElement(ue,{ref:pe},React$2.createElement(oe,contextPropIfNotDomElement(oe,me))):null}),Footer=React$2.memo(function(){const oe=useEmitterValue$1("FooterComponent"),ce=usePublisher$1("footerHeight"),ue=useEmitterValue$1("headerFooterTag"),pe=useSize(ge=>ce(correctItemSize(ge,"height"))),me=useEmitterValue$1("context");return oe?React$2.createElement(ue,{ref:pe},React$2.createElement(oe,contextPropIfNotDomElement(oe,me))):null}),Viewport$1=({children:ne})=>{const oe=React$2.useContext(VirtuosoGridMockContext),ce=usePublisher$1("itemDimensions"),ue=usePublisher$1("viewportDimensions"),pe=useSize(me=>{ue(me.getBoundingClientRect())});return React$2.useEffect(()=>{oe&&(ue({height:oe.viewportHeight,width:oe.viewportWidth}),ce({height:oe.itemHeight,width:oe.itemWidth}))},[oe,ue,ce]),React$2.createElement("div",{style:viewportStyle,ref:pe},ne)},WindowViewport$1=({children:ne})=>{const oe=React$2.useContext(VirtuosoGridMockContext),ce=usePublisher$1("windowViewportRect"),ue=usePublisher$1("itemDimensions"),pe=useEmitterValue$1("customScrollParent"),me=useWindowViewportRectRef(ce,pe);return React$2.useEffect(()=>{oe&&(ue({height:oe.itemHeight,width:oe.itemWidth}),ce({offsetTop:0,visibleHeight:oe.viewportHeight,visibleWidth:oe.viewportWidth}))},[oe,ce,ue]),React$2.createElement("div",{ref:me,style:viewportStyle},ne)},GridRoot=React$2.memo(function({...oe}){const ce=useEmitterValue$1("useWindowScroll"),ue=useEmitterValue$1("customScrollParent"),pe=ue||ce?WindowScroller$1:Scroller$1,me=ue||ce?WindowViewport$1:Viewport$1;return React$2.createElement(pe,{...oe},React$2.createElement(me,null,React$2.createElement(Header,null),React$2.createElement(GridItems,null),React$2.createElement(Footer,null)))}),{Component:Grid,usePublisher:usePublisher$1,useEmitterValue:useEmitterValue$1,useEmitter:useEmitter$1}=systemToComponent(combinedSystem$1,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged"}},GridRoot),Scroller$1=buildScroller({usePublisher:usePublisher$1,useEmitterValue:useEmitterValue$1,useEmitter:useEmitter$1}),WindowScroller$1=buildWindowScroller({usePublisher:usePublisher$1,useEmitterValue:useEmitterValue$1,useEmitter:useEmitter$1});function resolveGapValue(ne,oe,ce){return oe!=="normal"&&!(oe!=null&&oe.endsWith("px"))&&ce(`${ne} was not resolved to pixel value correctly`,oe,LogLevel.WARN),oe==="normal"?0:parseInt(oe??"0",10)}const Scroller=reactExports.forwardRef(({style:ne,children:oe,...ce},ue)=>{const pe=reactExports.useRef(null),{palette:me,spacing:ge}=useTheme$1(),ye=useCss$1({"--os-padding-perpendicular":"2px",".os-scrollbar":{visibility:"visible",opacity:1},".os-scrollbar-vertical > .os-scrollbar-track > .os-scrollbar-handle":{"min-height":ge(12)},"div.os-scrollbar-vertical > div.os-scrollbar-track":{height:`calc(100% - ${ge(6)})`,marginTop:ge(6)},"div > div.os-scrollbar-track":{"--os-handle-perpendicular-size":"2px","--os-handle-perpendicular-size-hover":"6px","--os-handle-perpendicular-size-active":"6px","> div.os-scrollbar-handle":{borderRadius:0,opacity:.5,"&:hover":{opacity:.8}}}}),[ve]=S$5({options:{overflow:{x:"hidden",y:"scroll"},scrollbars:{autoHide:"move",theme:me.mode==="dark"?"os-theme-light":"os-theme-dark"}}});reactExports.useEffect(()=>{typeof ue!="function"&&(ue!=null&&ue.current)&&(pe!=null&&pe.current)&&ve({target:pe.current,elements:{viewport:ue.current}})},[ve]);const xe=reactExports.useCallback(_e=>{_e&&ue&&(typeof ue=="function"?ue(_e):ue.current=_e)},[ue]);return jsxRuntimeExports.jsx("div",{ref:pe,style:ne,className:ye,children:jsxRuntimeExports.jsx("div",{ref:xe,...ce,children:oe})})});function LazyList({items:ne=[],renderItem:oe,listOptions:ce,placeholder:ue,...pe}){return jsxRuntimeExports.jsx(Box$1,{...pe,children:jsxRuntimeExports.jsx(Virtuoso,{components:{Scroller},totalCount:ne.length,itemContent:me=>oe==null?void 0:oe(ne[me],me),...ce})})}function Dot({label:ne}){return jsxRuntimeExports.jsx(Tooltip$1,{title:ne,children:jsxRuntimeExports.jsx(FiberManualRecord,{sx:{color:"error.main",transform:"scale(0.5)",pl:.5,mr:2},fontSize:"small"})})}function EventInspector({event:ne,index:oe,selected:ce,label:ue,...pe}){const{spacing:me}=useTheme$1(),ge=useCss$1({}),ye=useCss$1({}),ve=lodashExports$1.omit(ne,...OMIT_PROPS),xe=lodashExports$1.pick(ve,...ESSENTIAL_PROPS),_e=lodashExports$1.omit(ve,...ESSENTIAL_PROPS);return jsxRuntimeExports.jsxs(Box$1,{sx:{position:"relative",[`> .${ye}`]:{opacity:0},[`&:hover > .${ye}`]:{opacity:1},[`&:hover > .${ge}`]:{pr:8}},children:[jsxRuntimeExports.jsxs(ListItemButton$1,{className:ge,selected:ce,...pe,sx:{height:80,borderLeft:`${me(.5)} solid ${getColorHex(ne==null?void 0:ne.type)}`,...pe.sx},children:[jsxRuntimeExports.jsxs(ListItemIcon$1,{sx:{alignItems:"center"},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"body2",children:oe}),ue&&jsxRuntimeExports.jsx(Dot,{label:ue})]}),jsxRuntimeExports.jsx(ListItemText$1,{sx:{overflow:"hidden"},primary:jsxRuntimeExports.jsxs(Box$1,{sx:{overflow:"hidden",whiteSpace:"nowrap",display:"block",textOverflow:"ellipsis",my:.5},children:[lodashExports$1.startCase(`${(ne==null?void 0:ne.type)??"event"} ${(ne==null?void 0:ne.id)??"-"}`)," "]}),secondaryTypographyProps:{component:"div",whiteSpace:"nowrap",overflow:"hidden"},secondary:jsxRuntimeExports.jsxs(Stack$1,{direction:"row",justifyContent:"flex-start",sx:{"> *":{flex:0}},children:[jsxRuntimeExports.jsx(PropertyList,{event:xe,simple:!0}),jsxRuntimeExports.jsx(PropertyList,{event:_e,simple:!0})]})})]}),jsxRuntimeExports.jsx(Stack$1,{className:ye,direction:"row",sx:{p:1,justifyContent:"center",position:"absolute",right:0,alignItems:"center",top:0,height:"100%"},children:jsxRuntimeExports.jsx(PropertyDialog,{event:ne,trigger:Se=>jsxRuntimeExports.jsx(IconButtonWithTooltip,{onClick:Se,sx:{p:1.5,color:"text.secondary"},label:"See All Properties",icon:jsxRuntimeExports.jsx(DataObjectOutlined,{fontSize:"small"})})})})]})}function Skeleton({event:ne}){const{spacing:oe}=useTheme$1();return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ListItem$1,{sx:{height:80,borderLeft:`${oe(.5)} solid ${getColorHex(ne==null?void 0:ne.type)}`},children:jsxRuntimeExports.jsx(ListItemIcon$1,{children:jsxRuntimeExports.jsx(Placeholder$3,{animation:!1,width:oe(4)})})}),jsxRuntimeExports.jsx(Divider$1,{variant:"inset"})]})}function lerp(ne,oe,ce){return ne+lodashExports$1.clamp(ce,0,1)*(oe-ne)}const ITEM_HEIGHT=80,PADDING_TOP=8,divider$2=jsxRuntimeExports.jsx(Divider$1,{orientation:"vertical",flexItem:!0,sx:{m:1}}),pxToInt=ne=>Number(ne.replace(/px$/,"")),SYMBOL_ALL=nanoid$1(),stepsLayerGuard=ne=>!!getController(ne).steps;function useStepsPageState(ne,oe){const{key:ce,setKey:ue,layers:pe,layer:me,allLayers:ge}=useLayer(ne==null?void 0:ne.layer,stepsLayerGuard),[ye,ve]=reactExports.useState(ne==null?void 0:ne.selectedType);function xe(Se){oe==null||oe({layer:Se}),ue(Se)}function _e(Se){oe==null||oe({selectedType:Se}),ve(Se)}return{setSelectedType:_e,setKey:xe,selectedType:ye,layers:pe,allLayers:ge,key:ce,layer:me}}const getStepsPageDescription=ne=>ne?`${ne} contains 0 steps.`:"When you load a trace, you'll see its steps here.";function StepsPage({template:ne}){const{spacing:oe}=useTheme$1(),ce=usePaper(),ue=useAcrylic(),pe=reactExports.useRef(null),[me,ge]=reactExports.useState(null),{controls:ye,onChange:ve,state:xe,dragHandle:_e}=useViewTreeContext(),{allLayers:Se,key:$e,layers:Re,selectedType:Ae,setKey:Ie,setSelectedType:ke,layer:Be}=useStepsPageState(xe,ve),{step:Ne,playing:Fe,stepTo:Ue}=usePlaybackState($e),We=reactExports.useMemo(()=>{if(Be){const{steps:Je}=getController(Be);return Je(Be)}},[Be]),{steps:qe,types:ze,stepToFilteredStep:Ge,selectedType:Ze}=reactExports.useMemo(()=>{if(We){const Je=We.map((Zt,en)=>[Zt,en]),Ut=lodashExports$1.chain(Je).map(([Zt])=>Zt.type).filter().uniq().value(),jt=!Ut.includes(Ae),Ke=jt?Je:Je.filter(([Zt])=>Zt.type===Ae),{stepMap:an}=lodashExports$1.reduce(Je,(Zt,[,en])=>{const Kt=lodashExports$1.findIndex(Ke,([,un])=>un>=en,Zt.from),Wt=Kt===-1?Ke.length:Kt;return Zt.from=Wt,Zt.stepMap.push(Wt),Zt},{from:0,stepMap:[]});return{steps:Ke,types:Ut,stepToFilteredStep:Zt=>an[Zt],selectedType:jt?SYMBOL_ALL:Ae}}return{}},[We,Ae]),Dt=useBreakpoints($e);return reactExports.useEffect(()=>{if(Ge&&me&&pe.current){const Je=Ge(Ne);if(Fe){let Ut=!1;const jt=Ke=>{var an;if(!Ut&&"scrollTop"in me&&!lodashExports$1.isUndefined(Ne)){const{scrollTop:Zt}=me,en=Je*ITEM_HEIGHT;(an=pe.current)==null||an.scrollTo({top:lerp(Zt,en,1e-6*Ke)}),requestAnimationFrame(jt)}};return requestAnimationFrame(jt),()=>{Ut=!0}}else pe.current.scrollToIndex({index:Je,behavior:"smooth",offset:-pxToInt(oe(12+PADDING_TOP))})}},[Ne,pe,me,Ge,Fe]),jsxRuntimeExports.jsxs(ne,{onChange:ve,stack:xe,children:[jsxRuntimeExports.jsx(ne.Title,{children:"Steps"}),jsxRuntimeExports.jsx(ne.Handle,{children:_e}),jsxRuntimeExports.jsxs(ne.Content,{children:[jsxRuntimeExports.jsx(Flex,{vertical:!0,alignItems:"center",children:qe?qe.length?jsxRuntimeExports.jsx(LazyList,{sx:{width:"100%",height:"100%"},items:qe,listOptions:{scrollerRef:ge,ref:pe,defaultItemHeight:ITEM_HEIGHT,overscan:0},renderItem:([Je,Ut],jt)=>{var Ke;return Fe?jsxRuntimeExports.jsx(Box$1,{sx:{pt:jt?0:oe(6+PADDING_TOP)},children:jsxRuntimeExports.jsx(Skeleton,{event:Je})},jt):jsxRuntimeExports.jsxs(Box$1,{sx:{height:pxToInt(oe(jt?0:6+PADDING_TOP))+ITEM_HEIGHT,pt:jt?0:oe(6+PADDING_TOP)},children:[jsxRuntimeExports.jsx(EventInspector,{event:Je,index:Ut,selected:Ut===Ne,label:(Ke=Dt(Ut))==null?void 0:Ke.result,onClick:()=>Ue(Ut)}),jsxRuntimeExports.jsx(Divider$1,{variant:"inset"})]},jt)}}):jsxRuntimeExports.jsx(Placeholder$2,{icon:jsxRuntimeExports.jsx(StepsIcon,{}),label:"Events",secondary:getStepsPageDescription(inferLayerName(Be))}):jsxRuntimeExports.jsx(Placeholder$2,{icon:jsxRuntimeExports.jsx(StepsIcon,{}),label:"Events",secondary:getStepsPageDescription()})}),!!(qe!=null&&qe.length)&&jsxRuntimeExports.jsx(Stack$1,{direction:"row",sx:{...ce(1),...ue,alignItems:"center",position:"absolute",top:Je=>Je.spacing(6),height:Je=>Je.spacing(6),borderRadius:1,px:1,m:1},children:jsxRuntimeExports.jsx(Playback,{layer:Be})})]}),jsxRuntimeExports.jsxs(ne.Options,{children:[jsxRuntimeExports.jsx(FeaturePicker,{icon:jsxRuntimeExports.jsx(LayersIcon,{}),label:"Layer",value:$e,items:lodashExports$1.map(Se,Je=>({id:Je.key,hidden:!lodashExports$1.find(Re,{key:Je.key}),name:inferLayerName(Je)})),onChange:Ie,arrow:!0,ellipsis:12}),divider$2,jsxRuntimeExports.jsx(FeaturePicker,{icon:jsxRuntimeExports.jsx(FiberManualRecordOutlined,{sx:{color:Ze===SYMBOL_ALL||!Ze?grey$1[tint]:getColorHex(Ze)}}),label:"Event Type",value:Ze,items:[{id:SYMBOL_ALL,name:"All Events"},...lodashExports$1.map(ze,Je=>({id:`${Je}`,name:lodashExports$1.startCase(Je)}))],onChange:ke,arrow:!0,ellipsis:12})]}),jsxRuntimeExports.jsx(ne.Extras,{children:ye})]})}function SelectMulti({trigger:ne,items:oe,value:ce,onChange:ue,placeholder:pe="Select Options",defaultChecked:me}){return useSmallDisplay(),lodashExports$1.max([lodashExports$1.findIndex(oe,({value:ge})=>!!(ce!=null&&ce[ge])),0]),jsxRuntimeExports.jsx(PopupState,{variant:"popover",children:ge=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Tooltip$1,{title:pe,children:jsxRuntimeExports.jsx("span",{children:ne==null?void 0:ne(bindTrigger(ge))})}),jsxRuntimeExports.jsx(Menu$1,{...bindMenu(ge),anchorOrigin:{horizontal:"left",vertical:"bottom"},transformOrigin:{vertical:"top",horizontal:"left"},children:lodashExports$1.map(oe,({value:ye,label:ve,disabled:xe})=>jsxRuntimeExports.jsxs(MenuItem$1,{disabled:xe,onClick:()=>{ue==null||ue({...ce,[ye]:!((ce==null?void 0:ce[ye])??me)})},children:[jsxRuntimeExports.jsx(ListItemIcon$1,{children:jsxRuntimeExports.jsx(Checkbox$1,{sx:{p:0},checked:!!((ce==null?void 0:ce[ye])??me)})}),ve]},ye))})]})})}function FeaturePickerMulti({label:ne,value:oe,onChange:ce,items:ue,icon:pe,showArrow:me,defaultChecked:ge,ellipsis:ye=1/0}){var _e;const ve=lodashExports$1.filter(ue,({id:Se})=>!!((oe==null?void 0:oe[Se])??ge)),xe=ve.length?ve.length===1?(_e=lodashExports$1.head(ve))==null?void 0:_e.name:`${ve.length} Selected`:ne;return jsxRuntimeExports.jsx(SelectMulti,{defaultChecked:!0,placeholder:lodashExports$1.startCase(ne),trigger:Se=>jsxRuntimeExports.jsx(FeaturePickerButton,{...Se,disabled:!(ue!=null&&ue.length),icon:pe,arrow:me,children:lodashExports$1.truncate(xe,{length:ye})}),items:lodashExports$1.map(ue,({id:Se,name:$e,description:Re,hidden:Ae})=>({value:Se,label:jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Type$2,{component:"div",children:$e}),jsxRuntimeExports.jsx(Space,{}),jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"body2",color:"text.secondary",children:Re})]}),disabled:Ae})),value:oe,onChange:ce})}function useRendererResolver(ne){var ue,pe;const[oe]=useRenderers(),ce=reactExports.useMemo(()=>lodashExports$1.head(oe),[oe]);return{auto:ce,selected:ne&&ne!=="internal:auto"?ne:(pe=(ue=ce==null?void 0:ce.renderer)==null?void 0:ue.meta)==null?void 0:pe.id}}const divider$1=jsxRuntimeExports.jsx(Divider$1,{orientation:"vertical",flexItem:!0,sx:{m:1}});function ViewportPage({template:ne}){var ke,Be;const{controls:oe,onChange:ce,state:ue,dragHandle:pe}=useViewTreeContext(),[me]=useRenderers(),ge=usePaper(),ye=useAcrylic(),[{layers:ve}]=useLayers(),[xe,_e]=reactExports.useState({}),Se=reactExports.useMemo(()=>lodashExports$1.filter(ve,Ne=>(xe==null?void 0:xe[Ne.key])??!0),[xe,ve,ve==null?void 0:ve.length]),[$e,Re]=reactExports.useState(),{selected:Ae,auto:Ie}=useRendererResolver(ue==null?void 0:ue.renderer);return reactExports.useEffect(()=>{lodashExports$1.delay(()=>{var Ne;(Ne=$e==null?void 0:$e.fitCamera)==null||Ne.call($e,Fe=>{var Ue;return lodashExports$1.chain(Se).filter("viewKey").map("key").includes(((Ue=Fe.meta)==null?void 0:Ue.sourceLayer)??"").value()})},150)},[$e,lodashExports$1.chain(Se).map("viewKey").sort().join(".").value()]),jsxRuntimeExports.jsxs(ne,{onChange:ce,stack:ue,children:[jsxRuntimeExports.jsx(ne.Key,{children:"viewport"}),jsxRuntimeExports.jsx(ne.Title,{children:"Viewport"}),jsxRuntimeExports.jsx(ne.Handle,{children:pe}),jsxRuntimeExports.jsx(ne.Content,{children:jsxRuntimeExports.jsx(Flex,{children:jsxRuntimeExports.jsx(AutoSizer,{children:Ne=>jsxRuntimeExports.jsxs(Box$1,{children:[jsxRuntimeExports.jsx(TraceRenderer,{...Ne,layers:Se,renderer:Ae,rendererRef:Re}),jsxRuntimeExports.jsx(Stack$1,{sx:{pt:6,position:"absolute",top:0,left:0},children:jsxRuntimeExports.jsxs(Stack$1,{direction:"row",sx:{...ge(1),...ye,alignItems:"center",height:Fe=>Fe.spacing(6),px:1,m:1},children:[jsxRuntimeExports.jsx(IconButtonWithTooltip,{color:"primary",disabled:!$e,onClick:()=>{$e==null||$e.fitCamera()},label:"Fit",icon:jsxRuntimeExports.jsx(CenterFocusWeakOutlined,{})}),jsxRuntimeExports.jsx(IconButtonWithTooltip,{color:"primary",disabled:!$e,onClick:()=>{var Fe;(Fe=$e==null?void 0:$e.initialCamera)==null||Fe.call($e)},icon:jsxRuntimeExports.jsx(TimesOneMobiledataOutlined,{}),label:"1 to 1"}),divider$1,jsxRuntimeExports.jsx(IconButtonWithTooltip,{color:"primary",disabled:!$e,onClick:async()=>{const Fe=await($e==null?void 0:$e.toDataUrl());Fe&&download(Fe,dist$4.generateUsername("-"))},icon:jsxRuntimeExports.jsx(CameraOutlined,{}),label:"capture-screenshot"})]})})]})})})}),jsxRuntimeExports.jsx(ne.Options,{children:jsxRuntimeExports.jsxs(Stack$1,{direction:"row",children:[jsxRuntimeExports.jsx(FeaturePicker,{label:"Renderer",icon:jsxRuntimeExports.jsx(BlurCircularOutlined,{}),value:(ue==null?void 0:ue.renderer)??"internal:auto",onChange:Ne=>ce==null?void 0:ce({renderer:Ne}),items:[{id:"internal:auto",name:`Auto (${((Be=(ke=Ie==null?void 0:Ie.renderer)==null?void 0:ke.meta)==null?void 0:Be.name)??"None"})`},...lodashExports$1.map(me,({renderer:Ne})=>({id:Ne.meta.id,name:Ne.meta.name,description:Ne.meta.id}))],arrow:!0}),divider$1,jsxRuntimeExports.jsx(FeaturePickerMulti,{defaultChecked:!0,label:"Layers",icon:jsxRuntimeExports.jsx(LayersIcon,{}),value:xe,onChange:_e,items:lodashExports$1.map(ve,Ne=>({id:Ne.key,name:inferLayerName(Ne)})),showArrow:!0,ellipsis:12})]})}),jsxRuntimeExports.jsx(ne.Extras,{children:oe})]})}const isSourceLayer=ne=>{var oe;return!!((oe=getController(ne))!=null&&oe.getSources)};function SourcePage({template:ne}){const oe=useTheme$1();useMonacoTheme(oe);const{layers:ce}=useLayer(void 0,isSourceLayer),ue=reactExports.useMemo(()=>{var xe;return(xe=ce==null?void 0:ce.flatMap)==null?void 0:xe.call(ce,_e=>{var Se,$e,Re,Ae;return(Ae=(Re=($e=(Se=getController(_e))==null?void 0:Se.getSources)==null?void 0:$e.call(Se,_e))==null?void 0:Re.map)==null?void 0:Ae.call(Re,Ie=>({layer:_e.key,source:Ie}))})},[ce]),{controls:pe,onChange:me,state:ge,dragHandle:ye}=useViewTreeContext(),ve=reactExports.useMemo(()=>lodashExports$1.find(ue,xe=>xe&&xe.source.id===(ge==null?void 0:ge.source)&&xe.layer===(ge==null?void 0:ge.layer))??lodashExports$1.first(ue),[ue,ge==null?void 0:ge.source,ge==null?void 0:ge.layer]);return jsxRuntimeExports.jsxs(ne,{onChange:me,stack:ge,children:[jsxRuntimeExports.jsx(ne.Key,{children:"source"}),jsxRuntimeExports.jsx(ne.Title,{children:"Source"}),jsxRuntimeExports.jsx(ne.Handle,{children:ye}),jsxRuntimeExports.jsx(ne.Content,{children:ue!=null&&ue.length?jsxRuntimeExports.jsx(Flex,{pt:6,children:jsxRuntimeExports.jsx(AutoSizer,{children:xe=>{var _e,Se;return jsxRuntimeExports.jsx(de,{theme:oe.palette.mode==="dark"?"posthoc-dark":"light",options:{readOnly:!0},language:(_e=ve==null?void 0:ve.source)==null?void 0:_e.language,loading:jsxRuntimeExports.jsx(CircularProgress$1,{variant:"indeterminate"}),...xe,value:(Se=ve==null?void 0:ve.source)==null?void 0:Se.content})}})}):jsxRuntimeExports.jsx(Placeholder$2,{icon:jsxRuntimeExports.jsx(CodeOutlined,{}),label:"Source"})}),jsxRuntimeExports.jsx(ne.Options,{children:!!(ue!=null&&ue.length)&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Tabs$1,{value:`${ve==null?void 0:ve.source.id}::${ve==null?void 0:ve.layer}`,onChange:(xe,_e)=>{const[Se,$e]=_e.split("::");me==null||me({source:Se,layer:$e})},children:lodashExports$1.map(ue,({source:xe,layer:_e})=>jsxRuntimeExports.jsx(Tab$1,{label:xe.name,value:`${xe.id}::${_e}`}))})})}),jsxRuntimeExports.jsx(ne.Extras,{children:pe})]})}const pages={explore:{id:"explore",name:"Explore",color:"deepOrange",description:"Browse examples and guides",icon:jsxRuntimeExports.jsx(RocketIcon,{}),content:ExplorePage,allowFullscreen:!0,showInSidebar:"always"},layers:{id:"layers",name:"Layers",description:"",color:"pink",icon:jsxRuntimeExports.jsx(LayersIcon,{}),content:LayersPage,allowFullscreen:!0,showInSidebar:"mobile-only"},steps:{id:"steps",name:"Events",description:"",color:"pink",icon:jsxRuntimeExports.jsx(StepsIcon,{}),content:StepsPage,allowFullscreen:!0},viewport:{id:"viewport",name:"Viewport",description:"",color:"deepPurple",icon:jsxRuntimeExports.jsx(ViewportIcon,{}),content:ViewportPage,allowFullscreen:!0},tree:{id:"tree",name:"Graph",description:"",color:"deepPurple",icon:jsxRuntimeExports.jsx(TreeIcon,{}),content:TreePage,allowFullscreen:!0},source:{id:"source",name:"Sources",description:"",color:"deepPurple",icon:jsxRuntimeExports.jsx(CodeOutlined,{}),content:SourcePage,allowFullscreen:!0,showInSidebar:"mobile-only"},debug:{id:"debug",name:"Debugger",description:"",color:"indigo",icon:jsxRuntimeExports.jsx(DebuggerIcon,{}),content:DebugPage,allowFullscreen:!0,showInSidebar:"mobile-only"},info:{id:"info",name:"Logs",description:"",color:"grey",icon:jsxRuntimeExports.jsx(ListOutlined,{}),content:InfoPage,allowFullscreen:!0},settings:{id:"settings",name:"Settings",description:"",color:"grey",icon:jsxRuntimeExports.jsx(SettingsIcon,{}),content:SettingsPage,allowFullscreen:!0,showInSidebar:"always"}},ErrorBoundaryContext=reactExports.createContext(null),initialState={didCatch:!1,error:null};class ErrorBoundary extends reactExports.Component{constructor(oe){super(oe),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=initialState}static getDerivedStateFromError(oe){return{didCatch:!0,error:oe}}resetErrorBoundary(){const{error:oe}=this.state;if(oe!==null){for(var ce,ue,pe=arguments.length,me=new Array(pe),ge=0;ge0&&arguments[0]!==void 0?arguments[0]:[],oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return ne.length!==oe.length||ne.some((ce,ue)=>!Object.is(ce,oe[ue]))}const divider=jsxRuntimeExports.jsx(Divider$1,{orientation:"vertical",flexItem:!0,sx:{m:1,height:ne=>ne.spacing(3),alignSelf:"auto"}}),Page=withSlots(({slotProps:ne,onChange:oe,stack:ce})=>{var pe,me,ge,ye;const ue=useAcrylic();return jsxRuntimeExports.jsx(ErrorBoundary,{fallbackRender:ve=>{var xe,_e;return jsxRuntimeExports.jsxs(Stack$1,{sx:{background:Se=>Se.palette.background.paper,height:"100%"},children:[jsxRuntimeExports.jsxs(Stack$1,{direction:"row",sx:{height:Se=>Se.spacing(6),alignItems:"center",pl:1,borderBottom:1,borderColor:"divider"},children:[(xe=ne.Handle)==null?void 0:xe.children,jsxRuntimeExports.jsx(FeaturePicker,{icon:jsxRuntimeExports.jsx(WidgetsOutlined,{}),label:"Choose View",onChange:Se=>oe==null?void 0:oe({...ce,type:Se}),value:ce==null?void 0:ce.type,items:lodashExports$1.values(pages),itemOrientation:"vertical"}),jsxRuntimeExports.jsx(Space,{sx:{mx:"auto"}}),(_e=ne.Extras)==null?void 0:_e.children]}),jsxRuntimeExports.jsx(Placeholder$2,{secondary:`${ve.error}`,icon:jsxRuntimeExports.jsx(ErrorOutlineOutlined,{})})]})},children:jsxRuntimeExports.jsxs(Flex,{vertical:!0,children:[jsxRuntimeExports.jsx(Flex,{sx:{position:"absolute",top:0,left:0,width:"100%"},children:jsxRuntimeExports.jsx(Box$1,{sx:{width:"100%",height:"100%",bgcolor:"background.paper"},children:(pe=ne.Content)==null?void 0:pe.children})}),jsxRuntimeExports.jsxs(Flex,{sx:{height:ve=>ve.spacing(6),alignItems:"center"},children:[jsxRuntimeExports.jsx(Flex,{sx:{p:0,position:"absolute",top:0,left:0,width:"100%",borderBottom:1,borderColor:"divider",alignItems:"center",pr:6,...ue},children:jsxRuntimeExports.jsx(Scroll,{x:!0,children:jsxRuntimeExports.jsxs(Flex,{sx:{width:"max-content",height:ve=>ve.spacing(6),alignItems:"center",p:1},children:[(me=ne.Handle)==null?void 0:me.children,jsxRuntimeExports.jsx(FeaturePicker,{icon:jsxRuntimeExports.jsx(WidgetsOutlined,{}),label:"Choose View",onChange:ve=>oe==null?void 0:oe({...ce,type:ve}),value:ce==null?void 0:ce.type,items:lodashExports$1.values(pages),itemOrientation:"vertical"}),((ge=ne.Options)==null?void 0:ge.children)&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[divider,ne.Options.children]})]})})}),jsxRuntimeExports.jsx(Space,{sx:{mx:"auto"}}),(ye=ne.Extras)==null?void 0:ye.children]})]})})}),SidebarPage=withSlots(({slotProps:ne})=>{var pe,me,ge;const oe=useSidebarBackground(),ce=useAcrylic(oe),[,ue]=useUIState();return jsxRuntimeExports.jsx(ErrorBoundary,{fallback:jsxRuntimeExports.jsx(Box$1,{sx:{p:6,background:ye=>ye.palette.background.paper,height:"100%"},children:"This page encountered an error."}),children:jsxRuntimeExports.jsxs(Flex,{vertical:!0,children:[jsxRuntimeExports.jsx(Flex,{sx:{position:"absolute",top:0,left:0,width:"100%"},children:jsxRuntimeExports.jsx(Box$1,{sx:{width:"100%",height:"100%",bgcolor:oe},children:(pe=ne.Content)==null?void 0:pe.children})}),jsxRuntimeExports.jsx(Flex,{sx:{height:ye=>ye.spacing(6)},children:jsxRuntimeExports.jsxs(Flex,{sx:{p:0,position:"absolute",top:0,left:0,width:"100%",borderBottom:1,borderColor:"divider",alignItems:"center",...ce},children:[jsxRuntimeExports.jsx(Scroll,{x:!0,children:jsxRuntimeExports.jsxs(Flex,{sx:{width:"max-content",height:ye=>ye.spacing(6),alignItems:"center",p:1},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",sx:{p:1,color:"text.secondary"},children:(me=ne.Title)==null?void 0:me.children}),((ge=ne.Options)==null?void 0:ge.children)&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[divider,ne.Options.children]})]})}),jsxRuntimeExports.jsx(IconButtonWithTooltip,{onClick:()=>{ue(()=>{var ye;return{fullscreenModal:(ye=ne.Key)==null?void 0:ye.children,sidebarOpen:!1}})},size:"small",sx:{m:1},icon:jsxRuntimeExports.jsx(FullscreenOutlined,{sx:{color:"text.secondary"},fontSize:"small"}),label:"Maximise"})]})})]})})});var sysend$1={exports:{}};/**@license + }`,this._stylesheet)}get stylesheet(){return this._stylesheet}set stylesheet(ne){this._stylesheet!==ne&&(this._stylesheet=ne,this.styleID++)}normalizeColor(ne){return Array.isArray(ne)&&(ne=rgb2hex(ne)),typeof ne=="number"?hex2string(ne):ne}dropShadowToCSS(){let ne=this.normalizeColor(this.dropShadowColor);const oe=this.dropShadowAlpha,ce=Math.round(Math.cos(this.dropShadowAngle)*this.dropShadowDistance),ue=Math.round(Math.sin(this.dropShadowAngle)*this.dropShadowDistance);ne.startsWith("#")&&oe<1&&(ne+=(oe*255|0).toString(16).padStart(2,"0"));const pe=`${ce}px ${ue}px`;return this.dropShadowBlur>0?`text-shadow: ${pe} ${this.dropShadowBlur}px ${ne}`:`text-shadow: ${pe} ${ne}`}reset(){Object.assign(this,_HTMLTextStyle.defaultOptions)}onBeforeDraw(){const{fontsDirty:ne}=this;return this.fontsDirty=!1,this.isSafari&&this._fonts.length>0&&ne?new Promise(oe=>setTimeout(oe,100)):Promise.resolve()}get isSafari(){const{userAgent:ne}=settings.ADAPTER.getNavigator();return/^((?!chrome|android).)*safari/i.test(ne)}set fillGradientStops(ne){console.warn("[HTMLTextStyle] fillGradientStops is not supported by HTMLText")}get fillGradientStops(){return super.fillGradientStops}set fillGradientType(ne){console.warn("[HTMLTextStyle] fillGradientType is not supported by HTMLText")}get fillGradientType(){return super.fillGradientType}set miterLimit(ne){console.warn("[HTMLTextStyle] miterLimit is not supported by HTMLText")}get miterLimit(){return super.miterLimit}set trim(ne){console.warn("[HTMLTextStyle] trim is not supported by HTMLText")}get trim(){return super.trim}set textBaseline(ne){console.warn("[HTMLTextStyle] textBaseline is not supported by HTMLText")}get textBaseline(){return super.textBaseline}set leading(ne){console.warn("[HTMLTextStyle] leading is not supported by HTMLText")}get leading(){return super.leading}set lineJoin(ne){console.warn("[HTMLTextStyle] lineJoin is not supported by HTMLText")}get lineJoin(){return super.lineJoin}};let HTMLTextStyle=_HTMLTextStyle;HTMLTextStyle.availableFonts={};HTMLTextStyle.defaultOptions={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,padding:0,stroke:"black",strokeThickness:0,whiteSpace:"normal",wordWrap:!1,wordWrapWidth:100};const _HTMLText=class extends Sprite{constructor(ne="",oe={}){super(Texture.EMPTY),this._text=null,this._style=null,this._autoResolution=!0,this._loading=!1,this.localStyleID=-1,this.dirty=!1,this.ownsStyle=!1;const ce=new Image,ue=Texture.from(ce,{scaleMode:settings.SCALE_MODE,resourceOptions:{autoLoad:!1}});ue.orig=new Rectangle,ue.trim=new Rectangle,this.texture=ue;const pe="http://www.w3.org/2000/svg",me="http://www.w3.org/1999/xhtml",ge=document.createElementNS(pe,"svg"),ye=document.createElementNS(pe,"foreignObject"),ve=document.createElementNS(me,"div"),xe=document.createElementNS(me,"style");ye.setAttribute("width","10000"),ye.setAttribute("height","10000"),ye.style.overflow="hidden",ge.appendChild(ye),this.maxWidth=_HTMLText.defaultMaxWidth,this.maxHeight=_HTMLText.defaultMaxHeight,this._domElement=ve,this._styleElement=xe,this._svgRoot=ge,this._foreignObject=ye,this._foreignObject.appendChild(xe),this._foreignObject.appendChild(ve),this._image=ce,this._loadImage=new Image,this._autoResolution=_HTMLText.defaultAutoResolution,this._resolution=_HTMLText.defaultResolution??settings.RESOLUTION,this.text=ne,this.style=oe}measureText(ne){var ye,ve;const{text:oe,style:ce,resolution:ue}=Object.assign({text:this._text,style:this._style,resolution:this._resolution},ne);Object.assign(this._domElement,{innerHTML:oe,style:ce.toCSS(ue)}),this._styleElement.textContent=ce.toGlobalCSS(),document.body.appendChild(this._svgRoot);const pe=this._domElement.getBoundingClientRect();this._svgRoot.remove();const me=Math.min(this.maxWidth,Math.ceil(pe.width)),ge=Math.min(this.maxHeight,Math.ceil(pe.height));return this._svgRoot.setAttribute("width",me.toString()),this._svgRoot.setAttribute("height",ge.toString()),oe!==this._text&&(this._domElement.innerHTML=this._text),ce!==this._style&&(Object.assign(this._domElement,{style:(ye=this._style)==null?void 0:ye.toCSS(ue)}),this._styleElement.textContent=(ve=this._style)==null?void 0:ve.toGlobalCSS()),{width:me+ce.padding*2,height:ge+ce.padding*2}}async updateText(ne=!0){const{style:oe,_image:ce,_loadImage:ue}=this;if(this.localStyleID!==oe.styleID&&(this.dirty=!0,this.localStyleID=oe.styleID),!this.dirty&&ne)return;const{width:pe,height:me}=this.measureText();ce.width=ue.width=Math.ceil(Math.max(1,pe)),ce.height=ue.height=Math.ceil(Math.max(1,me)),this._loading||(this._loading=!0,await new Promise(ge=>{ue.onload=async()=>{await oe.onBeforeDraw(),this._loading=!1,ce.src=ue.src,ue.onload=null,ue.src="",this.updateTexture(),ge()};const ye=new XMLSerializer().serializeToString(this._svgRoot);ue.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(ye)}`}))}get source(){return this._image}updateTexture(){const{style:ne,texture:oe,_image:ce,resolution:ue}=this,{padding:pe}=ne,{baseTexture:me}=oe;oe.trim.width=oe._frame.width=ce.width/ue,oe.trim.height=oe._frame.height=ce.height/ue,oe.trim.x=-pe,oe.trim.y=-pe,oe.orig.width=oe._frame.width-pe*2,oe.orig.height=oe._frame.height-pe*2,this._onTextureUpdate(),me.setRealSize(ce.width,ce.height,ue),this.dirty=!1}_render(ne){this._autoResolution&&this._resolution!==ne.resolution&&(this._resolution=ne.resolution,this.dirty=!0),this.updateText(!0),super._render(ne)}_renderCanvas(ne){this._autoResolution&&this._resolution!==ne.resolution&&(this._resolution=ne.resolution,this.dirty=!0),this.updateText(!0),super._renderCanvas(ne)}getLocalBounds(ne){return this.updateText(!0),super.getLocalBounds(ne)}_calculateBounds(){this.updateText(!0),this.calculateVertices(),this._bounds.addQuad(this.vertexData)}_onStyleChange(){this.dirty=!0}destroy(ne){var ce,ue,pe,me,ge;typeof ne=="boolean"&&(ne={children:ne}),ne=Object.assign({},_HTMLText.defaultDestroyOptions,ne),super.destroy(ne);const oe=null;this.ownsStyle&&((ce=this._style)==null||ce.cleanFonts()),this._style=oe,(ue=this._svgRoot)==null||ue.remove(),this._svgRoot=oe,(pe=this._domElement)==null||pe.remove(),this._domElement=oe,(me=this._foreignObject)==null||me.remove(),this._foreignObject=oe,(ge=this._styleElement)==null||ge.remove(),this._styleElement=oe,this._loadImage.src="",this._loadImage.onload=null,this._loadImage=oe,this._image.src="",this._image=oe}get width(){return this.updateText(!0),Math.abs(this.scale.x)*this._image.width/this.resolution}set width(ne){this.updateText(!0);const oe=sign$2(this.scale.x)||1;this.scale.x=oe*ne/this._image.width/this.resolution,this._width=ne}get height(){return this.updateText(!0),Math.abs(this.scale.y)*this._image.height/this.resolution}set height(ne){this.updateText(!0);const oe=sign$2(this.scale.y)||1;this.scale.y=oe*ne/this._image.height/this.resolution,this._height=ne}get style(){return this._style}set style(ne){this._style!==ne&&(ne=ne||{},ne instanceof HTMLTextStyle?(this.ownsStyle=!1,this._style=ne):ne instanceof TextStyle?(console.warn("[HTMLText] Cloning TextStyle, if this is not what you want, use HTMLTextStyle"),this.ownsStyle=!0,this._style=HTMLTextStyle.from(ne)):(this.ownsStyle=!0,this._style=new HTMLTextStyle(ne)),this.localStyleID=-1,this.dirty=!0)}get text(){return this._text}set text(ne){ne=String(ne===""||ne===null||ne===void 0?" ":ne),ne=this.sanitiseText(ne),this._text!==ne&&(this._text=ne,this.dirty=!0)}get resolution(){return this._resolution}set resolution(ne){this._autoResolution=!1,this._resolution!==ne&&(this._resolution=ne,this.dirty=!0)}sanitiseText(ne){return ne.replace(/
/gi,"
").replace(/
/gi,"
").replace(/ /gi," ")}};let HTMLText=_HTMLText;HTMLText.defaultDestroyOptions={texture:!0,children:!1,baseTexture:!0};HTMLText.defaultMaxWidth=2024;HTMLText.defaultMaxHeight=2024;HTMLText.defaultAutoResolution=!0;function makeRenderer(ne,oe){return{constructor:ne,meta:oe}}function quickselect(ne,oe,ce,ue,pe){quickselectStep(ne,oe,ce||0,ue||ne.length-1,pe||defaultCompare)}function quickselectStep(ne,oe,ce,ue,pe){for(;ue>ce;){if(ue-ce>600){var me=ue-ce+1,ge=oe-ce+1,ye=Math.log(me),ve=.5*Math.exp(2*ye/3),xe=.5*Math.sqrt(ye*ve*(me-ve)/me)*(ge-me/2<0?-1:1),_e=Math.max(ce,Math.floor(oe-ge*ve/me+xe)),Se=Math.min(ue,Math.floor(oe+(me-ge)*ve/me+xe));quickselectStep(ne,oe,_e,Se,pe)}var $e=ne[oe],Re=ce,Ae=ue;for(swap(ne,ce,oe),pe(ne[ue],$e)>0&&swap(ne,ce,ue);Re0;)Ae--}pe(ne[ce],$e)===0?swap(ne,ce,Ae):(Ae++,swap(ne,Ae,ue)),Ae<=oe&&(ce=Ae+1),oe<=Ae&&(ue=Ae-1)}}function swap(ne,oe,ce){var ue=ne[oe];ne[oe]=ne[ce],ne[ce]=ue}function defaultCompare(ne,oe){return neoe?1:0}class RBush{constructor(oe=9){this._maxEntries=Math.max(4,oe),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(oe){let ce=this.data;const ue=[];if(!intersects(oe,ce))return ue;const pe=this.toBBox,me=[];for(;ce;){for(let ge=0;ge=0&&me[ce].children.length>this._maxEntries;)this._split(me,ce),ce--;this._adjustParentBBoxes(pe,me,ce)}_split(oe,ce){const ue=oe[ce],pe=ue.children.length,me=this._minEntries;this._chooseSplitAxis(ue,me,pe);const ge=this._chooseSplitIndex(ue,me,pe),ye=createNode(ue.children.splice(ge,ue.children.length-ge));ye.height=ue.height,ye.leaf=ue.leaf,calcBBox(ue,this.toBBox),calcBBox(ye,this.toBBox),ce?oe[ce-1].children.push(ye):this._splitRoot(ue,ye)}_splitRoot(oe,ce){this.data=createNode([oe,ce]),this.data.height=oe.height+1,this.data.leaf=!1,calcBBox(this.data,this.toBBox)}_chooseSplitIndex(oe,ce,ue){let pe,me=1/0,ge=1/0;for(let ye=ce;ye<=ue-ce;ye++){const ve=distBBox(oe,0,ye,this.toBBox),xe=distBBox(oe,ye,ue,this.toBBox),_e=intersectionArea(ve,xe),Se=bboxArea(ve)+bboxArea(xe);_e=ce;xe--){const _e=oe.children[xe];extend$1(ye,oe.leaf?me(_e):_e),ve+=bboxMargin(ye)}return ve}_adjustParentBBoxes(oe,ce,ue){for(let pe=ue;pe>=0;pe--)extend$1(ce[pe],oe)}_condense(oe){for(let ce=oe.length-1,ue;ce>=0;ce--)oe[ce].children.length===0?ce>0?(ue=oe[ce-1].children,ue.splice(ue.indexOf(oe[ce]),1)):this.clear():calcBBox(oe[ce],this.toBBox)}}function findItem(ne,oe,ce){if(!ce)return oe.indexOf(ne);for(let ue=0;ue=ne.minX&&oe.maxY>=ne.minY}function createNode(ne){return{children:ne,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function multiSelect(ne,oe,ce,ue,pe){const me=[oe,ce];for(;me.length;){if(ce=me.pop(),oe=me.pop(),ce-oe<=ue)continue;const ge=oe+Math.ceil((ce-oe)/ue/2)*ue;quickselect(ne,ge,oe,ce,pe),me.push(oe,ge,ge,ce)}}class Bush extends RBush{toBBox(oe){return{minX:oe.left,minY:oe.top,maxX:oe.right,maxY:oe.bottom}}compareMinX(oe,ce){return oe.left-ce.left}compareMinY(oe,ce){return oe.top-ce.top}}const defaultD2RendererOptions={screenSize:{width:1,height:1},workerCount:4,workerIndex:0,tileResolution:{width:64,height:64},tileSubdivision:0,refreshInterval:1e3/60,animationDuration:150,debounceInterval:1e3/60,errorColor:"#f44336",backgroundColor:"#ffffff",accentColor:"#333333",dynamicResolution:{intervalMs:500,increment:.5,maxScale:1.5,minScale:1,dtMax:1.5,dtMin:1.1}};var dist$1={},__assign=commonjsGlobal&&commonjsGlobal.__assign||function(){return __assign=Object.assign||function(ne){for(var oe,ce=1,ue=arguments.length;ce0?1:-1}),shim$4}var sign$1=isImplemented$6()?Math.sign:requireShim$4(),sign=sign$1,abs=Math.abs,floor$1=Math.floor,toInteger$1=function(ne){return isNaN(ne)?0:(ne=Number(ne),ne===0||!isFinite(ne)?ne:sign(ne)*floor$1(abs(ne)))},toInteger=toInteger$1,max$3=Math.max,toPosInteger=function(ne){return max$3(0,toInteger(ne))},validCallable=function(ne){if(typeof ne!="function")throw new TypeError(ne+" is not a function");return ne},isValue$4=isValue$6,validValue=function(ne){if(!isValue$4(ne))throw new TypeError("Cannot use null or undefined");return ne},custom={exports:{}},isImplemented$5=function(){var ne=Object.assign,oe;return typeof ne!="function"?!1:(oe={foo:"raz"},ne(oe,{bar:"dwa"},{trzy:"trzy"}),oe.foo+oe.bar+oe.trzy==="razdwatrzy")},isImplemented$4,hasRequiredIsImplemented$3;function requireIsImplemented$3(){return hasRequiredIsImplemented$3||(hasRequiredIsImplemented$3=1,isImplemented$4=function(){try{return Object.keys("primitive"),!0}catch{return!1}}),isImplemented$4}var shim$3,hasRequiredShim$3;function requireShim$3(){if(hasRequiredShim$3)return shim$3;hasRequiredShim$3=1;var ne=isValue$6,oe=Object.keys;return shim$3=function(ce){return oe(ne(ce)?Object(ce):ce)},shim$3}var keys,hasRequiredKeys;function requireKeys(){return hasRequiredKeys||(hasRequiredKeys=1,keys=requireIsImplemented$3()()?Object.keys:requireShim$3()),keys}var shim$2,hasRequiredShim$2;function requireShim$2(){if(hasRequiredShim$2)return shim$2;hasRequiredShim$2=1;var ne=requireKeys(),oe=validValue,ce=Math.max;return shim$2=function(ue,pe){var me,ge,ye=ce(arguments.length,2),ve;for(ue=Object(oe(ue)),ve=function(xe){try{ue[xe]=pe[xe]}catch(_e){me||(me=_e)}},ge=1;ge-1},shim$1}var contains$1=isImplemented$3()?String.prototype.contains:requireShim$1(),isValue$1=is$5,isPlainFunction=is$1,assign$1=assign$2,normalizeOpts=normalizeOptions,contains=contains$1,d$1=d$2.exports=function(ne,oe){var ce,ue,pe,me,ge;return arguments.length<2||typeof ne!="string"?(me=oe,oe=ne,ne=null):me=arguments[2],isValue$1(ne)?(ce=contains.call(ne,"c"),ue=contains.call(ne,"e"),pe=contains.call(ne,"w")):(ce=pe=!0,ue=!1),ge={value:oe,configurable:ce,enumerable:ue,writable:pe},me?assign$1(normalizeOpts(me),ge):ge};d$1.gs=function(ne,oe,ce){var ue,pe,me,ge;return typeof ne!="string"?(me=ce,ce=oe,oe=ne,ne=null):me=arguments[3],isValue$1(oe)?isPlainFunction(oe)?isValue$1(ce)?isPlainFunction(ce)||(me=ce,ce=void 0):ce=void 0:(me=oe,oe=ce=void 0):oe=void 0,isValue$1(ne)?(ue=contains.call(ne,"c"),pe=contains.call(ne,"e")):(ue=!0,pe=!1),ge={get:oe,set:ce,configurable:ue,enumerable:pe},me?assign$1(normalizeOpts(me),ge):ge};var dExports=d$2.exports,eventEmitter={exports:{}};(function(ne,oe){var ce=dExports,ue=validCallable,pe=Function.prototype.apply,me=Function.prototype.call,ge=Object.create,ye=Object.defineProperty,ve=Object.defineProperties,xe=Object.prototype.hasOwnProperty,_e={configurable:!0,enumerable:!1,writable:!0},Se,$e,Re,Ae,Ie,ke,Be;Se=function(Ne,Fe){var Ue;return ue(Fe),xe.call(this,"__ee__")?Ue=this.__ee__:(Ue=_e.value=ge(null),ye(this,"__ee__",_e),_e.value=null),Ue[Ne]?typeof Ue[Ne]=="object"?Ue[Ne].push(Fe):Ue[Ne]=[Ue[Ne],Fe]:Ue[Ne]=Fe,this},$e=function(Ne,Fe){var Ue,We;return ue(Fe),We=this,Se.call(this,Ne,Ue=function(){Re.call(We,Ne,Ue),pe.call(Fe,this,arguments)}),Ue.__eeOnceListener__=Fe,this},Re=function(Ne,Fe){var Ue,We,qe,ze;if(ue(Fe),!xe.call(this,"__ee__"))return this;if(Ue=this.__ee__,!Ue[Ne])return this;if(We=Ue[Ne],typeof We=="object")for(ze=0;qe=We[ze];++ze)(qe===Fe||qe.__eeOnceListener__===Fe)&&(We.length===2?Ue[Ne]=We[ze?0:1]:We.splice(ze,1));else(We===Fe||We.__eeOnceListener__===Fe)&&delete Ue[Ne];return this},Ae=function(Ne){var Fe,Ue,We,qe,ze;if(xe.call(this,"__ee__")&&(qe=this.__ee__[Ne],!!qe))if(typeof qe=="object"){for(Ue=arguments.length,ze=new Array(Ue-1),Fe=1;Fe=55296&&Ue<=56319&&(Ge+=$e[++ke])),Ge=Re?xe.call(Re,Ae,Ge,Be):Ge,Ie?(_e.value=Ge,Se(Ne,Be,_e)):Ne[Be]=Ge,++Be;Fe=Be}}if(Fe===void 0)for(Fe=ue($e.length),Ie&&(Ne=new Ie(Fe)),ke=0;ke=6&&(ce-=6),G(ce<1?255*((oe-ne)*ce+ne):ce<3?255*oe:ce<4?255*((oe-ne)*(4-ce)+ne):255*ne)},X=function(ne,oe,ce){oe/=100;var ue=(ce/=100)<=.5?ce*(oe+1):ce+oe-ce*oe,pe=2*ce-ue;return{r:O(pe,ue,(ne/=60)+2),g:O(pe,ue,ne),b:O(pe,ue,ne-2)}},Y=function(ne,oe,ce,ue){return{r:G(255*(1-ne)*(ue=1-ue)),g:G(255*(1-oe)*ue),b:G(255*(1-ce)*ue)}},j=function(ne,oe,ce){ne/=255,oe/=255,ce/=255;var ue=1-Math.max(ne,oe,ce),pe=1-ue,me=pe&&(pe-oe)/pe,ge=pe&&(pe-ce)/pe;return{c:G(100*(pe&&(pe-ne)/pe)),m:G(100*me),y:G(100*ge),k:G(100*ue)}},K=function(ne,oe,ce,ue){ue===void 0&&(ue=1),ne/=255,oe/=255,ce/=255,ue=Math.min(ue,1);var pe=Math.max(ne,oe,ce),me=Math.min(ne,oe,ce),ge=pe-me,ye=0,ve=0,xe=(pe+me)/2;if(ge!==0){switch(pe){case ne:ye=(oe-ce)/ge%6;break;case oe:ye=(ce-ne)/ge+2;break;case ce:ye=(ne-oe)/ge+4}(ye=G(60*ye))<0&&(ye+=360),ve=ge/(1-Math.abs(2*xe-1))}return{h:ye,s:G(100*ve),l:G(100*xe),a:ue}},I=function(ne,oe){if(ne<0&&(ne+=360),ne>360&&(ne-=360),ne===360||ne===0)return ne;var ce=[[0,120],[120,180],[180,240],[240,360]],ue=[[0,60],[60,120],[120,240],[240,360]],pe=oe?ue:ce,me=0,ge=0,ye=0,ve=0;return(oe?ce:ue).find(function(xe,_e){return ne>=xe[0]&&ne360||ne<0)&&(ne-=360*Math.floor(ne/360)),ne},N=function(ne){return typeof ne=="string"&&(ne=m.test(ne)?B(ne)/100:+ne),isNaN(+ne)||ne>1?1:G(ne)},V=function(ne,oe,ce){return oe.reduce(function(ue,pe){return e(e([],ue,!0),[t(t({},ne),{h:ce===i.ADDITIVE?x(ne.h+pe):x(I(I(ne.h,!1)+pe,!0))})],!1)},[t({},ne)])},U=function(ne,oe){return V(ne,[30,-30],oe)},q=function(ne,oe){return V(ne,[180],oe)},$=function(ne,oe){return V(ne,[150,-150],oe)},_=function(ne,oe){return V(ne,[120,-120],oe)},Q=function(ne,oe){return V(ne,[60,-120,180],oe)},z$1=function(ne,oe){return V(ne,[90,-90,180],oe)},J=function(ne){return typeof ne=="string"?function(oe){var ce;if(Object.keys(r).some(function(ue){if(b[ue].test(oe))return ce=ue,!0}),!ce&&~f.indexOf(oe)&&(ce=r.HEX),!ce)throw new Error(E);return ce}(ne):function(oe){var ce,ue=!1,pe=L(Object.keys(oe));if(p[pe]&&(ce=p[pe]),ce&&ce===r.RGB){var me=Object.entries(oe).some(function(ye){return!y.test("".concat(ye[1]))}),ge=Object.entries(oe).some(function(ye){return!(m.test("".concat(ye[1]))||!y.test("".concat(ye[1]))&&!isNaN(+ye[1])&&+ye[1]<=255)});me&&ge&&(ue=!0),me||(ce=r.HEX)}if(!ce||ue)throw new Error(v);return ce}(ne)},W=((c={})[r.HEX]=function(ne){var oe=(~f.indexOf(ne)?o[ne]:ne).match(b.HEX),ce={r:M(oe[1]||oe[5]),g:M(oe[2]||oe[6]),b:M(oe[3]||oe[7])},ue=oe[4]||oe[8];return ue!==void 0&&(ce.a=M(ue)/255),ce},c[r.RGB]=function(ne){var oe=ne.match(b.RGB),ce=D(oe[1]||oe[5]),ue=D(oe[2]||oe[6]),pe=D(oe[3]||oe[7]),me=oe[4]||oe[8],ge={r:Math.min(ce,255),g:Math.min(ue,255),b:Math.min(pe,255)};return me!==void 0&&(ge.a=N(me)),ge},c[r.HSL]=function(ne){var oe=ne.match(b.HSL),ce=x(oe[1]||oe[5]),ue=C(oe[2]||oe[6]),pe=C(oe[3]||oe[7]),me=oe[4]||oe[8],ge=X(ce,ue,pe);return me!==void 0&&(ge.a=N(me)),ge},c[r.CMYK]=function(ne){var oe=ne.match(b.CMYK),ce=S(oe[1]||oe[6]),ue=S(oe[2]||oe[7]),pe=S(oe[3]||oe[8]),me=S(oe[4]||oe[9]),ge=oe[5]||oe[10],ye=Y(ce,ue,pe,me);return ge!==void 0&&(ye.a=N(ge)),ye},c),Z=((s={})[r.HEX]=function(ne){var oe={r:D("".concat(ne.r)),g:D("".concat(ne.g)),b:D("".concat(ne.b))};return H(ne,"a")&&(oe.a=Math.min(D("".concat(ne.a),!0),1)),oe},s[r.RGB]=function(ne){return this.HEX(ne)},s[r.HSL]=function(ne){var oe=C("".concat(ne.s)),ce=C("".concat(ne.l)),ue=X(x(ne.h),oe,ce);return H(ne,"a")&&(ue.a=N(ne.a)),ue},s[r.CMYK]=function(ne){var oe=S("".concat(ne.c)),ce=S("".concat(ne.m)),ue=S("".concat(ne.y)),pe=S("".concat(ne.k)),me=Y(oe,ce,ue,pe);return H(ne,"a")&&(me.a=N(ne.a)),me},s),tt=function(ne,oe){return oe===void 0&&(oe=J(ne)),typeof ne=="string"?W[oe](ne):Z[oe](ne)},et=((d={})[r.HEX]=function(ne){return{r:R(ne.r),g:R(ne.g),b:R(ne.b)}},d.HEXA=function(ne){var oe=et.HEX(ne);return oe.a=H(ne,"a")?R(255*ne.a):"0xFF",oe},d[r.RGB]=function(ne,oe){return H(ne,"a")&&delete ne.a,ot(ne,oe)},d.RGBA=function(ne,oe){return ne.a=H(ne,"a")?G(ne.a):1,ot(ne,oe)},d[r.HSL]=function(ne,oe){var ce=K(ne.r,ne.g,ne.b);return delete ce.a,at(ce,oe)},d.HSLA=function(ne,oe){var ce=et.HSL(ne,oe);return ce.a=H(ne,"a")?G(ne.a,oe):1,ce},d[r.CMYK]=function(ne,oe){return ut(j(ne.r,ne.g,ne.b),oe)},d.CMYKA=function(ne,oe){var ce=et.CMYK(ne,oe);return ce.a=H(ne,"a")?G(ne.a,oe):1,ce},d),rt=function(ne,oe,ce,ue){var pe=J(ne),me=typeof ne=="string",ge=tt(ne,pe),ye=typeof ne=="string"&&H(ge,"a")||typeof ne!="string"&&H(ne,"a"),ve=K(ge.r,ge.g,ge.b,ge.a);ye||delete ve.a;var xe=ce?ve.l/(oe+1):(100-ve.l)/(oe+1),_e=Array(oe).fill(null).map(function(Se,$e){return t(t({},ve),{l:ve.l+xe*($e+1)*(1-2*+ce)})});switch(pe){case r.HEX:default:return _e.map(function(Se){var $e=X(Se.h,Se.s,Se.l);return ye&&($e.a=Se.a),me?ye?w.HEX(ot(t(t({},$e),{a:G(255*$e.a)}),ue)):w.HEX(ot($e,ue)):ye?et.HEXA($e):et.HEX($e)});case r.RGB:return _e.map(function(Se){var $e=X(Se.h,Se.s,Se.l);return ye&&($e.a=Se.a),me?w.RGB(ot($e,ue)):ye?et.RGBA($e,ue):et.RGB($e,ue)});case r.HSL:return _e.map(function(Se){return me?w.HSL(at(Se,ue)):ye?et.HSLA(t(t({},X(Se.h,Se.s,Se.l)),{a:Se.a}),ue):et.HSL(X(Se.h,Se.s,Se.l),ue)})}},nt=((h={buildHarmony:function(ne,oe,ce,ue){var pe=J(ne),me=tt(ne,pe),ge=K(me.r,me.g,me.b,me.a),ye=typeof ne=="string"&&H(me,"a")||typeof ne!="string"&&H(ne,"a"),ve=typeof ne=="string";switch(pe){case r.HEX:default:return ye?this.HEXA(at(ge,0),oe,ce,ve):this.HEX(at(ge,0),oe,ce,ve);case r.HSL:return ye?this.HSLA(ge,oe,ce,ve,ue):this.HSL(ge,oe,ce,ve,ue);case r.RGB:return ye?this.RGBA(ge,oe,ce,ve,ue):this.RGB(ge,oe,ce,ve,ue)}}})[r.HEX]=function(ne,oe,ce,ue){return oe(ne,ce).map(function(pe){return ue?w.HEX(X(pe.h,pe.s,pe.l)):et.HEX(X(pe.h,pe.s,pe.l))})},h.HEXA=function(ne,oe,ce,ue){return oe(ne,ce).map(function(pe){return ue?w.HEX(t(t({},X(pe.h,pe.s,pe.l)),{a:255*N(pe.a)})):et.HEXA(t(t({},X(pe.h,pe.s,pe.l)),{a:N(pe.a)}))})},h[r.RGB]=function(ne,oe,ce,ue,pe){return oe(ne,ce).map(function(me){return ue?w.RGB(ot(X(me.h,me.s,me.l),pe)):et.RGB(X(me.h,me.s,me.l),pe)})},h.RGBA=function(ne,oe,ce,ue,pe){return oe(ne,ce).map(function(me){return ue?w.RGB(ot(t(t({},X(me.h,me.s,me.l)),{a:N(me.a)}),pe)):et.RGBA(t(t({},X(me.h,me.s,me.l)),{a:N(me.a)}),pe)})},h[r.HSL]=function(ne,oe,ce,ue,pe){return oe(ne,ce).map(function(me){return ue?w.HSL(at({h:me.h,s:me.s,l:me.l},pe)):et.HSL(X(me.h,me.s,me.l),pe)})},h.HSLA=function(ne,oe,ce,ue,pe){return oe(ne,ce).map(function(me){return ue?w.HSL(at(t(t({},me),{a:N(me.a)}),pe)):et.HSLA(t(t({},X(me.h,me.s,me.l)),{a:N(me.a)}),pe)})},h),it=((l={mix:function(ne,oe){var ce,ue,pe,me,ge,ye,ve,xe,_e,Se,$e,Re,Ae,Ie,ke,Be=ne.map(function(We){var qe=J(We);return tt(We,qe)}),Ne=oe===i.SUBTRACTIVE?Be.map(function(We){var qe,ze,Ge,Ze,Dt,Je,Ut,jt,Ke,an,Zt,en,Kt,Wt,un=(qe=We.r,ze=We.g,Ge=We.b,Ze=Math.min(qe,ze,Ge),Dt=Math.min(255-qe,255-ze,255-Ge),Je=qe-Ze,Ut=ze-Ze,jt=Ge-Ze,Ke=Math.min(Je,Ut),an=Je-Ke,Zt=(Ut+Ke)/2,en=(jt+Ut-Ke)/2,Kt=Math.max(an,Zt,en)/Math.max(Je,Ut,jt),Wt=isNaN(Kt)||Kt===1/0||Kt<=0?1:Kt,{r:an/Wt+Dt,y:Zt/Wt+Dt,b:en/Wt+Dt});return H(We,"a")&&(un.a=We.a),un}):null;function Fe(We){var qe=oe===i.ADDITIVE?{r:0,g:0,b:0,a:0}:{r:0,y:0,b:0,a:0};return We.reduce(function(ze,Ge){var Ze=H(Ge,"a")?Ge.a:1,Dt={r:Math.min(ze.r+Ge.r*Ze,255),b:Math.min(ze.b+Ge.b*Ze,255),a:1-(1-Ze)*(1-ze.a)},Je="g"in ze?ze.g:ze.y,Ut="g"in Ge?Ge.g:Ge.y;return t(t({},Dt),oe===i.ADDITIVE?{g:Math.min(Je+Ut*Ze,255)}:{y:Math.min(Je+Ut*Ze,255)})},qe)}if(oe===i.ADDITIVE)ce=Fe(Be);else{var Ue=Fe(Ne);ue=Ue.r,pe=Ue.y,me=Ue.b,ge=Math.min(ue,pe,me),ye=Math.min(255-ue,255-pe,255-me),ve=ue-ge,xe=pe-ge,_e=me-ge,Se=Math.min(xe,_e),$e=ve+xe-Se,Re=xe+Se,Ae=2*(_e-Se),Ie=Math.max($e,Re,Ae)/Math.max(ve,xe,_e),ke=isNaN(Ie)||Ie===1/0||Ie<=0?1:Ie,(ce={r:$e/ke+ye,g:Re/ke+ye,b:Ae/ke+ye}).a=Ue.a}return{r:G(ce.r),g:G(ce.g),b:G(ce.b),a:k(ce.a,0,1)}}})[r.HEX]=function(ne,oe,ce){var ue=this.mix(ne,oe);return delete ue.a,ce?w.HEX(ue):et.HEX(ue)},l.HEXA=function(ne,oe,ce){var ue=this.mix(ne,oe);return ue.a=ce?255*N(ue.a):N(ue.a),ce?w.HEX(ue):et.HEXA(ue)},l[r.RGB]=function(ne,oe,ce,ue){var pe=this.mix(ne,oe);return delete pe.a,ce?w.RGB(pe):et.RGB(pe,ue)},l.RGBA=function(ne,oe,ce,ue){var pe=this.mix(ne,oe);return ce?w.RGB(pe):et.RGBA(pe,ue)},l[r.HSL]=function(ne,oe,ce,ue){var pe=this.mix(ne,oe),me=K(pe.r,pe.g,pe.b);return delete pe.a,delete me.a,ce?w.HSL(me):et.HSL(pe,ue)},l.HSLA=function(ne,oe,ce,ue){var pe=this.mix(ne,oe),me=K(pe.r,pe.g,pe.b,pe.a);return ce?w.HSL(me):et.HSLA(pe,ue)},l),ot=function(ne,oe){return t({r:G(ne.r,oe),g:G(ne.g,oe),b:G(ne.b,oe)},H(ne,"a")?{a:G(ne.a,oe)}:{})},at=function(ne,oe){return t({h:G(ne.h,oe),s:G(ne.s,oe),l:G(ne.l,oe)},H(ne,"a")?{a:G(ne.a,oe)}:{})},ut=function(ne,oe){return{c:G(ne.c,oe),m:G(ne.m,oe),y:G(ne.y,oe),k:G(ne.k,oe)}},ct=function(ne,oe,ce,ue,pe,me){var ge=pe(tt(ne,oe),ue);return ce?me(ge):ge},st=function(ne,oe,ce,ue,pe,me,ge){ce<1&&(ce=5);var ye=function(ve,xe,_e){var Se=_e-1,$e=(xe.r-ve.r)/Se,Re=(xe.g-ve.g)/Se,Ae=(xe.b-ve.b)/Se,Ie=N(ve.a),ke=(N(xe.a)-Ie)/Se;return Array(_e).fill(null).map(function(Be,Ne){return Ne===0?ve:Ne===Se?xe:{r:G(ve.r+$e*Ne),g:G(ve.g+Re*Ne),b:G(ve.b+Ae*Ne),a:G(Ie+ke*Ne)}})}(tt(ne),tt(oe),ce);return ye.map(function(ve){var xe=me(ve,pe);return ue?ge(xe):xe})},dt=function(){function ne(oe,ce){ce===void 0&&(ce=6),this.rgb=tt(oe),this._decimals=ce,this.updateHSL(),this.updateCMYK()}return ne.prototype.updateRGB=function(){this.rgb=t(t({},X(this.hsl.h,this.hsl.s,this.hsl.l)),{a:this.hsl.a})},ne.prototype.updateRGBFromCMYK=function(){this.rgb=t(t({},Y(this.cmyk.c,this.cmyk.m,this.cmyk.y,this.cmyk.k)),{a:this.rgb.a})},ne.prototype.updateHSL=function(){this.hsl=K(this.rgb.r,this.rgb.g,this.rgb.b,this.rgb.a)},ne.prototype.updateCMYK=function(){this.cmyk=j(this.rgb.r,this.rgb.g,this.rgb.b)},ne.prototype.updateRGBAndCMYK=function(){return this.updateRGB(),this.updateCMYK(),this},ne.prototype.updateHSLAndCMYK=function(){return this.updateHSL(),this.updateCMYK(),this},ne.prototype.updateRGBAndHSL=function(){return this.updateRGBFromCMYK(),this.updateHSL(),this},ne.prototype.setDecimals=function(oe){return this._decimals=oe,this},ne.prototype.setH=function(oe){return this.hsl.h=x(oe),this.updateRGBAndCMYK()},ne.prototype.setS=function(oe){return this.hsl.s=k(oe,0,100),this.updateRGBAndCMYK()},ne.prototype.setL=function(oe){return this.hsl.l=k(oe,0,100),this.updateRGBAndCMYK()},ne.prototype.setR=function(oe){return this.rgb.r=k(oe,0,255),this.updateHSLAndCMYK()},ne.prototype.setG=function(oe){return this.rgb.g=k(oe,0,255),this.updateHSLAndCMYK()},ne.prototype.setB=function(oe){return this.rgb.b=k(oe,0,255),this.updateHSLAndCMYK()},ne.prototype.setA=function(oe){return this.hsl.a=this.rgb.a=k(oe,0,1),this},ne.prototype.setC=function(oe){return this.cmyk.c=k(oe,0,100),this.updateRGBAndHSL()},ne.prototype.setM=function(oe){return this.cmyk.m=k(oe,0,100),this.updateRGBAndHSL()},ne.prototype.setY=function(oe){return this.cmyk.y=k(oe,0,100),this.updateRGBAndHSL()},ne.prototype.setK=function(oe){return this.cmyk.k=k(oe,0,100),this.updateRGBAndHSL()},Object.defineProperty(ne.prototype,"decimals",{get:function(){return this._decimals},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"H",{get:function(){return G(this.hsl.h,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"S",{get:function(){return G(this.hsl.s,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"L",{get:function(){return G(this.hsl.l,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"R",{get:function(){return G(this.rgb.r,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"G",{get:function(){return G(this.rgb.g,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"B",{get:function(){return G(this.rgb.b,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"A",{get:function(){return G(this.hsl.a,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"C",{get:function(){return G(this.cmyk.c,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"M",{get:function(){return G(this.cmyk.m,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"Y",{get:function(){return G(this.cmyk.y,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"K",{get:function(){return G(this.cmyk.k,this.decimals)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HEXObject",{get:function(){return et.HEX(this.rgb)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HEXAObject",{get:function(){return et.HEXA(this.rgb)},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"RGBObject",{get:function(){return{r:this.R,g:this.G,b:this.B}},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"RGBAObject",{get:function(){return t(t({},this.RGBObject),{a:this.A})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HSLObject",{get:function(){return{h:this.H,s:this.S,l:this.L}},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HSLAObject",{get:function(){return t(t({},this.HSLObject),{a:this.A})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"CMYKObject",{get:function(){return{c:this.C,m:this.M,y:this.Y,k:this.K}},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"CMYKAObject",{get:function(){return t(t({},this.CMYKObject),{a:this.A})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HEX",{get:function(){return w.HEX({r:this.R,g:this.G,b:this.B})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HEXA",{get:function(){return w.HEX({r:this.R,g:this.G,b:this.B,a:255*this.A})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"RGB",{get:function(){return w.RGB({r:this.R,g:this.G,b:this.B})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"RGBA",{get:function(){return w.RGB({r:this.R,g:this.G,b:this.B,a:this.A})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HSL",{get:function(){return w.HSL({h:this.H,s:this.S,l:this.L})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"HSLA",{get:function(){return w.HSL({h:this.H,s:this.S,l:this.L,a:this.A})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"CMYK",{get:function(){return w.CMYK({c:this.C,m:this.M,y:this.Y,k:this.K})},enumerable:!1,configurable:!0}),Object.defineProperty(ne.prototype,"CMYKA",{get:function(){return w.CMYK({c:this.C,m:this.M,y:this.Y,k:this.K,a:this.A})},enumerable:!1,configurable:!0}),ne.toHEX=function(oe,ce){ce===void 0&&(ce=!0);var ue=J(oe);return ct(oe,ue,ce,0,et.HEX,w.HEX)},ne.toHEXA=function(oe,ce){ce===void 0&&(ce=!0);var ue=J(oe);return ct(oe,ue,ce,0,et.HEXA,w.HEX)},ne.toRGB=function(oe,ce,ue){ce===void 0&&(ce=!0),ue===void 0&&(ue=6);var pe=J(oe);return ct(oe,pe,ce,ue,et.RGB,w.RGB)},ne.toRGBA=function(oe,ce,ue){ce===void 0&&(ce=!0),ue===void 0&&(ue=6);var pe=J(oe);return ct(oe,pe,ce,ue,et.RGBA,w.RGB)},ne.toHSL=function(oe,ce,ue){ce===void 0&&(ce=!0),ue===void 0&&(ue=6);var pe=J(oe);return ct(oe,pe,ce,ue,et.HSL,w.HSL)},ne.toHSLA=function(oe,ce,ue){ce===void 0&&(ce=!0),ue===void 0&&(ue=6);var pe=J(oe);return ct(oe,pe,ce,ue,et.HSLA,w.HSL)},ne.toCMYK=function(oe,ce,ue){ce===void 0&&(ce=!0),ue===void 0&&(ue=6);var pe=J(oe);return ct(oe,pe,ce,ue,et.CMYK,w.CMYK)},ne.toCMYKA=function(oe,ce,ue){ce===void 0&&(ce=!0),ue===void 0&&(ue=6);var pe=J(oe);return ct(oe,pe,ce,ue,et.CMYKA,w.CMYK)},ne.getBlendHEX=function(oe,ce,ue,pe,me){return ue===void 0&&(ue=5),pe===void 0&&(pe=!0),me===void 0&&(me=6),st(oe,ce,ue,pe,me,et.HEX,w.HEX)},ne.getBlendHEXA=function(oe,ce,ue,pe,me){return ue===void 0&&(ue=5),pe===void 0&&(pe=!0),me===void 0&&(me=6),st(oe,ce,ue,pe,me,et.HEXA,w.HEX)},ne.getBlendRGB=function(oe,ce,ue,pe,me){return ue===void 0&&(ue=5),pe===void 0&&(pe=!0),me===void 0&&(me=6),st(oe,ce,ue,pe,me,et.RGB,w.RGB)},ne.getBlendRGBA=function(oe,ce,ue,pe,me){return ue===void 0&&(ue=5),pe===void 0&&(pe=!0),me===void 0&&(me=6),st(oe,ce,ue,pe,me,et.RGBA,w.RGB)},ne.getBlendHSL=function(oe,ce,ue,pe,me){return ue===void 0&&(ue=5),pe===void 0&&(pe=!0),me===void 0&&(me=6),st(oe,ce,ue,pe,me,et.HSL,w.HSL)},ne.getBlendHSLA=function(oe,ce,ue,pe,me){return ue===void 0&&(ue=5),pe===void 0&&(pe=!0),me===void 0&&(me=6),st(oe,ce,ue,pe,me,et.HSLA,w.HSL)},ne.getMixHEX=function(oe,ce,ue){return ce===void 0&&(ce=i.ADDITIVE),ue===void 0&&(ue=!0),it.HEX(oe,ce,ue)},ne.getMixHEXA=function(oe,ce,ue){return ce===void 0&&(ce=i.ADDITIVE),ue===void 0&&(ue=!0),it.HEXA(oe,ce,ue)},ne.getMixRGB=function(oe,ce,ue,pe){return ce===void 0&&(ce=i.ADDITIVE),ue===void 0&&(ue=!0),pe===void 0&&(pe=6),it.RGB(oe,ce,ue,pe)},ne.getMixRGBA=function(oe,ce,ue,pe){return ce===void 0&&(ce=i.ADDITIVE),ue===void 0&&(ue=!0),pe===void 0&&(pe=6),it.RGBA(oe,ce,ue,pe)},ne.getMixHSL=function(oe,ce,ue,pe){return ce===void 0&&(ce=i.ADDITIVE),ue===void 0&&(ue=!0),pe===void 0&&(pe=6),it.HSL(oe,ce,ue,pe)},ne.getMixHSLA=function(oe,ce,ue,pe){return ce===void 0&&(ce=i.ADDITIVE),ue===void 0&&(ue=!0),pe===void 0&&(pe=6),it.HSLA(oe,ce,ue,pe)},ne.getShades=function(oe,ce,ue){return ue===void 0&&(ue=6),rt(oe,ce,!0,ue)},ne.getTints=function(oe,ce,ue){return ue===void 0&&(ue=6),rt(oe,ce,!1,ue)},ne.getHarmony=function(oe,ce,ue,pe){return ce===void 0&&(ce=n.COMPLEMENTARY),ue===void 0&&(ue=i.ADDITIVE),pe===void 0&&(pe=6),function(me,ge,ye,ve){var xe;return(xe={},xe[n.ANALOGOUS]=nt.buildHarmony(ge,U,ve,ye),xe[n.COMPLEMENTARY]=nt.buildHarmony(ge,q,ve,ye),xe[n.SPLIT_COMPLEMENTARY]=nt.buildHarmony(ge,$,ve,ye),xe[n.TRIADIC]=nt.buildHarmony(ge,_,ve,ye),xe[n.TETRADIC]=nt.buildHarmony(ge,Q,ve,ye),xe[n.SQUARE]=nt.buildHarmony(ge,z$1,ve,ye),xe)[me]}(ce,oe,pe,ue)},ne}();const defaultContext={current:void 0,parent:void 0,events:void 0,color:{source:2533018,destination:15753874,expanding:16733986,updating:16733986,generating:16771899,closing:11583173,end:15483002},scale:10,fill:"#000000",alpha:1};var earthRadius=63710088e-1,factors={centimeters:earthRadius*100,centimetres:earthRadius*100,degrees:earthRadius/111325,feet:earthRadius*3.28084,inches:earthRadius*39.37,kilometers:earthRadius/1e3,kilometres:earthRadius/1e3,meters:earthRadius,metres:earthRadius,miles:earthRadius/1609.344,millimeters:earthRadius*1e3,millimetres:earthRadius*1e3,nauticalmiles:earthRadius/1852,radians:1,yards:earthRadius*1.0936};function feature(ne,oe,ce){ce===void 0&&(ce={});var ue={type:"Feature"};return(ce.id===0||ce.id)&&(ue.id=ce.id),ce.bbox&&(ue.bbox=ce.bbox),ue.properties=oe||{},ue.geometry=ne,ue}function point(ne,oe,ce){if(ce===void 0&&(ce={}),!ne)throw new Error("coordinates is required");if(!Array.isArray(ne))throw new Error("coordinates must be an Array");if(ne.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!isNumber(ne[0])||!isNumber(ne[1]))throw new Error("coordinates must contain numbers");var ue={type:"Point",coordinates:ne};return feature(ue,oe,ce)}function lineString(ne,oe,ce){if(ce===void 0&&(ce={}),ne.length<2)throw new Error("coordinates must be an array of two or more positions");var ue={type:"LineString",coordinates:ne};return feature(ue,oe,ce)}function radiansToLength(ne,oe){oe===void 0&&(oe="kilometers");var ce=factors[oe];if(!ce)throw new Error(oe+" units is invalid");return ne*ce}function lengthToRadians(ne,oe){oe===void 0&&(oe="kilometers");var ce=factors[oe];if(!ce)throw new Error(oe+" units is invalid");return ne/ce}function degreesToRadians(ne){var oe=ne%360;return oe*Math.PI/180}function convertLength(ne,oe,ce){if(oe===void 0&&(oe="kilometers"),ce===void 0&&(ce="kilometers"),!(ne>=0))throw new Error("length must be a positive number");return radiansToLength(lengthToRadians(ne,oe),ce)}function isNumber(ne){return!isNaN(ne)&&ne!==null&&!Array.isArray(ne)}function getCoord(ne){if(!ne)throw new Error("coord is required");if(!Array.isArray(ne)){if(ne.type==="Feature"&&ne.geometry!==null&&ne.geometry.type==="Point")return ne.geometry.coordinates;if(ne.type==="Point")return ne.coordinates}if(Array.isArray(ne)&&ne.length>=2&&!Array.isArray(ne[0])&&!Array.isArray(ne[1]))return ne;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function featureOf(ne,oe,ce){if(!ne)throw new Error("No feature passed");if(!ce)throw new Error(".featureOf() requires a name");if(!ne||ne.type!=="Feature"||!ne.geometry)throw new Error("Invalid input to "+ce+", Feature with geometry required");if(!ne.geometry||ne.geometry.type!==oe)throw new Error("Invalid input to "+ce+": must be a "+oe+", given "+ne.geometry.type)}function distance(ne,oe,ce){ce===void 0&&(ce={});var ue=getCoord(ne),pe=getCoord(oe),me=degreesToRadians(pe[1]-ue[1]),ge=degreesToRadians(pe[0]-ue[0]),ye=degreesToRadians(ue[1]),ve=degreesToRadians(pe[1]),xe=Math.pow(Math.sin(me/2),2)+Math.pow(Math.sin(ge/2),2)*Math.cos(ye)*Math.cos(ve);return radiansToLength(2*Math.atan2(Math.sqrt(xe),Math.sqrt(1-xe)),ce.units)}function coordEach(ne,oe,ce){if(ne!==null)for(var ue,pe,me,ge,ye,ve,xe,_e=0,Se=0,$e,Re=ne.type,Ae=Re==="FeatureCollection",Ie=Re==="Feature",ke=Ae?ne.features.length:1,Be=0;Beve||Ae>xe||Ie>_e){ye=Se,ve=ue,xe=Ae,_e=Ie,me=0;return}var ke=lineString([ye,Se],ce.properties);if(oe(ke,ue,pe,Ie,me)===!1)return!1;me++,ye=Se})===!1)return!1}}})}function rhumbDistance(ne,oe,ce){ce===void 0&&(ce={});var ue=getCoord(ne),pe=getCoord(oe);pe[0]+=pe[0]-ue[0]>180?-360:ue[0]-pe[0]>180?360:0;var me=calculateRhumbDistance(ue,pe),ge=convertLength(me,"meters",ce.units);return ge}function calculateRhumbDistance(ne,oe,ce){ce=ce===void 0?earthRadius:Number(ce);var ue=ce,pe=ne[1]*Math.PI/180,me=oe[1]*Math.PI/180,ge=me-pe,ye=Math.abs(oe[0]-ne[0])*Math.PI/180;ye>Math.PI&&(ye-=2*Math.PI);var ve=Math.log(Math.tan(me/2+Math.PI/4)/Math.tan(pe/2+Math.PI/4)),xe=Math.abs(ve)>1e-11?ge/ve:Math.cos(pe),_e=Math.sqrt(ge*ge+xe*xe*ye*ye),Se=_e*ue;return Se}function pointToLineDistance(ne,oe,ce){if(ce===void 0&&(ce={}),ce.method||(ce.method="geodesic"),ce.units||(ce.units="kilometers"),!ne)throw new Error("pt is required");if(Array.isArray(ne)?ne=point(ne):ne.type==="Point"?ne=feature(ne):featureOf(ne,"Point","point"),!oe)throw new Error("line is required");Array.isArray(oe)?oe=lineString(oe):oe.type==="LineString"?oe=feature(oe):featureOf(oe,"LineString","line");var ue=1/0,pe=ne.geometry.coordinates;return segmentEach(oe,function(me){var ge=me.geometry.coordinates[0],ye=me.geometry.coordinates[1],ve=distanceToSegment(pe,ge,ye,ce);venew dt(ne).setA(oe??defaultContext.alpha).RGBA,getStrokeStyle=(ne,oe)=>getFillStyle(ne,oe);function transform(ne,oe){return{width:ne.width*oe.scale.x,height:ne.height*oe.scale.y,x:ne.x*oe.scale.x+oe.x,y:ne.y*oe.scale.y+oe.y}}const text={draw(ne,oe,ce){const ue=ne.label??ne.text;if(ue){const pe=transform(ne,{x:ne["label-x"]??ne.textX??0,y:ne["label-y"]??ne.textY??0,scale:{x:1,y:1}}),me=transform(pe,ce);oe.font=`${(ne["label-size"]??ne.fontSize??4)*ce.scale.x}px Inter`,oe.fillStyle=getFillStyle(ne["label-color"]??ne.fontColor??"grey",1),oe.fillText(ue,me.x,me.y)}},test(ne){return{left:-1/0,right:1/0,top:-1/0,bottom:1/0}},narrow(){return!0}},rect={draw(ne,oe,ce){const{x:ue,y:pe,width:me,height:ge}=transform(ne,ce);oe.fillStyle=getFillStyle(ne.fill,ne.alpha),oe.fillRect(ceil$1(ue),ceil$1(pe),ceil$1(me)||1,ceil$1(ge)||1)},test(ne){return{left:ne.x,right:ne.x+ne.width,top:ne.y,bottom:ne.y+ne.height}},narrow(){return!0}},circle={draw(ne,oe,ce){oe.fillStyle=getFillStyle(ne.fill,ne.alpha),oe.beginPath();const ue=transform({...ne,width:ne.radius,height:ne.radius},ce);oe.ellipse(ceil$1(ue.x),ceil$1(ue.y),ceil$1(ue.width),ceil$1(ue.height),0,0,2*PI),oe.fill()},test(ne){return{left:ne.x-ne.radius,right:ne.x+ne.radius,top:ne.y-ne.radius,bottom:ne.y+ne.radius}},narrow(){return!0}},polygon={draw(ne,oe,ce){const[ue,...pe]=ne.points;oe.beginPath(),oe.fillStyle=getFillStyle(ne.fill,ne.alpha);const{x:me,y:ge}=transform({...ue,width:0,height:0},ce);oe.moveTo(ceil$1(me),ceil$1(ge));for(const ye of pe){const{x:ve,y:xe}=transform({...ye,width:0,height:0},ce);oe.lineTo(ceil$1(ve),ceil$1(xe))}oe.closePath(),oe.fill()},test(ne){var oe,ce,ue,pe;return{left:((oe=lodashExports.minBy(ne.points,"x"))==null?void 0:oe.x)??0,right:((ce=lodashExports.maxBy(ne.points,"x"))==null?void 0:ce.x)??0,top:((ue=lodashExports.minBy(ne.points,"y"))==null?void 0:ue.y)??0,bottom:((pe=lodashExports.maxBy(ne.points,"y"))==null?void 0:pe.y)??0}},narrow(){return!0}},path={draw(ne,oe,ce){const[ue,...pe]=ne.points;oe.beginPath(),oe.lineCap="round",oe.lineJoin="round",oe.strokeStyle=getStrokeStyle(ne.fill,ne.alpha);const{x:me,y:ge,width:ye}=transform({...ue,width:ne["line-width"]??ne.lineWidth,height:0},ce);oe.lineWidth=ceil$1(ye),oe.moveTo(ceil$1(me),ceil$1(ge));for(const ve of pe){const{x:xe,y:_e}=transform({...ve,width:0,height:0},ce);oe.lineTo(ceil$1(xe),ceil$1(_e))}oe.stroke()},test(ne){var ce,ue,pe,me;const oe=ne["line-width"]??ne.lineWidth;return{left:(((ce=lodashExports.minBy(ne.points,"x"))==null?void 0:ce.x)??0-oe??0)-1,right:(((ue=lodashExports.maxBy(ne.points,"x"))==null?void 0:ue.x)??0+oe??0)+1,top:(((pe=lodashExports.minBy(ne.points,"y"))==null?void 0:pe.y)??0-oe??0)-1,bottom:(((me=lodashExports.maxBy(ne.points,"y"))==null?void 0:me.y)??0+oe??0)+1}},narrow(ne,oe){return pointToLineDistance(point([oe.x,oe.y]),lineString(ne.points.map(({x:ce,y:ue})=>[ce,ue])))<500*ne.lineWidth}},primitives={text,path,rect,polygon,circle};var rgb$1={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]},rgb=rgb$1;rgb.hsl=function(ne){var oe=ne[0]/255,ce=ne[1]/255,ue=ne[2]/255,pe=Math.min(oe,ce,ue),me=Math.max(oe,ce,ue),ge=me-pe,ye,ve,xe;return me===pe?ye=0:oe===me?ye=(ce-ue)/ge:ce===me?ye=2+(ue-oe)/ge:ue===me&&(ye=4+(oe-ce)/ge),ye=Math.min(ye*60,360),ye<0&&(ye+=360),xe=(pe+me)/2,me===pe?ve=0:xe<=.5?ve=ge/(me+pe):ve=ge/(2-me-pe),[ye,ve*100,xe*100]};const{log2,max:max$2}=Math,z=ne=>lodashExports.floor(log2(ne+1));function getTiles({right:ne,left:oe,bottom:ce,top:ue},pe){const me=max$2(z(ne-oe),z(ce-ue))-pe,ge=2**me,ye={left:lodashExports.floor(oe/ge),right:lodashExports.ceil((ne+1)/ge),top:lodashExports.floor(ue/ge),bottom:lodashExports.ceil((ce+1)/ge)};return{zoom:me,order:ge,tiles:lodashExports.shuffle(_default({x:lodashExports.range(ye.left,ye.right+1),y:lodashExports.range(ye.top,ye.bottom+1)}).map(ve=>{const xe=ve.x*ge,_e=ve.y*ge;return{tile:ve,bounds:{left:xe-ge/2,right:xe+ge/2,top:_e-ge/2,bottom:_e+ge/2}}}))}}const defaultBounds={top:0,left:0,right:1,bottom:1},isValue=ne=>lodashExports.isNumber(ne)&&!isNaN(ne),d2RendererWorkerUrl=""+new URL("D2Renderer.worker-32d1b7b8.js",import.meta.url).href;class D2RendererWorkerAdapter extends Worker{constructor(){super(d2RendererWorkerUrl,{type:"module"})}call(oe,ce,ue=[]){return this.postMessage({action:oe,payload:ce},ue)}on(oe,ce){const ue=pe=>{const{action:me,payload:ge}=pe.data;me===oe&&ce(ge)};return this.addEventListener("message",ue),()=>this.removeEventListener("message",ue)}}function intersect(ne,oe){return!(oe.left>=ne.right||oe.right<=ne.left||oe.top>=ne.bottom||oe.bottom<=ne.top)}const{max:max$1,min:min$1}=Math,_Tile=class K1 extends Sprite{constructor(oe,ce){super(oe),this.bounds=ce,this.destroying=!1,this.age=K1.age++}};_Tile.age=0;let Tile=_Tile;function handleNaN(ne,oe){return lodashExports.isNaN(ne)?oe:ne}var oa,wo,Bs,Ms,Fo,Wa,Ns,Fs,sd,ld,Z1,cd,Q1,Jl,td,ud,nd,dd,J1,hd,e0,fd,t0,pd,n0,rd,W1,od,q1,md,r0,ad,V1,gd,i0,yd,o0,bd,a0;class D2Renderer extends EventEmitter{constructor(){super(...arguments);ao(this,ld);ao(this,cd);ao(this,dd);ao(this,hd);ao(this,fd);ao(this,pd);ao(this,rd);ao(this,od);ao(this,md);ao(this,ad);ao(this,gd);ao(this,yd);ao(this,bd);ao(this,oa,void 0);ao(this,wo,void 0);ao(this,Bs,void 0);ao(this,Ms,void 0);ao(this,Fo,defaultD2RendererOptions);ao(this,Wa,[]);ao(this,Ns,new Bush(16));ao(this,Fs,void 0);ao(this,sd,0);ao(this,Jl,lodashExports.once(()=>lodashExports.debounce(()=>Ko(this,rd,W1).call(this),Vr(this,Fo).debounceInterval)));ao(this,td,lodashExports.once(()=>lodashExports.throttle(()=>Ko(this,od,q1).call(this),Vr(this,Fo).refreshInterval)));ao(this,ud,lodashExports.once(()=>lodashExports.throttle(ce=>Ko(this,md,r0).call(this,ce),Vr(this,Fo).refreshInterval)));ao(this,nd,lodashExports.once(()=>{if(typeof OffscreenCanvas>"u")return"OffscreenCanvas API is not supported by your system."}))}getInstance(){return{app:Vr(this,oa),viewport:Vr(this,wo)}}fitCamera(ce=lodashExports.constant(!0)){var pe,me,ge,ye;const ue=lodashExports.values(Vr(this,Ns).all()).flat().filter(ce);if(ue.length){const ve=lodashExports.reduce(ue,(xe,_e)=>({top:handleNaN(min$1(xe.top,_e.top),xe.top),left:handleNaN(min$1(xe.left,_e.left),xe.left),bottom:handleNaN(max$1(xe.bottom,_e.bottom),xe.bottom),right:handleNaN(max$1(xe.right,_e.right),xe.right)}),{bottom:-1/0,top:1/0,left:1/0,right:-1/0});(ye=(pe=Vr(this,wo))==null?void 0:pe.animate)==null||ye.call(pe,{position:new Point((ve.left+ve.right)/2,(ve.top+ve.bottom)/2),scale:((ge=(me=Vr(this,wo))==null?void 0:me.findFit)==null?void 0:ge.call(me,ve.right-ve.left,ve.bottom-ve.top))*.8,ease:"easeOutExpo",time:Vr(this,Fo).animationDuration*1.5,callbackOnComplete:()=>Vr(this,Jl).call(this)()})}}initialCamera(){var ce,ue;(ue=(ce=Vr(this,wo))==null?void 0:ce.animate)==null||ue.call(ce,{scale:1,ease:"easeOutExpo",time:Vr(this,Fo).animationDuration*1.5,callbackOnComplete:()=>Vr(this,Jl).call(this)()})}getView(){var ce;return(ce=Vr(this,oa))==null?void 0:ce.view}async toDataUrl(){var ce,ue,pe,me,ge;return(ue=(ce=Vr(this,oa))==null?void 0:ce.render)==null||ue.call(ce),(ge=(me=(pe=Vr(this,oa))==null?void 0:pe.view)==null?void 0:me.toDataURL)==null?void 0:ge.call(me)}setup(ce){if(Vr(this,nd).call(this))throw new Error(Vr(this,nd).call(this));const ue={...defaultD2RendererOptions,...ce};Ko(this,cd,Q1).call(this,ue),this.setOptions(ue),Ko(this,hd,e0).call(this,ue)}destroy(){lodashExports.map(Vr(this,Wa),ce=>ce.terminate()),Vr(this,oa).destroy()}add(ce){var me,ge;const ue=nanoid(),pe=ce.map(({component:ye,meta:ve})=>({...defaultBounds,...lodashExports.pickBy(primitives[ye.$].test(ye),isValue),component:ye,meta:ve,index:Ko(this,ld,Z1).call(this)}));return Vr(this,Ns).load(pe),(ge=(me=Vr(this,Wa))==null?void 0:me.forEach)==null||ge.call(me,ye=>ye.call("add",[ce,ue])),()=>requestIdleCallback(()=>{var ye,ve;for(const xe of pe)Vr(this,Ns).remove(xe);(ve=(ye=Vr(this,Wa))==null?void 0:ye.forEach)==null||ve.call(ye,xe=>xe.call("remove",[ue]))},{timeout:Vr(this,Fo).animationDuration})}setOptions(ce){const ue={...Vr(this,Fo),...ce};Ko(this,fd,t0).call(this,ue),Os(this,Fo,ue),Ko(this,rd,W1).call(this),Ko(this,od,q1).call(this)}}oa=new WeakMap,wo=new WeakMap,Bs=new WeakMap,Ms=new WeakMap,Fo=new WeakMap,Wa=new WeakMap,Ns=new WeakMap,Fs=new WeakMap,sd=new WeakMap,ld=new WeakSet,Z1=function(){return Y1(this,sd)._++},cd=new WeakSet,Q1=function(ce){Os(this,oa,new Application({backgroundAlpha:0,width:ce.screenSize.width,height:ce.screenSize.height,autoDensity:!0,resolution:2})),Os(this,wo,new ht({stopPropagation:!0,screenWidth:ce.screenSize.width,screenHeight:ce.screenSize.height,events:Vr(this,oa).renderer.events,passiveWheel:!1})),Vr(this,wo).on("clicked",ue=>{const{x:pe,y:me}=ue.world,ge=Vr(this,Ns).search({minX:pe,minY:me,maxX:pe+Number.MIN_VALUE,maxY:me+Number.MIN_VALUE}).filter(ye=>primitives[ye.component.$].narrow(ye.component,{x:pe,y:me}));this.emit("click",ue.event,{world:ue.world,components:ge})}),Vr(this,oa).stage.addChild(Vr(this,wo)),Vr(this,wo).drag().pinch().wheel().decelerate({friction:.98}).clampZoom({maxScale:300,minScale:1e-5}),Vr(this,wo).on("moved",()=>{Vr(this,Jl).call(this)(),Vr(this,td).call(this)()}),Vr(this,wo).on("mousemove",ue=>Vr(this,ud).call(this)(ue)),Os(this,Bs,new Container),Vr(this,wo).addChild(Vr(this,Bs)),Os(this,Ms,new Graphics),Vr(this,wo).addChild(Vr(this,Ms)),Os(this,Fs,new Graphics),Vr(this,wo).addChild(Vr(this,Fs)),Ko(this,dd,J1).call(this)},Jl=new WeakMap,td=new WeakMap,ud=new WeakMap,nd=new WeakMap,dd=new WeakSet,J1=function(){const{dynamicResolution:ce}=Vr(this,Fo),{dtMax:ue,dtMin:pe,increment:me,intervalMs:ge,maxScale:ye,minScale:ve}=ce,xe=lodashExports.floor(Ticker.targetFPMS*ge);let _e=0,Se=0,$e=1;Vr(this,oa).ticker.add(Re=>{const{tileResolution:Ae}=Vr(this,Fo);if(!(_e%xe)){const Ie=Se/xe;$e=lodashExports.clamp(Ie>=ue?$e+me:Ie<=pe?$e-me:$e,ve,ye),lodashExports.map(Vr(this,Wa),ke=>{ke.call("setTileResolution",[{width:lodashExports.ceil(Ae.width/$e),height:lodashExports.ceil(Ae.height/$e)}])}),Se=0}Se+=Re,_e++})},hd=new WeakSet,e0=function(ce){lodashExports.map(Vr(this,Wa),ue=>ue.terminate()),Os(this,Wa,lodashExports.times(ce.workerCount,ue=>{const pe=new D2RendererWorkerAdapter;return pe.on("update",me=>Ko(this,pd,n0).call(this,me)),pe.onerror=me=>{throw me},pe.call("setup",[{...ce,workerIndex:ue}]),pe}))},fd=new WeakSet,t0=function(ce){var me,ge,ye,ve;const{width:ue,height:pe}=ce.screenSize;(ye=(ge=(me=Vr(this,oa))==null?void 0:me.renderer)==null?void 0:ge.resize)==null||ye.call(ge,ue,pe),(ve=Vr(this,wo))==null||ve.resize(ue,pe),lodashExports.map(Vr(this,Wa),xe=>{xe.call("setTileResolution",[{width:lodashExports.ceil(ce.tileResolution.width),height:lodashExports.ceil(ce.tileResolution.height)}])})},pd=new WeakSet,n0=function({bounds:ce,bitmap:ue}){const pe=Texture.from(ue);Ko(this,gd,i0).call(this,pe,ce)},rd=new WeakSet,W1=function(){const{top:ce,bottom:ue,left:pe,right:me}=Vr(this,wo);lodashExports.map(Vr(this,Wa),ge=>ge.call("setFrustum",[{top:ce,bottom:ue,left:pe,right:me}]))},od=new WeakSet,q1=function(){var ge,ye,ve,xe,_e;const{tileSubdivision:ce,accentColor:ue}=Vr(this,Fo),{tiles:pe}=getTiles(Vr(this,wo),ce),me=Ko(this,ad,V1).call(this);(ge=Vr(this,Ms))==null||ge.clear(),(ye=Vr(this,Ms))==null||ye.lineStyle(1*me,ue,.5),(ve=Vr(this,Ms))==null||ve.beginFill(ue,.05);for(const{bounds:Se}of pe)lodashExports.find((xe=Vr(this,Bs))==null?void 0:xe.children,$e=>lodashExports.isEqual($e.bounds,Se))||(_e=Vr(this,Ms))==null||_e.drawRect(Se.left,Se.top,Se.right-Se.left,Se.bottom-Se.top)},md=new WeakSet,r0=function(ce){var ve;const{accentColor:ue}=Vr(this,Fo),pe=Ko(this,ad,V1).call(this),{x:me,y:ge}=Vr(this,wo).toWorld(ce.globalX,ce.globalY),ye=Vr(this,Ns).search({minX:me,minY:ge,maxX:me+Number.MIN_VALUE,maxY:ge+Number.MIN_VALUE}).filter(xe=>primitives[xe.component.$].narrow(xe.component,{x:me,y:ge}));Vr(this,Fs).clear();for(const xe of ye)Vr(this,Fs).lineStyle(2*pe,ue,"$info"in xe.component?1:.02),(ve=Vr(this,Fs))==null||ve.drawRect(xe.left,xe.top,xe.right-xe.left,xe.bottom-xe.top)},ad=new WeakSet,V1=function(){const{right:ce,left:ue}=Vr(this,wo),{width:pe}=Vr(this,Fo).screenSize;return(ce-ue)/pe},gd=new WeakSet,i0=async function(ce,ue){var ge,ye;const{tileSubdivision:pe}=Vr(this,Fo),{tiles:me}=getTiles(Vr(this,wo),pe);if(lodashExports.find(me,ve=>lodashExports.isEqual(ve.bounds,ue))){const ve={x:(ue.right-ue.left)/ce.width,y:(ue.bottom-ue.top)/ce.height},xe=new Tile(ce,ue);(ge=Vr(this,Bs))==null||ge.addChild(xe).setTransform(ue.left,ue.top,ve.x,ve.y),Vr(this,td).call(this)(),await Ko(this,yd,o0).call(this,xe),lodashExports.forEach((ye=Vr(this,Bs))==null?void 0:ye.children,async _e=>{intersect(_e.bounds,ue)&&_e.age{const me=ge=>{ce.alpha+=ge/Ticker.targetFPMS/Vr(this,Fo).animationDuration,ce.alpha>1&&(ue.remove(me),pe())};ce.alpha=0,ue.add(me)})},bd=new WeakSet,a0=function(ce){const ue=Vr(this,oa).ticker;return new Promise(pe=>{const me=ge=>{ce.alpha-=ge/Ticker.targetFPMS/Vr(this,Fo).animationDuration,ce.alpha<0&&(ue.remove(me),pe())};ce.alpha=1,ue.add(me)})};const D2Renderer$1=makeRenderer(D2Renderer,{components:["rect","circle","path","polygon"],id:"d2-renderer",name:"Pixel",description:"Comfortably performant 2D renderer",version:"1.0.0"}),renderers={"d2-renderer":D2Renderer$1};class NativeRendererTransport{constructor(oe){this.options=oe}async get(){const{hostname:oe}=url$2(this.options.url);return renderers[oe]}}const transports={native:{name:"Internal",constructor:NativeRendererTransport}};function RendererService(){const[{renderer:ne}]=useSettings(),[,oe]=useRenderers();return useAsync(async()=>{const ce=[];for(const{transport:ue,url:pe,key:me,disabled:ge}of ne??[])if(!ge){const ye=new transports[ue].constructor({url:pe});ce.push({key:me,url:pe,renderer:await ye.get()})}oe(()=>ce)},[JSON.stringify(ne),oe]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})}const statusColor$1={connected:"success.light",connecting:"warning.light",error:"error.light",disabled:"text.disabled"};function RendererEditor({value:ne,onValueChange:oe}){const[ce]=useRenderers(),ue=usePaper(),pe=lodashExports$1.find(ce,{key:ne.key});function me(ye){oe==null||oe(merge$4(ne,ye))}const ge=ne!=null&&ne.disabled?"disabled":pe?"connected":"error";return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Flex,{alignItems:"center",py:1,children:jsxRuntimeExports.jsx(ManagedModal,{slotProps:{paper:{sx:{width:480}},popover:{anchorOrigin:{horizontal:-18,vertical:"bottom"}}},popover:!0,trigger:ye=>{var ve;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(Box$1,{className:ne.key,onClick:ye,flex:1,sx:{width:0,overflow:"hidden","> *":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",children:pe?`${pe.renderer.meta.name} ${pe.renderer.meta.version}`:lodashExports$1.startCase(ge)}),!!pe&&jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"body2",color:"text.secondary",children:jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{children:pe.renderer.meta.description}),jsxRuntimeExports.jsx("br",{}),jsxRuntimeExports.jsxs("span",{children:["Contributes"," ",lodashExports$1.join(pe.renderer.meta.components,", ")]})]})}),jsxRuntimeExports.jsxs(Type$2,{component:"div",variant:"body2",color:"text.secondary",children:[(ve=transports[ne==null?void 0:ne.transport])==null?void 0:ve.name,": ",(ne==null?void 0:ne.url)||"No URL"]})]}),jsxRuntimeExports.jsx(Chip$1,{sx:{minWidth:0,maxWidth:"fit-content",flex:1,mx:1,color:statusColor$1[ge],...lodashExports$1.omit(ue(1),"borderRadius")},size:"small",label:lodashExports$1.startCase(ge)}),jsxRuntimeExports.jsx(Tooltip$1,{title:`${ne.disabled?"Enable":"Disable"} Renderer`,children:jsxRuntimeExports.jsx(Box$1,{mr:-3,children:jsxRuntimeExports.jsx(Switch$2,{checked:!ne.disabled,onChange:(xe,_e)=>me({disabled:!_e})})})})]})},appBar:{children:jsxRuntimeExports.jsx(AppBarTitle,{children:"Edit Renderer"})},children:jsxRuntimeExports.jsxs(Box$1,{p:2.5,children:[jsxRuntimeExports.jsx(TextField$1,{autoFocus:!0,defaultValue:ne.url,onChange:ye=>me({url:ye.target.value}),fullWidth:!0,variant:"filled",label:"URL",sx:{mb:2}}),jsxRuntimeExports.jsx(SelectField,{placeholder:"Renderer Type",items:lodashExports$1.entries(transports).map(([ye,{name:ve}])=>({value:ye,label:ve})),fullWidth:!0,value:ne.transport,onChange:ye=>me({transport:ye})})]})})})})}function RendererListEditor(){const[{renderer:ne},oe]=useSettings();return jsxRuntimeExports.jsx(Box$1,{sx:{mx:-2},children:jsxRuntimeExports.jsx(ListEditor,{sortable:!0,editor:ce=>jsxRuntimeExports.jsx(RendererEditor,{value:ce}),icon:null,value:ne,onChange:lodashExports$1.debounce(ce=>oe(()=>({renderer:ce})),300),addItemLabel:"Add renderer",create:()=>({transport:defaultTransport,url:"",disabled:!0}),addItemExtras:jsxRuntimeExports.jsx(FeaturePickerButton,{icon:jsxRuntimeExports.jsx(ResetIcon,{}),onClick:()=>oe(()=>({renderer:defaultRenderers})),children:"Reset"}),onFocus:ce=>{const ue=lodashExports$1.head(document.getElementsByClassName(ce));ue&&"click"in ue&&typeof ue.click=="function"&&ue.click()}})})}function useConnectionStatus(ne){const[{connections:oe}]=useLoading(),ce=useConnectionResolver(),[{remote:ue}]=useSettings(),pe=lodashExports$1.find(ue,{url:ne});return pe&&!(pe!=null&&pe.disabled)?ce({url:ne})?"connected":oe?"connecting":ne?"error":"not-connected":"not-connected"}const statusColor={connected:"success.light",connecting:"warning.light",error:"error.light","not-connected":"text.disabled"};function ServerEditor({value:ne,onValueChange:oe}){const ce=useConnection(ne.url),ue=usePaper(),pe=useConnectionStatus(ne.url),me=reactExports.useMemo(()=>debounce$2(ge=>{oe==null||oe(merge$4(ne,ge))},300),[oe,ne]);return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Flex,{alignItems:"center",children:jsxRuntimeExports.jsx(ManagedModal,{slotProps:{paper:{sx:{width:480}},popover:{anchorOrigin:{horizontal:-18,vertical:"bottom"}}},popover:!0,trigger:ge=>{var ye;return jsxRuntimeExports.jsxs(Stack$1,{direction:"row",flex:1,alignItems:"center",sx:{py:1,mr:-3},children:[jsxRuntimeExports.jsxs(Stack$1,{className:ne.key,direction:"row",flex:1,alignItems:"center",onClick:ge,children:[jsxRuntimeExports.jsxs(Box$1,{flex:1,sx:{width:0,overflow:"hidden","> *":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",children:ce?`${ce.name} ${ce.version}`:lodashExports$1.startCase(pe)}),!!(ce!=null&&ce.description)&&jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"body2",color:"text.secondary",children:ce.description}),jsxRuntimeExports.jsxs(Type$2,{component:"div",variant:"body2",color:"text.secondary",children:[(ye=transports$1[ne==null?void 0:ne.transport])==null?void 0:ye.name,": ",(ne==null?void 0:ne.url)||"No URL"]})]}),jsxRuntimeExports.jsx(Chip$1,{sx:{flex:1,minWidth:0,maxWidth:"fit-content",mx:1,color:statusColor[pe],...lodashExports$1.omit(ue(1),"borderRadius")},size:"small",label:lodashExports$1.startCase(pe)})]}),jsxRuntimeExports.jsx(Tooltip$1,{title:`${ne.disabled?"Enable":"Disable"} adapter`,children:jsxRuntimeExports.jsx(Box$1,{children:jsxRuntimeExports.jsx(Switch$2,{defaultChecked:!ne.disabled,onChange:(ve,xe)=>me({disabled:!xe})})})})]})},appBar:{children:jsxRuntimeExports.jsx(AppBarTitle,{children:"Edit Adapter"})},children:jsxRuntimeExports.jsxs(Box$1,{p:2.5,children:[jsxRuntimeExports.jsx(TextField$1,{autoFocus:!0,defaultValue:ne.url,onChange:ge=>me({url:ge.target.value}),fullWidth:!0,variant:"filled",label:"URL",sx:{mb:2}}),jsxRuntimeExports.jsx(SelectField,{placeholder:"Connection Type",items:lodashExports$1.entries(transports$1).map(([ge,{name:ye}])=>({value:ge,label:ye})),fullWidth:!0,value:ne.transport,onChange:ge=>me({transport:ge})})]})})})})}function ServerListEditor(){const[{remote:ne},oe]=useSettings();return jsxRuntimeExports.jsx(Box$1,{sx:{mx:-2},children:jsxRuntimeExports.jsx(ListEditor,{sortable:!0,editor:ce=>jsxRuntimeExports.jsx(ServerEditor,{value:ce}),icon:null,value:ne,onChange:lodashExports$1.debounce(ce=>oe(()=>({remote:ce})),300),addItemLabel:"Add adapter",create:()=>({transport:defaultTransport,url:"",disabled:!0}),addItemExtras:jsxRuntimeExports.jsx(FeaturePickerButton,{icon:jsxRuntimeExports.jsx(ResetIcon,{}),onClick:()=>oe(()=>({remote:defaultRemotes})),children:"Reset"}),onFocus:ce=>{const ue=lodashExports$1.head(document.getElementsByClassName(ce));ue&&"click"in ue&&typeof ue.click=="function"&&ue.click()}})})}const logo$1=""+new URL("logo512-23eace97.png",import.meta.url).href,contacts=[{name:"Dr Daniel Harabor",email:"daniel.harabor@monash.edu"},{name:"Dr Michael Wybrow",email:"michael.wybrow@monash.edu"},{name:"Kevin Zheng",email:"kevin.zheng@monash.edu"},{name:"Francis Anthony",email:"fant0003@student.monash.edu"},{name:"Karan Batta",email:"krnbatta@gmail.com"},{name:"Jay Wingate",email:"jaypeterwingate@gmail.com"},{name:"Leo Whitehead",email:"leo@whiteheadsoftware.dev"},{name:"Can Wang",email:"camwang@outlook.com"},{name:"Rory Tobin-Underwood",email:"rorytu@gmail.com"}];function parseUrl(ne){const oe=new URL(ne);return lodashExports$1.trimEnd(`${oe.hostname}${oe.pathname}`,"/")}function AboutContent(){function ne(oe,ce){return jsxRuntimeExports.jsxs(Box$1,{sx:{pt:2},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"overline",color:"text.secondary",children:oe}),jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"body2",children:ce})]})}return jsxRuntimeExports.jsxs(Box$1,{children:[jsxRuntimeExports.jsx(Box$1,{sx:{pt:0,pb:2},children:jsxRuntimeExports.jsx("img",{src:logo$1,height:"64"})}),jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"h6",children:name}),ne("Build Info",jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:version_name})),ne("Team",jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(List$2,{sx:{mx:-2},children:contacts.map(({name:oe,email:ce},ue)=>jsxRuntimeExports.jsxs(ListItemButton$1,{href:`mailto:${ce}`,children:[jsxRuntimeExports.jsx(ListItemAvatar$1,{children:jsxRuntimeExports.jsx(Avatar$1,{children:lodashExports$1.head(oe)})}),jsxRuntimeExports.jsx(ListItemText$1,{primary:oe,secondary:ce})]},ue))})})),ne("Resources",jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs(List$2,{sx:{mx:-2},children:[jsxRuntimeExports.jsxs(ListItemButton$1,{target:"_blank",href:homepage,children:[jsxRuntimeExports.jsx(ListItemAvatar$1,{children:jsxRuntimeExports.jsx(Avatar$1,{sx:{width:24,height:24},src:logo$1})}),jsxRuntimeExports.jsx(ListItemText$1,{primary:"Home",secondary:parseUrl(homepage)})]}),jsxRuntimeExports.jsxs(ListItemButton$1,{target:"_blank",href:repository,children:[jsxRuntimeExports.jsx(ListItemIcon$1,{children:jsxRuntimeExports.jsx(GitHub,{})}),jsxRuntimeExports.jsx(ListItemText$1,{primary:"Repository",secondary:parseUrl(repository)})]})]})}))]})}const formatLabel=ne=>`${ne}x`;function SettingsPage({template:ne}){const{controls:oe,onChange:ce,state:ue,dragHandle:pe}=useViewTreeContext(),me=useSmallDisplay(),[ge,ye]=useUIState(),ve=useSnackbar(),xe=useBusyState("reset"),[{"playback/playbackRate":_e=1,"appearance/acrylic":Se,"appearance/theme":$e="light","appearance/accentColor":Re="teal","behaviour/showOnStart":Ae},Ie]=useSettings(),[ke,Be]=reactExports.useState("general");function Ne(Ue){return jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"overline",color:"text.secondary",children:Ue})}function Fe(Ue){return jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"body1",sx:{mr:4,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:Ue})}return jsxRuntimeExports.jsx(TabContext,{value:ke,children:jsxRuntimeExports.jsxs(ne,{onChange:ce,stack:ue,children:[jsxRuntimeExports.jsx(ne.Key,{children:"settings"}),jsxRuntimeExports.jsx(ne.Title,{children:"Settings"}),jsxRuntimeExports.jsx(ne.Handle,{children:pe}),jsxRuntimeExports.jsx(ne.Options,{children:jsxRuntimeExports.jsxs(TabList$1,{onChange:(Ue,We)=>Be(We),children:[jsxRuntimeExports.jsx(Tab$1,{label:"General",value:"general"}),jsxRuntimeExports.jsx(Tab$1,{label:"Extensions",value:"connections"}),jsxRuntimeExports.jsx(Tab$1,{label:"Security",value:"security"}),jsxRuntimeExports.jsx(Tab$1,{label:"About",value:"about"})]})}),jsxRuntimeExports.jsx(ne.Content,{children:jsxRuntimeExports.jsx(Flex,{vertical:!0,children:jsxRuntimeExports.jsx(Scroll,{y:!0,children:jsxRuntimeExports.jsxs(Flex,{vertical:!0,pt:6,children:[jsxRuntimeExports.jsx(TabPanel$1,{value:"general",sx:{p:2},children:jsxRuntimeExports.jsxs(Box$1,{children:[Ne("Playback"),jsxRuntimeExports.jsxs(Flex,{alignItems:"center",justifyContent:"space-between",children:[Fe("Playback rate"),jsxRuntimeExports.jsx(Slider$1,{sx:{maxWidth:320,mr:2},marks:[1,2,5,10].map(Ue=>({value:Ue*defaultPlaybackRate,label:formatLabel(Ue)})),step:1*defaultPlaybackRate,min:1*defaultPlaybackRate,max:10*defaultPlaybackRate,valueLabelFormat:Ue=>formatLabel(Ue/defaultPlaybackRate),valueLabelDisplay:"auto",defaultValue:_e,onChangeCommitted:(Ue,We)=>Ie(()=>({"playback/playbackRate":We}))})]}),Ne("Appearance"),jsxRuntimeExports.jsxs(Flex,{alignItems:"center",justifyContent:"space-between",children:[Fe("Acrylic"),jsxRuntimeExports.jsx(Switch$2,{defaultChecked:!!Se,onChange:(Ue,We)=>Ie(()=>({"appearance/acrylic":We}))})]}),jsxRuntimeExports.jsxs(Flex,{alignItems:"center",justifyContent:"space-between",children:[Fe("Dark mode"),jsxRuntimeExports.jsx(Space,{flex:1}),jsxRuntimeExports.jsx(Switch$2,{defaultChecked:$e==="dark",onChange:(Ue,We)=>Ie(()=>({"appearance/theme":We?"dark":"light"}))})]}),jsxRuntimeExports.jsxs(Flex,{alignItems:"center",justifyContent:"space-between",children:[Fe("Accent"),jsxRuntimeExports.jsx(Box$1,{sx:{p:1},children:jsxRuntimeExports.jsx(FeaturePicker,{paper:!0,value:Re,items:lodashExports$1.map(shades,Ue=>({id:Ue,name:lodashExports$1.startCase(Ue),icon:jsxRuntimeExports.jsx(Box$1,{children:jsxRuntimeExports.jsx(Box$1,{sx:{ml:.5,width:12,height:12,backgroundColor:getShade(Ue,$e),borderRadius:4}})})})),arrow:!0,onChange:Ue=>Ie(()=>({"appearance/accentColor":Ue}))})})]}),Ne("Behaviour"),jsxRuntimeExports.jsxs(Flex,{alignItems:"center",justifyContent:"space-between",children:[Fe("Show explore on start-up"),jsxRuntimeExports.jsx(Switch$2,{defaultChecked:!!Ae,onChange:(Ue,We)=>Ie(()=>({"behaviour/showOnStart":We?"explore":void 0}))})]}),Ne("Advanced"),jsxRuntimeExports.jsxs(Flex,{alignItems:"center",justifyContent:"space-between",children:[Fe("Reset settings and extensions"),jsxRuntimeExports.jsx(ManagedModal,{trigger:Ue=>jsxRuntimeExports.jsx(Button,{sx:{mx:1},color:"error",startIcon:jsxRuntimeExports.jsx(RestartAltOutlined,{}),onClick:Ue,children:"Reset now"}),appBar:{children:jsxRuntimeExports.jsx(AppBarTitle,{children:"Reset settings and extensions"})},children:({close:Ue})=>jsxRuntimeExports.jsxs(Stack$1,{sx:{p:me?2:3,pt:2,gap:4},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",color:"text.secondary",children:"If something's not working correctly, you can try to reset all settings and extensions. This cannot be undone."}),jsxRuntimeExports.jsxs(Stack$1,{direction:"row",justifyContent:"flex-end",gap:2,children:[jsxRuntimeExports.jsx(Button,{variant:"text",onClick:()=>{Ue()},children:"Cancel"}),jsxRuntimeExports.jsx(Button,{onClick:()=>{xe(async()=>{await wait(300),Ie(()=>defaults$3),Ue(),ye(()=>({sidebarOpen:!1,fullscreenModal:void 0})),ve("Reset complete")},"Resetting settings and extensions")},color:"error",startIcon:jsxRuntimeExports.jsx(RestartAltOutlined,{}),children:"Reset settings and extensions"})]})]})})]})]})}),jsxRuntimeExports.jsxs(TabPanel$1,{value:"connections",sx:{p:2},children:[jsxRuntimeExports.jsxs(Box$1,{children:[Ne("Adapters"),jsxRuntimeExports.jsx(ServerListEditor,{})]}),jsxRuntimeExports.jsxs(Box$1,{children:[jsxRuntimeExports.jsx(Divider$1,{sx:{mb:2}}),Ne("Renderers"),jsxRuntimeExports.jsx(RendererListEditor,{})]}),jsxRuntimeExports.jsxs(Box$1,{children:[jsxRuntimeExports.jsx(Divider$1,{sx:{mb:2}}),Ne("Map support"),jsxRuntimeExports.jsx(MapParserListEditor,{})]})]}),jsxRuntimeExports.jsxs(TabPanel$1,{value:"security",sx:{p:2},children:[Ne("Trusted origins"),jsxRuntimeExports.jsxs(Box$1,{sx:{maxWidth:480},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",color:"text.secondary",variant:"caption",sx:{pt:2},children:"Rendering traces in the viewport and using advanced debugger features sometimes requires running third-party code."}),jsxRuntimeExports.jsx(Type$2,{component:"div",color:"text.secondary",variant:"caption",sx:{pt:2},children:"You'll be prompted to add origins when necessary, and you can stop trusting origins by removing them from this list."})]}),jsxRuntimeExports.jsx(Box$1,{sx:{pt:2},children:jsxRuntimeExports.jsx(TrustedOriginListEditor,{})})]}),jsxRuntimeExports.jsx(TabPanel$1,{value:"about",sx:{p:2},children:jsxRuntimeExports.jsx(Box$1,{children:jsxRuntimeExports.jsx(AboutContent,{})})})]})})})}),jsxRuntimeExports.jsx(ne.Extras,{children:oe})]})})}const a=lodashExports$1.keys(mapParsers).map(ne=>({key:ne}));function Sink({children:ne}){return ne}function TrustedOriginListEditor(){const[{trustedOrigins:ne},oe]=useSettings(),ce=reactExports.useMemo(()=>lodashExports$1.map(ne,ue=>({key:ue})),[ne]);return jsxRuntimeExports.jsx(Box$1,{sx:{mx:-2},children:jsxRuntimeExports.jsx(ListEditor,{button:!1,sortable:!0,addable:!1,deletable:!0,editor:ue=>jsxRuntimeExports.jsx(Sink,{children:jsxRuntimeExports.jsx(ListItemText$1,{primary:ue.key})},ue.key),icon:null,value:ce,onChange:lodashExports$1.debounce(ue=>oe(()=>({trustedOrigins:lodashExports$1.map(ue,"key")})),300),create:()=>({key:""})})})}function MapParserListEditor(){return jsxRuntimeExports.jsx(Box$1,{sx:{mx:-2},children:jsxRuntimeExports.jsx(ListEditor,{button:!1,sortable:!0,addable:!1,deletable:!1,editor:ne=>jsxRuntimeExports.jsx(Sink,{children:jsxRuntimeExports.jsx(ListItemText$1,{primary:lodashExports$1.startCase(ne.key),secondary:`Support for *.${ne.key} maps`})},ne.key),icon:null,value:a,create:()=>({key:""})})})}const PUBLISH=0,SUBSCRIBE=1,RESET=2,VALUE=4;function compose(ne,oe){return ce=>ne(oe(ce))}function thrush(ne,oe){return oe(ne)}function curry2to1(ne,oe){return ce=>ne(oe,ce)}function curry1to0(ne,oe){return()=>ne(oe)}function tap(ne,oe){return oe(ne),ne}function tup(...ne){return ne}function call(ne){ne()}function always(ne){return()=>ne}function joinProc(...ne){return()=>{ne.map(call)}}function isDefined(ne){return ne!==void 0}function noop$4(){}function subscribe(ne,oe){return ne(SUBSCRIBE,oe)}function publish(ne,oe){ne(PUBLISH,oe)}function reset(ne){ne(RESET)}function getValue(ne){return ne(VALUE)}function connect(ne,oe){return subscribe(ne,curry2to1(oe,PUBLISH))}function handleNext(ne,oe){const ce=ne(SUBSCRIBE,ue=>{ce(),oe(ue)});return ce}function stream(){const ne=[];return(oe,ce)=>{switch(oe){case RESET:ne.splice(0,ne.length);return;case SUBSCRIBE:return ne.push(ce),()=>{const ue=ne.indexOf(ce);ue>-1&&ne.splice(ue,1)};case PUBLISH:ne.slice().forEach(ue=>{ue(ce)});return;default:throw new Error(`unrecognized action ${oe}`)}}}function statefulStream(ne){let oe=ne;const ce=stream();return(ue,pe)=>{switch(ue){case SUBSCRIBE:pe(oe);break;case PUBLISH:oe=pe;break;case VALUE:return oe}return ce(ue,pe)}}function eventHandler(ne){let oe,ce;const ue=()=>oe&&oe();return function(pe,me){switch(pe){case SUBSCRIBE:return me?ce===me?void 0:(ue(),ce=me,oe=subscribe(ne,me),oe):(ue(),noop$4);case RESET:ue(),ce=null;return;default:throw new Error(`unrecognized action ${pe}`)}}}function streamFromEmitter(ne){return tap(stream(),oe=>connect(ne,oe))}function statefulStreamFromEmitter(ne,oe){return tap(statefulStream(oe),ce=>connect(ne,ce))}function combineOperators(...ne){return oe=>ne.reduceRight(thrush,oe)}function pipe(ne,...oe){const ce=combineOperators(...oe);return(ue,pe)=>{switch(ue){case SUBSCRIBE:return subscribe(ne,ce(pe));case RESET:reset(ne);return}}}function defaultComparator(ne,oe){return ne===oe}function distinctUntilChanged(ne=defaultComparator){let oe;return ce=>ue=>{ne(oe,ue)||(oe=ue,ce(ue))}}function filter(ne){return oe=>ce=>{ne(ce)&&oe(ce)}}function map$1(ne){return oe=>compose(oe,ne)}function mapTo(ne){return oe=>()=>oe(ne)}function scan(ne,oe){return ce=>ue=>ce(oe=ne(oe,ue))}function skip(ne){return oe=>ce=>{ne>0?ne--:oe(ce)}}function throttleTime(ne){let oe=null,ce;return ue=>pe=>{oe=pe,!ce&&(ce=setTimeout(()=>{ce=void 0,ue(oe)},ne))}}function debounceTime(ne){let oe,ce;return ue=>pe=>{oe=pe,ce&&clearTimeout(ce),ce=setTimeout(()=>{ue(oe)},ne)}}function withLatestFrom(...ne){const oe=new Array(ne.length);let ce=0,ue=null;const pe=Math.pow(2,ne.length)-1;return ne.forEach((me,ge)=>{const ye=Math.pow(2,ge);subscribe(me,ve=>{const xe=ce;ce=ce|ye,oe[ge]=ve,xe!==pe&&ce===pe&&ue&&(ue(),ue=null)})}),me=>ge=>{const ye=()=>me([ge].concat(oe));ce===pe?ye():ue=ye}}function merge(...ne){return function(oe,ce){switch(oe){case SUBSCRIBE:return joinProc(...ne.map(ue=>subscribe(ue,ce)));case RESET:return;default:throw new Error(`unrecognized action ${oe}`)}}}function duc(ne,oe=defaultComparator){return pipe(ne,distinctUntilChanged(oe))}function combineLatest(...ne){const oe=stream(),ce=new Array(ne.length);let ue=0;const pe=Math.pow(2,ne.length)-1;return ne.forEach((me,ge)=>{const ye=Math.pow(2,ge);subscribe(me,ve=>{ce[ge]=ve,ue=ue|ye,ue===pe&&publish(oe,ce)})}),function(me,ge){switch(me){case SUBSCRIBE:return ue===pe&&ge(ce),subscribe(oe,ge);case RESET:return reset(oe);default:throw new Error(`unrecognized action ${me}`)}}}function system(ne,oe=[],{singleton:ce}={singleton:!0}){return{id:id(),constructor:ne,dependencies:oe,singleton:ce}}const id=()=>Symbol();function init(ne){const oe=new Map,ce=({id:ue,constructor:pe,dependencies:me,singleton:ge})=>{if(ge&&oe.has(ue))return oe.get(ue);const ye=pe(me.map(ve=>ce(ve)));return ge&&oe.set(ue,ye),ye};return ce(ne)}function omit(ne,oe){const ce={},ue={};let pe=0;const me=ne.length;for(;pe(Ne[Fe]=Ue=>{const We=Be[oe.methods[Fe]];publish(We,Ue)},Ne),{})}function _e(Be){return ge.reduce((Ne,Fe)=>(Ne[Fe]=eventHandler(Be[oe.events[Fe]]),Ne),{})}const Se=React$2.forwardRef((Be,Ne)=>{const{children:Fe,...Ue}=Be,[We]=React$2.useState(()=>tap(init(ne),ze=>ve(ze,Ue))),[qe]=React$2.useState(curry1to0(_e,We));return useIsomorphicLayoutEffect$2(()=>{for(const ze of ge)ze in Ue&&subscribe(qe[ze],Ue[ze]);return()=>{Object.values(qe).map(reset)}},[Ue,qe,We]),useIsomorphicLayoutEffect$2(()=>{ve(We,Ue)}),React$2.useImperativeHandle(Ne,always(xe(We))),React$2.createElement(ye.Provider,{value:We},ce?React$2.createElement(ce,omit([...ue,...pe,...ge],Ue),Fe):Fe)}),$e=Be=>React$2.useCallback(curry2to1(publish,React$2.useContext(ye)[Be]),[Be]),Re=Be=>{const Fe=React$2.useContext(ye)[Be],Ue=React$2.useCallback(We=>subscribe(Fe,We),[Fe]);return React$2.useSyncExternalStore(Ue,()=>getValue(Fe),()=>getValue(Fe))},Ae=Be=>{const Fe=React$2.useContext(ye)[Be],[Ue,We]=React$2.useState(curry1to0(getValue,Fe));return useIsomorphicLayoutEffect$2(()=>subscribe(Fe,qe=>{qe!==Ue&&We(always(qe))}),[Fe,Ue]),Ue},Ie=React$2.version.startsWith("18")?Re:Ae;return{Component:Se,usePublisher:$e,useEmitterValue:Ie,useEmitter:(Be,Ne)=>{const Ue=React$2.useContext(ye)[Be];useIsomorphicLayoutEffect$2(()=>subscribe(Ue,Ne),[Ne,Ue])}}}const useIsomorphicLayoutEffect=typeof document<"u"?React$2.useLayoutEffect:React$2.useEffect,useIsomorphicLayoutEffect$1=useIsomorphicLayoutEffect;var LogLevel=(ne=>(ne[ne.DEBUG=0]="DEBUG",ne[ne.INFO=1]="INFO",ne[ne.WARN=2]="WARN",ne[ne.ERROR=3]="ERROR",ne))(LogLevel||{});const CONSOLE_METHOD_MAP={0:"debug",1:"log",2:"warn",3:"error"},getGlobalThis=()=>typeof globalThis>"u"?window:globalThis,loggerSystem=system(()=>{const ne=statefulStream(3);return{log:statefulStream((ce,ue,pe=1)=>{var me;const ge=(me=getGlobalThis().VIRTUOSO_LOG_LEVEL)!=null?me:getValue(ne);pe>=ge&&console[CONSOLE_METHOD_MAP[pe]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",ce,ue)}),logLevel:ne}},[],{singleton:!0});function useSizeWithElRef(ne,oe=!0){const ce=React$2.useRef(null);let ue=pe=>{};if(typeof ResizeObserver<"u"){const pe=React$2.useMemo(()=>new ResizeObserver(me=>{const ge=me[0].target;ge.offsetParent!==null&&ne(ge)}),[ne]);ue=me=>{me&&oe?(pe.observe(me),ce.current=me):(ce.current&&pe.unobserve(ce.current),ce.current=null)}}return{ref:ce,callbackRef:ue}}function useSize(ne,oe=!0){return useSizeWithElRef(ne,oe).callbackRef}function useChangedListContentsSizes(ne,oe,ce,ue,pe,me,ge){const ye=React$2.useCallback(ve=>{const xe=getChangedChildSizes(ve.children,oe,"offsetHeight",pe);let _e=ve.parentElement;for(;!_e.dataset.virtuosoScroller;)_e=_e.parentElement;const Se=_e.lastElementChild.dataset.viewportType==="window",$e=ge?ge.scrollTop:Se?window.pageYOffset||document.documentElement.scrollTop:_e.scrollTop,Re=ge?ge.scrollHeight:Se?document.documentElement.scrollHeight:_e.scrollHeight,Ae=ge?ge.offsetHeight:Se?window.innerHeight:_e.offsetHeight;ue({scrollTop:Math.max($e,0),scrollHeight:Re,viewportHeight:Ae}),me==null||me(resolveGapValue$1("row-gap",getComputedStyle(ve).rowGap,pe)),xe!==null&&ne(xe)},[ne,oe,pe,me,ge,ue]);return useSizeWithElRef(ye,ce)}function getChangedChildSizes(ne,oe,ce,ue){const pe=ne.length;if(pe===0)return null;const me=[];for(let ge=0;ge{const $e=Se.target,Re=$e===window||$e===document,Ae=Re?window.pageYOffset||document.documentElement.scrollTop:$e.scrollTop,Ie=Re?document.documentElement.scrollHeight:$e.scrollHeight,ke=Re?window.innerHeight:$e.offsetHeight,Be=()=>{ne({scrollTop:Math.max(Ae,0),scrollHeight:Ie,viewportHeight:ke})};Se.suppressFlushSync?Be():ReactDOM$1.flushSync(Be),ge.current!==null&&(Ae===ge.current||Ae<=0||Ae===Ie-ke)&&(ge.current=null,oe(!0),ye.current&&(clearTimeout(ye.current),ye.current=null))},[ne,oe]);React$2.useEffect(()=>{const Se=pe||me.current;return ue(pe||me.current),ve({target:Se,suppressFlushSync:!0}),Se.addEventListener("scroll",ve,{passive:!0}),()=>{ue(null),Se.removeEventListener("scroll",ve)}},[me,ve,ce,ue,pe]);function xe(Se){const $e=me.current;if(!$e||"offsetHeight"in $e&&$e.offsetHeight===0)return;const Re=Se.behavior==="smooth";let Ae,Ie,ke;$e===window?(Ie=Math.max(correctItemSize(document.documentElement,"height"),document.documentElement.scrollHeight),Ae=window.innerHeight,ke=document.documentElement.scrollTop):(Ie=$e.scrollHeight,Ae=correctItemSize($e,"height"),ke=$e.scrollTop);const Be=Ie-Ae;if(Se.top=Math.ceil(Math.max(Math.min(Be,Se.top),0)),approximatelyEqual(Ae,Ie)||Se.top===ke){ne({scrollTop:ke,scrollHeight:Ie,viewportHeight:Ae}),Re&&oe(!0);return}Re?(ge.current=Se.top,ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{ye.current=null,ge.current=null,oe(!0)},1e3)):ge.current=null,$e.scrollTo(Se)}function _e(Se){me.current.scrollBy(Se)}return{scrollerRef:me,scrollByCallback:_e,scrollToCallback:xe}}const domIOSystem=system(()=>{const ne=stream(),oe=stream(),ce=statefulStream(0),ue=stream(),pe=statefulStream(0),me=stream(),ge=stream(),ye=statefulStream(0),ve=statefulStream(0),xe=statefulStream(0),_e=statefulStream(0),Se=stream(),$e=stream(),Re=statefulStream(!1);return connect(pipe(ne,map$1(({scrollTop:Ae})=>Ae)),oe),connect(pipe(ne,map$1(({scrollHeight:Ae})=>Ae)),ge),connect(oe,pe),{scrollContainerState:ne,scrollTop:oe,viewportHeight:me,headerHeight:ye,fixedHeaderHeight:ve,fixedFooterHeight:xe,footerHeight:_e,scrollHeight:ge,smoothScrollTargetReached:ue,scrollTo:Se,scrollBy:$e,statefulScrollTop:pe,deviation:ce,scrollingInProgress:Re}},[],{singleton:!0}),NIL_NODE={lvl:0};function newAANode(ne,oe,ce,ue=NIL_NODE,pe=NIL_NODE){return{k:ne,v:oe,lvl:ce,l:ue,r:pe}}function empty(ne){return ne===NIL_NODE}function newTree(){return NIL_NODE}function remove(ne,oe){if(empty(ne))return NIL_NODE;const{k:ce,l:ue,r:pe}=ne;if(oe===ce){if(empty(ue))return pe;if(empty(pe))return ue;{const[me,ge]=last(ue);return adjust(clone(ne,{k:me,v:ge,l:deleteLast(ue)}))}}else return oeoe&&(ye=ye.concat(walkWithin(me,oe,ce))),ue>=oe&&ue<=ce&&ye.push({k:ue,v:pe}),ue<=ce&&(ye=ye.concat(walkWithin(ge,oe,ce))),ye}function walk(ne){return empty(ne)?[]:[...walk(ne.l),{k:ne.k,v:ne.v},...walk(ne.r)]}function last(ne){return empty(ne.r)?[ne.k,ne.v]:last(ne.r)}function deleteLast(ne){return empty(ne.r)?ne.l:adjust(clone(ne,{r:deleteLast(ne.r)}))}function clone(ne,oe){return newAANode(oe.k!==void 0?oe.k:ne.k,oe.v!==void 0?oe.v:ne.v,oe.lvl!==void 0?oe.lvl:ne.lvl,oe.l!==void 0?oe.l:ne.l,oe.r!==void 0?oe.r:ne.r)}function isSingle(ne){return empty(ne)||ne.lvl>ne.r.lvl}function rebalance(ne){return split(skew(ne))}function adjust(ne){const{l:oe,r:ce,lvl:ue}=ne;if(ce.lvl>=ue-1&&oe.lvl>=ue-1)return ne;if(ue>ce.lvl+1){if(isSingle(oe))return skew(clone(ne,{lvl:ue-1}));if(!empty(oe)&&!empty(oe.r))return clone(oe.r,{l:clone(oe,{r:oe.r.l}),r:clone(ne,{l:oe.r.r,lvl:ue-1}),lvl:ue});throw new Error("Unexpected empty nodes")}else{if(isSingle(ne))return split(clone(ne,{lvl:ue-1}));if(!empty(ce)&&!empty(ce.l)){const pe=ce.l,me=isSingle(pe)?ce.lvl-1:ce.lvl;return clone(pe,{l:clone(ne,{r:pe.l,lvl:ue-1}),r:split(clone(ce,{l:pe.r,lvl:me})),lvl:pe.lvl+1})}else throw new Error("Unexpected empty nodes")}}function rangesWithin(ne,oe,ce){if(empty(ne))return[];const ue=findMaxKeyValue(ne,oe)[0];return toRanges(walkWithin(ne,ue,ce))}function arrayToRanges(ne,oe){const ce=ne.length;if(ce===0)return[];let{index:ue,value:pe}=oe(ne[0]);const me=[];for(let ge=1;ge({index:oe,value:ce}))}function split(ne){const{r:oe,lvl:ce}=ne;return!empty(oe)&&!empty(oe.r)&&oe.lvl===ce&&oe.r.lvl===ce?clone(oe,{l:clone(ne,{r:oe.l}),lvl:ce+1}):ne}function skew(ne){const{l:oe}=ne;return!empty(oe)&&oe.lvl===ne.lvl?clone(oe,{r:clone(ne,{l:oe.r})}):ne}function findIndexOfClosestSmallerOrEqual(ne,oe,ce,ue=0){let pe=ne.length-1;for(;ue<=pe;){const me=Math.floor((ue+pe)/2),ge=ne[me],ye=ce(ge,oe);if(ye===0)return me;if(ye===-1){if(pe-ue<2)return me-1;pe=me-1}else{if(pe===ue)return me;ue=me+1}}throw new Error(`Failed binary finding record in array - ${ne.join(",")}, searched for ${oe}`)}function findClosestSmallerOrEqual(ne,oe,ce){return ne[findIndexOfClosestSmallerOrEqual(ne,oe,ce)]}function findRange(ne,oe,ce,ue){const pe=findIndexOfClosestSmallerOrEqual(ne,oe,ue),me=findIndexOfClosestSmallerOrEqual(ne,ce,ue,pe);return ne.slice(pe,me+1)}const recalcSystem=system(()=>({recalcInProgress:statefulStream(!1)}),[],{singleton:!0});function rangeIncludes(ne){const{size:oe,startIndex:ce,endIndex:ue}=ne;return pe=>pe.start===ce&&(pe.end===ue||pe.end===1/0)&&pe.value===oe}function affectedGroupCount(ne,oe){let ce=0,ue=0;for(;ce=_e||pe===$e)&&(ne=remove(ne,_e)):(xe=$e!==pe,ve=!0),Se>ge&&ge>=_e&&$e!==pe&&(ne=insert(ne,ge+1,$e));xe&&(ne=insert(ne,me,pe))}return[ne,ce]}function initialSizeState(){return{offsetTree:[],sizeTree:newTree(),groupOffsetTree:newTree(),lastIndex:0,lastOffset:0,lastSize:0,groupIndices:[]}}function indexComparator({index:ne},oe){return oe===ne?0:oe0&&(oe=Math.max(oe,findClosestSmallerOrEqual(ne,ue,indexComparator).offset)),arrayToRanges(findRange(ne,oe,ce,offsetComparator),offsetPointParser)}function createOffsetTree(ne,oe,ce,ue){let pe=ne,me=0,ge=0,ye=0,ve=0;if(oe!==0){ve=findIndexOfClosestSmallerOrEqual(pe,oe-1,indexComparator),ye=pe[ve].offset;const _e=findMaxKeyValue(ce,oe-1);me=_e[0],ge=_e[1],pe.length&&pe[ve].size===findMaxKeyValue(ce,oe)[1]&&(ve-=1),pe=pe.slice(0,ve+1)}else pe=[];for(const{start:xe,value:_e}of rangesWithin(ce,oe,1/0)){const Se=xe-me,$e=Se*ge+ye+Se*ue;pe.push({offset:$e,size:_e,index:xe}),me=xe,ye=$e,ge=_e}return{offsetTree:pe,lastIndex:me,lastOffset:ye,lastSize:ge}}function sizeStateReducer(ne,[oe,ce,ue,pe]){oe.length>0&&ue("received item sizes",oe,LogLevel.DEBUG);const me=ne.sizeTree;let ge=me,ye=0;if(ce.length>0&&empty(me)&&oe.length===2){const $e=oe[0].size,Re=oe[1].size;ge=ce.reduce((Ae,Ie)=>insert(insert(Ae,Ie,$e),Ie+1,Re),ge)}else[ge,ye]=insertRanges(ge,oe);if(ge===me)return ne;const{offsetTree:ve,lastIndex:xe,lastSize:_e,lastOffset:Se}=createOffsetTree(ne.offsetTree,ye,ge,pe);return{sizeTree:ge,offsetTree:ve,lastIndex:xe,lastOffset:Se,lastSize:_e,groupOffsetTree:ce.reduce(($e,Re)=>insert($e,Re,offsetOf(Re,ve,pe)),newTree()),groupIndices:ce}}function offsetOf(ne,oe,ce){if(oe.length===0)return 0;const{offset:ue,index:pe,size:me}=findClosestSmallerOrEqual(oe,ne,indexComparator),ge=ne-pe,ye=me*ge+(ge-1)*ce+ue;return ye>0?ye+ce:ye}function isGroupLocation(ne){return typeof ne.groupIndex<"u"}function originalIndexFromLocation(ne,oe,ce){if(isGroupLocation(ne))return oe.groupIndices[ne.groupIndex]+1;{const ue=ne.index==="LAST"?ce:ne.index;let pe=originalIndexFromItemIndex(ue,oe);return pe=Math.max(0,pe,Math.min(ce,pe)),pe}}function originalIndexFromItemIndex(ne,oe){if(!hasGroups(oe))return ne;let ce=0;for(;oe.groupIndices[ce]<=ne+ce;)ce++;return ne+ce}function hasGroups(ne){return!empty(ne.groupOffsetTree)}function sizeTreeToRanges(ne){return walk(ne).map(({k:oe,v:ce},ue,pe)=>{const me=pe[ue+1],ge=me?me.k-1:1/0;return{startIndex:oe,endIndex:ge,size:ce}})}const SIZE_MAP={offsetHeight:"height",offsetWidth:"width"},sizeSystem=system(([{log:ne},{recalcInProgress:oe}])=>{const ce=stream(),ue=stream(),pe=statefulStreamFromEmitter(ue,0),me=stream(),ge=stream(),ye=statefulStream(0),ve=statefulStream([]),xe=statefulStream(void 0),_e=statefulStream(void 0),Se=statefulStream((We,qe)=>correctItemSize(We,SIZE_MAP[qe])),$e=statefulStream(void 0),Re=statefulStream(0),Ae=initialSizeState(),Ie=statefulStreamFromEmitter(pipe(ce,withLatestFrom(ve,ne,Re),scan(sizeStateReducer,Ae),distinctUntilChanged()),Ae),ke=statefulStreamFromEmitter(pipe(ve,distinctUntilChanged(),scan((We,qe)=>({prev:We.current,current:qe}),{prev:[],current:[]}),map$1(({prev:We})=>We)),[]);connect(pipe(ve,filter(We=>We.length>0),withLatestFrom(Ie,Re),map$1(([We,qe,ze])=>{const Ge=We.reduce((Ze,Dt,Je)=>insert(Ze,Dt,offsetOf(Dt,qe.offsetTree,ze)||Je),newTree());return{...qe,groupIndices:We,groupOffsetTree:Ge}})),Ie),connect(pipe(ue,withLatestFrom(Ie),filter(([We,{lastIndex:qe}])=>We[{startIndex:We,endIndex:qe,size:ze}])),ce),connect(xe,_e);const Be=statefulStreamFromEmitter(pipe(xe,map$1(We=>We===void 0)),!0);connect(pipe(_e,filter(We=>We!==void 0&&empty(getValue(Ie).sizeTree)),map$1(We=>[{startIndex:0,endIndex:0,size:We}])),ce);const Ne=streamFromEmitter(pipe(ce,withLatestFrom(Ie),scan(({sizes:We},[qe,ze])=>({changed:ze!==We,sizes:ze}),{changed:!1,sizes:Ae}),map$1(We=>We.changed)));subscribe(pipe(ye,scan((We,qe)=>({diff:We.prev-qe,prev:qe}),{diff:0,prev:0}),map$1(We=>We.diff)),We=>{const{groupIndices:qe}=getValue(Ie);if(We>0)publish(oe,!0),publish(me,We+affectedGroupCount(We,qe));else if(We<0){const ze=getValue(ke);ze.length>0&&(We-=affectedGroupCount(-We,ze)),publish(ge,We)}}),subscribe(pipe(ye,withLatestFrom(ne)),([We,qe])=>{We<0&&qe("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:ye},LogLevel.ERROR)});const Fe=streamFromEmitter(me);connect(pipe(me,withLatestFrom(Ie),map$1(([We,qe])=>{const ze=qe.groupIndices.length>0,Ge=[],Ze=qe.lastSize;if(ze){const Dt=find(qe.sizeTree,0);let Je=0,Ut=0;for(;Je{let Kt=an.ranges;return an.prevSize!==0&&(Kt=[...an.ranges,{startIndex:an.prevIndex,endIndex:Zt+We-1,size:an.prevSize}]),{ranges:Kt,prevIndex:Zt+We,prevSize:en}},{ranges:Ge,prevIndex:We,prevSize:0}).ranges}return walk(qe.sizeTree).reduce((Dt,{k:Je,v:Ut})=>({ranges:[...Dt.ranges,{startIndex:Dt.prevIndex,endIndex:Je+We-1,size:Dt.prevSize}],prevIndex:Je+We,prevSize:Ut}),{ranges:[],prevIndex:0,prevSize:Ze}).ranges})),ce);const Ue=streamFromEmitter(pipe(ge,withLatestFrom(Ie,Re),map$1(([We,{offsetTree:qe},ze])=>{const Ge=-We;return offsetOf(Ge,qe,ze)})));return connect(pipe(ge,withLatestFrom(Ie,Re),map$1(([We,qe,ze])=>{if(qe.groupIndices.length>0){if(empty(qe.sizeTree))return qe;let Ze=newTree();const Dt=getValue(ke);let Je=0,Ut=0,jt=0;for(;Je<-We;){jt=Dt[Ut];const an=Dt[Ut+1]-jt-1;Ut++,Je+=an+1}if(Ze=walk(qe.sizeTree).reduce((an,{k:Zt,v:en})=>insert(an,Math.max(0,Zt+We),en),Ze),Je!==-We){const an=find(qe.sizeTree,jt);Ze=insert(Ze,0,an);const Zt=findMaxKeyValue(qe.sizeTree,-We+1)[1];Ze=insert(Ze,1,Zt)}return{...qe,sizeTree:Ze,...createOffsetTree(qe.offsetTree,0,Ze,ze)}}else{const Ze=walk(qe.sizeTree).reduce((Dt,{k:Je,v:Ut})=>insert(Dt,Math.max(0,Je+We),Ut),newTree());return{...qe,sizeTree:Ze,...createOffsetTree(qe.offsetTree,0,Ze,ze)}}})),Ie),{data:$e,totalCount:ue,sizeRanges:ce,groupIndices:ve,defaultItemSize:_e,fixedItemSize:xe,unshiftWith:me,shiftWith:ge,shiftWithOffset:Ue,beforeUnshiftWith:Fe,firstItemIndex:ye,gap:Re,sizes:Ie,listRefresh:Ne,statefulTotalCount:pe,trackItemSizes:Be,itemSize:Se}},tup(loggerSystem,recalcSystem),{singleton:!0}),SUPPORTS_SCROLL_TO_OPTIONS=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function normalizeIndexLocation(ne){const oe=typeof ne=="number"?{index:ne}:ne;return oe.align||(oe.align="start"),(!oe.behavior||!SUPPORTS_SCROLL_TO_OPTIONS)&&(oe.behavior="auto"),oe.offset||(oe.offset=0),oe}const scrollToIndexSystem=system(([{sizes:ne,totalCount:oe,listRefresh:ce,gap:ue},{scrollingInProgress:pe,viewportHeight:me,scrollTo:ge,smoothScrollTargetReached:ye,headerHeight:ve,footerHeight:xe,fixedHeaderHeight:_e,fixedFooterHeight:Se},{log:$e}])=>{const Re=stream(),Ae=statefulStream(0);let Ie=null,ke=null,Be=null;function Ne(){Ie&&(Ie(),Ie=null),Be&&(Be(),Be=null),ke&&(clearTimeout(ke),ke=null),publish(pe,!1)}return connect(pipe(Re,withLatestFrom(ne,me,oe,Ae,ve,xe,$e),withLatestFrom(ue,_e,Se),map$1(([[Fe,Ue,We,qe,ze,Ge,Ze,Dt],Je,Ut,jt])=>{const Ke=normalizeIndexLocation(Fe),{align:an,behavior:Zt,offset:en}=Ke,Kt=qe-1,Wt=originalIndexFromLocation(Ke,Ue,Kt);let un=offsetOf(Wt,Ue.offsetTree,Je)+Ge;an==="end"?(un+=Ut+findMaxKeyValue(Ue.sizeTree,Wt)[1]-We+jt,Wt===Kt&&(un+=Ze)):an==="center"?un+=(Ut+findMaxKeyValue(Ue.sizeTree,Wt)[1]-We+jt)/2:un-=ze,en&&(un+=en);const Xt=nn=>{Ne(),nn?(Dt("retrying to scroll to",{location:Fe},LogLevel.DEBUG),publish(Re,Fe)):Dt("list did not change, scroll successful",{},LogLevel.DEBUG)};if(Ne(),Zt==="smooth"){let nn=!1;Be=subscribe(ce,vn=>{nn=nn||vn}),Ie=handleNext(ye,()=>{Xt(nn)})}else Ie=handleNext(pipe(ce,watchChangesFor(150)),Xt);return ke=setTimeout(()=>{Ne()},1200),publish(pe,!0),Dt("scrolling from index to",{index:Wt,top:un,behavior:Zt},LogLevel.DEBUG),{top:un,behavior:Zt}})),ge),{scrollToIndex:Re,topListHeight:Ae}},tup(sizeSystem,domIOSystem,loggerSystem),{singleton:!0});function watchChangesFor(ne){return oe=>{const ce=setTimeout(()=>{oe(!1)},ne);return ue=>{ue&&(oe(!0),clearTimeout(ce))}}}const UP="up",DOWN="down",NONE$1="none",INITIAL_BOTTOM_STATE={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollTop:0,viewportHeight:0,scrollHeight:0}},DEFAULT_AT_TOP_THRESHOLD=0,stateFlagsSystem=system(([{scrollContainerState:ne,scrollTop:oe,viewportHeight:ce,headerHeight:ue,footerHeight:pe,scrollBy:me}])=>{const ge=statefulStream(!1),ye=statefulStream(!0),ve=stream(),xe=stream(),_e=statefulStream(4),Se=statefulStream(DEFAULT_AT_TOP_THRESHOLD),$e=statefulStreamFromEmitter(pipe(merge(pipe(duc(oe),skip(1),mapTo(!0)),pipe(duc(oe),skip(1),mapTo(!1),debounceTime(100))),distinctUntilChanged()),!1),Re=statefulStreamFromEmitter(pipe(merge(pipe(me,mapTo(!0)),pipe(me,mapTo(!1),debounceTime(200))),distinctUntilChanged()),!1);connect(pipe(combineLatest(duc(oe),duc(Se)),map$1(([Ne,Fe])=>Ne<=Fe),distinctUntilChanged()),ye),connect(pipe(ye,throttleTime(50)),xe);const Ae=streamFromEmitter(pipe(combineLatest(ne,duc(ce),duc(ue),duc(pe),duc(_e)),scan((Ne,[{scrollTop:Fe,scrollHeight:Ue},We,qe,ze,Ge])=>{const Ze=Fe+We-Ue>-Ge,Dt={viewportHeight:We,scrollTop:Fe,scrollHeight:Ue};if(Ze){let Ut,jt;return Fe>Ne.state.scrollTop?(Ut="SCROLLED_DOWN",jt=Ne.state.scrollTop-Fe):(Ut="SIZE_DECREASED",jt=Ne.state.scrollTop-Fe||Ne.scrollTopDelta),{atBottom:!0,state:Dt,atBottomBecause:Ut,scrollTopDelta:jt}}let Je;return Dt.scrollHeight>Ne.state.scrollHeight?Je="SIZE_INCREASED":WeNe&&Ne.atBottom===Fe.atBottom))),Ie=statefulStreamFromEmitter(pipe(ne,scan((Ne,{scrollTop:Fe,scrollHeight:Ue,viewportHeight:We})=>{if(approximatelyEqual(Ne.scrollHeight,Ue))return{scrollTop:Fe,scrollHeight:Ue,jump:0,changed:!1};{const qe=Ue-(Fe+We)<1;return Ne.scrollTop!==Fe&&qe?{scrollHeight:Ue,scrollTop:Fe,jump:Ne.scrollTop-Fe,changed:!0}:{scrollHeight:Ue,scrollTop:Fe,jump:0,changed:!0}}},{scrollHeight:0,jump:0,scrollTop:0,changed:!1}),filter(Ne=>Ne.changed),map$1(Ne=>Ne.jump)),0);connect(pipe(Ae,map$1(Ne=>Ne.atBottom)),ge),connect(pipe(ge,throttleTime(50)),ve);const ke=statefulStream(DOWN);connect(pipe(ne,map$1(({scrollTop:Ne})=>Ne),distinctUntilChanged(),scan((Ne,Fe)=>getValue(Re)?{direction:Ne.direction,prevScrollTop:Fe}:{direction:FeNe.direction)),ke),connect(pipe(ne,throttleTime(50),mapTo(NONE$1)),ke);const Be=statefulStream(0);return connect(pipe($e,filter(Ne=>!Ne),mapTo(0)),Be),connect(pipe(oe,throttleTime(100),withLatestFrom($e),filter(([Ne,Fe])=>!!Fe),scan(([Ne,Fe],[Ue])=>[Fe,Ue],[0,0]),map$1(([Ne,Fe])=>Fe-Ne)),Be),{isScrolling:$e,isAtTop:ye,isAtBottom:ge,atBottomState:Ae,atTopStateChange:xe,atBottomStateChange:ve,scrollDirection:ke,atBottomThreshold:_e,atTopThreshold:Se,scrollVelocity:Be,lastJumpDueToItemResize:Ie}},tup(domIOSystem)),propsReadySystem=system(([{log:ne}])=>{const oe=statefulStream(!1),ce=streamFromEmitter(pipe(oe,filter(ue=>ue),distinctUntilChanged()));return subscribe(oe,ue=>{ue&&getValue(ne)("props updated",{},LogLevel.DEBUG)}),{propsReady:oe,didMount:ce}},tup(loggerSystem),{singleton:!0});function skipFrames(ne,oe){ne==0?oe():requestAnimationFrame(()=>skipFrames(ne-1,oe))}function getInitialTopMostItemIndexNumber(ne,oe){const ce=oe-1;return typeof ne=="number"?ne:ne.index==="LAST"?ce:ne.index}const initialTopMostItemIndexSystem=system(([{sizes:ne,listRefresh:oe,defaultItemSize:ce},{scrollTop:ue},{scrollToIndex:pe},{didMount:me}])=>{const ge=statefulStream(!0),ye=statefulStream(0),ve=statefulStream(!1);return connect(pipe(me,withLatestFrom(ye),filter(([xe,_e])=>!!_e),mapTo(!1)),ge),subscribe(pipe(combineLatest(oe,me),withLatestFrom(ge,ne,ce,ve),filter(([[,xe],_e,{sizeTree:Se},$e,Re])=>xe&&(!empty(Se)||isDefined($e))&&!_e&&!Re),withLatestFrom(ye)),([,xe])=>{publish(ve,!0),skipFrames(3,()=>{handleNext(ue,()=>publish(ge,!0)),publish(pe,xe)})}),{scrolledToInitialItem:ge,initialTopMostItemIndex:ye}},tup(sizeSystem,domIOSystem,scrollToIndexSystem,propsReadySystem),{singleton:!0});function normalizeFollowOutput(ne){return ne?ne==="smooth"?"smooth":"auto":!1}const behaviorFromFollowOutput=(ne,oe)=>typeof ne=="function"?normalizeFollowOutput(ne(oe)):oe&&normalizeFollowOutput(ne),followOutputSystem=system(([{totalCount:ne,listRefresh:oe},{isAtBottom:ce,atBottomState:ue},{scrollToIndex:pe},{scrolledToInitialItem:me},{propsReady:ge,didMount:ye},{log:ve},{scrollingInProgress:xe}])=>{const _e=statefulStream(!1),Se=stream();let $e=null;function Re(Ie){publish(pe,{index:"LAST",align:"end",behavior:Ie})}subscribe(pipe(combineLatest(pipe(duc(ne),skip(1)),ye),withLatestFrom(duc(_e),ce,me,xe),map$1(([[Ie,ke],Be,Ne,Fe,Ue])=>{let We=ke&&Fe,qe="auto";return We&&(qe=behaviorFromFollowOutput(Be,Ne||Ue),We=We&&!!qe),{totalCount:Ie,shouldFollow:We,followOutputBehavior:qe}}),filter(({shouldFollow:Ie})=>Ie)),({totalCount:Ie,followOutputBehavior:ke})=>{$e&&($e(),$e=null),$e=handleNext(oe,()=>{getValue(ve)("following output to ",{totalCount:Ie},LogLevel.DEBUG),Re(ke),$e=null})});function Ae(Ie){const ke=handleNext(ue,Be=>{Ie&&!Be.atBottom&&Be.notAtBottomBecause==="SIZE_INCREASED"&&!$e&&(getValue(ve)("scrolling to bottom due to increased size",{},LogLevel.DEBUG),Re("auto"))});setTimeout(ke,100)}return subscribe(pipe(combineLatest(duc(_e),ne,ge),filter(([Ie,,ke])=>Ie&&ke),scan(({value:Ie},[,ke])=>({refreshed:Ie===ke,value:ke}),{refreshed:!1,value:0}),filter(({refreshed:Ie})=>Ie),withLatestFrom(_e,ne)),([,Ie])=>{Ae(Ie!==!1)}),subscribe(Se,()=>{Ae(getValue(_e)!==!1)}),subscribe(combineLatest(duc(_e),ue),([Ie,ke])=>{Ie&&!ke.atBottom&&ke.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&Re("auto")}),{followOutput:_e,autoscrollToBottom:Se}},tup(sizeSystem,stateFlagsSystem,scrollToIndexSystem,initialTopMostItemIndexSystem,propsReadySystem,loggerSystem,domIOSystem));function groupCountsToIndicesAndCount(ne){return ne.reduce((oe,ce)=>(oe.groupIndices.push(oe.totalCount),oe.totalCount+=ce+1,oe),{totalCount:0,groupIndices:[]})}const groupedListSystem=system(([{totalCount:ne,groupIndices:oe,sizes:ce},{scrollTop:ue,headerHeight:pe}])=>{const me=stream(),ge=stream(),ye=streamFromEmitter(pipe(me,map$1(groupCountsToIndicesAndCount)));return connect(pipe(ye,map$1(ve=>ve.totalCount)),ne),connect(pipe(ye,map$1(ve=>ve.groupIndices)),oe),connect(pipe(combineLatest(ue,ce,pe),filter(([ve,xe])=>hasGroups(xe)),map$1(([ve,xe,_e])=>findMaxKeyValue(xe.groupOffsetTree,Math.max(ve-_e,0),"v")[0]),distinctUntilChanged(),map$1(ve=>[ve])),ge),{groupCounts:me,topItemsIndexes:ge}},tup(sizeSystem,domIOSystem));function tupleComparator(ne,oe){return!!(ne&&ne[0]===oe[0]&&ne[1]===oe[1])}function rangeComparator(ne,oe){return!!(ne&&ne.startIndex===oe.startIndex&&ne.endIndex===oe.endIndex)}const TOP="top",BOTTOM="bottom",NONE="none";function getOverscan(ne,oe,ce){return typeof ne=="number"?ce===UP&&oe===TOP||ce===DOWN&&oe===BOTTOM?ne:0:ce===UP?oe===TOP?ne.main:ne.reverse:oe===BOTTOM?ne.main:ne.reverse}function getViewportIncrease(ne,oe){return typeof ne=="number"?ne:ne[oe]||0}const sizeRangeSystem=system(([{scrollTop:ne,viewportHeight:oe,deviation:ce,headerHeight:ue,fixedHeaderHeight:pe}])=>{const me=stream(),ge=statefulStream(0),ye=statefulStream(0),ve=statefulStream(0),xe=statefulStreamFromEmitter(pipe(combineLatest(duc(ne),duc(oe),duc(ue),duc(me,tupleComparator),duc(ve),duc(ge),duc(pe),duc(ce),duc(ye)),map$1(([_e,Se,$e,[Re,Ae],Ie,ke,Be,Ne,Fe])=>{const Ue=_e-Ne,We=ke+Be,qe=Math.max($e-Ue,0);let ze=NONE;const Ge=getViewportIncrease(Fe,TOP),Ze=getViewportIncrease(Fe,BOTTOM);return Re-=Ne,Re+=$e+Be,Ae+=$e+Be,Ae-=Ne,Re>_e+We-Ge&&(ze=UP),Ae<_e-qe+Se+Ze&&(ze=DOWN),ze!==NONE?[Math.max(Ue-$e-getOverscan(Ie,TOP,ze)-Ge,0),Ue-qe-Be+Se+getOverscan(Ie,BOTTOM,ze)+Ze]:null}),filter(_e=>_e!=null),distinctUntilChanged(tupleComparator)),[0,0]);return{listBoundary:me,overscan:ve,topListHeight:ge,increaseViewportBy:ye,visibleRange:xe}},tup(domIOSystem),{singleton:!0});function probeItemSet(ne,oe,ce){if(hasGroups(oe)){const ue=originalIndexFromItemIndex(ne,oe);return[{index:findMaxKeyValue(oe.groupOffsetTree,ue)[0],size:0,offset:0},{index:ue,size:0,offset:0,data:ce&&ce[0]}]}return[{index:ne,size:0,offset:0,data:ce&&ce[0]}]}const EMPTY_LIST_STATE={items:[],topItems:[],offsetTop:0,offsetBottom:0,top:0,bottom:0,topListHeight:0,totalCount:0,firstItemIndex:0};function transposeItems(ne,oe,ce){if(ne.length===0)return[];if(!hasGroups(oe))return ne.map(xe=>({...xe,index:xe.index+ce,originalIndex:xe.index}));const ue=ne[0].index,pe=ne[ne.length-1].index,me=[],ge=rangesWithin(oe.groupOffsetTree,ue,pe);let ye,ve=0;for(const xe of ne){(!ye||ye.end0){xe=ne[0].offset;const Ie=ne[ne.length-1];_e=Ie.offset+Ie.size}const Se=ce-ve,$e=ye+Se*ge+(Se-1)*ue,Re=xe,Ae=$e-_e;return{items:transposeItems(ne,pe,me),topItems:transposeItems(oe,pe,me),topListHeight:oe.reduce((Ie,ke)=>ke.size+Ie,0),offsetTop:xe,offsetBottom:Ae,top:Re,bottom:_e,totalCount:ce,firstItemIndex:me}}function buildListStateFromItemCount(ne,oe,ce,ue,pe,me){let ge=0;if(ce.groupIndices.length>0)for(const _e of ce.groupIndices){if(_e-ge>=ne)break;ge++}const ye=ne+ge,ve=getInitialTopMostItemIndexNumber(oe,ye),xe=Array.from({length:ye}).map((_e,Se)=>({index:Se+ve,size:0,offset:0,data:me[Se+ve]}));return buildListState(xe,[],ye,pe,ce,ue)}const listStateSystem=system(([{sizes:ne,totalCount:oe,data:ce,firstItemIndex:ue,gap:pe},me,{visibleRange:ge,listBoundary:ye,topListHeight:ve},{scrolledToInitialItem:xe,initialTopMostItemIndex:_e},{topListHeight:Se},$e,{didMount:Re},{recalcInProgress:Ae}])=>{const Ie=statefulStream([]),ke=statefulStream(0),Be=stream();connect(me.topItemsIndexes,Ie);const Ne=statefulStreamFromEmitter(pipe(combineLatest(Re,Ae,duc(ge,tupleComparator),duc(oe),duc(ne),duc(_e),xe,duc(Ie),duc(ue),duc(pe),ce),filter(([qe,ze,,Ge,,,,,,,Ze])=>{const Dt=Ze&&Ze.length!==Ge;return qe&&!ze&&!Dt}),map$1(([,,[qe,ze],Ge,Ze,Dt,Je,Ut,jt,Ke,an])=>{const Zt=Ze,{sizeTree:en,offsetTree:Kt}=Zt,Wt=getValue(ke);if(Ge===0)return{...EMPTY_LIST_STATE,totalCount:Ge};if(qe===0&&ze===0)return Wt===0?{...EMPTY_LIST_STATE,totalCount:Ge}:buildListStateFromItemCount(Wt,Dt,Ze,jt,Ke,an||[]);if(empty(en))return Wt>0?null:buildListState(probeItemSet(getInitialTopMostItemIndexNumber(Dt,Ge),Zt,an),[],Ge,Ke,Zt,jt);const un=[];if(Ut.length>0){const Cn=Ut[0],Nt=Ut[Ut.length-1];let Yt=0;for(const Jt of rangesWithin(en,Cn,Nt)){const hn=Jt.value,Ye=Math.max(Jt.start,Cn),Xe=Math.min(Jt.end,Nt);for(let Pt=Ye;Pt<=Xe;Pt++)un.push({index:Pt,size:hn,offset:Yt,data:an&&an[Pt]}),Yt+=hn}}if(!Je)return buildListState([],un,Ge,Ke,Zt,jt);const Xt=Ut.length>0?Ut[Ut.length-1]+1:0,nn=rangesWithinOffsets(Kt,qe,ze,Xt);if(nn.length===0)return null;const vn=Ge-1,Sn=tap([],Cn=>{for(const Nt of nn){const Yt=Nt.value;let Jt=Yt.offset,hn=Nt.start;const Ye=Yt.size;if(Yt.offset=ze);Pt++)Cn.push({index:Pt,size:Ye,offset:Jt,data:an&&an[Pt]}),Jt+=Ye+Ke}});return buildListState(Sn,un,Ge,Ke,Zt,jt)}),filter(qe=>qe!==null),distinctUntilChanged()),EMPTY_LIST_STATE);connect(pipe(ce,filter(isDefined),map$1(qe=>qe==null?void 0:qe.length)),oe),connect(pipe(Ne,map$1(qe=>qe.topListHeight)),Se),connect(Se,ve),connect(pipe(Ne,map$1(qe=>[qe.top,qe.bottom])),ye),connect(pipe(Ne,map$1(qe=>qe.items)),Be);const Fe=streamFromEmitter(pipe(Ne,filter(({items:qe})=>qe.length>0),withLatestFrom(oe,ce),filter(([{items:qe},ze])=>qe[qe.length-1].originalIndex===ze-1),map$1(([,qe,ze])=>[qe-1,ze]),distinctUntilChanged(tupleComparator),map$1(([qe])=>qe))),Ue=streamFromEmitter(pipe(Ne,throttleTime(200),filter(({items:qe,topItems:ze})=>qe.length>0&&qe[0].originalIndex===ze.length),map$1(({items:qe})=>qe[0].index),distinctUntilChanged())),We=streamFromEmitter(pipe(Ne,filter(({items:qe})=>qe.length>0),map$1(({items:qe})=>{let ze=0,Ge=qe.length-1;for(;qe[ze].type==="group"&&zeze;)Ge--;return{startIndex:qe[ze].index,endIndex:qe[Ge].index}}),distinctUntilChanged(rangeComparator)));return{listState:Ne,topItemsIndexes:Ie,endReached:Fe,startReached:Ue,rangeChanged:We,itemsRendered:Be,initialItemCount:ke,...$e}},tup(sizeSystem,groupedListSystem,sizeRangeSystem,initialTopMostItemIndexSystem,scrollToIndexSystem,stateFlagsSystem,propsReadySystem,recalcSystem),{singleton:!0}),initialItemCountSystem=system(([{sizes:ne,firstItemIndex:oe,data:ce,gap:ue},{initialTopMostItemIndex:pe},{initialItemCount:me,listState:ge},{didMount:ye}])=>(connect(pipe(ye,withLatestFrom(me),filter(([,ve])=>ve!==0),withLatestFrom(pe,ne,oe,ue,ce),map$1(([[,ve],xe,_e,Se,$e,Re=[]])=>buildListStateFromItemCount(ve,xe,_e,Se,$e,Re))),ge),{}),tup(sizeSystem,initialTopMostItemIndexSystem,listStateSystem,propsReadySystem),{singleton:!0}),scrollSeekSystem=system(([{scrollVelocity:ne}])=>{const oe=statefulStream(!1),ce=stream(),ue=statefulStream(!1);return connect(pipe(ne,withLatestFrom(ue,oe,ce),filter(([pe,me])=>!!me),map$1(([pe,me,ge,ye])=>{const{exit:ve,enter:xe}=me;if(ge){if(ve(pe,ye))return!1}else if(xe(pe,ye))return!0;return ge}),distinctUntilChanged()),oe),subscribe(pipe(combineLatest(oe,ne,ce),withLatestFrom(ue)),([[pe,me,ge],ye])=>pe&&ye&&ye.change&&ye.change(me,ge)),{isSeeking:oe,scrollSeekConfiguration:ue,scrollVelocity:ne,scrollSeekRangeChanged:ce}},tup(stateFlagsSystem),{singleton:!0}),topItemCountSystem=system(([{topItemsIndexes:ne}])=>{const oe=statefulStream(0);return connect(pipe(oe,filter(ce=>ce>0),map$1(ce=>Array.from({length:ce}).map((ue,pe)=>pe))),ne),{topItemCount:oe}},tup(listStateSystem)),totalListHeightSystem=system(([{footerHeight:ne,headerHeight:oe,fixedHeaderHeight:ce,fixedFooterHeight:ue},{listState:pe}])=>{const me=stream(),ge=statefulStreamFromEmitter(pipe(combineLatest(ne,ue,oe,ce,pe),map$1(([ye,ve,xe,_e,Se])=>ye+ve+xe+_e+Se.offsetBottom+Se.bottom)),0);return connect(duc(ge),me),{totalListHeight:ge,totalListHeightChanged:me}},tup(domIOSystem,listStateSystem),{singleton:!0});function simpleMemoize(ne){let oe=!1,ce;return()=>(oe||(oe=!0,ce=ne()),ce)}const isMobileSafari=simpleMemoize(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),upwardScrollFixSystem=system(([{scrollBy:ne,scrollTop:oe,deviation:ce,scrollingInProgress:ue},{isScrolling:pe,isAtBottom:me,scrollDirection:ge,lastJumpDueToItemResize:ye},{listState:ve},{beforeUnshiftWith:xe,shiftWithOffset:_e,sizes:Se,gap:$e},{log:Re},{recalcInProgress:Ae}])=>{const Ie=streamFromEmitter(pipe(ve,withLatestFrom(ye),scan(([,Be,Ne,Fe],[{items:Ue,totalCount:We,bottom:qe,offsetBottom:ze},Ge])=>{const Ze=qe+ze;let Dt=0;return Ne===We&&Be.length>0&&Ue.length>0&&(Ue[0].originalIndex===0&&Be[0].originalIndex===0||(Dt=Ze-Fe,Dt!==0&&(Dt+=Ge))),[Dt,Ue,We,Ze]},[0,[],0,0]),filter(([Be])=>Be!==0),withLatestFrom(oe,ge,ue,me,Re,Ae),filter(([,Be,Ne,Fe,,,Ue])=>!Ue&&!Fe&&Be!==0&&Ne===UP),map$1(([[Be],,,,,Ne])=>(Ne("Upward scrolling compensation",{amount:Be},LogLevel.DEBUG),Be))));function ke(Be){Be>0?(publish(ne,{top:-Be,behavior:"auto"}),publish(ce,0)):(publish(ce,0),publish(ne,{top:-Be,behavior:"auto"}))}return subscribe(pipe(Ie,withLatestFrom(ce,pe)),([Be,Ne,Fe])=>{Fe&&isMobileSafari()?publish(ce,Ne-Be):ke(-Be)}),subscribe(pipe(combineLatest(statefulStreamFromEmitter(pe,!1),ce,Ae),filter(([Be,Ne,Fe])=>!Be&&!Fe&&Ne!==0),map$1(([Be,Ne])=>Ne),throttleTime(1)),ke),connect(pipe(_e,map$1(Be=>({top:-Be}))),ne),subscribe(pipe(xe,withLatestFrom(Se,$e),map$1(([Be,{lastSize:Ne,groupIndices:Fe,sizeTree:Ue},We])=>{function qe(ze){return ze*(Ne+We)}if(Fe.length===0)return qe(Be);{let ze=0;const Ge=find(Ue,0);let Ze=0,Dt=0;for(;ZeBe&&(ze-=Ge,Je=Be-Ze+1),Ze+=Je,ze+=qe(Je),Dt++}return ze}})),Be=>{publish(ce,Be),requestAnimationFrame(()=>{publish(ne,{top:Be}),requestAnimationFrame(()=>{publish(ce,0),publish(Ae,!1)})})}),{deviation:ce}},tup(domIOSystem,stateFlagsSystem,listStateSystem,sizeSystem,loggerSystem,recalcSystem)),initialScrollTopSystem=system(([{didMount:ne},{scrollTo:oe},{listState:ce}])=>{const ue=statefulStream(0);return subscribe(pipe(ne,withLatestFrom(ue),filter(([,pe])=>pe!==0),map$1(([,pe])=>({top:pe}))),pe=>{handleNext(pipe(ce,skip(1),filter(me=>me.items.length>1)),()=>{requestAnimationFrame(()=>{publish(oe,pe)})})}),{initialScrollTop:ue}},tup(propsReadySystem,domIOSystem,listStateSystem),{singleton:!0}),alignToBottomSystem=system(([{viewportHeight:ne},{totalListHeight:oe}])=>{const ce=statefulStream(!1),ue=statefulStreamFromEmitter(pipe(combineLatest(ce,ne,oe),filter(([pe])=>pe),map$1(([,pe,me])=>Math.max(0,pe-me)),throttleTime(0),distinctUntilChanged()),0);return{alignToBottom:ce,paddingTopAddition:ue}},tup(domIOSystem,totalListHeightSystem),{singleton:!0}),windowScrollerSystem=system(([{scrollTo:ne,scrollContainerState:oe}])=>{const ce=stream(),ue=stream(),pe=stream(),me=statefulStream(!1),ge=statefulStream(void 0);return connect(pipe(combineLatest(ce,ue),map$1(([{viewportHeight:ye,scrollTop:ve,scrollHeight:xe},{offsetTop:_e}])=>({scrollTop:Math.max(0,ve-_e),scrollHeight:xe,viewportHeight:ye}))),oe),connect(pipe(ne,withLatestFrom(ue),map$1(([ye,{offsetTop:ve}])=>({...ye,top:ye.top+ve}))),pe),{useWindowScroll:me,customScrollParent:ge,windowScrollContainerState:ce,windowViewportRect:ue,windowScrollTo:pe}},tup(domIOSystem)),defaultCalculateViewLocation=({itemTop:ne,itemBottom:oe,viewportTop:ce,viewportBottom:ue,locationParams:{behavior:pe,align:me,...ge}})=>neue?{...ge,behavior:pe,align:me??"end"}:null,scrollIntoViewSystem=system(([{sizes:ne,totalCount:oe,gap:ce},{scrollTop:ue,viewportHeight:pe,headerHeight:me,fixedHeaderHeight:ge,fixedFooterHeight:ye,scrollingInProgress:ve},{scrollToIndex:xe}])=>{const _e=stream();return connect(pipe(_e,withLatestFrom(ne,pe,oe,me,ge,ye,ue),withLatestFrom(ce),map$1(([[Se,$e,Re,Ae,Ie,ke,Be,Ne],Fe])=>{const{done:Ue,behavior:We,align:qe,calculateViewLocation:ze=defaultCalculateViewLocation,...Ge}=Se,Ze=originalIndexFromLocation(Se,$e,Ae-1),Dt=offsetOf(Ze,$e.offsetTree,Fe)+Ie+ke,Je=Dt+findMaxKeyValue($e.sizeTree,Ze)[1],Ut=Ne+ke,jt=Ne+Re-Be,Ke=ze({itemTop:Dt,itemBottom:Je,viewportTop:Ut,viewportBottom:jt,locationParams:{behavior:We,align:qe,...Ge}});return Ke?Ue&&handleNext(pipe(ve,filter(an=>an===!1),skip(getValue(ve)?1:2)),Ue):Ue&&Ue(),Ke}),filter(Se=>Se!==null)),xe),{scrollIntoView:_e}},tup(sizeSystem,domIOSystem,scrollToIndexSystem,listStateSystem,loggerSystem),{singleton:!0}),stateLoadSystem=system(([{sizes:ne,sizeRanges:oe},{scrollTop:ce},{initialTopMostItemIndex:ue},{didMount:pe},{useWindowScroll:me,windowScrollContainerState:ge,windowViewportRect:ye}])=>{const ve=stream(),xe=statefulStream(void 0),_e=statefulStream(null),Se=statefulStream(null);return connect(ge,_e),connect(ye,Se),subscribe(pipe(ve,withLatestFrom(ne,ce,me,_e,Se)),([$e,Re,Ae,Ie,ke,Be])=>{const Ne=sizeTreeToRanges(Re.sizeTree);Ie&&ke!==null&&Be!==null&&(Ae=ke.scrollTop-Be.offsetTop),$e({ranges:Ne,scrollTop:Ae})}),connect(pipe(xe,filter(isDefined),map$1(locationFromSnapshot)),ue),connect(pipe(pe,withLatestFrom(xe),filter(([,$e])=>$e!==void 0),distinctUntilChanged(),map$1(([,$e])=>$e.ranges)),oe),{getState:ve,restoreStateFrom:xe}},tup(sizeSystem,domIOSystem,initialTopMostItemIndexSystem,propsReadySystem,windowScrollerSystem));function locationFromSnapshot(ne){return{offset:ne.scrollTop,index:0,align:"start"}}const featureGroup1System=system(([ne,oe,ce,ue,pe,me,ge,ye,ve,xe])=>({...ne,...oe,...ce,...ue,...pe,...me,...ge,...ye,...ve,...xe}),tup(sizeRangeSystem,initialItemCountSystem,propsReadySystem,scrollSeekSystem,totalListHeightSystem,initialScrollTopSystem,alignToBottomSystem,windowScrollerSystem,scrollIntoViewSystem,loggerSystem)),listSystem=system(([{totalCount:ne,sizeRanges:oe,fixedItemSize:ce,defaultItemSize:ue,trackItemSizes:pe,itemSize:me,data:ge,firstItemIndex:ye,groupIndices:ve,statefulTotalCount:xe,gap:_e,sizes:Se},{initialTopMostItemIndex:$e,scrolledToInitialItem:Re},Ae,Ie,ke,{listState:Be,topItemsIndexes:Ne,...Fe},{scrollToIndex:Ue},We,{topItemCount:qe},{groupCounts:ze},Ge])=>(connect(Fe.rangeChanged,Ge.scrollSeekRangeChanged),connect(pipe(Ge.windowViewportRect,map$1(Ze=>Ze.visibleHeight)),Ae.viewportHeight),{totalCount:ne,data:ge,firstItemIndex:ye,sizeRanges:oe,initialTopMostItemIndex:$e,scrolledToInitialItem:Re,topItemsIndexes:Ne,topItemCount:qe,groupCounts:ze,fixedItemHeight:ce,defaultItemHeight:ue,gap:_e,...ke,statefulTotalCount:xe,listState:Be,scrollToIndex:Ue,trackItemSizes:pe,itemSize:me,groupIndices:ve,...Fe,...Ge,...Ae,sizes:Se,...Ie}),tup(sizeSystem,initialTopMostItemIndexSystem,domIOSystem,stateLoadSystem,followOutputSystem,listStateSystem,scrollToIndexSystem,upwardScrollFixSystem,topItemCountSystem,groupedListSystem,featureGroup1System)),WEBKIT_STICKY="-webkit-sticky",STICKY="sticky",positionStickyCssValue=simpleMemoize(()=>{if(typeof document>"u")return STICKY;const ne=document.createElement("div");return ne.style.position=WEBKIT_STICKY,ne.style.position===WEBKIT_STICKY?WEBKIT_STICKY:STICKY});function useWindowViewportRectRef(ne,oe){const ce=React$2.useRef(null),ue=React$2.useCallback(ye=>{if(ye===null||!ye.offsetParent)return;const ve=ye.getBoundingClientRect(),xe=ve.width;let _e,Se;if(oe){const $e=oe.getBoundingClientRect(),Re=ve.top-$e.top;_e=$e.height-Math.max(0,Re),Se=Re+oe.scrollTop}else _e=window.innerHeight-Math.max(0,ve.top),Se=ve.top+window.pageYOffset;ce.current={offsetTop:Se,visibleHeight:_e,visibleWidth:xe},ne(ce.current)},[ne,oe]),{callbackRef:pe,ref:me}=useSizeWithElRef(ue),ge=React$2.useCallback(()=>{ue(me.current)},[ue,me]);return React$2.useEffect(()=>{if(oe){oe.addEventListener("scroll",ge);const ye=new ResizeObserver(ge);return ye.observe(oe),()=>{oe.removeEventListener("scroll",ge),ye.unobserve(oe)}}else return window.addEventListener("scroll",ge),window.addEventListener("resize",ge),()=>{window.removeEventListener("scroll",ge),window.removeEventListener("resize",ge)}},[ge,oe]),pe}const VirtuosoMockContext=React$2.createContext(void 0),VirtuosoGridMockContext=React$2.createContext(void 0);function identity(ne){return ne}const listComponentPropsSystem=system(()=>{const ne=statefulStream(ve=>`Item ${ve}`),oe=statefulStream(null),ce=statefulStream(ve=>`Group ${ve}`),ue=statefulStream({}),pe=statefulStream(identity),me=statefulStream("div"),ge=statefulStream(noop$4),ye=(ve,xe=null)=>statefulStreamFromEmitter(pipe(ue,map$1(_e=>_e[ve]),distinctUntilChanged()),xe);return{context:oe,itemContent:ne,groupContent:ce,components:ue,computeItemKey:pe,headerFooterTag:me,scrollerRef:ge,FooterComponent:ye("Footer"),HeaderComponent:ye("Header"),TopItemListComponent:ye("TopItemList"),ListComponent:ye("List","div"),ItemComponent:ye("Item","div"),GroupComponent:ye("Group","div"),ScrollerComponent:ye("Scroller","div"),EmptyPlaceholder:ye("EmptyPlaceholder"),ScrollSeekPlaceholder:ye("ScrollSeekPlaceholder")}}),combinedSystem$2=system(([ne,oe])=>({...ne,...oe}),tup(listSystem,listComponentPropsSystem)),DefaultScrollSeekPlaceholder$1=({height:ne})=>React$2.createElement("div",{style:{height:ne}}),GROUP_STYLE={position:positionStickyCssValue(),zIndex:1,overflowAnchor:"none"},ITEM_STYLE$1={overflowAnchor:"none"},Items$1=React$2.memo(function({showTopList:oe=!1}){const ce=useEmitterValue$2("listState"),ue=usePublisher$2("sizeRanges"),pe=useEmitterValue$2("useWindowScroll"),me=useEmitterValue$2("customScrollParent"),ge=usePublisher$2("windowScrollContainerState"),ye=usePublisher$2("scrollContainerState"),ve=me||pe?ge:ye,xe=useEmitterValue$2("itemContent"),_e=useEmitterValue$2("context"),Se=useEmitterValue$2("groupContent"),$e=useEmitterValue$2("trackItemSizes"),Re=useEmitterValue$2("itemSize"),Ae=useEmitterValue$2("log"),Ie=usePublisher$2("gap"),{callbackRef:ke}=useChangedListContentsSizes(ue,Re,$e,oe?noop$4:ve,Ae,Ie,me),[Be,Ne]=React$2.useState(0);useEmitter$2("deviation",Ke=>{Be!==Ke&&Ne(Ke)});const Fe=useEmitterValue$2("EmptyPlaceholder"),Ue=useEmitterValue$2("ScrollSeekPlaceholder")||DefaultScrollSeekPlaceholder$1,We=useEmitterValue$2("ListComponent"),qe=useEmitterValue$2("ItemComponent"),ze=useEmitterValue$2("GroupComponent"),Ge=useEmitterValue$2("computeItemKey"),Ze=useEmitterValue$2("isSeeking"),Dt=useEmitterValue$2("groupIndices").length>0,Je=useEmitterValue$2("paddingTopAddition"),Ut=useEmitterValue$2("scrolledToInitialItem"),jt=oe?{}:{boxSizing:"border-box",paddingTop:ce.offsetTop+Je,paddingBottom:ce.offsetBottom,marginTop:Be,...Ut?{}:{visibility:"hidden"}};return!oe&&ce.totalCount===0&&Fe?React$2.createElement(Fe,contextPropIfNotDomElement(Fe,_e)):React$2.createElement(We,{...contextPropIfNotDomElement(We,_e),ref:ke,style:jt,"data-test-id":oe?"virtuoso-top-item-list":"virtuoso-item-list"},(oe?ce.topItems:ce.items).map(Ke=>{const an=Ke.originalIndex,Zt=Ge(an+ce.firstItemIndex,Ke.data,_e);return Ze?React$2.createElement(Ue,{...contextPropIfNotDomElement(Ue,_e),key:Zt,index:Ke.index,height:Ke.size,type:Ke.type||"item",...Ke.type==="group"?{}:{groupIndex:Ke.groupIndex}}):Ke.type==="group"?React$2.createElement(ze,{...contextPropIfNotDomElement(ze,_e),key:Zt,"data-index":an,"data-known-size":Ke.size,"data-item-index":Ke.index,style:GROUP_STYLE},Se(Ke.index,_e)):React$2.createElement(qe,{...contextPropIfNotDomElement(qe,_e),...itemPropIfNotDomElement(qe,Ke.data),key:Zt,"data-index":an,"data-known-size":Ke.size,"data-item-index":Ke.index,"data-item-group-index":Ke.groupIndex,style:ITEM_STYLE$1},Dt?xe(Ke.index,Ke.groupIndex,Ke.data,_e):xe(Ke.index,Ke.data,_e))}))}),scrollerStyle={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},viewportStyle={width:"100%",height:"100%",position:"absolute",top:0},topItemListStyle={width:"100%",position:positionStickyCssValue(),top:0,zIndex:1};function contextPropIfNotDomElement(ne,oe){if(typeof ne!="string")return{context:oe}}function itemPropIfNotDomElement(ne,oe){return{item:typeof ne=="string"?void 0:oe}}const Header$1=React$2.memo(function(){const oe=useEmitterValue$2("HeaderComponent"),ce=usePublisher$2("headerHeight"),ue=useEmitterValue$2("headerFooterTag"),pe=useSize(ge=>ce(correctItemSize(ge,"height"))),me=useEmitterValue$2("context");return oe?React$2.createElement(ue,{ref:pe},React$2.createElement(oe,contextPropIfNotDomElement(oe,me))):null}),Footer$1=React$2.memo(function(){const oe=useEmitterValue$2("FooterComponent"),ce=usePublisher$2("footerHeight"),ue=useEmitterValue$2("headerFooterTag"),pe=useSize(ge=>ce(correctItemSize(ge,"height"))),me=useEmitterValue$2("context");return oe?React$2.createElement(ue,{ref:pe},React$2.createElement(oe,contextPropIfNotDomElement(oe,me))):null});function buildScroller({usePublisher:ne,useEmitter:oe,useEmitterValue:ce}){return React$2.memo(function({style:me,children:ge,...ye}){const ve=ne("scrollContainerState"),xe=ce("ScrollerComponent"),_e=ne("smoothScrollTargetReached"),Se=ce("scrollerRef"),$e=ce("context"),{scrollerRef:Re,scrollByCallback:Ae,scrollToCallback:Ie}=useScrollTop(ve,_e,xe,Se);return oe("scrollTo",Ie),oe("scrollBy",Ae),React$2.createElement(xe,{ref:Re,style:{...scrollerStyle,...me},"data-test-id":"virtuoso-scroller","data-virtuoso-scroller":!0,tabIndex:0,...ye,...contextPropIfNotDomElement(xe,$e)},ge)})}function buildWindowScroller({usePublisher:ne,useEmitter:oe,useEmitterValue:ce}){return React$2.memo(function({style:me,children:ge,...ye}){const ve=ne("windowScrollContainerState"),xe=ce("ScrollerComponent"),_e=ne("smoothScrollTargetReached"),Se=ce("totalListHeight"),$e=ce("deviation"),Re=ce("customScrollParent"),Ae=ce("context"),{scrollerRef:Ie,scrollByCallback:ke,scrollToCallback:Be}=useScrollTop(ve,_e,xe,noop$4,Re);return useIsomorphicLayoutEffect$1(()=>(Ie.current=Re||window,()=>{Ie.current=null}),[Ie,Re]),oe("windowScrollTo",Be),oe("scrollBy",ke),React$2.createElement(xe,{style:{position:"relative",...me,...Se!==0?{height:Se+$e}:{}},"data-virtuoso-scroller":!0,...ye,...contextPropIfNotDomElement(xe,Ae)},ge)})}const Viewport$2=({children:ne})=>{const oe=React$2.useContext(VirtuosoMockContext),ce=usePublisher$2("viewportHeight"),ue=usePublisher$2("fixedItemHeight"),pe=useSize(compose(ce,me=>correctItemSize(me,"height")));return React$2.useEffect(()=>{oe&&(ce(oe.viewportHeight),ue(oe.itemHeight))},[oe,ce,ue]),React$2.createElement("div",{style:viewportStyle,ref:pe,"data-viewport-type":"element"},ne)},WindowViewport$2=({children:ne})=>{const oe=React$2.useContext(VirtuosoMockContext),ce=usePublisher$2("windowViewportRect"),ue=usePublisher$2("fixedItemHeight"),pe=useEmitterValue$2("customScrollParent"),me=useWindowViewportRectRef(ce,pe);return React$2.useEffect(()=>{oe&&(ue(oe.itemHeight),ce({offsetTop:0,visibleHeight:oe.viewportHeight,visibleWidth:100}))},[oe,ce,ue]),React$2.createElement("div",{ref:me,style:viewportStyle,"data-viewport-type":"window"},ne)},TopItemListContainer=({children:ne})=>{const oe=useEmitterValue$2("TopItemListComponent")||"div",ce=useEmitterValue$2("headerHeight"),ue={...topItemListStyle,marginTop:`${ce}px`},pe=useEmitterValue$2("context");return React$2.createElement(oe,{style:ue,...contextPropIfNotDomElement(oe,pe)},ne)},ListRoot=React$2.memo(function(oe){const ce=useEmitterValue$2("useWindowScroll"),ue=useEmitterValue$2("topItemsIndexes").length>0,pe=useEmitterValue$2("customScrollParent"),me=pe||ce?WindowScroller$2:Scroller$2,ge=pe||ce?WindowViewport$2:Viewport$2;return React$2.createElement(me,{...oe},ue&&React$2.createElement(TopItemListContainer,null,React$2.createElement(Items$1,{showTopList:!0})),React$2.createElement(ge,null,React$2.createElement(Header$1,null),React$2.createElement(Items$1,null),React$2.createElement(Footer$1,null)))}),{Component:List,usePublisher:usePublisher$2,useEmitterValue:useEmitterValue$2,useEmitter:useEmitter$2}=systemToComponent(combinedSystem$2,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},ListRoot),Scroller$2=buildScroller({usePublisher:usePublisher$2,useEmitterValue:useEmitterValue$2,useEmitter:useEmitter$2}),WindowScroller$2=buildWindowScroller({usePublisher:usePublisher$2,useEmitterValue:useEmitterValue$2,useEmitter:useEmitter$2}),Virtuoso=List,INITIAL_GRID_STATE={items:[],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},PROBE_GRID_STATE={items:[{index:0}],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},{round,ceil,floor,min,max}=Math;function buildProbeGridState(ne){return{...PROBE_GRID_STATE,items:ne}}function buildItems(ne,oe,ce){return Array.from({length:oe-ne+1}).map((ue,pe)=>{const me=ce===null?null:ce[pe+ne];return{index:pe+ne,data:me}})}function gapComparator(ne,oe){return ne&&ne.column===oe.column&&ne.row===oe.row}function dimensionComparator(ne,oe){return ne&&ne.width===oe.width&&ne.height===oe.height}const gridSystem=system(([{overscan:ne,visibleRange:oe,listBoundary:ce},{scrollTop:ue,viewportHeight:pe,scrollBy:me,scrollTo:ge,smoothScrollTargetReached:ye,scrollContainerState:ve,footerHeight:xe,headerHeight:_e},Se,$e,{propsReady:Re,didMount:Ae},{windowViewportRect:Ie,useWindowScroll:ke,customScrollParent:Be,windowScrollContainerState:Ne,windowScrollTo:Fe},Ue])=>{const We=statefulStream(0),qe=statefulStream(0),ze=statefulStream(INITIAL_GRID_STATE),Ge=statefulStream({height:0,width:0}),Ze=statefulStream({height:0,width:0}),Dt=stream(),Je=stream(),Ut=statefulStream(0),jt=statefulStream(null),Ke=statefulStream({row:0,column:0}),an=stream(),Zt=stream(),en=statefulStream(!1),Kt=statefulStream(0),Wt=statefulStream(!0),un=statefulStream(!1);subscribe(pipe(Ae,withLatestFrom(Kt),filter(([Nt,Yt])=>!!Yt)),()=>{publish(Wt,!1),publish(qe,0)}),subscribe(pipe(combineLatest(Ae,Wt,Ze,Ge,Kt,un),filter(([Nt,Yt,Jt,hn,,Ye])=>Nt&&!Yt&&Jt.height!==0&&hn.height!==0&&!Ye)),([,,,,Nt])=>{publish(un,!0),skipFrames(1,()=>{publish(Dt,Nt)}),handleNext(pipe(ue),()=>{publish(ce,[0,0]),publish(Wt,!0)})}),connect(pipe(Zt,filter(Nt=>Nt!=null&&Nt.scrollTop>0),mapTo(0)),qe),subscribe(pipe(Ae,withLatestFrom(Zt),filter(([,Nt])=>Nt!=null)),([,Nt])=>{Nt&&(publish(Ge,Nt.viewport),publish(Ze,Nt==null?void 0:Nt.item),publish(Ke,Nt.gap),Nt.scrollTop>0&&(publish(en,!0),handleNext(pipe(ue,skip(1)),Yt=>{publish(en,!1)}),publish(ge,{top:Nt.scrollTop})))}),connect(pipe(Ge,map$1(({height:Nt})=>Nt)),pe),connect(pipe(combineLatest(duc(Ge,dimensionComparator),duc(Ze,dimensionComparator),duc(Ke,(Nt,Yt)=>Nt&&Nt.column===Yt.column&&Nt.row===Yt.row),duc(ue)),map$1(([Nt,Yt,Jt,hn])=>({viewport:Nt,item:Yt,gap:Jt,scrollTop:hn}))),an),connect(pipe(combineLatest(duc(We),oe,duc(Ke,gapComparator),duc(Ze,dimensionComparator),duc(Ge,dimensionComparator),duc(jt),duc(qe),duc(en),duc(Wt),duc(Kt)),filter(([,,,,,,,Nt])=>!Nt),map$1(([Nt,[Yt,Jt],hn,Ye,Xe,Pt,sn,,yn,qt])=>{const{row:wn,column:Tn}=hn,{height:xn,width:Nn}=Ye,{width:zn}=Xe;if(sn===0&&(Nt===0||zn===0))return INITIAL_GRID_STATE;if(Nn===0){const bn=getInitialTopMostItemIndexNumber(qt,Nt),kn=bn===0?Math.max(sn-1,0):bn;return buildProbeGridState(buildItems(bn,kn,Pt))}const Yn=itemsPerRow(zn,Nn,Tn);let Kn,Rn;yn?Yt===0&&Jt===0&&sn>0?(Kn=0,Rn=sn-1):(Kn=Yn*floor((Yt+wn)/(xn+wn)),Rn=Yn*ceil((Jt+wn)/(xn+wn))-1,Rn=min(Nt-1,max(Rn,Yn-1)),Kn=min(Rn,max(0,Kn))):(Kn=0,Rn=-1);const Mn=buildItems(Kn,Rn,Pt),{top:Xn,bottom:Jn}=gridLayout(Xe,hn,Ye,Mn),pn=ceil(Nt/Yn),Gt=pn*xn+(pn-1)*wn-Jn;return{items:Mn,offsetTop:Xn,offsetBottom:Gt,top:Xn,bottom:Jn,itemHeight:xn,itemWidth:Nn}})),ze),connect(pipe(jt,filter(Nt=>Nt!==null),map$1(Nt=>Nt.length)),We),connect(pipe(combineLatest(Ge,Ze,ze,Ke),filter(([Nt,Yt,{items:Jt}])=>Jt.length>0&&Yt.height!==0&&Nt.height!==0),map$1(([Nt,Yt,{items:Jt},hn])=>{const{top:Ye,bottom:Xe}=gridLayout(Nt,hn,Yt,Jt);return[Ye,Xe]}),distinctUntilChanged(tupleComparator)),ce);const Xt=statefulStream(!1);connect(pipe(ue,withLatestFrom(Xt),map$1(([Nt,Yt])=>Yt||Nt!==0)),Xt);const nn=streamFromEmitter(pipe(duc(ze),filter(({items:Nt})=>Nt.length>0),withLatestFrom(We,Xt),filter(([{items:Nt},Yt,Jt])=>Jt&&Nt[Nt.length-1].index===Yt-1),map$1(([,Nt])=>Nt-1),distinctUntilChanged())),vn=streamFromEmitter(pipe(duc(ze),filter(({items:Nt})=>Nt.length>0&&Nt[0].index===0),mapTo(0),distinctUntilChanged())),Sn=streamFromEmitter(pipe(duc(ze),withLatestFrom(en),filter(([{items:Nt},Yt])=>Nt.length>0&&!Yt),map$1(([{items:Nt}])=>({startIndex:Nt[0].index,endIndex:Nt[Nt.length-1].index})),distinctUntilChanged(rangeComparator),throttleTime(0)));connect(Sn,$e.scrollSeekRangeChanged),connect(pipe(Dt,withLatestFrom(Ge,Ze,We,Ke),map$1(([Nt,Yt,Jt,hn,Ye])=>{const Xe=normalizeIndexLocation(Nt),{align:Pt,behavior:sn,offset:yn}=Xe;let qt=Xe.index;qt==="LAST"&&(qt=hn-1),qt=max(0,qt,min(hn-1,qt));let wn=itemTop(Yt,Ye,Jt,qt);return Pt==="end"?wn=round(wn-Yt.height+Jt.height):Pt==="center"&&(wn=round(wn-Yt.height/2+Jt.height/2)),yn&&(wn+=yn),{top:wn,behavior:sn}})),ge);const Cn=statefulStreamFromEmitter(pipe(ze,map$1(Nt=>Nt.offsetBottom+Nt.bottom)),0);return connect(pipe(Ie,map$1(Nt=>({width:Nt.visibleWidth,height:Nt.visibleHeight}))),Ge),{data:jt,totalCount:We,viewportDimensions:Ge,itemDimensions:Ze,scrollTop:ue,scrollHeight:Je,overscan:ne,scrollBy:me,scrollTo:ge,scrollToIndex:Dt,smoothScrollTargetReached:ye,windowViewportRect:Ie,windowScrollTo:Fe,useWindowScroll:ke,customScrollParent:Be,windowScrollContainerState:Ne,deviation:Ut,scrollContainerState:ve,footerHeight:xe,headerHeight:_e,initialItemCount:qe,gap:Ke,restoreStateFrom:Zt,...$e,initialTopMostItemIndex:Kt,gridState:ze,totalListHeight:Cn,...Se,startReached:vn,endReached:nn,rangeChanged:Sn,stateChanged:an,propsReady:Re,stateRestoreInProgress:en,...Ue}},tup(sizeRangeSystem,domIOSystem,stateFlagsSystem,scrollSeekSystem,propsReadySystem,windowScrollerSystem,loggerSystem));function gridLayout(ne,oe,ce,ue){const{height:pe}=ce;if(pe===void 0||ue.length===0)return{top:0,bottom:0};const me=itemTop(ne,oe,ce,ue[0].index),ge=itemTop(ne,oe,ce,ue[ue.length-1].index)+pe;return{top:me,bottom:ge}}function itemTop(ne,oe,ce,ue){const pe=itemsPerRow(ne.width,ce.width,oe.column),me=floor(ue/pe),ge=me*ce.height+max(0,me-1)*oe.row;return ge>0?ge+oe.row:ge}function itemsPerRow(ne,oe,ce){return max(1,floor((ne+ce)/(floor(oe)+ce)))}const gridComponentPropsSystem=system(()=>{const ne=statefulStream(xe=>`Item ${xe}`),oe=statefulStream({}),ce=statefulStream(null),ue=statefulStream("virtuoso-grid-item"),pe=statefulStream("virtuoso-grid-list"),me=statefulStream(identity),ge=statefulStream("div"),ye=statefulStream(noop$4),ve=(xe,_e=null)=>statefulStreamFromEmitter(pipe(oe,map$1(Se=>Se[xe]),distinctUntilChanged()),_e);return{context:ce,itemContent:ne,components:oe,computeItemKey:me,itemClassName:ue,listClassName:pe,headerFooterTag:ge,scrollerRef:ye,FooterComponent:ve("Footer"),HeaderComponent:ve("Header"),ListComponent:ve("List","div"),ItemComponent:ve("Item","div"),ScrollerComponent:ve("Scroller","div"),ScrollSeekPlaceholder:ve("ScrollSeekPlaceholder","div")}}),combinedSystem$1=system(([ne,oe])=>({...ne,...oe}),tup(gridSystem,gridComponentPropsSystem)),GridItems=React$2.memo(function(){const oe=useEmitterValue$1("gridState"),ce=useEmitterValue$1("listClassName"),ue=useEmitterValue$1("itemClassName"),pe=useEmitterValue$1("itemContent"),me=useEmitterValue$1("computeItemKey"),ge=useEmitterValue$1("isSeeking"),ye=usePublisher$1("scrollHeight"),ve=useEmitterValue$1("ItemComponent"),xe=useEmitterValue$1("ListComponent"),_e=useEmitterValue$1("ScrollSeekPlaceholder"),Se=useEmitterValue$1("context"),$e=usePublisher$1("itemDimensions"),Re=usePublisher$1("gap"),Ae=useEmitterValue$1("log"),Ie=useEmitterValue$1("stateRestoreInProgress"),ke=useSize(Be=>{const Ne=Be.parentElement.parentElement.scrollHeight;ye(Ne);const Fe=Be.firstChild;if(Fe){const{width:Ue,height:We}=Fe.getBoundingClientRect();$e({width:Ue,height:We})}Re({row:resolveGapValue("row-gap",getComputedStyle(Be).rowGap,Ae),column:resolveGapValue("column-gap",getComputedStyle(Be).columnGap,Ae)})});return Ie?null:React$2.createElement(xe,{ref:ke,className:ce,...contextPropIfNotDomElement(xe,Se),style:{paddingTop:oe.offsetTop,paddingBottom:oe.offsetBottom},"data-test-id":"virtuoso-item-list"},oe.items.map(Be=>{const Ne=me(Be.index,Be.data,Se);return ge?React$2.createElement(_e,{key:Ne,...contextPropIfNotDomElement(_e,Se),index:Be.index,height:oe.itemHeight,width:oe.itemWidth}):React$2.createElement(ve,{...contextPropIfNotDomElement(ve,Se),className:ue,"data-index":Be.index,key:Ne},pe(Be.index,Be.data,Se))}))}),Header=React$2.memo(function(){const oe=useEmitterValue$1("HeaderComponent"),ce=usePublisher$1("headerHeight"),ue=useEmitterValue$1("headerFooterTag"),pe=useSize(ge=>ce(correctItemSize(ge,"height"))),me=useEmitterValue$1("context");return oe?React$2.createElement(ue,{ref:pe},React$2.createElement(oe,contextPropIfNotDomElement(oe,me))):null}),Footer=React$2.memo(function(){const oe=useEmitterValue$1("FooterComponent"),ce=usePublisher$1("footerHeight"),ue=useEmitterValue$1("headerFooterTag"),pe=useSize(ge=>ce(correctItemSize(ge,"height"))),me=useEmitterValue$1("context");return oe?React$2.createElement(ue,{ref:pe},React$2.createElement(oe,contextPropIfNotDomElement(oe,me))):null}),Viewport$1=({children:ne})=>{const oe=React$2.useContext(VirtuosoGridMockContext),ce=usePublisher$1("itemDimensions"),ue=usePublisher$1("viewportDimensions"),pe=useSize(me=>{ue(me.getBoundingClientRect())});return React$2.useEffect(()=>{oe&&(ue({height:oe.viewportHeight,width:oe.viewportWidth}),ce({height:oe.itemHeight,width:oe.itemWidth}))},[oe,ue,ce]),React$2.createElement("div",{style:viewportStyle,ref:pe},ne)},WindowViewport$1=({children:ne})=>{const oe=React$2.useContext(VirtuosoGridMockContext),ce=usePublisher$1("windowViewportRect"),ue=usePublisher$1("itemDimensions"),pe=useEmitterValue$1("customScrollParent"),me=useWindowViewportRectRef(ce,pe);return React$2.useEffect(()=>{oe&&(ue({height:oe.itemHeight,width:oe.itemWidth}),ce({offsetTop:0,visibleHeight:oe.viewportHeight,visibleWidth:oe.viewportWidth}))},[oe,ce,ue]),React$2.createElement("div",{ref:me,style:viewportStyle},ne)},GridRoot=React$2.memo(function({...oe}){const ce=useEmitterValue$1("useWindowScroll"),ue=useEmitterValue$1("customScrollParent"),pe=ue||ce?WindowScroller$1:Scroller$1,me=ue||ce?WindowViewport$1:Viewport$1;return React$2.createElement(pe,{...oe},React$2.createElement(me,null,React$2.createElement(Header,null),React$2.createElement(GridItems,null),React$2.createElement(Footer,null)))}),{Component:Grid,usePublisher:usePublisher$1,useEmitterValue:useEmitterValue$1,useEmitter:useEmitter$1}=systemToComponent(combinedSystem$1,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged"}},GridRoot),Scroller$1=buildScroller({usePublisher:usePublisher$1,useEmitterValue:useEmitterValue$1,useEmitter:useEmitter$1}),WindowScroller$1=buildWindowScroller({usePublisher:usePublisher$1,useEmitterValue:useEmitterValue$1,useEmitter:useEmitter$1});function resolveGapValue(ne,oe,ce){return oe!=="normal"&&!(oe!=null&&oe.endsWith("px"))&&ce(`${ne} was not resolved to pixel value correctly`,oe,LogLevel.WARN),oe==="normal"?0:parseInt(oe??"0",10)}const Scroller=reactExports.forwardRef(({style:ne,children:oe,...ce},ue)=>{const pe=reactExports.useRef(null),{palette:me,spacing:ge}=useTheme$1(),ye=useCss$1({"--os-padding-perpendicular":"2px",".os-scrollbar":{visibility:"visible",opacity:1},".os-scrollbar-vertical > .os-scrollbar-track > .os-scrollbar-handle":{"min-height":ge(12)},"div.os-scrollbar-vertical > div.os-scrollbar-track":{height:`calc(100% - ${ge(6)})`,marginTop:ge(6)},"div > div.os-scrollbar-track":{"--os-handle-perpendicular-size":"2px","--os-handle-perpendicular-size-hover":"6px","--os-handle-perpendicular-size-active":"6px","> div.os-scrollbar-handle":{borderRadius:0,opacity:.5,"&:hover":{opacity:.8}}}}),[ve]=S$5({options:{overflow:{x:"hidden",y:"scroll"},scrollbars:{autoHide:"move",theme:me.mode==="dark"?"os-theme-light":"os-theme-dark"}}});reactExports.useEffect(()=>{typeof ue!="function"&&(ue!=null&&ue.current)&&(pe!=null&&pe.current)&&ve({target:pe.current,elements:{viewport:ue.current}})},[ve]);const xe=reactExports.useCallback(_e=>{_e&&ue&&(typeof ue=="function"?ue(_e):ue.current=_e)},[ue]);return jsxRuntimeExports.jsx("div",{ref:pe,style:ne,className:ye,children:jsxRuntimeExports.jsx("div",{ref:xe,...ce,children:oe})})});function LazyList({items:ne=[],renderItem:oe,listOptions:ce,placeholder:ue,...pe}){return jsxRuntimeExports.jsx(Box$1,{...pe,children:jsxRuntimeExports.jsx(Virtuoso,{components:{Scroller},totalCount:ne.length,itemContent:me=>oe==null?void 0:oe(ne[me],me),...ce})})}function Dot({label:ne}){return jsxRuntimeExports.jsx(Tooltip$1,{title:ne,children:jsxRuntimeExports.jsx(FiberManualRecord,{sx:{color:"error.main",transform:"scale(0.5)",pl:.5,mr:2},fontSize:"small"})})}function EventInspector({event:ne,index:oe,selected:ce,label:ue,...pe}){const{spacing:me}=useTheme$1(),ge=useCss$1({}),ye=useCss$1({}),ve=lodashExports$1.omit(ne,...OMIT_PROPS),xe=lodashExports$1.pick(ve,...ESSENTIAL_PROPS),_e=lodashExports$1.omit(ve,...ESSENTIAL_PROPS);return jsxRuntimeExports.jsxs(Box$1,{sx:{position:"relative",[`> .${ye}`]:{opacity:0},[`&:hover > .${ye}`]:{opacity:1},[`&:hover > .${ge}`]:{pr:8}},children:[jsxRuntimeExports.jsxs(ListItemButton$1,{className:ge,selected:ce,...pe,sx:{height:80,borderLeft:`${me(.5)} solid ${getColorHex(ne==null?void 0:ne.type)}`,...pe.sx},children:[jsxRuntimeExports.jsxs(ListItemIcon$1,{sx:{alignItems:"center"},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"body2",children:oe}),ue&&jsxRuntimeExports.jsx(Dot,{label:ue})]}),jsxRuntimeExports.jsx(ListItemText$1,{sx:{overflow:"hidden"},primary:jsxRuntimeExports.jsxs(Box$1,{sx:{overflow:"hidden",whiteSpace:"nowrap",display:"block",textOverflow:"ellipsis",my:.5},children:[lodashExports$1.startCase((ne==null?void 0:ne.type)??"event")," ",(ne==null?void 0:ne.id)??"-"]}),secondaryTypographyProps:{component:"div",whiteSpace:"nowrap",overflow:"hidden"},secondary:jsxRuntimeExports.jsxs(Stack$1,{direction:"row",justifyContent:"flex-start",sx:{"> *":{flex:0}},children:[jsxRuntimeExports.jsx(PropertyList,{event:xe,simple:!0}),jsxRuntimeExports.jsx(PropertyList,{event:_e,simple:!0})]})})]}),jsxRuntimeExports.jsx(Stack$1,{className:ye,direction:"row",sx:{p:1,justifyContent:"center",position:"absolute",right:0,alignItems:"center",top:0,height:"100%"},children:jsxRuntimeExports.jsx(PropertyDialog,{event:ne,trigger:Se=>jsxRuntimeExports.jsx(IconButtonWithTooltip,{onClick:Se,sx:{p:1.5,color:"text.secondary"},label:"See All Properties",icon:jsxRuntimeExports.jsx(DataObjectOutlined,{fontSize:"small"})})})})]})}function Skeleton({event:ne}){const{spacing:oe}=useTheme$1();return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ListItem$1,{sx:{height:80,borderLeft:`${oe(.5)} solid ${getColorHex(ne==null?void 0:ne.type)}`},children:jsxRuntimeExports.jsx(ListItemIcon$1,{children:jsxRuntimeExports.jsx(Placeholder$3,{animation:!1,width:oe(4)})})}),jsxRuntimeExports.jsx(Divider$1,{variant:"inset"})]})}function lerp(ne,oe,ce){return ne+lodashExports$1.clamp(ce,0,1)*(oe-ne)}const ITEM_HEIGHT=80,PADDING_TOP=8,divider$2=jsxRuntimeExports.jsx(Divider$1,{orientation:"vertical",flexItem:!0,sx:{m:1}}),pxToInt=ne=>Number(ne.replace(/px$/,"")),SYMBOL_ALL=nanoid$1(),stepsLayerGuard=ne=>!!getController(ne).steps;function useStepsPageState(ne,oe){const{key:ce,setKey:ue,layers:pe,layer:me,allLayers:ge}=useLayer(ne==null?void 0:ne.layer,stepsLayerGuard),[ye,ve]=reactExports.useState(ne==null?void 0:ne.selectedType);function xe(Se){oe==null||oe({layer:Se}),ue(Se)}function _e(Se){oe==null||oe({selectedType:Se}),ve(Se)}return{setSelectedType:_e,setKey:xe,selectedType:ye,layers:pe,allLayers:ge,key:ce,layer:me}}const getStepsPageDescription=ne=>ne?`${ne} contains 0 steps.`:"When you load a trace, you'll see its steps here.";function StepsPage({template:ne}){const{spacing:oe}=useTheme$1(),ce=usePaper(),ue=useAcrylic(),pe=reactExports.useRef(null),[me,ge]=reactExports.useState(null),{controls:ye,onChange:ve,state:xe,dragHandle:_e}=useViewTreeContext(),{allLayers:Se,key:$e,layers:Re,selectedType:Ae,setKey:Ie,setSelectedType:ke,layer:Be}=useStepsPageState(xe,ve),{step:Ne,playing:Fe,stepTo:Ue}=usePlaybackState($e),We=reactExports.useMemo(()=>{if(Be){const{steps:Je}=getController(Be);return Je(Be)}},[Be]),{steps:qe,types:ze,stepToFilteredStep:Ge,selectedType:Ze}=reactExports.useMemo(()=>{if(We){const Je=We.map((Zt,en)=>[Zt,en]),Ut=lodashExports$1.chain(Je).map(([Zt])=>Zt.type).filter().uniq().value(),jt=!Ut.includes(Ae),Ke=jt?Je:Je.filter(([Zt])=>Zt.type===Ae),{stepMap:an}=lodashExports$1.reduce(Je,(Zt,[,en])=>{const Kt=lodashExports$1.findIndex(Ke,([,un])=>un>=en,Zt.from),Wt=Kt===-1?Ke.length:Kt;return Zt.from=Wt,Zt.stepMap.push(Wt),Zt},{from:0,stepMap:[]});return{steps:Ke,types:Ut,stepToFilteredStep:Zt=>an[Zt],selectedType:jt?SYMBOL_ALL:Ae}}return{}},[We,Ae]),Dt=useBreakpoints($e);return reactExports.useEffect(()=>{if(Ge&&me&&pe.current){const Je=Ge(Ne);if(Fe){let Ut=!1;const jt=Ke=>{var an;if(!Ut&&"scrollTop"in me&&!lodashExports$1.isUndefined(Ne)){const{scrollTop:Zt}=me,en=Je*ITEM_HEIGHT;(an=pe.current)==null||an.scrollTo({top:lerp(Zt,en,1e-6*Ke)}),requestAnimationFrame(jt)}};return requestAnimationFrame(jt),()=>{Ut=!0}}else pe.current.scrollToIndex({index:Je,behavior:"smooth",offset:-pxToInt(oe(12+PADDING_TOP))})}},[Ne,pe,me,Ge,Fe]),jsxRuntimeExports.jsxs(ne,{onChange:ve,stack:xe,children:[jsxRuntimeExports.jsx(ne.Title,{children:"Steps"}),jsxRuntimeExports.jsx(ne.Handle,{children:_e}),jsxRuntimeExports.jsxs(ne.Content,{children:[jsxRuntimeExports.jsx(Flex,{vertical:!0,alignItems:"center",children:qe?qe.length?jsxRuntimeExports.jsx(LazyList,{sx:{width:"100%",height:"100%"},items:qe,listOptions:{scrollerRef:ge,ref:pe,defaultItemHeight:ITEM_HEIGHT,overscan:0},renderItem:([Je,Ut],jt)=>{var Ke;return Fe?jsxRuntimeExports.jsx(Box$1,{sx:{pt:jt?0:oe(6+PADDING_TOP)},children:jsxRuntimeExports.jsx(Skeleton,{event:Je})},jt):jsxRuntimeExports.jsxs(Box$1,{sx:{height:pxToInt(oe(jt?0:6+PADDING_TOP))+ITEM_HEIGHT,pt:jt?0:oe(6+PADDING_TOP)},children:[jsxRuntimeExports.jsx(EventInspector,{event:Je,index:Ut,selected:Ut===Ne,label:(Ke=Dt(Ut))==null?void 0:Ke.result,onClick:()=>Ue(Ut)}),jsxRuntimeExports.jsx(Divider$1,{variant:"inset"})]},jt)}}):jsxRuntimeExports.jsx(Placeholder$2,{icon:jsxRuntimeExports.jsx(StepsIcon,{}),label:"Events",secondary:getStepsPageDescription(inferLayerName(Be))}):jsxRuntimeExports.jsx(Placeholder$2,{icon:jsxRuntimeExports.jsx(StepsIcon,{}),label:"Events",secondary:getStepsPageDescription()})}),!!(qe!=null&&qe.length)&&jsxRuntimeExports.jsx(Stack$1,{direction:"row",sx:{...ce(1),...ue,alignItems:"center",position:"absolute",top:Je=>Je.spacing(6),height:Je=>Je.spacing(6),borderRadius:1,px:1,m:1},children:jsxRuntimeExports.jsx(Playback,{layer:Be})})]}),jsxRuntimeExports.jsxs(ne.Options,{children:[jsxRuntimeExports.jsx(FeaturePicker,{icon:jsxRuntimeExports.jsx(LayersIcon,{}),label:"Layer",value:$e,items:lodashExports$1.map(Se,Je=>({id:Je.key,hidden:!lodashExports$1.find(Re,{key:Je.key}),name:inferLayerName(Je)})),onChange:Ie,arrow:!0,ellipsis:12}),divider$2,jsxRuntimeExports.jsx(FeaturePicker,{icon:jsxRuntimeExports.jsx(FiberManualRecordOutlined,{sx:{color:Ze===SYMBOL_ALL||!Ze?grey$1[tint]:getColorHex(Ze)}}),label:"Event Type",value:Ze,items:[{id:SYMBOL_ALL,name:"All Events"},...lodashExports$1.map(ze,Je=>({id:`${Je}`,name:lodashExports$1.startCase(Je)}))],onChange:ke,arrow:!0,ellipsis:12})]}),jsxRuntimeExports.jsx(ne.Extras,{children:ye})]})}function SelectMulti({trigger:ne,items:oe,value:ce,onChange:ue,placeholder:pe="Select Options",defaultChecked:me}){return useSmallDisplay(),lodashExports$1.max([lodashExports$1.findIndex(oe,({value:ge})=>!!(ce!=null&&ce[ge])),0]),jsxRuntimeExports.jsx(PopupState,{variant:"popover",children:ge=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Tooltip$1,{title:pe,children:jsxRuntimeExports.jsx("span",{children:ne==null?void 0:ne(bindTrigger(ge))})}),jsxRuntimeExports.jsx(Menu$1,{...bindMenu(ge),anchorOrigin:{horizontal:"left",vertical:"bottom"},transformOrigin:{vertical:"top",horizontal:"left"},children:lodashExports$1.map(oe,({value:ye,label:ve,disabled:xe})=>jsxRuntimeExports.jsxs(MenuItem$1,{disabled:xe,onClick:()=>{ue==null||ue({...ce,[ye]:!((ce==null?void 0:ce[ye])??me)})},children:[jsxRuntimeExports.jsx(ListItemIcon$1,{children:jsxRuntimeExports.jsx(Checkbox$1,{sx:{p:0},checked:!!((ce==null?void 0:ce[ye])??me)})}),ve]},ye))})]})})}function FeaturePickerMulti({label:ne,value:oe,onChange:ce,items:ue,icon:pe,showArrow:me,defaultChecked:ge,ellipsis:ye=1/0}){var _e;const ve=lodashExports$1.filter(ue,({id:Se})=>!!((oe==null?void 0:oe[Se])??ge)),xe=ve.length?ve.length===1?(_e=lodashExports$1.head(ve))==null?void 0:_e.name:`${ve.length} Selected`:ne;return jsxRuntimeExports.jsx(SelectMulti,{defaultChecked:!0,placeholder:lodashExports$1.startCase(ne),trigger:Se=>jsxRuntimeExports.jsx(FeaturePickerButton,{...Se,disabled:!(ue!=null&&ue.length),icon:pe,arrow:me,children:lodashExports$1.truncate(xe,{length:ye})}),items:lodashExports$1.map(ue,({id:Se,name:$e,description:Re,hidden:Ae})=>({value:Se,label:jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Type$2,{component:"div",children:$e}),jsxRuntimeExports.jsx(Space,{}),jsxRuntimeExports.jsx(Type$2,{component:"div",variant:"body2",color:"text.secondary",children:Re})]}),disabled:Ae})),value:oe,onChange:ce})}function useRendererResolver(ne){var ue,pe;const[oe]=useRenderers(),ce=reactExports.useMemo(()=>lodashExports$1.head(oe),[oe]);return{auto:ce,selected:ne&&ne!=="internal:auto"?ne:(pe=(ue=ce==null?void 0:ce.renderer)==null?void 0:ue.meta)==null?void 0:pe.id}}const divider$1=jsxRuntimeExports.jsx(Divider$1,{orientation:"vertical",flexItem:!0,sx:{m:1}});function ViewportPage({template:ne}){var ke,Be;const{controls:oe,onChange:ce,state:ue,dragHandle:pe}=useViewTreeContext(),[me]=useRenderers(),ge=usePaper(),ye=useAcrylic(),[{layers:ve}]=useLayers(),[xe,_e]=reactExports.useState({}),Se=reactExports.useMemo(()=>lodashExports$1.filter(ve,Ne=>(xe==null?void 0:xe[Ne.key])??!0),[xe,ve,ve==null?void 0:ve.length]),[$e,Re]=reactExports.useState(),{selected:Ae,auto:Ie}=useRendererResolver(ue==null?void 0:ue.renderer);return reactExports.useEffect(()=>{lodashExports$1.delay(()=>{var Ne;(Ne=$e==null?void 0:$e.fitCamera)==null||Ne.call($e,Fe=>{var Ue;return lodashExports$1.chain(Se).filter("viewKey").map("key").includes(((Ue=Fe.meta)==null?void 0:Ue.sourceLayer)??"").value()})},150)},[$e,lodashExports$1.chain(Se).map("viewKey").sort().join(".").value()]),jsxRuntimeExports.jsxs(ne,{onChange:ce,stack:ue,children:[jsxRuntimeExports.jsx(ne.Key,{children:"viewport"}),jsxRuntimeExports.jsx(ne.Title,{children:"Viewport"}),jsxRuntimeExports.jsx(ne.Handle,{children:pe}),jsxRuntimeExports.jsx(ne.Content,{children:jsxRuntimeExports.jsx(Flex,{children:jsxRuntimeExports.jsx(AutoSizer,{children:Ne=>jsxRuntimeExports.jsxs(Box$1,{children:[jsxRuntimeExports.jsx(TraceRenderer,{...Ne,layers:Se,renderer:Ae,rendererRef:Re}),jsxRuntimeExports.jsx(Stack$1,{sx:{pt:6,position:"absolute",top:0,left:0},children:jsxRuntimeExports.jsxs(Stack$1,{direction:"row",sx:{...ge(1),...ye,alignItems:"center",height:Fe=>Fe.spacing(6),px:1,m:1},children:[jsxRuntimeExports.jsx(IconButtonWithTooltip,{color:"primary",disabled:!$e,onClick:()=>{$e==null||$e.fitCamera()},label:"Fit",icon:jsxRuntimeExports.jsx(CenterFocusWeakOutlined,{})}),jsxRuntimeExports.jsx(IconButtonWithTooltip,{color:"primary",disabled:!$e,onClick:()=>{var Fe;(Fe=$e==null?void 0:$e.initialCamera)==null||Fe.call($e)},icon:jsxRuntimeExports.jsx(TimesOneMobiledataOutlined,{}),label:"1 to 1"}),divider$1,jsxRuntimeExports.jsx(IconButtonWithTooltip,{color:"primary",disabled:!$e,onClick:async()=>{const Fe=await($e==null?void 0:$e.toDataUrl());Fe&&download(Fe,dist$4.generateUsername("-"))},icon:jsxRuntimeExports.jsx(CameraOutlined,{}),label:"capture-screenshot"})]})})]})})})}),jsxRuntimeExports.jsx(ne.Options,{children:jsxRuntimeExports.jsxs(Stack$1,{direction:"row",children:[jsxRuntimeExports.jsx(FeaturePicker,{label:"Renderer",icon:jsxRuntimeExports.jsx(BlurCircularOutlined,{}),value:(ue==null?void 0:ue.renderer)??"internal:auto",onChange:Ne=>ce==null?void 0:ce({renderer:Ne}),items:[{id:"internal:auto",name:`Auto (${((Be=(ke=Ie==null?void 0:Ie.renderer)==null?void 0:ke.meta)==null?void 0:Be.name)??"None"})`},...lodashExports$1.map(me,({renderer:Ne})=>({id:Ne.meta.id,name:Ne.meta.name,description:Ne.meta.id}))],arrow:!0}),divider$1,jsxRuntimeExports.jsx(FeaturePickerMulti,{defaultChecked:!0,label:"Layers",icon:jsxRuntimeExports.jsx(LayersIcon,{}),value:xe,onChange:_e,items:lodashExports$1.map(ve,Ne=>({id:Ne.key,name:inferLayerName(Ne)})),showArrow:!0,ellipsis:12})]})}),jsxRuntimeExports.jsx(ne.Extras,{children:oe})]})}const isSourceLayer=ne=>{var oe;return!!((oe=getController(ne))!=null&&oe.getSources)};function SourcePage({template:ne}){const oe=useTheme$1();useMonacoTheme(oe);const{layers:ce}=useLayer(void 0,isSourceLayer),ue=reactExports.useMemo(()=>{var xe;return(xe=ce==null?void 0:ce.flatMap)==null?void 0:xe.call(ce,_e=>{var Se,$e,Re,Ae;return(Ae=(Re=($e=(Se=getController(_e))==null?void 0:Se.getSources)==null?void 0:$e.call(Se,_e))==null?void 0:Re.map)==null?void 0:Ae.call(Re,Ie=>({layer:_e.key,source:Ie}))})},[ce]),{controls:pe,onChange:me,state:ge,dragHandle:ye}=useViewTreeContext(),ve=reactExports.useMemo(()=>lodashExports$1.find(ue,xe=>xe&&xe.source.id===(ge==null?void 0:ge.source)&&xe.layer===(ge==null?void 0:ge.layer))??lodashExports$1.first(ue),[ue,ge==null?void 0:ge.source,ge==null?void 0:ge.layer]);return jsxRuntimeExports.jsxs(ne,{onChange:me,stack:ge,children:[jsxRuntimeExports.jsx(ne.Key,{children:"source"}),jsxRuntimeExports.jsx(ne.Title,{children:"Source"}),jsxRuntimeExports.jsx(ne.Handle,{children:ye}),jsxRuntimeExports.jsx(ne.Content,{children:ue!=null&&ue.length?jsxRuntimeExports.jsx(Flex,{pt:6,children:jsxRuntimeExports.jsx(AutoSizer,{children:xe=>{var _e,Se;return jsxRuntimeExports.jsx(de,{theme:oe.palette.mode==="dark"?"posthoc-dark":"light",options:{readOnly:!0},language:(_e=ve==null?void 0:ve.source)==null?void 0:_e.language,loading:jsxRuntimeExports.jsx(CircularProgress$1,{variant:"indeterminate"}),...xe,value:(Se=ve==null?void 0:ve.source)==null?void 0:Se.content})}})}):jsxRuntimeExports.jsx(Placeholder$2,{icon:jsxRuntimeExports.jsx(CodeOutlined,{}),label:"Source"})}),jsxRuntimeExports.jsx(ne.Options,{children:!!(ue!=null&&ue.length)&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Tabs$1,{value:`${ve==null?void 0:ve.source.id}::${ve==null?void 0:ve.layer}`,onChange:(xe,_e)=>{const[Se,$e]=_e.split("::");me==null||me({source:Se,layer:$e})},children:lodashExports$1.map(ue,({source:xe,layer:_e})=>jsxRuntimeExports.jsx(Tab$1,{label:xe.name,value:`${xe.id}::${_e}`}))})})}),jsxRuntimeExports.jsx(ne.Extras,{children:pe})]})}const pages={explore:{id:"explore",name:"Explore",color:"deepOrange",description:"Browse examples and guides",icon:jsxRuntimeExports.jsx(RocketIcon,{}),content:ExplorePage,allowFullscreen:!0,showInSidebar:"always"},layers:{id:"layers",name:"Layers",description:"",color:"pink",icon:jsxRuntimeExports.jsx(LayersIcon,{}),content:LayersPage,allowFullscreen:!0,showInSidebar:"mobile-only"},steps:{id:"steps",name:"Events",description:"",color:"pink",icon:jsxRuntimeExports.jsx(StepsIcon,{}),content:StepsPage,allowFullscreen:!0},viewport:{id:"viewport",name:"Viewport",description:"",color:"deepPurple",icon:jsxRuntimeExports.jsx(ViewportIcon,{}),content:ViewportPage,allowFullscreen:!0},tree:{id:"tree",name:"Graph",description:"",color:"deepPurple",icon:jsxRuntimeExports.jsx(TreeIcon,{}),content:TreePage,allowFullscreen:!0},source:{id:"source",name:"Sources",description:"",color:"deepPurple",icon:jsxRuntimeExports.jsx(CodeOutlined,{}),content:SourcePage,allowFullscreen:!0,showInSidebar:"mobile-only"},debug:{id:"debug",name:"Debugger",description:"",color:"indigo",icon:jsxRuntimeExports.jsx(DebuggerIcon,{}),content:DebugPage,allowFullscreen:!0,showInSidebar:"mobile-only"},info:{id:"info",name:"Logs",description:"",color:"grey",icon:jsxRuntimeExports.jsx(ListOutlined,{}),content:InfoPage,allowFullscreen:!0},settings:{id:"settings",name:"Settings",description:"",color:"grey",icon:jsxRuntimeExports.jsx(SettingsIcon,{}),content:SettingsPage,allowFullscreen:!0,showInSidebar:"always"}},ErrorBoundaryContext=reactExports.createContext(null),initialState={didCatch:!1,error:null};class ErrorBoundary extends reactExports.Component{constructor(oe){super(oe),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=initialState}static getDerivedStateFromError(oe){return{didCatch:!0,error:oe}}resetErrorBoundary(){const{error:oe}=this.state;if(oe!==null){for(var ce,ue,pe=arguments.length,me=new Array(pe),ge=0;ge0&&arguments[0]!==void 0?arguments[0]:[],oe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return ne.length!==oe.length||ne.some((ce,ue)=>!Object.is(ce,oe[ue]))}const divider=jsxRuntimeExports.jsx(Divider$1,{orientation:"vertical",flexItem:!0,sx:{m:1,height:ne=>ne.spacing(3),alignSelf:"auto"}}),Page=withSlots(({slotProps:ne,onChange:oe,stack:ce})=>{var pe,me,ge,ye;const ue=useAcrylic();return jsxRuntimeExports.jsx(ErrorBoundary,{fallbackRender:ve=>{var xe,_e;return jsxRuntimeExports.jsxs(Stack$1,{sx:{background:Se=>Se.palette.background.paper,height:"100%"},children:[jsxRuntimeExports.jsxs(Stack$1,{direction:"row",sx:{height:Se=>Se.spacing(6),alignItems:"center",pl:1,borderBottom:1,borderColor:"divider"},children:[(xe=ne.Handle)==null?void 0:xe.children,jsxRuntimeExports.jsx(FeaturePicker,{icon:jsxRuntimeExports.jsx(WidgetsOutlined,{}),label:"Choose View",onChange:Se=>oe==null?void 0:oe({...ce,type:Se}),value:ce==null?void 0:ce.type,items:lodashExports$1.values(pages),itemOrientation:"vertical"}),jsxRuntimeExports.jsx(Space,{sx:{mx:"auto"}}),(_e=ne.Extras)==null?void 0:_e.children]}),jsxRuntimeExports.jsx(Placeholder$2,{secondary:`${ve.error}`,icon:jsxRuntimeExports.jsx(ErrorOutlineOutlined,{})})]})},children:jsxRuntimeExports.jsxs(Flex,{vertical:!0,children:[jsxRuntimeExports.jsx(Flex,{sx:{position:"absolute",top:0,left:0,width:"100%"},children:jsxRuntimeExports.jsx(Box$1,{sx:{width:"100%",height:"100%",bgcolor:"background.paper"},children:(pe=ne.Content)==null?void 0:pe.children})}),jsxRuntimeExports.jsxs(Flex,{sx:{height:ve=>ve.spacing(6),alignItems:"center"},children:[jsxRuntimeExports.jsx(Flex,{sx:{p:0,position:"absolute",top:0,left:0,width:"100%",borderBottom:1,borderColor:"divider",alignItems:"center",pr:6,...ue},children:jsxRuntimeExports.jsx(Scroll,{x:!0,children:jsxRuntimeExports.jsxs(Flex,{sx:{width:"max-content",height:ve=>ve.spacing(6),alignItems:"center",p:1},children:[(me=ne.Handle)==null?void 0:me.children,jsxRuntimeExports.jsx(FeaturePicker,{icon:jsxRuntimeExports.jsx(WidgetsOutlined,{}),label:"Choose View",onChange:ve=>oe==null?void 0:oe({...ce,type:ve}),value:ce==null?void 0:ce.type,items:lodashExports$1.values(pages),itemOrientation:"vertical"}),((ge=ne.Options)==null?void 0:ge.children)&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[divider,ne.Options.children]})]})})}),jsxRuntimeExports.jsx(Space,{sx:{mx:"auto"}}),(ye=ne.Extras)==null?void 0:ye.children]})]})})}),SidebarPage=withSlots(({slotProps:ne})=>{var pe,me,ge;const oe=useSidebarBackground(),ce=useAcrylic(oe),[,ue]=useUIState();return jsxRuntimeExports.jsx(ErrorBoundary,{fallback:jsxRuntimeExports.jsx(Box$1,{sx:{p:6,background:ye=>ye.palette.background.paper,height:"100%"},children:"This page encountered an error."}),children:jsxRuntimeExports.jsxs(Flex,{vertical:!0,children:[jsxRuntimeExports.jsx(Flex,{sx:{position:"absolute",top:0,left:0,width:"100%"},children:jsxRuntimeExports.jsx(Box$1,{sx:{width:"100%",height:"100%",bgcolor:oe},children:(pe=ne.Content)==null?void 0:pe.children})}),jsxRuntimeExports.jsx(Flex,{sx:{height:ye=>ye.spacing(6)},children:jsxRuntimeExports.jsxs(Flex,{sx:{p:0,position:"absolute",top:0,left:0,width:"100%",borderBottom:1,borderColor:"divider",alignItems:"center",...ce},children:[jsxRuntimeExports.jsx(Scroll,{x:!0,children:jsxRuntimeExports.jsxs(Flex,{sx:{width:"max-content",height:ye=>ye.spacing(6),alignItems:"center",p:1},children:[jsxRuntimeExports.jsx(Type$2,{component:"div",sx:{p:1,color:"text.secondary"},children:(me=ne.Title)==null?void 0:me.children}),((ge=ne.Options)==null?void 0:ge.children)&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[divider,ne.Options.children]})]})}),jsxRuntimeExports.jsx(IconButtonWithTooltip,{onClick:()=>{ue(()=>{var ye;return{fullscreenModal:(ye=ne.Key)==null?void 0:ye.children,sidebarOpen:!1}})},size:"small",sx:{m:1},icon:jsxRuntimeExports.jsx(FullscreenOutlined,{sx:{color:"text.secondary"},fontSize:"small"}),label:"Maximise"})]})})]})})});var sysend$1={exports:{}};/**@license * sysend.js - send messages between browser windows/tabs version 1.17.4 * * Copyright (C) 2014 Jakub T. Jankiewicz diff --git a/index.html b/index.html index a99645e..b8b81ff 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@ Posthoc - +