nterminal 1.2.17 → 1.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{g as Zt,j as nn}from"./index-CzfRb88C.js";function pi(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const mi=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gi=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,di={};function ct(e,t){return(di.jsx?gi:mi).test(e)}const yi=/[ \t\n\f\r]/g;function ki(e){return typeof e=="object"?e.type==="text"?ft(e.value):!1:ft(e)}function ft(e){return e.replace(yi,"")===""}class Ye{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ye.prototype.normal={};Ye.prototype.property={};Ye.prototype.space=void 0;function er(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Ye(n,r,t)}function zn(e){return e.toLowerCase()}class ee{constructor(t,n){this.attribute=n,this.property=t}}ee.prototype.attribute="";ee.prototype.booleanish=!1;ee.prototype.boolean=!1;ee.prototype.commaOrSpaceSeparated=!1;ee.prototype.commaSeparated=!1;ee.prototype.defined=!1;ee.prototype.mustUseProperty=!1;ee.prototype.number=!1;ee.prototype.overloadedBoolean=!1;ee.prototype.property="";ee.prototype.spaceSeparated=!1;ee.prototype.space=void 0;let xi=0;const _=Ee(),Y=Ee(),Dn=Ee(),E=Ee(),W=Ee(),De=Ee(),te=Ee();function Ee(){return 2**++xi}const Ln=Object.freeze(Object.defineProperty({__proto__:null,boolean:_,booleanish:Y,commaOrSpaceSeparated:te,commaSeparated:De,number:E,overloadedBoolean:Dn,spaceSeparated:W},Symbol.toStringTag,{value:"Module"})),pn=Object.keys(Ln);class Hn extends ee{constructor(t,n,r,i){let o=-1;if(super(t,n),ht(this,"space",i),typeof r=="number")for(;++o<pn.length;){const l=pn[o];ht(this,pn[o],(r&Ln[l])===Ln[l])}}}Hn.prototype.defined=!0;function ht(e,t,n){n&&(e[t]=n)}function Fe(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const o=new Hn(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[zn(r)]=r,n[zn(o.attribute)]=r}return new Ye(t,n,e.space)}const nr=Fe({properties:{ariaActiveDescendant:null,ariaAtomic:Y,ariaAutoComplete:null,ariaBusy:Y,ariaChecked:Y,ariaColCount:E,ariaColIndex:E,ariaColSpan:E,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:Y,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:Y,ariaFlowTo:W,ariaGrabbed:Y,ariaHasPopup:null,ariaHidden:Y,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:E,ariaLive:null,ariaModal:Y,ariaMultiLine:Y,ariaMultiSelectable:Y,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:E,ariaPressed:Y,ariaReadOnly:Y,ariaRelevant:null,ariaRequired:Y,ariaRoleDescription:W,ariaRowCount:E,ariaRowIndex:E,ariaRowSpan:E,ariaSelected:Y,ariaSetSize:E,ariaSort:null,ariaValueMax:E,ariaValueMin:E,ariaValueNow:E,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function tr(e,t){return t in e?e[t]:t}function rr(e,t){return tr(e,t.toLowerCase())}const bi=Fe({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:De,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:_,allowPaymentRequest:_,allowUserMedia:_,alt:null,as:null,async:_,autoCapitalize:null,autoComplete:W,autoFocus:_,autoPlay:_,blocking:W,capture:null,charSet:null,checked:_,cite:null,className:W,cols:E,colSpan:null,content:null,contentEditable:Y,controls:_,controlsList:W,coords:E|De,crossOrigin:null,data:null,dateTime:null,decoding:null,default:_,defer:_,dir:null,dirName:null,disabled:_,download:Dn,draggable:Y,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:_,formTarget:null,headers:W,height:E,hidden:Dn,high:E,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:_,inputMode:null,integrity:null,is:null,isMap:_,itemId:null,itemProp:W,itemRef:W,itemScope:_,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:_,low:E,manifest:null,max:null,maxLength:E,media:null,method:null,min:null,minLength:E,multiple:_,muted:_,name:null,nonce:null,noModule:_,noValidate:_,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:_,optimum:E,pattern:null,ping:W,placeholder:null,playsInline:_,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:_,referrerPolicy:null,rel:W,required:_,reversed:_,rows:E,rowSpan:E,sandbox:W,scope:null,scoped:_,seamless:_,selected:_,shadowRootClonable:_,shadowRootDelegatesFocus:_,shadowRootMode:null,shape:null,size:E,sizes:null,slot:null,span:E,spellCheck:Y,src:null,srcDoc:null,srcLang:null,srcSet:null,start:E,step:null,style:null,tabIndex:E,target:null,title:null,translate:null,type:null,typeMustMatch:_,useMap:null,value:Y,width:E,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:E,borderColor:null,bottomMargin:E,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:_,declare:_,event:null,face:null,frame:null,frameBorder:null,hSpace:E,leftMargin:E,link:null,longDesc:null,lowSrc:null,marginHeight:E,marginWidth:E,noResize:_,noHref:_,noShade:_,noWrap:_,object:null,profile:null,prompt:null,rev:null,rightMargin:E,rules:null,scheme:null,scrolling:Y,standby:null,summary:null,text:null,topMargin:E,valueType:null,version:null,vAlign:null,vLink:null,vSpace:E,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:_,disableRemotePlayback:_,prefix:null,property:null,results:E,security:null,unselectable:null},space:"html",transform:rr}),wi=Fe({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:te,accentHeight:E,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:E,amplitude:E,arabicForm:null,ascent:E,attributeName:null,attributeType:null,azimuth:E,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:E,by:null,calcMode:null,capHeight:E,className:W,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:E,diffuseConstant:E,direction:null,display:null,dur:null,divisor:E,dominantBaseline:null,download:_,dx:null,dy:null,edgeMode:null,editable:null,elevation:E,enableBackground:null,end:null,event:null,exponent:E,externalResourcesRequired:null,fill:null,fillOpacity:E,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:De,g2:De,glyphName:De,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:E,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:E,horizOriginX:E,horizOriginY:E,id:null,ideographic:E,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:E,k:E,k1:E,k2:E,k3:E,k4:E,kernelMatrix:te,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:E,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:E,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:E,overlineThickness:E,paintOrder:null,panose1:null,path:null,pathLength:E,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:E,pointsAtY:E,pointsAtZ:E,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:te,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:te,rev:te,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:te,requiredFeatures:te,requiredFonts:te,requiredFormats:te,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:E,specularExponent:E,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:E,strikethroughThickness:E,string:null,stroke:null,strokeDashArray:te,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:E,strokeOpacity:E,strokeWidth:null,style:null,surfaceScale:E,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:te,tabIndex:E,tableValues:null,target:null,targetX:E,targetY:E,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:te,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:E,underlineThickness:E,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:E,values:null,vAlphabetic:E,vMathematical:E,vectorEffect:null,vHanging:E,vIdeographic:E,version:null,vertAdvY:E,vertOriginX:E,vertOriginY:E,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:E,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:tr}),ir=Fe({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),lr=Fe({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:rr}),or=Fe({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Si={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Ci=/[A-Z]/g,pt=/-[a-z]/g,Ei=/^data[-\w.:]+$/i;function Ii(e,t){const n=zn(t);let r=t,i=ee;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Ei.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(pt,Ti);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!pt.test(o)){let l=o.replace(Ci,Ai);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}i=Hn}return new i(r,t)}function Ai(e){return"-"+e.toLowerCase()}function Ti(e){return e.charAt(1).toUpperCase()}const Pi=er([nr,bi,ir,lr,or],"html"),Un=er([nr,wi,ir,lr,or],"svg");function vi(e){return e.join(" ").trim()}var Pe={},mn,mt;function zi(){if(mt)return mn;mt=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,a=/^\s+|\s+$/g,u=`
1
+ import{g as Zt,j as nn}from"./index-8FTmdvif.js";function pi(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const mi=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,gi=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,di={};function ct(e,t){return(di.jsx?gi:mi).test(e)}const yi=/[ \t\n\f\r]/g;function ki(e){return typeof e=="object"?e.type==="text"?ft(e.value):!1:ft(e)}function ft(e){return e.replace(yi,"")===""}class Ye{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Ye.prototype.normal={};Ye.prototype.property={};Ye.prototype.space=void 0;function er(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Ye(n,r,t)}function zn(e){return e.toLowerCase()}class ee{constructor(t,n){this.attribute=n,this.property=t}}ee.prototype.attribute="";ee.prototype.booleanish=!1;ee.prototype.boolean=!1;ee.prototype.commaOrSpaceSeparated=!1;ee.prototype.commaSeparated=!1;ee.prototype.defined=!1;ee.prototype.mustUseProperty=!1;ee.prototype.number=!1;ee.prototype.overloadedBoolean=!1;ee.prototype.property="";ee.prototype.spaceSeparated=!1;ee.prototype.space=void 0;let xi=0;const _=Ee(),Y=Ee(),Dn=Ee(),E=Ee(),W=Ee(),De=Ee(),te=Ee();function Ee(){return 2**++xi}const Ln=Object.freeze(Object.defineProperty({__proto__:null,boolean:_,booleanish:Y,commaOrSpaceSeparated:te,commaSeparated:De,number:E,overloadedBoolean:Dn,spaceSeparated:W},Symbol.toStringTag,{value:"Module"})),pn=Object.keys(Ln);class Hn extends ee{constructor(t,n,r,i){let o=-1;if(super(t,n),ht(this,"space",i),typeof r=="number")for(;++o<pn.length;){const l=pn[o];ht(this,pn[o],(r&Ln[l])===Ln[l])}}}Hn.prototype.defined=!0;function ht(e,t,n){n&&(e[t]=n)}function Fe(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const o=new Hn(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[zn(r)]=r,n[zn(o.attribute)]=r}return new Ye(t,n,e.space)}const nr=Fe({properties:{ariaActiveDescendant:null,ariaAtomic:Y,ariaAutoComplete:null,ariaBusy:Y,ariaChecked:Y,ariaColCount:E,ariaColIndex:E,ariaColSpan:E,ariaControls:W,ariaCurrent:null,ariaDescribedBy:W,ariaDetails:null,ariaDisabled:Y,ariaDropEffect:W,ariaErrorMessage:null,ariaExpanded:Y,ariaFlowTo:W,ariaGrabbed:Y,ariaHasPopup:null,ariaHidden:Y,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:W,ariaLevel:E,ariaLive:null,ariaModal:Y,ariaMultiLine:Y,ariaMultiSelectable:Y,ariaOrientation:null,ariaOwns:W,ariaPlaceholder:null,ariaPosInSet:E,ariaPressed:Y,ariaReadOnly:Y,ariaRelevant:null,ariaRequired:Y,ariaRoleDescription:W,ariaRowCount:E,ariaRowIndex:E,ariaRowSpan:E,ariaSelected:Y,ariaSetSize:E,ariaSort:null,ariaValueMax:E,ariaValueMin:E,ariaValueNow:E,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function tr(e,t){return t in e?e[t]:t}function rr(e,t){return tr(e,t.toLowerCase())}const bi=Fe({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:De,acceptCharset:W,accessKey:W,action:null,allow:null,allowFullScreen:_,allowPaymentRequest:_,allowUserMedia:_,alt:null,as:null,async:_,autoCapitalize:null,autoComplete:W,autoFocus:_,autoPlay:_,blocking:W,capture:null,charSet:null,checked:_,cite:null,className:W,cols:E,colSpan:null,content:null,contentEditable:Y,controls:_,controlsList:W,coords:E|De,crossOrigin:null,data:null,dateTime:null,decoding:null,default:_,defer:_,dir:null,dirName:null,disabled:_,download:Dn,draggable:Y,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:_,formTarget:null,headers:W,height:E,hidden:Dn,high:E,href:null,hrefLang:null,htmlFor:W,httpEquiv:W,id:null,imageSizes:null,imageSrcSet:null,inert:_,inputMode:null,integrity:null,is:null,isMap:_,itemId:null,itemProp:W,itemRef:W,itemScope:_,itemType:W,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:_,low:E,manifest:null,max:null,maxLength:E,media:null,method:null,min:null,minLength:E,multiple:_,muted:_,name:null,nonce:null,noModule:_,noValidate:_,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:_,optimum:E,pattern:null,ping:W,placeholder:null,playsInline:_,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:_,referrerPolicy:null,rel:W,required:_,reversed:_,rows:E,rowSpan:E,sandbox:W,scope:null,scoped:_,seamless:_,selected:_,shadowRootClonable:_,shadowRootDelegatesFocus:_,shadowRootMode:null,shape:null,size:E,sizes:null,slot:null,span:E,spellCheck:Y,src:null,srcDoc:null,srcLang:null,srcSet:null,start:E,step:null,style:null,tabIndex:E,target:null,title:null,translate:null,type:null,typeMustMatch:_,useMap:null,value:Y,width:E,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:W,axis:null,background:null,bgColor:null,border:E,borderColor:null,bottomMargin:E,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:_,declare:_,event:null,face:null,frame:null,frameBorder:null,hSpace:E,leftMargin:E,link:null,longDesc:null,lowSrc:null,marginHeight:E,marginWidth:E,noResize:_,noHref:_,noShade:_,noWrap:_,object:null,profile:null,prompt:null,rev:null,rightMargin:E,rules:null,scheme:null,scrolling:Y,standby:null,summary:null,text:null,topMargin:E,valueType:null,version:null,vAlign:null,vLink:null,vSpace:E,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:_,disableRemotePlayback:_,prefix:null,property:null,results:E,security:null,unselectable:null},space:"html",transform:rr}),wi=Fe({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:te,accentHeight:E,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:E,amplitude:E,arabicForm:null,ascent:E,attributeName:null,attributeType:null,azimuth:E,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:E,by:null,calcMode:null,capHeight:E,className:W,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:E,diffuseConstant:E,direction:null,display:null,dur:null,divisor:E,dominantBaseline:null,download:_,dx:null,dy:null,edgeMode:null,editable:null,elevation:E,enableBackground:null,end:null,event:null,exponent:E,externalResourcesRequired:null,fill:null,fillOpacity:E,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:De,g2:De,glyphName:De,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:E,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:E,horizOriginX:E,horizOriginY:E,id:null,ideographic:E,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:E,k:E,k1:E,k2:E,k3:E,k4:E,kernelMatrix:te,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:E,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:E,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:E,overlineThickness:E,paintOrder:null,panose1:null,path:null,pathLength:E,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:W,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:E,pointsAtY:E,pointsAtZ:E,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:te,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:te,rev:te,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:te,requiredFeatures:te,requiredFonts:te,requiredFormats:te,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:E,specularExponent:E,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:E,strikethroughThickness:E,string:null,stroke:null,strokeDashArray:te,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:E,strokeOpacity:E,strokeWidth:null,style:null,surfaceScale:E,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:te,tabIndex:E,tableValues:null,target:null,targetX:E,targetY:E,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:te,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:E,underlineThickness:E,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:E,values:null,vAlphabetic:E,vMathematical:E,vectorEffect:null,vHanging:E,vIdeographic:E,version:null,vertAdvY:E,vertOriginX:E,vertOriginY:E,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:E,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:tr}),ir=Fe({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),lr=Fe({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:rr}),or=Fe({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Si={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Ci=/[A-Z]/g,pt=/-[a-z]/g,Ei=/^data[-\w.:]+$/i;function Ii(e,t){const n=zn(t);let r=t,i=ee;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Ei.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(pt,Ti);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!pt.test(o)){let l=o.replace(Ci,Ai);l.charAt(0)!=="-"&&(l="-"+l),t="data"+l}}i=Hn}return new i(r,t)}function Ai(e){return"-"+e.toLowerCase()}function Ti(e){return e.charAt(1).toUpperCase()}const Pi=er([nr,bi,ir,lr,or],"html"),Un=er([nr,wi,ir,lr,or],"svg");function vi(e){return e.join(" ").trim()}var Pe={},mn,mt;function zi(){if(mt)return mn;mt=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,a=/^\s+|\s+$/g,u=`
2
2
  `,s="/",f="*",c="",p="comment",h="declaration";function d(S,y){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];y=y||{};var I=1,C=1;function F(D){var T=D.match(t);T&&(I+=T.length);var q=D.lastIndexOf(u);C=~q?D.length-q:C+D.length}function R(){var D={line:I,column:C};return function(T){return T.position=new b(D),j(),T}}function b(D){this.start=D,this.end={line:I,column:C},this.source=y.source}b.prototype.content=S;function M(D){var T=new Error(y.source+":"+I+":"+C+": "+D);if(T.reason=D,T.filename=y.source,T.line=I,T.column=C,T.source=S,!y.silent)throw T}function H(D){var T=D.exec(S);if(T){var q=T[0];return F(q),S=S.slice(q.length),T}}function j(){H(n)}function k(D){var T;for(D=D||[];T=P();)T!==!1&&D.push(T);return D}function P(){var D=R();if(!(s!=S.charAt(0)||f!=S.charAt(1))){for(var T=2;c!=S.charAt(T)&&(f!=S.charAt(T)||s!=S.charAt(T+1));)++T;if(T+=2,c===S.charAt(T-1))return M("End of comment missing");var q=S.slice(2,T-2);return C+=2,F(q),S=S.slice(T),C+=2,D({type:p,comment:q})}}function v(){var D=R(),T=H(r);if(T){if(P(),!H(i))return M("property missing ':'");var q=H(o),X=D({type:h,property:w(T[0].replace(e,c)),value:q?w(q[0].replace(e,c)):c});return H(l),X}}function U(){var D=[];k(D);for(var T;T=v();)T!==!1&&(D.push(T),k(D));return D}return j(),U()}function w(S){return S?S.replace(a,c):c}return mn=d,mn}var gt;function Di(){if(gt)return Pe;gt=1;var e=Pe&&Pe.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.default=n;const t=e(zi());function n(r,i){let o=null;if(!r||typeof r!="string")return o;const l=(0,t.default)(r),a=typeof i=="function";return l.forEach(u=>{if(u.type!=="declaration")return;const{property:s,value:f}=u;a?i(s,f,u):f&&(o=o||{},o[s]=f)}),o}return Pe}var Ne={},dt;function Li(){if(dt)return Ne;dt=1,Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(s){return!s||n.test(s)||e.test(s)},l=function(s,f){return f.toUpperCase()},a=function(s,f){return"".concat(f,"-")},u=function(s,f){return f===void 0&&(f={}),o(s)?s:(s=s.toLowerCase(),f.reactCompat?s=s.replace(i,a):s=s.replace(r,a),s.replace(t,l))};return Ne.camelCase=u,Ne}var Be,yt;function Fi(){if(yt)return Be;yt=1;var e=Be&&Be.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Di()),n=Li();function r(i,o){var l={};return!i||typeof i!="string"||(0,t.default)(i,function(a,u){a&&u&&(l[(0,n.camelCase)(a,o)]=u)}),l}return r.default=r,Be=r,Be}var Ri=Fi();const _i=Zt(Ri),ar=ur("end"),qn=ur("start");function ur(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Oi(e){const t=qn(e),n=ar(e);if(t&&n)return{start:t,end:n}}function Ue(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?kt(e.position):"start"in e||"end"in e?kt(e):"line"in e||"column"in e?Fn(e):""}function Fn(e){return xt(e&&e.line)+":"+xt(e&&e.column)}function kt(e){return Fn(e&&e.start)+"-"+Fn(e&&e.end)}function xt(e){return e&&typeof e=="number"?e:1}class K extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},l=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?i=t:!o.cause&&t&&(l=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?o.ruleId=r:(o.source=r.slice(0,u),o.ruleId=r.slice(u+1))}if(!o.place&&o.ancestors&&o.ancestors){const u=o.ancestors[o.ancestors.length-1];u&&(o.place=u.position)}const a=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=Ue(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=l&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}K.prototype.file="";K.prototype.name="";K.prototype.reason="";K.prototype.message="";K.prototype.stack="";K.prototype.column=void 0;K.prototype.line=void 0;K.prototype.ancestors=void 0;K.prototype.cause=void 0;K.prototype.fatal=void 0;K.prototype.place=void 0;K.prototype.ruleId=void 0;K.prototype.source=void 0;const Vn={}.hasOwnProperty,Mi=new Map,Ni=/[A-Z]/g,Bi=new Set(["table","tbody","thead","tfoot","tr"]),ji=new Set(["td","th"]),sr="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Hi(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Qi(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Xi(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Un:Pi,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=cr(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function cr(e,t,n){if(t.type==="element")return Ui(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return qi(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return $i(e,t,n);if(t.type==="mdxjsEsm")return Vi(e,t);if(t.type==="root")return Wi(e,t,n);if(t.type==="text")return Yi(e,t)}function Ui(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Un,e.schema=i),e.ancestors.push(t);const o=hr(e,t.tagName,!1),l=Gi(e,t);let a=Wn(e,t);return Bi.has(t.tagName)&&(a=a.filter(function(u){return typeof u=="string"?!ki(u):!0})),fr(e,l,o,t),$n(l,a),e.ancestors.pop(),e.schema=r,e.create(t,o,l,n)}function qi(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}$e(e,t.position)}function Vi(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);$e(e,t.position)}function $i(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Un,e.schema=i),e.ancestors.push(t);const o=t.name===null?e.Fragment:hr(e,t.name,!0),l=Ki(e,t),a=Wn(e,t);return fr(e,l,o,t),$n(l,a),e.ancestors.pop(),e.schema=r,e.create(t,o,l,n)}function Wi(e,t,n){const r={};return $n(r,Wn(e,t)),e.create(t,e.Fragment,r,n)}function Yi(e,t){return t.value}function fr(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function $n(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Xi(e,t,n){return r;function r(i,o,l,a){const s=Array.isArray(l.children)?n:t;return a?s(o,l,a):s(o,l)}}function Qi(e,t){return n;function n(r,i,o,l){const a=Array.isArray(o.children),u=qn(r);return t(i,o,l,a,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function Gi(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Vn.call(t.properties,i)){const o=Ji(e,i,t.properties[i]);if(o){const[l,a]=o;e.tableCellAlignToStyle&&l==="align"&&typeof a=="string"&&ji.has(t.tagName)?r=a:n[l]=a}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Ki(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const l=o.expression;l.type;const a=l.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else $e(e,t.position);else{const i=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,o=e.evaluater.evaluateExpression(a.expression)}else $e(e,t.position);else o=r.value===null?!0:r.value;n[i]=o}return n}function Wn(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Mi;for(;++r<t.children.length;){const o=t.children[r];let l;if(e.passKeys){const u=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(u){const s=i.get(u)||0;l=u+"-"+s,i.set(u,s+1)}}const a=cr(e,o,l);a!==void 0&&n.push(a)}return n}function Ji(e,t,n){const r=Ii(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?pi(n):vi(n)),r.property==="style"){let i=typeof n=="object"?n:Zi(e,String(n));return e.stylePropertyNameCase==="css"&&(i=el(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Si[r.property]||r.property:r.attribute,n]}}function Zi(e,t){try{return _i(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new K("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=sr+"#cannot-parse-style-attribute",i}}function hr(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let o=-1,l;for(;++o<i.length;){const a=ct(i[o])?{type:"Identifier",name:i[o]}:{type:"Literal",value:i[o]};l=l?{type:"MemberExpression",object:l,property:a,computed:!!(o&&a.type==="Literal"),optional:!1}:a}r=l}else r=ct(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Vn.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);$e(e)}function $e(e,t){const n=new K("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=sr+"#cannot-handle-mdx-estrees-without-createevaluater",n}function el(e){const t={};let n;for(n in e)Vn.call(e,n)&&(t[nl(n)]=e[n]);return t}function nl(e){let t=e.replace(Ni,tl);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function tl(e){return"-"+e.toLowerCase()}const gn={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},rl={};function Yn(e,t){const n=rl,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return pr(e,r,i)}function pr(e,t,n){if(il(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return bt(e.children,t,n)}return Array.isArray(e)?bt(e,t,n):""}function bt(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=pr(e[i],t,n);return r.join("")}function il(e){return!!(e&&typeof e=="object")}const wt=document.createElement("i");function Xn(e){const t="&"+e+";";wt.innerHTML=t;const n=wt.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function re(e,t,n,r){const i=e.length;let o=0,l;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)l=Array.from(r),l.unshift(t,n),e.splice(...l);else for(n&&e.splice(t,n);o<r.length;)l=r.slice(o,o+1e4),l.unshift(t,0),e.splice(...l),o+=1e4,t+=1e4}function ie(e,t){return e.length>0?(re(e,e.length,0,t),e):t}const St={}.hasOwnProperty;function mr(e){const t={};let n=-1;for(;++n<e.length;)ll(t,e[n]);return t}function ll(e,t){let n;for(n in t){const i=(St.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let l;if(o)for(l in o){St.call(i,l)||(i[l]=[]);const a=o[l];ol(i[l],Array.isArray(a)?a:a?[a]:[])}}}function ol(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);re(e,0,0,r)}function gr(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function se(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const J=xe(/[A-Za-z]/),G=xe(/[\dA-Za-z]/),al=xe(/[#-'*+\--9=?A-Z^-~]/);function rn(e){return e!==null&&(e<32||e===127)}const Rn=xe(/\d/),ul=xe(/[\dA-Fa-f]/),sl=xe(/[!-/:-@[-`{-~]/);function z(e){return e!==null&&e<-2}function $(e){return e!==null&&(e<0||e===32)}function O(e){return e===-2||e===-1||e===32}const un=xe(new RegExp("\\p{P}|\\p{S}","u")),Ce=xe(/\s/);function xe(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Re(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const o=e.charCodeAt(n);let l="";if(o===37&&G(e.charCodeAt(n+1))&&G(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(l=String.fromCharCode(o));else if(o>55295&&o<57344){const a=e.charCodeAt(n+1);o<56320&&a>56319&&a<57344?(l=String.fromCharCode(o,a),i=1):l="�"}else l=String.fromCharCode(o);l&&(t.push(e.slice(r,n),encodeURIComponent(l)),r=n+i+1,l=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function B(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return l;function l(u){return O(u)?(e.enter(n),a(u)):t(u)}function a(u){return O(u)&&o++<i?(e.consume(u),a):(e.exit(n),t(u))}}const cl={tokenize:fl};function fl(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),B(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),o(a)}function o(a){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,l(a)}function l(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return z(a)?(e.consume(a),e.exit("chunkText"),o):(e.consume(a),l)}}const hl={tokenize:pl},Ct={tokenize:ml};function pl(e){const t=this,n=[];let r=0,i,o,l;return a;function a(C){if(r<n.length){const F=n[r];return t.containerState=F[1],e.attempt(F[0].continuation,u,s)(C)}return s(C)}function u(C){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&I();const F=t.events.length;let R=F,b;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){b=t.events[R][1].end;break}y(r);let M=F;for(;M<t.events.length;)t.events[M][1].end={...b},M++;return re(t.events,R+1,0,t.events.slice(F)),t.events.length=M,s(C)}return a(C)}function s(C){if(r===n.length){if(!i)return p(C);if(i.currentConstruct&&i.currentConstruct.concrete)return d(C);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ct,f,c)(C)}function f(C){return i&&I(),y(r),p(C)}function c(C){return t.parser.lazy[t.now().line]=r!==n.length,l=t.now().offset,d(C)}function p(C){return t.containerState={},e.attempt(Ct,h,d)(C)}function h(C){return r++,n.push([t.currentConstruct,t.containerState]),p(C)}function d(C){if(C===null){i&&I(),y(0),e.consume(C);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),w(C)}function w(C){if(C===null){S(e.exit("chunkFlow"),!0),y(0),e.consume(C);return}return z(C)?(e.consume(C),S(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(C),w)}function S(C,F){const R=t.sliceStream(C);if(F&&R.push(null),C.previous=o,o&&(o.next=C),o=C,i.defineSkip(C.start),i.write(R),t.parser.lazy[C.start.line]){let b=i.events.length;for(;b--;)if(i.events[b][1].start.offset<l&&(!i.events[b][1].end||i.events[b][1].end.offset>l))return;const M=t.events.length;let H=M,j,k;for(;H--;)if(t.events[H][0]==="exit"&&t.events[H][1].type==="chunkFlow"){if(j){k=t.events[H][1].end;break}j=!0}for(y(r),b=M;b<t.events.length;)t.events[b][1].end={...k},b++;re(t.events,H+1,0,t.events.slice(M)),t.events.length=b}}function y(C){let F=n.length;for(;F-- >C;){const R=n[F];t.containerState=R[1],R[0].exit.call(t,e)}n.length=C}function I(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function ml(e,t,n){return B(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Le(e){if(e===null||$(e)||Ce(e))return 1;if(un(e))return 2}function sn(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const _n={name:"attention",resolveAll:gl,tokenize:dl};function gl(e,t){let n=-1,r,i,o,l,a,u,s,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const c={...e[r][1].end},p={...e[n][1].start};Et(c,-u),Et(p,u),l={type:u>1?"strongSequence":"emphasisSequence",start:c,end:{...e[r][1].end}},a={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},o={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?"strong":"emphasis",start:{...l.start},end:{...a.end}},e[r][1].end={...l.start},e[n][1].start={...a.end},s=[],e[r][1].end.offset-e[r][1].start.offset&&(s=ie(s,[["enter",e[r][1],t],["exit",e[r][1],t]])),s=ie(s,[["enter",i,t],["enter",l,t],["exit",l,t],["enter",o,t]]),s=ie(s,sn(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),s=ie(s,[["exit",o,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,s=ie(s,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,re(e,r-1,n-r+3,s),n=r+s.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function dl(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Le(r);let o;return l;function l(u){return o=u,e.enter("attentionSequence"),a(u)}function a(u){if(u===o)return e.consume(u),a;const s=e.exit("attentionSequence"),f=Le(u),c=!f||f===2&&i||n.includes(u),p=!i||i===2&&f||n.includes(r);return s._open=!!(o===42?c:c&&(i||!p)),s._close=!!(o===42?p:p&&(f||!c)),t(u)}}function Et(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const yl={name:"autolink",tokenize:kl};function kl(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(h){return J(h)?(e.consume(h),l):h===64?n(h):s(h)}function l(h){return h===43||h===45||h===46||G(h)?(r=1,a(h)):s(h)}function a(h){return h===58?(e.consume(h),r=0,u):(h===43||h===45||h===46||G(h))&&r++<32?(e.consume(h),a):(r=0,s(h))}function u(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||rn(h)?n(h):(e.consume(h),u)}function s(h){return h===64?(e.consume(h),f):al(h)?(e.consume(h),s):n(h)}function f(h){return G(h)?c(h):n(h)}function c(h){return h===46?(e.consume(h),r=0,f):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):p(h)}function p(h){if((h===45||G(h))&&r++<63){const d=h===45?p:c;return e.consume(h),d}return n(h)}}const Xe={partial:!0,tokenize:xl};function xl(e,t,n){return r;function r(o){return O(o)?B(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||z(o)?t(o):n(o)}}const dr={continuation:{tokenize:wl},exit:Sl,name:"blockQuote",tokenize:bl};function bl(e,t,n){const r=this;return i;function i(l){if(l===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(l),e.exit("blockQuoteMarker"),o}return n(l)}function o(l){return O(l)?(e.enter("blockQuotePrefixWhitespace"),e.consume(l),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(l))}}function wl(e,t,n){const r=this;return i;function i(l){return O(l)?B(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l):o(l)}function o(l){return e.attempt(dr,t,n)(l)}}function Sl(e){e.exit("blockQuote")}const yr={name:"characterEscape",tokenize:Cl};function Cl(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),i}function i(o){return sl(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const kr={name:"characterReference",tokenize:El};function El(e,t,n){const r=this;let i=0,o,l;return a;function a(c){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),u}function u(c){return c===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(c),e.exit("characterReferenceMarkerNumeric"),s):(e.enter("characterReferenceValue"),o=31,l=G,f(c))}function s(c){return c===88||c===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(c),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,l=ul,f):(e.enter("characterReferenceValue"),o=7,l=Rn,f(c))}function f(c){if(c===59&&i){const p=e.exit("characterReferenceValue");return l===G&&!Xn(r.sliceSerialize(p))?n(c):(e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return l(c)&&i++<o?(e.consume(c),f):n(c)}}const It={partial:!0,tokenize:Al},At={concrete:!0,name:"codeFenced",tokenize:Il};function Il(e,t,n){const r=this,i={partial:!0,tokenize:R};let o=0,l=0,a;return u;function u(b){return s(b)}function s(b){const M=r.events[r.events.length-1];return o=M&&M[1].type==="linePrefix"?M[2].sliceSerialize(M[1],!0).length:0,a=b,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(b)}function f(b){return b===a?(l++,e.consume(b),f):l<3?n(b):(e.exit("codeFencedFenceSequence"),O(b)?B(e,c,"whitespace")(b):c(b))}function c(b){return b===null||z(b)?(e.exit("codeFencedFence"),r.interrupt?t(b):e.check(It,w,F)(b)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||z(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(b)):O(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),B(e,h,"whitespace")(b)):b===96&&b===a?n(b):(e.consume(b),p)}function h(b){return b===null||z(b)?c(b):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),d(b))}function d(b){return b===null||z(b)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(b)):b===96&&b===a?n(b):(e.consume(b),d)}function w(b){return e.attempt(i,F,S)(b)}function S(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),y}function y(b){return o>0&&O(b)?B(e,I,"linePrefix",o+1)(b):I(b)}function I(b){return b===null||z(b)?e.check(It,w,F)(b):(e.enter("codeFlowValue"),C(b))}function C(b){return b===null||z(b)?(e.exit("codeFlowValue"),I(b)):(e.consume(b),C)}function F(b){return e.exit("codeFenced"),t(b)}function R(b,M,H){let j=0;return k;function k(T){return b.enter("lineEnding"),b.consume(T),b.exit("lineEnding"),P}function P(T){return b.enter("codeFencedFence"),O(T)?B(b,v,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):v(T)}function v(T){return T===a?(b.enter("codeFencedFenceSequence"),U(T)):H(T)}function U(T){return T===a?(j++,b.consume(T),U):j>=l?(b.exit("codeFencedFenceSequence"),O(T)?B(b,D,"whitespace")(T):D(T)):H(T)}function D(T){return T===null||z(T)?(b.exit("codeFencedFence"),M(T)):H(T)}}}function Al(e,t,n){const r=this;return i;function i(l){return l===null?n(l):(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),o)}function o(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}const dn={name:"codeIndented",tokenize:Pl},Tl={partial:!0,tokenize:vl};function Pl(e,t,n){const r=this;return i;function i(s){return e.enter("codeIndented"),B(e,o,"linePrefix",5)(s)}function o(s){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?l(s):n(s)}function l(s){return s===null?u(s):z(s)?e.attempt(Tl,l,u)(s):(e.enter("codeFlowValue"),a(s))}function a(s){return s===null||z(s)?(e.exit("codeFlowValue"),l(s)):(e.consume(s),a)}function u(s){return e.exit("codeIndented"),t(s)}}function vl(e,t,n){const r=this;return i;function i(l){return r.parser.lazy[r.now().line]?n(l):z(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),i):B(e,o,"linePrefix",5)(l)}function o(l){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(l):z(l)?i(l):n(l)}}const zl={name:"codeText",previous:Ll,resolve:Dl,tokenize:Fl};function Dl(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Ll(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Fl(e,t,n){let r=0,i,o;return l;function l(c){return e.enter("codeText"),e.enter("codeTextSequence"),a(c)}function a(c){return c===96?(e.consume(c),r++,a):(e.exit("codeTextSequence"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter("space"),e.consume(c),e.exit("space"),u):c===96?(o=e.enter("codeTextSequence"),i=0,f(c)):z(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),u):(e.enter("codeTextData"),s(c))}function s(c){return c===null||c===32||c===96||z(c)?(e.exit("codeTextData"),u(c)):(e.consume(c),s)}function f(c){return c===96?(e.consume(c),i++,f):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(c)):(o.type="codeTextData",s(c))}}class Rl{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&je(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),je(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),je(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);je(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);je(this.left,n.reverse())}}}function je(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function xr(e){const t={};let n=-1,r,i,o,l,a,u,s;const f=new Rl(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,o=0,o<u.length&&u[o][1].type==="lineEndingBlank"&&(o+=2),o<u.length&&u[o][1].type==="content"))for(;++o<u.length&&u[o][1].type!=="content";)u[o][1].type==="chunkText"&&(u[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,_l(f,n)),n=t[n],s=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(l=f.get(o),l[1].type==="lineEnding"||l[1].type==="lineEndingBlank")l[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),l[1].type="lineEnding",i=o);else if(!(l[1].type==="linePrefix"||l[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},a=f.slice(i,n),a.unshift(r),f.splice(i,n-i+1,a))}}return re(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!s}function _l(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const o=[];let l=n._tokenizer;l||(l=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(l._contentTypeTextTrailing=!0));const a=l.events,u=[],s={};let f,c,p=-1,h=n,d=0,w=0;const S=[w];for(;h;){for(;e.get(++i)[1]!==h;);o.push(i),h._tokenizer||(f=r.sliceStream(h),h.next||f.push(null),c&&l.defineSkip(h.start),h._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=!0),l.write(f),h._isInFirstContentOfListItem&&(l._gfmTasklistFirstContentOfListItem=void 0)),c=h,h=h.next}for(h=n;++p<a.length;)a[p][0]==="exit"&&a[p-1][0]==="enter"&&a[p][1].type===a[p-1][1].type&&a[p][1].start.line!==a[p][1].end.line&&(w=p+1,S.push(w),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(l.events=[],h?(h._tokenizer=void 0,h.previous=void 0):S.pop(),p=S.length;p--;){const y=a.slice(S[p],S[p+1]),I=o.pop();u.push([I,I+y.length-1]),e.splice(I,2,y)}for(u.reverse(),p=-1;++p<u.length;)s[d+u[p][0]]=d+u[p][1],d+=u[p][1]-u[p][0]-1;return s}const Ol={resolve:Nl,tokenize:Bl},Ml={partial:!0,tokenize:jl};function Nl(e){return xr(e),e}function Bl(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?o(a):z(a)?e.check(Ml,l,o)(a):(e.consume(a),i)}function o(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function l(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function jl(e,t,n){const r=this;return i;function i(l){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),B(e,o,"linePrefix")}function o(l){if(l===null||z(l))return n(l);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(l):e.interrupt(r.parser.constructs.flow,n,t)(l)}}function br(e,t,n,r,i,o,l,a,u){const s=u||Number.POSITIVE_INFINITY;let f=0;return c;function c(y){return y===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(y),e.exit(o),p):y===null||y===32||y===41||rn(y)?n(y):(e.enter(r),e.enter(l),e.enter(a),e.enter("chunkString",{contentType:"string"}),w(y))}function p(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===62?(e.exit("chunkString"),e.exit(a),p(y)):y===null||y===60||z(y)?n(y):(e.consume(y),y===92?d:h)}function d(y){return y===60||y===62||y===92?(e.consume(y),h):h(y)}function w(y){return!f&&(y===null||y===41||$(y))?(e.exit("chunkString"),e.exit(a),e.exit(l),e.exit(r),t(y)):f<s&&y===40?(e.consume(y),f++,w):y===41?(e.consume(y),f--,w):y===null||y===32||y===40||rn(y)?n(y):(e.consume(y),y===92?S:w)}function S(y){return y===40||y===41||y===92?(e.consume(y),w):w(y)}}function wr(e,t,n,r,i,o){const l=this;let a=0,u;return s;function s(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(o),f}function f(h){return a>999||h===null||h===91||h===93&&!u||h===94&&!a&&"_hiddenFootnoteSupport"in l.parser.constructs?n(h):h===93?(e.exit(o),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):z(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),c(h))}function c(h){return h===null||h===91||h===93||z(h)||a++>999?(e.exit("chunkString"),f(h)):(e.consume(h),u||(u=!O(h)),h===92?p:c)}function p(h){return h===91||h===92||h===93?(e.consume(h),a++,c):c(h)}}function Sr(e,t,n,r,i,o){let l;return a;function a(p){return p===34||p===39||p===40?(e.enter(r),e.enter(i),e.consume(p),e.exit(i),l=p===40?41:p,u):n(p)}function u(p){return p===l?(e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):(e.enter(o),s(p))}function s(p){return p===l?(e.exit(o),u(l)):p===null?n(p):z(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),B(e,s,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===l||p===null||z(p)?(e.exit("chunkString"),s(p)):(e.consume(p),p===92?c:f)}function c(p){return p===l||p===92?(e.consume(p),f):f(p)}}function qe(e,t){let n;return r;function r(i){return z(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):O(i)?B(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Hl={name:"definition",tokenize:ql},Ul={partial:!0,tokenize:Vl};function ql(e,t,n){const r=this;let i;return o;function o(h){return e.enter("definition"),l(h)}function l(h){return wr.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function a(h){return i=se(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),u):n(h)}function u(h){return $(h)?qe(e,s)(h):s(h)}function s(h){return br(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function f(h){return e.attempt(Ul,c,c)(h)}function c(h){return O(h)?B(e,p,"whitespace")(h):p(h)}function p(h){return h===null||z(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function Vl(e,t,n){return r;function r(a){return $(a)?qe(e,i)(a):n(a)}function i(a){return Sr(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function o(a){return O(a)?B(e,l,"whitespace")(a):l(a)}function l(a){return a===null||z(a)?t(a):n(a)}}const $l={name:"hardBreakEscape",tokenize:Wl};function Wl(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return z(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const Yl={name:"headingAtx",resolve:Xl,tokenize:Ql};function Xl(e,t){let n=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},re(e,r,n-r+1,[["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t]])),e}function Ql(e,t,n){let r=0;return i;function i(f){return e.enter("atxHeading"),o(f)}function o(f){return e.enter("atxHeadingSequence"),l(f)}function l(f){return f===35&&r++<6?(e.consume(f),l):f===null||$(f)?(e.exit("atxHeadingSequence"),a(f)):n(f)}function a(f){return f===35?(e.enter("atxHeadingSequence"),u(f)):f===null||z(f)?(e.exit("atxHeading"),t(f)):O(f)?B(e,a,"whitespace")(f):(e.enter("atxHeadingText"),s(f))}function u(f){return f===35?(e.consume(f),u):(e.exit("atxHeadingSequence"),a(f))}function s(f){return f===null||f===35||$(f)?(e.exit("atxHeadingText"),a(f)):(e.consume(f),s)}}const Gl=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Tt=["pre","script","style","textarea"],Kl={concrete:!0,name:"htmlFlow",resolveTo:eo,tokenize:no},Jl={partial:!0,tokenize:ro},Zl={partial:!0,tokenize:to};function eo(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function no(e,t,n){const r=this;let i,o,l,a,u;return s;function s(g){return f(g)}function f(g){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(g),c}function c(g){return g===33?(e.consume(g),p):g===47?(e.consume(g),o=!0,w):g===63?(e.consume(g),i=3,r.interrupt?t:m):J(g)?(e.consume(g),l=String.fromCharCode(g),S):n(g)}function p(g){return g===45?(e.consume(g),i=2,h):g===91?(e.consume(g),i=5,a=0,d):J(g)?(e.consume(g),i=4,r.interrupt?t:m):n(g)}function h(g){return g===45?(e.consume(g),r.interrupt?t:m):n(g)}function d(g){const ae="CDATA[";return g===ae.charCodeAt(a++)?(e.consume(g),a===ae.length?r.interrupt?t:v:d):n(g)}function w(g){return J(g)?(e.consume(g),l=String.fromCharCode(g),S):n(g)}function S(g){if(g===null||g===47||g===62||$(g)){const ae=g===47,be=l.toLowerCase();return!ae&&!o&&Tt.includes(be)?(i=1,r.interrupt?t(g):v(g)):Gl.includes(l.toLowerCase())?(i=6,ae?(e.consume(g),y):r.interrupt?t(g):v(g)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(g):o?I(g):C(g))}return g===45||G(g)?(e.consume(g),l+=String.fromCharCode(g),S):n(g)}function y(g){return g===62?(e.consume(g),r.interrupt?t:v):n(g)}function I(g){return O(g)?(e.consume(g),I):k(g)}function C(g){return g===47?(e.consume(g),k):g===58||g===95||J(g)?(e.consume(g),F):O(g)?(e.consume(g),C):k(g)}function F(g){return g===45||g===46||g===58||g===95||G(g)?(e.consume(g),F):R(g)}function R(g){return g===61?(e.consume(g),b):O(g)?(e.consume(g),R):C(g)}function b(g){return g===null||g===60||g===61||g===62||g===96?n(g):g===34||g===39?(e.consume(g),u=g,M):O(g)?(e.consume(g),b):H(g)}function M(g){return g===u?(e.consume(g),u=null,j):g===null||z(g)?n(g):(e.consume(g),M)}function H(g){return g===null||g===34||g===39||g===47||g===60||g===61||g===62||g===96||$(g)?R(g):(e.consume(g),H)}function j(g){return g===47||g===62||O(g)?C(g):n(g)}function k(g){return g===62?(e.consume(g),P):n(g)}function P(g){return g===null||z(g)?v(g):O(g)?(e.consume(g),P):n(g)}function v(g){return g===45&&i===2?(e.consume(g),q):g===60&&i===1?(e.consume(g),X):g===62&&i===4?(e.consume(g),oe):g===63&&i===3?(e.consume(g),m):g===93&&i===5?(e.consume(g),he):z(g)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Jl,pe,U)(g)):g===null||z(g)?(e.exit("htmlFlowData"),U(g)):(e.consume(g),v)}function U(g){return e.check(Zl,D,pe)(g)}function D(g){return e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),T}function T(g){return g===null||z(g)?U(g):(e.enter("htmlFlowData"),v(g))}function q(g){return g===45?(e.consume(g),m):v(g)}function X(g){return g===47?(e.consume(g),l="",le):v(g)}function le(g){if(g===62){const ae=l.toLowerCase();return Tt.includes(ae)?(e.consume(g),oe):v(g)}return J(g)&&l.length<8?(e.consume(g),l+=String.fromCharCode(g),le):v(g)}function he(g){return g===93?(e.consume(g),m):v(g)}function m(g){return g===62?(e.consume(g),oe):g===45&&i===2?(e.consume(g),m):v(g)}function oe(g){return g===null||z(g)?(e.exit("htmlFlowData"),pe(g)):(e.consume(g),oe)}function pe(g){return e.exit("htmlFlow"),t(g)}}function to(e,t,n){const r=this;return i;function i(l){return z(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),o):n(l)}function o(l){return r.parser.lazy[r.now().line]?n(l):t(l)}}function ro(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Xe,t,n)}}const io={name:"htmlText",tokenize:lo};function lo(e,t,n){const r=this;let i,o,l;return a;function a(m){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(m),u}function u(m){return m===33?(e.consume(m),s):m===47?(e.consume(m),R):m===63?(e.consume(m),C):J(m)?(e.consume(m),H):n(m)}function s(m){return m===45?(e.consume(m),f):m===91?(e.consume(m),o=0,d):J(m)?(e.consume(m),I):n(m)}function f(m){return m===45?(e.consume(m),h):n(m)}function c(m){return m===null?n(m):m===45?(e.consume(m),p):z(m)?(l=c,X(m)):(e.consume(m),c)}function p(m){return m===45?(e.consume(m),h):c(m)}function h(m){return m===62?q(m):m===45?p(m):c(m)}function d(m){const oe="CDATA[";return m===oe.charCodeAt(o++)?(e.consume(m),o===oe.length?w:d):n(m)}function w(m){return m===null?n(m):m===93?(e.consume(m),S):z(m)?(l=w,X(m)):(e.consume(m),w)}function S(m){return m===93?(e.consume(m),y):w(m)}function y(m){return m===62?q(m):m===93?(e.consume(m),y):w(m)}function I(m){return m===null||m===62?q(m):z(m)?(l=I,X(m)):(e.consume(m),I)}function C(m){return m===null?n(m):m===63?(e.consume(m),F):z(m)?(l=C,X(m)):(e.consume(m),C)}function F(m){return m===62?q(m):C(m)}function R(m){return J(m)?(e.consume(m),b):n(m)}function b(m){return m===45||G(m)?(e.consume(m),b):M(m)}function M(m){return z(m)?(l=M,X(m)):O(m)?(e.consume(m),M):q(m)}function H(m){return m===45||G(m)?(e.consume(m),H):m===47||m===62||$(m)?j(m):n(m)}function j(m){return m===47?(e.consume(m),q):m===58||m===95||J(m)?(e.consume(m),k):z(m)?(l=j,X(m)):O(m)?(e.consume(m),j):q(m)}function k(m){return m===45||m===46||m===58||m===95||G(m)?(e.consume(m),k):P(m)}function P(m){return m===61?(e.consume(m),v):z(m)?(l=P,X(m)):O(m)?(e.consume(m),P):j(m)}function v(m){return m===null||m===60||m===61||m===62||m===96?n(m):m===34||m===39?(e.consume(m),i=m,U):z(m)?(l=v,X(m)):O(m)?(e.consume(m),v):(e.consume(m),D)}function U(m){return m===i?(e.consume(m),i=void 0,T):m===null?n(m):z(m)?(l=U,X(m)):(e.consume(m),U)}function D(m){return m===null||m===34||m===39||m===60||m===61||m===96?n(m):m===47||m===62||$(m)?j(m):(e.consume(m),D)}function T(m){return m===47||m===62||$(m)?j(m):n(m)}function q(m){return m===62?(e.consume(m),e.exit("htmlTextData"),e.exit("htmlText"),t):n(m)}function X(m){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),le}function le(m){return O(m)?B(e,he,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):he(m)}function he(m){return e.enter("htmlTextData"),l(m)}}const Qn={name:"labelEnd",resolveAll:so,resolveTo:co,tokenize:fo},oo={tokenize:ho},ao={tokenize:po},uo={tokenize:mo};function so(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&re(e,0,e.length,n),e}function co(e,t){let n=e.length,r=0,i,o,l,a;for(;n--;)if(i=e[n][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(l){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(l=n);const u={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},s={type:"label",start:{...e[o][1].start},end:{...e[l][1].end}},f={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[l-2][1].start}};return a=[["enter",u,t],["enter",s,t]],a=ie(a,e.slice(o+1,o+r+3)),a=ie(a,[["enter",f,t]]),a=ie(a,sn(t.parser.constructs.insideSpan.null,e.slice(o+r+4,l-3),t)),a=ie(a,[["exit",f,t],e[l-2],e[l-1],["exit",s,t]]),a=ie(a,e.slice(l+1)),a=ie(a,[["exit",u,t]]),re(e,o,e.length,a),e}function fo(e,t,n){const r=this;let i=r.events.length,o,l;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return a;function a(p){return o?o._inactive?c(p):(l=r.parser.defined.includes(se(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),u):n(p)}function u(p){return p===40?e.attempt(oo,f,l?f:c)(p):p===91?e.attempt(ao,f,l?s:c)(p):l?f(p):c(p)}function s(p){return e.attempt(uo,f,c)(p)}function f(p){return t(p)}function c(p){return o._balanced=!0,n(p)}}function ho(e,t,n){return r;function r(c){return e.enter("resource"),e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),i}function i(c){return $(c)?qe(e,o)(c):o(c)}function o(c){return c===41?f(c):br(e,l,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function l(c){return $(c)?qe(e,u)(c):f(c)}function a(c){return n(c)}function u(c){return c===34||c===39||c===40?Sr(e,s,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):f(c)}function s(c){return $(c)?qe(e,f)(c):f(c)}function f(c){return c===41?(e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),e.exit("resource"),t):n(c)}}function po(e,t,n){const r=this;return i;function i(a){return wr.call(r,e,o,l,"reference","referenceMarker","referenceString")(a)}function o(a){return r.parser.defined.includes(se(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function l(a){return n(a)}}function mo(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),i}function i(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const go={name:"labelStartImage",resolveAll:Qn.resolveAll,tokenize:yo};function yo(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),o}function o(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),l):n(a)}function l(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const ko={name:"labelStartLink",resolveAll:Qn.resolveAll,tokenize:xo};function xo(e,t,n){const r=this;return i;function i(l){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelLink"),o}function o(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const yn={name:"lineEnding",tokenize:bo};function bo(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),B(e,t,"linePrefix")}}const tn={name:"thematicBreak",tokenize:wo};function wo(e,t,n){let r=0,i;return o;function o(s){return e.enter("thematicBreak"),l(s)}function l(s){return i=s,a(s)}function a(s){return s===i?(e.enter("thematicBreakSequence"),u(s)):r>=3&&(s===null||z(s))?(e.exit("thematicBreak"),t(s)):n(s)}function u(s){return s===i?(e.consume(s),r++,u):(e.exit("thematicBreakSequence"),O(s)?B(e,a,"whitespace")(s):a(s))}}const Z={continuation:{tokenize:Io},exit:To,name:"list",tokenize:Eo},So={partial:!0,tokenize:Po},Co={partial:!0,tokenize:Ao};function Eo(e,t,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,l=0;return a;function a(h){const d=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(d==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Rn(h)){if(r.containerState.type||(r.containerState.type=d,e.enter(d,{_container:!0})),d==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(tn,n,s)(h):s(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(h)}return n(h)}function u(h){return Rn(h)&&++l<10?(e.consume(h),u):(!r.interrupt||l<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),s(h)):n(h)}function s(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(Xe,r.interrupt?n:f,e.attempt(So,p,c))}function f(h){return r.containerState.initialBlankLine=!0,o++,p(h)}function c(h){return O(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),p):n(h)}function p(h){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function Io(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Xe,i,o);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,B(e,t,"listItemIndent",r.containerState.size+1)(a)}function o(a){return r.containerState.furtherBlankLines||!O(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,l(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Co,t,l)(a))}function l(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,B(e,e.attempt(Z,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Ao(e,t,n){const r=this;return B(e,i,"listItemIndent",r.containerState.size+1);function i(o){const l=r.events[r.events.length-1];return l&&l[1].type==="listItemIndent"&&l[2].sliceSerialize(l[1],!0).length===r.containerState.size?t(o):n(o)}}function To(e){e.exit(this.containerState.type)}function Po(e,t,n){const r=this;return B(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const l=r.events[r.events.length-1];return!O(o)&&l&&l[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const Pt={name:"setextUnderline",resolveTo:vo,tokenize:zo};function vo(e,t){let n=e.length,r,i,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const l={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",l,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=l,e.push(["exit",l,t]),e}function zo(e,t,n){const r=this;let i;return o;function o(s){let f=r.events.length,c;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){c=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter("setextHeadingLine"),i=s,l(s)):n(s)}function l(s){return e.enter("setextHeadingLineSequence"),a(s)}function a(s){return s===i?(e.consume(s),a):(e.exit("setextHeadingLineSequence"),O(s)?B(e,u,"lineSuffix")(s):u(s))}function u(s){return s===null||z(s)?(e.exit("setextHeadingLine"),t(s)):n(s)}}const Do={tokenize:Lo};function Lo(e){const t=this,n=e.attempt(Xe,r,e.attempt(this.parser.constructs.flowInitial,i,B(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Ol,i)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Fo={resolveAll:Er()},Ro=Cr("string"),_o=Cr("text");function Cr(e){return{resolveAll:Er(e==="text"?Oo:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],o=n.attempt(i,l,a);return l;function l(f){return s(f)?o(f):a(f)}function a(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),u}function u(f){return s(f)?(n.exit("data"),o(f)):(n.consume(f),u)}function s(f){if(f===null)return!0;const c=i[f];let p=-1;if(c)for(;++p<c.length;){const h=c[p];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function Er(e){return t;function t(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type==="data"&&(o=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(n,r):n}}function Oo(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let o=i.length,l=-1,a=0,u;for(;o--;){const s=i[o];if(typeof s=="string"){for(l=s.length;s.charCodeAt(l-1)===32;)a++,l--;if(l)break;l=-1}else if(s===-2)u=!0,a++;else if(s!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const s={type:n===e.length||u||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?l:r.start._bufferIndex+l,_index:r.start._index+o,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...s.start},r.start.offset===r.end.offset?Object.assign(r,s):(e.splice(n,0,["enter",s,t],["exit",s,t]),n+=2)}n++}return e}const Mo={42:Z,43:Z,45:Z,48:Z,49:Z,50:Z,51:Z,52:Z,53:Z,54:Z,55:Z,56:Z,57:Z,62:dr},No={91:Hl},Bo={[-2]:dn,[-1]:dn,32:dn},jo={35:Yl,42:tn,45:[Pt,tn],60:Kl,61:Pt,95:tn,96:At,126:At},Ho={38:kr,92:yr},Uo={[-5]:yn,[-4]:yn,[-3]:yn,33:go,38:kr,42:_n,60:[yl,io],91:ko,92:[$l,yr],93:Qn,95:_n,96:zl},qo={null:[_n,Fo]},Vo={null:[42,95]},$o={null:[]},Wo=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Vo,contentInitial:No,disable:$o,document:Mo,flow:jo,flowInitial:Bo,insideSpan:qo,string:Ho,text:Uo},Symbol.toStringTag,{value:"Module"}));function Yo(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},o=[];let l=[],a=[];const u={attempt:M(R),check:M(b),consume:I,enter:C,exit:F,interrupt:M(b,{interrupt:!0})},s={code:null,containerState:{},defineSkip:w,events:[],now:d,parser:e,previous:null,sliceSerialize:p,sliceStream:h,write:c};let f=t.tokenize.call(s,u);return t.resolveAll&&o.push(t),s;function c(P){return l=ie(l,P),S(),l[l.length-1]!==null?[]:(H(t,0),s.events=sn(o,s.events,s),s.events)}function p(P,v){return Qo(h(P),v)}function h(P){return Xo(l,P)}function d(){const{_bufferIndex:P,_index:v,line:U,column:D,offset:T}=r;return{_bufferIndex:P,_index:v,line:U,column:D,offset:T}}function w(P){i[P.line]=P.column,k()}function S(){let P;for(;r._index<l.length;){const v=l[r._index];if(typeof v=="string")for(P=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===P&&r._bufferIndex<v.length;)y(v.charCodeAt(r._bufferIndex));else y(v)}}function y(P){f=f(P)}function I(P){z(P)?(r.line++,r.column=1,r.offset+=P===-3?2:1,k()):P!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===l[r._index].length&&(r._bufferIndex=-1,r._index++)),s.previous=P}function C(P,v){const U=v||{};return U.type=P,U.start=d(),s.events.push(["enter",U,s]),a.push(U),U}function F(P){const v=a.pop();return v.end=d(),s.events.push(["exit",v,s]),v}function R(P,v){H(P,v.from)}function b(P,v){v.restore()}function M(P,v){return U;function U(D,T,q){let X,le,he,m;return Array.isArray(D)?pe(D):"tokenize"in D?pe([D]):oe(D);function oe(Q){return _e;function _e(ye){const Ie=ye!==null&&Q[ye],Ae=ye!==null&&Q.null,Ge=[...Array.isArray(Ie)?Ie:Ie?[Ie]:[],...Array.isArray(Ae)?Ae:Ae?[Ae]:[]];return pe(Ge)(ye)}}function pe(Q){return X=Q,le=0,Q.length===0?q:g(Q[le])}function g(Q){return _e;function _e(ye){return m=j(),he=Q,Q.partial||(s.currentConstruct=Q),Q.name&&s.parser.constructs.disable.null.includes(Q.name)?be():Q.tokenize.call(v?Object.assign(Object.create(s),v):s,u,ae,be)(ye)}}function ae(Q){return P(he,m),T}function be(Q){return m.restore(),++le<X.length?g(X[le]):q}}}function H(P,v){P.resolveAll&&!o.includes(P)&&o.push(P),P.resolve&&re(s.events,v,s.events.length-v,P.resolve(s.events.slice(v),s)),P.resolveTo&&(s.events=P.resolveTo(s.events,s))}function j(){const P=d(),v=s.previous,U=s.currentConstruct,D=s.events.length,T=Array.from(a);return{from:D,restore:q};function q(){r=P,s.previous=v,s.currentConstruct=U,s.events.length=D,a=T,k()}}function k(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Xo(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex;let l;if(n===i)l=[e[n].slice(r,o)];else{if(l=e.slice(n,i),r>-1){const a=l[0];typeof a=="string"?l[0]=a.slice(r):l.shift()}o>0&&l.push(e[i].slice(0,o))}return l}function Qo(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const o=e[n];let l;if(typeof o=="string")l=o;else switch(o){case-5:{l="\r";break}case-4:{l=`
3
3
  `;break}case-3:{l=`\r
4
4
  `;break}case-2:{l=t?" ":" ";break}case-1:{if(!t&&i)continue;l=" ";break}default:l=String.fromCharCode(o)}i=o===-2,r.push(l)}return r.join("")}function Go(e){const r={constructs:mr([Wo,...(e||{}).extensions||[]]),content:i(cl),defined:[],document:i(hl),flow:i(Do),lazy:{},string:i(Ro),text:i(_o)};return r;function i(o){return l;function l(a){return Yo(r,o,a)}}}function Ko(e){for(;!xr(e););return e}const vt=/[\0\t\n\r]/g;function Jo(){let e=1,t="",n=!0,r;return i;function i(o,l,a){const u=[];let s,f,c,p,h;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(l||void 0).decode(o)),c=0,t="",n&&(o.charCodeAt(0)===65279&&c++,n=void 0);c<o.length;){if(vt.lastIndex=c,s=vt.exec(o),p=s&&s.index!==void 0?s.index:o.length,h=o.charCodeAt(p),!s){t=o.slice(c);break}if(h===10&&c===p&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<p&&(u.push(o.slice(c,p)),e+=p-c),h){case 0:{u.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,u.push(-2);e++<f;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=p+1}return a&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const Zo=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ea(e){return e.replace(Zo,na)}function na(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return gr(n.slice(o?2:1),o?16:10)}return Xn(n)||e}const Ir={}.hasOwnProperty;function ta(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),ra(n)(Ko(Go(n).document().write(Jo()(e,t,!0))))}function ra(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(ut),autolinkProtocol:j,autolinkEmail:j,atxHeading:o(lt),blockQuote:o(Ae),characterEscape:j,characterReference:j,codeFenced:o(Ge),codeFencedFenceInfo:l,codeFencedFenceMeta:l,codeIndented:o(Ge,l),codeText:o(ii,l),codeTextData:j,data:j,codeFlowValue:j,definition:o(li),definitionDestinationString:l,definitionLabelString:l,definitionTitleString:l,emphasis:o(oi),hardBreakEscape:o(ot),hardBreakTrailing:o(ot),htmlFlow:o(at,l),htmlFlowData:j,htmlText:o(at,l),htmlTextData:j,image:o(ai),label:l,link:o(ut),listItem:o(ui),listItemValue:p,listOrdered:o(st,c),listUnordered:o(st),paragraph:o(si),reference:g,referenceString:l,resourceDestinationString:l,resourceTitleString:l,setextHeading:o(lt),strong:o(ci),thematicBreak:o(hi)},exit:{atxHeading:u(),atxHeadingSequence:R,autolink:u(),autolinkEmail:Ie,autolinkProtocol:ye,blockQuote:u(),characterEscapeValue:k,characterReferenceMarkerHexadecimal:be,characterReferenceMarkerNumeric:be,characterReferenceValue:Q,characterReference:_e,codeFenced:u(S),codeFencedFence:w,codeFencedFenceInfo:h,codeFencedFenceMeta:d,codeFlowValue:k,codeIndented:u(y),codeText:u(T),codeTextData:k,data:k,definition:u(),definitionDestinationString:F,definitionLabelString:I,definitionTitleString:C,emphasis:u(),hardBreakEscape:u(v),hardBreakTrailing:u(v),htmlFlow:u(U),htmlFlowData:k,htmlText:u(D),htmlTextData:k,image:u(X),label:he,labelText:le,lineEnding:P,link:u(q),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:ae,resourceDestinationString:m,resourceTitleString:oe,resource:pe,setextHeading:u(H),setextHeadingLineSequence:M,setextHeadingText:b,strong:u(),thematicBreak:u()}};Ar(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(x){let A={type:"root",children:[]};const L={stack:[A],tokenStack:[],config:t,enter:a,exit:s,buffer:l,resume:f,data:n},N=[];let V=-1;for(;++V<x.length;)if(x[V][1].type==="listOrdered"||x[V][1].type==="listUnordered")if(x[V][0]==="enter")N.push(V);else{const ue=N.pop();V=i(x,ue,V)}for(V=-1;++V<x.length;){const ue=t[x[V][0]];Ir.call(ue,x[V][1].type)&&ue[x[V][1].type].call(Object.assign({sliceSerialize:x[V][2].sliceSerialize},L),x[V][1])}if(L.tokenStack.length>0){const ue=L.tokenStack[L.tokenStack.length-1];(ue[1]||zt).call(L,void 0,ue[0])}for(A.position={start:ke(x.length>0?x[0][1].start:{line:1,column:1,offset:0}),end:ke(x.length>0?x[x.length-2][1].end:{line:1,column:1,offset:0})},V=-1;++V<t.transforms.length;)A=t.transforms[V](A)||A;return A}function i(x,A,L){let N=A-1,V=-1,ue=!1,we,me,Oe,Me;for(;++N<=L;){const ne=x[N];switch(ne[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ne[0]==="enter"?V++:V--,Me=void 0;break}case"lineEndingBlank":{ne[0]==="enter"&&(we&&!Me&&!V&&!Oe&&(Oe=N),Me=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Me=void 0}if(!V&&ne[0]==="enter"&&ne[1].type==="listItemPrefix"||V===-1&&ne[0]==="exit"&&(ne[1].type==="listUnordered"||ne[1].type==="listOrdered")){if(we){let Te=N;for(me=void 0;Te--;){const ge=x[Te];if(ge[1].type==="lineEnding"||ge[1].type==="lineEndingBlank"){if(ge[0]==="exit")continue;me&&(x[me][1].type="lineEndingBlank",ue=!0),ge[1].type="lineEnding",me=Te}else if(!(ge[1].type==="linePrefix"||ge[1].type==="blockQuotePrefix"||ge[1].type==="blockQuotePrefixWhitespace"||ge[1].type==="blockQuoteMarker"||ge[1].type==="listItemIndent"))break}Oe&&(!me||Oe<me)&&(we._spread=!0),we.end=Object.assign({},me?x[me][1].start:ne[1].end),x.splice(me||N,0,["exit",we,ne[2]]),N++,L++}if(ne[1].type==="listItemPrefix"){const Te={type:"listItem",_spread:!1,start:Object.assign({},ne[1].start),end:void 0};we=Te,x.splice(N,0,["enter",Te,ne[2]]),N++,L++,Oe=void 0,Me=!0}}}return x[A][1]._spread=ue,L}function o(x,A){return L;function L(N){a.call(this,x(N),N),A&&A.call(this,N)}}function l(){this.stack.push({type:"fragment",children:[]})}function a(x,A,L){this.stack[this.stack.length-1].children.push(x),this.stack.push(x),this.tokenStack.push([A,L||void 0]),x.position={start:ke(A.start),end:void 0}}function u(x){return A;function A(L){x&&x.call(this,L),s.call(this,L)}}function s(x,A){const L=this.stack.pop(),N=this.tokenStack.pop();if(N)N[0].type!==x.type&&(A?A.call(this,x,N[0]):(N[1]||zt).call(this,x,N[0]));else throw new Error("Cannot close `"+x.type+"` ("+Ue({start:x.start,end:x.end})+"): it’s not open");L.position.end=ke(x.end)}function f(){return Yn(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function p(x){if(this.data.expectingFirstListItemValue){const A=this.stack[this.stack.length-2];A.start=Number.parseInt(this.sliceSerialize(x),10),this.data.expectingFirstListItemValue=void 0}}function h(){const x=this.resume(),A=this.stack[this.stack.length-1];A.lang=x}function d(){const x=this.resume(),A=this.stack[this.stack.length-1];A.meta=x}function w(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function S(){const x=this.resume(),A=this.stack[this.stack.length-1];A.value=x.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const x=this.resume(),A=this.stack[this.stack.length-1];A.value=x.replace(/(\r?\n|\r)$/g,"")}function I(x){const A=this.resume(),L=this.stack[this.stack.length-1];L.label=A,L.identifier=se(this.sliceSerialize(x)).toLowerCase()}function C(){const x=this.resume(),A=this.stack[this.stack.length-1];A.title=x}function F(){const x=this.resume(),A=this.stack[this.stack.length-1];A.url=x}function R(x){const A=this.stack[this.stack.length-1];if(!A.depth){const L=this.sliceSerialize(x).length;A.depth=L}}function b(){this.data.setextHeadingSlurpLineEnding=!0}function M(x){const A=this.stack[this.stack.length-1];A.depth=this.sliceSerialize(x).codePointAt(0)===61?1:2}function H(){this.data.setextHeadingSlurpLineEnding=void 0}function j(x){const L=this.stack[this.stack.length-1].children;let N=L[L.length-1];(!N||N.type!=="text")&&(N=fi(),N.position={start:ke(x.start),end:void 0},L.push(N)),this.stack.push(N)}function k(x){const A=this.stack.pop();A.value+=this.sliceSerialize(x),A.position.end=ke(x.end)}function P(x){const A=this.stack[this.stack.length-1];if(this.data.atHardBreak){const L=A.children[A.children.length-1];L.position.end=ke(x.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(A.type)&&(j.call(this,x),k.call(this,x))}function v(){this.data.atHardBreak=!0}function U(){const x=this.resume(),A=this.stack[this.stack.length-1];A.value=x}function D(){const x=this.resume(),A=this.stack[this.stack.length-1];A.value=x}function T(){const x=this.resume(),A=this.stack[this.stack.length-1];A.value=x}function q(){const x=this.stack[this.stack.length-1];if(this.data.inReference){const A=this.data.referenceType||"shortcut";x.type+="Reference",x.referenceType=A,delete x.url,delete x.title}else delete x.identifier,delete x.label;this.data.referenceType=void 0}function X(){const x=this.stack[this.stack.length-1];if(this.data.inReference){const A=this.data.referenceType||"shortcut";x.type+="Reference",x.referenceType=A,delete x.url,delete x.title}else delete x.identifier,delete x.label;this.data.referenceType=void 0}function le(x){const A=this.sliceSerialize(x),L=this.stack[this.stack.length-2];L.label=ea(A),L.identifier=se(A).toLowerCase()}function he(){const x=this.stack[this.stack.length-1],A=this.resume(),L=this.stack[this.stack.length-1];if(this.data.inReference=!0,L.type==="link"){const N=x.children;L.children=N}else L.alt=A}function m(){const x=this.resume(),A=this.stack[this.stack.length-1];A.url=x}function oe(){const x=this.resume(),A=this.stack[this.stack.length-1];A.title=x}function pe(){this.data.inReference=void 0}function g(){this.data.referenceType="collapsed"}function ae(x){const A=this.resume(),L=this.stack[this.stack.length-1];L.label=A,L.identifier=se(this.sliceSerialize(x)).toLowerCase(),this.data.referenceType="full"}function be(x){this.data.characterReferenceType=x.type}function Q(x){const A=this.sliceSerialize(x),L=this.data.characterReferenceType;let N;L?(N=gr(A,L==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):N=Xn(A);const V=this.stack[this.stack.length-1];V.value+=N}function _e(x){const A=this.stack.pop();A.position.end=ke(x.end)}function ye(x){k.call(this,x);const A=this.stack[this.stack.length-1];A.url=this.sliceSerialize(x)}function Ie(x){k.call(this,x);const A=this.stack[this.stack.length-1];A.url="mailto:"+this.sliceSerialize(x)}function Ae(){return{type:"blockquote",children:[]}}function Ge(){return{type:"code",lang:null,meta:null,value:""}}function ii(){return{type:"inlineCode",value:""}}function li(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function oi(){return{type:"emphasis",children:[]}}function lt(){return{type:"heading",depth:0,children:[]}}function ot(){return{type:"break"}}function at(){return{type:"html",value:""}}function ai(){return{type:"image",title:null,url:"",alt:null}}function ut(){return{type:"link",title:null,url:"",children:[]}}function st(x){return{type:"list",ordered:x.type==="listOrdered",start:null,spread:x._spread,children:[]}}function ui(x){return{type:"listItem",spread:x._spread,checked:null,children:[]}}function si(){return{type:"paragraph",children:[]}}function ci(){return{type:"strong",children:[]}}function fi(){return{type:"text",value:""}}function hi(){return{type:"thematicBreak"}}}function ke(e){return{line:e.line,column:e.column,offset:e.offset}}function Ar(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Ar(e,r):ia(e,r)}}function ia(e,t){let n;for(n in t)if(Ir.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function zt(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Ue({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Ue({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Ue({start:t.start,end:t.end})+") is still open")}function la(e){const t=this;t.parser=n;function n(r){return ta(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function oa(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function aa(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
@@ -10,8 +10,8 @@ Error generating stack: `+l.message+`
10
10
  To pick up a draggable item, press the space bar.
11
11
  While dragging, use the arrow keys to move the item.
12
12
  Press space again to drop the item in its new position, or press escape to cancel.
13
- `},cx={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function ux(e){let{announcements:t=cx,container:n,hiddenTextDescribedById:a,screenReaderInstructions:o=ox}=e;const{announce:c,announcement:d}=rx(),p=ku("DndLiveRegion"),[m,f]=g.useState(!1);if(g.useEffect(()=>{f(!0)},[]),ax(g.useMemo(()=>({onDragStart(y){let{active:w}=y;c(t.onDragStart({active:w}))},onDragMove(y){let{active:w,over:x}=y;t.onDragMove&&c(t.onDragMove({active:w,over:x}))},onDragOver(y){let{active:w,over:x}=y;c(t.onDragOver({active:w,over:x}))},onDragEnd(y){let{active:w,over:x}=y;c(t.onDragEnd({active:w,over:x}))},onDragCancel(y){let{active:w,over:x}=y;c(t.onDragCancel({active:w,over:x}))}}),[c,t])),!m)return null;const S=xi.createElement(xi.Fragment,null,xi.createElement(sx,{id:a,value:o.draggable}),xi.createElement(nx,{id:p,announcement:d}));return n?Il.createPortal(S,n):S}var ni;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ni||(ni={}));function cu(){}function ky(e,t){return g.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function hx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g.useMemo(()=>[...t].filter(a=>a!=null),[...t])}const Ns=Object.freeze({x:0,y:0});function dx(e,t){let{data:{value:n}}=e,{data:{value:a}}=t;return a-n}function fx(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function px(e,t){const n=Math.max(t.top,e.top),a=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),d=o-a,p=c-n;if(a<o&&n<c){const m=t.width*t.height,f=e.width*e.height,S=d*p,y=S/(m+f-S);return Number(y.toFixed(4))}return 0}const mx=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:a}=e;const o=[];for(const c of a){const{id:d}=c,p=n.get(d);if(p){const m=px(p,t);m>0&&o.push({id:d,data:{droppableContainer:c,value:m}})}}return o.sort(dx)};function _x(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function kb(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ns}function vx(e){return function(n){for(var a=arguments.length,o=new Array(a>1?a-1:0),c=1;c<a;c++)o[c-1]=arguments[c];return o.reduce((d,p)=>({...d,top:d.top+e*p.y,bottom:d.bottom+e*p.y,left:d.left+e*p.x,right:d.right+e*p.x}),{...n})}}const gx=vx(1);function yx(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Sx(e,t,n){const a=yx(t);if(!a)return e;const{scaleX:o,scaleY:c,x:d,y:p}=a,m=e.left-d-(1-o)*parseFloat(n),f=e.top-p-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),S=o?e.width/o:e.width,y=c?e.height/c:e.height;return{width:S,height:y,top:f,right:m+S,bottom:f+y,left:m}}const bx={ignoreTransform:!1};function bo(e,t){t===void 0&&(t=bx);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:S}=$i(e).getComputedStyle(e);f&&(n=Sx(n,f,S))}const{top:a,left:o,width:c,height:d,bottom:p,right:m}=n;return{top:a,left:o,width:c,height:d,bottom:p,right:m}}function Dy(e){return bo(e,{ignoreTransform:!0})}function wx(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Cx(e,t){return t===void 0&&(t=$i(e).getComputedStyle(e)),t.position==="fixed"}function xx(e,t){t===void 0&&(t=$i(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?n.test(c):!1})}function Zp(e,t){const n=[];function a(o){if(t!=null&&n.length>=t||!o)return n;if(Xp(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!yo(o)||Cb(o)||n.includes(o))return n;const c=$i(e).getComputedStyle(o);return o!==e&&xx(o,c)&&n.push(o),Cx(o,c)?n:a(o.parentNode)}return e?a(e):n}function Db(e){const[t]=Zp(e,1);return t??null}function Gd(e){return!Tu||!e?null:za(e)?e:Vp(e)?Xp(e)||e===ja(e).scrollingElement?window:yo(e)?e:null:null}function Rb(e){return za(e)?e.scrollX:e.scrollLeft}function Mb(e){return za(e)?e.scrollY:e.scrollTop}function kf(e){return{x:Rb(e),y:Mb(e)}}var ui;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ui||(ui={}));function Ab(e){return!Tu||!e?!1:e===document.scrollingElement}function Nb(e){const t={x:0,y:0},n=Ab(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,d=e.scrollTop>=a.y,p=e.scrollLeft>=a.x;return{isTop:o,isLeft:c,isBottom:d,isRight:p,maxScroll:a,minScroll:t}}const Ex={x:.2,y:.2};function Tx(e,t,n,a,o){let{top:c,left:d,right:p,bottom:m}=n;a===void 0&&(a=10),o===void 0&&(o=Ex);const{isTop:f,isBottom:S,isLeft:y,isRight:w}=Nb(e),x={x:0,y:0},C={x:0,y:0},k={height:t.height*o.y,width:t.width*o.x};return!f&&c<=t.top+k.height?(x.y=ui.Backward,C.y=a*Math.abs((t.top+k.height-c)/k.height)):!S&&m>=t.bottom-k.height&&(x.y=ui.Forward,C.y=a*Math.abs((t.bottom-k.height-m)/k.height)),!w&&p>=t.right-k.width?(x.x=ui.Forward,C.x=a*Math.abs((t.right-k.width-p)/k.width)):!y&&d<=t.left+k.width&&(x.x=ui.Backward,C.x=a*Math.abs((t.left+k.width-d)/k.width)),{direction:x,speed:C}}function kx(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:d}=window;return{top:0,left:0,right:c,bottom:d,width:c,height:d}}const{top:t,left:n,right:a,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:a,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Bb(e){return e.reduce((t,n)=>Aa(t,kf(n)),Ns)}function Dx(e){return e.reduce((t,n)=>t+Rb(n),0)}function Rx(e){return e.reduce((t,n)=>t+Mb(n),0)}function Mx(e,t){if(t===void 0&&(t=bo),!e)return;const{top:n,left:a,bottom:o,right:c}=t(e);Db(e)&&(o<=0||c<=0||n>=window.innerHeight||a>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Ax=[["x",["left","right"],Dx],["y",["top","bottom"],Rx]];class Qp{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const a=Zp(n),o=Bb(a);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,d,p]of Ax)for(const m of d)Object.defineProperty(this,m,{get:()=>{const f=p(a),S=o[c]-f;return this.rect[m]+S},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Gl{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var a;return(a=this.target)==null?void 0:a.removeEventListener(...n)})},this.target=t}add(t,n,a){var o;(o=this.target)==null||o.addEventListener(t,n,a),this.listeners.push([t,n,a])}}function Nx(e){const{EventTarget:t}=$i(e);return e instanceof t?e:ja(e)}function Zd(e,t){const n=Math.abs(e.x),a=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+a**2)>t:"x"in t&&"y"in t?n>t.x&&a>t.y:"x"in t?n>t.x:"y"in t?a>t.y:!1}var bs;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(bs||(bs={}));function Ry(e){e.preventDefault()}function Bx(e){e.stopPropagation()}var vt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(vt||(vt={}));const Lb={start:[vt.Space,vt.Enter],cancel:[vt.Esc],end:[vt.Space,vt.Enter,vt.Tab]},Lx=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case vt.Right:return{...n,x:n.x+25};case vt.Left:return{...n,x:n.x-25};case vt.Down:return{...n,y:n.y+25};case vt.Up:return{...n,y:n.y-25}}};class Ob{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Gl(ja(n)),this.windowListeners=new Gl($i(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(bs.Resize,this.handleCancel),this.windowListeners.add(bs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(bs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,a=t.node.current;a&&Mx(a),n(Ns)}handleKeyDown(t){if(Eb(t)){const{active:n,context:a,options:o}=this.props,{keyboardCodes:c=Lb,coordinateGetter:d=Lx,scrollBehavior:p="smooth"}=o,{code:m}=t;if(c.end.includes(m)){this.handleEnd(t);return}if(c.cancel.includes(m)){this.handleCancel(t);return}const{collisionRect:f}=a.current,S=f?{x:f.left,y:f.top}:Ns;this.referenceCoordinates||(this.referenceCoordinates=S);const y=d(t,{active:n,context:a.current,currentCoordinates:S});if(y){const w=ou(y,S),x={x:0,y:0},{scrollableAncestors:C}=a.current;for(const k of C){const L=t.code,{isTop:R,isRight:ae,isLeft:q,isBottom:G,maxScroll:ue,minScroll:F}=Nb(k),P=kx(k),M={x:Math.min(L===vt.Right?P.right-P.width/2:P.right,Math.max(L===vt.Right?P.left:P.left+P.width/2,y.x)),y:Math.min(L===vt.Down?P.bottom-P.height/2:P.bottom,Math.max(L===vt.Down?P.top:P.top+P.height/2,y.y))},Q=L===vt.Right&&!ae||L===vt.Left&&!q,ne=L===vt.Down&&!G||L===vt.Up&&!R;if(Q&&M.x!==y.x){const Z=k.scrollLeft+w.x,K=L===vt.Right&&Z<=ue.x||L===vt.Left&&Z>=F.x;if(K&&!w.y){k.scrollTo({left:Z,behavior:p});return}K?x.x=k.scrollLeft-Z:x.x=L===vt.Right?k.scrollLeft-ue.x:k.scrollLeft-F.x,x.x&&k.scrollBy({left:-x.x,behavior:p});break}else if(ne&&M.y!==y.y){const Z=k.scrollTop+w.y,K=L===vt.Down&&Z<=ue.y||L===vt.Up&&Z>=F.y;if(K&&!w.x){k.scrollTo({top:Z,behavior:p});return}K?x.y=k.scrollTop-Z:x.y=L===vt.Down?k.scrollTop-ue.y:k.scrollTop-F.y,x.y&&k.scrollBy({top:-x.y,behavior:p});break}}this.handleMove(t,Aa(ou(y,this.referenceCoordinates),x))}}}handleMove(t,n){const{onMove:a}=this.props;t.preventDefault(),a(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Ob.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:a=Lb,onActivation:o}=t,{active:c}=n;const{code:d}=e.nativeEvent;if(a.start.includes(d)){const p=c.activatorNode.current;return p&&e.target!==p?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function My(e){return!!(e&&"distance"in e)}function Ay(e){return!!(e&&"delay"in e)}class Jp{constructor(t,n,a){var o;a===void 0&&(a=Nx(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:c}=t,{target:d}=c;this.props=t,this.events=n,this.document=ja(d),this.documentListeners=new Gl(this.document),this.listeners=new Gl(a),this.windowListeners=new Gl($i(d)),this.initialCoordinates=(o=Ef(c))!=null?o:Ns,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:a}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(bs.Resize,this.handleCancel),this.windowListeners.add(bs.DragStart,Ry),this.windowListeners.add(bs.VisibilityChange,this.handleCancel),this.windowListeners.add(bs.ContextMenu,Ry),this.documentListeners.add(bs.Keydown,this.handleKeydown),n){if(a!=null&&a({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ay(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(My(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:a,onPending:o}=this.props;o(a,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(bs.Click,Bx,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(bs.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:a,initialCoordinates:o,props:c}=this,{onMove:d,options:{activationConstraint:p}}=c;if(!o)return;const m=(n=Ef(t))!=null?n:Ns,f=ou(o,m);if(!a&&p){if(My(p)){if(p.tolerance!=null&&Zd(f,p.tolerance))return this.handleCancel();if(Zd(f,p.distance))return this.handleStart()}if(Ay(p)&&Zd(f,p.tolerance))return this.handleCancel();this.handlePending(p,f);return}t.cancelable&&t.preventDefault(),d(m)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===vt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Ox={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class zb extends Jp{constructor(t){const{event:n}=t,a=ja(n.target);super(t,Ox,a)}}zb.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:a}=t;return!n.isPrimary||n.button!==0?!1:(a?.({event:n}),!0)}}];const zx={move:{name:"mousemove"},end:{name:"mouseup"}};var Df;(function(e){e[e.RightClick=2]="RightClick"})(Df||(Df={}));class jb extends Jp{constructor(t){super(t,zx,ja(t.event.target))}}jb.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:a}=t;return n.button===Df.RightClick?!1:(a?.({event:n}),!0)}}];const Qd={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Hb extends Jp{constructor(t){super(t,Qd)}static setup(){return window.addEventListener(Qd.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Qd.move.name,t)};function t(){}}}Hb.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:a}=t;const{touches:o}=n;return o.length>1?!1:(a?.({event:n}),!0)}}];var Zl;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Zl||(Zl={}));var uu;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(uu||(uu={}));function jx(e){let{acceleration:t,activator:n=Zl.Pointer,canScroll:a,draggingRect:o,enabled:c,interval:d=5,order:p=uu.TreeOrder,pointerCoordinates:m,scrollableAncestors:f,scrollableAncestorRects:S,delta:y,threshold:w}=e;const x=Ux({delta:y,disabled:!c}),[C,k]=QC(),L=g.useRef({x:0,y:0}),R=g.useRef({x:0,y:0}),ae=g.useMemo(()=>{switch(n){case Zl.Pointer:return m?{top:m.y,bottom:m.y,left:m.x,right:m.x}:null;case Zl.DraggableRect:return o}},[n,o,m]),q=g.useRef(null),G=g.useCallback(()=>{const F=q.current;if(!F)return;const P=L.current.x*R.current.x,M=L.current.y*R.current.y;F.scrollBy(P,M)},[]),ue=g.useMemo(()=>p===uu.TreeOrder?[...f].reverse():f,[p,f]);g.useEffect(()=>{if(!c||!f.length||!ae){k();return}for(const F of ue){if(a?.(F)===!1)continue;const P=f.indexOf(F),M=S[P];if(!M)continue;const{direction:Q,speed:ne}=Tx(F,M,ae,t,w);for(const Z of["x","y"])x[Z][Q[Z]]||(ne[Z]=0,Q[Z]=0);if(ne.x>0||ne.y>0){k(),q.current=F,C(G,d),L.current=ne,R.current=Q;return}}L.current={x:0,y:0},R.current={x:0,y:0},k()},[t,G,a,k,c,d,JSON.stringify(ae),JSON.stringify(x),C,f,ue,S,JSON.stringify(w)])}const Hx={x:{[ui.Backward]:!1,[ui.Forward]:!1},y:{[ui.Backward]:!1,[ui.Forward]:!1}};function Ux(e){let{delta:t,disabled:n}=e;const a=xf(t);return So(o=>{if(n||!a||!o)return Hx;const c={x:Math.sign(t.x-a.x),y:Math.sign(t.y-a.y)};return{x:{[ui.Backward]:o.x[ui.Backward]||c.x===-1,[ui.Forward]:o.x[ui.Forward]||c.x===1},y:{[ui.Backward]:o.y[ui.Backward]||c.y===-1,[ui.Forward]:o.y[ui.Forward]||c.y===1}}},[n,t,a])}function Px(e,t){const n=t!=null?e.get(t):void 0,a=n?n.node.current:null;return So(o=>{var c;return t==null?null:(c=a??o)!=null?c:null},[a,t])}function Kx(e,t){return g.useMemo(()=>e.reduce((n,a)=>{const{sensor:o}=a,c=o.activators.map(d=>({eventName:d.eventName,handler:t(d.handler,a)}));return[...n,...c]},[]),[e,t])}var no;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(no||(no={}));var Rf;(function(e){e.Optimized="optimized"})(Rf||(Rf={}));const Ny=new Map;function Ix(e,t){let{dragging:n,dependencies:a,config:o}=t;const[c,d]=g.useState(null),{frequency:p,measure:m,strategy:f}=o,S=g.useRef(e),y=L(),w=so(y),x=g.useCallback(function(R){R===void 0&&(R=[]),!w.current&&d(ae=>ae===null?R:ae.concat(R.filter(q=>!ae.includes(q))))},[w]),C=g.useRef(null),k=So(R=>{if(y&&!n)return Ny;if(!R||R===Ny||S.current!==e||c!=null){const ae=new Map;for(let q of e){if(!q)continue;if(c&&c.length>0&&!c.includes(q.id)&&q.rect.current){ae.set(q.id,q.rect.current);continue}const G=q.node.current,ue=G?new Qp(m(G),G):null;q.rect.current=ue,ue&&ae.set(q.id,ue)}return ae}return R},[e,c,n,y,m]);return g.useEffect(()=>{S.current=e},[e]),g.useEffect(()=>{y||x()},[n,y]),g.useEffect(()=>{c&&c.length>0&&d(null)},[JSON.stringify(c)]),g.useEffect(()=>{y||typeof p!="number"||C.current!==null||(C.current=setTimeout(()=>{x(),C.current=null},p))},[p,y,x,...a]),{droppableRects:k,measureDroppableContainers:x,measuringScheduled:c!=null};function L(){switch(f){case no.Always:return!1;case no.BeforeDragging:return n;default:return!n}}}function Ub(e,t){return So(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Fx(e,t){return Ub(e,t)}function qx(e){let{callback:t,disabled:n}=e;const a=Gp(t),o=g.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(a)},[a,n]);return g.useEffect(()=>()=>o?.disconnect(),[o]),o}function Du(e){let{callback:t,disabled:n}=e;const a=Gp(t),o=g.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(a)},[n]);return g.useEffect(()=>()=>o?.disconnect(),[o]),o}function Wx(e){return new Qp(bo(e),e)}function By(e,t,n){t===void 0&&(t=Wx);const[a,o]=g.useState(null);function c(){o(m=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=m??n)!=null?f:null}const S=t(e);return JSON.stringify(m)===JSON.stringify(S)?m:S})}const d=qx({callback(m){if(e)for(const f of m){const{type:S,target:y}=f;if(S==="childList"&&y instanceof HTMLElement&&y.contains(e)){c();break}}}}),p=Du({callback:c});return ar(()=>{c(),e?(p?.observe(e),d?.observe(document.body,{childList:!0,subtree:!0})):(p?.disconnect(),d?.disconnect())},[e]),a}function Yx(e){const t=Ub(e);return kb(e,t)}const Ly=[];function $x(e){const t=g.useRef(e),n=So(a=>e?a&&a!==Ly&&e&&t.current&&e.parentNode===t.current.parentNode?a:Zp(e):Ly,[e]);return g.useEffect(()=>{t.current=e},[e]),n}function Vx(e){const[t,n]=g.useState(null),a=g.useRef(e),o=g.useCallback(c=>{const d=Gd(c.target);d&&n(p=>p?(p.set(d,kf(d)),new Map(p)):null)},[]);return g.useEffect(()=>{const c=a.current;if(e!==c){d(c);const p=e.map(m=>{const f=Gd(m);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,kf(f)]):null}).filter(m=>m!=null);n(p.length?new Map(p):null),a.current=e}return()=>{d(e),d(c)};function d(p){p.forEach(m=>{const f=Gd(m);f?.removeEventListener("scroll",o)})}},[o,e]),g.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,d)=>Aa(c,d),Ns):Bb(e):Ns,[e,t])}function Oy(e,t){t===void 0&&(t=[]);const n=g.useRef(null);return g.useEffect(()=>{n.current=null},t),g.useEffect(()=>{const a=e!==Ns;a&&!n.current&&(n.current=e),!a&&n.current&&(n.current=null)},[e]),n.current?ou(e,n.current):Ns}function Xx(e){g.useEffect(()=>{if(!Tu)return;const t=e.map(n=>{let{sensor:a}=n;return a.setup==null?void 0:a.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function Gx(e,t){return g.useMemo(()=>e.reduce((n,a)=>{let{eventName:o,handler:c}=a;return n[o]=d=>{c(d,t)},n},{}),[e,t])}function Pb(e){return g.useMemo(()=>e?wx(e):null,[e])}const zy=[];function Zx(e,t){t===void 0&&(t=bo);const[n]=e,a=Pb(n?$i(n):null),[o,c]=g.useState(zy);function d(){c(()=>e.length?e.map(m=>Ab(m)?a:new Qp(t(m),m)):zy)}const p=Du({callback:d});return ar(()=>{p?.disconnect(),d(),e.forEach(m=>p?.observe(m))},[e]),o}function Qx(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return yo(t)?t:e}function Jx(e){let{measure:t}=e;const[n,a]=g.useState(null),o=g.useCallback(f=>{for(const{target:S}of f)if(yo(S)){a(y=>{const w=t(S);return y?{...y,width:w.width,height:w.height}:w});break}},[t]),c=Du({callback:o}),d=g.useCallback(f=>{const S=Qx(f);c?.disconnect(),S&&c?.observe(S),a(S?t(S):null)},[t,c]),[p,m]=lu(d);return g.useMemo(()=>({nodeRef:p,rect:n,setRef:m}),[n,p,m])}const eE=[{sensor:zb,options:{}},{sensor:Ob,options:{}}],tE={current:{}},Gc={draggable:{measure:Dy},droppable:{measure:Dy,strategy:no.WhileDragging,frequency:Rf.Optimized},dragOverlay:{measure:bo}};class Ql extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,a;return(n=(a=this.get(t))==null?void 0:a.node.current)!=null?n:void 0}}const iE={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ql,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:cu},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Gc,measureDroppableContainers:cu,windowRect:null,measuringScheduled:!1},sE={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:cu,draggableNodes:new Map,over:null,measureDroppableContainers:cu},Ru=g.createContext(sE),nE=g.createContext(iE);function rE(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ql}}}function aE(e,t){switch(t.type){case ni.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case ni.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case ni.DragEnd:case ni.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ni.RegisterDroppable:{const{element:n}=t,{id:a}=n,o=new Ql(e.droppable.containers);return o.set(a,n),{...e,droppable:{...e.droppable,containers:o}}}case ni.SetDroppableDisabled:{const{id:n,key:a,disabled:o}=t,c=e.droppable.containers.get(n);if(!c||a!==c.key)return e;const d=new Ql(e.droppable.containers);return d.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:d}}}case ni.UnregisterDroppable:{const{id:n,key:a}=t,o=e.droppable.containers.get(n);if(!o||a!==o.key)return e;const c=new Ql(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function lE(e){let{disabled:t}=e;const{active:n,activatorEvent:a,draggableNodes:o}=g.useContext(Ru),c=xf(a),d=xf(n?.id);return g.useEffect(()=>{if(!t&&!a&&c&&d!=null){if(!Eb(c)||document.activeElement===c.target)return;const p=o.get(d);if(!p)return;const{activatorNode:m,node:f}=p;if(!m.current&&!f.current)return;requestAnimationFrame(()=>{for(const S of[m.current,f.current]){if(!S)continue;const y=tx(S);if(y){y.focus();break}}})}},[a,t,o,d,c]),null}function oE(e,t){let{transform:n,...a}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...a}),n):n}function cE(e){return g.useMemo(()=>({draggable:{...Gc.draggable,...e?.draggable},droppable:{...Gc.droppable,...e?.droppable},dragOverlay:{...Gc.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function uE(e){let{activeNode:t,measure:n,initialRect:a,config:o=!0}=e;const c=g.useRef(!1),{x:d,y:p}=typeof o=="boolean"?{x:o,y:o}:o;ar(()=>{if(!d&&!p||!t){c.current=!1;return}if(c.current||!a)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const S=n(f),y=kb(S,a);if(d||(y.x=0),p||(y.y=0),c.current=!0,Math.abs(y.x)>0||Math.abs(y.y)>0){const w=Db(f);w&&w.scrollBy({top:y.y,left:y.x})}},[t,d,p,a,n])}const Kb=g.createContext({...Ns,scaleX:1,scaleY:1});var er;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(er||(er={}));const hE=g.memo(function(t){var n,a,o,c;let{id:d,accessibility:p,autoScroll:m=!0,children:f,sensors:S=eE,collisionDetection:y=mx,measuring:w,modifiers:x,...C}=t;const k=g.useReducer(aE,void 0,rE),[L,R]=k,[ae,q]=lx(),[G,ue]=g.useState(er.Uninitialized),F=G===er.Initialized,{draggable:{active:P,nodes:M,translate:Q},droppable:{containers:ne}}=L,Z=P!=null?M.get(P):null,K=g.useRef({initial:null,translated:null}),j=g.useMemo(()=>{var ot;return P!=null?{id:P,data:(ot=Z?.data)!=null?ot:tE,rect:K}:null},[P,Z]),te=g.useRef(null),[se,N]=g.useState(null),[$,X]=g.useState(null),ve=so(C,Object.values(C)),Se=ku("DndDescribedBy",d),E=g.useMemo(()=>ne.getEnabled(),[ne]),W=cE(w),{droppableRects:J,measureDroppableContainers:he,measuringScheduled:ge}=Ix(E,{dragging:F,dependencies:[Q.x,Q.y],config:W.droppable}),pe=Px(M,P),Ce=g.useMemo(()=>$?Ef($):null,[$]),Oe=ks(),Ne=Fx(pe,W.draggable.measure);uE({activeNode:P!=null?M.get(P):null,config:Oe.layoutShiftCompensation,initialRect:Ne,measure:W.draggable.measure});const Re=By(pe,W.draggable.measure,Ne),Ue=By(pe?pe.parentElement:null),Ye=g.useRef({activatorEvent:null,active:null,activeNode:pe,collisionRect:null,collisions:null,droppableRects:J,draggableNodes:M,draggingNode:null,draggingNodeRect:null,droppableContainers:ne,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Be=ne.getNodeFor((n=Ye.current.over)==null?void 0:n.id),le=Jx({measure:W.dragOverlay.measure}),Ee=(a=le.nodeRef.current)!=null?a:pe,xe=F?(o=le.rect)!=null?o:Re:null,Ke=!!(le.nodeRef.current&&le.rect),Xe=Yx(Ke?null:Re),gt=Pb(Ee?$i(Ee):null),yt=$x(F?Be??pe:null),mi=Zx(yt),ee=oE(x,{transform:{x:Q.x-Xe.x,y:Q.y-Xe.y,scaleX:1,scaleY:1},activatorEvent:$,active:j,activeNodeRect:Re,containerNodeRect:Ue,draggingNodeRect:xe,over:Ye.current.over,overlayNodeRect:le.rect,scrollableAncestors:yt,scrollableAncestorRects:mi,windowRect:gt}),ze=Ce?Aa(Ce,Q):null,je=Vx(yt),_i=Oy(je),Vi=Oy(je,[Re]),ai=Aa(ee,_i),kt=xe?gx(xe,ee):null,ji=j&&kt?y({active:j,collisionRect:kt,droppableRects:J,droppableContainers:E,pointerCoordinates:ze}):null,Ti=fx(ji,"id"),[Nt,$s]=g.useState(null),Hi=Ke?ee:Aa(ee,Vi),qt=_x(Hi,(c=Nt?.rect)!=null?c:null,Re),Jt=g.useRef(null),Dt=g.useCallback((ot,St)=>{let{sensor:Rt,options:li}=St;if(te.current==null)return;const ei=M.get(te.current);if(!ei)return;const Bt=ot.nativeEvent,nt=new Rt({active:te.current,activeNode:ei,event:Bt,options:li,context:Ye,onAbort(bt){if(!M.get(bt))return;const{onDragAbort:ct}=ve.current,vi={id:bt};ct?.(vi),ae({type:"onDragAbort",event:vi})},onPending(bt,Ge,ct,vi){if(!M.get(bt))return;const{onDragPending:Ni}=ve.current,ki={id:bt,constraint:Ge,initialCoordinates:ct,offset:vi};Ni?.(ki),ae({type:"onDragPending",event:ki})},onStart(bt){const Ge=te.current;if(Ge==null)return;const ct=M.get(Ge);if(!ct)return;const{onDragStart:vi}=ve.current,Ai={activatorEvent:Bt,active:{id:Ge,data:ct.data,rect:K}};Il.unstable_batchedUpdates(()=>{vi?.(Ai),ue(er.Initializing),R({type:ni.DragStart,initialCoordinates:bt,active:Ge}),ae({type:"onDragStart",event:Ai}),N(Jt.current),X(Bt)})},onMove(bt){R({type:ni.DragMove,coordinates:bt})},onEnd:Wt(ni.DragEnd),onCancel:Wt(ni.DragCancel)});Jt.current=nt;function Wt(bt){return async function(){const{active:ct,collisions:vi,over:Ai,scrollAdjustedTranslate:Ni}=Ye.current;let ki=null;if(ct&&Ni){const{cancelDrop:cs}=ve.current;ki={activatorEvent:Bt,active:ct,collisions:vi,delta:Ni,over:Ai},bt===ni.DragEnd&&typeof cs=="function"&&await Promise.resolve(cs(ki))&&(bt=ni.DragCancel)}te.current=null,Il.unstable_batchedUpdates(()=>{R({type:bt}),ue(er.Uninitialized),$s(null),N(null),X(null),Jt.current=null;const cs=bt===ni.DragEnd?"onDragEnd":"onDragCancel";if(ki){const gi=ve.current[cs];gi?.(ki),ae({type:cs,event:ki})}})}}},[M]),Cn=g.useCallback((ot,St)=>(Rt,li)=>{const ei=Rt.nativeEvent,Bt=M.get(li);if(te.current!==null||!Bt||ei.dndKit||ei.defaultPrevented)return;const nt={active:Bt};ot(Rt,St.options,nt)===!0&&(ei.dndKit={capturedBy:St.sensor},te.current=li,Dt(Rt,St))},[M,Dt]),Bs=Kx(S,Cn);Xx(S),ar(()=>{Re&&G===er.Initializing&&ue(er.Initialized)},[Re,G]),g.useEffect(()=>{const{onDragMove:ot}=ve.current,{active:St,activatorEvent:Rt,collisions:li,over:ei}=Ye.current;if(!St||!Rt)return;const Bt={active:St,activatorEvent:Rt,collisions:li,delta:{x:ai.x,y:ai.y},over:ei};Il.unstable_batchedUpdates(()=>{ot?.(Bt),ae({type:"onDragMove",event:Bt})})},[ai.x,ai.y]),g.useEffect(()=>{const{active:ot,activatorEvent:St,collisions:Rt,droppableContainers:li,scrollAdjustedTranslate:ei}=Ye.current;if(!ot||te.current==null||!St||!ei)return;const{onDragOver:Bt}=ve.current,nt=li.get(Ti),Wt=nt&&nt.rect.current?{id:nt.id,rect:nt.rect.current,data:nt.data,disabled:nt.disabled}:null,bt={active:ot,activatorEvent:St,collisions:Rt,delta:{x:ei.x,y:ei.y},over:Wt};Il.unstable_batchedUpdates(()=>{$s(Wt),Bt?.(bt),ae({type:"onDragOver",event:bt})})},[Ti]),ar(()=>{Ye.current={activatorEvent:$,active:j,activeNode:pe,collisionRect:kt,collisions:ji,droppableRects:J,draggableNodes:M,draggingNode:Ee,draggingNodeRect:xe,droppableContainers:ne,over:Nt,scrollableAncestors:yt,scrollAdjustedTranslate:ai},K.current={initial:xe,translated:kt}},[j,pe,ji,kt,M,Ee,xe,J,ne,Nt,yt,ai]),jx({...Oe,delta:Q,draggingRect:kt,pointerCoordinates:ze,scrollableAncestors:yt,scrollableAncestorRects:mi});const Vs=g.useMemo(()=>({active:j,activeNode:pe,activeNodeRect:Re,activatorEvent:$,collisions:ji,containerNodeRect:Ue,dragOverlay:le,draggableNodes:M,droppableContainers:ne,droppableRects:J,over:Nt,measureDroppableContainers:he,scrollableAncestors:yt,scrollableAncestorRects:mi,measuringConfiguration:W,measuringScheduled:ge,windowRect:gt}),[j,pe,Re,$,ji,Ue,le,M,ne,J,Nt,he,yt,mi,W,ge,gt]),Ts=g.useMemo(()=>({activatorEvent:$,activators:Bs,active:j,activeNodeRect:Re,ariaDescribedById:{draggable:Se},dispatch:R,draggableNodes:M,over:Nt,measureDroppableContainers:he}),[$,Bs,j,Re,R,Se,M,Nt,he]);return xi.createElement(Tb.Provider,{value:q},xi.createElement(Ru.Provider,{value:Ts},xi.createElement(nE.Provider,{value:Vs},xi.createElement(Kb.Provider,{value:qt},f)),xi.createElement(lE,{disabled:p?.restoreFocus===!1})),xi.createElement(ux,{...p,hiddenTextDescribedById:Se}));function ks(){const ot=se?.autoScrollEnabled===!1,St=typeof m=="object"?m.enabled===!1:m===!1,Rt=F&&!ot&&!St;return typeof m=="object"?{...m,enabled:Rt}:{enabled:Rt}}}),dE=g.createContext(null),jy="button",fE="Draggable";function Ib(e){let{id:t,data:n,disabled:a=!1,attributes:o}=e;const c=ku(fE),{activators:d,activatorEvent:p,active:m,activeNodeRect:f,ariaDescribedById:S,draggableNodes:y,over:w}=g.useContext(Ru),{role:x=jy,roleDescription:C="draggable",tabIndex:k=0}=o??{},L=m?.id===t,R=g.useContext(L?Kb:dE),[ae,q]=lu(),[G,ue]=lu(),F=Gx(d,t),P=so(n);ar(()=>(y.set(t,{id:t,key:c,node:ae,activatorNode:G,data:P}),()=>{const Q=y.get(t);Q&&Q.key===c&&y.delete(t)}),[y,t]);const M=g.useMemo(()=>({role:x,tabIndex:k,"aria-disabled":a,"aria-pressed":L&&x===jy?!0:void 0,"aria-roledescription":C,"aria-describedby":S.draggable}),[a,x,k,L,C,S.draggable]);return{active:m,activatorEvent:p,activeNodeRect:f,attributes:M,isDragging:L,listeners:a?void 0:F,node:ae,over:w,setNodeRef:q,setActivatorNodeRef:ue,transform:R}}const pE="Droppable",mE={timeout:25};function Fb(e){let{data:t,disabled:n=!1,id:a,resizeObserverConfig:o}=e;const c=ku(pE),{active:d,dispatch:p,over:m,measureDroppableContainers:f}=g.useContext(Ru),S=g.useRef({disabled:n}),y=g.useRef(!1),w=g.useRef(null),x=g.useRef(null),{disabled:C,updateMeasurementsFor:k,timeout:L}={...mE,...o},R=so(k??a),ae=g.useCallback(()=>{if(!y.current){y.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{f(Array.isArray(R.current)?R.current:[R.current]),x.current=null},L)},[L]),q=Du({callback:ae,disabled:C||!d}),G=g.useCallback((M,Q)=>{q&&(Q&&(q.unobserve(Q),y.current=!1),M&&q.observe(M))},[q]),[ue,F]=lu(G),P=so(t);return g.useEffect(()=>{!q||!ue.current||(q.disconnect(),y.current=!1,q.observe(ue.current))},[ue,q]),g.useEffect(()=>(p({type:ni.RegisterDroppable,element:{id:a,key:c,disabled:n,node:ue,rect:w,data:P}}),()=>p({type:ni.UnregisterDroppable,key:c,id:a})),[a]),g.useEffect(()=>{n!==S.current.disabled&&(p({type:ni.SetDroppableDisabled,id:a,key:c,disabled:n}),S.current.disabled=n)},[a,c,n,p]),{active:d,rect:w,isOver:m?.id===a,node:ue,over:m,setNodeRef:F}}const _E=128,vE=512,gE=64,yE=4096;function qb(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.activeWorkspaceId!="string"&&t.activeWorkspaceId!==null||!Array.isArray(t.workspaces)||t.workspaces.length>_E)return null;const n=t.workspaces.map(SE);return n.some(a=>a===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:n}}function SE(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTabId!="string"&&t.activeTabId!==null||!Array.isArray(t.tabs)||t.tabs.length>vE)return null;const n=t.tabs.map(bE);return n.some(a=>a===null)?null:{id:t.id,title:t.title,activeTabId:t.activeTabId,tabs:n}}function bE(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTerminalId!="string")return null;const n=wE(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function wE(e){if(!e||typeof e!="object")return null;let t=0;return Mf(e,1,()=>(t+=1,t<=yE))}function Mf(e,t,n){if(!e||typeof e!="object"||t>gE||!n())return null;const a=e;if(a.type==="pane")return typeof a.terminalId=="string"?{type:"pane",terminalId:a.terminalId}:null;if(a.type!=="split"||a.direction!=="horizontal"&&a.direction!=="vertical")return null;const o=Mf(a.first,t+1,n),c=Mf(a.second,t+1,n);return!o||!c?null:{type:"split",direction:a.direction,ratio:CE(a.ratio),first:o,second:c}}function CE(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const Wb=[{id:"builtin-character-2260",filename:"character-2260.mp4",contentType:"video/mp4",size:123288,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2260.mp4"},{id:"builtin-character-2272",filename:"character-2272.mp4",contentType:"video/mp4",size:55873,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2272.mp4"},{id:"builtin-character-2258",filename:"character-2258.mp4",contentType:"video/mp4",size:112612,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2258.mp4"}];function Hy(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function Uy(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Py="Local",xE=3e4;function Jd(e){return e===void 0?"":e==="error"?"offline":[`CPU ${Cs(e.cpuPercent)} ${em(e)}`,`MEM ${Cs(e.memoryPercent)} ${Sn(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${Cs(e.diskPercent)} ${Sn(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${Cs(e.swapPercent)} ${Sn(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function EE(e){if(!(e===void 0||e==="error"))return[`CPU ${Cs(e.cpuPercent)} (${em(e)})`,`RAM ${Cs(e.memoryPercent)} (${Sn(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${Cs(e.diskPercent)} (${Sn(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${Cs(e.swapPercent)} (${Sn(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function Cs(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function em(e){const t=Number.isFinite(e.cores)&&e.cores>0?e.cores:null;return e.cpuPercent===null||e.cpuPercent===void 0||!Number.isFinite(e.cpuPercent)||t===null?`–/${t??"–"} cores`:`${Af(e.cpuPercent/100*t)}/${t} cores`}function Sn(e,t){return!Ky(e)||!Ky(t)?"–/–":TE(e,t)}function TE(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",a=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${Af(e/a)}/${Af(t/a)} ${n}`}function Af(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function Ky(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function kE(e){return[{label:"CPU",percent:Cs(e.cpuPercent),detail:em(e)},{label:"MEM",percent:Cs(e.memoryPercent),detail:Sn(e.memoryUsedBytes,e.memoryTotalBytes)},{label:"DISK",percent:Cs(e.diskPercent),detail:Sn(e.diskUsedBytes,e.diskTotalBytes)},{label:"SWAP",percent:Cs(e.swapPercent),detail:Sn(e.swapUsedBytes,e.swapTotalBytes)}]}function Iy({entry:e}){return e==="error"?_.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?_.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>_.jsxs("span",{className:"server-list-stat-cell",children:[_.jsx("span",{className:"server-list-stat-label",children:t}),_.jsx("span",{className:"server-list-stat-value",children:"–"}),_.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):_.jsx("span",{className:"server-list-stats server-list-stats-grid",title:EE(e),children:kE(e).map(t=>_.jsxs("span",{className:"server-list-stat-cell",children:[_.jsx("span",{className:"server-list-stat-label",children:t.label}),_.jsx("span",{className:"server-list-stat-value",children:t.percent}),_.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function ef({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:a,refreshToken:o=0,compact:c=!1}){const[d,p]=g.useState([]),[m,f]=g.useState(null),[S,y]=g.useState(null),[w,x]=g.useState(""),C=g.useRef(null),[k,L]=g.useState({});g.useEffect(()=>{let F=!1;return e.listAgents().then(P=>{F||p(P.agents)}).catch(()=>{}),e.getMainInfo().then(P=>{F||f(P.name)}).catch(()=>{}),()=>{F=!0}},[e,o]),g.useEffect(()=>{S&&(C.current?.focus(),C.current?.select())},[S]),g.useEffect(()=>{let F=!1;async function P(){let Q=!1;const ne=[{key:"__main__",load:()=>e.getMainStats()},...d.map(K=>({key:K.id,load:()=>e.getAgentStats(K.id)}))],Z=await Promise.all(ne.map(async K=>{try{return[K.key,await K.load()]}catch(j){return j instanceof yn&&j.status===401?(Q=!0,[K.key,"error"]):[K.key,"error"]}}));if(!F){if(Q){a?.();return}L(K=>{const j={};for(const[se,N]of Z)j[se]=N;const te=new Set(["__main__",...d.map(se=>se.id)]);for(const se of Object.keys(K))!te.has(se)||se in j||(j[se]=K[se]);return j})}}P();const M=window.setInterval(()=>{P()},xE);return()=>{F=!0,window.clearInterval(M)}},[e,d,a]);function R(F){F==="main"?(x(m??""),y({kind:"main"})):(x(F.name),y({kind:"agent",id:F.id}))}async function ae(){if(!S)return;const F=w.trim(),P=S;if(y(null),P.kind==="main"){const M=F||"";try{const Q=await e.renameMain(M);f(Q.name)}catch{}}else{if(!F)return;const M=d.find(Q=>Q.id===P.id)?.name;p(Q=>Q.map(ne=>ne.id===P.id?{...ne,name:F}:ne));try{await e.renameAgent(P.id,F)}catch{M!==void 0&&p(Q=>Q.map(ne=>ne.id===P.id?{...ne,name:M}:ne))}}}function q(){y(null)}const G=m?.trim()||Py,ue=S?.kind==="main";return c?_.jsxs("div",{className:"server-list server-list--compact",children:[_.jsxs("button",{type:"button",className:`server-list-chip${t===null?" server-list-chip--active":""}`,onClick:()=>n(null),"aria-label":G,title:`${G}${Jd(k.__main__)?` — ${Jd(k.__main__)}`:""}`,children:[_.jsx("span",{className:"server-list-chip-initial",children:Uy(G)}),_.jsx("span",{className:"server-list-chip-pip","data-status":Hy(k.__main__)})]}),d.map(F=>{const P=k[F.id],M=Jd(P);return _.jsxs("button",{type:"button",className:`server-list-chip${t===F.id?" server-list-chip--active":""}`,onClick:()=>n(F.id),"aria-label":F.name,title:`${F.name}${M?` — ${M}`:""}`,children:[_.jsx("span",{className:"server-list-chip-initial",children:Uy(F.name)}),_.jsx("span",{className:"server-list-chip-pip","data-status":Hy(P)})]},F.id)})]}):_.jsxs("div",{className:"server-list",children:[_.jsx("div",{className:"server-list-row",children:ue?_.jsx("form",{className:"server-list-editor",onSubmit:F=>{F.preventDefault(),ae()},children:_.jsx("input",{ref:C,"aria-label":"Rename main server",value:w,onChange:F=>x(F.target.value),onBlur:()=>{ae()},onKeyDown:F=>{F.key==="Escape"&&(F.preventDefault(),q())},placeholder:Py})}):_.jsxs("button",{type:"button",className:`server-list-item${t===null?" server-list-item--active":""}`,onClick:()=>n(null),onDoubleClick:F=>{F.preventDefault(),R("main")},title:"Double-click to rename",children:[_.jsxs("span",{className:"server-list-item-header",children:[_.jsx("span",{className:"server-list-dot"}),_.jsx("span",{className:"server-list-name",children:G})]}),_.jsx(Iy,{entry:k.__main__})]})}),d.map(F=>{const P=S?.kind==="agent"&&S.id===F.id;return _.jsx("div",{className:"server-list-row",children:P?_.jsx("form",{className:"server-list-editor",onSubmit:M=>{M.preventDefault(),ae()},children:_.jsx("input",{ref:C,"aria-label":`Rename ${F.name}`,value:w,onChange:M=>x(M.target.value),onBlur:()=>{ae()},onKeyDown:M=>{M.key==="Escape"&&(M.preventDefault(),q())}})}):_.jsxs("button",{type:"button",className:`server-list-item${t===F.id?" server-list-item--active":""}`,onClick:()=>n(F.id),onDoubleClick:M=>{M.preventDefault(),R({id:F.id,name:F.name})},title:"Double-click to rename",children:[_.jsxs("span",{className:"server-list-item-header",children:[_.jsx("span",{className:"server-list-dot"}),_.jsx("span",{className:"server-list-name",title:F.url,children:F.name})]}),_.jsx(Iy,{entry:k[F.id]})]})},F.id)})]})}function DE({api:e}){const[t,n]=g.useState([]),[a,o]=g.useState([]),[c,d]=g.useState(!1),[p,m]=g.useState(null),[f,S]=g.useState(""),[y,w]=g.useState("");async function x(){try{const[R,ae,q]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(R.devices),o(ae.networks),d(q.totpEnabled),m(null)}catch(R){m(R instanceof Error?R.message:"Failed to load")}}g.useEffect(()=>{x()},[]);async function C(R){await e.revokeDevice(R),await x()}async function k(R){await e.removeNetwork(R),await x()}async function L(R){R.preventDefault(),m(null);try{await e.addNetwork({value:f.trim(),label:y.trim()}),S(""),w(""),await x()}catch(ae){m(ae instanceof Error?ae.message:"Failed to add network")}}return _.jsxs(_.Fragment,{children:[p?_.jsx("p",{className:"form-error",children:p}):null,_.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Trusted devices"}),_.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?_.jsx("p",{className:"muted",children:"No trusted devices."}):_.jsx("ul",{className:"security-list",children:t.map(R=>_.jsxs("li",{children:[_.jsxs("div",{children:[_.jsxs("span",{className:"security-item-label",children:[R.label,R.current?_.jsx("span",{className:"security-badge",children:"this device"}):null]}),_.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(R.lastSeenAt).toLocaleString()]})]}),_.jsx("button",{type:"button",className:"security-remove",onClick:()=>{C(R.id)},children:"revoke"})]},R.id))})]}),_.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Trusted networks"}),_.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),a.length===0?_.jsx("p",{className:"muted",children:"No trusted networks."}):_.jsx("ul",{className:"security-list",children:a.map(R=>_.jsxs("li",{children:[_.jsxs("div",{children:[_.jsx("span",{className:"security-item-label",children:R.value}),R.label!==R.value?_.jsx("span",{className:"security-item-meta",children:R.label}):null]}),_.jsx("button",{type:"button",className:"security-remove",onClick:()=>{k(R.id)},children:"remove"})]},R.id))}),_.jsxs("form",{className:"security-add-form",onSubmit:L,children:[_.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:R=>S(R.currentTarget.value),required:!0}),_.jsx("input",{type:"text",placeholder:"Label (optional)",value:y,onChange:R=>w(R.currentTarget.value)}),_.jsx("button",{type:"submit",disabled:!f.trim(),children:"Add"})]})]}),c?_.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Two-factor authentication"}),_.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),_.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await x()},children:"Disable 2FA"})]}):null]})}const Yb="nterminal.notifications.completionEnabled",tm="nterminal.notifications.completionToastEnabled",im="nterminal.notifications.completionToastDurationSeconds",sm="nterminal.notifications.completionToastPersistent",Nf="nterminal:completion-toast-display",Jl=6.5,Bf=2,Lf=60;function Mu(){return typeof window<"u"&&"Notification"in window}function $b(){try{return window.localStorage.getItem(Yb)==="true"}catch{return!1}}function Fy(e){try{window.localStorage.setItem(Yb,e?"true":"false")}catch{}}function zr(){return{enabled:NE(),durationSeconds:AE(),persistUntilDismissed:BE()}}function RE(e){if(typeof window<"u"){try{window.localStorage.setItem(tm,e?"true":"false")}catch{}rm()}return zr()}function qy(e){const t=Xb(e);if(typeof window<"u"){try{window.localStorage.setItem(im,String(t))}catch{}rm()}return zr()}function ME(e){if(typeof window<"u"){try{window.localStorage.setItem(sm,e?"true":"false")}catch{}rm()}return zr()}function Vb(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===tm||n.key===im||n.key===sm)&&e()};return window.addEventListener(Nf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Nf,e),window.removeEventListener("storage",t)}}function nm(){return Mu()?window.Notification.permission:"unsupported"}function AE(){if(typeof window>"u")return Jl;try{const e=window.localStorage.getItem(im);return e===null?Jl:Xb(Number(e))}catch{return Jl}}function NE(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(tm)!=="false"}catch{return!0}}function BE(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(sm)==="true"}catch{return!1}}function Xb(e){if(!Number.isFinite(e))return Jl;const t=Math.round(e*2)/2;return Math.max(Bf,Math.min(Lf,t))}function rm(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Nf))}async function LE(){if(!Mu())return"unsupported";try{return await window.Notification.requestPermission()}catch{return nm()}}function OE(e){if(!Mu()||nm()!=="granted"||!$b()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.commandName?`${e.commandName} finished`:"Command finished";try{new Notification(`NTerminal · ${e.tabTitle}`,{body:t,tag:e.terminalId,icon:"/icons/app-icon-384.png",silent:!0})}catch{}}const zE=1500,am="nterminal.terminal.fontSize",lm="nterminal.terminal.fontFamily",Of="nterminal:terminal-font-size",zf="nterminal:terminal-font-family",jf=11,Hf=20,Lr=14,hu=[{id:"meslo",label:"MesloLGS NF",cssFamily:['"MesloLGS NF"','"MesloLGS Nerd Font Mono"','"MesloLGSNerdFontMono"','"JetBrainsMono Nerd Font"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:['"MesloLGS NF"']},{id:"jetbrains",label:"JetBrains Mono",cssFamily:['"JetBrainsMono Nerd Font"','"JetBrains Mono"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]},{id:"system",label:"System mono",cssFamily:['"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]}],Na="meslo";Uf(Na);async function tf(e=Lr,t=Na){if(typeof document>"u"||!document.fonts)return;const n=Qb(t).webFontFamilies;if(n.length===0)return;const a=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([a,new Promise(o=>{globalThis.setTimeout(o,zE)})])}function Gb(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return Lr;const n=Math.round(t);return Math.max(jf,Math.min(Hf,n))}function Zb(e){return hu.some(t=>t.id===e)?e:Na}function Uf(e){return Qb(e).cssFamily}function Qb(e){return hu.find(t=>t.id===e)??hu[0]}function Pf(){if(typeof window>"u")return Lr;try{const e=window.localStorage.getItem(am);return e?Gb(e):Lr}catch{return Lr}}function Kf(){if(typeof window>"u")return Na;try{return Zb(window.localStorage.getItem(lm))}catch{return Na}}function Hc(e){const t=Gb(e);if(typeof window>"u")return t;try{window.localStorage.setItem(am,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Of,{detail:t})),t}function jE(e){const t=Zb(e);if(typeof window>"u")return t;try{window.localStorage.setItem(lm,t)}catch{}return window.dispatchEvent(new CustomEvent(zf,{detail:t})),t}function Jb(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===am&&e()};return window.addEventListener(Of,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Of,e),window.removeEventListener("storage",t)}}function e0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===lm&&e()};return window.addEventListener(zf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(zf,e),window.removeEventListener("storage",t)}}const om="nterminal.terminal.showScrollProgress",If="nterminal:terminal-scroll-progress";function Ff(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(om)!=="false"}catch{return!0}}function HE(e){if(typeof window<"u"){try{window.localStorage.setItem(om,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(If,{detail:e}))}return e}function t0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===om&&e()};return window.addEventListener(If,e),window.addEventListener("storage",t),()=>{window.removeEventListener(If,e),window.removeEventListener("storage",t)}}const cm="nterminal.shortcuts.workspace.v1",qf="nterminal:workspace-shortcuts",ro=[{id:"server.previous",label:"Previous server",group:"Servers"},{id:"server.next",label:"Next server",group:"Servers"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"}],um={"server.previous":Mi("ArrowUp",{ctrlKey:!0}),"server.next":Mi("ArrowDown",{ctrlKey:!0}),"tab.previous":Mi("ArrowLeft",{ctrlKey:!0}),"tab.next":Mi("ArrowRight",{ctrlKey:!0}),"tab.index":Mi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":Mi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":Mi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Mi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0})},UE={"server.previous":Mi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":Mi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":Mi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":Mi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":Mi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":Mi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":Mi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Mi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0})};function jr(){const e=r0(um);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(cm);if(!t)return e;const n=JSON.parse(t);for(const a of ro){const o=n[a.id];if(VE(o)){const c=a0(o,a);$E(c,UE[a.id])||(e[a.id]=c)}}}catch{return e}return e}function Wy(){return JSON.stringify(jr())}function PE(e,t){const n=jr(),a=ro.find(o=>o.id===e);return a&&(n[e]=a0(t,a),hm(n)),n}function KE(e){const t=jr();return t[e]={...um[e]},hm(t),t}function IE(){const e=r0(um);return hm(e),e}function i0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===cm&&e()};return window.addEventListener(qf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(qf,e),window.removeEventListener("storage",t)}}function FE(e,t){const n=o0(e);return!n||GE(n)||t.indexed&&l0(e)===null?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function qE(e){const t=jr();for(const n of ro){const a=t[n.id];if(!(!a||!XE(e,a))){if(n.indexed){if(a.code!=="Digit")continue;const o=l0(e);if(o!==null)return{id:n.id,index:o};continue}if(o0(e)===a.code)return{id:n.id,index:null}}}return null}function s0(e){return n0(jr()[e])}function n0(e){const t=[];return e.ctrlKey&&t.push("Ctrl"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),e.metaKey&&t.push("Meta"),t.push(ZE(e.code)),t.join("+")}const WE=()=>s0("split.right"),YE=()=>s0("split.down");function Mi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function r0(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function $E(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function hm(e){if(!(typeof window>"u")){try{window.localStorage.setItem(cm,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(qf))}}function a0(e,t){return{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function VE(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.ctrlKey=="boolean"&&typeof t.altKey=="boolean"&&typeof t.shiftKey=="boolean"&&typeof t.metaKey=="boolean"&&typeof t.code=="string"&&t.code.length>0}function XE(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function l0(e){const t=/^Digit([1-9])$/.exec(e.code);return t?.[1]?Number(t[1]):/^[1-9]$/.test(e.key)?Number(e.key):null}function o0(e){if(e.code)return e.code;if(/^[a-z]$/i.test(e.key))return`Key${e.key.toUpperCase()}`;if(/^[0-9]$/.test(e.key))return`Digit${e.key}`;switch(e.key){case"[":case"{":return"BracketLeft";case"]":case"}":return"BracketRight";case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"Tab":case"Enter":case"Escape":case"Space":return e.key==="Space"?"Space":e.key;default:return null}}function GE(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function ZE(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const n=/^Key([A-Z])$/.exec(e);if(n?.[1])return n[1];switch(e){case"BracketLeft":return"[";case"BracketRight":return"]";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"Space":return"Space";default:return e.replace(/^(Numpad|Digit|Key)/,"")}}const dm="nterminal.theme.accent",Wf="nterminal:theme-accent",ao=[{id:"aqua",label:"Aqua Teal",accent:"#5EEAD4",soft:"rgba(94, 234, 212, 0.10)",glow:"rgba(94, 234, 212, 0.55)",xtermSelection:"#1f3f45"},{id:"signal-red",label:"Signal Red",accent:"#FF2A3D",soft:"rgba(255, 42, 61, 0.12)",glow:"rgba(255, 42, 61, 0.52)",xtermSelection:"#4a1b22"}],du="aqua";function wo(e){return ao.some(t=>t.id===e)?e:du}function fm(e){return ao.find(t=>t.id===e)??ao[0]}function lr(){if(typeof window>"u")return du;try{return wo(window.localStorage.getItem(dm))}catch{return du}}function QE(e){const t=wo(e);if(typeof window<"u"){try{window.localStorage.setItem(dm,t)}catch{}pm(t),window.dispatchEvent(new CustomEvent(Wf,{detail:t}))}return t}function pm(e=lr()){if(typeof document>"u")return;const t=fm(wo(e)),n=document.documentElement;n.style.setProperty("--nt-accent",t.accent),n.style.setProperty("--nt-accent-soft",t.soft),n.style.setProperty("--nt-accent-glow",t.glow)}function JE(e=lr()){return fm(wo(e)).accent}function e2(e=lr()){return fm(wo(e)).xtermSelection}function c0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===dm&&(pm(lr()),e())};return window.addEventListener(Wf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Wf,e),window.removeEventListener("storage",t)}}const t2="Automatic update needs write access to the global npm install. Run the manual update command on this server.";function i2(e="nterminal",t=new Date){return{reason:"permission",message:t2,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart`,detectedAt:t.toISOString()}}function s2(e){return/\b(?:EACCES|EPERM)\b|permission denied|missing write access|access denied|operation was rejected by your operating system|operation not permitted|root-owned files/i.test(e)}const u0=3600*1e3,n2="local",Yf=new Set,nr=new Map;let or={checking:!1,hasUpdates:!1,lastCheckedAt:null},mm=null,eo=null,fu=0,Jn=null;function r2(e){return Yf.add(e),()=>{Yf.delete(e)}}function Yy(){return or}function a2(e){const t=h2();mm=e,_m(),$f(e,t);const n=()=>{if(document.visibilityState!=="visible"||!cr(e,t))return;const a=or.lastCheckedAt;(a===null||Date.now()-a>=u0)&&$f(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),cr(e,t)&&u2()}}function l2(e,t){nr.set(e,h0(t)),Ba({...or,hasUpdates:vm(),lastCheckedAt:Date.now()})}function sf(e){e===void 0?nr.clear():nr.set(e,!1),Ba({...or,hasUpdates:vm()})}async function $f(e,t){if(!cr(e,t))return;if(Jn&&Jn.api===e&&Jn.runId===t)return Jn.promise;Ba({...or,checking:!0});const n=o2(e,t).finally(()=>{Jn?.promise===n&&(Jn=null),cr(e,t)&&(Ba({...or,checking:!1,lastCheckedAt:Date.now()}),c2(e,t))});return Jn={api:e,runId:t,promise:n},n}async function o2(e,t){try{const n=await e.listAgents();if(!cr(e,t))return;const a=[{key:n2,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(a.map(async c=>{try{const d=await c.check();o.set(c.key,h0(d))}catch{o.set(c.key,nr.get(c.key)??!1)}})),!cr(e,t))return;nr.clear();for(const[c,d]of o)nr.set(c,d);Ba({...or,hasUpdates:vm()})}catch{}}function c2(e,t){cr(e,t)&&(_m(),eo=window.setTimeout(()=>{eo=null,cr(e,t)&&$f(e,t)},u0))}function u2(){fu+=1,_m(),mm=null,Jn=null,nr.clear(),Ba({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function _m(){eo!==null&&(window.clearTimeout(eo),eo=null)}function h2(){return fu+=1,fu}function cr(e,t){return mm===e&&fu===t}function h0(e){return e.updateAvailable===!0}function vm(){return Array.from(nr.values()).some(Boolean)}function Ba(e){or=e;for(const t of Array.from(Yf))t()}const d2=e=>new Promise(t=>setTimeout(t,e));function f2({api:e,onAgentRemoved:t}){const[n,a]=g.useState([{key:"local",id:null,name:"Local (main)"}]),[o,c]=g.useState({}),[d,p]=g.useState(!1),[m,f]=g.useState(null);function S(M,Q){c(ne=>({...ne,[M]:{...ne[M],...Q}}))}const y=M=>M.id===null?e.getVersion():e.getAgentVersion(M.id),w=M=>M.id===null?e.checkUpdate():e.checkAgentUpdate(M.id),x=M=>M.id===null?e.runUpdate():e.runAgentUpdate(M.id);g.useEffect(()=>{let M=!1;return e.listAgents().then(Q=>{if(M)return;const ne=[{key:"local",id:null,name:"Local (main)"},...Q.agents.map(Z=>({key:Z.id,id:Z.id,name:Z.name}))];a(ne);for(const Z of ne)y(Z).then(K=>S(Z.key,{version:K,manualUpdate:K.manualUpdate??null})).catch(K=>S(Z.key,{error:K instanceof Error?K.message:"unreachable"}))}).catch(()=>{}),()=>{M=!0}},[]);async function C(M){S(M.key,{busy:!0,status:"checking…",error:void 0});try{const Q=await w(M);l2(M.key,Q),S(M.key,{latestVersion:Q.latestVersion,updateAvailable:Q.updateAvailable,status:ue(Q),...Q.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(Q){S(M.key,{busy:!1,error:Q instanceof Error?Q.message:"check failed"})}}async function k(){p(!0),await Promise.all(n.map(M=>C(M))),p(!1)}async function L(M,Q){const ne=Date.now()+18e4;for(;Date.now()<ne;){await d2(3e3);try{const Z=await y(M);if(Q&&Z.runningVersion!==Q.runningVersion)return Z}catch{}}return null}async function R(M,Q={}){let ne=o[M.key]?.version;if(!ne)try{ne=await y(M),S(M.key,{version:ne,manualUpdate:ne.manualUpdate??null})}catch(te){return S(M.key,{busy:!1,error:te instanceof Error?te.message:"version check failed"}),"failed"}const Z=o[M.key]?.manualUpdate??ne.manualUpdate??null;if(Z&&Q.skipManual)return S(M.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:Z}),"manual";S(M.key,{busy:!0,status:"updating…",error:void 0});let K;try{K=await x(M)}catch(te){return S(M.key,{busy:!1,error:te instanceof Error?te.message:"update failed"}),"failed"}if(!K.ok){const te=K.manualUpdate??(s2(K.message)?i2():null);return te?(S(M.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:te}),"manual"):(S(M.key,{busy:!1,status:void 0,error:K.message}),"failed")}if(!K.changed)return S(M.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),sf(M.key),"unchanged";S(M.key,{status:"restarting…"});const j=await L(M,ne);return j?(S(M.key,{busy:!1,version:j,updateAvailable:!1,status:"updated",manualUpdate:j.manualUpdate??null}),sf(M.key),M.id===null&&window.setTimeout(()=>window.location.reload(),250),"updated"):(S(M.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function ae(M){if(!(M.id===null||!window.confirm([`Delete secondary server "${M.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
14
- `)))){S(M.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const ne=await e.uninstallAgent(M.id);a(Z=>Z.filter(K=>K.key!==M.key)),c(Z=>{const K={...Z};return delete K[M.key],K}),sf(M.key),t?.(M.id),f(ne.message)}catch(ne){S(M.key,{busy:!1,status:void 0,error:ne instanceof Error?ne.message:"delete failed"})}}}async function q(){p(!0),f(null);const M=n.filter(j=>j.id!==null),Q=n.find(j=>j.id===null),ne=await Promise.all(M.map(j=>R(j,{skipManual:!0}))),Z=ne.filter(j=>j==="failed").length;let K=ne.filter(j=>j==="manual").length;if(Z>0){p(!1);return}if(Q){const j=await R(Q,{skipManual:!0});if(j==="manual"&&(K+=1),j==="updated"){window.location.reload();return}}K>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),p(!1)}function G(M){return M?M.error?M.error:M.status?M.status:M.manualUpdate?"manual update required":M.version?`v${M.version.version}`:"…":"…"}function ue(M){return M.error?M.error:typeof M.updateAvailable=="boolean"?M.updateAvailable?`latest v${M.latestVersion??"available"}`:"up to date":"unknown"}function F(M){const Q=M?.version;return Q?`npm package v${Q.runningVersion}`:""}async function P(M,Q){try{await p2(Q),S(M,{copiedCommand:!0}),window.setTimeout(()=>S(M,{copiedCommand:!1}),1800)}catch(ne){S(M,{error:ne instanceof Error?ne.message:"copy failed"})}}return _.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Servers"}),_.jsxs("div",{className:"update-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{k()},disabled:d,children:"Check for updates"}),_.jsx("button",{type:"button",onClick:()=>{q()},disabled:d,children:"Update all"})]}),m?_.jsx("p",{className:"settings-status",children:m}):null,_.jsx("ul",{className:"security-list",children:n.map(M=>{const Q=o[M.key],ne=F(Q),Z=Q?.manualUpdate??null,K=Q?.version!==void 0&&Q?.updateAvailable!==!1&&!Z&&!Q?.busy&&!d,j=M.id!==null&&!Q?.busy&&!d;return _.jsxs("li",{children:[_.jsxs("div",{className:"server-row-main",children:[_.jsxs("div",{children:[_.jsx("span",{className:"security-item-label",children:M.name}),_.jsxs("span",{className:"security-item-meta",children:[ne?`${ne} — `:"",G(Q)]})]}),Z?_.jsxs("div",{className:"server-manual-update",children:[_.jsx("span",{children:Z.message}),_.jsxs("div",{className:"server-manual-command",children:[_.jsx("code",{children:Z.command}),_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{P(M.key,Z.command)},children:Q?.copiedCommand?"Copied":"Copy"})]})]}):null]}),_.jsxs("div",{className:"server-row-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{R(M)},disabled:!K,children:Q?.busy?"…":"Update"}),M.id!==null?_.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{ae(M)},disabled:!j,children:"Delete"}):null]})]},M.key)})})]})}async function p2(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("copy failed")}finally{t.remove()}}const Uc=[{id:"terminal",label:"Terminal"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function m2({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:a,onAgentRemoved:o}){const c=g.useMemo(()=>t??Eu(),[t]),[d,p]=g.useState(()=>Pf()),[m,f]=g.useState(()=>Kf()),[S,y]=g.useState(()=>Ff()),[w,x]=g.useState(()=>lr()),[C,k]=g.useState(()=>jr()),[L,R]=g.useState(null),[ae,q]=g.useState(null),[G,ue]=g.useState("terminal"),[F,P]=g.useState(()=>$b()),[M,Q]=g.useState(()=>zr()),[ne,Z]=g.useState(()=>nm()),[K,j]=g.useState([]),[te,se]=g.useState([]),[N,$]=g.useState([]),[X,ve]=g.useState(5*1024*1024),[Se,E]=g.useState(!1),[W,J]=g.useState(null),he=g.useRef(null),ge=g.useRef(null),pe=g.useRef({terminal:null,shortcuts:null,notifications:null,security:null,servers:null}),Ce=g.useMemo(()=>new Set(te),[te]),Oe=!_2(te,N);g.useEffect(()=>Jb(()=>p(Pf())),[]),g.useEffect(()=>e0(()=>f(Kf())),[]),g.useEffect(()=>t0(()=>y(Ff())),[]),g.useEffect(()=>c0(()=>x(lr())),[]),g.useEffect(()=>i0(()=>k(jr())),[]),g.useEffect(()=>Vb(()=>Q(zr())),[]),g.useEffect(()=>{if(!L)return;const ee=ro.find(je=>je.id===L);if(!ee)return;const ze=je=>{if(je.preventDefault(),je.stopPropagation(),je.key==="Escape"){R(null),q(null);return}const _i=FE(je,ee);if(!_i){q(ee.indexed?"Press a shortcut ending in a number from 1 to 9.":"Press a complete shortcut.");return}k(PE(L,_i)),R(null),q(null)};return window.addEventListener("keydown",ze,!0),()=>window.removeEventListener("keydown",ze,!0)},[L]),g.useEffect(()=>{let ee=!1;return c.listNotificationAssets().then(ze=>{ee||Ee(ze)}).catch(ze=>{ee||J(Pc(ze))}),()=>{ee=!0}},[c]);function Ne(ee){p(Hc(Number(ee)))}function Re(ee){Q(qy(Number(ee)))}function Ue(ee){ue(ee),pe.current[ee]?.scrollIntoView?.({block:"start",behavior:"smooth"})}function Ye(){const ee=ge.current;if(!ee)return;if(ee.scrollTop+ee.clientHeight>=ee.scrollHeight-2){ue(Uc[Uc.length-1].id);return}const ze=ee.getBoundingClientRect();let je="terminal",_i=0;for(const Vi of Uc){const ai=pe.current[Vi.id];if(!ai)continue;const kt=ai.getBoundingClientRect(),ji=Math.max(kt.top,ze.top),Ti=Math.min(kt.bottom,ze.bottom),Nt=Math.max(0,Ti-ji);Nt>_i&&(je=Vi.id,_i=Nt)}ue(je)}function Be(ee){k(KE(ee)),R(null),q(null)}function le(){k(IE()),R(null),q(null)}function Ee(ee){const ze=ee.assets.filter(je=>je.enabled).map(je=>je.id);j(ee.assets),se(ze),$(ze),ve(ee.maxFileBytes),J(null)}async function xe(){if(F){Fy(!1),P(!1);return}let ee=ne;ee==="default"&&(ee=await LE(),Z(ee)),ee==="granted"&&(Fy(!0),P(!0))}async function Ke(ee){const ze=ee?.[0];if(ze){if(ze.size>X){J(`File must be ${nf(X)} or smaller.`),gt();return}if(ze.type!=="video/mp4"&&ze.type!=="video/webm"){J("Upload an MP4 or WebM video."),gt();return}E(!0),J(null);try{await c.uploadNotificationAsset(ze),Ee(await c.listNotificationAssets()),a?.()}catch(je){J(Pc(je))}finally{E(!1),gt()}}}async function Xe(ee){E(!0),J(null);try{await c.deleteNotificationAsset(ee),Ee(await c.listNotificationAssets()),a?.()}catch(ze){J(Pc(ze))}finally{E(!1)}}function gt(){he.current&&(he.current.value="")}function yt(ee,ze){const je=new Set(te);if(ze?je.add(ee):je.delete(ee),je.size===0){J("Keep at least one toast video selected.");return}J(null),se(Array.from(je))}async function mi(){if(te.length===0){J("Keep at least one toast video selected.");return}E(!0),J(null);try{const ee=await c.updateNotificationAssetSelection({enabledAssetIds:te});Ee(ee),a?.()}catch(ee){J(Pc(ee))}finally{E(!1)}}return _.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:_.jsxs("div",{className:"security-panel settings-panel",onClick:ee=>ee.stopPropagation(),children:[_.jsxs("header",{className:"security-panel-header",children:[_.jsx("h2",{children:"Settings"}),_.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),_.jsxs("div",{className:"settings-layout",children:[_.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Uc.map(ee=>_.jsxs("button",{type:"button","data-active":G===ee.id?"true":"false","aria-current":G===ee.id?"true":void 0,onClick:()=>Ue(ee.id),children:[ee.label,ee.id==="servers"&&n?_.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},ee.id))}),_.jsxs("div",{ref:ge,className:"settings-content",onScroll:Ye,children:[_.jsxs("section",{id:"settings-terminal",ref:ee=>{pe.current.terminal=ee},className:"security-section settings-section",children:[_.jsx("h3",{children:"Terminal"}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Font size"}),_.jsxs("span",{className:"settings-control-value",children:[d,"px"]}),_.jsx("input",{type:"range",min:jf,max:Hf,step:1,value:d,"aria-label":"Terminal font size",onChange:ee=>Ne(ee.currentTarget.value)})]}),_.jsxs("div",{className:"settings-stepper-row",children:[_.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Hc(d-1)),children:"-"}),_.jsx("input",{type:"number",min:jf,max:Hf,step:1,value:d,"aria-label":"Terminal font size value",onChange:ee=>Ne(ee.currentTarget.value)}),_.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Hc(d+1)),children:"+"}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>p(Hc(Lr)),children:"Reset"})]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Font family"}),_.jsx("select",{value:m,"aria-label":"Terminal font family",onChange:ee=>f(jE(ee.currentTarget.value)),children:hu.map(ee=>_.jsx("option",{value:ee.id,children:ee.label},ee.id))})]}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:S,onChange:ee=>y(HE(ee.currentTarget.checked))}),"Show scroll progress"]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Accent theme"}),_.jsx("select",{value:w,"aria-label":"Theme accent",onChange:ee=>x(QE(ee.currentTarget.value)),children:ao.map(ee=>_.jsx("option",{value:ee.id,children:ee.label},ee.id))})]}),_.jsx("div",{className:"settings-theme-swatches","aria-hidden":"true",children:ao.map(ee=>_.jsx("span",{className:"settings-theme-swatch","data-active":w===ee.id?"true":"false",style:{"--settings-theme-accent":ee.accent}},ee.id))})]}),_.jsxs("section",{id:"settings-shortcuts",ref:ee=>{pe.current.shortcuts=ee},className:"security-section settings-section",children:[_.jsxs("div",{className:"settings-section-heading",children:[_.jsx("h3",{children:"Shortcuts"}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:le,children:"Reset all"})]}),_.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),ae?_.jsx("p",{className:"settings-error",children:ae}):null,_.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:ro.map(ee=>{const ze=L===ee.id;return _.jsxs("li",{children:[_.jsxs("div",{children:[_.jsx("span",{className:"settings-shortcut-label",children:ee.label}),_.jsx("span",{className:"settings-shortcut-group",children:ee.group})]}),_.jsxs("div",{className:"settings-shortcut-actions",children:[_.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":ze?"true":"false",onClick:()=>{R(ee.id),q(null)},children:ze?"Press keys…":n0(C[ee.id])}),_.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Be(ee.id),children:"Reset"})]})]},ee.id)})})]}),_.jsxs("section",{id:"settings-notifications",ref:ee=>{pe.current.notifications=ee},className:"security-section settings-section",children:[_.jsx("h3",{children:"Notifications"}),Mu()?_.jsxs(_.Fragment,{children:[_.jsxs("label",{className:"auth-checkbox",children:[_.jsx("input",{type:"checkbox",checked:F&&ne==="granted",onChange:()=>{xe()},disabled:ne==="denied"}),"System notification when page is hidden"]}),ne==="denied"?_.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):_.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):_.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:M.enabled,onChange:ee=>Q(RE(ee.currentTarget.checked))}),"Show animated completion toast"]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Toast duration"}),_.jsx("span",{className:"settings-control-value",children:M.persistUntilDismissed?"Until closed":`${M.durationSeconds}s`}),_.jsx("input",{type:"range",min:Bf,max:Lf,step:.5,value:M.durationSeconds,disabled:!M.enabled||M.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:ee=>Re(ee.currentTarget.value)})]}),_.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[_.jsx("input",{type:"number",min:Bf,max:Lf,step:.5,value:M.durationSeconds,disabled:!M.enabled||M.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:ee=>Re(ee.currentTarget.value)}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!M.enabled||M.persistUntilDismissed,onClick:()=>Q(qy(Jl)),children:"Reset"})]}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:M.persistUntilDismissed,disabled:!M.enabled,onChange:ee=>Q(ME(ee.currentTarget.checked))}),"Keep toast until dismissed"]}),_.jsxs("div",{className:"settings-assets-header",children:[_.jsx("span",{children:"Toast videos"}),_.jsxs("span",{children:[nf(X)," max"]})]}),_.jsx("input",{ref:he,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:ee=>{Ke(ee.currentTarget.files)}}),_.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:Se,onClick:()=>he.current?.click(),children:"Upload video"}),W?_.jsx("p",{className:"settings-error",children:W}):null,K.length>0?_.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:K.map(ee=>_.jsxs("li",{"data-enabled":Ce.has(ee.id)?"true":"false",children:[_.jsxs("label",{className:"settings-asset-choice",children:[_.jsx("input",{type:"checkbox",checked:Ce.has(ee.id),disabled:Se,"aria-label":`Use ${ee.filename}`,onChange:ze=>yt(ee.id,ze.currentTarget.checked)}),_.jsx("video",{src:ee.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),_.jsxs("span",{className:"settings-asset-copy",children:[_.jsx("span",{children:ee.filename}),_.jsx("small",{children:ee.source==="built-in"?"Built-in":nf(ee.size)})]})]}),ee.source==="uploaded"?_.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:Se,"aria-label":`Delete ${ee.filename}`,onClick:()=>{Xe(ee.id)},children:"x"}):null]},ee.id))}):_.jsx("p",{className:"muted",children:"Built-in videos will be used."}),_.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:Se||K.length===0||!Oe,onClick:()=>{mi()},children:"Save selected videos"})]}),_.jsx("div",{id:"settings-security",ref:ee=>{pe.current.security=ee},className:"settings-section-group",children:_.jsx(DE,{api:c})}),_.jsx("div",{id:"settings-servers",ref:ee=>{pe.current.servers=ee},className:"settings-section-group",children:_.jsx(f2,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function nf(e){return e>=1024*1024?`${Math.round(e/1024/1024*10)/10} MB`:e>=1024?`${Math.round(e/1024*10)/10} KB`:`${e} B`}function Pc(e){return e instanceof Error?e.message:"Request failed."}function _2(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(a=>n.has(a))}class Dr extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function v2(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,a=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:a}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let d=!1;const p=()=>{e.signal?.removeEventListener("abort",S)},m=y=>{d||(d=!0,p(),o(y))},f=y=>{d||(d=!0,p(),c(y))},S=()=>{t.abort(),f(new Dr(0,"Upload aborted."))};if(e.signal?.aborted){f(new Dr(0,"Upload aborted."));return}e.signal?.addEventListener("abort",S,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=y=>{if(e.onProgress){if(y.lengthComputable&&y.total>0){e.onProgress({loaded:y.loaded,total:y.total,percent:Math.round(y.loaded/y.total*100)});return}e.onProgress({loaded:y.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{m(JSON.parse(t.responseText))}catch{f(new Dr(t.status,"Invalid upload response."))}return}f(new Dr(t.status,g2(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new Dr(0,"Upload failed.")),t.onabort=()=>f(new Dr(0,"Upload aborted.")),t.ontimeout=()=>f(new Dr(0,"Upload timed out.")),t.send(n)})}function g2(e,t){try{const n=JSON.parse(e),a=typeof n.error=="string"?n.error:n.message;if(typeof a=="string"&&a.trim())return a}catch{}return t}const y2="modulepreload",S2=function(e){return"/"+e},$y={},d0=function(t,n,a){let o=Promise.resolve();if(n&&n.length>0){let m=function(f){return Promise.all(f.map(S=>Promise.resolve(S).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=d?.nonce||d?.getAttribute("nonce");o=m(n.map(f=>{if(f=S2(f),f in $y)return;$y[f]=!0;const S=f.endsWith(".css"),y=S?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const w=document.createElement("link");if(w.rel=S?"stylesheet":y2,S||(w.as="script"),w.crossOrigin="",w.href=f,p&&w.setAttribute("nonce",p),document.head.appendChild(w),S)return new Promise((x,C)=>{w.addEventListener("load",x),w.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(d){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=d,window.dispatchEvent(p),!p.defaultPrevented)throw d}return o.then(d=>{for(const p of d||[])p.status==="rejected"&&c(p.reason);return t().catch(c)})},b2=g.lazy(()=>d0(()=>import("./MarkdownPreview-fAU63YUT.js"),[]));function w2({api:e,activeTerminalId:t,activeTerminalCwd:n,onOpenFile:a}){const[o,c]=g.useState(null),[d,p]=g.useState(""),[m,f]=g.useState({}),[S,y]=g.useState(()=>new Set),[w,x]=g.useState(null),[C,k]=g.useState({type:"empty"}),[L,R]=g.useState("idle"),[ae,q]=g.useState(null),G=g.useRef(null),ue=g.useRef(null),F=g.useRef(!1),P=g.useRef(0),M=g.useRef(null);M.current===null&&t&&(M.current=t);const Q=M.current,ne=t?af(t,n):null,Z=o?[o.rootPath,d].filter(Boolean).join("/"):"",K=w?.path??null;g.useEffect(()=>(F.current=!0,()=>{F.current=!1,P.current+=1,Oe()}),[]),g.useEffect(()=>{M.current=t,ue.current=null;const le=t?af(t,n):null;j(t,le)},[e]),g.useEffect(()=>{if(!Q||t!==Q)return;const le=af(Q,n);le!==ue.current&&j(Q,le)},[Q,t,n]);async function j(le,Ee=ne){const xe=Ne();if(ue.current=Ee,Oe(),c(null),p(""),f({}),y(new Set),x(null),k({type:"empty"}),q(null),!le){R("idle");return}R("loading");try{const Ke=await e.createFileRoot({terminalId:le});if(!Re(xe))return;c({rootToken:Ke.rootToken,rootPath:Ke.rootPath});const Xe=await e.listFiles({rootToken:Ke.rootToken,path:""});if(!Re(xe))return;N(Xe),R("idle")}catch(Ke){if(await Ue(Ke,xe))return;Re(xe)&&(q(Xn(Ke)),R("idle"))}}async function te(le=d,Ee=o){if(!Ee)return;const xe=Ne();R("loading"),q(null);try{const Ke=await e.listFiles({rootToken:Ee.rootToken,path:le});if(!Re(xe))return;N(Ke),R("idle")}catch(Ke){if(await Ue(Ke,xe))return;Re(xe)&&(q(Xn(Ke)),R("idle"))}}async function se(){M.current=t,await j(t,ne)}function N(le){f(Ee=>({...Ee,[le.path]:x2(le.entries)}))}async function $(le){if(!(!rf(le)||!o)){if(x(le),q(null),le.kind==="directory"){p(le.path),Ce(),await ve(le);return}if(p(Rr(le.path)),le.editable){await E(le);return}le.previewKind!=="none"&&await J(le,le.previewKind)}}async function X(le){if(!(!rf(le)||!o)){if(x(le),q(null),le.kind==="directory"){p(le.path),Ce(),await ve(le);return}if(p(Rr(le.path)),le.editable){await W(le);return}le.previewKind!=="none"&&await J(le,le.previewKind)}}async function ve(le){if(S.has(le.path)){y(Ee=>{const xe=new Set(Ee);return xe.delete(le.path),xe});return}y(Ee=>new Set(Ee).add(le.path)),await te(le.path)}function Se(le,Ee){le.key==="Enter"&&(le.preventDefault(),X(Ee))}async function E(le){if(!o)return;const Ee=Ne();R("loading"),Oe();try{const xe=await e.readFile({rootToken:o.rootToken,path:le.path});if(!Re(Ee))return;k({type:"text-preview",file:le,read:xe}),R("idle")}catch(xe){if(await Ue(xe,Ee))return;Re(Ee)&&(q(Xn(xe)),R("idle"))}}async function W(le){if(!o)return;const Ee=Ne();R("loading");try{await a({rootToken:o.rootToken,path:le.path}),Re(Ee)&&R("idle")}catch(xe){if(await Ue(xe,Ee))return;Re(Ee)&&(q(Xn(xe)),R("idle"))}}async function J(le,Ee){if(!o)return;const xe=Ne();R("loading"),Oe();try{const Ke=await e.previewFile({rootToken:o.rootToken,path:le.path});if(!Re(xe))return;const Xe=URL.createObjectURL(Ke);if(!Re(xe)){URL.revokeObjectURL(Xe);return}G.current=Xe,k({type:"preview",file:le,previewKind:Ee,url:Xe}),R("idle")}catch(Ke){if(await Ue(Ke,xe))return;Re(xe)&&(q(Xn(Ke)),R("idle"))}}async function he(le){if(!o)return;const Ee=le==="file"?"New file":"New folder",xe=window.prompt(Ee,""),Ke=w?w.kind==="directory"?w.path:Rr(w.path):d,Xe=Vy(xe,Ke);if(Xe){q(null);try{const gt=await e.createFileEntry({rootToken:o.rootToken,path:Xe,kind:le});x(gt.entry),await te(Ke)}catch(gt){if(await Ue(gt))return;q(Xn(gt))}}}async function ge(){if(!o||!w)return;const le=window.prompt("Move selected entry",w.path),Ee=Vy(le,"");if(!Ee||Ee===w.path)return;const xe=Rr(w.path),Ke=Rr(Ee);q(null);try{const Xe=await e.moveFileEntry({rootToken:o.rootToken,sourcePath:w.path,destinationPath:Ee});x(Xe.entry),p(Xe.entry.kind==="directory"?Xe.entry.path:Rr(Xe.entry.path)),Ce(),await te(xe),Ke!==xe&&await te(Ke)}catch(Xe){if(await Ue(Xe))return;q(Xn(Xe))}}async function pe(){if(!o||!w)return;const le=w.path,Ee=Rr(le);q(null);try{const xe=await e.previewDeleteFileEntry({rootToken:o.rootToken,path:w.path}),Ke=xe.descendantCount>0?` and ${xe.descendantCount} nested item${xe.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${xe.path}${Ke}?`))return;await e.deleteFileEntry({rootToken:o.rootToken,path:w.path,previewToken:xe.previewToken}),x(null),p(Ee),y(Xe=>{const gt=new Set(Xe);for(const yt of Xe)(yt===le||yt.startsWith(`${le}/`))&&gt.delete(yt);return gt}),Ce(),await te(Ee)}catch(xe){if(await Ue(xe))return;q(Xn(xe))}}function Ce(){P.current+=1,Oe(),k({type:"empty"})}function Oe(){G.current&&(URL.revokeObjectURL(G.current),G.current=null)}function Ne(){return P.current+=1,P.current}function Re(le){return F.current&&le===P.current}async function Ue(le,Ee){return E2(le)?(Ee!==void 0&&!Re(Ee)||await j(t,ne),!0):!1}function Ye(le,Ee){const xe=rf(le),Ke=le.kind==="directory"&&S.has(le.path),Xe=m[le.path]??[],gt={"--file-tree-depth":Ee};return _.jsxs(xi.Fragment,{children:[_.jsxs("button",{type:"button",className:"file-entry-button","data-kind":le.kind,"data-expanded":Ke,"data-active":K===le.path,disabled:!xe,style:gt,"aria-expanded":le.kind==="directory"?Ke:void 0,"aria-label":`${le.kind==="directory"?"Open folder":"Open file"} ${le.name}`,title:le.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{$(le)},onDoubleClick:()=>{X(le)},onKeyDown:yt=>Se(yt,le),children:[_.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:le.kind==="directory"?Ke?"▾":"▸":""}),_.jsx("span",{className:"file-entry-name",children:le.name}),_.jsx("small",{children:C2(le)})]}),Ke?_.jsx("div",{className:"file-tree-children",role:"group",children:Xe.map(yt=>Ye(yt,Ee+1))}):null]},le.path)}const Be=m[""]??[];return _.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":L==="loading",children:[_.jsxs("header",{className:"file-explorer-header",children:[_.jsx("div",{className:"file-explorer-path",title:Z,children:Z||"No active pane"}),_.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[_.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!t,onClick:()=>{se()},children:"↻"}),_.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!o,onClick:()=>{he("file")},children:"+"}),_.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!o,onClick:()=>{he("directory")},children:"▣"})]})]}),ae?_.jsx("div",{className:"file-explorer-alert",role:"alert",children:ae}):null,_.jsxs("div",{className:"file-explorer-layout",children:[_.jsx("div",{className:"file-tree","aria-label":Z?`Files in ${Z}`:"Files",children:Be.map(le=>Ye(le,0))}),_.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[_.jsxs("div",{className:"file-detail-header",children:[_.jsx("strong",{children:w?.name??"detail"}),_.jsxs("div",{className:"file-detail-actions",children:[_.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{ge()},children:"Move"}),_.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{pe()},children:"Delete"})]})]}),L==="loading"?_.jsx("div",{className:"file-detail-empty",children:"loading"}):null,C.type==="empty"&&L!=="loading"?_.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,C.type==="preview"?_.jsxs("div",{className:"file-preview-frame",children:[C.previewKind==="image"?_.jsx("img",{src:C.url,alt:C.file.name}):null,C.previewKind==="pdf"?_.jsx("iframe",{src:C.url,title:C.file.name}):null]}):null,C.type==="text-preview"&&C.read.language==="markdown"?_.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${C.file.name}`,children:_.jsx(g.Suspense,{fallback:_.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:_.jsx(b2,{content:C.read.content})})}):null,C.type==="text-preview"&&C.read.language==="text"?_.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${C.file.name}`,children:C.read.content}):null]})]})]})}function rf(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function C2(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function af(e,t){return`${e}\0${t??""}`}function x2(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function Rr(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function Vy(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function Xn(e){return e instanceof Error?e.message:"Request failed"}function E2(e){return e instanceof yn&&e.status===409&&e.message==="terminal_cwd_changed"}const T2=g.lazy(()=>d0(()=>import("./MarkdownPreview-fAU63YUT.js"),[]));function Xy({api:e,editor:t,canClose:n,onClose:a}){const[o,c]=g.useState(t.read),[d,p]=g.useState(t.read.content),[m,f]=g.useState("idle"),[S,y]=g.useState(null),[w,x]=g.useState(!1),[C,k]=g.useState("edit"),L=g.useRef(t),R=g.useRef(t.read),ae=g.useRef(t.read.content),q=g.useRef(!1),G=g.useRef(!1),ue=g.useRef(0),F=d!==o.content&&m!=="saving"&&!w;g.useEffect(()=>(G.current=!0,()=>{G.current=!1,ue.current+=1}),[]),g.useEffect(()=>{ue.current+=1,q.current=!1,L.current=t,R.current=t.read,ae.current=t.read.content,c(t.read),p(t.read.content),f("idle"),y(null),x(!1),k("edit")},[t.id,t.read]),g.useEffect(()=>{L.current=t},[t]),g.useEffect(()=>{R.current=o},[o]),g.useEffect(()=>{ae.current=d},[d]),g.useEffect(()=>{if(d===o.content||w)return;const Z=window.setInterval(()=>{!q.current&&ae.current!==R.current.content&&P()},1e3);return()=>window.clearInterval(Z)},[d===o.content,w,t.id]);async function P(){if(q.current)return;const Z=ae.current,K=R.current;if(Z===K.content)return;const j=L.current,te=ue.current;q.current=!0,f("saving"),y(null),x(!1);try{const se=await e.writeFile({rootToken:j.rootToken,path:j.path,content:Z,expectedVersion:K.version});if(!G.current||te!==ue.current)return;const N={...K,content:Z,version:se.version};R.current=N,c(N),f(ae.current===Z?"saved":"idle")}catch(se){if(!G.current||te!==ue.current)return;if(se instanceof yn&&se.status===409){x(!0),f("idle");return}y(k2(se)),f("idle")}finally{te===ue.current&&(q.current=!1)}}const M=m==="saving"?"saving":m==="saved"?"saved":o.language,Q=o.language==="markdown",ne=Q&&C==="preview";return _.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[_.jsxs("header",{className:"editor-pane-header",children:[_.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),_.jsx("strong",{children:t.title}),_.jsx("span",{className:"terminal-pane-spacer"}),_.jsx("span",{className:"terminal-pane-state",children:M}),_.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!F,onClick:()=>{P()},children:"Save"}),Q?_.jsx("button",{type:"button","aria-label":`${ne?"Edit":"Preview"} ${t.title}`,onClick:()=>k(Z=>Z==="preview"?"edit":"preview"),children:ne?"Edit":"Preview"}):null,n?_.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:a,children:"x"}):null]}),S?_.jsx("div",{className:"editor-pane-alert",role:"alert",children:S}):null,w?_.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,ne?_.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:_.jsx(g.Suspense,{fallback:_.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:_.jsx(T2,{content:d})})}):_.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:Z=>{const K=Z.target.value;ae.current=K,p(K),f("idle"),y(null),x(!1)}})]})}function k2(e){return e instanceof Error?e.message:"Request failed"}var D2=2,R2=1,M2=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),a=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),d={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},p=d.top+d.bottom,m=d.right+d.left,f=a-p,S=o-m-t;return{cols:Math.max(D2,Math.floor(S/e.css.cell.width)),rows:Math.max(R2,Math.floor(f/e.css.cell.height))}}};var f0=Object.defineProperty,A2=Object.getOwnPropertyDescriptor,N2=(e,t)=>{for(var n in t)f0(e,n,{get:t[n],enumerable:!0})},Ht=(e,t,n,a)=>{for(var o=a>1?void 0:a?A2(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=(a?d(t,n,o):d(o))||o);return a&&o&&f0(t,n,o),o},ye=(e,t)=>(n,a)=>t(n,a,e),Gy="Terminal input",Vf={get:()=>Gy,set:e=>Gy=e},Zy="Too much output to announce, navigate to rows manually to read",Xf={get:()=>Zy,set:e=>Zy=e};function B2(e){return e.replace(/\r?\n/g,"\r")}function L2(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function O2(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function z2(e,t,n,a){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");p0(o,t,n,a)}}function p0(e,t,n,a){e=B2(e),e=L2(e,n.decPrivateModes.bracketedPasteMode&&a.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function m0(e,t,n){let a=n.getBoundingClientRect(),o=e.clientX-a.left-10,c=e.clientY-a.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function Qy(e,t,n,a,o){m0(e,t,n),o&&a.rightClickSelect(e),t.value=a.selectionText,t.select()}function tr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Au(e,t=0,n=e.length){let a="";for(let o=t;o<n;++o){let c=e[o];c>65535?(c-=65536,a+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):a+=String.fromCharCode(c)}return a}var j2=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let a=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[a++]=(this._interim-55296)*1024+c-56320+65536:(t[a++]=this._interim,t[a++]=c),this._interim=0}for(let c=o;c<n;++c){let d=e.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=n)return this._interim=d,a;let p=e.charCodeAt(c);56320<=p&&p<=57343?t[a++]=(d-55296)*1024+p-56320+65536:(t[a++]=d,t[a++]=p);continue}d!==65279&&(t[a++]=d)}return a}},H2=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let a=0,o,c,d,p,m=0,f=0;if(this.interim[0]){let w=!1,x=this.interim[0];x&=(x&224)===192?31:(x&240)===224?15:7;let C=0,k;for(;(k=this.interim[++C]&63)&&C<4;)x<<=6,x|=k;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,R=L-C;for(;f<R;){if(f>=n)return 0;if(k=e[f++],(k&192)!==128){f--,w=!0;break}else this.interim[C++]=k,x<<=6,x|=k&63}w||(L===2?x<128?f--:t[a++]=x:L===3?x<2048||x>=55296&&x<=57343||x===65279||(t[a++]=x):x<65536||x>1114111||(t[a++]=x)),this.interim.fill(0)}let S=n-4,y=f;for(;y<n;){for(;y<S&&!((o=e[y])&128)&&!((c=e[y+1])&128)&&!((d=e[y+2])&128)&&!((p=e[y+3])&128);)t[a++]=o,t[a++]=c,t[a++]=d,t[a++]=p,y+=4;if(o=e[y++],o<128)t[a++]=o;else if((o&224)===192){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(m=(o&31)<<6|c&63,m<128){y--;continue}t[a++]=m}else if((o&240)===224){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,a;if(d=e[y++],(d&192)!==128){y--;continue}if(m=(o&15)<<12|(c&63)<<6|d&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[a++]=m}else if((o&248)===240){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,a;if(d=e[y++],(d&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=d,a;if(p=e[y++],(p&192)!==128){y--;continue}if(m=(o&7)<<18|(c&63)<<12|(d&63)<<6|p&63,m<65536||m>1114111)continue;t[a++]=m}}return a}},_0="",sr=" ",Co=class v0{constructor(){this.fg=0,this.bg=0,this.extended=new pu}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new v0;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},pu=class g0{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new g0(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},xs=class y0 extends Co{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new pu,this.combinedData=""}static fromCharData(t){let n=new y0;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?tr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let a=t[1].charCodeAt(0);if(55296<=a&&a<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(a-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Jy="di$target",Gf="di$dependencies",lf=new Map;function U2(e){return e[Gf]||[]}function pi(e){if(lf.has(e))return lf.get(e);let t=function(n,a,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");P2(t,n,o)};return t._id=e,lf.set(e,t),t}function P2(e,t,n){t[Jy]===t?t[Gf].push({id:e,index:n}):(t[Gf]=[{id:e,index:n}],t[Jy]=t)}var Oi=pi("BufferService"),S0=pi("CoreMouseService"),Pr=pi("CoreService"),K2=pi("CharsetService"),gm=pi("InstantiationService"),b0=pi("LogService"),zi=pi("OptionsService"),w0=pi("OscLinkService"),I2=pi("UnicodeService"),xo=pi("DecorationService"),Zf=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let a=[],o=this._optionsService.rawOptions.linkHandler,c=new xs,d=n.getTrimmedLength(),p=-1,m=-1,f=!1;for(let S=0;S<d;S++)if(!(m===-1&&!n.hasContent(S))){if(n.loadCell(S,c),c.hasExtendedAttrs()&&c.extended.urlId)if(m===-1){m=S,p=c.extended.urlId;continue}else f=c.extended.urlId!==p;else m!==-1&&(f=!0);if(f||m!==-1&&S===d-1){let y=this._oscLinkService.getLinkData(p)?.uri;if(y){let w={start:{x:m+1,y:e},end:{x:S+(!f&&S===d-1?1:0),y:e}},x=!1;if(!o?.allowNonHttpProtocols)try{let C=new URL(y);["http:","https:"].includes(C.protocol)||(x=!0)}catch{x=!0}x||a.push({text:y,range:w,activate:(C,k)=>o?o.activate(C,k,w):F2(C,k),hover:(C,k)=>o?.hover?.(C,k,w),leave:(C,k)=>o?.leave?.(C,k,w)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(m=S,p=c.extended.urlId):(m=-1,p=-1)}}t(a)}};Zf=Ht([ye(0,Oi),ye(1,zi),ye(2,w0)],Zf);function F2(e,t){if(confirm(`Do you want to navigate to ${t}?
13
+ `},cx={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function ux(e){let{announcements:t=cx,container:n,hiddenTextDescribedById:a,screenReaderInstructions:o=ox}=e;const{announce:c,announcement:d}=rx(),p=ku("DndLiveRegion"),[m,f]=g.useState(!1);if(g.useEffect(()=>{f(!0)},[]),ax(g.useMemo(()=>({onDragStart(y){let{active:w}=y;c(t.onDragStart({active:w}))},onDragMove(y){let{active:w,over:x}=y;t.onDragMove&&c(t.onDragMove({active:w,over:x}))},onDragOver(y){let{active:w,over:x}=y;c(t.onDragOver({active:w,over:x}))},onDragEnd(y){let{active:w,over:x}=y;c(t.onDragEnd({active:w,over:x}))},onDragCancel(y){let{active:w,over:x}=y;c(t.onDragCancel({active:w,over:x}))}}),[c,t])),!m)return null;const S=xi.createElement(xi.Fragment,null,xi.createElement(sx,{id:a,value:o.draggable}),xi.createElement(nx,{id:p,announcement:d}));return n?Il.createPortal(S,n):S}var ni;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ni||(ni={}));function cu(){}function ky(e,t){return g.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function hx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return g.useMemo(()=>[...t].filter(a=>a!=null),[...t])}const Ns=Object.freeze({x:0,y:0});function dx(e,t){let{data:{value:n}}=e,{data:{value:a}}=t;return a-n}function fx(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function px(e,t){const n=Math.max(t.top,e.top),a=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),c=Math.min(t.top+t.height,e.top+e.height),d=o-a,p=c-n;if(a<o&&n<c){const m=t.width*t.height,f=e.width*e.height,S=d*p,y=S/(m+f-S);return Number(y.toFixed(4))}return 0}const mx=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:a}=e;const o=[];for(const c of a){const{id:d}=c,p=n.get(d);if(p){const m=px(p,t);m>0&&o.push({id:d,data:{droppableContainer:c,value:m}})}}return o.sort(dx)};function _x(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function kb(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Ns}function vx(e){return function(n){for(var a=arguments.length,o=new Array(a>1?a-1:0),c=1;c<a;c++)o[c-1]=arguments[c];return o.reduce((d,p)=>({...d,top:d.top+e*p.y,bottom:d.bottom+e*p.y,left:d.left+e*p.x,right:d.right+e*p.x}),{...n})}}const gx=vx(1);function yx(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Sx(e,t,n){const a=yx(t);if(!a)return e;const{scaleX:o,scaleY:c,x:d,y:p}=a,m=e.left-d-(1-o)*parseFloat(n),f=e.top-p-(1-c)*parseFloat(n.slice(n.indexOf(" ")+1)),S=o?e.width/o:e.width,y=c?e.height/c:e.height;return{width:S,height:y,top:f,right:m+S,bottom:f+y,left:m}}const bx={ignoreTransform:!1};function bo(e,t){t===void 0&&(t=bx);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:f,transformOrigin:S}=$i(e).getComputedStyle(e);f&&(n=Sx(n,f,S))}const{top:a,left:o,width:c,height:d,bottom:p,right:m}=n;return{top:a,left:o,width:c,height:d,bottom:p,right:m}}function Dy(e){return bo(e,{ignoreTransform:!0})}function wx(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Cx(e,t){return t===void 0&&(t=$i(e).getComputedStyle(e)),t.position==="fixed"}function xx(e,t){t===void 0&&(t=$i(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const c=t[o];return typeof c=="string"?n.test(c):!1})}function Zp(e,t){const n=[];function a(o){if(t!=null&&n.length>=t||!o)return n;if(Xp(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!yo(o)||Cb(o)||n.includes(o))return n;const c=$i(e).getComputedStyle(o);return o!==e&&xx(o,c)&&n.push(o),Cx(o,c)?n:a(o.parentNode)}return e?a(e):n}function Db(e){const[t]=Zp(e,1);return t??null}function Gd(e){return!Tu||!e?null:za(e)?e:Vp(e)?Xp(e)||e===ja(e).scrollingElement?window:yo(e)?e:null:null}function Rb(e){return za(e)?e.scrollX:e.scrollLeft}function Mb(e){return za(e)?e.scrollY:e.scrollTop}function kf(e){return{x:Rb(e),y:Mb(e)}}var ui;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ui||(ui={}));function Ab(e){return!Tu||!e?!1:e===document.scrollingElement}function Nb(e){const t={x:0,y:0},n=Ab(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,c=e.scrollLeft<=t.x,d=e.scrollTop>=a.y,p=e.scrollLeft>=a.x;return{isTop:o,isLeft:c,isBottom:d,isRight:p,maxScroll:a,minScroll:t}}const Ex={x:.2,y:.2};function Tx(e,t,n,a,o){let{top:c,left:d,right:p,bottom:m}=n;a===void 0&&(a=10),o===void 0&&(o=Ex);const{isTop:f,isBottom:S,isLeft:y,isRight:w}=Nb(e),x={x:0,y:0},C={x:0,y:0},k={height:t.height*o.y,width:t.width*o.x};return!f&&c<=t.top+k.height?(x.y=ui.Backward,C.y=a*Math.abs((t.top+k.height-c)/k.height)):!S&&m>=t.bottom-k.height&&(x.y=ui.Forward,C.y=a*Math.abs((t.bottom-k.height-m)/k.height)),!w&&p>=t.right-k.width?(x.x=ui.Forward,C.x=a*Math.abs((t.right-k.width-p)/k.width)):!y&&d<=t.left+k.width&&(x.x=ui.Backward,C.x=a*Math.abs((t.left+k.width-d)/k.width)),{direction:x,speed:C}}function kx(e){if(e===document.scrollingElement){const{innerWidth:c,innerHeight:d}=window;return{top:0,left:0,right:c,bottom:d,width:c,height:d}}const{top:t,left:n,right:a,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:a,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Bb(e){return e.reduce((t,n)=>Aa(t,kf(n)),Ns)}function Dx(e){return e.reduce((t,n)=>t+Rb(n),0)}function Rx(e){return e.reduce((t,n)=>t+Mb(n),0)}function Mx(e,t){if(t===void 0&&(t=bo),!e)return;const{top:n,left:a,bottom:o,right:c}=t(e);Db(e)&&(o<=0||c<=0||n>=window.innerHeight||a>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Ax=[["x",["left","right"],Dx],["y",["top","bottom"],Rx]];class Qp{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const a=Zp(n),o=Bb(a);this.rect={...t},this.width=t.width,this.height=t.height;for(const[c,d,p]of Ax)for(const m of d)Object.defineProperty(this,m,{get:()=>{const f=p(a),S=o[c]-f;return this.rect[m]+S},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Gl{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var a;return(a=this.target)==null?void 0:a.removeEventListener(...n)})},this.target=t}add(t,n,a){var o;(o=this.target)==null||o.addEventListener(t,n,a),this.listeners.push([t,n,a])}}function Nx(e){const{EventTarget:t}=$i(e);return e instanceof t?e:ja(e)}function Zd(e,t){const n=Math.abs(e.x),a=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+a**2)>t:"x"in t&&"y"in t?n>t.x&&a>t.y:"x"in t?n>t.x:"y"in t?a>t.y:!1}var bs;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(bs||(bs={}));function Ry(e){e.preventDefault()}function Bx(e){e.stopPropagation()}var vt;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(vt||(vt={}));const Lb={start:[vt.Space,vt.Enter],cancel:[vt.Esc],end:[vt.Space,vt.Enter,vt.Tab]},Lx=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case vt.Right:return{...n,x:n.x+25};case vt.Left:return{...n,x:n.x-25};case vt.Down:return{...n,y:n.y+25};case vt.Up:return{...n,y:n.y-25}}};class Ob{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Gl(ja(n)),this.windowListeners=new Gl($i(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(bs.Resize,this.handleCancel),this.windowListeners.add(bs.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(bs.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,a=t.node.current;a&&Mx(a),n(Ns)}handleKeyDown(t){if(Eb(t)){const{active:n,context:a,options:o}=this.props,{keyboardCodes:c=Lb,coordinateGetter:d=Lx,scrollBehavior:p="smooth"}=o,{code:m}=t;if(c.end.includes(m)){this.handleEnd(t);return}if(c.cancel.includes(m)){this.handleCancel(t);return}const{collisionRect:f}=a.current,S=f?{x:f.left,y:f.top}:Ns;this.referenceCoordinates||(this.referenceCoordinates=S);const y=d(t,{active:n,context:a.current,currentCoordinates:S});if(y){const w=ou(y,S),x={x:0,y:0},{scrollableAncestors:C}=a.current;for(const k of C){const L=t.code,{isTop:R,isRight:ae,isLeft:q,isBottom:G,maxScroll:ue,minScroll:F}=Nb(k),P=kx(k),M={x:Math.min(L===vt.Right?P.right-P.width/2:P.right,Math.max(L===vt.Right?P.left:P.left+P.width/2,y.x)),y:Math.min(L===vt.Down?P.bottom-P.height/2:P.bottom,Math.max(L===vt.Down?P.top:P.top+P.height/2,y.y))},Q=L===vt.Right&&!ae||L===vt.Left&&!q,ne=L===vt.Down&&!G||L===vt.Up&&!R;if(Q&&M.x!==y.x){const Z=k.scrollLeft+w.x,K=L===vt.Right&&Z<=ue.x||L===vt.Left&&Z>=F.x;if(K&&!w.y){k.scrollTo({left:Z,behavior:p});return}K?x.x=k.scrollLeft-Z:x.x=L===vt.Right?k.scrollLeft-ue.x:k.scrollLeft-F.x,x.x&&k.scrollBy({left:-x.x,behavior:p});break}else if(ne&&M.y!==y.y){const Z=k.scrollTop+w.y,K=L===vt.Down&&Z<=ue.y||L===vt.Up&&Z>=F.y;if(K&&!w.x){k.scrollTo({top:Z,behavior:p});return}K?x.y=k.scrollTop-Z:x.y=L===vt.Down?k.scrollTop-ue.y:k.scrollTop-F.y,x.y&&k.scrollBy({top:-x.y,behavior:p});break}}this.handleMove(t,Aa(ou(y,this.referenceCoordinates),x))}}}handleMove(t,n){const{onMove:a}=this.props;t.preventDefault(),a(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Ob.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:a=Lb,onActivation:o}=t,{active:c}=n;const{code:d}=e.nativeEvent;if(a.start.includes(d)){const p=c.activatorNode.current;return p&&e.target!==p?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function My(e){return!!(e&&"distance"in e)}function Ay(e){return!!(e&&"delay"in e)}class Jp{constructor(t,n,a){var o;a===void 0&&(a=Nx(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:c}=t,{target:d}=c;this.props=t,this.events=n,this.document=ja(d),this.documentListeners=new Gl(this.document),this.listeners=new Gl(a),this.windowListeners=new Gl($i(d)),this.initialCoordinates=(o=Ef(c))!=null?o:Ns,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:a}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(bs.Resize,this.handleCancel),this.windowListeners.add(bs.DragStart,Ry),this.windowListeners.add(bs.VisibilityChange,this.handleCancel),this.windowListeners.add(bs.ContextMenu,Ry),this.documentListeners.add(bs.Keydown,this.handleKeydown),n){if(a!=null&&a({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ay(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(My(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:a,onPending:o}=this.props;o(a,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(bs.Click,Bx,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(bs.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:a,initialCoordinates:o,props:c}=this,{onMove:d,options:{activationConstraint:p}}=c;if(!o)return;const m=(n=Ef(t))!=null?n:Ns,f=ou(o,m);if(!a&&p){if(My(p)){if(p.tolerance!=null&&Zd(f,p.tolerance))return this.handleCancel();if(Zd(f,p.distance))return this.handleStart()}if(Ay(p)&&Zd(f,p.tolerance))return this.handleCancel();this.handlePending(p,f);return}t.cancelable&&t.preventDefault(),d(m)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===vt.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Ox={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class zb extends Jp{constructor(t){const{event:n}=t,a=ja(n.target);super(t,Ox,a)}}zb.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:a}=t;return!n.isPrimary||n.button!==0?!1:(a?.({event:n}),!0)}}];const zx={move:{name:"mousemove"},end:{name:"mouseup"}};var Df;(function(e){e[e.RightClick=2]="RightClick"})(Df||(Df={}));class jb extends Jp{constructor(t){super(t,zx,ja(t.event.target))}}jb.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:a}=t;return n.button===Df.RightClick?!1:(a?.({event:n}),!0)}}];const Qd={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Hb extends Jp{constructor(t){super(t,Qd)}static setup(){return window.addEventListener(Qd.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Qd.move.name,t)};function t(){}}}Hb.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:a}=t;const{touches:o}=n;return o.length>1?!1:(a?.({event:n}),!0)}}];var Zl;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Zl||(Zl={}));var uu;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(uu||(uu={}));function jx(e){let{acceleration:t,activator:n=Zl.Pointer,canScroll:a,draggingRect:o,enabled:c,interval:d=5,order:p=uu.TreeOrder,pointerCoordinates:m,scrollableAncestors:f,scrollableAncestorRects:S,delta:y,threshold:w}=e;const x=Ux({delta:y,disabled:!c}),[C,k]=QC(),L=g.useRef({x:0,y:0}),R=g.useRef({x:0,y:0}),ae=g.useMemo(()=>{switch(n){case Zl.Pointer:return m?{top:m.y,bottom:m.y,left:m.x,right:m.x}:null;case Zl.DraggableRect:return o}},[n,o,m]),q=g.useRef(null),G=g.useCallback(()=>{const F=q.current;if(!F)return;const P=L.current.x*R.current.x,M=L.current.y*R.current.y;F.scrollBy(P,M)},[]),ue=g.useMemo(()=>p===uu.TreeOrder?[...f].reverse():f,[p,f]);g.useEffect(()=>{if(!c||!f.length||!ae){k();return}for(const F of ue){if(a?.(F)===!1)continue;const P=f.indexOf(F),M=S[P];if(!M)continue;const{direction:Q,speed:ne}=Tx(F,M,ae,t,w);for(const Z of["x","y"])x[Z][Q[Z]]||(ne[Z]=0,Q[Z]=0);if(ne.x>0||ne.y>0){k(),q.current=F,C(G,d),L.current=ne,R.current=Q;return}}L.current={x:0,y:0},R.current={x:0,y:0},k()},[t,G,a,k,c,d,JSON.stringify(ae),JSON.stringify(x),C,f,ue,S,JSON.stringify(w)])}const Hx={x:{[ui.Backward]:!1,[ui.Forward]:!1},y:{[ui.Backward]:!1,[ui.Forward]:!1}};function Ux(e){let{delta:t,disabled:n}=e;const a=xf(t);return So(o=>{if(n||!a||!o)return Hx;const c={x:Math.sign(t.x-a.x),y:Math.sign(t.y-a.y)};return{x:{[ui.Backward]:o.x[ui.Backward]||c.x===-1,[ui.Forward]:o.x[ui.Forward]||c.x===1},y:{[ui.Backward]:o.y[ui.Backward]||c.y===-1,[ui.Forward]:o.y[ui.Forward]||c.y===1}}},[n,t,a])}function Px(e,t){const n=t!=null?e.get(t):void 0,a=n?n.node.current:null;return So(o=>{var c;return t==null?null:(c=a??o)!=null?c:null},[a,t])}function Kx(e,t){return g.useMemo(()=>e.reduce((n,a)=>{const{sensor:o}=a,c=o.activators.map(d=>({eventName:d.eventName,handler:t(d.handler,a)}));return[...n,...c]},[]),[e,t])}var no;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(no||(no={}));var Rf;(function(e){e.Optimized="optimized"})(Rf||(Rf={}));const Ny=new Map;function Ix(e,t){let{dragging:n,dependencies:a,config:o}=t;const[c,d]=g.useState(null),{frequency:p,measure:m,strategy:f}=o,S=g.useRef(e),y=L(),w=so(y),x=g.useCallback(function(R){R===void 0&&(R=[]),!w.current&&d(ae=>ae===null?R:ae.concat(R.filter(q=>!ae.includes(q))))},[w]),C=g.useRef(null),k=So(R=>{if(y&&!n)return Ny;if(!R||R===Ny||S.current!==e||c!=null){const ae=new Map;for(let q of e){if(!q)continue;if(c&&c.length>0&&!c.includes(q.id)&&q.rect.current){ae.set(q.id,q.rect.current);continue}const G=q.node.current,ue=G?new Qp(m(G),G):null;q.rect.current=ue,ue&&ae.set(q.id,ue)}return ae}return R},[e,c,n,y,m]);return g.useEffect(()=>{S.current=e},[e]),g.useEffect(()=>{y||x()},[n,y]),g.useEffect(()=>{c&&c.length>0&&d(null)},[JSON.stringify(c)]),g.useEffect(()=>{y||typeof p!="number"||C.current!==null||(C.current=setTimeout(()=>{x(),C.current=null},p))},[p,y,x,...a]),{droppableRects:k,measureDroppableContainers:x,measuringScheduled:c!=null};function L(){switch(f){case no.Always:return!1;case no.BeforeDragging:return n;default:return!n}}}function Ub(e,t){return So(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Fx(e,t){return Ub(e,t)}function qx(e){let{callback:t,disabled:n}=e;const a=Gp(t),o=g.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:c}=window;return new c(a)},[a,n]);return g.useEffect(()=>()=>o?.disconnect(),[o]),o}function Du(e){let{callback:t,disabled:n}=e;const a=Gp(t),o=g.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:c}=window;return new c(a)},[n]);return g.useEffect(()=>()=>o?.disconnect(),[o]),o}function Wx(e){return new Qp(bo(e),e)}function By(e,t,n){t===void 0&&(t=Wx);const[a,o]=g.useState(null);function c(){o(m=>{if(!e)return null;if(e.isConnected===!1){var f;return(f=m??n)!=null?f:null}const S=t(e);return JSON.stringify(m)===JSON.stringify(S)?m:S})}const d=qx({callback(m){if(e)for(const f of m){const{type:S,target:y}=f;if(S==="childList"&&y instanceof HTMLElement&&y.contains(e)){c();break}}}}),p=Du({callback:c});return ar(()=>{c(),e?(p?.observe(e),d?.observe(document.body,{childList:!0,subtree:!0})):(p?.disconnect(),d?.disconnect())},[e]),a}function Yx(e){const t=Ub(e);return kb(e,t)}const Ly=[];function $x(e){const t=g.useRef(e),n=So(a=>e?a&&a!==Ly&&e&&t.current&&e.parentNode===t.current.parentNode?a:Zp(e):Ly,[e]);return g.useEffect(()=>{t.current=e},[e]),n}function Vx(e){const[t,n]=g.useState(null),a=g.useRef(e),o=g.useCallback(c=>{const d=Gd(c.target);d&&n(p=>p?(p.set(d,kf(d)),new Map(p)):null)},[]);return g.useEffect(()=>{const c=a.current;if(e!==c){d(c);const p=e.map(m=>{const f=Gd(m);return f?(f.addEventListener("scroll",o,{passive:!0}),[f,kf(f)]):null}).filter(m=>m!=null);n(p.length?new Map(p):null),a.current=e}return()=>{d(e),d(c)};function d(p){p.forEach(m=>{const f=Gd(m);f?.removeEventListener("scroll",o)})}},[o,e]),g.useMemo(()=>e.length?t?Array.from(t.values()).reduce((c,d)=>Aa(c,d),Ns):Bb(e):Ns,[e,t])}function Oy(e,t){t===void 0&&(t=[]);const n=g.useRef(null);return g.useEffect(()=>{n.current=null},t),g.useEffect(()=>{const a=e!==Ns;a&&!n.current&&(n.current=e),!a&&n.current&&(n.current=null)},[e]),n.current?ou(e,n.current):Ns}function Xx(e){g.useEffect(()=>{if(!Tu)return;const t=e.map(n=>{let{sensor:a}=n;return a.setup==null?void 0:a.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function Gx(e,t){return g.useMemo(()=>e.reduce((n,a)=>{let{eventName:o,handler:c}=a;return n[o]=d=>{c(d,t)},n},{}),[e,t])}function Pb(e){return g.useMemo(()=>e?wx(e):null,[e])}const zy=[];function Zx(e,t){t===void 0&&(t=bo);const[n]=e,a=Pb(n?$i(n):null),[o,c]=g.useState(zy);function d(){c(()=>e.length?e.map(m=>Ab(m)?a:new Qp(t(m),m)):zy)}const p=Du({callback:d});return ar(()=>{p?.disconnect(),d(),e.forEach(m=>p?.observe(m))},[e]),o}function Qx(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return yo(t)?t:e}function Jx(e){let{measure:t}=e;const[n,a]=g.useState(null),o=g.useCallback(f=>{for(const{target:S}of f)if(yo(S)){a(y=>{const w=t(S);return y?{...y,width:w.width,height:w.height}:w});break}},[t]),c=Du({callback:o}),d=g.useCallback(f=>{const S=Qx(f);c?.disconnect(),S&&c?.observe(S),a(S?t(S):null)},[t,c]),[p,m]=lu(d);return g.useMemo(()=>({nodeRef:p,rect:n,setRef:m}),[n,p,m])}const eE=[{sensor:zb,options:{}},{sensor:Ob,options:{}}],tE={current:{}},Gc={draggable:{measure:Dy},droppable:{measure:Dy,strategy:no.WhileDragging,frequency:Rf.Optimized},dragOverlay:{measure:bo}};class Ql extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,a;return(n=(a=this.get(t))==null?void 0:a.node.current)!=null?n:void 0}}const iE={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ql,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:cu},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Gc,measureDroppableContainers:cu,windowRect:null,measuringScheduled:!1},sE={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:cu,draggableNodes:new Map,over:null,measureDroppableContainers:cu},Ru=g.createContext(sE),nE=g.createContext(iE);function rE(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ql}}}function aE(e,t){switch(t.type){case ni.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case ni.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case ni.DragEnd:case ni.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ni.RegisterDroppable:{const{element:n}=t,{id:a}=n,o=new Ql(e.droppable.containers);return o.set(a,n),{...e,droppable:{...e.droppable,containers:o}}}case ni.SetDroppableDisabled:{const{id:n,key:a,disabled:o}=t,c=e.droppable.containers.get(n);if(!c||a!==c.key)return e;const d=new Ql(e.droppable.containers);return d.set(n,{...c,disabled:o}),{...e,droppable:{...e.droppable,containers:d}}}case ni.UnregisterDroppable:{const{id:n,key:a}=t,o=e.droppable.containers.get(n);if(!o||a!==o.key)return e;const c=new Ql(e.droppable.containers);return c.delete(n),{...e,droppable:{...e.droppable,containers:c}}}default:return e}}function lE(e){let{disabled:t}=e;const{active:n,activatorEvent:a,draggableNodes:o}=g.useContext(Ru),c=xf(a),d=xf(n?.id);return g.useEffect(()=>{if(!t&&!a&&c&&d!=null){if(!Eb(c)||document.activeElement===c.target)return;const p=o.get(d);if(!p)return;const{activatorNode:m,node:f}=p;if(!m.current&&!f.current)return;requestAnimationFrame(()=>{for(const S of[m.current,f.current]){if(!S)continue;const y=tx(S);if(y){y.focus();break}}})}},[a,t,o,d,c]),null}function oE(e,t){let{transform:n,...a}=t;return e!=null&&e.length?e.reduce((o,c)=>c({transform:o,...a}),n):n}function cE(e){return g.useMemo(()=>({draggable:{...Gc.draggable,...e?.draggable},droppable:{...Gc.droppable,...e?.droppable},dragOverlay:{...Gc.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function uE(e){let{activeNode:t,measure:n,initialRect:a,config:o=!0}=e;const c=g.useRef(!1),{x:d,y:p}=typeof o=="boolean"?{x:o,y:o}:o;ar(()=>{if(!d&&!p||!t){c.current=!1;return}if(c.current||!a)return;const f=t?.node.current;if(!f||f.isConnected===!1)return;const S=n(f),y=kb(S,a);if(d||(y.x=0),p||(y.y=0),c.current=!0,Math.abs(y.x)>0||Math.abs(y.y)>0){const w=Db(f);w&&w.scrollBy({top:y.y,left:y.x})}},[t,d,p,a,n])}const Kb=g.createContext({...Ns,scaleX:1,scaleY:1});var er;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(er||(er={}));const hE=g.memo(function(t){var n,a,o,c;let{id:d,accessibility:p,autoScroll:m=!0,children:f,sensors:S=eE,collisionDetection:y=mx,measuring:w,modifiers:x,...C}=t;const k=g.useReducer(aE,void 0,rE),[L,R]=k,[ae,q]=lx(),[G,ue]=g.useState(er.Uninitialized),F=G===er.Initialized,{draggable:{active:P,nodes:M,translate:Q},droppable:{containers:ne}}=L,Z=P!=null?M.get(P):null,K=g.useRef({initial:null,translated:null}),j=g.useMemo(()=>{var ot;return P!=null?{id:P,data:(ot=Z?.data)!=null?ot:tE,rect:K}:null},[P,Z]),te=g.useRef(null),[se,N]=g.useState(null),[$,X]=g.useState(null),ve=so(C,Object.values(C)),Se=ku("DndDescribedBy",d),E=g.useMemo(()=>ne.getEnabled(),[ne]),W=cE(w),{droppableRects:J,measureDroppableContainers:he,measuringScheduled:ge}=Ix(E,{dragging:F,dependencies:[Q.x,Q.y],config:W.droppable}),pe=Px(M,P),Ce=g.useMemo(()=>$?Ef($):null,[$]),Oe=ks(),Ne=Fx(pe,W.draggable.measure);uE({activeNode:P!=null?M.get(P):null,config:Oe.layoutShiftCompensation,initialRect:Ne,measure:W.draggable.measure});const Re=By(pe,W.draggable.measure,Ne),Ue=By(pe?pe.parentElement:null),Ye=g.useRef({activatorEvent:null,active:null,activeNode:pe,collisionRect:null,collisions:null,droppableRects:J,draggableNodes:M,draggingNode:null,draggingNodeRect:null,droppableContainers:ne,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Be=ne.getNodeFor((n=Ye.current.over)==null?void 0:n.id),le=Jx({measure:W.dragOverlay.measure}),Ee=(a=le.nodeRef.current)!=null?a:pe,xe=F?(o=le.rect)!=null?o:Re:null,Ke=!!(le.nodeRef.current&&le.rect),Xe=Yx(Ke?null:Re),gt=Pb(Ee?$i(Ee):null),yt=$x(F?Be??pe:null),mi=Zx(yt),ee=oE(x,{transform:{x:Q.x-Xe.x,y:Q.y-Xe.y,scaleX:1,scaleY:1},activatorEvent:$,active:j,activeNodeRect:Re,containerNodeRect:Ue,draggingNodeRect:xe,over:Ye.current.over,overlayNodeRect:le.rect,scrollableAncestors:yt,scrollableAncestorRects:mi,windowRect:gt}),ze=Ce?Aa(Ce,Q):null,je=Vx(yt),_i=Oy(je),Vi=Oy(je,[Re]),ai=Aa(ee,_i),kt=xe?gx(xe,ee):null,ji=j&&kt?y({active:j,collisionRect:kt,droppableRects:J,droppableContainers:E,pointerCoordinates:ze}):null,Ti=fx(ji,"id"),[Nt,$s]=g.useState(null),Hi=Ke?ee:Aa(ee,Vi),qt=_x(Hi,(c=Nt?.rect)!=null?c:null,Re),Jt=g.useRef(null),Dt=g.useCallback((ot,St)=>{let{sensor:Rt,options:li}=St;if(te.current==null)return;const ei=M.get(te.current);if(!ei)return;const Bt=ot.nativeEvent,nt=new Rt({active:te.current,activeNode:ei,event:Bt,options:li,context:Ye,onAbort(bt){if(!M.get(bt))return;const{onDragAbort:ct}=ve.current,vi={id:bt};ct?.(vi),ae({type:"onDragAbort",event:vi})},onPending(bt,Ge,ct,vi){if(!M.get(bt))return;const{onDragPending:Ni}=ve.current,ki={id:bt,constraint:Ge,initialCoordinates:ct,offset:vi};Ni?.(ki),ae({type:"onDragPending",event:ki})},onStart(bt){const Ge=te.current;if(Ge==null)return;const ct=M.get(Ge);if(!ct)return;const{onDragStart:vi}=ve.current,Ai={activatorEvent:Bt,active:{id:Ge,data:ct.data,rect:K}};Il.unstable_batchedUpdates(()=>{vi?.(Ai),ue(er.Initializing),R({type:ni.DragStart,initialCoordinates:bt,active:Ge}),ae({type:"onDragStart",event:Ai}),N(Jt.current),X(Bt)})},onMove(bt){R({type:ni.DragMove,coordinates:bt})},onEnd:Wt(ni.DragEnd),onCancel:Wt(ni.DragCancel)});Jt.current=nt;function Wt(bt){return async function(){const{active:ct,collisions:vi,over:Ai,scrollAdjustedTranslate:Ni}=Ye.current;let ki=null;if(ct&&Ni){const{cancelDrop:cs}=ve.current;ki={activatorEvent:Bt,active:ct,collisions:vi,delta:Ni,over:Ai},bt===ni.DragEnd&&typeof cs=="function"&&await Promise.resolve(cs(ki))&&(bt=ni.DragCancel)}te.current=null,Il.unstable_batchedUpdates(()=>{R({type:bt}),ue(er.Uninitialized),$s(null),N(null),X(null),Jt.current=null;const cs=bt===ni.DragEnd?"onDragEnd":"onDragCancel";if(ki){const gi=ve.current[cs];gi?.(ki),ae({type:cs,event:ki})}})}}},[M]),Cn=g.useCallback((ot,St)=>(Rt,li)=>{const ei=Rt.nativeEvent,Bt=M.get(li);if(te.current!==null||!Bt||ei.dndKit||ei.defaultPrevented)return;const nt={active:Bt};ot(Rt,St.options,nt)===!0&&(ei.dndKit={capturedBy:St.sensor},te.current=li,Dt(Rt,St))},[M,Dt]),Bs=Kx(S,Cn);Xx(S),ar(()=>{Re&&G===er.Initializing&&ue(er.Initialized)},[Re,G]),g.useEffect(()=>{const{onDragMove:ot}=ve.current,{active:St,activatorEvent:Rt,collisions:li,over:ei}=Ye.current;if(!St||!Rt)return;const Bt={active:St,activatorEvent:Rt,collisions:li,delta:{x:ai.x,y:ai.y},over:ei};Il.unstable_batchedUpdates(()=>{ot?.(Bt),ae({type:"onDragMove",event:Bt})})},[ai.x,ai.y]),g.useEffect(()=>{const{active:ot,activatorEvent:St,collisions:Rt,droppableContainers:li,scrollAdjustedTranslate:ei}=Ye.current;if(!ot||te.current==null||!St||!ei)return;const{onDragOver:Bt}=ve.current,nt=li.get(Ti),Wt=nt&&nt.rect.current?{id:nt.id,rect:nt.rect.current,data:nt.data,disabled:nt.disabled}:null,bt={active:ot,activatorEvent:St,collisions:Rt,delta:{x:ei.x,y:ei.y},over:Wt};Il.unstable_batchedUpdates(()=>{$s(Wt),Bt?.(bt),ae({type:"onDragOver",event:bt})})},[Ti]),ar(()=>{Ye.current={activatorEvent:$,active:j,activeNode:pe,collisionRect:kt,collisions:ji,droppableRects:J,draggableNodes:M,draggingNode:Ee,draggingNodeRect:xe,droppableContainers:ne,over:Nt,scrollableAncestors:yt,scrollAdjustedTranslate:ai},K.current={initial:xe,translated:kt}},[j,pe,ji,kt,M,Ee,xe,J,ne,Nt,yt,ai]),jx({...Oe,delta:Q,draggingRect:kt,pointerCoordinates:ze,scrollableAncestors:yt,scrollableAncestorRects:mi});const Vs=g.useMemo(()=>({active:j,activeNode:pe,activeNodeRect:Re,activatorEvent:$,collisions:ji,containerNodeRect:Ue,dragOverlay:le,draggableNodes:M,droppableContainers:ne,droppableRects:J,over:Nt,measureDroppableContainers:he,scrollableAncestors:yt,scrollableAncestorRects:mi,measuringConfiguration:W,measuringScheduled:ge,windowRect:gt}),[j,pe,Re,$,ji,Ue,le,M,ne,J,Nt,he,yt,mi,W,ge,gt]),Ts=g.useMemo(()=>({activatorEvent:$,activators:Bs,active:j,activeNodeRect:Re,ariaDescribedById:{draggable:Se},dispatch:R,draggableNodes:M,over:Nt,measureDroppableContainers:he}),[$,Bs,j,Re,R,Se,M,Nt,he]);return xi.createElement(Tb.Provider,{value:q},xi.createElement(Ru.Provider,{value:Ts},xi.createElement(nE.Provider,{value:Vs},xi.createElement(Kb.Provider,{value:qt},f)),xi.createElement(lE,{disabled:p?.restoreFocus===!1})),xi.createElement(ux,{...p,hiddenTextDescribedById:Se}));function ks(){const ot=se?.autoScrollEnabled===!1,St=typeof m=="object"?m.enabled===!1:m===!1,Rt=F&&!ot&&!St;return typeof m=="object"?{...m,enabled:Rt}:{enabled:Rt}}}),dE=g.createContext(null),jy="button",fE="Draggable";function Ib(e){let{id:t,data:n,disabled:a=!1,attributes:o}=e;const c=ku(fE),{activators:d,activatorEvent:p,active:m,activeNodeRect:f,ariaDescribedById:S,draggableNodes:y,over:w}=g.useContext(Ru),{role:x=jy,roleDescription:C="draggable",tabIndex:k=0}=o??{},L=m?.id===t,R=g.useContext(L?Kb:dE),[ae,q]=lu(),[G,ue]=lu(),F=Gx(d,t),P=so(n);ar(()=>(y.set(t,{id:t,key:c,node:ae,activatorNode:G,data:P}),()=>{const Q=y.get(t);Q&&Q.key===c&&y.delete(t)}),[y,t]);const M=g.useMemo(()=>({role:x,tabIndex:k,"aria-disabled":a,"aria-pressed":L&&x===jy?!0:void 0,"aria-roledescription":C,"aria-describedby":S.draggable}),[a,x,k,L,C,S.draggable]);return{active:m,activatorEvent:p,activeNodeRect:f,attributes:M,isDragging:L,listeners:a?void 0:F,node:ae,over:w,setNodeRef:q,setActivatorNodeRef:ue,transform:R}}const pE="Droppable",mE={timeout:25};function Fb(e){let{data:t,disabled:n=!1,id:a,resizeObserverConfig:o}=e;const c=ku(pE),{active:d,dispatch:p,over:m,measureDroppableContainers:f}=g.useContext(Ru),S=g.useRef({disabled:n}),y=g.useRef(!1),w=g.useRef(null),x=g.useRef(null),{disabled:C,updateMeasurementsFor:k,timeout:L}={...mE,...o},R=so(k??a),ae=g.useCallback(()=>{if(!y.current){y.current=!0;return}x.current!=null&&clearTimeout(x.current),x.current=setTimeout(()=>{f(Array.isArray(R.current)?R.current:[R.current]),x.current=null},L)},[L]),q=Du({callback:ae,disabled:C||!d}),G=g.useCallback((M,Q)=>{q&&(Q&&(q.unobserve(Q),y.current=!1),M&&q.observe(M))},[q]),[ue,F]=lu(G),P=so(t);return g.useEffect(()=>{!q||!ue.current||(q.disconnect(),y.current=!1,q.observe(ue.current))},[ue,q]),g.useEffect(()=>(p({type:ni.RegisterDroppable,element:{id:a,key:c,disabled:n,node:ue,rect:w,data:P}}),()=>p({type:ni.UnregisterDroppable,key:c,id:a})),[a]),g.useEffect(()=>{n!==S.current.disabled&&(p({type:ni.SetDroppableDisabled,id:a,key:c,disabled:n}),S.current.disabled=n)},[a,c,n,p]),{active:d,rect:w,isOver:m?.id===a,node:ue,over:m,setNodeRef:F}}const _E=128,vE=512,gE=64,yE=4096;function qb(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.activeWorkspaceId!="string"&&t.activeWorkspaceId!==null||!Array.isArray(t.workspaces)||t.workspaces.length>_E)return null;const n=t.workspaces.map(SE);return n.some(a=>a===null)?null:{activeWorkspaceId:t.activeWorkspaceId,workspaces:n}}function SE(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTabId!="string"&&t.activeTabId!==null||!Array.isArray(t.tabs)||t.tabs.length>vE)return null;const n=t.tabs.map(bE);return n.some(a=>a===null)?null:{id:t.id,title:t.title,activeTabId:t.activeTabId,tabs:n}}function bE(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.id!="string"||typeof t.title!="string"||typeof t.activeTerminalId!="string")return null;const n=wE(t.root);return n?{id:t.id,title:t.title,activeTerminalId:t.activeTerminalId,root:n}:null}function wE(e){if(!e||typeof e!="object")return null;let t=0;return Mf(e,1,()=>(t+=1,t<=yE))}function Mf(e,t,n){if(!e||typeof e!="object"||t>gE||!n())return null;const a=e;if(a.type==="pane")return typeof a.terminalId=="string"?{type:"pane",terminalId:a.terminalId}:null;if(a.type!=="split"||a.direction!=="horizontal"&&a.direction!=="vertical")return null;const o=Mf(a.first,t+1,n),c=Mf(a.second,t+1,n);return!o||!c?null:{type:"split",direction:a.direction,ratio:CE(a.ratio),first:o,second:c}}function CE(e){return typeof e=="number"&&Number.isFinite(e)?Math.min(.9,Math.max(.1,e)):.5}const Wb=[{id:"builtin-character-2260",filename:"character-2260.mp4",contentType:"video/mp4",size:123288,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2260.mp4"},{id:"builtin-character-2272",filename:"character-2272.mp4",contentType:"video/mp4",size:55873,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2272.mp4"},{id:"builtin-character-2258",filename:"character-2258.mp4",contentType:"video/mp4",size:112612,createdAt:"2026-05-26T00:00:00.000Z",url:"/assets/notifications/character-2258.mp4"}];function Hy(e){return e===void 0?"unknown":e==="error"?"offline":"ok"}function Uy(e){const t=e.trim();return t?t.charAt(0).toUpperCase():"?"}const Py="Local",xE=3e4;function Jd(e){return e===void 0?"":e==="error"?"offline":[`CPU ${Cs(e.cpuPercent)} ${em(e)}`,`MEM ${Cs(e.memoryPercent)} ${Sn(e.memoryUsedBytes,e.memoryTotalBytes)}`,`DISK ${Cs(e.diskPercent)} ${Sn(e.diskUsedBytes,e.diskTotalBytes)}`,`SWAP ${Cs(e.swapPercent)} ${Sn(e.swapUsedBytes,e.swapTotalBytes)}`].join(" · ")}function EE(e){if(!(e===void 0||e==="error"))return[`CPU ${Cs(e.cpuPercent)} (${em(e)})`,`RAM ${Cs(e.memoryPercent)} (${Sn(e.memoryUsedBytes,e.memoryTotalBytes)})`,`Disk ${Cs(e.diskPercent)} (${Sn(e.diskUsedBytes,e.diskTotalBytes)})`,`Swap ${Cs(e.swapPercent)} (${Sn(e.swapUsedBytes,e.swapTotalBytes)})`].join(" · ")}function Cs(e){return typeof e=="number"&&Number.isFinite(e)?`${Math.round(e)}%`:"–"}function em(e){const t=Number.isFinite(e.cores)&&e.cores>0?e.cores:null;return e.cpuPercent===null||e.cpuPercent===void 0||!Number.isFinite(e.cpuPercent)||t===null?`–/${t??"–"} cores`:`${Af(e.cpuPercent/100*t)}/${t} cores`}function Sn(e,t){return!Ky(e)||!Ky(t)?"–/–":TE(e,t)}function TE(e,t){const n=t>=1073741824?"GB":t>=1048576?"MB":"KB",a=n==="GB"?1024**3:n==="MB"?1024**2:1024;return`${Af(e/a)}/${Af(t/a)} ${n}`}function Af(e){return e>=10||Number.isInteger(e)?e.toFixed(0):e.toFixed(1)}function Ky(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}function kE(e){return[{label:"CPU",percent:Cs(e.cpuPercent),detail:em(e)},{label:"MEM",percent:Cs(e.memoryPercent),detail:Sn(e.memoryUsedBytes,e.memoryTotalBytes)},{label:"DISK",percent:Cs(e.diskPercent),detail:Sn(e.diskUsedBytes,e.diskTotalBytes)},{label:"SWAP",percent:Cs(e.swapPercent),detail:Sn(e.swapUsedBytes,e.swapTotalBytes)}]}function Iy({entry:e}){return e==="error"?_.jsx("span",{className:"server-list-stats server-list-stats--offline",children:"offline"}):e===void 0?_.jsx("span",{className:"server-list-stats server-list-stats-grid","aria-hidden":"true",children:["CPU","MEM","DISK","SWAP"].map(t=>_.jsxs("span",{className:"server-list-stat-cell",children:[_.jsx("span",{className:"server-list-stat-label",children:t}),_.jsx("span",{className:"server-list-stat-value",children:"–"}),_.jsx("span",{className:"server-list-stat-detail",children:"–"})]},t))}):_.jsx("span",{className:"server-list-stats server-list-stats-grid",title:EE(e),children:kE(e).map(t=>_.jsxs("span",{className:"server-list-stat-cell",children:[_.jsx("span",{className:"server-list-stat-label",children:t.label}),_.jsx("span",{className:"server-list-stat-value",children:t.percent}),_.jsx("span",{className:"server-list-stat-detail",children:t.detail})]},t.label))})}function ef({api:e,activeAgentId:t,onSelectServer:n,onSessionInvalid:a,refreshToken:o=0,compact:c=!1}){const[d,p]=g.useState([]),[m,f]=g.useState(null),[S,y]=g.useState(null),[w,x]=g.useState(""),C=g.useRef(null),[k,L]=g.useState({});g.useEffect(()=>{let F=!1;return e.listAgents().then(P=>{F||p(P.agents)}).catch(()=>{}),e.getMainInfo().then(P=>{F||f(P.name)}).catch(()=>{}),()=>{F=!0}},[e,o]),g.useEffect(()=>{S&&(C.current?.focus(),C.current?.select())},[S]),g.useEffect(()=>{let F=!1;async function P(){let Q=!1;const ne=[{key:"__main__",load:()=>e.getMainStats()},...d.map(K=>({key:K.id,load:()=>e.getAgentStats(K.id)}))],Z=await Promise.all(ne.map(async K=>{try{return[K.key,await K.load()]}catch(j){return j instanceof yn&&j.status===401?(Q=!0,[K.key,"error"]):[K.key,"error"]}}));if(!F){if(Q){a?.();return}L(K=>{const j={};for(const[se,N]of Z)j[se]=N;const te=new Set(["__main__",...d.map(se=>se.id)]);for(const se of Object.keys(K))!te.has(se)||se in j||(j[se]=K[se]);return j})}}P();const M=window.setInterval(()=>{P()},xE);return()=>{F=!0,window.clearInterval(M)}},[e,d,a]);function R(F){F==="main"?(x(m??""),y({kind:"main"})):(x(F.name),y({kind:"agent",id:F.id}))}async function ae(){if(!S)return;const F=w.trim(),P=S;if(y(null),P.kind==="main"){const M=F||"";try{const Q=await e.renameMain(M);f(Q.name)}catch{}}else{if(!F)return;const M=d.find(Q=>Q.id===P.id)?.name;p(Q=>Q.map(ne=>ne.id===P.id?{...ne,name:F}:ne));try{await e.renameAgent(P.id,F)}catch{M!==void 0&&p(Q=>Q.map(ne=>ne.id===P.id?{...ne,name:M}:ne))}}}function q(){y(null)}const G=m?.trim()||Py,ue=S?.kind==="main";return c?_.jsxs("div",{className:"server-list server-list--compact",children:[_.jsxs("button",{type:"button",className:`server-list-chip${t===null?" server-list-chip--active":""}`,onClick:()=>n(null),"aria-label":G,title:`${G}${Jd(k.__main__)?` — ${Jd(k.__main__)}`:""}`,children:[_.jsx("span",{className:"server-list-chip-initial",children:Uy(G)}),_.jsx("span",{className:"server-list-chip-pip","data-status":Hy(k.__main__)})]}),d.map(F=>{const P=k[F.id],M=Jd(P);return _.jsxs("button",{type:"button",className:`server-list-chip${t===F.id?" server-list-chip--active":""}`,onClick:()=>n(F.id),"aria-label":F.name,title:`${F.name}${M?` — ${M}`:""}`,children:[_.jsx("span",{className:"server-list-chip-initial",children:Uy(F.name)}),_.jsx("span",{className:"server-list-chip-pip","data-status":Hy(P)})]},F.id)})]}):_.jsxs("div",{className:"server-list",children:[_.jsx("div",{className:"server-list-row",children:ue?_.jsx("form",{className:"server-list-editor",onSubmit:F=>{F.preventDefault(),ae()},children:_.jsx("input",{ref:C,"aria-label":"Rename main server",value:w,onChange:F=>x(F.target.value),onBlur:()=>{ae()},onKeyDown:F=>{F.key==="Escape"&&(F.preventDefault(),q())},placeholder:Py})}):_.jsxs("button",{type:"button",className:`server-list-item${t===null?" server-list-item--active":""}`,onClick:()=>n(null),onDoubleClick:F=>{F.preventDefault(),R("main")},title:"Double-click to rename",children:[_.jsxs("span",{className:"server-list-item-header",children:[_.jsx("span",{className:"server-list-dot"}),_.jsx("span",{className:"server-list-name",children:G})]}),_.jsx(Iy,{entry:k.__main__})]})}),d.map(F=>{const P=S?.kind==="agent"&&S.id===F.id;return _.jsx("div",{className:"server-list-row",children:P?_.jsx("form",{className:"server-list-editor",onSubmit:M=>{M.preventDefault(),ae()},children:_.jsx("input",{ref:C,"aria-label":`Rename ${F.name}`,value:w,onChange:M=>x(M.target.value),onBlur:()=>{ae()},onKeyDown:M=>{M.key==="Escape"&&(M.preventDefault(),q())}})}):_.jsxs("button",{type:"button",className:`server-list-item${t===F.id?" server-list-item--active":""}`,onClick:()=>n(F.id),onDoubleClick:M=>{M.preventDefault(),R({id:F.id,name:F.name})},title:"Double-click to rename",children:[_.jsxs("span",{className:"server-list-item-header",children:[_.jsx("span",{className:"server-list-dot"}),_.jsx("span",{className:"server-list-name",title:F.url,children:F.name})]}),_.jsx(Iy,{entry:k[F.id]})]})},F.id)})]})}function DE({api:e}){const[t,n]=g.useState([]),[a,o]=g.useState([]),[c,d]=g.useState(!1),[p,m]=g.useState(null),[f,S]=g.useState(""),[y,w]=g.useState("");async function x(){try{const[R,ae,q]=await Promise.all([e.listDevices(),e.listNetworks(),e.getSession()]);n(R.devices),o(ae.networks),d(q.totpEnabled),m(null)}catch(R){m(R instanceof Error?R.message:"Failed to load")}}g.useEffect(()=>{x()},[]);async function C(R){await e.revokeDevice(R),await x()}async function k(R){await e.removeNetwork(R),await x()}async function L(R){R.preventDefault(),m(null);try{await e.addNetwork({value:f.trim(),label:y.trim()}),S(""),w(""),await x()}catch(ae){m(ae instanceof Error?ae.message:"Failed to add network")}}return _.jsxs(_.Fragment,{children:[p?_.jsx("p",{className:"form-error",children:p}):null,_.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Trusted devices"}),_.jsx("p",{className:"muted",children:"Devices that can re-authenticate with a 2FA code only (no password) for 30 days."}),t.length===0?_.jsx("p",{className:"muted",children:"No trusted devices."}):_.jsx("ul",{className:"security-list",children:t.map(R=>_.jsxs("li",{children:[_.jsxs("div",{children:[_.jsxs("span",{className:"security-item-label",children:[R.label,R.current?_.jsx("span",{className:"security-badge",children:"this device"}):null]}),_.jsxs("span",{className:"security-item-meta",children:["last seen ",new Date(R.lastSeenAt).toLocaleString()]})]}),_.jsx("button",{type:"button",className:"security-remove",onClick:()=>{C(R.id)},children:"revoke"})]},R.id))})]}),_.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Trusted networks"}),_.jsx("p",{className:"muted",children:"Sessions from these IPs/ranges skip the 2FA re-auth prompt."}),a.length===0?_.jsx("p",{className:"muted",children:"No trusted networks."}):_.jsx("ul",{className:"security-list",children:a.map(R=>_.jsxs("li",{children:[_.jsxs("div",{children:[_.jsx("span",{className:"security-item-label",children:R.value}),R.label!==R.value?_.jsx("span",{className:"security-item-meta",children:R.label}):null]}),_.jsx("button",{type:"button",className:"security-remove",onClick:()=>{k(R.id)},children:"remove"})]},R.id))}),_.jsxs("form",{className:"security-add-form",onSubmit:L,children:[_.jsx("input",{type:"text",placeholder:"IP or CIDR (e.g. 203.0.113.4 or 192.168.0.0/24)",value:f,onChange:R=>S(R.currentTarget.value),required:!0}),_.jsx("input",{type:"text",placeholder:"Label (optional)",value:y,onChange:R=>w(R.currentTarget.value)}),_.jsx("button",{type:"submit",disabled:!f.trim(),children:"Add"})]})]}),c?_.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Two-factor authentication"}),_.jsx("p",{className:"muted",children:"2FA is enabled. Disabling it removes the requirement; you will be asked to set it up again on next login."}),_.jsx("button",{type:"button",className:"security-remove",onClick:async()=>{await e.disableTotp(),await x()},children:"Disable 2FA"})]}):null]})}const Yb="nterminal.notifications.completionEnabled",tm="nterminal.notifications.completionToastEnabled",im="nterminal.notifications.completionToastDurationSeconds",sm="nterminal.notifications.completionToastPersistent",Nf="nterminal:completion-toast-display",Jl=6.5,Bf=2,Lf=60;function Mu(){return typeof window<"u"&&"Notification"in window}function $b(){try{return window.localStorage.getItem(Yb)==="true"}catch{return!1}}function Fy(e){try{window.localStorage.setItem(Yb,e?"true":"false")}catch{}}function zr(){return{enabled:NE(),durationSeconds:AE(),persistUntilDismissed:BE()}}function RE(e){if(typeof window<"u"){try{window.localStorage.setItem(tm,e?"true":"false")}catch{}rm()}return zr()}function qy(e){const t=Xb(e);if(typeof window<"u"){try{window.localStorage.setItem(im,String(t))}catch{}rm()}return zr()}function ME(e){if(typeof window<"u"){try{window.localStorage.setItem(sm,e?"true":"false")}catch{}rm()}return zr()}function Vb(e){if(typeof window>"u")return()=>{};const t=n=>{(n.key===tm||n.key===im||n.key===sm)&&e()};return window.addEventListener(Nf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Nf,e),window.removeEventListener("storage",t)}}function nm(){return Mu()?window.Notification.permission:"unsupported"}function AE(){if(typeof window>"u")return Jl;try{const e=window.localStorage.getItem(im);return e===null?Jl:Xb(Number(e))}catch{return Jl}}function NE(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(tm)!=="false"}catch{return!0}}function BE(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(sm)==="true"}catch{return!1}}function Xb(e){if(!Number.isFinite(e))return Jl;const t=Math.round(e*2)/2;return Math.max(Bf,Math.min(Lf,t))}function rm(){typeof window<"u"&&window.dispatchEvent(new CustomEvent(Nf))}async function LE(){if(!Mu())return"unsupported";try{return await window.Notification.requestPermission()}catch{return nm()}}function OE(e){if(!Mu()||nm()!=="granted"||!$b()||typeof document<"u"&&document.visibilityState==="visible")return;const t=e.commandName?`${e.commandName} finished`:"Command finished";try{new Notification(`NTerminal · ${e.tabTitle}`,{body:t,tag:e.terminalId,icon:"/icons/app-icon-384.png",silent:!0})}catch{}}const zE=1500,am="nterminal.terminal.fontSize",lm="nterminal.terminal.fontFamily",Of="nterminal:terminal-font-size",zf="nterminal:terminal-font-family",jf=11,Hf=20,Lr=14,hu=[{id:"meslo",label:"MesloLGS NF",cssFamily:['"MesloLGS NF"','"MesloLGS Nerd Font Mono"','"MesloLGSNerdFontMono"','"JetBrainsMono Nerd Font"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:['"MesloLGS NF"']},{id:"jetbrains",label:"JetBrains Mono",cssFamily:['"JetBrainsMono Nerd Font"','"JetBrains Mono"','"Hack Nerd Font"','"FiraCode Nerd Font"','"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]},{id:"system",label:"System mono",cssFamily:['"SF Mono"',"Menlo","Monaco","Consolas",'"Liberation Mono"','"Symbols Nerd Font Mono"','"Apple Symbols"','"Apple Color Emoji"',"monospace"].join(", "),webFontFamilies:[]}],Na="meslo";Uf(Na);async function tf(e=Lr,t=Na){if(typeof document>"u"||!document.fonts)return;const n=Qb(t).webFontFamilies;if(n.length===0)return;const a=Promise.all(n.map(o=>document.fonts.load(`${e}px ${o}`))).then(()=>{}).catch(()=>{});await Promise.race([a,new Promise(o=>{globalThis.setTimeout(o,zE)})])}function Gb(e){const t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return Lr;const n=Math.round(t);return Math.max(jf,Math.min(Hf,n))}function Zb(e){return hu.some(t=>t.id===e)?e:Na}function Uf(e){return Qb(e).cssFamily}function Qb(e){return hu.find(t=>t.id===e)??hu[0]}function Pf(){if(typeof window>"u")return Lr;try{const e=window.localStorage.getItem(am);return e?Gb(e):Lr}catch{return Lr}}function Kf(){if(typeof window>"u")return Na;try{return Zb(window.localStorage.getItem(lm))}catch{return Na}}function Hc(e){const t=Gb(e);if(typeof window>"u")return t;try{window.localStorage.setItem(am,String(t))}catch{}return window.dispatchEvent(new CustomEvent(Of,{detail:t})),t}function jE(e){const t=Zb(e);if(typeof window>"u")return t;try{window.localStorage.setItem(lm,t)}catch{}return window.dispatchEvent(new CustomEvent(zf,{detail:t})),t}function Jb(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===am&&e()};return window.addEventListener(Of,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Of,e),window.removeEventListener("storage",t)}}function e0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===lm&&e()};return window.addEventListener(zf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(zf,e),window.removeEventListener("storage",t)}}const om="nterminal.terminal.showScrollProgress",If="nterminal:terminal-scroll-progress";function Ff(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(om)!=="false"}catch{return!0}}function HE(e){if(typeof window<"u"){try{window.localStorage.setItem(om,e?"true":"false")}catch{}window.dispatchEvent(new CustomEvent(If,{detail:e}))}return e}function t0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===om&&e()};return window.addEventListener(If,e),window.addEventListener("storage",t),()=>{window.removeEventListener(If,e),window.removeEventListener("storage",t)}}const cm="nterminal.shortcuts.workspace.v1",qf="nterminal:workspace-shortcuts",ro=[{id:"server.previous",label:"Previous server",group:"Servers"},{id:"server.next",label:"Next server",group:"Servers"},{id:"tab.previous",label:"Previous tab",group:"Tabs"},{id:"tab.next",label:"Next tab",group:"Tabs"},{id:"tab.index",label:"Select tab 1-9",group:"Tabs",indexed:!0},{id:"pane.index",label:"Select pane 1-9",group:"Panes",indexed:!0},{id:"split.right",label:"Split right",group:"Panes"},{id:"split.down",label:"Split down",group:"Panes"}],um={"server.previous":Mi("ArrowUp",{ctrlKey:!0}),"server.next":Mi("ArrowDown",{ctrlKey:!0}),"tab.previous":Mi("ArrowLeft",{ctrlKey:!0}),"tab.next":Mi("ArrowRight",{ctrlKey:!0}),"tab.index":Mi("Digit",{ctrlKey:!0,altKey:!0}),"pane.index":Mi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.right":Mi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Mi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0})},UE={"server.previous":Mi("BracketLeft",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"server.next":Mi("BracketRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"tab.previous":Mi("BracketLeft",{ctrlKey:!0,altKey:!0}),"tab.next":Mi("BracketRight",{ctrlKey:!0,altKey:!0}),"tab.index":Mi("Digit",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"pane.index":Mi("Digit",{ctrlKey:!0,altKey:!0}),"split.right":Mi("ArrowRight",{ctrlKey:!0,altKey:!0,shiftKey:!0}),"split.down":Mi("ArrowDown",{ctrlKey:!0,altKey:!0,shiftKey:!0})};function jr(){const e=r0(um);if(typeof window>"u")return e;try{const t=window.localStorage.getItem(cm);if(!t)return e;const n=JSON.parse(t);for(const a of ro){const o=n[a.id];if(VE(o)){const c=a0(o,a);$E(c,UE[a.id])||(e[a.id]=c)}}}catch{return e}return e}function Wy(){return JSON.stringify(jr())}function PE(e,t){const n=jr(),a=ro.find(o=>o.id===e);return a&&(n[e]=a0(t,a),hm(n)),n}function KE(e){const t=jr();return t[e]={...um[e]},hm(t),t}function IE(){const e=r0(um);return hm(e),e}function i0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===cm&&e()};return window.addEventListener(qf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(qf,e),window.removeEventListener("storage",t)}}function FE(e,t){const n=o0(e);return!n||GE(n)||t.indexed&&l0(e)===null?null:{ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,code:t.indexed?"Digit":n}}function qE(e){const t=jr();for(const n of ro){const a=t[n.id];if(!(!a||!XE(e,a))){if(n.indexed){if(a.code!=="Digit")continue;const o=l0(e);if(o!==null)return{id:n.id,index:o};continue}if(o0(e)===a.code)return{id:n.id,index:null}}}return null}function s0(e){return n0(jr()[e])}function n0(e){const t=[];return e.ctrlKey&&t.push("Ctrl"),e.altKey&&t.push("Alt"),e.shiftKey&&t.push("Shift"),e.metaKey&&t.push("Meta"),t.push(ZE(e.code)),t.join("+")}const WE=()=>s0("split.right"),YE=()=>s0("split.down");function Mi(e,t){return{ctrlKey:t.ctrlKey??!1,altKey:t.altKey??!1,shiftKey:t.shiftKey??!1,metaKey:t.metaKey??!1,code:e}}function r0(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,{...n}]))}function $E(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey&&e.code===t.code}function hm(e){if(!(typeof window>"u")){try{window.localStorage.setItem(cm,JSON.stringify(e))}catch{}window.dispatchEvent(new CustomEvent(qf))}}function a0(e,t){return{ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,shiftKey:!!e.shiftKey,metaKey:!!e.metaKey,code:t.indexed?"Digit":e.code}}function VE(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.ctrlKey=="boolean"&&typeof t.altKey=="boolean"&&typeof t.shiftKey=="boolean"&&typeof t.metaKey=="boolean"&&typeof t.code=="string"&&t.code.length>0}function XE(e,t){return e.ctrlKey===t.ctrlKey&&e.altKey===t.altKey&&e.shiftKey===t.shiftKey&&e.metaKey===t.metaKey}function l0(e){const t=/^Digit([1-9])$/.exec(e.code);return t?.[1]?Number(t[1]):/^[1-9]$/.test(e.key)?Number(e.key):null}function o0(e){if(e.code)return e.code;if(/^[a-z]$/i.test(e.key))return`Key${e.key.toUpperCase()}`;if(/^[0-9]$/.test(e.key))return`Digit${e.key}`;switch(e.key){case"[":case"{":return"BracketLeft";case"]":case"}":return"BracketRight";case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"Tab":case"Enter":case"Escape":case"Space":return e.key==="Space"?"Space":e.key;default:return null}}function GE(e){return e==="ControlLeft"||e==="ControlRight"||e==="AltLeft"||e==="AltRight"||e==="ShiftLeft"||e==="ShiftRight"||e==="MetaLeft"||e==="MetaRight"}function ZE(e){if(e==="Digit")return"1-9";const t=/^Digit([0-9])$/.exec(e);if(t?.[1])return t[1];const n=/^Key([A-Z])$/.exec(e);if(n?.[1])return n[1];switch(e){case"BracketLeft":return"[";case"BracketRight":return"]";case"ArrowLeft":return"Left";case"ArrowRight":return"Right";case"ArrowUp":return"Up";case"ArrowDown":return"Down";case"Space":return"Space";default:return e.replace(/^(Numpad|Digit|Key)/,"")}}const dm="nterminal.theme.accent",Wf="nterminal:theme-accent",ao=[{id:"aqua",label:"Aqua Teal",accent:"#5EEAD4",soft:"rgba(94, 234, 212, 0.10)",glow:"rgba(94, 234, 212, 0.55)",xtermSelection:"#1f3f45"},{id:"signal-red",label:"Signal Red",accent:"#FF2A3D",soft:"rgba(255, 42, 61, 0.12)",glow:"rgba(255, 42, 61, 0.52)",xtermSelection:"#4a1b22"}],du="aqua";function wo(e){return ao.some(t=>t.id===e)?e:du}function fm(e){return ao.find(t=>t.id===e)??ao[0]}function lr(){if(typeof window>"u")return du;try{return wo(window.localStorage.getItem(dm))}catch{return du}}function QE(e){const t=wo(e);if(typeof window<"u"){try{window.localStorage.setItem(dm,t)}catch{}pm(t),window.dispatchEvent(new CustomEvent(Wf,{detail:t}))}return t}function pm(e=lr()){if(typeof document>"u")return;const t=fm(wo(e)),n=document.documentElement;n.style.setProperty("--nt-accent",t.accent),n.style.setProperty("--nt-accent-soft",t.soft),n.style.setProperty("--nt-accent-glow",t.glow)}function JE(e=lr()){return fm(wo(e)).accent}function e2(e=lr()){return fm(wo(e)).xtermSelection}function c0(e){if(typeof window>"u")return()=>{};const t=n=>{n.key===dm&&(pm(lr()),e())};return window.addEventListener(Wf,e),window.addEventListener("storage",t),()=>{window.removeEventListener(Wf,e),window.removeEventListener("storage",t)}}const t2="Automatic update needs write access to the global npm install. Run the manual update command as the NTerminal runtime user; only the npm install step should use sudo.";function i2(e="nterminal",t=new Date){return{reason:"permission",message:t2,command:`sudo npm i -g ${e}@latest --prefer-online && nterminal restart`,detectedAt:t.toISOString()}}function s2(e){return/\b(?:EACCES|EPERM)\b|permission denied|missing write access|access denied|operation was rejected by your operating system|operation not permitted|root-owned files/i.test(e)}const u0=3600*1e3,n2="local",Yf=new Set,nr=new Map;let or={checking:!1,hasUpdates:!1,lastCheckedAt:null},mm=null,eo=null,fu=0,Jn=null;function r2(e){return Yf.add(e),()=>{Yf.delete(e)}}function Yy(){return or}function a2(e){const t=h2();mm=e,_m(),$f(e,t);const n=()=>{if(document.visibilityState!=="visible"||!cr(e,t))return;const a=or.lastCheckedAt;(a===null||Date.now()-a>=u0)&&$f(e,t)};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n),cr(e,t)&&u2()}}function l2(e,t){nr.set(e,h0(t)),Ba({...or,hasUpdates:vm(),lastCheckedAt:Date.now()})}function sf(e){e===void 0?nr.clear():nr.set(e,!1),Ba({...or,hasUpdates:vm()})}async function $f(e,t){if(!cr(e,t))return;if(Jn&&Jn.api===e&&Jn.runId===t)return Jn.promise;Ba({...or,checking:!0});const n=o2(e,t).finally(()=>{Jn?.promise===n&&(Jn=null),cr(e,t)&&(Ba({...or,checking:!1,lastCheckedAt:Date.now()}),c2(e,t))});return Jn={api:e,runId:t,promise:n},n}async function o2(e,t){try{const n=await e.listAgents();if(!cr(e,t))return;const a=[{key:n2,check:()=>e.checkUpdate()},...n.agents.map(c=>({key:c.id,check:()=>e.checkAgentUpdate(c.id)}))],o=new Map;if(await Promise.all(a.map(async c=>{try{const d=await c.check();o.set(c.key,h0(d))}catch{o.set(c.key,nr.get(c.key)??!1)}})),!cr(e,t))return;nr.clear();for(const[c,d]of o)nr.set(c,d);Ba({...or,hasUpdates:vm()})}catch{}}function c2(e,t){cr(e,t)&&(_m(),eo=window.setTimeout(()=>{eo=null,cr(e,t)&&$f(e,t)},u0))}function u2(){fu+=1,_m(),mm=null,Jn=null,nr.clear(),Ba({checking:!1,hasUpdates:!1,lastCheckedAt:null})}function _m(){eo!==null&&(window.clearTimeout(eo),eo=null)}function h2(){return fu+=1,fu}function cr(e,t){return mm===e&&fu===t}function h0(e){return e.updateAvailable===!0}function vm(){return Array.from(nr.values()).some(Boolean)}function Ba(e){or=e;for(const t of Array.from(Yf))t()}const d2=e=>new Promise(t=>setTimeout(t,e));function f2({api:e,onAgentRemoved:t}){const[n,a]=g.useState([{key:"local",id:null,name:"Local (main)"}]),[o,c]=g.useState({}),[d,p]=g.useState(!1),[m,f]=g.useState(null);function S(M,Q){c(ne=>({...ne,[M]:{...ne[M],...Q}}))}const y=M=>M.id===null?e.getVersion():e.getAgentVersion(M.id),w=M=>M.id===null?e.checkUpdate():e.checkAgentUpdate(M.id),x=M=>M.id===null?e.runUpdate():e.runAgentUpdate(M.id);g.useEffect(()=>{let M=!1;return e.listAgents().then(Q=>{if(M)return;const ne=[{key:"local",id:null,name:"Local (main)"},...Q.agents.map(Z=>({key:Z.id,id:Z.id,name:Z.name}))];a(ne);for(const Z of ne)y(Z).then(K=>S(Z.key,{version:K,manualUpdate:K.manualUpdate??null})).catch(K=>S(Z.key,{error:K instanceof Error?K.message:"unreachable"}))}).catch(()=>{}),()=>{M=!0}},[]);async function C(M){S(M.key,{busy:!0,status:"checking…",error:void 0});try{const Q=await w(M);l2(M.key,Q),S(M.key,{latestVersion:Q.latestVersion,updateAvailable:Q.updateAvailable,status:ue(Q),...Q.updateAvailable===!1?{manualUpdate:null}:{},busy:!1})}catch(Q){S(M.key,{busy:!1,error:Q instanceof Error?Q.message:"check failed"})}}async function k(){p(!0),await Promise.all(n.map(M=>C(M))),p(!1)}async function L(M,Q){const ne=Date.now()+18e4;for(;Date.now()<ne;){await d2(3e3);try{const Z=await y(M);if(Q&&Z.runningVersion!==Q.runningVersion)return Z}catch{}}return null}async function R(M,Q={}){let ne=o[M.key]?.version;if(!ne)try{ne=await y(M),S(M.key,{version:ne,manualUpdate:ne.manualUpdate??null})}catch(te){return S(M.key,{busy:!1,error:te instanceof Error?te.message:"version check failed"}),"failed"}const Z=o[M.key]?.manualUpdate??ne.manualUpdate??null;if(Z&&Q.skipManual)return S(M.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:Z}),"manual";S(M.key,{busy:!0,status:"updating…",error:void 0});let K;try{K=await x(M)}catch(te){return S(M.key,{busy:!1,error:te instanceof Error?te.message:"update failed"}),"failed"}if(!K.ok){const te=K.manualUpdate??(s2(K.message)?i2():null);return te?(S(M.key,{busy:!1,status:"manual update required",error:void 0,manualUpdate:te}),"manual"):(S(M.key,{busy:!1,status:void 0,error:K.message}),"failed")}if(!K.changed)return S(M.key,{busy:!1,status:"already up to date",updateAvailable:!1,manualUpdate:null}),sf(M.key),"unchanged";S(M.key,{status:"restarting…"});const j=await L(M,ne);return j?(S(M.key,{busy:!1,version:j,updateAvailable:!1,status:"updated",manualUpdate:j.manualUpdate??null}),sf(M.key),M.id===null&&window.setTimeout(()=>window.location.reload(),250),"updated"):(S(M.key,{busy:!1,status:void 0,error:"timed out — check the server log"}),"failed")}async function ae(M){if(!(M.id===null||!window.confirm([`Delete secondary server "${M.name}"?`,"","If the secondary is reachable, NTerminal will schedule a clean uninstall on that host, stop its runtime, remove its local state, and remove it from this main server.","If it is already gone or unreachable, only the stale registration on this main server will be removed.","","This can close live terminals on that secondary. Continue?"].join(`
14
+ `)))){S(M.key,{busy:!0,status:"deleting…",error:void 0}),f(null);try{const ne=await e.uninstallAgent(M.id);a(Z=>Z.filter(K=>K.key!==M.key)),c(Z=>{const K={...Z};return delete K[M.key],K}),sf(M.key),t?.(M.id),f(ne.message)}catch(ne){S(M.key,{busy:!1,status:void 0,error:ne instanceof Error?ne.message:"delete failed"})}}}async function q(){p(!0),f(null);const M=n.filter(j=>j.id!==null),Q=n.find(j=>j.id===null),ne=await Promise.all(M.map(j=>R(j,{skipManual:!0}))),Z=ne.filter(j=>j==="failed").length;let K=ne.filter(j=>j==="manual").length;if(Z>0){p(!1);return}if(Q){const j=await R(Q,{skipManual:!0});if(j==="manual"&&(K+=1),j==="updated"){window.location.reload();return}}K>0&&f("Some servers need manual update. Copy and run the command shown on each marked server."),p(!1)}function G(M){return M?M.error?M.error:M.status?M.status:M.manualUpdate?"manual update required":M.version?`v${M.version.version}`:"…":"…"}function ue(M){return M.error?M.error:typeof M.updateAvailable=="boolean"?M.updateAvailable?`latest v${M.latestVersion??"available"}`:"up to date":"unknown"}function F(M){const Q=M?.version;return Q?`npm package v${Q.runningVersion}`:""}async function P(M,Q){try{await p2(Q),S(M,{copiedCommand:!0}),window.setTimeout(()=>S(M,{copiedCommand:!1}),1800)}catch(ne){S(M,{error:ne instanceof Error?ne.message:"copy failed"})}}return _.jsxs("section",{className:"security-section",children:[_.jsx("h3",{children:"Servers"}),_.jsxs("div",{className:"update-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{k()},disabled:d,children:"Check for updates"}),_.jsx("button",{type:"button",onClick:()=>{q()},disabled:d,children:"Update all"})]}),m?_.jsx("p",{className:"settings-status",children:m}):null,_.jsx("ul",{className:"security-list",children:n.map(M=>{const Q=o[M.key],ne=F(Q),Z=Q?.manualUpdate??null,K=Q?.version!==void 0&&Q?.updateAvailable!==!1&&!Z&&!Q?.busy&&!d,j=M.id!==null&&!Q?.busy&&!d;return _.jsxs("li",{children:[_.jsxs("div",{className:"server-row-main",children:[_.jsxs("div",{children:[_.jsx("span",{className:"security-item-label",children:M.name}),_.jsxs("span",{className:"security-item-meta",children:[ne?`${ne} — `:"",G(Q)]})]}),Z?_.jsxs("div",{className:"server-manual-update",children:[_.jsx("span",{children:Z.message}),_.jsxs("div",{className:"server-manual-command",children:[_.jsx("code",{children:Z.command}),_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{P(M.key,Z.command)},children:Q?.copiedCommand?"Copied":"Copy"})]})]}):null]}),_.jsxs("div",{className:"server-row-actions",children:[_.jsx("button",{type:"button",className:"secondary-button",onClick:()=>{R(M)},disabled:!K,children:Q?.busy?"…":"Update"}),M.id!==null?_.jsx("button",{type:"button",className:"server-delete-button",onClick:()=>{ae(M)},disabled:!j,children:"Delete"}):null]})]},M.key)})})]})}async function p2(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{if(!document.execCommand("copy"))throw new Error("copy failed")}finally{t.remove()}}const Uc=[{id:"terminal",label:"Terminal"},{id:"shortcuts",label:"Shortcuts"},{id:"notifications",label:"Notifications"},{id:"security",label:"Security"},{id:"servers",label:"Servers"}];function m2({onClose:e,api:t,updateAvailable:n=!1,onNotificationAssetsChanged:a,onAgentRemoved:o}){const c=g.useMemo(()=>t??Eu(),[t]),[d,p]=g.useState(()=>Pf()),[m,f]=g.useState(()=>Kf()),[S,y]=g.useState(()=>Ff()),[w,x]=g.useState(()=>lr()),[C,k]=g.useState(()=>jr()),[L,R]=g.useState(null),[ae,q]=g.useState(null),[G,ue]=g.useState("terminal"),[F,P]=g.useState(()=>$b()),[M,Q]=g.useState(()=>zr()),[ne,Z]=g.useState(()=>nm()),[K,j]=g.useState([]),[te,se]=g.useState([]),[N,$]=g.useState([]),[X,ve]=g.useState(5*1024*1024),[Se,E]=g.useState(!1),[W,J]=g.useState(null),he=g.useRef(null),ge=g.useRef(null),pe=g.useRef({terminal:null,shortcuts:null,notifications:null,security:null,servers:null}),Ce=g.useMemo(()=>new Set(te),[te]),Oe=!_2(te,N);g.useEffect(()=>Jb(()=>p(Pf())),[]),g.useEffect(()=>e0(()=>f(Kf())),[]),g.useEffect(()=>t0(()=>y(Ff())),[]),g.useEffect(()=>c0(()=>x(lr())),[]),g.useEffect(()=>i0(()=>k(jr())),[]),g.useEffect(()=>Vb(()=>Q(zr())),[]),g.useEffect(()=>{if(!L)return;const ee=ro.find(je=>je.id===L);if(!ee)return;const ze=je=>{if(je.preventDefault(),je.stopPropagation(),je.key==="Escape"){R(null),q(null);return}const _i=FE(je,ee);if(!_i){q(ee.indexed?"Press a shortcut ending in a number from 1 to 9.":"Press a complete shortcut.");return}k(PE(L,_i)),R(null),q(null)};return window.addEventListener("keydown",ze,!0),()=>window.removeEventListener("keydown",ze,!0)},[L]),g.useEffect(()=>{let ee=!1;return c.listNotificationAssets().then(ze=>{ee||Ee(ze)}).catch(ze=>{ee||J(Pc(ze))}),()=>{ee=!0}},[c]);function Ne(ee){p(Hc(Number(ee)))}function Re(ee){Q(qy(Number(ee)))}function Ue(ee){ue(ee),pe.current[ee]?.scrollIntoView?.({block:"start",behavior:"smooth"})}function Ye(){const ee=ge.current;if(!ee)return;if(ee.scrollTop+ee.clientHeight>=ee.scrollHeight-2){ue(Uc[Uc.length-1].id);return}const ze=ee.getBoundingClientRect();let je="terminal",_i=0;for(const Vi of Uc){const ai=pe.current[Vi.id];if(!ai)continue;const kt=ai.getBoundingClientRect(),ji=Math.max(kt.top,ze.top),Ti=Math.min(kt.bottom,ze.bottom),Nt=Math.max(0,Ti-ji);Nt>_i&&(je=Vi.id,_i=Nt)}ue(je)}function Be(ee){k(KE(ee)),R(null),q(null)}function le(){k(IE()),R(null),q(null)}function Ee(ee){const ze=ee.assets.filter(je=>je.enabled).map(je=>je.id);j(ee.assets),se(ze),$(ze),ve(ee.maxFileBytes),J(null)}async function xe(){if(F){Fy(!1),P(!1);return}let ee=ne;ee==="default"&&(ee=await LE(),Z(ee)),ee==="granted"&&(Fy(!0),P(!0))}async function Ke(ee){const ze=ee?.[0];if(ze){if(ze.size>X){J(`File must be ${nf(X)} or smaller.`),gt();return}if(ze.type!=="video/mp4"&&ze.type!=="video/webm"){J("Upload an MP4 or WebM video."),gt();return}E(!0),J(null);try{await c.uploadNotificationAsset(ze),Ee(await c.listNotificationAssets()),a?.()}catch(je){J(Pc(je))}finally{E(!1),gt()}}}async function Xe(ee){E(!0),J(null);try{await c.deleteNotificationAsset(ee),Ee(await c.listNotificationAssets()),a?.()}catch(ze){J(Pc(ze))}finally{E(!1)}}function gt(){he.current&&(he.current.value="")}function yt(ee,ze){const je=new Set(te);if(ze?je.add(ee):je.delete(ee),je.size===0){J("Keep at least one toast video selected.");return}J(null),se(Array.from(je))}async function mi(){if(te.length===0){J("Keep at least one toast video selected.");return}E(!0),J(null);try{const ee=await c.updateNotificationAssetSelection({enabledAssetIds:te});Ee(ee),a?.()}catch(ee){J(Pc(ee))}finally{E(!1)}}return _.jsx("div",{className:"security-overlay",role:"dialog","aria-modal":"true","aria-label":"Settings",onClick:e,children:_.jsxs("div",{className:"security-panel settings-panel",onClick:ee=>ee.stopPropagation(),children:[_.jsxs("header",{className:"security-panel-header",children:[_.jsx("h2",{children:"Settings"}),_.jsx("button",{type:"button",className:"security-close","aria-label":"Close",onClick:e,children:"×"})]}),_.jsxs("div",{className:"settings-layout",children:[_.jsx("nav",{className:"settings-nav","aria-label":"Settings categories",children:Uc.map(ee=>_.jsxs("button",{type:"button","data-active":G===ee.id?"true":"false","aria-current":G===ee.id?"true":void 0,onClick:()=>Ue(ee.id),children:[ee.label,ee.id==="servers"&&n?_.jsx("span",{className:"update-pulse-dot settings-update-dot","aria-hidden":"true"}):null]},ee.id))}),_.jsxs("div",{ref:ge,className:"settings-content",onScroll:Ye,children:[_.jsxs("section",{id:"settings-terminal",ref:ee=>{pe.current.terminal=ee},className:"security-section settings-section",children:[_.jsx("h3",{children:"Terminal"}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Font size"}),_.jsxs("span",{className:"settings-control-value",children:[d,"px"]}),_.jsx("input",{type:"range",min:jf,max:Hf,step:1,value:d,"aria-label":"Terminal font size",onChange:ee=>Ne(ee.currentTarget.value)})]}),_.jsxs("div",{className:"settings-stepper-row",children:[_.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Hc(d-1)),children:"-"}),_.jsx("input",{type:"number",min:jf,max:Hf,step:1,value:d,"aria-label":"Terminal font size value",onChange:ee=>Ne(ee.currentTarget.value)}),_.jsx("button",{type:"button",className:"secondary-button settings-stepper-button",onClick:()=>p(Hc(d+1)),children:"+"}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:()=>p(Hc(Lr)),children:"Reset"})]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Font family"}),_.jsx("select",{value:m,"aria-label":"Terminal font family",onChange:ee=>f(jE(ee.currentTarget.value)),children:hu.map(ee=>_.jsx("option",{value:ee.id,children:ee.label},ee.id))})]}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:S,onChange:ee=>y(HE(ee.currentTarget.checked))}),"Show scroll progress"]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Accent theme"}),_.jsx("select",{value:w,"aria-label":"Theme accent",onChange:ee=>x(QE(ee.currentTarget.value)),children:ao.map(ee=>_.jsx("option",{value:ee.id,children:ee.label},ee.id))})]}),_.jsx("div",{className:"settings-theme-swatches","aria-hidden":"true",children:ao.map(ee=>_.jsx("span",{className:"settings-theme-swatch","data-active":w===ee.id?"true":"false",style:{"--settings-theme-accent":ee.accent}},ee.id))})]}),_.jsxs("section",{id:"settings-shortcuts",ref:ee=>{pe.current.shortcuts=ee},className:"security-section settings-section",children:[_.jsxs("div",{className:"settings-section-heading",children:[_.jsx("h3",{children:"Shortcuts"}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",onClick:le,children:"Reset all"})]}),_.jsx("p",{className:"muted",children:"Defaults avoid Chrome's browser-tab shortcuts. Click a shortcut, then press the new key combo."}),ae?_.jsx("p",{className:"settings-error",children:ae}):null,_.jsx("ul",{className:"settings-shortcut-list","aria-label":"Workspace shortcuts",children:ro.map(ee=>{const ze=L===ee.id;return _.jsxs("li",{children:[_.jsxs("div",{children:[_.jsx("span",{className:"settings-shortcut-label",children:ee.label}),_.jsx("span",{className:"settings-shortcut-group",children:ee.group})]}),_.jsxs("div",{className:"settings-shortcut-actions",children:[_.jsx("button",{type:"button",className:"settings-shortcut-recorder","data-recording":ze?"true":"false",onClick:()=>{R(ee.id),q(null)},children:ze?"Press keys…":n0(C[ee.id])}),_.jsx("button",{type:"button",className:"secondary-button settings-shortcut-reset",onClick:()=>Be(ee.id),children:"Reset"})]})]},ee.id)})})]}),_.jsxs("section",{id:"settings-notifications",ref:ee=>{pe.current.notifications=ee},className:"security-section settings-section",children:[_.jsx("h3",{children:"Notifications"}),Mu()?_.jsxs(_.Fragment,{children:[_.jsxs("label",{className:"auth-checkbox",children:[_.jsx("input",{type:"checkbox",checked:F&&ne==="granted",onChange:()=>{xe()},disabled:ne==="denied"}),"System notification when page is hidden"]}),ne==="denied"?_.jsx("p",{className:"muted",children:"Notification permission is blocked for this site. Re-enable it in the browser's site settings, then come back here to turn the toggle on."}):_.jsx("p",{className:"muted",children:"Uses browser notifications only when this page isn't visible. Animated toast is controlled separately below."})]}):_.jsx("p",{className:"muted",children:"This browser doesn't expose the Notification API; animated toast and in-app badges can still work."}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:M.enabled,onChange:ee=>Q(RE(ee.currentTarget.checked))}),"Show animated completion toast"]}),_.jsxs("label",{className:"settings-control",children:[_.jsx("span",{children:"Toast duration"}),_.jsx("span",{className:"settings-control-value",children:M.persistUntilDismissed?"Until closed":`${M.durationSeconds}s`}),_.jsx("input",{type:"range",min:Bf,max:Lf,step:.5,value:M.durationSeconds,disabled:!M.enabled||M.persistUntilDismissed,"aria-label":"Completion toast duration",onChange:ee=>Re(ee.currentTarget.value)})]}),_.jsxs("div",{className:"settings-stepper-row settings-duration-row",children:[_.jsx("input",{type:"number",min:Bf,max:Lf,step:.5,value:M.durationSeconds,disabled:!M.enabled||M.persistUntilDismissed,"aria-label":"Completion toast duration value",onChange:ee=>Re(ee.currentTarget.value)}),_.jsx("button",{type:"button",className:"secondary-button settings-reset-button",disabled:!M.enabled||M.persistUntilDismissed,onClick:()=>Q(qy(Jl)),children:"Reset"})]}),_.jsxs("label",{className:"auth-checkbox settings-checkbox",children:[_.jsx("input",{type:"checkbox",checked:M.persistUntilDismissed,disabled:!M.enabled,onChange:ee=>Q(ME(ee.currentTarget.checked))}),"Keep toast until dismissed"]}),_.jsxs("div",{className:"settings-assets-header",children:[_.jsx("span",{children:"Toast videos"}),_.jsxs("span",{children:[nf(X)," max"]})]}),_.jsx("input",{ref:he,type:"file",accept:"video/mp4,video/webm",className:"settings-asset-input","aria-label":"Upload toast video",onChange:ee=>{Ke(ee.currentTarget.files)}}),_.jsx("button",{type:"button",className:"secondary-button settings-upload-button",disabled:Se,onClick:()=>he.current?.click(),children:"Upload video"}),W?_.jsx("p",{className:"settings-error",children:W}):null,K.length>0?_.jsx("ul",{className:"settings-asset-list","aria-label":"Toast videos",children:K.map(ee=>_.jsxs("li",{"data-enabled":Ce.has(ee.id)?"true":"false",children:[_.jsxs("label",{className:"settings-asset-choice",children:[_.jsx("input",{type:"checkbox",checked:Ce.has(ee.id),disabled:Se,"aria-label":`Use ${ee.filename}`,onChange:ze=>yt(ee.id,ze.currentTarget.checked)}),_.jsx("video",{src:ee.url,muted:!0,autoPlay:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),_.jsxs("span",{className:"settings-asset-copy",children:[_.jsx("span",{children:ee.filename}),_.jsx("small",{children:ee.source==="built-in"?"Built-in":nf(ee.size)})]})]}),ee.source==="uploaded"?_.jsx("button",{type:"button",className:"secondary-button settings-asset-delete",disabled:Se,"aria-label":`Delete ${ee.filename}`,onClick:()=>{Xe(ee.id)},children:"x"}):null]},ee.id))}):_.jsx("p",{className:"muted",children:"Built-in videos will be used."}),_.jsx("button",{type:"button",className:"secondary-button settings-save-assets-button",disabled:Se||K.length===0||!Oe,onClick:()=>{mi()},children:"Save selected videos"})]}),_.jsx("div",{id:"settings-security",ref:ee=>{pe.current.security=ee},className:"settings-section-group",children:_.jsx(DE,{api:c})}),_.jsx("div",{id:"settings-servers",ref:ee=>{pe.current.servers=ee},className:"settings-section-group",children:_.jsx(f2,{api:c,...o?{onAgentRemoved:o}:{}})})]})]})]})})}function nf(e){return e>=1024*1024?`${Math.round(e/1024/1024*10)/10} MB`:e>=1024?`${Math.round(e/1024*10)/10} KB`:`${e} B`}function Pc(e){return e instanceof Error?e.message:"Request failed."}function _2(e,t){if(e.length!==t.length)return!1;const n=new Set(t);return e.every(a=>n.has(a))}class Dr extends Error{constructor(t,n){super(n),this.status=t,this.name="UploadClientError"}status}function v2(e){const t=e.createXhr?.()??new XMLHttpRequest,n=new FormData,a=e.files.map((o,c)=>({fieldName:`file${c}`,relativePath:o.relativePath,size:o.file.size}));n.append("manifest",JSON.stringify({terminalId:e.terminalId,entries:a}));for(const[o,c]of e.files.entries())n.append(`file${o}`,c.file);return new Promise((o,c)=>{let d=!1;const p=()=>{e.signal?.removeEventListener("abort",S)},m=y=>{d||(d=!0,p(),o(y))},f=y=>{d||(d=!0,p(),c(y))},S=()=>{t.abort(),f(new Dr(0,"Upload aborted."))};if(e.signal?.aborted){f(new Dr(0,"Upload aborted."));return}e.signal?.addEventListener("abort",S,{once:!0}),t.open("POST","/api/uploads"),t.withCredentials=!0,t.upload.onprogress=y=>{if(e.onProgress){if(y.lengthComputable&&y.total>0){e.onProgress({loaded:y.loaded,total:y.total,percent:Math.round(y.loaded/y.total*100)});return}e.onProgress({loaded:y.loaded,total:null,percent:null})}},t.onload=()=>{if(t.status>=200&&t.status<300){try{m(JSON.parse(t.responseText))}catch{f(new Dr(t.status,"Invalid upload response."))}return}f(new Dr(t.status,g2(t.responseText,t.statusText||`HTTP ${t.status}`)))},t.onerror=()=>f(new Dr(0,"Upload failed.")),t.onabort=()=>f(new Dr(0,"Upload aborted.")),t.ontimeout=()=>f(new Dr(0,"Upload timed out.")),t.send(n)})}function g2(e,t){try{const n=JSON.parse(e),a=typeof n.error=="string"?n.error:n.message;if(typeof a=="string"&&a.trim())return a}catch{}return t}const y2="modulepreload",S2=function(e){return"/"+e},$y={},d0=function(t,n,a){let o=Promise.resolve();if(n&&n.length>0){let m=function(f){return Promise.all(f.map(S=>Promise.resolve(S).then(y=>({status:"fulfilled",value:y}),y=>({status:"rejected",reason:y}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=d?.nonce||d?.getAttribute("nonce");o=m(n.map(f=>{if(f=S2(f),f in $y)return;$y[f]=!0;const S=f.endsWith(".css"),y=S?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${y}`))return;const w=document.createElement("link");if(w.rel=S?"stylesheet":y2,S||(w.as="script"),w.crossOrigin="",w.href=f,p&&w.setAttribute("nonce",p),document.head.appendChild(w),S)return new Promise((x,C)=>{w.addEventListener("load",x),w.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${f}`)))})}))}function c(d){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=d,window.dispatchEvent(p),!p.defaultPrevented)throw d}return o.then(d=>{for(const p of d||[])p.status==="rejected"&&c(p.reason);return t().catch(c)})},b2=g.lazy(()=>d0(()=>import("./MarkdownPreview-BfwhfniS.js"),[]));function w2({api:e,activeTerminalId:t,activeTerminalCwd:n,onOpenFile:a}){const[o,c]=g.useState(null),[d,p]=g.useState(""),[m,f]=g.useState({}),[S,y]=g.useState(()=>new Set),[w,x]=g.useState(null),[C,k]=g.useState({type:"empty"}),[L,R]=g.useState("idle"),[ae,q]=g.useState(null),G=g.useRef(null),ue=g.useRef(null),F=g.useRef(!1),P=g.useRef(0),M=g.useRef(null);M.current===null&&t&&(M.current=t);const Q=M.current,ne=t?af(t,n):null,Z=o?[o.rootPath,d].filter(Boolean).join("/"):"",K=w?.path??null;g.useEffect(()=>(F.current=!0,()=>{F.current=!1,P.current+=1,Oe()}),[]),g.useEffect(()=>{M.current=t,ue.current=null;const le=t?af(t,n):null;j(t,le)},[e]),g.useEffect(()=>{if(!Q||t!==Q)return;const le=af(Q,n);le!==ue.current&&j(Q,le)},[Q,t,n]);async function j(le,Ee=ne){const xe=Ne();if(ue.current=Ee,Oe(),c(null),p(""),f({}),y(new Set),x(null),k({type:"empty"}),q(null),!le){R("idle");return}R("loading");try{const Ke=await e.createFileRoot({terminalId:le});if(!Re(xe))return;c({rootToken:Ke.rootToken,rootPath:Ke.rootPath});const Xe=await e.listFiles({rootToken:Ke.rootToken,path:""});if(!Re(xe))return;N(Xe),R("idle")}catch(Ke){if(await Ue(Ke,xe))return;Re(xe)&&(q(Xn(Ke)),R("idle"))}}async function te(le=d,Ee=o){if(!Ee)return;const xe=Ne();R("loading"),q(null);try{const Ke=await e.listFiles({rootToken:Ee.rootToken,path:le});if(!Re(xe))return;N(Ke),R("idle")}catch(Ke){if(await Ue(Ke,xe))return;Re(xe)&&(q(Xn(Ke)),R("idle"))}}async function se(){M.current=t,await j(t,ne)}function N(le){f(Ee=>({...Ee,[le.path]:x2(le.entries)}))}async function $(le){if(!(!rf(le)||!o)){if(x(le),q(null),le.kind==="directory"){p(le.path),Ce(),await ve(le);return}if(p(Rr(le.path)),le.editable){await E(le);return}le.previewKind!=="none"&&await J(le,le.previewKind)}}async function X(le){if(!(!rf(le)||!o)){if(x(le),q(null),le.kind==="directory"){p(le.path),Ce(),await ve(le);return}if(p(Rr(le.path)),le.editable){await W(le);return}le.previewKind!=="none"&&await J(le,le.previewKind)}}async function ve(le){if(S.has(le.path)){y(Ee=>{const xe=new Set(Ee);return xe.delete(le.path),xe});return}y(Ee=>new Set(Ee).add(le.path)),await te(le.path)}function Se(le,Ee){le.key==="Enter"&&(le.preventDefault(),X(Ee))}async function E(le){if(!o)return;const Ee=Ne();R("loading"),Oe();try{const xe=await e.readFile({rootToken:o.rootToken,path:le.path});if(!Re(Ee))return;k({type:"text-preview",file:le,read:xe}),R("idle")}catch(xe){if(await Ue(xe,Ee))return;Re(Ee)&&(q(Xn(xe)),R("idle"))}}async function W(le){if(!o)return;const Ee=Ne();R("loading");try{await a({rootToken:o.rootToken,path:le.path}),Re(Ee)&&R("idle")}catch(xe){if(await Ue(xe,Ee))return;Re(Ee)&&(q(Xn(xe)),R("idle"))}}async function J(le,Ee){if(!o)return;const xe=Ne();R("loading"),Oe();try{const Ke=await e.previewFile({rootToken:o.rootToken,path:le.path});if(!Re(xe))return;const Xe=URL.createObjectURL(Ke);if(!Re(xe)){URL.revokeObjectURL(Xe);return}G.current=Xe,k({type:"preview",file:le,previewKind:Ee,url:Xe}),R("idle")}catch(Ke){if(await Ue(Ke,xe))return;Re(xe)&&(q(Xn(Ke)),R("idle"))}}async function he(le){if(!o)return;const Ee=le==="file"?"New file":"New folder",xe=window.prompt(Ee,""),Ke=w?w.kind==="directory"?w.path:Rr(w.path):d,Xe=Vy(xe,Ke);if(Xe){q(null);try{const gt=await e.createFileEntry({rootToken:o.rootToken,path:Xe,kind:le});x(gt.entry),await te(Ke)}catch(gt){if(await Ue(gt))return;q(Xn(gt))}}}async function ge(){if(!o||!w)return;const le=window.prompt("Move selected entry",w.path),Ee=Vy(le,"");if(!Ee||Ee===w.path)return;const xe=Rr(w.path),Ke=Rr(Ee);q(null);try{const Xe=await e.moveFileEntry({rootToken:o.rootToken,sourcePath:w.path,destinationPath:Ee});x(Xe.entry),p(Xe.entry.kind==="directory"?Xe.entry.path:Rr(Xe.entry.path)),Ce(),await te(xe),Ke!==xe&&await te(Ke)}catch(Xe){if(await Ue(Xe))return;q(Xn(Xe))}}async function pe(){if(!o||!w)return;const le=w.path,Ee=Rr(le);q(null);try{const xe=await e.previewDeleteFileEntry({rootToken:o.rootToken,path:w.path}),Ke=xe.descendantCount>0?` and ${xe.descendantCount} nested item${xe.descendantCount===1?"":"s"}`:"";if(!window.confirm(`Delete ${xe.path}${Ke}?`))return;await e.deleteFileEntry({rootToken:o.rootToken,path:w.path,previewToken:xe.previewToken}),x(null),p(Ee),y(Xe=>{const gt=new Set(Xe);for(const yt of Xe)(yt===le||yt.startsWith(`${le}/`))&&gt.delete(yt);return gt}),Ce(),await te(Ee)}catch(xe){if(await Ue(xe))return;q(Xn(xe))}}function Ce(){P.current+=1,Oe(),k({type:"empty"})}function Oe(){G.current&&(URL.revokeObjectURL(G.current),G.current=null)}function Ne(){return P.current+=1,P.current}function Re(le){return F.current&&le===P.current}async function Ue(le,Ee){return E2(le)?(Ee!==void 0&&!Re(Ee)||await j(t,ne),!0):!1}function Ye(le,Ee){const xe=rf(le),Ke=le.kind==="directory"&&S.has(le.path),Xe=m[le.path]??[],gt={"--file-tree-depth":Ee};return _.jsxs(xi.Fragment,{children:[_.jsxs("button",{type:"button",className:"file-entry-button","data-kind":le.kind,"data-expanded":Ke,"data-active":K===le.path,disabled:!xe,style:gt,"aria-expanded":le.kind==="directory"?Ke:void 0,"aria-label":`${le.kind==="directory"?"Open folder":"Open file"} ${le.name}`,title:le.kind==="directory"?"Expand or collapse folder":"Click to preview. Double-click or press Enter to open.",onClick:()=>{$(le)},onDoubleClick:()=>{X(le)},onKeyDown:yt=>Se(yt,le),children:[_.jsx("span",{className:"file-entry-disclosure","aria-hidden":"true",children:le.kind==="directory"?Ke?"▾":"▸":""}),_.jsx("span",{className:"file-entry-name",children:le.name}),_.jsx("small",{children:C2(le)})]}),Ke?_.jsx("div",{className:"file-tree-children",role:"group",children:Xe.map(yt=>Ye(yt,Ee+1))}):null]},le.path)}const Be=m[""]??[];return _.jsxs("section",{className:"file-explorer","aria-label":"Files","aria-busy":L==="loading",children:[_.jsxs("header",{className:"file-explorer-header",children:[_.jsx("div",{className:"file-explorer-path",title:Z,children:Z||"No active pane"}),_.jsxs("div",{className:"file-explorer-toolbar","aria-label":"File actions",children:[_.jsx("button",{type:"button","aria-label":"Refresh files",title:"Refresh",disabled:!t,onClick:()=>{se()},children:"↻"}),_.jsx("button",{type:"button","aria-label":"New file",title:"New file",disabled:!o,onClick:()=>{he("file")},children:"+"}),_.jsx("button",{type:"button","aria-label":"New folder",title:"New folder",disabled:!o,onClick:()=>{he("directory")},children:"▣"})]})]}),ae?_.jsx("div",{className:"file-explorer-alert",role:"alert",children:ae}):null,_.jsxs("div",{className:"file-explorer-layout",children:[_.jsx("div",{className:"file-tree","aria-label":Z?`Files in ${Z}`:"Files",children:Be.map(le=>Ye(le,0))}),_.jsxs("section",{className:"file-detail","aria-label":"File detail",children:[_.jsxs("div",{className:"file-detail-header",children:[_.jsx("strong",{children:w?.name??"detail"}),_.jsxs("div",{className:"file-detail-actions",children:[_.jsx("button",{type:"button","aria-label":"Move selected entry",disabled:!w,onClick:()=>{ge()},children:"Move"}),_.jsx("button",{type:"button","aria-label":"Delete selected entry",disabled:!w,onClick:()=>{pe()},children:"Delete"})]})]}),L==="loading"?_.jsx("div",{className:"file-detail-empty",children:"loading"}):null,C.type==="empty"&&L!=="loading"?_.jsx("div",{className:"file-detail-empty",children:"No file selected"}):null,C.type==="preview"?_.jsxs("div",{className:"file-preview-frame",children:[C.previewKind==="image"?_.jsx("img",{src:C.url,alt:C.file.name}):null,C.previewKind==="pdf"?_.jsx("iframe",{src:C.url,title:C.file.name}):null]}):null,C.type==="text-preview"&&C.read.language==="markdown"?_.jsx("div",{className:"file-markdown-preview","aria-label":`Preview for ${C.file.name}`,children:_.jsx(g.Suspense,{fallback:_.jsx("div",{className:"file-markdown-preview-loading",children:"loading preview"}),children:_.jsx(b2,{content:C.read.content})})}):null,C.type==="text-preview"&&C.read.language==="text"?_.jsx("pre",{className:"file-text-preview","aria-label":`Preview for ${C.file.name}`,children:C.read.content}):null]})]})]})}function rf(e){return e.kind==="directory"||e.editable||e.previewKind!=="none"}function C2(e){return e.kind==="directory"?"dir":e.editable?"edit":e.previewKind!=="none"?e.previewKind:"unsupported"}function af(e,t){return`${e}\0${t??""}`}function x2(e){return[...e].sort((t,n)=>t.kind==="directory"&&n.kind!=="directory"?-1:t.kind!=="directory"&&n.kind==="directory"?1:t.name.localeCompare(n.name))}function Rr(e){const t=e.split("/").filter(Boolean);return t.pop(),t.join("/")}function Vy(e,t){if(e===null)return null;const n=e.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/").replace(/\/$/,"");return n?!t||n.includes("/")?n:`${t}/${n}`:null}function Xn(e){return e instanceof Error?e.message:"Request failed"}function E2(e){return e instanceof yn&&e.status===409&&e.message==="terminal_cwd_changed"}const T2=g.lazy(()=>d0(()=>import("./MarkdownPreview-BfwhfniS.js"),[]));function Xy({api:e,editor:t,canClose:n,onClose:a}){const[o,c]=g.useState(t.read),[d,p]=g.useState(t.read.content),[m,f]=g.useState("idle"),[S,y]=g.useState(null),[w,x]=g.useState(!1),[C,k]=g.useState("edit"),L=g.useRef(t),R=g.useRef(t.read),ae=g.useRef(t.read.content),q=g.useRef(!1),G=g.useRef(!1),ue=g.useRef(0),F=d!==o.content&&m!=="saving"&&!w;g.useEffect(()=>(G.current=!0,()=>{G.current=!1,ue.current+=1}),[]),g.useEffect(()=>{ue.current+=1,q.current=!1,L.current=t,R.current=t.read,ae.current=t.read.content,c(t.read),p(t.read.content),f("idle"),y(null),x(!1),k("edit")},[t.id,t.read]),g.useEffect(()=>{L.current=t},[t]),g.useEffect(()=>{R.current=o},[o]),g.useEffect(()=>{ae.current=d},[d]),g.useEffect(()=>{if(d===o.content||w)return;const Z=window.setInterval(()=>{!q.current&&ae.current!==R.current.content&&P()},1e3);return()=>window.clearInterval(Z)},[d===o.content,w,t.id]);async function P(){if(q.current)return;const Z=ae.current,K=R.current;if(Z===K.content)return;const j=L.current,te=ue.current;q.current=!0,f("saving"),y(null),x(!1);try{const se=await e.writeFile({rootToken:j.rootToken,path:j.path,content:Z,expectedVersion:K.version});if(!G.current||te!==ue.current)return;const N={...K,content:Z,version:se.version};R.current=N,c(N),f(ae.current===Z?"saved":"idle")}catch(se){if(!G.current||te!==ue.current)return;if(se instanceof yn&&se.status===409){x(!0),f("idle");return}y(k2(se)),f("idle")}finally{te===ue.current&&(q.current=!1)}}const M=m==="saving"?"saving":m==="saved"?"saved":o.language,Q=o.language==="markdown",ne=Q&&C==="preview";return _.jsxs("section",{className:"editor-pane","aria-label":`Editor pane ${t.title}`,children:[_.jsxs("header",{className:"editor-pane-header",children:[_.jsx("span",{className:"terminal-pane-dot","aria-hidden":"true"}),_.jsx("strong",{children:t.title}),_.jsx("span",{className:"terminal-pane-spacer"}),_.jsx("span",{className:"terminal-pane-state",children:M}),_.jsx("button",{type:"button","aria-label":`Save ${t.title}`,disabled:!F,onClick:()=>{P()},children:"Save"}),Q?_.jsx("button",{type:"button","aria-label":`${ne?"Edit":"Preview"} ${t.title}`,onClick:()=>k(Z=>Z==="preview"?"edit":"preview"),children:ne?"Edit":"Preview"}):null,n?_.jsx("button",{type:"button",className:"terminal-pane-close","aria-label":`Close editor ${t.title}`,onClick:a,children:"x"}):null]}),S?_.jsx("div",{className:"editor-pane-alert",role:"alert",children:S}):null,w?_.jsx("div",{className:"editor-pane-alert",role:"alert",children:"File changed on disk."}):null,ne?_.jsx("div",{className:"editor-markdown-preview","aria-label":`Markdown preview for ${t.title}`,children:_.jsx(g.Suspense,{fallback:_.jsx("div",{className:"editor-markdown-preview-loading",children:"loading preview"}),children:_.jsx(T2,{content:d})})}):_.jsx("textarea",{className:"editor-pane-textarea","aria-label":`Editor for ${t.title}`,spellCheck:!1,value:d,onChange:Z=>{const K=Z.target.value;ae.current=K,p(K),f("idle"),y(null),x(!1)}})]})}function k2(e){return e instanceof Error?e.message:"Request failed"}var D2=2,R2=1,M2=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),a=parseInt(n.getPropertyValue("height")),o=Math.max(0,parseInt(n.getPropertyValue("width"))),c=window.getComputedStyle(this._terminal.element),d={top:parseInt(c.getPropertyValue("padding-top")),bottom:parseInt(c.getPropertyValue("padding-bottom")),right:parseInt(c.getPropertyValue("padding-right")),left:parseInt(c.getPropertyValue("padding-left"))},p=d.top+d.bottom,m=d.right+d.left,f=a-p,S=o-m-t;return{cols:Math.max(D2,Math.floor(S/e.css.cell.width)),rows:Math.max(R2,Math.floor(f/e.css.cell.height))}}};var f0=Object.defineProperty,A2=Object.getOwnPropertyDescriptor,N2=(e,t)=>{for(var n in t)f0(e,n,{get:t[n],enumerable:!0})},Ht=(e,t,n,a)=>{for(var o=a>1?void 0:a?A2(t,n):t,c=e.length-1,d;c>=0;c--)(d=e[c])&&(o=(a?d(t,n,o):d(o))||o);return a&&o&&f0(t,n,o),o},ye=(e,t)=>(n,a)=>t(n,a,e),Gy="Terminal input",Vf={get:()=>Gy,set:e=>Gy=e},Zy="Too much output to announce, navigate to rows manually to read",Xf={get:()=>Zy,set:e=>Zy=e};function B2(e){return e.replace(/\r?\n/g,"\r")}function L2(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function O2(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function z2(e,t,n,a){if(e.stopPropagation(),e.clipboardData){let o=e.clipboardData.getData("text/plain");p0(o,t,n,a)}}function p0(e,t,n,a){e=B2(e),e=L2(e,n.decPrivateModes.bracketedPasteMode&&a.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=""}function m0(e,t,n){let a=n.getBoundingClientRect(),o=e.clientX-a.left-10,c=e.clientY-a.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${o}px`,t.style.top=`${c}px`,t.style.zIndex="1000",t.focus()}function Qy(e,t,n,a,o){m0(e,t,n),o&&a.rightClickSelect(e),t.value=a.selectionText,t.select()}function tr(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Au(e,t=0,n=e.length){let a="";for(let o=t;o<n;++o){let c=e[o];c>65535?(c-=65536,a+=String.fromCharCode((c>>10)+55296)+String.fromCharCode(c%1024+56320)):a+=String.fromCharCode(c)}return a}var j2=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let a=0,o=0;if(this._interim){let c=e.charCodeAt(o++);56320<=c&&c<=57343?t[a++]=(this._interim-55296)*1024+c-56320+65536:(t[a++]=this._interim,t[a++]=c),this._interim=0}for(let c=o;c<n;++c){let d=e.charCodeAt(c);if(55296<=d&&d<=56319){if(++c>=n)return this._interim=d,a;let p=e.charCodeAt(c);56320<=p&&p<=57343?t[a++]=(d-55296)*1024+p-56320+65536:(t[a++]=d,t[a++]=p);continue}d!==65279&&(t[a++]=d)}return a}},H2=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let a=0,o,c,d,p,m=0,f=0;if(this.interim[0]){let w=!1,x=this.interim[0];x&=(x&224)===192?31:(x&240)===224?15:7;let C=0,k;for(;(k=this.interim[++C]&63)&&C<4;)x<<=6,x|=k;let L=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,R=L-C;for(;f<R;){if(f>=n)return 0;if(k=e[f++],(k&192)!==128){f--,w=!0;break}else this.interim[C++]=k,x<<=6,x|=k&63}w||(L===2?x<128?f--:t[a++]=x:L===3?x<2048||x>=55296&&x<=57343||x===65279||(t[a++]=x):x<65536||x>1114111||(t[a++]=x)),this.interim.fill(0)}let S=n-4,y=f;for(;y<n;){for(;y<S&&!((o=e[y])&128)&&!((c=e[y+1])&128)&&!((d=e[y+2])&128)&&!((p=e[y+3])&128);)t[a++]=o,t[a++]=c,t[a++]=d,t[a++]=p,y+=4;if(o=e[y++],o<128)t[a++]=o;else if((o&224)===192){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(m=(o&31)<<6|c&63,m<128){y--;continue}t[a++]=m}else if((o&240)===224){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,a;if(d=e[y++],(d&192)!==128){y--;continue}if(m=(o&15)<<12|(c&63)<<6|d&63,m<2048||m>=55296&&m<=57343||m===65279)continue;t[a++]=m}else if((o&248)===240){if(y>=n)return this.interim[0]=o,a;if(c=e[y++],(c&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,a;if(d=e[y++],(d&192)!==128){y--;continue}if(y>=n)return this.interim[0]=o,this.interim[1]=c,this.interim[2]=d,a;if(p=e[y++],(p&192)!==128){y--;continue}if(m=(o&7)<<18|(c&63)<<12|(d&63)<<6|p&63,m<65536||m>1114111)continue;t[a++]=m}}return a}},_0="",sr=" ",Co=class v0{constructor(){this.fg=0,this.bg=0,this.extended=new pu}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new v0;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},pu=class g0{constructor(t=0,n=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=n}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new g0(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},xs=class y0 extends Co{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new pu,this.combinedData=""}static fromCharData(t){let n=new y0;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?tr(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let n=!1;if(t[1].length>2)n=!0;else if(t[1].length===2){let a=t[1].charCodeAt(0);if(55296<=a&&a<=56319){let o=t[1].charCodeAt(1);56320<=o&&o<=57343?this.content=(a-55296)*1024+o-56320+65536|t[2]<<22:n=!0}else n=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;n&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Jy="di$target",Gf="di$dependencies",lf=new Map;function U2(e){return e[Gf]||[]}function pi(e){if(lf.has(e))return lf.get(e);let t=function(n,a,o){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");P2(t,n,o)};return t._id=e,lf.set(e,t),t}function P2(e,t,n){t[Jy]===t?t[Gf].push({id:e,index:n}):(t[Gf]=[{id:e,index:n}],t[Jy]=t)}var Oi=pi("BufferService"),S0=pi("CoreMouseService"),Pr=pi("CoreService"),K2=pi("CharsetService"),gm=pi("InstantiationService"),b0=pi("LogService"),zi=pi("OptionsService"),w0=pi("OscLinkService"),I2=pi("UnicodeService"),xo=pi("DecorationService"),Zf=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let a=[],o=this._optionsService.rawOptions.linkHandler,c=new xs,d=n.getTrimmedLength(),p=-1,m=-1,f=!1;for(let S=0;S<d;S++)if(!(m===-1&&!n.hasContent(S))){if(n.loadCell(S,c),c.hasExtendedAttrs()&&c.extended.urlId)if(m===-1){m=S,p=c.extended.urlId;continue}else f=c.extended.urlId!==p;else m!==-1&&(f=!0);if(f||m!==-1&&S===d-1){let y=this._oscLinkService.getLinkData(p)?.uri;if(y){let w={start:{x:m+1,y:e},end:{x:S+(!f&&S===d-1?1:0),y:e}},x=!1;if(!o?.allowNonHttpProtocols)try{let C=new URL(y);["http:","https:"].includes(C.protocol)||(x=!0)}catch{x=!0}x||a.push({text:y,range:w,activate:(C,k)=>o?o.activate(C,k,w):F2(C,k),hover:(C,k)=>o?.hover?.(C,k,w),leave:(C,k)=>o?.leave?.(C,k,w)})}f=!1,c.hasExtendedAttrs()&&c.extended.urlId?(m=S,p=c.extended.urlId):(m=-1,p=-1)}}t(a)}};Zf=Ht([ye(0,Oi),ye(1,zi),ye(2,w0)],Zf);function F2(e,t){if(confirm(`Do you want to navigate to ${t}?
15
15
 
16
16
  WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Nu=pi("CharSizeService"),bn=pi("CoreBrowserService"),ym=pi("MouseService"),wn=pi("RenderService"),q2=pi("SelectionService"),C0=pi("CharacterJoinerService"),Ha=pi("ThemeService"),x0=pi("LinkProviderService"),W2=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?eS.isErrorNoTelemetry(e)?new eS(e.message+`
17
17
 
@@ -12,7 +12,7 @@
12
12
  <link rel="icon" type="image/png" sizes="64x64" href="/icons/favicon-64.png" />
13
13
  <link rel="icon" type="image/png" sizes="96x96" href="/icons/favicon-96.png" />
14
14
  <title>NTerminal</title>
15
- <script type="module" crossorigin src="/assets/index-CzfRb88C.js"></script>
15
+ <script type="module" crossorigin src="/assets/index-8FTmdvif.js"></script>
16
16
  <link rel="stylesheet" crossorigin href="/assets/index-B3-WG4Tf.css">
17
17
  </head>
18
18
  <body>
@@ -1,4 +1,4 @@
1
1
  import type { ManualUpdateInfo } from './protocol.js';
2
- export declare const manualUpdateMessage = "Automatic update needs write access to the global npm install. Run the manual update command on this server.";
2
+ export declare const manualUpdateMessage = "Automatic update needs write access to the global npm install. Run the manual update command as the NTerminal runtime user; only the npm install step should use sudo.";
3
3
  export declare function createManualUpdateInfo(packageName?: string, detectedAt?: Date): ManualUpdateInfo;
4
4
  export declare function isPermissionUpdateFailure(output: string): boolean;
@@ -1,4 +1,4 @@
1
- export const manualUpdateMessage = 'Automatic update needs write access to the global npm install. Run the manual update command on this server.';
1
+ export const manualUpdateMessage = 'Automatic update needs write access to the global npm install. Run the manual update command as the NTerminal runtime user; only the npm install step should use sudo.';
2
2
  export function createManualUpdateInfo(packageName = 'nterminal', detectedAt = new Date()) {
3
3
  return {
4
4
  reason: 'permission',
@@ -1 +1 @@
1
- {"version":3,"file":"manualUpdate.js","sourceRoot":"","sources":["../../src/shared/manualUpdate.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAC9B,8GAA8G,CAAC;AAEjH,MAAM,UAAU,sBAAsB,CAAC,WAAW,GAAG,WAAW,EAAE,UAAU,GAAG,IAAI,IAAI,EAAE;IACvF,OAAO;QACL,MAAM,EAAE,YAAY;QACpB,OAAO,EAAE,mBAAmB;QAC5B,OAAO,EAAE,iBAAiB,WAAW,8CAA8C;QACnF,UAAU,EAAE,UAAU,CAAC,WAAW,EAAE;KACrC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,MAAc;IACtD,OAAO,qKAAqK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5L,CAAC"}
1
+ {"version":3,"file":"manualUpdate.js","sourceRoot":"","sources":["../../src/shared/manualUpdate.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAC9B,wKAAwK,CAAC;AAE3K,MAAM,UAAU,sBAAsB,CAAC,WAAW,GAAG,WAAW,EAAE,UAAU,GAAG,IAAI,IAAI,EAAE;IACvF,OAAO;QACL,MAAM,EAAE,YAAY;QACpB,OAAO,EAAE,mBAAmB;QAC5B,OAAO,EAAE,iBAAiB,WAAW,8CAA8C;QACnF,UAAU,EAAE,UAAU,CAAC,WAAW,EAAE;KACrC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,MAAc;IACtD,OAAO,qKAAqK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5L,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nterminal",
3
- "version": "1.2.17",
3
+ "version": "1.2.18",
4
4
  "license": "GPL-3.0-only",
5
5
  "type": "module",
6
6
  "packageManager": "npm@10.9.7",
@@ -150,6 +150,14 @@ validate_required_env() {
150
150
  return "$missing"
151
151
  }
152
152
 
153
+ prepare_start() {
154
+ ensure_app_dir
155
+ ensure_env_file
156
+ ensure_runtime
157
+ validate_required_env || die "generate real secrets before starting"
158
+ ensure_directories
159
+ }
160
+
153
161
  read_pid() {
154
162
  [[ -f "$PID_PATH" ]] || return 1
155
163
  read_pid_file "$PID_PATH"
@@ -514,11 +522,7 @@ cmd_status() {
514
522
  }
515
523
 
516
524
  cmd_start() {
517
- ensure_app_dir
518
- ensure_env_file
519
- ensure_runtime
520
- validate_required_env || die "generate real secrets before starting"
521
- ensure_directories
525
+ prepare_start
522
526
  remove_stale_pid
523
527
  remove_stale_monitor_pid
524
528
 
@@ -640,6 +644,7 @@ cmd_restart() {
640
644
  if launchd_controls_app; then
641
645
  start_launchd
642
646
  else
647
+ prepare_start
643
648
  cmd_stop >/dev/null
644
649
  cmd_start
645
650
  fi