0){(c=new z(T.PLAIN,[])).context={parent:a,src:a.context.src};var u=a.range.start+1;if(c.range={start:u,end:u},c.valueRange={start:u,end:u},"number"===typeof a.range.origStart){var h=a.range.origStart+1;c.range.origStart=c.range.origEnd=h,c.valueRange.origStart=c.valueRange.origEnd=h}}var d=new fe(i,Ke(e,c));Je(a,d),r.push(d),i&&"number"===typeof o&&a.range.start>o+1024&&e.errors.push(ze(t,i)),i=void 0,o=null;break;default:void 0!==i&&r.push(new fe(i)),i=Ke(e,a),o=a.range.start,a.error&&e.errors.push(a.error);e:for(var f=s+1;;++f){var p=t.items[f];switch(p&&p.type){case T.BLANK_LINE:case T.COMMENT:continue e;case T.MAP_VALUE:break e;default:var m="Implicit map keys need to be followed by map values";e.errors.push(new L(a,m));break e}}if(a.valueRangeContainsNewline){var g="Implicit map keys need to be on a single line";e.errors.push(new L(a,g))}}}void 0!==i&&r.push(new fe(i));return{comments:n,items:r}}(e,t),i=r.comments,o=r.items,s=new ve;s.items=o,He(s,i);for(var a=!1,l=0;lr.valueRange.start)return!1;if(i[s]!==E.COMMENT)return!1;for(var a=n;as+1024&&e.errors.push(ze(t,o));for(var m=l.context.src,g=s;g1){throw new L(t,"Each pair must have its own sequence indicator")}var o=i.items[0]||new fe;i.commentBefore&&(o.commentBefore=o.commentBefore?"".concat(i.commentBefore,"\n").concat(o.commentBefore):i.commentBefore),i.comment&&(o.comment=o.comment?"".concat(i.comment,"\n").concat(o.comment):i.comment),i=o}n.items[r]=i instanceof fe?i:new fe(i)}}return n}function et(e,t,n){var r=new de(e);r.tag="tag:yaml.org,2002:pairs";var i,o=C(t);try{for(o.s();!(i=o.n()).done;){var s=i.value,a=void 0,l=void 0;if(Array.isArray(s)){if(2!==s.length)throw new TypeError("Expected [key, value] tuple: ".concat(s));a=s[0],l=s[1]}else if(s&&s instanceof Object){var c=Object.keys(s);if(1!==c.length)throw new TypeError("Expected { key: value } tuple: ".concat(s));l=s[a=c[0]]}else a=s;var u=e.createPair(a,l,n);r.items.push(u)}}catch(h){o.e(h)}finally{o.f()}return r}var tt={default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ze,createNode:et},nt=function(e){l(n,e);var t=g(n);function n(){var e;return i(this,n),a(p(e=t.call(this)),"add",ve.prototype.add.bind(p(e))),a(p(e),"delete",ve.prototype.delete.bind(p(e))),a(p(e),"get",ve.prototype.get.bind(p(e))),a(p(e),"has",ve.prototype.has.bind(p(e))),a(p(e),"set",ve.prototype.set.bind(p(e))),e.tag=n.tag,e}return s(n,[{key:"toJSON",value:function(e,t){var n=new Map;t&&t.onCreate&&t.onCreate(n);var r,i=C(this.items);try{for(i.s();!(r=i.n()).done;){var o=r.value,s=void 0,a=void 0;if(o instanceof fe?(s=se(o.key,"",t),a=se(o.value,s,t)):s=se(o,"",t),n.has(s))throw new Error("Ordered maps must not include duplicate keys");n.set(s,a)}}catch(l){i.e(l)}finally{i.f()}return n}}]),n}(de);a(nt,"tag","tag:yaml.org,2002:omap");var rt={identify:function(e){return e instanceof Map},nodeClass:nt,default:!1,tag:"tag:yaml.org,2002:omap",resolve:function(e,t){var n,r=Ze(e,t),i=[],o=C(r.items);try{for(o.s();!(n=o.n()).done;){var s=n.value.key;if(s instanceof ae){if(i.includes(s.value)){throw new L(t,"Ordered maps must not include duplicate keys")}i.push(s.value)}}}catch(a){o.e(a)}finally{o.f()}return Object.assign(new nt,r)},createNode:function(e,t,n){var r=et(e,t,n),i=new nt;return i.items=r.items,i}},it=function(e){l(n,e);var t=g(n);function n(){var e;return i(this,n),(e=t.call(this)).tag=n.tag,e}return s(n,[{key:"add",value:function(e){var t=e instanceof fe?e:new fe(e);ge(this.items,t.key)||this.items.push(t)}},{key:"get",value:function(e,t){var n=ge(this.items,e);return!t&&n instanceof fe?n.key instanceof ae?n.key.value:n.key:n}},{key:"set",value:function(e,t){if("boolean"!==typeof t)throw new Error("Expected boolean value for set(key, value) in a YAML set, not ".concat(r(t)));var n=ge(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new fe(e))}},{key:"toJSON",value:function(e,t){return v(c(n.prototype),"toJSON",this).call(this,e,t,Set)}},{key:"toString",value:function(e,t,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues())return v(c(n.prototype),"toString",this).call(this,e,t,r);throw new Error("Set items must all have null values")}}]),n}(ve);a(it,"tag","tag:yaml.org,2002:set");var ot={identify:function(e){return e instanceof Set},nodeClass:it,default:!1,tag:"tag:yaml.org,2002:set",resolve:function(e,t){var n=Qe(e,t);if(!n.hasAllNullValues())throw new L(t,"Set items must all have null values");return Object.assign(new it,n)},createNode:function(e,t,n){var r,i=new it,o=C(t);try{for(o.s();!(r=o.n()).done;){var s=r.value;i.items.push(e.createPair(s,null,n))}}catch(a){o.e(a)}finally{o.f()}return i}},st=function(e,t){var n=t.split(":").reduce((function(e,t){return 60*e+Number(t)}),0);return"-"===e?-n:n},at=function(e){var t=e.value;if(isNaN(t)||!isFinite(t))return Le(t);var n="";t<0&&(n="-",t=Math.abs(t));var r=[t%60];return t<60?r.unshift(0):(t=Math.round((t-r[0])/60),r.unshift(t%60),t>=60&&(t=Math.round((t-r[0])/60),r.unshift(t))),n+r.map((function(e){return e<10?"0"+String(e):String(e)})).join(":").replace(/000000\d*$/,"")},lt={identify:function(e){return"number"===typeof e},default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/,resolve:function(e,t,n){return st(t,n.replace(/_/g,""))},stringify:at},ct={identify:function(e){return"number"===typeof e},default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/,resolve:function(e,t,n){return st(t,n.replace(/_/g,""))},stringify:at},ut={identify:function(e){return e instanceof Date},default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^(?:([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?)$"),resolve:function(e,t,n,r,i,o,s,a,l){a&&(a=(a+"00").substr(1,3));var c=Date.UTC(t,n-1,r,i||0,o||0,s||0,a||0);if(l&&"Z"!==l){var u=st(l[0],l.slice(1));Math.abs(u)<30&&(u*=60),c-=6e4*u}return new Date(c)},stringify:function(e){return e.value.toISOString().replace(/((T00:00)?:00)?\.000Z$/,"")}};function ht(e){var t="undefined"!==typeof process&&{NODE_ENV:"production",PUBLIC_URL:".",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}||{};return e?"undefined"!==typeof YAML_SILENCE_DEPRECATION_WARNINGS?!YAML_SILENCE_DEPRECATION_WARNINGS:!t.YAML_SILENCE_DEPRECATION_WARNINGS:"undefined"!==typeof YAML_SILENCE_WARNINGS?!YAML_SILENCE_WARNINGS:!t.YAML_SILENCE_WARNINGS}function dt(e,t){if(ht(!1)){var n="undefined"!==typeof process&&process.emitWarning;n?n(e,t):console.warn(t?"".concat(t,": ").concat(e):e)}}var ft={};var pt={createNode:function(e,t,n){var i=new ve(e);if(t instanceof Map){var o,s=C(t);try{for(s.s();!(o=s.n()).done;){var a=y(o.value,2),l=a[0],c=a[1];i.items.push(e.createPair(l,c,n))}}catch(f){s.e(f)}finally{s.f()}}else if(t&&"object"===r(t))for(var u=0,h=Object.keys(t);u=0?n+r.toString(t):Le(e)}var wt={identify:function(e){return null==e},createNode:function(e,t,n){return n.wrapScalars?new ae(null):null},default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:function(){return null},options:Se,stringify:function(){return Se.nullStr}},xt={identify:function(e){return"boolean"===typeof e},default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:function(e){return"t"===e[0]||"T"===e[0]},options:xe,stringify:function(e){return e.value?xe.trueStr:xe.falseStr}},kt={identify:function(e){return vt(e)&&e>=0},default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o([0-7]+)$/,resolve:function(e,t){return yt(e,t,8)},options:ke,stringify:function(e){return bt(e,8,"0o")}},St={identify:vt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:function(e){return yt(e,e,10)},options:ke,stringify:Le},Ct={identify:function(e){return vt(e)&&e>=0},default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x([0-9a-fA-F]+)$/,resolve:function(e,t){return yt(e,t,16)},options:ke,stringify:function(e){return bt(e,16,"0x")}},Et={identify:function(e){return"number"===typeof e},default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.inf|(\.nan))$/i,resolve:function(e,t){return t?NaN:"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY},stringify:Le},Tt={identify:function(e){return"number"===typeof e},default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:function(e){return parseFloat(e)},stringify:function(e){var t=e.value;return Number(t).toExponential()}},Ot={identify:function(e){return"number"===typeof e},default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/,resolve:function(e,t,n){var r=t||n,i=new ae(parseFloat(e));return r&&"0"===r[r.length-1]&&(i.minFractionDigits=r.length),i},stringify:Le},At=gt.concat([wt,xt,kt,St,Ct,Et,Tt,Ot]),_t=function(e){return"bigint"===typeof e||Number.isInteger(e)},Pt=function(e){var t=e.value;return JSON.stringify(t)},Nt=[pt,mt,{identify:function(e){return"string"===typeof e},default:!0,tag:"tag:yaml.org,2002:str",resolve:$e,stringify:Pt},{identify:function(e){return null==e},createNode:function(e,t,n){return n.wrapScalars?new ae(null):null},default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:function(){return null},stringify:Pt},{identify:function(e){return"boolean"===typeof e},default:!0,tag:"tag:yaml.org,2002:bool",test:/^true|false$/,resolve:function(e){return"true"===e},stringify:Pt},{identify:_t,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:function(e){return ke.asBigInt?BigInt(e):parseInt(e,10)},stringify:function(e){var t=e.value;return _t(t)?t.toString():JSON.stringify(t)}},{identify:function(e){return"number"===typeof e},default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:function(e){return parseFloat(e)},stringify:Pt}];Nt.scalarFallback=function(e){throw new SyntaxError("Unresolved plain scalar ".concat(JSON.stringify(e)))};var Mt=function(e){return e.value?xe.trueStr:xe.falseStr},jt=function(e){return"bigint"===typeof e||Number.isInteger(e)};function Rt(e,t,n){var r=t.replace(/_/g,"");if(ke.asBigInt){switch(n){case 2:r="0b".concat(r);break;case 8:r="0o".concat(r);break;case 16:r="0x".concat(r)}var i=BigInt(r);return"-"===e?BigInt(-1)*i:i}var o=parseInt(r,n);return"-"===e?-1*o:o}function It(e,t,n){var r=e.value;if(jt(r)){var i=r.toString(t);return r<0?"-"+n+i.substr(1):n+i}return Le(e)}var Dt=gt.concat([{identify:function(e){return null==e},createNode:function(e,t,n){return n.wrapScalars?new ae(null):null},default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:function(){return null},options:Se,stringify:function(){return Se.nullStr}},{identify:function(e){return"boolean"===typeof e},default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:function(){return!0},options:xe,stringify:Mt},{identify:function(e){return"boolean"===typeof e},default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,resolve:function(){return!1},options:xe,stringify:Mt},{identify:jt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^([-+]?)0b([0-1_]+)$/,resolve:function(e,t,n){return Rt(t,n,2)},stringify:function(e){return It(e,2,"0b")}},{identify:jt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^([-+]?)0([0-7_]+)$/,resolve:function(e,t,n){return Rt(t,n,8)},stringify:function(e){return It(e,8,"0")}},{identify:jt,default:!0,tag:"tag:yaml.org,2002:int",test:/^([-+]?)([0-9][0-9_]*)$/,resolve:function(e,t,n){return Rt(t,n,10)},stringify:Le},{identify:jt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^([-+]?)0x([0-9a-fA-F_]+)$/,resolve:function(e,t,n){return Rt(t,n,16)},stringify:function(e){return It(e,16,"0x")}},{identify:function(e){return"number"===typeof e},default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.inf|(\.nan))$/i,resolve:function(e,t){return t?NaN:"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY},stringify:Le},{identify:function(e){return"number"===typeof e},default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:function(e){return parseFloat(e.replace(/_/g,""))},stringify:function(e){var t=e.value;return Number(t).toExponential()}},{identify:function(e){return"number"===typeof e},default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,resolve:function(e,t){var n=new ae(parseFloat(e.replace(/_/g,"")));if(t){var r=t.replace(/_/g,"");"0"===r[r.length-1]&&(n.minFractionDigits=r.length)}return n},stringify:Le}],Xe,rt,tt,ot,lt,ct,ut),Lt={core:At,failsafe:gt,json:Nt,yaml11:Dt},Bt={binary:Xe,bool:xt,float:Ot,floatExp:Tt,floatNaN:Et,floatTime:ct,int:St,intHex:Ct,intOct:kt,intTime:lt,map:pt,null:wt,omap:rt,pairs:tt,seq:mt,set:ot,timestamp:ut};function Ft(e,t,n){if(e instanceof oe)return e;var i=n.defaultPrefix,o=n.onTagObj,s=n.prevObjects,a=n.schema,l=n.wrapScalars;t&&t.startsWith("!!")&&(t=i+t.slice(2));var c=function(e,t,n){if(t){var r=n.filter((function(e){return e.tag===t})),i=r.find((function(e){return!e.format}))||r[0];if(!i)throw new Error("Tag ".concat(t," not found"));return i}return n.find((function(t){return(t.identify&&t.identify(e)||t.class&&e instanceof t.class)&&!t.format}))}(e,t,a.tags);if(!c){if("function"===typeof e.toJSON&&(e=e.toJSON()),!e||"object"!==r(e))return l?new ae(e):e;c=e instanceof Map?pt:e[Symbol.iterator]?mt:pt}o&&(o(c),delete n.onTagObj);var u={value:void 0,node:void 0};if(e&&"object"===r(e)&&s){var h=s.get(e);if(h){var d=new me(h);return n.aliasNodes.push(d),d}u.value=e,s.set(e,u)}return u.node=c.createNode?c.createNode(n.schema,e,n):l?new ae(e):e,t&&u.node instanceof oe&&(u.node.tag=t),u.node}var zt=function(e,t){return e.keyt.key?1:0},Ht=function(){function e(t){var n=t.customTags,r=t.merge,o=t.schema,s=t.sortMapEntries,a=t.tags;i(this,e),this.merge=!!r,this.name=o,this.sortMapEntries=!0===s?zt:s||null,!n&&a&&function(e,t){if(!ft[e]&&ht(!0)){ft[e]=!0;var n="The option '".concat(e,"' will be removed in a future release");dt(n+=t?", use '".concat(t,"' instead."):".","DeprecationWarning")}}("tags","customTags"),this.tags=function(e,t,n,r){var i=e[r.replace(/\W/g,"")];if(!i){var o=Object.keys(e).map((function(e){return JSON.stringify(e)})).join(", ");throw new Error('Unknown schema "'.concat(r,'"; use one of ').concat(o))}if(Array.isArray(n)){var s,a=C(n);try{for(a.s();!(s=a.n()).done;){var l=s.value;i=i.concat(l)}}catch(f){a.e(f)}finally{a.f()}}else"function"===typeof n&&(i=n(i.slice()));for(var c=0;c");var s=t.substr(i.prefix.length).replace(/[!,[\]{}]/g,(function(e){return{"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"}[e]}));return i.handle+s}function qt(e,t,n,i){var o,s=t.doc,a=s.anchors,l=s.schema;if(!(e instanceof oe)){var c={aliasNodes:[],onTagObj:function(e){return o=e},prevObjects:new Map};e=l.createNode(e,!0,null,c);var u,h=C(c.aliasNodes);try{for(h.s();!(u=h.n()).done;){var d=u.value;d.source=d.source.node;var f=a.getName(d.source);f||(f=a.newName(),a.map[f]=d.source)}}catch(g){h.e(g)}finally{h.f()}}if(e instanceof fe)return e.toString(t,n,i);o||(o=function(e,t){if(t instanceof me)return me;if(t.tag){var n=e.filter((function(e){return e.tag===t.tag}));if(n.length>0)return n.find((function(e){return e.format===t.format}))||n[0]}var i,o;if(t instanceof ae){o=t.value;var s=e.filter((function(e){return e.identify&&e.identify(o)||e.class&&o instanceof e.class}));i=s.find((function(e){return e.format===t.format}))||s.find((function(e){return!e.format}))}else o=t,i=e.find((function(e){return e.nodeClass&&o instanceof e.nodeClass}));if(!i){var a=o&&o.constructor?o.constructor.name:r(o);throw new Error("Tag not resolved for ".concat(a," value"))}return i}(l.tags,e));var p=function(e,t,n){var r=n.anchors,i=n.doc,o=[],s=i.anchors.getName(e);return s&&(r[s]=e,o.push("&".concat(s))),e.tag?o.push(Vt(i,e.tag)):t.default||o.push(Vt(i,t.tag)),o.join(" ")}(e,o,t);p.length>0&&(t.indentAtStart=(t.indentAtStart||0)+p.length+1);var m="function"===typeof o.stringify?o.stringify(e,t,n,i):e instanceof ae?De(e,t,n,i):e.toString(t,n,i);return p?e instanceof ae||"{"===m[0]||"["===m[0]?"".concat(p," ").concat(m):"".concat(p,"\n").concat(t.indent).concat(m):m}var Kt=function(){function e(t){i(this,e),a(this,"map",Object.create(null)),this.prefix=t}return s(e,[{key:"createAlias",value:function(e,t){return this.setAnchor(e,t),new me(e)}},{key:"createMergePair",value:function(){for(var e=this,t=new be,n=arguments.length,r=new Array(n),i=0;i0&&!e.commentBefore&&(e.commentBefore=r.before.join("\n"),r.before=[]))}}catch(h){s.e(h)}finally{s.f()}if(e.contents=i||null,i){var c=r.before.join("\n");if(c){var u=i instanceof ue&&i.items[0]?i.items[0]:i;u.commentBefore=u.commentBefore?"".concat(c,"\n").concat(u.commentBefore):c}e.comment=r.after.join("\n")||null}else e.comment=r.before.concat(r.after).join("\n")||null}(this,o),this.anchors.resolveNodes(),this.options.prettyErrors){var c,u=C(this.errors);try{for(u.s();!(c=u.n()).done;){var h=c.value;h instanceof I&&h.makePretty()}}catch(m){u.e(m)}finally{u.f()}var d,f=C(this.warnings);try{for(f.s();!(d=f.n()).done;){var p=d.value;p instanceof I&&p.makePretty()}}catch(m){f.e(m)}finally{f.f()}}return this}},{key:"listNonDefaultTags",value:function(){return Gt(this.contents).filter((function(e){return 0!==e.indexOf(Ht.defaultPrefix)}))}},{key:"setTagPrefix",value:function(e,t){if("!"!==e[0]||"!"!==e[e.length-1])throw new Error("Handle must start and end with !");if(t){var n=this.tagPrefixes.find((function(t){return t.handle===e}));n?n.prefix=t:this.tagPrefixes.push({handle:e,prefix:t})}else this.tagPrefixes=this.tagPrefixes.filter((function(t){return t.handle!==e}))}},{key:"toJSON",value:function(e,t){var n=this,r=this.options,i=r.keepBlobsInJSON,o=r.mapAsMap,s=r.maxAliasCount,a=i&&("string"!==typeof e||!(this.contents instanceof ae)),l={doc:this,indentStep:" ",keep:a,mapAsMap:a&&!!o,maxAliasCount:s,stringify:qt},c=Object.keys(this.anchors.map);c.length>0&&(l.anchors=new Map(c.map((function(e){return[n.anchors.map[e],{alias:[],aliasCount:0,count:1}]}))));var u=se(this.contents,e,l);if("function"===typeof t&&l.anchors){var h,d=C(l.anchors.values());try{for(d.s();!(h=d.n()).done;){var f=h.value,p=f.count;t(f.res,p)}}catch(m){d.e(m)}finally{d.f()}}return u}},{key:"toString",value:function(){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");var e=this.options.indent;if(!Number.isInteger(e)||e<=0){var t=JSON.stringify(e);throw new Error('"indent" option must be a positive integer, not '.concat(t))}this.setSchema();var n=[],r=!1;if(this.version){var i="%YAML 1.2";"yaml-1.1"===this.schema.name&&("1.0"===this.version?i="%YAML:1.0":"1.1"===this.version&&(i="%YAML 1.1")),n.push(i),r=!0}var o=this.listNonDefaultTags();this.tagPrefixes.forEach((function(e){var t=e.handle,i=e.prefix;o.some((function(e){return 0===e.indexOf(i)}))&&(n.push("%TAG ".concat(t," ").concat(i)),r=!0)})),(r||this.directivesEndMarker)&&n.push("---"),this.commentBefore&&(!r&&this.directivesEndMarker||n.unshift(""),n.unshift(this.commentBefore.replace(/^/gm,"#")));var s={anchors:Object.create(null),doc:this,indent:"",indentStep:" ".repeat(e),stringify:qt},a=!1,l=null;if(this.contents){this.contents instanceof oe&&(this.contents.spaceBefore&&(r||this.directivesEndMarker)&&n.push(""),this.contents.commentBefore&&n.push(this.contents.commentBefore.replace(/^/gm,"#")),s.forceBlockIndent=!!this.comment,l=this.contents.comment);var c=l?null:function(){return a=!0},u=qt(this.contents,s,(function(){return l=null}),c);n.push(ie(u,"",l))}else void 0!==this.contents&&n.push(qt(this.contents,s));return this.comment&&(a&&!l||""===n[n.length-1]||n.push(""),n.push(this.comment.replace(/^/gm,"#"))),n.join("\n")+"\n"}}]),e}();a(Zt,"defaults",Wt);var en=function(e){l(n,e);var t=g(n);function n(e){return i(this,n),t.call(this,Object.assign({},$t,e))}return n}(Zt);function tn(e,t){var n=re(e),r=new en(t).parse(n[0]);if(n.length>1){r.errors.unshift(new L(n[1],"Source contains multiple documents; please use YAML.parseAllDocuments()"))}return r}var nn={createNode:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0;void 0===n&&"string"===typeof t&&(n=t,t=!0);var r=Object.assign({},Zt.defaults[$t.version],$t);return new Ht(r).createNode(e,t,n)},defaultOptions:$t,Document:en,parse:function(e,t){var n=tn(e,t);if(n.warnings.forEach((function(e){return dt(e)})),n.errors.length>0)throw n.errors[0];return n.toJSON()},parseAllDocuments:function(e,t){var n,r,i=[],o=C(re(e));try{for(o.s();!(r=o.n()).done;){var s=r.value,a=new en(t);a.parse(s,n),i.push(a),n=a}}catch(l){o.e(l)}finally{o.f()}return i},parseCST:re,parseDocument:tn,scalarOptions:Ut,stringify:function(e,t){var n=new en(t);return n.contents=e,String(n)}}}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e;const t=("/"===window.urlBase?"":window.urlBase)||"",r=(e=window.port,`${t}/api/v0`),i=`${t}/hub`,o="slskd-token",s="n/a",a="slskd-active-chat",l="slskd-active-room",c="slskd-active-user",u=()=>sessionStorage.getItem(o)||localStorage.getItem(o),h=(e,t)=>e.setItem(o,t),d=()=>{localStorage.removeItem(o),sessionStorage.removeItem(o)},f=()=>u()===s,p=[0,2e3,1e4,3e4,null];class m{constructor(e){this._retryDelays=void 0!==e?[...e,null]:p}nextRetryDelayInMilliseconds(e){return this._retryDelays[e.previousRetryCount]}}class g{}g.Authorization="Authorization",g.Cookie="Cookie";class v{constructor(e,t,n){this.statusCode=e,this.statusText=t,this.content=n}}class y{get(e,t){return this.send({...t,method:"GET",url:e})}post(e,t){return this.send({...t,method:"POST",url:e})}delete(e,t){return this.send({...t,method:"DELETE",url:e})}getCookieString(e){return""}}class b extends y{constructor(e,t){super(),this._innerClient=e,this._accessTokenFactory=t}async send(e){let t=!0;this._accessTokenFactory&&(!this._accessToken||e.url&&e.url.indexOf("/negotiate?")>0)&&(t=!1,this._accessToken=await this._accessTokenFactory()),this._setAuthorizationHeader(e);const n=await this._innerClient.send(e);return t&&401===n.statusCode&&this._accessTokenFactory?(this._accessToken=await this._accessTokenFactory(),this._setAuthorizationHeader(e),await this._innerClient.send(e)):n}_setAuthorizationHeader(e){e.headers||(e.headers={}),this._accessToken?e.headers[g.Authorization]=`Bearer ${this._accessToken}`:this._accessTokenFactory&&e.headers[g.Authorization]&&delete e.headers[g.Authorization]}getCookieString(e){return this._innerClient.getCookieString(e)}}class w extends Error{constructor(e,t){const n=new.target.prototype;super(`${e}: Status code '${t}'`),this.statusCode=t,this.__proto__=n}}class x extends Error{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"A timeout occurred.";const t=new.target.prototype;super(e),this.__proto__=t}}class k extends Error{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"An abort occurred.";const t=new.target.prototype;super(e),this.__proto__=t}}class S extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.transport=t,this.errorType="UnsupportedTransportError",this.__proto__=n}}class C extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.transport=t,this.errorType="DisabledTransportError",this.__proto__=n}}class E extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.transport=t,this.errorType="FailedToStartTransportError",this.__proto__=n}}class T extends Error{constructor(e){const t=new.target.prototype;super(e),this.errorType="FailedToNegotiateWithServerError",this.__proto__=t}}class O extends Error{constructor(e,t){const n=new.target.prototype;super(e),this.innerErrors=t,this.__proto__=n}}var A;!function(e){e[e.Trace=0]="Trace",e[e.Debug=1]="Debug",e[e.Information=2]="Information",e[e.Warning=3]="Warning",e[e.Error=4]="Error",e[e.Critical=5]="Critical",e[e.None=6]="None"}(A||(A={}));class _{constructor(){}log(e,t){}}_.instance=new _;const P="7.0.7";class N{static isRequired(e,t){if(null===e||void 0===e)throw new Error(`The '${t}' argument is required.`)}static isNotEmpty(e,t){if(!e||e.match(/^\s*$/))throw new Error(`The '${t}' argument should not be empty.`)}static isIn(e,t,n){if(!(e in t))throw new Error(`Unknown ${n} value: ${e}.`)}}class M{static get isBrowser(){return"object"===typeof window&&"object"===typeof window.document}static get isWebWorker(){return"object"===typeof self&&"importScripts"in self}static get isReactNative(){return"object"===typeof window&&"undefined"===typeof window.document}static get isNode(){return!this.isBrowser&&!this.isWebWorker&&!this.isReactNative}}function j(e,t){let n="";return R(e)?(n=`Binary data of length ${e.byteLength}`,t&&(n+=`. Content: '${function(e){const t=new Uint8Array(e);let n="";return t.forEach((e=>{n+=`0x${e<16?"0":""}${e.toString(16)} `})),n.substr(0,n.length-1)}(e)}'`)):"string"===typeof e&&(n=`String data of length ${e.length}`,t&&(n+=`. Content: '${e}'`)),n}function R(e){return e&&"undefined"!==typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}async function I(e,t,n,r,i,o){const s={},[a,l]=B();s[a]=l,e.log(A.Trace,`(${t} transport) sending data. ${j(i,o.logMessageContent)}.`);const c=R(i)?"arraybuffer":"text",u=await n.post(r,{content:i,headers:{...s,...o.headers},responseType:c,timeout:o.timeout,withCredentials:o.withCredentials});e.log(A.Trace,`(${t} transport) request complete. Response status: ${u.statusCode}.`)}class D{constructor(e,t){this._subject=e,this._observer=t}dispose(){const e=this._subject.observers.indexOf(this._observer);e>-1&&this._subject.observers.splice(e,1),0===this._subject.observers.length&&this._subject.cancelCallback&&this._subject.cancelCallback().catch((e=>{}))}}class L{constructor(e){this._minLevel=e,this.out=console}log(e,t){if(e>=this._minLevel){const n=`[${(new Date).toISOString()}] ${A[e]}: ${t}`;switch(e){case A.Critical:case A.Error:this.out.error(n);break;case A.Warning:this.out.warn(n);break;case A.Information:this.out.info(n);break;default:this.out.log(n)}}}}function B(){let e="X-SignalR-User-Agent";return M.isNode&&(e="User-Agent"),[e,F(P,z(),$(),H())]}function F(e,t,n,r){let i="Microsoft SignalR/";const o=e.split(".");return i+=`${o[0]}.${o[1]}`,i+=` (${e}; `,i+=t&&""!==t?`${t}; `:"Unknown OS; ",i+=`${n}`,i+=r?`; ${r}`:"; Unknown Runtime Version",i+=")",i}function z(){if(!M.isNode)return"";switch(process.platform){case"win32":return"Windows NT";case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}}function H(){if(M.isNode)return process.versions.node}function $(){return M.isNode?"NodeJS":"Browser"}function U(e){return e.stack?e.stack:e.message?e.message:`${e}`}class W extends y{constructor(e){if(super(),this._logger=e,"undefined"===typeof fetch){const e=require;this._jar=new(e("tough-cookie").CookieJar),this._fetchType=e("node-fetch"),this._fetchType=e("fetch-cookie")(this._fetchType,this._jar)}else this._fetchType=fetch.bind(function(){if("undefined"!==typeof globalThis)return globalThis;if("undefined"!==typeof self)return self;if("undefined"!==typeof window)return window;if("undefined"!==typeof n.g)return n.g;throw new Error("could not find global")}());if("undefined"===typeof AbortController){const e=require;this._abortControllerType=e("abort-controller")}else this._abortControllerType=AbortController}async send(e){if(e.abortSignal&&e.abortSignal.aborted)throw new k;if(!e.method)throw new Error("No method defined.");if(!e.url)throw new Error("No url defined.");const t=new this._abortControllerType;let n;e.abortSignal&&(e.abortSignal.onabort=()=>{t.abort(),n=new k});let r,i=null;if(e.timeout){const r=e.timeout;i=setTimeout((()=>{t.abort(),this._logger.log(A.Warning,"Timeout from HTTP request."),n=new x}),r)}""===e.content&&(e.content=void 0),e.content&&(e.headers=e.headers||{},R(e.content)?e.headers["Content-Type"]="application/octet-stream":e.headers["Content-Type"]="text/plain;charset=UTF-8");try{r=await this._fetchType(e.url,{body:e.content,cache:"no-cache",credentials:!0===e.withCredentials?"include":"same-origin",headers:{"X-Requested-With":"XMLHttpRequest",...e.headers},method:e.method,mode:"cors",redirect:"follow",signal:t.signal})}catch(a){if(n)throw n;throw this._logger.log(A.Warning,`Error from HTTP request. ${a}.`),a}finally{i&&clearTimeout(i),e.abortSignal&&(e.abortSignal.onabort=null)}if(!r.ok){const e=await V(r,"text");throw new w(e||r.statusText,r.status)}const o=V(r,e.responseType),s=await o;return new v(r.status,r.statusText,s)}getCookieString(e){let t="";return M.isNode&&this._jar&&this._jar.getCookies(e,((e,n)=>t=n.join("; "))),t}}function V(e,t){let n;switch(t){case"arraybuffer":n=e.arrayBuffer();break;case"text":default:n=e.text();break;case"blob":case"document":case"json":throw new Error(`${t} is not supported.`)}return n}class q extends y{constructor(e){super(),this._logger=e}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new k):e.method?e.url?new Promise(((t,n)=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),r.withCredentials=void 0===e.withCredentials||e.withCredentials,r.setRequestHeader("X-Requested-With","XMLHttpRequest"),""===e.content&&(e.content=void 0),e.content&&(R(e.content)?r.setRequestHeader("Content-Type","application/octet-stream"):r.setRequestHeader("Content-Type","text/plain;charset=UTF-8"));const i=e.headers;i&&Object.keys(i).forEach((e=>{r.setRequestHeader(e,i[e])})),e.responseType&&(r.responseType=e.responseType),e.abortSignal&&(e.abortSignal.onabort=()=>{r.abort(),n(new k)}),e.timeout&&(r.timeout=e.timeout),r.onload=()=>{e.abortSignal&&(e.abortSignal.onabort=null),r.status>=200&&r.status<300?t(new v(r.status,r.statusText,r.response||r.responseText)):n(new w(r.response||r.responseText||r.statusText,r.status))},r.onerror=()=>{this._logger.log(A.Warning,`Error from HTTP request. ${r.status}: ${r.statusText}.`),n(new w(r.statusText,r.status))},r.ontimeout=()=>{this._logger.log(A.Warning,"Timeout from HTTP request."),n(new x)},r.send(e.content)})):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}}class K extends y{constructor(e){if(super(),"undefined"!==typeof fetch||M.isNode)this._httpClient=new W(e);else{if("undefined"===typeof XMLHttpRequest)throw new Error("No usable HttpClient found.");this._httpClient=new q(e)}}send(e){return e.abortSignal&&e.abortSignal.aborted?Promise.reject(new k):e.method?e.url?this._httpClient.send(e):Promise.reject(new Error("No url defined.")):Promise.reject(new Error("No method defined."))}getCookieString(e){return this._httpClient.getCookieString(e)}}var Q,G;!function(e){e[e.None=0]="None",e[e.WebSockets=1]="WebSockets",e[e.ServerSentEvents=2]="ServerSentEvents",e[e.LongPolling=4]="LongPolling"}(Q||(Q={})),function(e){e[e.Text=1]="Text",e[e.Binary=2]="Binary"}(G||(G={}));class J{constructor(){this._isAborted=!1,this.onabort=null}abort(){this._isAborted||(this._isAborted=!0,this.onabort&&this.onabort())}get signal(){return this}get aborted(){return this._isAborted}}class Y{constructor(e,t,n){this._httpClient=e,this._logger=t,this._pollAbort=new J,this._options=n,this._running=!1,this.onreceive=null,this.onclose=null}get pollAborted(){return this._pollAbort.aborted}async connect(e,t){if(N.isRequired(e,"url"),N.isRequired(t,"transferFormat"),N.isIn(t,G,"transferFormat"),this._url=e,this._logger.log(A.Trace,"(LongPolling transport) Connecting."),t===G.Binary&&"undefined"!==typeof XMLHttpRequest&&"string"!==typeof(new XMLHttpRequest).responseType)throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");const[n,r]=B(),i={[n]:r,...this._options.headers},o={abortSignal:this._pollAbort.signal,headers:i,timeout:1e5,withCredentials:this._options.withCredentials};t===G.Binary&&(o.responseType="arraybuffer");const s=`${e}&_=${Date.now()}`;this._logger.log(A.Trace,`(LongPolling transport) polling: ${s}.`);const a=await this._httpClient.get(s,o);200!==a.statusCode?(this._logger.log(A.Error,`(LongPolling transport) Unexpected response code: ${a.statusCode}.`),this._closeError=new w(a.statusText||"",a.statusCode),this._running=!1):this._running=!0,this._receiving=this._poll(this._url,o)}async _poll(e,t){try{for(;this._running;)try{const n=`${e}&_=${Date.now()}`;this._logger.log(A.Trace,`(LongPolling transport) polling: ${n}.`);const r=await this._httpClient.get(n,t);204===r.statusCode?(this._logger.log(A.Information,"(LongPolling transport) Poll terminated by server."),this._running=!1):200!==r.statusCode?(this._logger.log(A.Error,`(LongPolling transport) Unexpected response code: ${r.statusCode}.`),this._closeError=new w(r.statusText||"",r.statusCode),this._running=!1):r.content?(this._logger.log(A.Trace,`(LongPolling transport) data received. ${j(r.content,this._options.logMessageContent)}.`),this.onreceive&&this.onreceive(r.content)):this._logger.log(A.Trace,"(LongPolling transport) Poll timed out, reissuing.")}catch(n){this._running?n instanceof x?this._logger.log(A.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this._closeError=n,this._running=!1):this._logger.log(A.Trace,`(LongPolling transport) Poll errored after shutdown: ${n.message}`)}}finally{this._logger.log(A.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||this._raiseOnClose()}}async send(e){return this._running?I(this._logger,"LongPolling",this._httpClient,this._url,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}async stop(){this._logger.log(A.Trace,"(LongPolling transport) Stopping polling."),this._running=!1,this._pollAbort.abort();try{await this._receiving,this._logger.log(A.Trace,`(LongPolling transport) sending DELETE request to ${this._url}.`);const e={},[t,n]=B();e[t]=n;const r={headers:{...e,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials};await this._httpClient.delete(this._url,r),this._logger.log(A.Trace,"(LongPolling transport) DELETE request sent.")}finally{this._logger.log(A.Trace,"(LongPolling transport) Stop finished."),this._raiseOnClose()}}_raiseOnClose(){if(this.onclose){let e="(LongPolling transport) Firing onclose event.";this._closeError&&(e+=" Error: "+this._closeError),this._logger.log(A.Trace,e),this.onclose(this._closeError)}}}class X{constructor(e,t,n,r){this._httpClient=e,this._accessToken=t,this._logger=n,this._options=r,this.onreceive=null,this.onclose=null}async connect(e,t){return N.isRequired(e,"url"),N.isRequired(t,"transferFormat"),N.isIn(t,G,"transferFormat"),this._logger.log(A.Trace,"(SSE transport) Connecting."),this._url=e,this._accessToken&&(e+=(e.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(this._accessToken)}`),new Promise(((n,r)=>{let i,o=!1;if(t===G.Text){if(M.isBrowser||M.isWebWorker)i=new this._options.EventSource(e,{withCredentials:this._options.withCredentials});else{const t=this._httpClient.getCookieString(e),n={};n.Cookie=t;const[r,o]=B();n[r]=o,i=new this._options.EventSource(e,{withCredentials:this._options.withCredentials,headers:{...n,...this._options.headers}})}try{i.onmessage=e=>{if(this.onreceive)try{this._logger.log(A.Trace,`(SSE transport) data received. ${j(e.data,this._options.logMessageContent)}.`),this.onreceive(e.data)}catch(t){return void this._close(t)}},i.onerror=e=>{o?this._close():r(new Error("EventSource failed to connect. The connection could not be found on the server, either the connection ID is not present on the server, or a proxy is refusing/buffering the connection. If you have multiple servers check that sticky sessions are enabled."))},i.onopen=()=>{this._logger.log(A.Information,`SSE connected to ${this._url}`),this._eventSource=i,o=!0,n()}}catch(s){return void r(s)}}else r(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"))}))}async send(e){return this._eventSource?I(this._logger,"SSE",this._httpClient,this._url,e,this._options):Promise.reject(new Error("Cannot send until the transport is connected"))}stop(){return this._close(),Promise.resolve()}_close(e){this._eventSource&&(this._eventSource.close(),this._eventSource=void 0,this.onclose&&this.onclose(e))}}class Z{constructor(e,t,n,r,i,o){this._logger=n,this._accessTokenFactory=t,this._logMessageContent=r,this._webSocketConstructor=i,this._httpClient=e,this.onreceive=null,this.onclose=null,this._headers=o}async connect(e,t){let n;return N.isRequired(e,"url"),N.isRequired(t,"transferFormat"),N.isIn(t,G,"transferFormat"),this._logger.log(A.Trace,"(WebSockets transport) Connecting."),this._accessTokenFactory&&(n=await this._accessTokenFactory()),new Promise(((r,i)=>{let o;e=e.replace(/^http/,"ws");const s=this._httpClient.getCookieString(e);let a=!1;if(M.isNode||M.isReactNative){const t={},[r,i]=B();t[r]=i,n&&(t[g.Authorization]=`Bearer ${n}`),s&&(t[g.Cookie]=s),o=new this._webSocketConstructor(e,void 0,{headers:{...t,...this._headers}})}else n&&(e+=(e.indexOf("?")<0?"?":"&")+`access_token=${encodeURIComponent(n)}`);o||(o=new this._webSocketConstructor(e)),t===G.Binary&&(o.binaryType="arraybuffer"),o.onopen=t=>{this._logger.log(A.Information,`WebSocket connected to ${e}.`),this._webSocket=o,a=!0,r()},o.onerror=e=>{let t=null;t="undefined"!==typeof ErrorEvent&&e instanceof ErrorEvent?e.error:"There was an error with the transport",this._logger.log(A.Information,`(WebSockets transport) ${t}.`)},o.onmessage=e=>{if(this._logger.log(A.Trace,`(WebSockets transport) data received. ${j(e.data,this._logMessageContent)}.`),this.onreceive)try{this.onreceive(e.data)}catch(t){return void this._close(t)}},o.onclose=e=>{if(a)this._close(e);else{let t=null;t="undefined"!==typeof ErrorEvent&&e instanceof ErrorEvent?e.error:"WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.",i(new Error(t))}}}))}send(e){return this._webSocket&&this._webSocket.readyState===this._webSocketConstructor.OPEN?(this._logger.log(A.Trace,`(WebSockets transport) sending data. ${j(e,this._logMessageContent)}.`),this._webSocket.send(e),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")}stop(){return this._webSocket&&this._close(void 0),Promise.resolve()}_close(e){this._webSocket&&(this._webSocket.onclose=()=>{},this._webSocket.onmessage=()=>{},this._webSocket.onerror=()=>{},this._webSocket.close(),this._webSocket=void 0),this._logger.log(A.Trace,"(WebSockets transport) socket closed."),this.onclose&&(!this._isCloseEvent(e)||!1!==e.wasClean&&1e3===e.code?e instanceof Error?this.onclose(e):this.onclose():this.onclose(new Error(`WebSocket closed with status code: ${e.code} (${e.reason||"no reason given"}).`)))}_isCloseEvent(e){return e&&"boolean"===typeof e.wasClean&&"number"===typeof e.code}}class ee{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var n;if(this._stopPromiseResolver=()=>{},this.features={},this._negotiateVersion=1,N.isRequired(e,"url"),this._logger=void 0===(n=t.logger)?new L(A.Information):null===n?_.instance:void 0!==n.log?n:new L(n),this.baseUrl=this._resolveUrl(e),t=t||{},t.logMessageContent=void 0!==t.logMessageContent&&t.logMessageContent,"boolean"!==typeof t.withCredentials&&void 0!==t.withCredentials)throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");t.withCredentials=void 0===t.withCredentials||t.withCredentials,t.timeout=void 0===t.timeout?1e5:t.timeout;let r=null,i=null;if(M.isNode){const e=require;r=e("ws"),i=e("eventsource")}M.isNode||"undefined"===typeof WebSocket||t.WebSocket?M.isNode&&!t.WebSocket&&r&&(t.WebSocket=r):t.WebSocket=WebSocket,M.isNode||"undefined"===typeof EventSource||t.EventSource?M.isNode&&!t.EventSource&&"undefined"!==typeof i&&(t.EventSource=i):t.EventSource=EventSource,this._httpClient=new b(t.httpClient||new K(this._logger),t.accessTokenFactory),this._connectionState="Disconnected",this._connectionStarted=!1,this._options=t,this.onreceive=null,this.onclose=null}async start(e){if(e=e||G.Binary,N.isIn(e,G,"transferFormat"),this._logger.log(A.Debug,`Starting connection with transfer format '${G[e]}'.`),"Disconnected"!==this._connectionState)return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));if(this._connectionState="Connecting",this._startInternalPromise=this._startInternal(e),await this._startInternalPromise,"Disconnecting"===this._connectionState){const e="Failed to start the HttpConnection before stop() was called.";return this._logger.log(A.Error,e),await this._stopPromise,Promise.reject(new k(e))}if("Connected"!==this._connectionState){const e="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";return this._logger.log(A.Error,e),Promise.reject(new k(e))}this._connectionStarted=!0}send(e){return"Connected"!==this._connectionState?Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State.")):(this._sendQueue||(this._sendQueue=new te(this.transport)),this._sendQueue.send(e))}async stop(e){return"Disconnected"===this._connectionState?(this._logger.log(A.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnected state.`),Promise.resolve()):"Disconnecting"===this._connectionState?(this._logger.log(A.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState="Disconnecting",this._stopPromise=new Promise((e=>{this._stopPromiseResolver=e})),await this._stopInternal(e),void await this._stopPromise)}async _stopInternal(e){this._stopError=e;try{await this._startInternalPromise}catch(t){}if(this.transport){try{await this.transport.stop()}catch(t){this._logger.log(A.Error,`HttpConnection.transport.stop() threw error '${t}'.`),this._stopConnection()}this.transport=void 0}else this._logger.log(A.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.")}async _startInternal(e){let t=this.baseUrl;this._accessTokenFactory=this._options.accessTokenFactory,this._httpClient._accessTokenFactory=this._accessTokenFactory;try{if(this._options.skipNegotiation){if(this._options.transport!==Q.WebSockets)throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");this.transport=this._constructTransport(Q.WebSockets),await this._startTransport(t,e)}else{let n=null,r=0;do{if(n=await this._getNegotiationResponse(t),"Disconnecting"===this._connectionState||"Disconnected"===this._connectionState)throw new k("The connection was stopped during negotiation.");if(n.error)throw new Error(n.error);if(n.ProtocolVersion)throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");if(n.url&&(t=n.url),n.accessToken){const e=n.accessToken;this._accessTokenFactory=()=>e,this._httpClient._accessToken=e,this._httpClient._accessTokenFactory=void 0}r++}while(n.url&&r<100);if(100===r&&n.url)throw new Error("Negotiate redirection limit exceeded.");await this._createTransport(t,this._options.transport,n,e)}this.transport instanceof Y&&(this.features.inherentKeepAlive=!0),"Connecting"===this._connectionState&&(this._logger.log(A.Debug,"The HttpConnection connected successfully."),this._connectionState="Connected")}catch(n){return this._logger.log(A.Error,"Failed to start the connection: "+n),this._connectionState="Disconnected",this.transport=void 0,this._stopPromiseResolver(),Promise.reject(n)}}async _getNegotiationResponse(e){const t={},[n,r]=B();t[n]=r;const i=this._resolveNegotiateUrl(e);this._logger.log(A.Debug,`Sending negotiation request: ${i}.`);try{const e=await this._httpClient.post(i,{content:"",headers:{...t,...this._options.headers},timeout:this._options.timeout,withCredentials:this._options.withCredentials});if(200!==e.statusCode)return Promise.reject(new Error(`Unexpected status code returned from negotiate '${e.statusCode}'`));const n=JSON.parse(e.content);return(!n.negotiateVersion||n.negotiateVersion<1)&&(n.connectionToken=n.connectionId),n}catch(o){let e="Failed to complete negotiation with the server: "+o;return o instanceof w&&404===o.statusCode&&(e+=" Either this is not a SignalR endpoint or there is a proxy blocking the connection."),this._logger.log(A.Error,e),Promise.reject(new T(e))}}_createConnectUrl(e,t){return t?e+(-1===e.indexOf("?")?"?":"&")+`id=${t}`:e}async _createTransport(e,t,n,r){let i=this._createConnectUrl(e,n.connectionToken);if(this._isITransport(t))return this._logger.log(A.Debug,"Connection was provided an instance of ITransport, using that directly."),this.transport=t,await this._startTransport(i,r),void(this.connectionId=n.connectionId);const o=[],s=n.availableTransports||[];let a=n;for(const c of s){const n=this._resolveTransportOrError(c,t,r);if(n instanceof Error)o.push(`${c.transport} failed:`),o.push(n);else if(this._isITransport(n)){if(this.transport=n,!a){try{a=await this._getNegotiationResponse(e)}catch(l){return Promise.reject(l)}i=this._createConnectUrl(e,a.connectionToken)}try{return await this._startTransport(i,r),void(this.connectionId=a.connectionId)}catch(l){if(this._logger.log(A.Error,`Failed to start the transport '${c.transport}': ${l}`),a=void 0,o.push(new E(`${c.transport} failed: ${l}`,Q[c.transport])),"Connecting"!==this._connectionState){const e="Failed to select transport before stop() was called.";return this._logger.log(A.Debug,e),Promise.reject(new k(e))}}}}return o.length>0?Promise.reject(new O(`Unable to connect to the server with any of the available transports. ${o.join(" ")}`,o)):Promise.reject(new Error("None of the transports supported by the client are supported by the server."))}_constructTransport(e){switch(e){case Q.WebSockets:if(!this._options.WebSocket)throw new Error("'WebSocket' is not supported in your environment.");return new Z(this._httpClient,this._accessTokenFactory,this._logger,this._options.logMessageContent,this._options.WebSocket,this._options.headers||{});case Q.ServerSentEvents:if(!this._options.EventSource)throw new Error("'EventSource' is not supported in your environment.");return new X(this._httpClient,this._httpClient._accessToken,this._logger,this._options);case Q.LongPolling:return new Y(this._httpClient,this._logger,this._options);default:throw new Error(`Unknown transport: ${e}.`)}}_startTransport(e,t){return this.transport.onreceive=this.onreceive,this.transport.onclose=e=>this._stopConnection(e),this.transport.connect(e,t)}_resolveTransportOrError(e,t,n){const r=Q[e.transport];if(null===r||void 0===r)return this._logger.log(A.Debug,`Skipping transport '${e.transport}' because it is not supported by this client.`),new Error(`Skipping transport '${e.transport}' because it is not supported by this client.`);if(!function(e,t){return!e||0!==(t&e)}(t,r))return this._logger.log(A.Debug,`Skipping transport '${Q[r]}' because it was disabled by the client.`),new C(`'${Q[r]}' is disabled by the client.`,r);if(!(e.transferFormats.map((e=>G[e])).indexOf(n)>=0))return this._logger.log(A.Debug,`Skipping transport '${Q[r]}' because it does not support the requested transfer format '${G[n]}'.`),new Error(`'${Q[r]}' does not support ${G[n]}.`);if(r===Q.WebSockets&&!this._options.WebSocket||r===Q.ServerSentEvents&&!this._options.EventSource)return this._logger.log(A.Debug,`Skipping transport '${Q[r]}' because it is not supported in your environment.'`),new S(`'${Q[r]}' is not supported in your environment.`,r);this._logger.log(A.Debug,`Selecting transport '${Q[r]}'.`);try{return this._constructTransport(r)}catch(i){return i}}_isITransport(e){return e&&"object"===typeof e&&"connect"in e}_stopConnection(e){if(this._logger.log(A.Debug,`HttpConnection.stopConnection(${e}) called while in state ${this._connectionState}.`),this.transport=void 0,e=this._stopError||e,this._stopError=void 0,"Disconnected"!==this._connectionState){if("Connecting"===this._connectionState)throw this._logger.log(A.Warning,`Call to HttpConnection.stopConnection(${e}) was ignored because the connection is still in the connecting state.`),new Error(`HttpConnection.stopConnection(${e}) was called while the connection is still in the connecting state.`);if("Disconnecting"===this._connectionState&&this._stopPromiseResolver(),e?this._logger.log(A.Error,`Connection disconnected with error '${e}'.`):this._logger.log(A.Information,"Connection disconnected."),this._sendQueue&&(this._sendQueue.stop().catch((e=>{this._logger.log(A.Error,`TransportSendQueue.stop() threw error '${e}'.`)})),this._sendQueue=void 0),this.connectionId=void 0,this._connectionState="Disconnected",this._connectionStarted){this._connectionStarted=!1;try{this.onclose&&this.onclose(e)}catch(t){this._logger.log(A.Error,`HttpConnection.onclose(${e}) threw error '${t}'.`)}}}else this._logger.log(A.Debug,`Call to HttpConnection.stopConnection(${e}) was ignored because the connection is already in the disconnected state.`)}_resolveUrl(e){if(0===e.lastIndexOf("https://",0)||0===e.lastIndexOf("http://",0))return e;if(!M.isBrowser)throw new Error(`Cannot resolve '${e}'.`);const t=window.document.createElement("a");return t.href=e,this._logger.log(A.Information,`Normalizing '${e}' to '${t.href}'.`),t.href}_resolveNegotiateUrl(e){const t=e.indexOf("?");let n=e.substring(0,-1===t?e.length:t);return"/"!==n[n.length-1]&&(n+="/"),n+="negotiate",n+=-1===t?"":e.substring(t),-1===n.indexOf("negotiateVersion")&&(n+=-1===t?"?":"&",n+="negotiateVersion="+this._negotiateVersion),n}}class te{constructor(e){this._transport=e,this._buffer=[],this._executing=!0,this._sendBufferedData=new ne,this._transportResult=new ne,this._sendLoopPromise=this._sendLoop()}send(e){return this._bufferData(e),this._transportResult||(this._transportResult=new ne),this._transportResult.promise}stop(){return this._executing=!1,this._sendBufferedData.resolve(),this._sendLoopPromise}_bufferData(e){if(this._buffer.length&&typeof this._buffer[0]!==typeof e)throw new Error(`Expected data to be of type ${typeof this._buffer} but was of type ${typeof e}`);this._buffer.push(e),this._sendBufferedData.resolve()}async _sendLoop(){for(;;){if(await this._sendBufferedData.promise,!this._executing){this._transportResult&&this._transportResult.reject("Connection stopped.");break}this._sendBufferedData=new ne;const t=this._transportResult;this._transportResult=void 0;const n="string"===typeof this._buffer[0]?this._buffer.join(""):te._concatBuffers(this._buffer);this._buffer.length=0;try{await this._transport.send(n),t.resolve()}catch(e){t.reject(e)}}}static _concatBuffers(e){const t=e.map((e=>e.byteLength)).reduce(((e,t)=>e+t)),n=new Uint8Array(t);let r=0;for(const i of e)n.set(new Uint8Array(i),r),r+=i.byteLength;return n.buffer}}class ne{constructor(){this.promise=new Promise(((e,t)=>[this._resolver,this._rejecter]=[e,t]))}resolve(){this._resolver()}reject(e){this._rejecter(e)}}class re{static write(e){return`${e}${re.RecordSeparator}`}static parse(e){if(e[e.length-1]!==re.RecordSeparator)throw new Error("Message is incomplete.");const t=e.split(re.RecordSeparator);return t.pop(),t}}re.RecordSeparatorCode=30,re.RecordSeparator=String.fromCharCode(re.RecordSeparatorCode);class ie{writeHandshakeRequest(e){return re.write(JSON.stringify(e))}parseHandshakeResponse(e){let t,n;if(R(e)){const r=new Uint8Array(e),i=r.indexOf(re.RecordSeparatorCode);if(-1===i)throw new Error("Message is incomplete.");const o=i+1;t=String.fromCharCode.apply(null,Array.prototype.slice.call(r.slice(0,o))),n=r.byteLength>o?r.slice(o).buffer:null}else{const r=e,i=r.indexOf(re.RecordSeparator);if(-1===i)throw new Error("Message is incomplete.");const o=i+1;t=r.substring(0,o),n=r.length>o?r.substring(o):null}const r=re.parse(t),i=JSON.parse(r[0]);if(i.type)throw new Error("Expected a handshake response from the server.");return[n,i]}}var oe;!function(e){e[e.Invocation=1]="Invocation",e[e.StreamItem=2]="StreamItem",e[e.Completion=3]="Completion",e[e.StreamInvocation=4]="StreamInvocation",e[e.CancelInvocation=5]="CancelInvocation",e[e.Ping=6]="Ping",e[e.Close=7]="Close"}(oe||(oe={}));class se{constructor(){this.observers=[]}next(e){for(const t of this.observers)t.next(e)}error(e){for(const t of this.observers)t.error&&t.error(e)}complete(){for(const e of this.observers)e.complete&&e.complete()}subscribe(e){return this.observers.push(e),new D(this,e)}}var ae;!function(e){e.Disconnected="Disconnected",e.Connecting="Connecting",e.Connected="Connected",e.Disconnecting="Disconnecting",e.Reconnecting="Reconnecting"}(ae||(ae={}));class le{constructor(e,t,n,r){this._nextKeepAlive=0,this._freezeEventListener=()=>{this._logger.log(A.Warning,"The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://docs.microsoft.com/aspnet/core/signalr/javascript-client#bsleep")},N.isRequired(e,"connection"),N.isRequired(t,"logger"),N.isRequired(n,"protocol"),this.serverTimeoutInMilliseconds=3e4,this.keepAliveIntervalInMilliseconds=15e3,this._logger=t,this._protocol=n,this.connection=e,this._reconnectPolicy=r,this._handshakeProtocol=new ie,this.connection.onreceive=e=>this._processIncomingData(e),this.connection.onclose=e=>this._connectionClosed(e),this._callbacks={},this._methods={},this._closedCallbacks=[],this._reconnectingCallbacks=[],this._reconnectedCallbacks=[],this._invocationId=0,this._receivedHandshakeResponse=!1,this._connectionState=ae.Disconnected,this._connectionStarted=!1,this._cachedPingMessage=this._protocol.writeMessage({type:oe.Ping})}static create(e,t,n,r){return new le(e,t,n,r)}get state(){return this._connectionState}get connectionId(){return this.connection&&this.connection.connectionId||null}get baseUrl(){return this.connection.baseUrl||""}set baseUrl(e){if(this._connectionState!==ae.Disconnected&&this._connectionState!==ae.Reconnecting)throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!e)throw new Error("The HubConnection url must be a valid url.");this.connection.baseUrl=e}start(){return this._startPromise=this._startWithStateTransitions(),this._startPromise}async _startWithStateTransitions(){if(this._connectionState!==ae.Disconnected)return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));this._connectionState=ae.Connecting,this._logger.log(A.Debug,"Starting HubConnection.");try{await this._startInternal(),M.isBrowser&&window.document.addEventListener("freeze",this._freezeEventListener),this._connectionState=ae.Connected,this._connectionStarted=!0,this._logger.log(A.Debug,"HubConnection connected successfully.")}catch(e){return this._connectionState=ae.Disconnected,this._logger.log(A.Debug,`HubConnection failed to start successfully because of error '${e}'.`),Promise.reject(e)}}async _startInternal(){this._stopDuringStartError=void 0,this._receivedHandshakeResponse=!1;const e=new Promise(((e,t)=>{this._handshakeResolver=e,this._handshakeRejecter=t}));await this.connection.start(this._protocol.transferFormat);try{const t={protocol:this._protocol.name,version:this._protocol.version};if(this._logger.log(A.Debug,"Sending handshake request."),await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(t)),this._logger.log(A.Information,`Using HubProtocol '${this._protocol.name}'.`),this._cleanupTimeout(),this._resetTimeoutPeriod(),this._resetKeepAliveInterval(),await e,this._stopDuringStartError)throw this._stopDuringStartError;this.connection.features.inherentKeepAlive||await this._sendMessage(this._cachedPingMessage)}catch(t){throw this._logger.log(A.Debug,`Hub handshake failed with error '${t}' during start(). Stopping HubConnection.`),this._cleanupTimeout(),this._cleanupPingTimer(),await this.connection.stop(t),t}}async stop(){const e=this._startPromise;this._stopPromise=this._stopInternal(),await this._stopPromise;try{await e}catch(t){}}_stopInternal(e){return this._connectionState===ae.Disconnected?(this._logger.log(A.Debug,`Call to HubConnection.stop(${e}) ignored because it is already in the disconnected state.`),Promise.resolve()):this._connectionState===ae.Disconnecting?(this._logger.log(A.Debug,`Call to HttpConnection.stop(${e}) ignored because the connection is already in the disconnecting state.`),this._stopPromise):(this._connectionState=ae.Disconnecting,this._logger.log(A.Debug,"Stopping HubConnection."),this._reconnectDelayHandle?(this._logger.log(A.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this._reconnectDelayHandle),this._reconnectDelayHandle=void 0,this._completeClose(),Promise.resolve()):(this._cleanupTimeout(),this._cleanupPingTimer(),this._stopDuringStartError=e||new k("The connection was stopped before the hub handshake could complete."),this.connection.stop(e)))}stream(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{const e=this._createCancelInvocation(s.invocationId);return delete this._callbacks[s.invocationId],a.then((()=>this._sendWithProtocol(e)))},this._callbacks[s.invocationId]=(e,t)=>{t?l.error(t):e&&(e.type===oe.Completion?e.error?l.error(new Error(e.error)):l.complete():l.next(e.item))},a=this._sendWithProtocol(s).catch((e=>{l.error(e),delete this._callbacks[s.invocationId]})),this._launchStreams(i,a),l}_sendMessage(e){return this._resetKeepAliveInterval(),this.connection.send(e)}_sendWithProtocol(e){return this._sendMessage(this._protocol.writeMessage(e))}send(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r1?t-1:0),r=1;r{this._callbacks[s.invocationId]=(n,r)=>{r?t(r):n&&(n.type===oe.Completion?n.error?t(new Error(n.error)):e(n.result):t(new Error(`Unexpected message type: ${n.type}`)))};const n=this._sendWithProtocol(s).catch((e=>{t(e),delete this._callbacks[s.invocationId]}));this._launchStreams(i,n)}))}on(e,t){e&&t&&(e=e.toLowerCase(),this._methods[e]||(this._methods[e]=[]),-1===this._methods[e].indexOf(t)&&this._methods[e].push(t))}off(e,t){if(!e)return;e=e.toLowerCase();const n=this._methods[e];if(n)if(t){const r=n.indexOf(t);-1!==r&&(n.splice(r,1),0===n.length&&delete this._methods[e])}else delete this._methods[e]}onclose(e){e&&this._closedCallbacks.push(e)}onreconnecting(e){e&&this._reconnectingCallbacks.push(e)}onreconnected(e){e&&this._reconnectedCallbacks.push(e)}_processIncomingData(e){if(this._cleanupTimeout(),this._receivedHandshakeResponse||(e=this._processHandshakeResponse(e),this._receivedHandshakeResponse=!0),e){const n=this._protocol.parseMessages(e,this._logger);for(const e of n)switch(e.type){case oe.Invocation:this._invokeClientMethod(e);break;case oe.StreamItem:case oe.Completion:{const n=this._callbacks[e.invocationId];if(n){e.type===oe.Completion&&delete this._callbacks[e.invocationId];try{n(e)}catch(t){this._logger.log(A.Error,`Stream callback threw error: ${U(t)}`)}}break}case oe.Ping:break;case oe.Close:{this._logger.log(A.Information,"Close message received from server.");const t=e.error?new Error("Server returned an error on close: "+e.error):void 0;!0===e.allowReconnect?this.connection.stop(t):this._stopPromise=this._stopInternal(t);break}default:this._logger.log(A.Warning,`Invalid message type: ${e.type}.`)}}this._resetTimeoutPeriod()}_processHandshakeResponse(e){let t,n;try{[n,t]=this._handshakeProtocol.parseHandshakeResponse(e)}catch(r){const e="Error parsing handshake response: "+r;this._logger.log(A.Error,e);const t=new Error(e);throw this._handshakeRejecter(t),t}if(t.error){const e="Server returned handshake error: "+t.error;this._logger.log(A.Error,e);const n=new Error(e);throw this._handshakeRejecter(n),n}return this._logger.log(A.Debug,"Server handshake complete."),this._handshakeResolver(),n}_resetKeepAliveInterval(){this.connection.features.inherentKeepAlive||(this._nextKeepAlive=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this._cleanupPingTimer())}_resetTimeoutPeriod(){if((!this.connection.features||!this.connection.features.inherentKeepAlive)&&(this._timeoutHandle=setTimeout((()=>this.serverTimeout()),this.serverTimeoutInMilliseconds),void 0===this._pingServerHandle)){let e=this._nextKeepAlive-(new Date).getTime();e<0&&(e=0),this._pingServerHandle=setTimeout((async()=>{if(this._connectionState===ae.Connected)try{await this._sendMessage(this._cachedPingMessage)}catch{this._cleanupPingTimer()}}),e)}}serverTimeout(){this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."))}async _invokeClientMethod(e){const t=e.target.toLowerCase(),n=this._methods[t];if(!n)return this._logger.log(A.Warning,`No client method with the name '${t}' found.`),void(e.invocationId&&(this._logger.log(A.Warning,`No result given for '${t}' method and invocation ID '${e.invocationId}'.`),await this._sendWithProtocol(this._createCompletionMessage(e.invocationId,"Client didn't provide a result.",null))));const r=n.slice(),i=!!e.invocationId;let o,s,a;for(const c of r)try{const n=o;o=await c.apply(this,e.arguments),i&&o&&n&&(this._logger.log(A.Error,`Multiple results provided for '${t}'. Sending error to server.`),a=this._createCompletionMessage(e.invocationId,"Client provided multiple results.",null)),s=void 0}catch(l){s=l,this._logger.log(A.Error,`A callback for the method '${t}' threw error '${l}'.`)}a?await this._sendWithProtocol(a):i?(s?a=this._createCompletionMessage(e.invocationId,`${s}`,null):void 0!==o?a=this._createCompletionMessage(e.invocationId,null,o):(this._logger.log(A.Warning,`No result given for '${t}' method and invocation ID '${e.invocationId}'.`),a=this._createCompletionMessage(e.invocationId,"Client didn't provide a result.",null)),await this._sendWithProtocol(a)):o&&this._logger.log(A.Error,`Result given for '${t}' method but server is not expecting a result.`)}_connectionClosed(e){this._logger.log(A.Debug,`HubConnection.connectionClosed(${e}) called while in state ${this._connectionState}.`),this._stopDuringStartError=this._stopDuringStartError||e||new k("The underlying connection was closed before the hub handshake could complete."),this._handshakeResolver&&this._handshakeResolver(),this._cancelCallbacksWithError(e||new Error("Invocation canceled due to the underlying connection being closed.")),this._cleanupTimeout(),this._cleanupPingTimer(),this._connectionState===ae.Disconnecting?this._completeClose(e):this._connectionState===ae.Connected&&this._reconnectPolicy?this._reconnect(e):this._connectionState===ae.Connected&&this._completeClose(e)}_completeClose(e){if(this._connectionStarted){this._connectionState=ae.Disconnected,this._connectionStarted=!1,M.isBrowser&&window.document.removeEventListener("freeze",this._freezeEventListener);try{this._closedCallbacks.forEach((t=>t.apply(this,[e])))}catch(t){this._logger.log(A.Error,`An onclose callback called with error '${e}' threw error '${t}'.`)}}}async _reconnect(e){const t=Date.now();let n=0,r=void 0!==e?e:new Error("Attempting to reconnect due to a unknown error."),i=this._getNextRetryDelay(n++,0,r);if(null===i)return this._logger.log(A.Debug,"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),void this._completeClose(e);if(this._connectionState=ae.Reconnecting,e?this._logger.log(A.Information,`Connection reconnecting because of error '${e}'.`):this._logger.log(A.Information,"Connection reconnecting."),0!==this._reconnectingCallbacks.length){try{this._reconnectingCallbacks.forEach((t=>t.apply(this,[e])))}catch(o){this._logger.log(A.Error,`An onreconnecting callback called with error '${e}' threw error '${o}'.`)}if(this._connectionState!==ae.Reconnecting)return void this._logger.log(A.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting.")}for(;null!==i;){if(this._logger.log(A.Information,`Reconnect attempt number ${n} will start in ${i} ms.`),await new Promise((e=>{this._reconnectDelayHandle=setTimeout(e,i)})),this._reconnectDelayHandle=void 0,this._connectionState!==ae.Reconnecting)return void this._logger.log(A.Debug,"Connection left the reconnecting state during reconnect delay. Done reconnecting.");try{if(await this._startInternal(),this._connectionState=ae.Connected,this._logger.log(A.Information,"HubConnection reconnected successfully."),0!==this._reconnectedCallbacks.length)try{this._reconnectedCallbacks.forEach((e=>e.apply(this,[this.connection.connectionId])))}catch(o){this._logger.log(A.Error,`An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${o}'.`)}return}catch(o){if(this._logger.log(A.Information,`Reconnect attempt failed because of error '${o}'.`),this._connectionState!==ae.Reconnecting)return this._logger.log(A.Debug,`Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`),void(this._connectionState===ae.Disconnecting&&this._completeClose());r=o instanceof Error?o:new Error(o.toString()),i=this._getNextRetryDelay(n++,Date.now()-t,r)}}this._logger.log(A.Information,`Reconnect retries have been exhausted after ${Date.now()-t} ms and ${n} failed attempts. Connection disconnecting.`),this._completeClose()}_getNextRetryDelay(e,t,n){try{return this._reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:t,previousRetryCount:e,retryReason:n})}catch(r){return this._logger.log(A.Error,`IRetryPolicy.nextRetryDelayInMilliseconds(${e}, ${t}) threw error '${r}'.`),null}}_cancelCallbacksWithError(e){const t=this._callbacks;this._callbacks={},Object.keys(t).forEach((n=>{const r=t[n];try{r(null,e)}catch(i){this._logger.log(A.Error,`Stream 'error' callback called with '${e}' threw error: ${U(i)}`)}}))}_cleanupPingTimer(){this._pingServerHandle&&(clearTimeout(this._pingServerHandle),this._pingServerHandle=void 0)}_cleanupTimeout(){this._timeoutHandle&&clearTimeout(this._timeoutHandle)}_createInvocation(e,t,n,r){if(n)return 0!==r.length?{arguments:t,streamIds:r,target:e,type:oe.Invocation}:{arguments:t,target:e,type:oe.Invocation};{const n=this._invocationId;return this._invocationId++,0!==r.length?{arguments:t,invocationId:n.toString(),streamIds:r,target:e,type:oe.Invocation}:{arguments:t,invocationId:n.toString(),target:e,type:oe.Invocation}}}_launchStreams(e,t){if(0!==e.length){t||(t=Promise.resolve());for(const n in e)e[n].subscribe({complete:()=>{t=t.then((()=>this._sendWithProtocol(this._createCompletionMessage(n))))},error:e=>{let r;r=e instanceof Error?e.message:e&&e.toString?e.toString():"Unknown error",t=t.then((()=>this._sendWithProtocol(this._createCompletionMessage(n,r))))},next:e=>{t=t.then((()=>this._sendWithProtocol(this._createStreamItemMessage(n,e))))}})}}_replaceStreamingParams(e){const t=[],n=[];for(let r=0;r{let{url:t}=e;return(new he).withUrl(t,{accessTokenFactory:f()?void 0:u,withCredentials:!0}).withAutomaticReconnect([0,100,250,500,1e3,2e3,3e3,5e3,5e3,5e3,5e3,5e3]).withHubProtocol(new ce).configureLogging(A.Warning).build()};var fe=n(854),pe=n.n(fe);pe().defaults.baseURL=r;const me=pe().create({withCredentials:!0});me.interceptors.request.use((e=>{const t=u();return e.headers["Content-Type"]="application/json",!f()&&t&&(e.headers.Authorization="Bearer "+t),e})),me.interceptors.response.use((e=>e),(e=>(401!==e.response.status||["/session","/server","/application"].includes(e.response.config.url)||(console.debug("received 401 from api route, logging out"),d(),window.location.reload(!0)),Promise.reject(e))));const ge=me,ve=()=>{const e=u();return void 0!==e&&null!==e&&e!==s},ye=()=>{console.debug("removing token from local and session storage"),d()},be=async()=>{try{return await ge.get("/session"),!0}catch(e){if(401===e.response.status)return console.error("session error; not logged in or session has expired"),ye(),!1;throw e}};var we=n(5043);const xe=we.createContext(),ke=e=>{let{username:t}=e;return ge.get(`/users/${encodeURIComponent(t)}/info`)},Se=e=>{let{username:t}=e;return ge.get(`/users/${encodeURIComponent(t)}/status`)},Ce=e=>{let{username:t}=e;return ge.get(`/users/${encodeURIComponent(t)}/endpoint`)};function Ee(){return Ee=Object.assign?Object.assign.bind():function(e){for(var t=1;t-1};const Ke=function(e,t){var n=this.__data__,r=$e(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};function Qe(e){var t=-1,n=null==e?0:e.length;for(this.clear();++ta))return!1;var c=o.get(e),u=o.get(t);if(c&&u)return c==t&&u==e;var h=-1,d=!0,f=2&n?new tn:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991};var Rn={};Rn["[object Float32Array]"]=Rn["[object Float64Array]"]=Rn["[object Int8Array]"]=Rn["[object Int16Array]"]=Rn["[object Int32Array]"]=Rn["[object Uint8Array]"]=Rn["[object Uint8ClampedArray]"]=Rn["[object Uint16Array]"]=Rn["[object Uint32Array]"]=!0,Rn["[object Arguments]"]=Rn["[object Array]"]=Rn["[object ArrayBuffer]"]=Rn["[object Boolean]"]=Rn["[object DataView]"]=Rn["[object Date]"]=Rn["[object Error]"]=Rn["[object Function]"]=Rn["[object Map]"]=Rn["[object Number]"]=Rn["[object Object]"]=Rn["[object RegExp]"]=Rn["[object Set]"]=Rn["[object String]"]=Rn["[object WeakMap]"]=!1;const In=function(e){return wn(e)&&jn(e.length)&&!!Rn[dt(e)]};const Dn=function(e){return function(t){return e(t)}};var Ln="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bn=Ln&&"object"==typeof module&&module&&!module.nodeType&&module,Fn=Bn&&Bn.exports===Ln&&et.process,zn=function(){try{var e=Bn&&Bn.require&&Bn.require("util").types;return e||Fn&&Fn.binding&&Fn.binding("util")}catch(t){}}();var Hn=zn&&zn.isTypedArray;const $n=Hn?Dn(Hn):In;var Un=Object.prototype.hasOwnProperty;const Wn=function(e,t){var n=dn(e),r=!n&&En(e),i=!n&&!r&&Pn(e),o=!n&&!r&&!i&&$n(e),s=n||r||i||o,a=s?bn(e.length,String):[],l=a.length;for(var c in e)!t&&!Un.call(e,c)||s&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Mn(c,l))||a.push(c);return a};var Vn=Object.prototype;const qn=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Vn)};const Kn=function(e,t){return function(n){return e(t(n))}};const Qn=Kn(Object.keys,Object);var Gn=Object.prototype.hasOwnProperty;const Jn=function(e){if(!qn(e))return Qn(e);var t=[];for(var n in Object(e))Gn.call(e,n)&&"constructor"!=n&&t.push(n);return t};const Yn=function(e){return null!=e&&jn(e.length)&&!pt(e)};const Xn=function(e){return Yn(e)?Wn(e):Jn(e)};const Zn=function(e){return fn(e,Xn,yn)};var er=Object.prototype.hasOwnProperty;const tr=function(e,t,n,r,i,o){var s=1&n,a=Zn(e),l=a.length;if(l!=Zn(t).length&&!s)return!1;for(var c=l;c--;){var u=a[c];if(!(s?u in t:er.call(t,u)))return!1}var h=o.get(e),d=o.get(t);if(h&&d)return h==t&&d==e;var f=!0;o.set(e,t),o.set(t,e);for(var p=s;++ci?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Pi);const ji=function(e,t){return Mi(Ti(e,t,Zr),e+"")};const Ri=ji(Ci);const Ii=function(e){return null==e};const Di=function(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o-1};const Hi=function(e,t,n){for(var r=-1,i=null==e?0:e.length;++r=200){var c=t?null:Wi(e);if(c)return an(c);s=!1,i=nn,l=new tn}else l=t?[]:a;e:for(;++r-1:!!i&&Fi(e,t,n)>-1};const Po=function(e,t){for(var n=-1,r=null==e?0:e.length;++n0?we.cloneElement(i,r):i;return we.createElement(o,{innerRef:n},s)},Yo=n(3090),Xo=n.n(Yo),Zo=Math.max,es=Math.min;const ts=function(e,t,n){return e>=es(t,n)&&e1?o-1:0),a=1;a1?a-1:0),c=1;c1?o-1:0),a=1;a1?s-1:0),l=1;l1?s-1:0),l=1;l{let{caption:t,icon:n,size:r,...i}=e;const o="small"===r?"placeholder-segment-small":"placeholder-segment";return(0,Ps.jsx)(vi,{basic:!0,className:o,placeholder:!0,...i,children:(0,Ps.jsxs)(_s,{icon:!0,children:[(0,Ps.jsx)(fo,{name:n}),t]})})},Ms=e=>{let{username:t,files:n=[]}=e;return ge.post(`/transfers/downloads/${encodeURIComponent(t)}`,n)},js=e=>{let{direction:t,username:n,id:r,remove:i=!1}=e;return ge.delete(`/transfers/${t}s/${encodeURIComponent(n)}/${encodeURIComponent(r)}?remove=${i}`)},Rs=e=>e.includes("Completed")&&"Completed, Succeeded"!==e,Is=e=>["InProgress","Requested","Queued","Queued, Remotely","Queued, Locally","Initializing"].find((t=>t===e)),Ds=e=>{if(void 0===e)return"";const t=new Date(1970,0,1);return t.setSeconds(e),e>=3600?t.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/u,"$1"):t.toTimeString().replace(/.*(\d{2}:\d{2}).*/u,"$1")},Ls=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(0===e)return"0 B";const n=t<0?0:t,r=Math.floor(Math.log(e)/Math.log(1024));return Number.parseFloat((e/1024**r).toFixed(n))+" "+["B","KB","MB","GB","TB","PB","EB","ZB","YB"][r]},Bs=e=>new Date(e).toLocaleString(),Fs=e=>e.split("\\").pop().split("/").pop(),zs=e=>{let{bitRate:t,isVariableBitRate:n,bitDepth:r,sampleRate:i}=e;return Boolean(i)&&Boolean(r)?`${r}/${i/1e3}kHz`:n?`${t} Kbps, VBR`:t?`${t} Kbps`:""};const Hs=function(e,t){var n=-1,r=Yn(e)?Array(e.length):[];return ai(e,(function(e,i,o){r[++n]=t(e,i,o)})),r};const $s=function(e,t){return(dn(e)?zr:Hs)(e,ri(t,3))};function Us(e){var t=e.children,n=e.className,r=e.content,i=Oe(n,"description"),o=Le(Us,e),s=Be(Us,e);return we.createElement(s,Ee({},o,{className:i}),hi(t)?r:t)}Us.handledProps=["as","children","className","content"],Us.propTypes={},Us.create=io(Us,(function(e){return{content:e}}));const Ws=Us;function Vs(e){var t=e.children,n=e.className,r=e.content,i=Oe("header",n),o=Le(Vs,e),s=Be(Vs,e);return we.createElement(s,Ee({},o,{className:i}),hi(t)?r:t)}Vs.handledProps=["as","children","className","content"],Vs.propTypes={},Vs.create=io(Vs,(function(e){return{content:e}}));const qs=Vs;function Ks(e){var t=e.children,n=e.className,r=e.content,i=e.description,o=e.floated,s=e.header,a=e.verticalAlign,l=Oe(Ne(o,"floated"),Ie(a),"content",n),c=Le(Ks,e),u=Be(Ks,e);return hi(t)?we.createElement(u,Ee({},c,{className:l}),qs.create(s),Ws.create(i),r):we.createElement(u,Ee({},c,{className:l}),t)}Ks.handledProps=["as","children","className","content","description","floated","header","verticalAlign"],Ks.propTypes={},Ks.create=io(Ks,(function(e){return{content:e}}));const Qs=Ks;function Gs(e){var t=e.className,n=e.verticalAlign,r=Oe(Ie(n),t),i=Le(Gs,e);return we.createElement(fo,Ee({},i,{className:r}))}Gs.handledProps=["className","verticalAlign"],Gs.propTypes={},Gs.create=io(Gs,(function(e){return{name:e}}));const Js=Gs;var Ys=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i{let{directoryName:t,disabled:n,files:r,footer:i,locked:o,onClose:s,onSelectionChange:a}=e;const[l,c]=(0,we.useState)(!1);return(0,Ps.jsxs)("div",{style:{opacity:o?.5:1},children:[(0,Ps.jsx)(_s,{className:"filelist-header",size:"small",children:(0,Ps.jsxs)("div",{children:[(0,Ps.jsx)(fo,{link:!o,name:o?"lock":l?"folder":"folder open",onClick:()=>!o&&c(!l),size:"large"}),t,Boolean(s)&&(0,Ps.jsx)(fo,{className:"close-button",color:"red",link:!0,name:"close",onClick:()=>s()})]})}),!l&&r&&r.length>0&&(0,Ps.jsx)(na,{children:(0,Ps.jsx)(na.Item,{children:(0,Ps.jsxs)(ga,{children:[(0,Ps.jsx)(ga.Header,{children:(0,Ps.jsxs)(ga.Row,{children:[(0,Ps.jsx)(ga.HeaderCell,{className:"filelist-selector",children:(0,Ps.jsx)(ka,{checked:0===r.filter((e=>!e.selected)).length,disabled:n,fitted:!0,onChange:(e,t)=>r.map((e=>a(e,t.checked)))})}),(0,Ps.jsx)(ga.HeaderCell,{className:"filelist-filename",children:"File"}),(0,Ps.jsx)(ga.HeaderCell,{className:"filelist-size",children:"Size"}),(0,Ps.jsx)(ga.HeaderCell,{className:"filelist-attributes",children:"Attributes"}),(0,Ps.jsx)(ga.HeaderCell,{className:"filelist-length",children:"Length"})]})}),(0,Ps.jsx)(ga.Body,{children:r.sort(((e,t)=>e.filename>t.filename?1:-1)).map((e=>(0,Ps.jsxs)(ga.Row,{children:[(0,Ps.jsx)(ga.Cell,{className:"filelist-selector",children:(0,Ps.jsx)(ka,{checked:e.selected,disabled:n,fitted:!0,onChange:(t,n)=>a(e,n.checked)})}),(0,Ps.jsxs)(ga.Cell,{className:"filelist-filename",children:[o?(0,Ps.jsx)(fo,{name:"lock"}):"",Fs(e.filename)]}),(0,Ps.jsx)(ga.Cell,{className:"filelist-size",children:Ls(e.size)}),(0,Ps.jsx)(ga.Cell,{className:"filelist-attributes",children:zs(e)}),(0,Ps.jsx)(ga.Cell,{className:"filelist-length",children:Ds(e.length)})]},e.filename)))}),i&&(0,Ps.jsx)(ga.Footer,{fullWidth:!0,children:(0,Ps.jsx)(ga.Row,{children:(0,Ps.jsx)(ga.HeaderCell,{colSpan:"5",children:i})})})]})})})]})};function Ca(e){var t=e.children,n=e.className,r=e.content,i=e.textAlign,o=Oe(Re(i),"description",n),s=Le(Ca,e),a=Be(Ca,e);return we.createElement(a,Ee({},s,{className:o}),hi(t)?r:t)}Ca.handledProps=["as","children","className","content","textAlign"],Ca.propTypes={};const Ea=Ca;function Ta(e){var t=e.children,n=e.className,r=e.content,i=e.textAlign,o=Oe(Re(i),"header",n),s=Le(Ta,e),a=Be(Ta,e);return we.createElement(a,Ee({},s,{className:o}),hi(t)?r:t)}Ta.handledProps=["as","children","className","content","textAlign"],Ta.propTypes={};const Oa=Ta;function Aa(e){var t=e.children,n=e.className,r=e.content,i=e.textAlign,o=Oe(Re(i),"meta",n),s=Le(Aa,e),a=Be(Aa,e);return we.createElement(a,Ee({},s,{className:o}),hi(t)?r:t)}Aa.handledProps=["as","children","className","content","textAlign"],Aa.propTypes={};const _a=Aa;function Pa(e){var t=e.children,n=e.className,r=e.content,i=e.description,o=e.extra,s=e.header,a=e.meta,l=e.textAlign,c=Oe(Pe(o,"extra"),Re(l),"content",n),u=Le(Pa,e),h=Be(Pa,e);return hi(t)?hi(r)?we.createElement(h,Ee({},u,{className:c}),ro(Oa,(function(e){return{content:e}}),s,{autoGenerateKey:!1}),ro(_a,(function(e){return{content:e}}),a,{autoGenerateKey:!1}),ro(Ea,(function(e){return{content:e}}),i,{autoGenerateKey:!1})):we.createElement(h,Ee({},u,{className:c}),r):we.createElement(h,Ee({},u,{className:c}),t)}Pa.handledProps=["as","children","className","content","description","extra","header","meta","textAlign"],Pa.propTypes={};const Na=Pa;function Ma(e){var t=e.centered,n=e.children,r=e.className,i=e.content,o=e.doubling,s=e.items,a=e.itemsPerRow,l=e.stackable,c=e.textAlign,u=Oe("ui",Pe(t,"centered"),Pe(o,"doubling"),Pe(l,"stackable"),Re(c),De(a),"cards",r),h=Le(Ma,e),d=Be(Ma,e);if(!hi(n))return we.createElement(d,Ee({},h,{className:u}),n);if(!hi(i))return we.createElement(d,Ee({},h,{className:u}),i);var f=$s(s,(function(e){var t,n=null!=(t=e.key)?t:[e.header,e.description].join("-");return we.createElement(Ra,Ee({key:n},e))}));return we.createElement(d,Ee({},h,{className:u}),f)}Ma.handledProps=["as","centered","children","className","content","doubling","items","itemsPerRow","stackable","textAlign"],Ma.propTypes={};const ja=Ma;var Ra=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i{e.selected=t,this.setState((e=>({downloadError:"",downloadRequest:void 0,tree:e.tree})))},this.download=(e,t)=>{this.setState({downloadRequest:"inProgress"},(async()=>{try{const n=(t||[]).map((e=>{let{filename:t,size:n}=e;return{filename:t,size:n}}));await Ms({files:n,username:e}),this.setState({downloadRequest:"complete"})}catch(n){this.setState({downloadError:n.response,downloadRequest:"error"})}}))},this.state={...Ua,files:this.props.files.map((e=>({selected:!1,...e})))}}componentDidUpdate(e){this.props.name!==e.name&&this.setState({files:this.props.files.map((e=>({selected:!1,...e})))})}render(){const{locked:e,marginTop:t,name:n,onClose:r,username:i}=this.props,{downloadError:o,downloadRequest:s,files:a}=this.state,l=a.filter((e=>e.selected)),c=Ls(l.reduce(((e,t)=>e+t.size),0));return(0,Ps.jsxs)(Ra,{className:"result-card",raised:!0,children:[(0,Ps.jsx)(Ra.Content,{children:(0,Ps.jsx)("div",{style:{marginTop:t||0},children:(0,Ps.jsx)(Sa,{directoryName:n,disabled:"inProgress"===s,files:a,locked:e,onClose:r,onSelectionChange:this.handleFileSelectionChange})})}),l.length>0&&(0,Ps.jsx)(Ra.Content,{extra:!0,children:(0,Ps.jsxs)("span",{children:[(0,Ps.jsx)($a,{color:"green",content:"Download",disabled:"inProgress"===s,icon:"download",label:{as:"a",basic:!1,content:`${l.length} file${1===l.length?"":"s"}, ${c}`},labelPosition:"right",onClick:()=>this.download(i,l)}),"inProgress"===s&&(0,Ps.jsx)(fo,{loading:!0,name:"circle notch",size:"large"}),"complete"===s&&(0,Ps.jsx)(fo,{color:"green",name:"checkmark",size:"large"}),"error"===s&&(0,Ps.jsxs)("span",{children:[(0,Ps.jsx)(fo,{color:"red",name:"x",size:"large"}),(0,Ps.jsx)(bs,{children:o.data+` (HTTP ${o.status} ${o.statusText})`})]})]})})]})}}const Va=Wa,qa=(e,t,n)=>(e||[]).map((e=>{const r=e.name===t;return(0,Ps.jsx)(na,{className:"browse-folderlist-list",children:(0,Ps.jsxs)(na.Item,{children:[(0,Ps.jsx)(na.Icon,{className:"browse-folderlist-icon"+(r?" selected":"")+(e.locked?" locked":""),name:!0===e.locked?"lock":r?"folder open":"folder"}),(0,Ps.jsxs)(na.Content,{children:[(0,Ps.jsx)(na.Header,{className:"browse-folderlist-header"+(r?" selected":"")+(e.locked?" locked":""),onClick:t=>n(t,e),children:e.name.split("\\").pop().split("/").pop()}),(0,Ps.jsx)(na.List,{children:qa(e.children,t,n)})]})]})},e.name)})),Ka=e=>{let{onSelect:t,selectedDirectoryName:n,tree:r}=e;return qa(r,n,t)};var Qa=n(3393),Ga=n(5173),Ja=n.n(Ga);function Ya(e){return"/"===e.charAt(0)}function Xa(e,t){for(var n=t,r=n+1,i=e.length;r=0;u--){var h=i[u];"."===h?Xa(i,u):".."===h?(Xa(i,u),c++):c&&(Xa(i,u),c--)}if(!a)for(;c--;c)i.unshift("..");!a||""===i[0]||i[0]&&Ya(i[0])||i.unshift("");var d=i.join("/");return n&&"/"!==d.substr(-1)&&(d+="/"),d};function el(e){return e.valueOf?e.valueOf():Object.prototype.valueOf.call(e)}const tl=function e(t,n){if(t===n)return!0;if(null==t||null==n)return!1;if(Array.isArray(t))return Array.isArray(n)&&t.length===n.length&&t.every((function(t,r){return e(t,n[r])}));if("object"===typeof t||"object"===typeof n){var r=el(t),i=el(n);return r!==t||i!==n?e(r,i):Object.keys(Object.assign({},t,n)).every((function(r){return e(t[r],n[r])}))}return!1};var nl=!0,rl="Invariant failed";function il(e,t){if(!e){if(nl)throw new Error(rl);var n="function"===typeof t?t():t,r=n?"".concat(rl,": ").concat(n):rl;throw new Error(r)}}function ol(e){return"/"===e.charAt(0)?e:"/"+e}function sl(e){return"/"===e.charAt(0)?e.substr(1):e}function al(e,t){return function(e,t){return 0===e.toLowerCase().indexOf(t.toLowerCase())&&-1!=="/?#".indexOf(e.charAt(t.length))}(e,t)?e.substr(t.length):e}function ll(e){return"/"===e.charAt(e.length-1)?e.slice(0,-1):e}function cl(e){var t=e.pathname,n=e.search,r=e.hash,i=t||"/";return n&&"?"!==n&&(i+="?"===n.charAt(0)?n:"?"+n),r&&"#"!==r&&(i+="#"===r.charAt(0)?r:"#"+r),i}function ul(e,t,n,r){var i;"string"===typeof e?(i=function(e){var t=e||"/",n="",r="",i=t.indexOf("#");-1!==i&&(r=t.substr(i),t=t.substr(0,i));var o=t.indexOf("?");return-1!==o&&(n=t.substr(o),t=t.substr(0,o)),{pathname:t,search:"?"===n?"":n,hash:"#"===r?"":r}}(e),i.state=t):(void 0===(i=Ee({},e)).pathname&&(i.pathname=""),i.search?"?"!==i.search.charAt(0)&&(i.search="?"+i.search):i.search="",i.hash?"#"!==i.hash.charAt(0)&&(i.hash="#"+i.hash):i.hash="",void 0!==t&&void 0===i.state&&(i.state=t));try{i.pathname=decodeURI(i.pathname)}catch(o){throw o instanceof URIError?new URIError('Pathname "'+i.pathname+'" could not be decoded. This is likely caused by an invalid percent-encoding.'):o}return n&&(i.key=n),r?i.pathname?"/"!==i.pathname.charAt(0)&&(i.pathname=Za(i.pathname,r.pathname)):i.pathname=r.pathname:i.pathname||(i.pathname="/"),i}function hl(){var e=null;var t=[];return{setPrompt:function(t){return e=t,function(){e===t&&(e=null)}},confirmTransitionTo:function(t,n,r,i){if(null!=e){var o="function"===typeof e?e(t,n):e;"string"===typeof o?"function"===typeof r?r(o,i):i(!0):i(!1!==o)}else i(!0)},appendListener:function(e){var n=!0;function r(){n&&e.apply(void 0,arguments)}return t.push(r),function(){n=!1,t=t.filter((function(e){return e!==r}))}},notifyListeners:function(){for(var e=arguments.length,n=new Array(e),r=0;r{const e=this.inputtext.inputRef.current.value;this.setState({browseError:void 0,browseState:"pending",username:e},(()=>{(async e=>{let{username:t}=e;return(await ge.get(`/users/${encodeURIComponent(t)}/browse`)).data})({username:e}).then((e=>{let{directories:t}=e;const{lockedDirectories:n}=e;let r;const i=t.length,o=t.reduce(((e,t)=>(r||(t.name.includes("\\")?r="\\":t.name.includes("/")&&(r="/")),e+t.fileCount)),0),s=n.length,a=n.reduce(((e,t)=>e+t.fileCount),0);t=t.concat(n.map((e=>({...e,locked:!0})))),this.setState({info:{directories:i,files:o,lockedDirectories:s,lockedFiles:a},separator:r,tree:this.getDirectoryTree({directories:t,separator:r})})})).then((()=>this.setState({browseError:void 0,browseState:"complete"},(()=>{this.saveState()})))).catch((e=>this.setState({browseError:e,browseState:"error"})))}))},this.clear=()=>{this.setState(lc,(()=>{this.saveState(),this.inputtext.focus()}))},this.keyUp=e=>"Escape"===e.key?this.clear():"",this.saveState=()=>{this.inputtext.inputRef.current.value=this.state.username,this.inputtext.inputRef.current.disabled="idle"!==this.state.browseState;const e=()=>{try{localStorage.setItem("soulseek-example-browse-state",Qa.compress(JSON.stringify(this.state)))}catch(e){console.error(e)}};window.requestIdleCallback?window.requestIdleCallback(e):Promise.resolve().then(e)},this.loadState=()=>{var e;this.setState(!(null!==(e=this.props.location.state)&&void 0!==e&&e.user)&&JSON.parse(Qa.decompress(localStorage.getItem("soulseek-example-browse-state")||""))||lc)},this.fetchStatus=()=>{const{browseState:e,username:t}=this.state;"pending"===e&&(e=>{let{username:t}=e;return ge.get(`/users/${encodeURIComponent(t)}/browse/status`)})({username:t}).then((e=>this.setState({browseStatus:e.data})))},this.getDirectoryTree=e=>{let{directories:t,separator:n}=e;if(0===t.length||void 0===t[0].name)return[];const r=new Map;for(const o of t){const e=o.name.split(n).length;r.has(e)||r.set(e,[]),r.get(e).push(o)}const i=Math.min(...Array.from(r.keys()));return r.get(i).map((e=>this.getChildDirectories(r,e,n,i+1)))},this.getChildDirectories=(e,t,n,r)=>{if(!e.has(r))return{...t,children:[]};const i=e.get(r).filter((e=>e.name.startsWith(t.name)));return{...t,children:i.map((t=>this.getChildDirectories(e,t,n,r+1)))}},this.selectDirectory=e=>{this.setState({selectedDirectory:{...e,children:[]}},(()=>this.saveState()))},this.handleDeselectDirectory=()=>{this.setState({selectedDirectory:lc.selectedDirectory},(()=>this.saveState()))},this.state=lc}componentDidMount(){var e;this.fetchStatus(),this.loadState(),this.setState({interval:window.setInterval(this.fetchStatus,500)},(()=>this.saveState())),null!==(e=this.props.location.state)&&void 0!==e&&e.user&&this.setState({username:this.props.location.state.user},this.browse),document.addEventListener("keyup",this.keyUp,!1)}componentWillUnmount(){clearInterval(this.state.interval),this.setState({interval:void 0}),document.removeEventListener("keyup",this.keyUp,!1)}render(){const{browseError:e,browseState:t,browseStatus:n,info:r,selectedDirectory:i,separator:o,tree:s,username:a}=this.state,{locked:l,name:c}=i,u="pending"===t,h=!(s&&s.length>0),d=(i.files||[]).map((e=>({...e,filename:`${c}${o}${e.filename}`})));return(0,Ps.jsxs)("div",{className:"search-container",children:[(0,Ps.jsxs)(vi,{className:"browse-segment",raised:!0,children:[(0,Ps.jsx)("div",{className:"browse-segment-icon",children:(0,Ps.jsx)(fo,{name:"folder open",size:"big"})}),(0,Ps.jsx)(oc,{action:!u&&("idle"===t?{icon:"search",onClick:this.browse}:{color:"red",icon:"x",onClick:this.clear}),className:"search-input",disabled:u,input:(0,Ps.jsx)("input",{"data-lpignore":"true",placeholder:"Username",type:"search"}),loading:u,onKeyUp:e=>"Enter"===e.key?this.browse():"",placeholder:"Username",ref:e=>this.inputtext=e,size:"big"})]}),u?(0,Ps.jsxs)(ac,{active:!0,className:"search-loader",inline:"centered",size:"big",children:["Downloaded ",Math.round(n.percentComplete||0),"% of Response"]}):(0,Ps.jsx)("div",{children:e?(0,Ps.jsxs)("span",{className:"browse-error",children:["Failed to browse ",a]}):(0,Ps.jsxs)("div",{className:"browse-container",children:[h?(0,Ps.jsx)(Ns,{caption:"No user share to display",icon:"folder open"}):(0,Ps.jsx)(Ra,{className:"browse-tree-card",raised:!0,children:(0,Ps.jsxs)(Ra.Content,{children:[(0,Ps.jsxs)(Ra.Header,{children:[(0,Ps.jsx)(fo,{color:"green",name:"circle"}),a]}),(0,Ps.jsx)(Ra.Meta,{className:"browse-meta",children:(0,Ps.jsxs)("span",{children:[`${r.files+r.lockedFiles} files in ${r.directories+r.lockedDirectories} directories (including ${r.lockedFiles} files in ${r.lockedDirectories} locked directories)`," "]})}),(0,Ps.jsx)(vi,{className:"browse-folderlist",children:(0,Ps.jsx)(Ka,{onSelect:(e,t)=>this.selectDirectory(t),selectedDirectoryName:c,tree:s})})]})}),c&&(0,Ps.jsx)(Va,{files:d,locked:l,marginTop:-20,name:c,onClose:this.handleDeselectDirectory,username:a})]})})]})}}const uc=Zl(cc),hc=async e=>{let{username:t}=e;return(await ge.get(`/conversations/${encodeURIComponent(t)}`)).data};const dc=function(e,t,n){for(var r=-1,i=t.length,o={};++r0&&r(l)?n>1?e(l,n-1,r,i,o):hn(o,l):i||(o[o.length]=l)}return o};const vc=function(e){return(null==e?0:e.length)?gc(e,1):[]};const yc=function(e){return Mi(Ti(e,void 0,vc),e+"")}((function(e,t){return null==e?{}:fc(e,t)}));const bc=function(e,t,n,r){var i=-1,o=null==e?0:e.length;for(r&&o&&(n=e[++i]);++i0&&n.indexOf(e)===t}))):[]}(t),r=function(e,t){return[t.filter((function(t){return-1===e.indexOf(t)})),e.filter((function(e){return-1===t.indexOf(e)}))]}(Rc.get(e)||[],n),i=r[0],o=r[1];e&&(i.forEach((function(t){return e.classList.add(t)})),o.forEach((function(t){return e.classList.remove(t)}))),Rc.set(e,n)},Dc=new function(){var e=this;this.add=function(t,n){if(e.nodes.has(t)){e.nodes.get(t).add(n)}else{var r=new Set;r.add(n),e.nodes.set(t,r)}},this.del=function(t,n){if(e.nodes.has(t)){var r=e.nodes.get(t);1!==r.size?r.delete(n):e.nodes.delete(t)}},this.emit=function(t,n){n(t,e.nodes.get(t))},this.nodes=new Map};function Lc(e){var t=e.blurring,n=e.children,r=e.className,i=e.centered,o=e.content,s=e.inverted,a=e.mountNode,l=e.scrolling,c=we.useRef(),u=Oe("ui",Pe(s,"inverted"),Pe(!i,"top aligned"),"page modals dimmer transition visible active",r),h=Oe("dimmable dimmed",Pe(t,"blurring"),Pe(l,"scrolling")),d=Le(Lc,e),f=Be(Lc,e);return function(e,t){var n=we.useRef(),r=we.useRef(!1);Mc((function(){if(n.current=t,r.current){var i=Uo(e)?e.current:e;Dc.emit(i,Ic)}r.current=!0}),[t]),Mc((function(){var t=Uo(e)?e.current:e;return Dc.add(t,n),Dc.emit(t,Ic),function(){Dc.del(t,n),Dc.emit(t,Ic)}}),[e])}(a,h),we.useEffect((function(){c.current&&c.current.style&&c.current.style.setProperty("display","flex","important")}),[]),we.createElement(Jo,{innerRef:c},we.createElement(f,Ee({},d,{className:u}),hi(n)?o:n))}Lc.handledProps=["as","blurring","centered","children","className","content","inverted","mountNode","scrolling"],Lc.propTypes={},Lc.create=io(Lc,(function(e){return{content:e}}));const Bc=Lc;function Fc(e){var t=e.children,n=e.className,r=e.content,i=Oe("header",n),o=Le(Fc,e),s=Be(Fc,e);return we.createElement(s,Ee({},o,{className:i}),hi(t)?r:t)}Fc.handledProps=["as","children","className","content"],Fc.propTypes={},Fc.create=io(Fc,(function(e){return{content:e}}));const zc=Fc;var Hc=function(e){function t(){for(var n,r=arguments.length,i=new Array(r),o=0;o=200&&(o=nn,s=!1,t=new tn(t));e:for(;++i-1?i[o?t[s]:s]:void 0}};var su=Math.max;const au=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:Eo(n);return i<0&&(i=su(r+i,0)),Di(e,ri(t,3),i)};const lu=ou(au);const cu=function(e,t,n){var r=null==e?0:e.length;return r?(t=n||void 0===t?1:Eo(t),ki(e,0,(t=r-t)<0?0:t)):[]};const uu=ei("length");var hu=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const du=function(e){return hu.test(e)};var fu="\\ud800-\\udfff",pu="["+fu+"]",mu="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",gu="\\ud83c[\\udffb-\\udfff]",vu="[^"+fu+"]",yu="(?:\\ud83c[\\udde6-\\uddff]){2}",bu="[\\ud800-\\udbff][\\udc00-\\udfff]",wu="(?:"+mu+"|"+gu+")"+"?",xu="[\\ufe0e\\ufe0f]?",ku=xu+wu+("(?:\\u200d(?:"+[vu,yu,bu].join("|")+")"+xu+wu+")*"),Su="(?:"+[vu+mu+"?",mu,yu,bu,pu].join("|")+")",Cu=RegExp(gu+"(?="+gu+")|"+Su+ku,"g");const Eu=function(e){for(var t=Cu.lastIndex=0;Cu.test(e);)++t;return t};const Tu=function(e){return du(e)?Eu(e):uu(e)};const Ou=function(e){if(null==e)return 0;if(Yn(e))return to(e)?Tu(e):e.length;var t=vr(e);return"[object Map]"==t||"[object Set]"==t?e.size:Jn(e).length};var Au=ji((function(e,t){return nu(e)?tu(e,gc(t,1,nu,!0)):[]}));const _u=Au;const Pu=ji((function(e){return Vi(gc(e,1,nu,!0))}));const Nu=function(e,t){return Sr(e,t)};var Mu=function(e){function t(){return e.apply(this,arguments)||this}return bi(t,e),t.prototype.render=function(){var e=this.props,n=e.className,r=e.name,i=Oe(r,"flag",n),o=Le(t,this.props),s=Be(t,this.props);return we.createElement(s,Ee({},o,{className:i}))},t}(we.PureComponent);Mu.handledProps=["as","className","name"],Mu.propTypes={},Mu.defaultProps={as:"i"},Mu.create=io(Mu,(function(e){return{name:e}}));const ju=Mu;function Ru(e){var t=e.className,n=Oe("divider",t),r=Le(Ru,e),i=Be(Ru,e);return we.createElement(i,Ee({},r,{className:n}))}Ru.handledProps=["as","className"],Ru.propTypes={};const Iu=Ru;var Du=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i=u})),u>=d.length-1&&(t=f[f.length-1]);else{var m=au(d,["value",h]);t=_o(f,m)?m:void 0}return(!t||t<0)&&(t=f[0]),t}nh.handledProps=[];var ih=function(e,t){return Ii(e)?t:e},oh=function(e){return e?e.map((function(e){return yc(e,["key","value"])})):e};function sh(e){var t=e.flag,n=e.image,r=e.text;return pt(r)?r:{content:we.createElement(we.Fragment,null,ju.create(t),Ss.create(n),r)}}var ah=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i=r||1===r?t.open(e):Ri(t.searchRef.current,"focus")},t.handleIconClick=function(e){var n=t.props.clearable,r=t.hasValue();Ri(t.props,"onClick",e,t.props),e.stopPropagation(),n&&r?t.clearValue(e):t.toggle(e)},t.handleItemClick=function(e,n){var r=t.props,i=r.multiple,o=r.search,s=t.state.value,a=n.value;if(e.stopPropagation(),(i||n.disabled)&&e.nativeEvent.stopImmediatePropagation(),!n.disabled){var l=n["data-additional"],c=i?Pu(t.state.value,[a]):a;(i?!!_u(c,s).length:c!==s)&&(t.setState({value:c}),t.handleChange(e,c)),t.clearSearchQuery(),Ri(o?t.searchRef.current:t.ref.current,"focus"),t.closeOnChange(e),l&&Ri(t.props,"onAddItem",e,Ee({},t.props,{value:a}))}},t.handleFocus=function(e){t.state.focus||(Ri(t.props,"onFocus",e,t.props),t.setState({focus:!0}))},t.handleBlur=function(e){var n=Qr(e,"currentTarget");if(!n||!n.contains(document.activeElement)){var r=t.props,i=r.closeOnBlur,o=r.multiple,s=r.selectOnBlur;t.isMouseDown||(Ri(t.props,"onBlur",e,t.props),s&&!o&&(t.makeSelectedItemActive(e,t.state.selectedIndex),i&&t.close()),t.setState({focus:!1}),t.clearSearchQuery())}},t.handleSearchChange=function(e,n){var r=n.value;e.stopPropagation();var i=t.props.minCharacters,o=t.state.open,s=r;Ri(t.props,"onSearchChange",e,Ee({},t.props,{searchQuery:s})),t.setState({searchQuery:s,selectedIndex:0}),!o&&s.length>=i?t.open():o&&1!==i&&s.lengthi||o<0)?o=n:o>i?o=0:o<0&&(o=i),r[o].disabled?t.getSelectedIndexAfterMove(e,o):o}},t.handleIconOverrides=function(e){var n=t.props.clearable;return{className:Oe(n&&t.hasValue()&&"clear",e.className),onClick:function(n){Ri(e,"onClick",n,e),t.handleIconClick(n)}}},t.clearValue=function(e){var n=t.props.multiple?[]:"";t.setState({value:n}),t.handleChange(e,n)},t.computeSearchInputTabIndex=function(){var e=t.props,n=e.disabled,r=e.tabIndex;return Ii(r)?n?-1:0:r},t.computeSearchInputWidth=function(){var e=t.state.searchQuery;if(t.sizerRef.current&&e){t.sizerRef.current.style.display="inline",t.sizerRef.current.textContent=e;var n=Math.ceil(t.sizerRef.current.getBoundingClientRect().width);return t.sizerRef.current.style.removeProperty("display"),n}},t.computeTabIndex=function(){var e=t.props,n=e.disabled,r=e.search,i=e.tabIndex;if(!r)return n?-1:Ii(i)?0:i},t.handleSearchInputOverrides=function(e){return{onChange:function(n,r){Ri(e,"onChange",n,r),t.handleSearchChange(n,r)}}},t.hasValue=function(){var e=t.props.multiple,n=t.state.value;return e?!Sc(n):!Ii(n)&&""!==n},t.scrollSelectedItemIntoView=function(){if(t.ref.current){var e=t.ref.current.querySelector(".menu.visible");if(e){var n=e.querySelector(".item.selected");if(n){var r=n.offsetTope.scrollTop+e.clientHeight;r?e.scrollTop=n.offsetTop:i&&(e.scrollTop=n.offsetTop+n.clientHeight-e.clientHeight)}}}},t.setOpenDirection=function(){if(t.ref.current){var e=t.ref.current.querySelector(".menu.visible");if(e){var n=t.ref.current.getBoundingClientRect(),r=e.clientHeight,i=document.documentElement.clientHeight-n.top-n.height-r,o=n.top-r,s=i<0&&o>i;!s!==!t.state.upward&&t.setState({upward:s})}}},t.open=function(e,n){void 0===e&&(e=null),void 0===n&&(n=!0);var r=t.props,i=r.disabled,o=r.search;i||(o&&Ri(t.searchRef.current,"focus"),Ri(t.props,"onOpen",e,t.props),n&&t.setState({open:!0}),t.scrollSelectedItemIntoView())},t.close=function(e,n){void 0===n&&(n=t.handleClose),t.state.open&&(Ri(t.props,"onClose",e,t.props),t.setState({open:!1},n))},t.handleClose=function(){var e=document.activeElement===t.searchRef.current;!e&&t.ref.current&&t.ref.current.blur();var n=document.activeElement===t.ref.current,r=e||n;t.setState({focus:r})},t.toggle=function(e){return t.state.open?t.close(e):t.open(e)},t.renderText=function(){var e,n=t.props,r=n.multiple,i=n.placeholder,o=n.search,s=n.text,a=t.state,l=a.searchQuery,c=a.selectedIndex,u=a.value,h=a.open,d=t.hasValue(),f=Oe(i&&!d&&"default","text",o&&l&&"filtered"),p=i;return s?p=s:h&&!r?e=t.getSelectedItem(c):d&&(e=t.getItemByValue(u)),Vu.create(e?sh(e):p,{defaultProps:{className:f}})},t.renderSearchInput=function(){var e=t.props,n=e.search,r=e.searchInput,i=t.state.searchQuery;return n&&we.createElement(Jo,{innerRef:t.searchRef},Uu.create(r,{defaultProps:{style:{width:t.computeSearchInputWidth()},tabIndex:t.computeSearchInputTabIndex(),value:i},overrideProps:t.handleSearchInputOverrides}))},t.renderSearchSizer=function(){var e=t.props,n=e.search,r=e.multiple;return n&&r&&we.createElement("span",{className:"sizer",ref:t.sizerRef})},t.renderLabels=function(){var e=t.props,n=e.multiple,r=e.renderLabel,i=t.state,o=i.selectedLabel,s=i.value;if(n&&!Sc(s)){var a=$s(s,t.getItemByValue);return $s(Yc(a),(function(e,n){var i={active:e.value===o,as:"a",key:ih(e.key,e.value),onClick:t.handleLabelClick,onRemove:t.handleLabelRemove,value:e.value};return bs.create(r(e,n,i),{defaultProps:i})}))}},t.renderOptions=function(){var e=t.props,n=e.lazyLoad,r=e.multiple,i=e.search,o=e.noResultsMessage,s=t.state,a=s.open,l=s.selectedIndex,c=s.value;if(n&&!a)return null;var u=nh({value:t.state.value,options:t.props.options,searchQuery:t.state.searchQuery,additionLabel:t.props.additionLabel,additionPosition:t.props.additionPosition,allowAdditions:t.props.allowAdditions,deburr:t.props.deburr,multiple:t.props.multiple,search:t.props.search});if(null!==o&&i&&Sc(u))return we.createElement("div",{className:"message"},o);var h=r?function(e){return _o(c,e)}:function(e){return e===c};return $s(u,(function(e,n){return Lu.create(Ee({active:h(e.value),selected:l===n},e,{key:ih(e.key,e.value),style:Ee({},e.style,{pointerEvents:"all"})}),{generateKey:!1,overrideProps:function(e){return{onClick:function(n,r){null==e.onClick||e.onClick(n,r),t.handleItemClick(n,r)}}}})}))},t.renderMenu=function(){var e=t.props,n=e.children,r=e.direction,i=e.header,o=t.state.open,s=t.getDropdownMenuAriaOptions();if(!hi(n)){var a=we.Children.only(n),l=Oe(r,Pe(o,"visible"),a.props.className);return(0,we.cloneElement)(a,Ee({className:l},s))}return we.createElement(Hu,Ee({},s,{direction:r,open:o}),Fu.create(i,{autoGenerateKey:!1}),t.renderOptions())},t}bi(t,e);var n=t.prototype;return n.getInitialAutoControlledState=function(){return{focus:!1,searchQuery:""}},t.getAutoControlledStateFromProps=function(e,t,n){var r={__options:e.options,__value:t.value};return(!Ec()(n.__value,t.value)||!Nu(oh(e.options),oh(n.__options)))&&(r.selectedIndex=rh({additionLabel:e.additionLabel,additionPosition:e.additionPosition,allowAdditions:e.allowAdditions,deburr:e.deburr,multiple:e.multiple,search:e.search,selectedIndex:t.selectedIndex,value:t.value,options:e.options,searchQuery:t.searchQuery})),r},n.componentDidMount=function(){this.state.open&&this.open(null,!1)},n.shouldComponentUpdate=function(e,t){return!Ec()(e,this.props)||!Ec()(t,this.state)},n.componentDidUpdate=function(e,t){var n=this.props,r=n.closeOnBlur,i=n.minCharacters,o=n.openOnFocus,s=n.search;if(!t.focus&&this.state.focus){if(!this.isMouseDown){var a=!s||s&&1===i&&!this.state.open;o&&a&&this.open()}}else t.focus&&!this.state.focus&&!this.isMouseDown&&r&&this.close();!t.open&&this.state.open?(this.setOpenDirection(),this.scrollSelectedItemIntoView()):t.open&&this.state.open,t.selectedIndex!==this.state.selectedIndex&&this.scrollSelectedItemIntoView()},n.getDropdownMenuAriaOptions=function(){var e=this.props,t=e.search,n=e.multiple,r={};return t&&(r["aria-multiselectable"]=n,r.role="listbox"),r},n.render=function(){var e=this.props,n=e.basic,r=e.button,i=e.className,o=e.compact,s=e.disabled,a=e.error,l=e.fluid,c=e.floating,u=e.icon,h=e.inline,d=e.item,f=e.labeled,p=e.loading,m=e.multiple,g=e.pointing,v=e.search,y=e.selection,b=e.scrolling,w=e.simple,x=e.trigger,k=this.state,S=k.focus,C=k.open,E=k.upward,T=Oe("ui",Pe(C,"active visible"),Pe(s,"disabled"),Pe(a,"error"),Pe(p,"loading"),Pe(n,"basic"),Pe(r,"button"),Pe(o,"compact"),Pe(l,"fluid"),Pe(c,"floating"),Pe(h,"inline"),Pe(f,"labeled"),Pe(d,"item"),Pe(m,"multiple"),Pe(v,"search"),Pe(y,"selection"),Pe(w,"simple"),Pe(b,"scrolling"),Pe(E,"upward"),Me(g,"pointing"),"dropdown",i),O=Le(t,this.props),A=Be(t,this.props),_=this.getDropdownAriaOptions(A,this.props);return we.createElement(Jo,{innerRef:this.ref},we.createElement(A,Ee({},O,_,{className:T,onBlur:this.handleBlur,onClick:this.handleClick,onKeyDown:this.handleKeyDown,onMouseDown:this.handleMouseDown,onFocus:this.handleFocus,onChange:this.handleChange,tabIndex:this.computeTabIndex()}),this.renderLabels(),this.renderSearchInput(),this.renderSearchSizer(),x||this.renderText(),fo.create(u,{overrideProps:this.handleIconOverrides,autoGenerateKey:!1}),this.renderMenu(),C&&we.createElement(Ho(),{name:"keydown",on:this.closeOnEscape}),C&&we.createElement(Ho(),{name:"click",on:this.closeOnDocumentClick}),S&&we.createElement(Ho(),{name:"keydown",on:this.removeItemOnBackspace})))},t}(ss);function lh(e){var t=e.control,n=Le(lh,e),r=Be(lh,e);return we.createElement(r,Ee({},n,{control:t}))}ah.handledProps=["additionLabel","additionPosition","allowAdditions","as","basic","button","children","className","clearable","closeOnBlur","closeOnChange","closeOnEscape","compact","deburr","defaultOpen","defaultSearchQuery","defaultSelectedLabel","defaultUpward","defaultValue","direction","disabled","error","floating","fluid","header","icon","inline","item","labeled","lazyLoad","loading","minCharacters","multiple","noResultsMessage","onAddItem","onBlur","onChange","onClick","onClose","onFocus","onLabelClick","onMouseDown","onOpen","onSearchChange","open","openOnFocus","options","placeholder","pointing","renderLabel","scrolling","search","searchInput","searchQuery","selectOnBlur","selectOnNavigation","selectedLabel","selection","simple","tabIndex","text","trigger","upward","value","wrapSelection"],ah.propTypes={},ah.defaultProps={additionLabel:"Add ",additionPosition:"top",closeOnBlur:!0,closeOnEscape:!0,deburr:!1,icon:"dropdown",minCharacters:1,noResultsMessage:"No results found.",openOnFocus:!0,renderLabel:sh,searchInput:"text",selectOnBlur:!0,selectOnNavigation:!0,wrapSelection:!0},ah.autoControlledProps=["open","searchQuery","selectedLabel","value","upward"],ah.Divider=Iu,ah.Header=Fu,ah.Item=Lu,ah.Menu=Hu,ah.SearchInput=Uu,ah.Text=Vu,lh.handledProps=["as","control"],lh.propTypes={},lh.defaultProps={as:qc,control:ah};const ch=lh;function uh(e){var t=e.children,n=e.className,r=e.grouped,i=e.inline,o=e.unstackable,s=e.widths,a=Oe(Pe(r,"grouped"),Pe(i,"inline"),Pe(o,"unstackable"),De(s,null,!0),"fields",n),l=Le(uh,e),c=Be(uh,e);return we.createElement(c,Ee({},l,{className:a}),t)}uh.handledProps=["as","children","className","grouped","inline","unstackable","widths"],uh.propTypes={};const hh=uh;function dh(e){var t=e.control,n=Le(dh,e),r=Be(dh,e);return we.createElement(r,Ee({},n,{control:t}))}dh.handledProps=["as","control"],dh.propTypes={},dh.defaultProps={as:qc,control:oc};const fh=dh;function ph(e){var t=e.control,n=Le(ph,e),r=Be(ph,e);return we.createElement(r,Ee({},n,{control:t}))}ph.handledProps=["as","control"],ph.propTypes={},ph.defaultProps={as:qc,control:Wc};const mh=ph;function gh(e){return we.createElement(ah,Ee({},e,{selection:!0}))}gh.handledProps=["options"],gh.propTypes={},gh.Divider=ah.Divider,gh.Header=ah.Header,gh.Item=ah.Item,gh.Menu=ah.Menu;const vh=gh;function yh(e){var t=e.control,n=e.options,r=Le(yh,e),i=Be(yh,e);return we.createElement(i,Ee({},r,{control:t,options:n}))}yh.handledProps=["as","control","options"],yh.propTypes={},yh.defaultProps={as:qc,control:vh};const bh=yh;var wh=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i1?n-1:0),i=1;i{let{initiateConversation:t,...n}=e;const[r,i]=we.useState(!1),[o,s]=we.useState(""),[a,l]=we.useState("");(0,we.useEffect)((()=>{r&&Th.current.focus()}),[r]);const c=()=>o.length>0&&a.length>0;return(0,Ps.jsxs)($c,{onClose:()=>i(!1),onOpen:()=>i(!0),open:r,...n,children:[(0,Ps.jsxs)(_s,{children:[(0,Ps.jsx)(fo,{name:"send"}),(0,Ps.jsx)($c.Content,{children:"Send Private Message"})]}),(0,Ps.jsx)($c.Content,{children:(0,Ps.jsxs)(Eh,{children:[(0,Ps.jsx)(Eh.Field,{children:(0,Ps.jsx)(oc,{onChange:(e,t)=>s(t.value),placeholder:"Username",ref:Th})}),(0,Ps.jsx)(Eh.Field,{children:(0,Ps.jsx)(oc,{onChange:(e,t)=>l(t.value),placeholder:"Message"})})]})}),(0,Ps.jsxs)($c.Actions,{children:[(0,Ps.jsx)($a,{onClick:()=>i(!1),children:"Cancel"}),(0,Ps.jsx)($a,{disabled:!c(),onClick:()=>(async()=>{c()?(await t(o,a),i(!1)):Th.current.focus()})(),positive:!0,children:"Send"})]})]})};function Ah(e){var t=e.children,n=e.className,r=e.content,i=Oe("header",n),o=Le(Ah,e),s=Be(Ah,e);return we.createElement(s,Ee({},o,{className:i}),hi(t)?r:t)}Ah.handledProps=["as","children","className","content"],Ah.propTypes={};const _h=Ah;var Ph=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;const Nh=function(e){return e.match(Ph)||[]};var Mh=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;const jh=function(e){return Mh.test(e)};var Rh="\\ud800-\\udfff",Ih="\\u2700-\\u27bf",Dh="a-z\\xdf-\\xf6\\xf8-\\xff",Lh="A-Z\\xc0-\\xd6\\xd8-\\xde",Bh="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Fh="["+Bh+"]",zh="\\d+",Hh="["+Ih+"]",$h="["+Dh+"]",Uh="[^"+Rh+Bh+zh+Ih+Dh+Lh+"]",Wh="(?:\\ud83c[\\udde6-\\uddff]){2}",Vh="[\\ud800-\\udbff][\\udc00-\\udfff]",qh="["+Lh+"]",Kh="(?:"+$h+"|"+Uh+")",Qh="(?:"+qh+"|"+Uh+")",Gh="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",Jh="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",Yh="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",Xh="[\\ufe0e\\ufe0f]?",Zh=Xh+Yh+("(?:\\u200d(?:"+["[^"+Rh+"]",Wh,Vh].join("|")+")"+Xh+Yh+")*"),ed="(?:"+[Hh,Wh,Vh].join("|")+")"+Zh,td=RegExp([qh+"?"+$h+"+"+Gh+"(?="+[Fh,qh,"$"].join("|")+")",Qh+"+"+Jh+"(?="+[Fh,qh+Kh,"$"].join("|")+")",qh+"?"+Kh+"+"+Gh,qh+"+"+Jh,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",zh,ed].join("|"),"g");const nd=function(e){return e.match(td)||[]};const rd=function(e,t,n){return e=Wr(e),void 0===(t=n?void 0:t)?jh(e)?nd(e):Nh(e):e.match(t)||[]};var id=RegExp("['\u2019]","g");const od=function(e){return function(t){return bc(rd(Zu(t).replace(id,"")),e,"")}};const sd=function(e,t,n){var r=e.length;return n=void 0===n?r:n,!t&&n>=r?e:ki(e,t,n)};const ad=function(e){return e.split("")};var ld="\\ud800-\\udfff",cd="["+ld+"]",ud="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",hd="\\ud83c[\\udffb-\\udfff]",dd="[^"+ld+"]",fd="(?:\\ud83c[\\udde6-\\uddff]){2}",pd="[\\ud800-\\udbff][\\udc00-\\udfff]",md="(?:"+ud+"|"+hd+")"+"?",gd="[\\ufe0e\\ufe0f]?",vd=gd+md+("(?:\\u200d(?:"+[dd,fd,pd].join("|")+")"+gd+md+")*"),yd="(?:"+[dd+ud+"?",ud,fd,pd,cd].join("|")+")",bd=RegExp(hd+"(?="+hd+")|"+yd+vd,"g");const wd=function(e){return e.match(bd)||[]};const xd=function(e){return du(e)?wd(e):ad(e)};const kd=function(e){return function(t){t=Wr(t);var n=du(t)?xd(t):void 0,r=n?n[0]:t.charAt(0),i=n?sd(n,1).join(""):t.slice(1);return r[e]()+i}};const Sd=kd("toUpperCase");const Cd=od((function(e,t,n){return e+(n?" ":"")+Sd(t)}));var Ed=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i{let{active:t,conversations:n,onConversationChange:r,...i}=e;const o=Object.keys(n),s=e=>t===e;return(0,Ps.jsxs)(_d,{className:"conversation-menu",size:"large",children:[o.map((e=>(0,Ps.jsxs)(_d.Item,{active:s(e),className:"menu-item "+(s(e)?"menu-active":""),name:e,onClick:()=>r(e),children:[(0,Ps.jsx)(fo,{color:"green",name:"circle",size:"tiny"}),e,n[e].hasUnAcknowledgedMessages&&(0,Ps.jsx)(bs,{color:"red",size:"tiny",children:n[e].unAcknowledgedMessageCount})]},e))),(0,Ps.jsx)(_d.Menu,{position:"right",children:(0,Ps.jsx)(Oh,{centered:!0,size:"small",trigger:(0,Ps.jsx)($a,{className:"add-button",icon:!0,children:(0,Ps.jsx)(fo,{name:"plus"})}),...i})})]})},Nd={active:"",conversations:{},interval:void 0,loading:!1};class Md extends we.Component{constructor(e){super(e),this.listRef=(0,we.createRef)(),this.messageRef=void 0,this.getFirstConversation=()=>{const e=Object.keys(this.state.conversations);return e.length>0?e[0]:""},this.fetchConversations=async()=>{let e=await(async()=>(await ge.get("/conversations")).data)();e=0===e.length?{}:e.reduce(((e,t)=>(e[t.username]=t,e)),{});const{active:t}=this.state,n=e[t];n&&(console.log("active?",n),!0===n.hasUnAcknowledgedMessages&&await this.acknowledgeMessages(t),e={...e,[t]:await hc({username:t})}),this.setState({conversations:e},(()=>{this.state.conversations[this.state.active]||this.selectConversation(this.getFirstConversation())}))},this.acknowledgeMessages=async e=>{e&&""!==e&&await(e=>{let{username:t}=e;return ge.put(`/conversations/${encodeURIComponent(t)}`)})({username:e})},this.sendMessage=async(e,t)=>{e&&t&&""!==e&&await(e=>{let{username:t,message:n}=e;return ge.post(`/conversations/${encodeURIComponent(t)}`,JSON.stringify(n))})({message:t,username:e})},this.sendReply=async()=>{const{active:e}=this.state,t=this.messageRef.current.value;this.validInput()&&(await this.sendMessage(e,t),this.messageRef.current.value="",this.fetchConversations())},this.validInput=()=>(this.state.active||"").length>0&&(this.messageRef&&this.messageRef.current&&this.messageRef.current.value||"").length>0,this.focusInput=()=>{this.messageRef.current.focus()},this.formatTimestamp=e=>{const t=new Date(e);return new Intl.DateTimeFormat("en",{day:"numeric",hour:"numeric",minute:"2-digit",month:"numeric"}).format(t)},this.selectConversation=e=>{this.setState({active:e,loading:!0},(async()=>{const{active:e,conversations:t}=this.state;sessionStorage.setItem(a,e),this.setState({conversations:""===e?t:{...t,[e]:await hc({username:e})},loading:!1},(()=>{try{this.listRef.current.lastChild.scrollIntoView()}catch{}}))}))},this.initiateConversation=async(e,t)=>{await this.sendMessage(e,t),await this.fetchConversations(),this.selectConversation(e)},this.deleteConversation=async e=>{await(e=>{let{username:t}=e;return ge.delete(`/conversations/${encodeURIComponent(t)}`)})({username:e}),await this.fetchConversations(),this.selectConversation(this.getFirstConversation())},this.state=Nd}componentDidMount(){this.setState({active:sessionStorage.getItem(a)||"",interval:window.setInterval(this.fetchConversations,5e3)},(async()=>{await this.fetchConversations(),this.selectConversation(this.state.active||this.getFirstConversation())}))}componentWillUnmount(){clearInterval(this.state.interval),this.setState({interval:void 0})}render(){var e;const{active:t,conversations:n=[],loading:r}=this.state,i=(null===(e=n[t])||void 0===e?void 0:e.messages)||[],{user:o}=this.props.state;return(0,Ps.jsxs)("div",{className:"chats",children:[(0,Ps.jsxs)(vi,{className:"chat-segment",raised:!0,children:[(0,Ps.jsx)("div",{className:"chat-segment-icon",children:(0,Ps.jsx)(fo,{name:"comment",size:"big"})}),(0,Ps.jsx)(Pd,{active:t,conversations:n,initiateConversation:this.initiateConversation,onConversationChange:e=>this.selectConversation(e)})]}),!1===Boolean(t)?(0,Ps.jsx)(Ns,{caption:"No chats to display",icon:"comment"}):(0,Ps.jsx)(Ra,{className:"chat-active-card",raised:!0,children:(0,Ps.jsxs)(Ra.Content,{onClick:()=>this.focusInput(),children:[(0,Ps.jsxs)(Ra.Header,{children:[(0,Ps.jsx)(fo,{color:"green",name:"circle"}),t,(0,Ps.jsx)(fo,{className:"close-button",color:"red",link:!0,name:"close",onClick:()=>this.deleteConversation(t)})]}),(0,Ps.jsx)("div",{className:"chat",children:r?(0,Ps.jsx)(ps,{active:!0,inverted:!0,children:(0,Ps.jsx)(ac,{inverted:!0})}):(0,Ps.jsxs)(vi.Group,{children:[(0,Ps.jsx)(vi,{className:"chat-history",children:(0,Ps.jsx)(Jo,{innerRef:this.listRef,children:(0,Ps.jsxs)(na,{children:[i.map((e=>(0,Ps.jsxs)(na.Content,{className:"chat-message "+("Out"===e.direction?"chat-message-self":""),children:[(0,Ps.jsx)("span",{className:"chat-message-time",children:this.formatTimestamp(e.timestamp)}),(0,Ps.jsxs)("span",{className:"chat-message-name",children:["Out"===e.direction?o.username:e.username,":"," "]}),(0,Ps.jsx)("span",{className:"chat-message-message",children:e.message})]},`${e.timestamp}+${e.message}`))),(0,Ps.jsx)(na.Content,{id:"chat-history-scroll-anchor"})]})})}),(0,Ps.jsx)(vi,{className:"chat-input",children:(0,Ps.jsx)(oc,{action:{className:"chat-message-button",disabled:!this.validInput(),icon:(0,Ps.jsx)(fo,{color:"green",name:"send"}),onClick:this.sendMessage},fluid:!0,input:(0,Ps.jsx)("input",{autoComplete:"off","data-lpignore":"true",id:"chat-message-input",type:"text"}),onKeyUp:e=>"Enter"===e.key?this.sendReply():"",ref:e=>this.messageRef=e&&e.inputRef,transparent:!0})})]})})]})})]})}}const jd=Md,Rd=["\n \u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\n\u2584\u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584\u2588 \u2588\n\u2588__ --\u2588 \u2588__ --\u2588 \u25c4\u2588 - \u2588\n\u2588\u2584\u2584\u2584\u2584\u2584\u2588\u2584\u2584\u2588\u2584\u2584\u2584\u2584\u2584\u2588\u2584\u2584\u2588\u2584\u2584\u2588\u2584\u2584\u2584\u2584\u2584\u2588\n","\n \u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\n\u2584\u2584\u2584\u2584\u2584\u2584\u2584 \u2588 \u2588 \u2584\u2584\u2584\u2584\u2584\u2584\u2584 \u2588 \u2588\u2584\u2584\u2584 \u2584\u2584\u2584\u2588 \u2588\n\u2588__ --\u2588 \u2588 \u2588 \u2588__ --\u2588 \u2588 \u25c4\u2588 \u2588 - \u2588\n\u2588\u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2588\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584\u2588\n"];function Id(e){var t=e.children,n=e.className,r=e.computer,i=e.color,o=e.floated,s=e.largeScreen,a=e.mobile,l=e.only,c=e.stretched,u=e.tablet,h=e.textAlign,d=e.verticalAlign,f=e.widescreen,p=e.width,m=Oe(i,Pe(c,"stretched"),je(l,"only"),Re(h),Ne(o,"floated"),Ie(d),De(r,"wide computer"),De(s,"wide large screen"),De(a,"wide mobile"),De(u,"wide tablet"),De(f,"wide widescreen"),De(p,"wide"),"column",n),g=Le(Id,e),v=Be(Id,e);return we.createElement(v,Ee({},g,{className:m}),t)}Id.handledProps=["as","children","className","color","computer","floated","largeScreen","mobile","only","stretched","tablet","textAlign","verticalAlign","widescreen","width"],Id.propTypes={},Id.create=io(Id,(function(e){return{children:e}}));const Dd=Id;function Ld(e){var t=e.centered,n=e.children,r=e.className,i=e.color,o=e.columns,s=e.divided,a=e.only,l=e.reversed,c=e.stretched,u=e.textAlign,h=e.verticalAlign,d=Oe(i,Pe(t,"centered"),Pe(s,"divided"),Pe(c,"stretched"),je(a,"only"),je(l,"reversed"),Re(u),Ie(h),De(o,"column",!0),"row",r),f=Le(Ld,e),p=Be(Ld,e);return we.createElement(p,Ee({},f,{className:d}),n)}Ld.handledProps=["as","centered","children","className","color","columns","divided","only","reversed","stretched","textAlign","verticalAlign"],Ld.propTypes={};const Bd=Ld;function Fd(e){var t=e.celled,n=e.centered,r=e.children,i=e.className,o=e.columns,s=e.container,a=e.divided,l=e.doubling,c=e.inverted,u=e.padded,h=e.relaxed,d=e.reversed,f=e.stackable,p=e.stretched,m=e.textAlign,g=e.verticalAlign,v=Oe("ui",Pe(n,"centered"),Pe(s,"container"),Pe(l,"doubling"),Pe(c,"inverted"),Pe(f,"stackable"),Pe(p,"stretched"),Me(t,"celled"),Me(a,"divided"),Me(u,"padded"),Me(h,"relaxed"),je(d,"reversed"),Re(m),Ie(g),De(o,"column",!0),"grid",i),y=Le(Fd,e),b=Be(Fd,e);return we.createElement(b,Ee({},y,{className:v}),r)}Fd.handledProps=["as","celled","centered","children","className","columns","container","divided","doubling","inverted","padded","relaxed","reversed","stackable","stretched","textAlign","verticalAlign"],Fd.Column=Dd,Fd.Row=Bd,Fd.propTypes={};const zd=Fd;function Hd(e){var t=e.children,n=e.className,r=e.content,i=Oe("content",n),o=Le(Hd,e),s=Be(Hd,e);return we.createElement(s,Ee({},o,{className:i}),hi(t)?r:t)}Hd.handledProps=["as","children","className","content"],Hd.propTypes={};const $d=Hd;function Ud(e){var t=e.children,n=e.className,r=e.content,i=Oe("header",n),o=Le(Ud,e),s=Be(Ud,e);return we.createElement(s,Ee({},o,{className:i}),hi(t)?r:t)}Ud.handledProps=["as","children","className","content"],Ud.propTypes={},Ud.create=io(Ud,(function(e){return{content:e}}));const Wd=Ud;function Vd(e){var t=e.children,n=e.className,r=e.content,i=Oe("content",n),o=Le(Vd,e),s=Be(Vd,e);return we.createElement(s,Ee({},o,{className:i}),hi(t)?r:t)}Vd.handledProps=["as","children","className","content"],Vd.propTypes={},Vd.defaultProps={as:"li"},Vd.create=io(Vd,(function(e){return{content:e}}));const qd=Vd;function Kd(e){var t=e.children,n=e.className,r=e.items,i=Oe("list",n),o=Le(Kd,e),s=Be(Kd,e);return we.createElement(s,Ee({},o,{className:i}),hi(t)?$s(r,qd.create):t)}Kd.handledProps=["as","children","className","items"],Kd.propTypes={},Kd.defaultProps={as:"ul"},Kd.create=io(Kd,(function(e){return{items:e}}));const Qd=Kd;var Gd=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i{let{error:t,loading:n,onLoginAttempt:r}=e;const i=(0,we.useRef)(),[o,s]=(0,we.useState)(Jd),[a,l]=(0,we.useState)(!1),c=(0,we.useMemo)((()=>Rd[Math.floor(Math.random()*Rd.length)]),[]);(0,we.useEffect)((()=>{""!==o.username&&""!==o.password?l(!0):l(!1)}),[o]),(0,we.useEffect)((()=>{var e;null===(e=i.current)||void 0===e||e.focus()}),[n]);const u=(e,t)=>{s({...o,[e]:t})},{password:h,rememberMe:d,username:f}=o;return(0,Ps.jsx)(zd,{style:{height:"100vh"},textAlign:"center",verticalAlign:"middle",children:(0,Ps.jsxs)(zd.Column,{style:{maxWidth:372},children:[(0,Ps.jsx)(_s,{as:"h2",style:{fontFamily:"monospace",fontSize:"inherit",letterSpacing:-1,lineHeight:1.1,whiteSpace:"pre"},textAlign:"center",children:c}),(0,Ps.jsxs)(Eh,{size:"large",children:[(0,Ps.jsxs)(vi,{raised:!0,children:[(0,Ps.jsx)(oc,{disabled:n,fluid:!0,icon:"user",iconPosition:"left",onChange:e=>u("username",e.target.value),placeholder:"Username",ref:i}),(0,Ps.jsx)(Eh.Input,{disabled:n,fluid:!0,icon:"lock",iconPosition:"left",onChange:e=>u("password",e.target.value),placeholder:"Password",type:"password"}),(0,Ps.jsx)(ka,{checked:d,disabled:n,label:"Remember Me",onChange:()=>u("rememberMe",!d)})]}),(0,Ps.jsxs)($a,{className:"login-button",disabled:!a||n,fluid:!0,loading:n,onClick:()=>r(f,h,d),primary:!0,size:"large",children:[(0,Ps.jsx)(fo,{name:"sign in"}),"Login"]}),t&&(0,Ps.jsxs)(Gd,{className:"login-failure",floating:!0,negative:!0,children:[(0,Ps.jsx)(fo,{name:"x"}),t.message]})]})]})})},Xd=e=>{let{joinRoom:t,...n}=e;const[r,i]=(0,we.useState)(!1),[o,s]=(0,we.useState)([]),[a,l]=(0,we.useState)(void 0),[c,u]=(0,we.useState)("name"),[h,d]=(0,we.useState)("desc"),[f,p]=(0,we.useState)(""),[m,g]=(0,we.useState)(!0);(0,we.useEffect)((()=>{r&&(async()=>{g(!0);const e=await(async()=>{const e=(await ge.get("/rooms/available")).data;if(Array.isArray(e))return e;console.warn("got non-array response from rooms API",e)})();s(e),g(!1)})()}),[r]);const v=(0,we.useMemo)((()=>{const e=[...o].filter((e=>e.name.includes(f)));return e.sort(((e,t)=>"asc"===h?"string"===typeof e[c]?t[c].localeCompare(e[c]):e[c]-t[c]:"string"===typeof e[c]?e[c].localeCompare(t[c]):t[c]-e[c])),e}),[o,f,c,h]),y=()=>{s([]),l(void 0),u("name"),d("desc"),p(""),i(!1)},b=e=>a===e.name;return(0,Ps.jsxs)($c,{className:"join-room-modal",onClose:()=>y(),onOpen:()=>i(!0),open:r,...n,children:[(0,Ps.jsxs)(_s,{children:[(0,Ps.jsx)(fo,{name:"comments"}),(0,Ps.jsx)($c.Content,{children:"Join Room"})]}),(0,Ps.jsx)($c.Content,{scrolling:!0,children:m?(0,Ps.jsx)(ps,{active:!0,inverted:!0,children:(0,Ps.jsx)(ac,{content:"Loading Room List",inverted:!0})}):(0,Ps.jsxs)(Ps.Fragment,{children:[(0,Ps.jsx)(oc,{fluid:!0,icon:"filter",onChange:(e,t)=>p(t.value),placeholder:"Room Filter"}),(0,Ps.jsxs)(ga,{celled:!0,selectable:!0,children:[(0,Ps.jsx)(ga.Header,{children:(0,Ps.jsxs)(ga.Row,{children:[(0,Ps.jsxs)(ga.HeaderCell,{onClick:()=>u("name"),children:["Name",(0,Ps.jsx)(fo,{link:"name"===c,name:"name"===c&&("asc"===h?"chevron up":"chevron down"),onClick:()=>d("asc"===h?"desc":"asc")})]}),(0,Ps.jsxs)(ga.HeaderCell,{onClick:()=>u("userCount"),children:["Users",(0,Ps.jsx)(fo,{link:"userCount"===c,name:"userCount"===c&&("asc"===h?"chevron up":"chevron down"),onClick:()=>d("asc"===h?"desc":"asc")})]})]})}),(0,Ps.jsx)(ga.Body,{children:v.map((e=>(0,Ps.jsxs)(ga.Row,{onClick:()=>l(e.name),style:b(e)?{fontWeight:"bold"}:{},children:[(0,Ps.jsxs)(ga.Cell,{children:[b(e)&&(0,Ps.jsx)(fo,{color:"green",name:"check"}),e.isPrivate&&(0,Ps.jsx)(fo,{name:"lock"}),e.isOwned&&(0,Ps.jsx)(fo,{name:"chess queen"}),e.isModerated&&(0,Ps.jsx)(fo,{name:"gavel"}),e.name]}),(0,Ps.jsx)(ga.Cell,{children:e.userCount})]},e.name)))})]})]})}),(0,Ps.jsxs)($c.Actions,{children:[(0,Ps.jsx)($a,{onClick:()=>i(!1),children:"Cancel"}),(0,Ps.jsx)($a,{disabled:!a,onClick:()=>(async()=>{await t(a),y()})(),positive:!0,children:"Join"})]})]})},Zd=e=>{let{active:t,joined:n,onRoomChange:r,...i}=e;const o=[...n],s=e=>t===e;return(0,Ps.jsxs)(_d,{className:"room-menu",size:"large",children:[o.map((e=>(0,Ps.jsxs)(_d.Item,{active:s(e),className:"menu-item "+(s(e)?"menu-active":""),name:e,onClick:()=>r(e),children:[(0,Ps.jsx)(fo,{color:"green",name:"circle",size:"tiny"}),e]},e))),(0,Ps.jsx)(_d.Menu,{position:"right",children:(0,Ps.jsx)(Xd,{centered:!0,size:"small",trigger:(0,Ps.jsx)($a,{className:"add-button",icon:!0,children:(0,Ps.jsx)(fo,{name:"plus"})}),...i})})]})};const ef=function(e){return wn(e)&&1===e.nodeType&&!Zi(e)};var tf=we.createContext();we.createContext();var nf=function(e,t){if("function"===typeof e)return function(e){if("function"===typeof e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r0&&df(r.width)/e.offsetWidth||1,o=e.offsetHeight>0&&df(r.height)/e.offsetHeight||1);var s=(af(e)?sf(e):window).visualViewport,a=!pf()&&n,l=(r.left+(a&&s?s.offsetLeft:0))/i,c=(r.top+(a&&s?s.offsetTop:0))/o,u=r.width/i,h=r.height/o;return{width:u,height:h,top:c,right:l+u,bottom:c+h,left:l,x:l,y:c}}function gf(e){var t=sf(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function vf(e){return e?(e.nodeName||"").toLowerCase():null}function yf(e){return((af(e)?e.ownerDocument:e.document)||window.document).documentElement}function bf(e){return mf(yf(e)).left+gf(e).scrollLeft}function wf(e){return sf(e).getComputedStyle(e)}function xf(e){var t=wf(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function kf(e,t,n){void 0===n&&(n=!1);var r=lf(t),i=lf(t)&&function(e){var t=e.getBoundingClientRect(),n=df(t.width)/e.offsetWidth||1,r=df(t.height)/e.offsetHeight||1;return 1!==n||1!==r}(t),o=yf(t),s=mf(e,i,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&(("body"!==vf(t)||xf(o))&&(a=function(e){return e!==sf(e)&&lf(e)?{scrollLeft:(t=e).scrollLeft,scrollTop:t.scrollTop}:gf(e);var t}(t)),lf(t)?((l=mf(t,!0)).x+=t.clientLeft,l.y+=t.clientTop):o&&(l.x=bf(o))),{x:s.left+a.scrollLeft-l.x,y:s.top+a.scrollTop-l.y,width:s.width,height:s.height}}function Sf(e){var t=mf(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function Cf(e){return"html"===vf(e)?e:e.assignedSlot||e.parentNode||(cf(e)?e.host:null)||yf(e)}function Ef(e){return["html","body","#document"].indexOf(vf(e))>=0?e.ownerDocument.body:lf(e)&&xf(e)?e:Ef(Cf(e))}function Tf(e,t){var n;void 0===t&&(t=[]);var r=Ef(e),i=r===(null==(n=e.ownerDocument)?void 0:n.body),o=sf(r),s=i?[o].concat(o.visualViewport||[],xf(r)?r:[]):r,a=t.concat(s);return i?a:a.concat(Tf(Cf(s)))}function Of(e){return["table","td","th"].indexOf(vf(e))>=0}function Af(e){return lf(e)&&"fixed"!==wf(e).position?e.offsetParent:null}function _f(e){for(var t=sf(e),n=Af(e);n&&Of(n)&&"static"===wf(n).position;)n=Af(n);return n&&("html"===vf(n)||"body"===vf(n)&&"static"===wf(n).position)?t:n||function(e){var t=/firefox/i.test(ff());if(/Trident/i.test(ff())&&lf(e)&&"fixed"===wf(e).position)return null;var n=Cf(e);for(cf(n)&&(n=n.host);lf(n)&&["html","body"].indexOf(vf(n))<0;){var r=wf(n);if("none"!==r.transform||"none"!==r.perspective||"paint"===r.contain||-1!==["transform","perspective"].indexOf(r.willChange)||t&&"filter"===r.willChange||t&&r.filter&&"none"!==r.filter)return n;n=n.parentNode}return null}(e)||t}var Pf="top",Nf="bottom",Mf="right",jf="left",Rf="auto",If=[Pf,Nf,Mf,jf],Df="start",Lf="end",Bf="clippingParents",Ff="viewport",zf="popper",Hf="reference",$f=If.reduce((function(e,t){return e.concat([t+"-"+Df,t+"-"+Lf])}),[]),Uf=[].concat(If,[Rf]).reduce((function(e,t){return e.concat([t,t+"-"+Df,t+"-"+Lf])}),[]),Wf=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function Vf(e){var t=new Map,n=new Set,r=[];function i(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var r=t.get(e);r&&i(r)}})),r.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||i(e)})),r}function qf(e){var t;return function(){return t||(t=new Promise((function(n){Promise.resolve().then((function(){t=void 0,n(e())}))}))),t}}var Kf={placement:"bottom",modifiers:[],strategy:"absolute"};function Qf(){for(var e=arguments.length,t=new Array(e),n=0;n=0?"x":"y"}function ep(e){var t,n=e.reference,r=e.element,i=e.placement,o=i?Yf(i):null,s=i?Xf(i):null,a=n.x+n.width/2-r.width/2,l=n.y+n.height/2-r.height/2;switch(o){case Pf:t={x:a,y:n.y-r.height};break;case Nf:t={x:a,y:n.y+n.height};break;case Mf:t={x:n.x+n.width,y:l};break;case jf:t={x:n.x-r.width,y:l};break;default:t={x:n.x,y:n.y}}var c=o?Zf(o):null;if(null!=c){var u="y"===c?"height":"width";switch(s){case Df:t[c]=t[c]-(n[u]/2-r[u]/2);break;case Lf:t[c]=t[c]+(n[u]/2-r[u]/2)}}return t}var tp={top:"auto",right:"auto",bottom:"auto",left:"auto"};function np(e){var t,n=e.popper,r=e.popperRect,i=e.placement,o=e.variation,s=e.offsets,a=e.position,l=e.gpuAcceleration,c=e.adaptive,u=e.roundOffsets,h=e.isFixed,d=s.x,f=void 0===d?0:d,p=s.y,m=void 0===p?0:p,g="function"===typeof u?u({x:f,y:m}):{x:f,y:m};f=g.x,m=g.y;var v=s.hasOwnProperty("x"),y=s.hasOwnProperty("y"),b=jf,w=Pf,x=window;if(c){var k=_f(n),S="clientHeight",C="clientWidth";if(k===sf(n)&&"static"!==wf(k=yf(n)).position&&"absolute"===a&&(S="scrollHeight",C="scrollWidth"),i===Pf||(i===jf||i===Mf)&&o===Lf)w=Nf,m-=(h&&k===x&&x.visualViewport?x.visualViewport.height:k[S])-r.height,m*=l?1:-1;if(i===jf||(i===Pf||i===Nf)&&o===Lf)b=Mf,f-=(h&&k===x&&x.visualViewport?x.visualViewport.width:k[C])-r.width,f*=l?1:-1}var E,T=Object.assign({position:a},c&&tp),O=!0===u?function(e,t){var n=e.x,r=e.y,i=t.devicePixelRatio||1;return{x:df(n*i)/i||0,y:df(r*i)/i||0}}({x:f,y:m},sf(n)):{x:f,y:m};return f=O.x,m=O.y,l?Object.assign({},T,((E={})[w]=y?"0":"",E[b]=v?"0":"",E.transform=(x.devicePixelRatio||1)<=1?"translate("+f+"px, "+m+"px)":"translate3d("+f+"px, "+m+"px, 0)",E)):Object.assign({},T,((t={})[w]=y?m+"px":"",t[b]=v?f+"px":"",t.transform="",t))}const rp={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},i=t.elements[e];lf(i)&&vf(i)&&(Object.assign(i.style,n),Object.keys(r).forEach((function(e){var t=r[e];!1===t?i.removeAttribute(e):i.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach((function(e){var r=t.elements[e],i=t.attributes[e]||{},o=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce((function(e,t){return e[t]="",e}),{});lf(r)&&vf(r)&&(Object.assign(r.style,o),Object.keys(i).forEach((function(e){r.removeAttribute(e)})))}))}},requires:["computeStyles"]};const ip={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.options,r=e.name,i=n.offset,o=void 0===i?[0,0]:i,s=Uf.reduce((function(e,n){return e[n]=function(e,t,n){var r=Yf(e),i=[jf,Pf].indexOf(r)>=0?-1:1,o="function"===typeof n?n(Object.assign({},t,{placement:e})):n,s=o[0],a=o[1];return s=s||0,a=(a||0)*i,[jf,Mf].indexOf(r)>=0?{x:a,y:s}:{x:s,y:a}}(n,t.rects,o),e}),{}),a=s[t.placement],l=a.x,c=a.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=l,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=s}};var op={left:"right",right:"left",bottom:"top",top:"bottom"};function sp(e){return e.replace(/left|right|bottom|top/g,(function(e){return op[e]}))}var ap={start:"end",end:"start"};function lp(e){return e.replace(/start|end/g,(function(e){return ap[e]}))}function cp(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&cf(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function up(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function hp(e,t,n){return t===Ff?up(function(e,t){var n=sf(e),r=yf(e),i=n.visualViewport,o=r.clientWidth,s=r.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;var c=pf();(c||!c&&"fixed"===t)&&(a=i.offsetLeft,l=i.offsetTop)}return{width:o,height:s,x:a+bf(e),y:l}}(e,n)):af(t)?function(e,t){var n=mf(e,!1,"fixed"===t);return n.top=n.top+e.clientTop,n.left=n.left+e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}(t,n):up(function(e){var t,n=yf(e),r=gf(e),i=null==(t=e.ownerDocument)?void 0:t.body,o=uf(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),s=uf(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-r.scrollLeft+bf(e),l=-r.scrollTop;return"rtl"===wf(i||n).direction&&(a+=uf(n.clientWidth,i?i.clientWidth:0)-o),{width:o,height:s,x:a,y:l}}(yf(e)))}function dp(e,t,n,r){var i="clippingParents"===t?function(e){var t=Tf(Cf(e)),n=["absolute","fixed"].indexOf(wf(e).position)>=0&&lf(e)?_f(e):e;return af(n)?t.filter((function(e){return af(e)&&cp(e,n)&&"body"!==vf(e)})):[]}(e):[].concat(t),o=[].concat(i,[n]),s=o[0],a=o.reduce((function(t,n){var i=hp(e,n,r);return t.top=uf(i.top,t.top),t.right=hf(i.right,t.right),t.bottom=hf(i.bottom,t.bottom),t.left=uf(i.left,t.left),t}),hp(e,s,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function fp(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function pp(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}function mp(e,t){void 0===t&&(t={});var n=t,r=n.placement,i=void 0===r?e.placement:r,o=n.strategy,s=void 0===o?e.strategy:o,a=n.boundary,l=void 0===a?Bf:a,c=n.rootBoundary,u=void 0===c?Ff:c,h=n.elementContext,d=void 0===h?zf:h,f=n.altBoundary,p=void 0!==f&&f,m=n.padding,g=void 0===m?0:m,v=fp("number"!==typeof g?g:pp(g,If)),y=d===zf?Hf:zf,b=e.rects.popper,w=e.elements[p?y:d],x=dp(af(w)?w:w.contextElement||yf(e.elements.popper),l,u,s),k=mf(e.elements.reference),S=ep({reference:k,element:b,strategy:"absolute",placement:i}),C=up(Object.assign({},b,S)),E=d===zf?C:k,T={top:x.top-E.top+v.top,bottom:E.bottom-x.bottom+v.bottom,left:x.left-E.left+v.left,right:E.right-x.right+v.right},O=e.modifiersData.offset;if(d===zf&&O){var A=O[i];Object.keys(T).forEach((function(e){var t=[Mf,Nf].indexOf(e)>=0?1:-1,n=[Pf,Nf].indexOf(e)>=0?"y":"x";T[e]+=A[n]*t}))}return T}const gp={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,o=void 0===i||i,s=n.altAxis,a=void 0===s||s,l=n.fallbackPlacements,c=n.padding,u=n.boundary,h=n.rootBoundary,d=n.altBoundary,f=n.flipVariations,p=void 0===f||f,m=n.allowedAutoPlacements,g=t.options.placement,v=Yf(g),y=l||(v===g||!p?[sp(g)]:function(e){if(Yf(e)===Rf)return[];var t=sp(e);return[lp(e),t,lp(t)]}(g)),b=[g].concat(y).reduce((function(e,n){return e.concat(Yf(n)===Rf?function(e,t){void 0===t&&(t={});var n=t,r=n.placement,i=n.boundary,o=n.rootBoundary,s=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=void 0===l?Uf:l,u=Xf(r),h=u?a?$f:$f.filter((function(e){return Xf(e)===u})):If,d=h.filter((function(e){return c.indexOf(e)>=0}));0===d.length&&(d=h);var f=d.reduce((function(t,n){return t[n]=mp(e,{placement:n,boundary:i,rootBoundary:o,padding:s})[Yf(n)],t}),{});return Object.keys(f).sort((function(e,t){return f[e]-f[t]}))}(t,{placement:n,boundary:u,rootBoundary:h,padding:c,flipVariations:p,allowedAutoPlacements:m}):n)}),[]),w=t.rects.reference,x=t.rects.popper,k=new Map,S=!0,C=b[0],E=0;E=0,P=_?"width":"height",N=mp(t,{placement:T,boundary:u,rootBoundary:h,altBoundary:d,padding:c}),M=_?A?Mf:jf:A?Nf:Pf;w[P]>x[P]&&(M=sp(M));var j=sp(M),R=[];if(o&&R.push(N[O]<=0),a&&R.push(N[M]<=0,N[j]<=0),R.every((function(e){return e}))){C=T,S=!1;break}k.set(T,R)}if(S)for(var I=function(e){var t=b.find((function(t){var n=k.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return C=t,"break"},D=p?3:1;D>0;D--){if("break"===I(D))break}t.placement!==C&&(t.modifiersData[r]._skip=!0,t.placement=C,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function vp(e,t,n){return uf(e,hf(t,n))}const yp={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,o=void 0===i||i,s=n.altAxis,a=void 0!==s&&s,l=n.boundary,c=n.rootBoundary,u=n.altBoundary,h=n.padding,d=n.tether,f=void 0===d||d,p=n.tetherOffset,m=void 0===p?0:p,g=mp(t,{boundary:l,rootBoundary:c,padding:h,altBoundary:u}),v=Yf(t.placement),y=Xf(t.placement),b=!y,w=Zf(v),x="x"===w?"y":"x",k=t.modifiersData.popperOffsets,S=t.rects.reference,C=t.rects.popper,E="function"===typeof m?m(Object.assign({},t.rects,{placement:t.placement})):m,T="number"===typeof E?{mainAxis:E,altAxis:E}:Object.assign({mainAxis:0,altAxis:0},E),O=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,A={x:0,y:0};if(k){if(o){var _,P="y"===w?Pf:jf,N="y"===w?Nf:Mf,M="y"===w?"height":"width",j=k[w],R=j+g[P],I=j-g[N],D=f?-C[M]/2:0,L=y===Df?S[M]:C[M],B=y===Df?-C[M]:-S[M],F=t.elements.arrow,z=f&&F?Sf(F):{width:0,height:0},H=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},$=H[P],U=H[N],W=vp(0,S[M],z[M]),V=b?S[M]/2-D-W-$-T.mainAxis:L-W-$-T.mainAxis,q=b?-S[M]/2+D+W+U+T.mainAxis:B+W+U+T.mainAxis,K=t.elements.arrow&&_f(t.elements.arrow),Q=K?"y"===w?K.clientTop||0:K.clientLeft||0:0,G=null!=(_=null==O?void 0:O[w])?_:0,J=j+q-G,Y=vp(f?hf(R,j+V-G-Q):R,j,f?uf(I,J):I);k[w]=Y,A[w]=Y-j}if(a){var X,Z="x"===w?Pf:jf,ee="x"===w?Nf:Mf,te=k[x],ne="y"===x?"height":"width",re=te+g[Z],ie=te-g[ee],oe=-1!==[Pf,jf].indexOf(v),se=null!=(X=null==O?void 0:O[x])?X:0,ae=oe?re:te-S[ne]-C[ne]-se+T.altAxis,le=oe?te+S[ne]+C[ne]-se-T.altAxis:ie,ce=f&&oe?function(e,t,n){var r=vp(e,t,n);return r>n?n:r}(ae,te,le):vp(f?ae:re,te,f?le:ie);k[x]=ce,A[x]=ce-te}t.modifiersData[r]=A}},requiresIfExists:["offset"]};const bp={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,r=e.name,i=e.options,o=n.elements.arrow,s=n.modifiersData.popperOffsets,a=Yf(n.placement),l=Zf(a),c=[jf,Mf].indexOf(a)>=0?"height":"width";if(o&&s){var u=function(e,t){return fp("number"!==typeof(e="function"===typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:pp(e,If))}(i.padding,n),h=Sf(o),d="y"===l?Pf:jf,f="y"===l?Nf:Mf,p=n.rects.reference[c]+n.rects.reference[l]-s[l]-n.rects.popper[c],m=s[l]-n.rects.reference[l],g=_f(o),v=g?"y"===l?g.clientHeight||0:g.clientWidth||0:0,y=p/2-m/2,b=u[d],w=v-h[c]-u[f],x=v/2-h[c]/2+y,k=vp(b,x,w),S=l;n.modifiersData[r]=((t={})[S]=k,t.centerOffset=k-x,t)}},effect:function(e){var t=e.state,n=e.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!==typeof r||(r=t.elements.popper.querySelector(r)))&&cp(t.elements.popper,r)&&(t.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function wp(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function xp(e){return[Pf,Mf,Nf,jf].some((function(t){return e[t]>=0}))}var kp=Gf({defaultModifiers:[{name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,o=void 0===i||i,s=r.resize,a=void 0===s||s,l=sf(t.elements.popper),c=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&c.forEach((function(e){e.addEventListener("scroll",n.update,Jf)})),a&&l.addEventListener("resize",n.update,Jf),function(){o&&c.forEach((function(e){e.removeEventListener("scroll",n.update,Jf)})),a&&l.removeEventListener("resize",n.update,Jf)}},data:{}},{name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,n=e.name;t.modifiersData[n]=ep({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},{name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=void 0===r||r,o=n.adaptive,s=void 0===o||o,a=n.roundOffsets,l=void 0===a||a,c={placement:Yf(t.placement),variation:Xf(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,np(Object.assign({},c,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:s,roundOffsets:l})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,np(Object.assign({},c,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},rp,ip,gp,yp,bp,{name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,o=t.modifiersData.preventOverflow,s=mp(t,{elementContext:"reference"}),a=mp(t,{altBoundary:!0}),l=wp(s,r),c=wp(a,i,o),u=xp(l),h=xp(c);t.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:h},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":h})}}]}),Sp=n(6366),Cp=n.n(Sp),Ep=[],Tp=function(){},Op=function(){return Promise.resolve(null)},Ap=[];function _p(e){var t=e.placement,n=void 0===t?"bottom":t,r=e.strategy,i=void 0===r?"absolute":r,o=e.modifiers,s=void 0===o?Ap:o,a=e.referenceElement,l=e.onFirstUpdate,c=e.innerRef,u=e.children,h=we.useContext(tf),d=we.useState(null),f=d[0],p=d[1],m=we.useState(null),g=m[0],v=m[1];we.useEffect((function(){nf(c,f)}),[c,f]);var y,b=we.useMemo((function(){return{placement:n,strategy:i,onFirstUpdate:l,modifiers:[].concat(s,[{name:"arrow",enabled:null!=g,options:{element:g}}])}}),[n,i,l,s,g]),w=function(e,t,n){void 0===n&&(n={});var r=we.useRef(null),i={onFirstUpdate:n.onFirstUpdate,placement:n.placement||"bottom",strategy:n.strategy||"absolute",modifiers:n.modifiers||Ep},o=we.useState({styles:{popper:{position:i.strategy,left:"0",top:"0"},arrow:{position:"absolute"}},attributes:{}}),s=o[0],a=o[1],l=we.useMemo((function(){return{name:"updateState",enabled:!0,phase:"write",fn:function(e){var t=e.state,n=Object.keys(t.elements);qo.flushSync((function(){a({styles:rf(n.map((function(e){return[e,t.styles[e]||{}]}))),attributes:rf(n.map((function(e){return[e,t.attributes[e]]})))})}))},requires:["computeStyles"]}}),[]),c=we.useMemo((function(){var e={onFirstUpdate:i.onFirstUpdate,placement:i.placement,strategy:i.strategy,modifiers:[].concat(i.modifiers,[l,{name:"applyStyles",enabled:!1}])};return Cp()(r.current,e)?r.current||e:(r.current=e,e)}),[i.onFirstUpdate,i.placement,i.strategy,i.modifiers,l]),u=we.useRef();return of((function(){u.current&&u.current.setOptions(c)}),[c]),of((function(){if(null!=e&&null!=t){var r=(n.createPopper||kp)(e,t,c);return u.current=r,function(){r.destroy(),u.current=null}}}),[e,t,n.createPopper]),{state:u.current?u.current.state:null,styles:s.styles,attributes:s.attributes,update:u.current?u.current.update:null,forceUpdate:u.current?u.current.forceUpdate:null}}(a||h,f,b),x=w.state,k=w.styles,S=w.forceUpdate,C=w.update,E=we.useMemo((function(){return{ref:p,style:k.popper,placement:x?x.placement:n,hasPopperEscaped:x&&x.modifiersData.hide?x.modifiersData.hide.hasPopperEscaped:null,isReferenceHidden:x&&x.modifiersData.hide?x.modifiersData.hide.isReferenceHidden:null,arrowProps:{style:k.arrow,ref:v},forceUpdate:S||Tp,update:C||Op}}),[p,v,n,x,k,C,S]);return(y=u,Array.isArray(y)?y[0]:y)(E)}const Pp=function(e,t,n,r){return si(e,(function(e,i,o){t(r,n(e),i,o)})),r};const Np=function(e,t){return function(n,r){return Pp(n,e,t(r),{})}};var Mp=Object.prototype.toString,jp=Np((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=Mp.call(t)),e[t]=n}),Oi(Zr));const Rp=jp;var Ip={"top center":"top","top left":"top-start","top right":"top-end","bottom center":"bottom","bottom left":"bottom-start","bottom right":"bottom-end","right center":"right","left center":"left"},Dp=(Xn(Ip),Rp(Ip));function Lp(e){return Lp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Lp(e)}function Bp(e){var t=function(e,t){if("object"!=Lp(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Lp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Lp(t)?t:t+""}function Fp(e,t){for(var n=0;n{var t;return null!==(t=e.countryCode)&&void 0!==t?t:"?"},Kp=e=>{let{users:t}=e;const n=e=>(e||{}).countryCode?(0,Ps.jsx)(ju,{name:e.countryCode.toLowerCase()}):(0,Ps.jsx)(fo,{className:"unknown-user-flag",name:"question"}),r=(0,we.useMemo)((()=>{const e=[...t].sort(((e,t)=>e.username.localeCompare(t.username))).reduce(((e,t)=>(("Online"===t.status?e.online:e.offline).push(t),e)),{offline:[],online:[]});return[...e.online,...e.offline]}),[t]);return(0,Ps.jsx)(na,{children:r.map((e=>(0,Ps.jsx)(na.Item,{className:e.self?"room-user-self":"",children:(0,Ps.jsxs)(na.Content,{style:{opacity:"Online"===e.status?1:.5},children:[(0,Ps.jsx)(Vp,{content:qp(e),trigger:n(e)}),e.username]})},e.username)))})},Qp={active:"",contextMenu:{message:null,open:!1,x:0,y:0},intervals:{messages:void 0,rooms:void 0},joined:[],loading:!1,room:{messages:[],users:[]}};class Gp extends we.Component{constructor(e){super(e),this.listRef=(0,we.createRef)(),this.messageRef=void 0,this.getFirstRoom=()=>this.state.joined.length>0?this.state.joined[0]:"",this.fetchJoinedRooms=async()=>{const e=await(async()=>{const e=(await ge.get("/rooms/joined")).data;if(Array.isArray(e))return e;console.warn("got non-array response from rooms API",e)})();this.setState({joined:e},(()=>{this.state.joined.includes(this.state.active)||this.selectRoom(this.getFirstRoom())}))},this.fetchActiveRoom=async()=>{const{active:e}=this.state;if(0===e.length)return;const t=await(async e=>{let{roomName:t}=e;const n=(await ge.get(`/rooms/joined/${encodeURIComponent(t)}/messages`)).data;if(Array.isArray(n))return n;console.warn("got non-array response from rooms API",n)})({roomName:e}),n=await(async e=>{let{roomName:t}=e;const n=(await ge.get(`/rooms/joined/${encodeURIComponent(t)}/users`)).data;if(Array.isArray(n))return n;console.warn("got non-array response from rooms API",n)})({roomName:e});this.setState({room:{messages:t,users:n}})},this.selectRoom=async e=>{this.setState({active:e,loading:!0,room:Qp.room},(async()=>{const{active:e}=this.state;sessionStorage.setItem(l,e),await this.fetchActiveRoom(),this.setState({loading:!1},(()=>{try{this.listRef.current.lastChild.scrollIntoView()}catch{}}))}))},this.joinRoom=async e=>{await(async e=>{let{roomName:t}=e;return ge.post("/rooms/joined",t)})({roomName:e}),await this.fetchJoinedRooms(),this.selectRoom(e)},this.leaveRoom=async e=>{await(async e=>{let{roomName:t}=e;return ge.delete(`/rooms/joined/${encodeURIComponent(t)}`)})({roomName:e}),await this.fetchJoinedRooms(),this.selectRoom(this.getFirstRoom())},this.validInput=()=>(this.state.active||"").length>0&&(this.messageRef&&this.messageRef.current&&this.messageRef.current.value||"").length>0,this.focusInput=()=>{this.messageRef.current.focus()},this.formatTimestamp=e=>{const t=new Date(e);return new Intl.DateTimeFormat("en",{day:"numeric",hour:"numeric",minute:"2-digit",month:"numeric"}).format(t)},this.sendMessage=async()=>{const{active:e}=this.state,t=this.messageRef.current.value;this.validInput()&&(await(async e=>{let{roomName:t,message:n}=e;return ge.post(`/rooms/joined/${encodeURIComponent(t)}/messages`,JSON.stringify(n))})({message:t,roomName:e}),this.messageRef.current.value="")},this.handleContextMenu=(e,t)=>{e.preventDefault(),this.setState({contextMenu:{message:t,open:!0,x:e.pageX,y:e.pageY}})},this.handleCloseContextMenu=()=>{this.setState((e=>({contextMenu:{...e.contextMenu,open:!1}})))},this.handleReply=()=>{this.messageRef.current.value=`[${this.state.contextMenu.message.username}] ${this.state.contextMenu.message.message} --\x3e `,this.focusInput()},this.handleUserProfile=()=>{this.props.history.push("/users",{user:this.state.contextMenu.message.username})},this.handleBrowseShares=()=>{this.props.history.push("/browse",{user:this.state.contextMenu.message.username})},this.state=Qp}componentDidMount(){this.setState({active:sessionStorage.getItem(l)||"",intervals:{messages:window.setInterval(this.fetchActiveRoom,1e3),rooms:window.setInterval(this.fetchJoinedRooms,500)}},(async()=>{await this.fetchJoinedRooms(),this.selectRoom(this.state.active||this.getFirstRoom()),document.addEventListener("click",this.handleCloseContextMenu)}))}componentWillUnmount(){const{messages:e,rooms:t}=this.state.intervals;clearInterval(t),clearInterval(e),document.removeEventListener("click",this.handleCloseContextMenu),this.setState({intervals:Qp.intervals})}renderContextMenu(){const{contextMenu:e}=this.state;return(0,Ps.jsx)(us,{open:e.open,children:(0,Ps.jsxs)("div",{className:"ui vertical buttons popup-menu",style:{left:e.x,maxHeight:`calc(100vh - ${e.y}px)`,top:e.y},children:[(0,Ps.jsx)($a,{className:"ui compact button popup-option",onClick:this.handleReply,children:"Reply"}),(0,Ps.jsx)($a,{className:"ui compact button popup-option",onClick:this.handleUserProfile,children:"User Profile"}),(0,Ps.jsx)($a,{className:"ui compact button popup-option",onClick:this.handleBrowseShares,children:"Browse Shares"})]})})}render(){const{active:e=[],joined:t=[],loading:n,room:r}=this.state;return(0,Ps.jsxs)("div",{className:"rooms",children:[(0,Ps.jsxs)(vi,{className:"rooms-segment",raised:!0,children:[(0,Ps.jsx)("div",{className:"rooms-segment-icon",children:(0,Ps.jsx)(fo,{name:"comments",size:"big"})}),(0,Ps.jsx)(Zd,{active:e,joinRoom:this.joinRoom,joined:t,onRoomChange:e=>this.selectRoom(e)})]}),0===(null===e||void 0===e?void 0:e.length)?(0,Ps.jsx)(Ns,{caption:"No rooms to display",icon:"comments"}):(0,Ps.jsx)(Ra,{className:"room-active-card",raised:!0,children:(0,Ps.jsxs)(Ra.Content,{onClick:()=>this.focusInput(),children:[(0,Ps.jsxs)(Ra.Header,{children:[(0,Ps.jsx)(fo,{color:"green",name:"circle"}),e,(0,Ps.jsx)(fo,{className:"close-button",color:"red",link:!0,name:"close",onClick:()=>this.leaveRoom(e)})]}),(0,Ps.jsx)("div",{className:"room",children:n?(0,Ps.jsx)(ps,{active:!0,inverted:!0,children:(0,Ps.jsx)(ac,{inverted:!0})}):(0,Ps.jsxs)(Ps.Fragment,{children:[(0,Ps.jsxs)(vi.Group,{children:[(0,Ps.jsx)(vi,{className:"room-history",children:(0,Ps.jsx)(Jo,{innerRef:this.listRef,children:(0,Ps.jsxs)(na,{children:[r.messages.map((e=>(0,Ps.jsx)("div",{onContextMenu:t=>this.handleContextMenu(t,e),children:(0,Ps.jsxs)(na.Content,{className:"room-message "+(e.self?"room-message-self":""),children:[(0,Ps.jsx)("span",{className:"room-message-time",children:this.formatTimestamp(e.timestamp)}),(0,Ps.jsxs)("span",{className:"room-message-name",children:[e.username,":"," "]}),(0,Ps.jsx)("span",{className:"room-message-message",children:e.message})]})},`${e.timestamp}+${e.message}`))),(0,Ps.jsx)(na.Content,{id:"room-history-scroll-anchor"})]})})}),(0,Ps.jsx)(vi,{className:"room-input",children:(0,Ps.jsx)(oc,{action:{className:"room-message-button",disabled:!this.validInput(),icon:(0,Ps.jsx)(fo,{color:"green",name:"send"}),onClick:this.sendMessage},fluid:!0,input:(0,Ps.jsx)("input",{autoComplete:"off","data-lpignore":"true",id:"room-message-input",type:"text"}),onKeyUp:e=>"Enter"===e.key?this.sendMessage():"",ref:e=>this.messageRef=e&&e.inputRef,transparent:!0})})]}),(0,Ps.jsx)(vi,{className:"room-users",children:(0,Ps.jsx)(Kp,{users:r.users})})]})})]})}),this.renderContextMenu()]})}}const Jp=Zl(Gp),Yp=(e,t,n)=>{const r=e.match(t);if(r)return Number.parseInt(r[n],10)},Xp=e=>{let{caption:t,icon:n="x",suppressPrefix:r=!1}=e;return(0,Ps.jsx)(vi,{basic:!0,className:"error-segment",placeholder:!0,children:(0,Ps.jsxs)(_s,{icon:!0,children:[(0,Ps.jsx)(fo,{color:"red",name:n}),!r&&"Error: ",t]})})},Zp=e=>{let{children:t,size:n="big",...r}=e;return(0,Ps.jsx)(vi,{basic:!0,className:"loader-segment",placeholder:!0,children:(0,Ps.jsx)(ac,{active:!0,size:n,...r,children:t})})},em=e=>{let{children:t,...n}=e;const r=Object.values(n);for(const i of r)if(i)return i;return t},tm=e=>"number"==typeof e&&!isNaN(e),nm=e=>"string"==typeof e,rm=e=>"function"==typeof e,im=e=>nm(e)||rm(e)?e:null,om=e=>(0,we.isValidElement)(e)||nm(e)||rm(e)||tm(e);function sm(e){let{enter:t,exit:n,appendPosition:r=!1,collapse:i=!0,collapseDuration:o=300}=e;return function(e){let{children:s,position:a,preventExitTransition:l,done:c,nodeRef:u,isIn:h}=e;const d=r?`${t}--${a}`:t,f=r?`${n}--${a}`:n,p=(0,we.useRef)(0);return(0,we.useLayoutEffect)((()=>{const e=u.current,t=d.split(" "),n=r=>{r.target===u.current&&(e.dispatchEvent(new Event("d")),e.removeEventListener("animationend",n),e.removeEventListener("animationcancel",n),0===p.current&&"animationcancel"!==r.type&&e.classList.remove(...t))};e.classList.add(...t),e.addEventListener("animationend",n),e.addEventListener("animationcancel",n)}),[]),(0,we.useEffect)((()=>{const e=u.current,t=()=>{e.removeEventListener("animationend",t),i?function(e,t,n){void 0===n&&(n=300);const{scrollHeight:r,style:i}=e;requestAnimationFrame((()=>{i.minHeight="initial",i.height=r+"px",i.transition=`all ${n}ms`,requestAnimationFrame((()=>{i.height="0",i.padding="0",i.margin="0",setTimeout(t,n)}))}))}(e,c,o):c()};h||(l?t():(p.current=1,e.className+=` ${f}`,e.addEventListener("animationend",t)))}),[h]),we.createElement(we.Fragment,null,s)}}function am(e,t){return null!=e?{content:e.content,containerId:e.props.containerId,id:e.props.toastId,theme:e.props.theme,type:e.props.type,data:e.props.data||{},isLoading:e.props.isLoading,icon:e.props.icon,status:t}:{}}const lm={list:new Map,emitQueue:new Map,on(e,t){return this.list.has(e)||this.list.set(e,[]),this.list.get(e).push(t),this},off(e,t){if(t){const n=this.list.get(e).filter((e=>e!==t));return this.list.set(e,n),this}return this.list.delete(e),this},cancelEmit(e){const t=this.emitQueue.get(e);return t&&(t.forEach(clearTimeout),this.emitQueue.delete(e)),this},emit(e){this.list.has(e)&&this.list.get(e).forEach((t=>{const n=setTimeout((()=>{t(...[].slice.call(arguments,1))}),0);this.emitQueue.has(e)||this.emitQueue.set(e,[]),this.emitQueue.get(e).push(n)}))}},cm=e=>{let{theme:t,type:n,...r}=e;return we.createElement("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:"colored"===t?"currentColor":`var(--toastify-icon-color-${n})`,...r})},um={info:function(e){return we.createElement(cm,{...e},we.createElement("path",{d:"M12 0a12 12 0 1012 12A12.013 12.013 0 0012 0zm.25 5a1.5 1.5 0 11-1.5 1.5 1.5 1.5 0 011.5-1.5zm2.25 13.5h-4a1 1 0 010-2h.75a.25.25 0 00.25-.25v-4.5a.25.25 0 00-.25-.25h-.75a1 1 0 010-2h1a2 2 0 012 2v4.75a.25.25 0 00.25.25h.75a1 1 0 110 2z"}))},warning:function(e){return we.createElement(cm,{...e},we.createElement("path",{d:"M23.32 17.191L15.438 2.184C14.728.833 13.416 0 11.996 0c-1.42 0-2.733.833-3.443 2.184L.533 17.448a4.744 4.744 0 000 4.368C1.243 23.167 2.555 24 3.975 24h16.05C22.22 24 24 22.044 24 19.632c0-.904-.251-1.746-.68-2.44zm-9.622 1.46c0 1.033-.724 1.823-1.698 1.823s-1.698-.79-1.698-1.822v-.043c0-1.028.724-1.822 1.698-1.822s1.698.79 1.698 1.822v.043zm.039-12.285l-.84 8.06c-.057.581-.408.943-.897.943-.49 0-.84-.367-.896-.942l-.84-8.065c-.057-.624.25-1.095.779-1.095h1.91c.528.005.84.476.784 1.1z"}))},success:function(e){return we.createElement(cm,{...e},we.createElement("path",{d:"M12 0a12 12 0 1012 12A12.014 12.014 0 0012 0zm6.927 8.2l-6.845 9.289a1.011 1.011 0 01-1.43.188l-4.888-3.908a1 1 0 111.25-1.562l4.076 3.261 6.227-8.451a1 1 0 111.61 1.183z"}))},error:function(e){return we.createElement(cm,{...e},we.createElement("path",{d:"M11.983 0a12.206 12.206 0 00-8.51 3.653A11.8 11.8 0 000 12.207 11.779 11.779 0 0011.8 24h.214A12.111 12.111 0 0024 11.791 11.766 11.766 0 0011.983 0zM10.5 16.542a1.476 1.476 0 011.449-1.53h.027a1.527 1.527 0 011.523 1.47 1.475 1.475 0 01-1.449 1.53h-.027a1.529 1.529 0 01-1.523-1.47zM11 12.5v-6a1 1 0 012 0v6a1 1 0 11-2 0z"}))},spinner:function(){return we.createElement("div",{className:"Toastify__spinner"})}};function hm(e){const[,t]=(0,we.useReducer)((e=>e+1),0),[n,r]=(0,we.useState)([]),i=(0,we.useRef)(null),o=(0,we.useRef)(new Map).current,s=e=>-1!==n.indexOf(e),a=(0,we.useRef)({toastKey:1,displayedToast:0,count:0,queue:[],props:e,containerId:null,isToastActive:s,getToast:e=>o.get(e)}).current;function l(e){let{containerId:t}=e;const{limit:n}=a.props;!n||t&&a.containerId!==t||(a.count-=a.queue.length,a.queue=[])}function c(e){r((t=>null==e?[]:t.filter((t=>t!==e))))}function u(){const{toastContent:e,toastProps:t,staleId:n}=a.queue.shift();d(e,t,n)}function h(e,n){let{delay:r,staleId:s,...l}=n;if(!om(e)||function(e){return!i.current||a.props.enableMultiContainer&&e.containerId!==a.props.containerId||o.has(e.toastId)&&null==e.updateId}(l))return;const{toastId:h,updateId:f,data:p}=l,{props:m}=a,g=()=>c(h),v=null==f;v&&a.count++;const y={...m,style:m.toastStyle,key:a.toastKey++,...Object.fromEntries(Object.entries(l).filter((e=>{let[t,n]=e;return null!=n}))),toastId:h,updateId:f,data:p,closeToast:g,isIn:!1,className:im(l.className||m.toastClassName),bodyClassName:im(l.bodyClassName||m.bodyClassName),progressClassName:im(l.progressClassName||m.progressClassName),autoClose:!l.isLoading&&(b=l.autoClose,w=m.autoClose,!1===b||tm(b)&&b>0?b:w),deleteToast(){const e=am(o.get(h),"removed");o.delete(h),lm.emit(4,e);const n=a.queue.length;if(a.count=null==h?a.count-a.displayedToast:a.count-1,a.count<0&&(a.count=0),n>0){const e=null==h?a.props.limit:1;if(1===n||1===e)a.displayedToast++,u();else{const t=e>n?n:e;a.displayedToast=t;for(let e=0;ee in um)(n)&&(o=um[n](s))),o}(y),rm(l.onOpen)&&(y.onOpen=l.onOpen),rm(l.onClose)&&(y.onClose=l.onClose),y.closeButton=m.closeButton,!1===l.closeButton||om(l.closeButton)?y.closeButton=l.closeButton:!0===l.closeButton&&(y.closeButton=!om(m.closeButton)||m.closeButton);let x=e;(0,we.isValidElement)(e)&&!nm(e.type)?x=(0,we.cloneElement)(e,{closeToast:g,toastProps:y,data:p}):rm(e)&&(x=e({closeToast:g,toastProps:y,data:p})),m.limit&&m.limit>0&&a.count>m.limit&&v?a.queue.push({toastContent:x,toastProps:y,staleId:s}):tm(r)?setTimeout((()=>{d(x,y,s)}),r):d(x,y,s)}function d(e,t,n){const{toastId:i}=t;n&&o.delete(n);const s={content:e,props:t};o.set(i,s),r((e=>[...e,i].filter((e=>e!==n)))),lm.emit(4,am(s,null==s.props.updateId?"added":"updated"))}return(0,we.useEffect)((()=>(a.containerId=e.containerId,lm.cancelEmit(3).on(0,h).on(1,(e=>i.current&&c(e))).on(5,l).emit(2,a),()=>{o.clear(),lm.emit(3,a)})),[]),(0,we.useEffect)((()=>{a.props=e,a.isToastActive=s,a.displayedToast=n.length})),{getToastToRender:function(t){const n=new Map,r=Array.from(o.values());return e.newestOnTop&&r.reverse(),r.forEach((e=>{const{position:t}=e.props;n.has(t)||n.set(t,[]),n.get(t).push(e)})),Array.from(n,(e=>t(e[0],e[1])))},containerRef:i,isToastActive:s}}function dm(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientX:e.clientX}function fm(e){return e.targetTouches&&e.targetTouches.length>=1?e.targetTouches[0].clientY:e.clientY}function pm(e){const[t,n]=(0,we.useState)(!1),[r,i]=(0,we.useState)(!1),o=(0,we.useRef)(null),s=(0,we.useRef)({start:0,x:0,y:0,delta:0,removalDistance:0,canCloseOnClick:!0,canDrag:!1,boundingRect:null,didMove:!1}).current,a=(0,we.useRef)(e),{autoClose:l,pauseOnHover:c,closeToast:u,onClick:h,closeOnClick:d}=e;function f(t){if(e.draggable){"touchstart"===t.nativeEvent.type&&t.nativeEvent.preventDefault(),s.didMove=!1,document.addEventListener("mousemove",v),document.addEventListener("mouseup",y),document.addEventListener("touchmove",v),document.addEventListener("touchend",y);const n=o.current;s.canCloseOnClick=!0,s.canDrag=!0,s.boundingRect=n.getBoundingClientRect(),n.style.transition="",s.x=dm(t.nativeEvent),s.y=fm(t.nativeEvent),"x"===e.draggableDirection?(s.start=s.x,s.removalDistance=n.offsetWidth*(e.draggablePercent/100)):(s.start=s.y,s.removalDistance=n.offsetHeight*(80===e.draggablePercent?1.5*e.draggablePercent:e.draggablePercent/100))}}function p(t){if(s.boundingRect){const{top:n,bottom:r,left:i,right:o}=s.boundingRect;"touchend"!==t.nativeEvent.type&&e.pauseOnHover&&s.x>=i&&s.x<=o&&s.y>=n&&s.y<=r?g():m()}}function m(){n(!0)}function g(){n(!1)}function v(n){const r=o.current;s.canDrag&&r&&(s.didMove=!0,t&&g(),s.x=dm(n),s.y=fm(n),s.delta="x"===e.draggableDirection?s.x-s.start:s.y-s.start,s.start!==s.x&&(s.canCloseOnClick=!1),r.style.transform=`translate${e.draggableDirection}(${s.delta}px)`,r.style.opacity=""+(1-Math.abs(s.delta/s.removalDistance)))}function y(){document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",y),document.removeEventListener("touchmove",v),document.removeEventListener("touchend",y);const t=o.current;if(s.canDrag&&s.didMove&&t){if(s.canDrag=!1,Math.abs(s.delta)>s.removalDistance)return i(!0),void e.closeToast();t.style.transition="transform 0.2s, opacity 0.2s",t.style.transform=`translate${e.draggableDirection}(0)`,t.style.opacity="1"}}(0,we.useEffect)((()=>{a.current=e})),(0,we.useEffect)((()=>(o.current&&o.current.addEventListener("d",m,{once:!0}),rm(e.onOpen)&&e.onOpen((0,we.isValidElement)(e.children)&&e.children.props),()=>{const e=a.current;rm(e.onClose)&&e.onClose((0,we.isValidElement)(e.children)&&e.children.props)})),[]),(0,we.useEffect)((()=>(e.pauseOnFocusLoss&&(document.hasFocus()||g(),window.addEventListener("focus",m),window.addEventListener("blur",g)),()=>{e.pauseOnFocusLoss&&(window.removeEventListener("focus",m),window.removeEventListener("blur",g))})),[e.pauseOnFocusLoss]);const b={onMouseDown:f,onTouchStart:f,onMouseUp:p,onTouchEnd:p};return l&&c&&(b.onMouseEnter=g,b.onMouseLeave=m),d&&(b.onClick=e=>{h&&h(e),s.canCloseOnClick&&u()}),{playToast:m,pauseToast:g,isRunning:t,preventExitTransition:r,toastRef:o,eventHandlers:b}}function mm(e){let{closeToast:t,theme:n,ariaLabel:r="close"}=e;return we.createElement("button",{className:`Toastify__close-button Toastify__close-button--${n}`,type:"button",onClick:e=>{e.stopPropagation(),t(e)},"aria-label":r},we.createElement("svg",{"aria-hidden":"true",viewBox:"0 0 14 16"},we.createElement("path",{fillRule:"evenodd",d:"M7.71 8.23l3.75 3.75-1.48 1.48-3.75-3.75-3.75 3.75L1 11.98l3.75-3.75L1 4.48 2.48 3l3.75 3.75L9.98 3l1.48 1.48-3.75 3.75z"})))}function gm(e){let{delay:t,isRunning:n,closeToast:r,type:i="default",hide:o,className:s,style:a,controlledProgress:l,progress:c,rtl:u,isIn:h,theme:d}=e;const f=o||l&&0===c,p={...a,animationDuration:`${t}ms`,animationPlayState:n?"running":"paused",opacity:f?0:1};l&&(p.transform=`scaleX(${c})`);const m=Oe("Toastify__progress-bar",l?"Toastify__progress-bar--controlled":"Toastify__progress-bar--animated",`Toastify__progress-bar-theme--${d}`,`Toastify__progress-bar--${i}`,{"Toastify__progress-bar--rtl":u}),g=rm(s)?s({rtl:u,type:i,defaultClassName:m}):Oe(m,s);return we.createElement("div",{role:"progressbar","aria-hidden":f?"true":"false","aria-label":"notification timer",className:g,style:p,[l&&c>=1?"onTransitionEnd":"onAnimationEnd"]:l&&c<1?null:()=>{h&&r()}})}const vm=e=>{const{isRunning:t,preventExitTransition:n,toastRef:r,eventHandlers:i}=pm(e),{closeButton:o,children:s,autoClose:a,onClick:l,type:c,hideProgressBar:u,closeToast:h,transition:d,position:f,className:p,style:m,bodyClassName:g,bodyStyle:v,progressClassName:y,progressStyle:b,updateId:w,role:x,progress:k,rtl:S,toastId:C,deleteToast:E,isIn:T,isLoading:O,iconOut:A,closeOnClick:_,theme:P}=e,N=Oe("Toastify__toast",`Toastify__toast-theme--${P}`,`Toastify__toast--${c}`,{"Toastify__toast--rtl":S},{"Toastify__toast--close-on-click":_}),M=rm(p)?p({rtl:S,position:f,type:c,defaultClassName:N}):Oe(N,p),j=!!k||!a,R={closeToast:h,type:c,theme:P};let I=null;return!1===o||(I=rm(o)?o(R):(0,we.isValidElement)(o)?(0,we.cloneElement)(o,R):mm(R)),we.createElement(d,{isIn:T,done:E,position:f,preventExitTransition:n,nodeRef:r},we.createElement("div",{id:C,onClick:l,className:M,...i,style:m,ref:r},we.createElement("div",{...T&&{role:x},className:rm(g)?g({type:c}):Oe("Toastify__toast-body",g),style:v},null!=A&&we.createElement("div",{className:Oe("Toastify__toast-icon",{"Toastify--animate-icon Toastify__zoom-enter":!O})},A),we.createElement("div",null,s)),I,we.createElement(gm,{...w&&!j?{key:`pb-${w}`}:{},rtl:S,theme:P,delay:a,isRunning:t,isIn:T,closeToast:h,hide:u,type:c,style:b,className:y,controlledProgress:j,progress:k||0})))},ym=function(e,t){return void 0===t&&(t=!1),{enter:`Toastify--animate Toastify__${e}-enter`,exit:`Toastify--animate Toastify__${e}-exit`,appendPosition:t}},bm=sm(ym("bounce",!0)),wm=(sm(ym("slide",!0)),sm(ym("zoom")),sm(ym("flip")),(0,we.forwardRef)(((e,t)=>{const{getToastToRender:n,containerRef:r,isToastActive:i}=hm(e),{className:o,style:s,rtl:a,containerId:l}=e;function c(e){const t=Oe("Toastify__toast-container",`Toastify__toast-container--${e}`,{"Toastify__toast-container--rtl":a});return rm(o)?o({position:e,rtl:a,defaultClassName:t}):Oe(t,im(o))}return(0,we.useEffect)((()=>{t&&(t.current=r.current)}),[]),we.createElement("div",{ref:r,className:"Toastify",id:l},n(((e,t)=>{const n=t.length?{...s}:{...s,pointerEvents:"none"};return we.createElement("div",{className:c(e),style:n,key:`container-${e}`},t.map(((e,n)=>{let{content:r,props:o}=e;return we.createElement(vm,{...o,isIn:i(o.toastId),style:{...o.style,"--nth":n+1,"--len":t.length},key:`toast-${o.key}`},r)})))})))})));wm.displayName="ToastContainer",wm.defaultProps={position:"top-right",transition:bm,autoClose:5e3,closeButton:mm,pauseOnHover:!0,pauseOnFocusLoss:!0,closeOnClick:!0,draggable:!0,draggablePercent:80,draggableDirection:"x",role:"alert",theme:"light"};let xm,km=new Map,Sm=[],Cm=1;function Em(){return""+Cm++}function Tm(e){return e&&(nm(e.toastId)||tm(e.toastId))?e.toastId:Em()}function Om(e,t){return km.size>0?lm.emit(0,e,t):Sm.push({content:e,options:t}),t.toastId}function Am(e,t){return{...t,type:t&&t.type||e,toastId:Tm(t)}}function _m(e){return(t,n)=>Om(t,Am(e,n))}function Pm(e,t){return Om(e,Am("default",t))}Pm.loading=(e,t)=>Om(e,Am("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...t})),Pm.promise=function(e,t,n){let r,{pending:i,error:o,success:s}=t;i&&(r=nm(i)?Pm.loading(i,n):Pm.loading(i.render,{...n,...i}));const a={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},l=(e,t,i)=>{if(null==t)return void Pm.dismiss(r);const o={type:e,...a,...n,data:i},s=nm(t)?{render:t}:t;return r?Pm.update(r,{...o,...s}):Pm(s.render,{...o,...s}),i},c=rm(e)?e():e;return c.then((e=>l("success",s,e))).catch((e=>l("error",o,e))),c},Pm.success=_m("success"),Pm.info=_m("info"),Pm.error=_m("error"),Pm.warning=_m("warning"),Pm.warn=Pm.warning,Pm.dark=(e,t)=>Om(e,Am("default",{theme:"dark",...t})),Pm.dismiss=e=>{km.size>0?lm.emit(1,e):Sm=Sm.filter((t=>null!=e&&t.options.toastId!==e))},Pm.clearWaitingQueue=function(e){return void 0===e&&(e={}),lm.emit(5,e)},Pm.isActive=e=>{let t=!1;return km.forEach((n=>{n.isToastActive&&n.isToastActive(e)&&(t=!0)})),t},Pm.update=function(e,t){void 0===t&&(t={}),setTimeout((()=>{const n=function(e,t){let{containerId:n}=t;const r=km.get(n||xm);return r&&r.getToast(e)}(e,t);if(n){const{props:r,content:i}=n,o={delay:100,...r,...t,toastId:t.toastId||e,updateId:Em()};o.toastId!==e&&(o.staleId=e);const s=o.render||i;delete o.render,Om(s,o)}}),0)},Pm.done=e=>{Pm.update(e,{progress:1})},Pm.onChange=e=>(lm.on(4,e),()=>{lm.off(4,e)}),Pm.POSITION={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",TOP_CENTER:"top-center",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",BOTTOM_CENTER:"bottom-center"},Pm.TYPE={INFO:"info",SUCCESS:"success",WARNING:"warning",ERROR:"error",DEFAULT:"default"},lm.on(2,(e=>{xm=e.containerId||e,km.set(xm,e),Sm.forEach((e=>{lm.emit(0,e.content,e.options)})),Sm=[]})).on(3,(e=>{km.delete(e.containerId||e),0===km.size&&lm.off(0).off(1).off(5)}));const Nm=e=>{let{files:t=[]}=e;const{lockedFiles:n=[]}=e;return t=t.concat(n.map((e=>({...e,locked:!0})))),t.reduce(((e,t)=>{const n=(e=>{let t=e;return t.lastIndexOf("\\")>0&&(t=t.slice(0,Math.max(0,t.lastIndexOf("\\")))),t.lastIndexOf("/")>0&&(t=t.slice(0,Math.max(0,t.lastIndexOf("/")))),t})(t.filename),r={selected:!1,...t};return e[n]=void 0===e[n]?[r]:e[n].concat(r),e}),{})};class Mm extends we.Component{constructor(e){super(e),this.handleFileSelectionChange=(e,t)=>{e.selected=t,this.setState((e=>({downloadError:"",downloadRequest:void 0,tree:e.tree})))},this.download=(e,t)=>{this.setState({downloadRequest:"inProgress"},(async()=>{try{const n=(t||[]).map((e=>{let{filename:t,size:n}=e;return{filename:t,size:n}}));await Ms({files:n,username:e}),this.setState({downloadRequest:"complete"})}catch(n){this.setState({downloadError:n.response,downloadRequest:"error"})}}))},this.getFullDirectory=async(e,t)=>{this.setState({fetchingDirectoryContents:!0});try{const n={...this.state.tree},r=n[t];try{const i=await(async e=>{let{username:t,directory:n}=e;return(await ge.post(`/users/${encodeURIComponent(t)}/directory`,{directory:n})).data})({directory:t,username:e}),o=null===i||void 0===i?void 0:i[0];if(!o)throw new Error("No directories were included in the response");const{files:s,name:a}=o,l=s.map((e=>{var n,i;return{...e,filename:`${t}\\${e.filename}`,selected:null!==(n=null===(i=r.find((n=>n.filename===`${t}\\${e.filename}`)))||void 0===i?void 0:i.selected)&&void 0!==n&&n}}));n[a]=l,this.setState({tree:{...n}})}catch(o){throw new Error(`Failed to process directory response: ${o}`,{cause:o})}}catch(o){var n,r,i;console.error(o),Pm.error(null!==(n=null!==(r=null===o||void 0===o||null===(i=o.response)||void 0===i?void 0:i.data)&&void 0!==r?r:null===o||void 0===o?void 0:o.message)&&void 0!==n?n:o)}finally{this.setState({fetchingDirectoryContents:!1})}},this.handleToggleFolded=()=>{this.setState((e=>({isFolded:!e.isFolded})))},this.state={downloadError:"",downloadRequest:void 0,fetchingDirectoryContents:!1,isFolded:this.props.isInitiallyFolded,tree:Nm(this.props.response)}}componentDidUpdate(e){JSON.stringify(this.props.response)!==JSON.stringify(e.response)&&this.setState({tree:Nm(this.props.response)}),this.props.isInitiallyFolded!==e.isInitiallyFolded&&this.setState({isFolded:this.props.isInitiallyFolded})}render(){const{response:e}=this.props,t=e.hasFreeUploadSlot,{downloadError:n,downloadRequest:r,fetchingDirectoryContents:i,isFolded:o,tree:s}=this.state,a=Object.keys(s).reduce(((e,t)=>e.concat(s[t])),[]).filter((e=>e.selected)),l=Ls(a.reduce(((e,t)=>e+t.size),0));return(0,Ps.jsxs)(Ra,{className:"result-card",raised:!0,children:[(0,Ps.jsxs)(Ra.Content,{children:[(0,Ps.jsxs)(Ra.Header,{children:[(0,Ps.jsx)(fo,{link:!0,name:o?"chevron right":"chevron down",onClick:this.handleToggleFolded}),(0,Ps.jsx)(fo,{color:t?"green":"yellow",name:"circle"}),e.username,(0,Ps.jsx)(fo,{className:"close-button",color:"red",link:!0,name:"close",onClick:()=>this.props.onHide()})]}),(0,Ps.jsx)(Ra.Meta,{className:"result-meta",children:(0,Ps.jsxs)("span",{children:["Upload Speed: ",Ls(e.uploadSpeed),"/s, Free Upload Slot: ",t?"YES":"NO",", Queue Length: ",e.queueLength]})}),(!o&&Object.keys(s)||[]).map((t=>(0,Ps.jsx)(Sa,{directoryName:t,disabled:"inProgress"===r,files:s[t],footer:(0,Ps.jsxs)("button",{disabled:i,onClick:()=>this.getFullDirectory(e.username,t),style:{backgroundColor:"transparent",border:"none",cursor:"pointer",width:"100%"},type:"button",children:[(0,Ps.jsx)(fo,{loading:i,name:i?"circle notch":"folder"}),"Get Full Directory Contents"]}),locked:s[t].find((e=>e.locked)),onSelectionChange:this.handleFileSelectionChange},t)))]}),a.length>0&&(0,Ps.jsx)(Ra.Content,{extra:!0,children:(0,Ps.jsxs)("span",{children:[(0,Ps.jsx)($a,{color:"green",content:"Download",disabled:this.props.disabled||"inProgress"===r,icon:"download",label:{as:"a",basic:!1,content:`${a.length} file${1===a.length?"":"s"}, ${l}`},labelPosition:"right",onClick:()=>this.download(e.username,a)}),"inProgress"===r&&(0,Ps.jsx)(fo,{loading:!0,name:"circle notch",size:"large"}),"complete"===r&&(0,Ps.jsx)(fo,{color:"green",name:"checkmark",size:"large"}),"error"===r&&(0,Ps.jsxs)("span",{children:[(0,Ps.jsx)(fo,{color:"red",name:"x",size:"large"}),(0,Ps.jsx)(bs,{children:n.data+` (HTTP ${n.status} ${n.statusText})`})]})]})})]})}}const jm=Mm,Rm=e=>{let{state:t,...n}=e;switch(t){case"None":case"Queued":case"Requested":return(0,Ps.jsx)(fo,{name:"time",...n});case"InProgress":return(0,Ps.jsx)(fo,{color:"green",loading:!0,name:"circle notch",...n});case"Completed, TimedOut":case"Completed, ResponseLimitReached":case"Completed, FileLimitReached":return(0,Ps.jsx)(fo,{color:"green",name:"check",...n});case"Completed, Cancelled":return(0,Ps.jsx)(fo,{color:"green",name:"stop circle",...n});case"Completed, Errored":return(0,Ps.jsx)(fo,{color:"red",name:"x",...n});default:return(0,Ps.jsx)(fo,{color:"yellow",name:"question circle",...n})}},Im=e=>{let{state:t,...n}=e;return(0,Ps.jsx)(Vp,{content:t,trigger:Rm({state:t,...n})})};var Dm=n(5237);const Lm=e=>{let{creating:t,disabled:n,isSmallScreen:r,isTinyScreen:i,loaded:o,onCreate:s,searchText:a,working:l}=e;return o&&(0,Ps.jsxs)($a,{disabled:n||l,icon:r&&!i,loading:t,onClick:()=>s({navigate:!0,search:a}),children:[(0,Ps.jsx)(fo,{name:"refresh"}),(!r||i)&&"Search Again"]})},Bm=e=>{let{isComplete:t,isSmallScreen:n,isTinyScreen:r,loaded:i,removing:o,stopOrRemove:s,stopping:a,working:l}=e;return(0,Ps.jsxs)($a,{disabled:l,floated:r?"right":void 0,icon:n&&!r,loading:o||a,negative:!0,onClick:s,children:[(0,Ps.jsx)(fo,{name:t?"trash alternate":"stop circle"}),(!n||r)&&(i&&t?"Delete":"Stop")]})},Fm=e=>{let{creating:t,disabled:n,loaded:r,loading:i,onCreate:o,onRemove:s,onStop:a,removing:l,search:c,stopping:u}=e;const h=(0,Dm.useMediaQuery)({query:"(max-width: 899px)"}),d=(0,Dm.useMediaQuery)({query:"(max-width: 684px)"}),{isComplete:f,searchText:p,state:m}=c,g=i||t||l||u,v=()=>{f?s(c):a(c)};return(0,Ps.jsxs)(Ps.Fragment,{children:[(0,Ps.jsxs)(vi,{className:"search-detail-header-segment",raised:!0,children:[(0,Ps.jsxs)(_s,{children:[(0,Ps.jsx)(Im,{state:m}),p]}),!d&&(0,Ps.jsxs)("div",{className:"search-detail-header-buttons",children:[(0,Ps.jsx)(Lm,{creating:t,disabled:n,isSmallScreen:h,isTinyScreen:d,loaded:r,onCreate:o,searchText:p,working:g}),(0,Ps.jsx)(Bm,{isComplete:f,isSmallScreen:h,isTinyScreen:d,loaded:r,removing:l,stopOrRemove:v,stopping:u,working:g})]})]}),d&&(0,Ps.jsxs)(vi,{children:[(0,Ps.jsx)(Lm,{creating:t,disabled:n,isSmallScreen:h,isTinyScreen:d,loaded:r,onCreate:o,searchText:p,working:g}),(0,Ps.jsx)(Bm,{isComplete:f,isSmallScreen:h,isTinyScreen:d,loaded:r,removing:l,stopOrRemove:v,stopping:u,working:g})]})]})},zm=[{key:"uploadSpeed",text:"Upload Speed (Fastest to Slowest)",value:"uploadSpeed"},{key:"queueLength",text:"Queue Depth (Least to Most)",value:"queueLength"}],Hm=e=>{let{creating:t,disabled:n,onCreate:r,onRemove:i,onStop:o,removing:s,search:a,stopping:l}=e;const{fileCount:c,id:u,isComplete:h,lockedFileCount:d,responseCount:f,state:p}=a,[m,g]=(0,we.useState)(!1),[v,y]=(0,we.useState)(void 0),[b,w]=(0,we.useState)([]),[x,k]=(0,we.useState)([]),[S,C]=(0,we.useState)("uploadSpeed"),[E,T]=(0,we.useState)(!0),[O,A]=(0,we.useState)(!1),[_,P]=(0,we.useState)(!1),[N,M]=(0,we.useState)(""),[j,R]=(0,we.useState)(5);(0,we.useEffect)((()=>{const e=async()=>{try{g(!0),await(e=500,new Promise((t=>{setTimeout(t,e)})));const t=await(async e=>{let{id:t}=e;const n=(await ge.get(`/searches/${encodeURIComponent(t)}/responses`)).data;if(Array.isArray(n))return n;console.warn("got non-array response from searches API",n)})({id:u});w(t),g(!1)}catch(t){y(t),g(!1)}var e};h&&e()}),[u,h]);const I=(0,we.useMemo)((()=>{const{field:e,order:t}={queueLength:{field:"queueLength",order:"asc"},uploadSpeed:{field:"uploadSpeed",order:"desc"}}[S],n=(e=>{const t={exclude:[],include:[],isCBR:!1,isLossless:!1,isLossy:!1,isVBR:!1,minBitDepth:0,minBitRate:0,minFilesInFolder:0,minFileSize:0,minLength:0};t.minBitRate=Yp(e,/(minbr|minbitrate):(\d+)/iu,2)||t.minBitRate,t.minBitDepth=Yp(e,/(minbd|minbitdepth):(\d+)/iu,2)||t.minBitDepth,t.minFileSize=Yp(e,/(minfs|minfilesize):(\d+)/iu,2)||t.minFileSize,t.minLength=Yp(e,/(minlen|minlength):(\d+)/iu,2)||t.minLength,t.minFilesInFolder=Yp(e,/(minfif|minfilesinfolder):(\d+)/iu,2)||t.minFilesInFolder,t.isVBR=Boolean(/isvbr/iu.test(e)),t.isCBR=Boolean(/iscbr/iu.test(e)),t.isLossless=Boolean(/islossless/iu.test(e)),t.isLossy=Boolean(/islossy/iu.test(e));const n=e.toLowerCase().split(" ").filter((e=>!e.includes(":")&&"isvbr"!==e&&"iscbr"!==e&&"islossless"!==e&&"islossy"!==e));return t.include=n.filter((e=>!e.startsWith("-"))),t.exclude=n.filter((e=>e.startsWith("-"))).map((e=>e.slice(1))),t})(N);return b.filter((e=>!x.includes(e.username))).map((e=>E?{...e,lockedFileCount:0,lockedFiles:[]}:e)).map((e=>(e=>{let{filters:t={exclude:[],include:[],isCBR:!1,isLossless:!1,isLossy:!1,isVBR:!1,minBitDepth:0,minBitRate:0,minFileSize:0,minLength:0},response:n={files:[],lockedFiles:[]}}=e;const{files:r=[],lockedFiles:i=[]}=n;if(n.fileCount+n.lockedFileCounte.filter((e=>{const{bitRate:n,size:r,length:i,filename:o,sampleRate:s,bitDepth:a,isVariableBitRate:l}=e,{isCBR:c,isVBR:u,isLossless:h,isLossy:d,minBitRate:f,minBitDepth:p,minFileSize:m,minLength:g,include:v=[],exclude:y=[]}=t;return(!c||void 0!==l&&!l)&&!(u&&(void 0===l||!l))&&!!(!h||s&&a)&&(!d||!s&&!a)&&!(n0&&v.filter((e=>o.toLowerCase().includes(e))).length!==v.length)&&!y.some((e=>o.toLowerCase().includes(e)))})),s=o(r),a=o(i);return{...n,fileCount:s.length,files:s,lockedFileCount:a.length,lockedFiles:a}})({filters:n,response:e}))).filter((e=>e.fileCount+e.lockedFileCount>0)).filter((e=>!(O&&!e.hasFreeUploadSlot))).sort(((n,r)=>"asc"===t?n[e]-r[e]:r[e]-n[e]))}),[x,E,O,N,S,b]),D=()=>{g(!1),y(void 0),w([]),k([]),R(5)},L=(null===b||void 0===b?void 0:b.length)-I.length,B=I.length-j,F=!s&&!t&&!m&&b;var z;return v?(0,Ps.jsx)(Xp,{caption:null!==(z=null===v||void 0===v?void 0:v.message)&&void 0!==z?z:v}):(0,Ps.jsxs)(Ps.Fragment,{children:[(0,Ps.jsx)(Fm,{creating:t,disabled:n,loaded:F,loading:m,onCreate:async e=>{let{navigate:t,search:n}=e;D(),r({navigate:t,searchForCreate:n})},onRemove:async()=>{D(),i(a)},onStop:o,removing:s,search:a,stopping:l}),(0,Ps.jsxs)(em,{loading:m&&(0,Ps.jsx)(Zp,{}),searching:!h&&(0,Ps.jsx)(Zp,{children:"InProgress"===p?`Found ${c} files ${d>0?`(plus ${d} locked) `:""}from ${f} users`:"Loading results..."}),children:[F&&(0,Ps.jsxs)(vi,{className:"search-options",raised:!0,children:[(0,Ps.jsx)(ah,{button:!0,className:"search-options-sort icon",floating:!0,icon:"sort",labeled:!0,onChange:(e,t)=>{let{value:n}=t;return C(n)},options:zm,text:zm.find((e=>e.value===S)).text}),(0,Ps.jsxs)("div",{className:"search-option-toggles",children:[(0,Ps.jsx)(ka,{checked:E,className:"search-options-hide-locked",label:"Hide Locked Results",onChange:()=>T(!E),toggle:!0}),(0,Ps.jsx)(ka,{checked:O,className:"search-options-hide-no-slots",label:"Hide Results with No Free Slots",onChange:()=>A(!O),toggle:!0}),(0,Ps.jsx)(ka,{checked:_,className:"search-options-fold-results",label:"Fold Results",onChange:()=>P(!_),toggle:!0})]}),(0,Ps.jsx)(oc,{action:Boolean(N)&&{color:"red",icon:"x",onClick:()=>M("")},className:"search-filter",label:{content:"Filter",icon:"filter"},onChange:(e,t)=>M(t.value),placeholder:" lackluster container -bothersome iscbr|isvbr islossless|islossy minbitrate:320 minbitdepth:24 minfilesize:10 minfilesinfolder:8 minlength:5000 ",value:N})]}),F&&I.slice(0,j).map((e=>(0,Ps.jsx)(jm,{disabled:n,isInitiallyFolded:_,onHide:()=>k([...x,e.username]),response:e},e.username))),F&&(B>0?(0,Ps.jsxs)($a,{className:"showmore-button",fluid:!0,onClick:()=>R(j+5),primary:!0,size:"large",children:["Show ",B>5?5:B," More Results"," ",`(${B} remaining, ${L} hidden by filter(s))`]}):L>0?(0,Ps.jsx)($a,{className:"showmore-button",disabled:!0,fluid:!0,size:"large",children:`All results shown. ${L} results hidden by filter(s)`}):"")]})]})},$m=e=>{let{loading:t,onRemove:n,onStop:r,search:i,...o}=e;return t?(0,Ps.jsx)(fo,{loading:!0,name:"spinner",...o}):i.state.includes("Completed")?(0,Ps.jsx)(fo,{color:"red",name:"trash alternate",onClick:()=>n(),style:{cursor:"pointer"}}):(0,Ps.jsx)(fo,{color:"red",name:"stop circle",onClick:()=>r(),style:{cursor:"pointer"}})};var Um=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i{let{onRemove:t,onStop:n,search:r}=e;const[i,o]=(0,we.useState)(!1),s=rc(),a=async e=>{o(!0);try{await e()}catch(t){console.error(t)}finally{o(!1)}};return(0,Ps.jsxs)(ga.Row,{disabled:i,style:{cursor:i?"wait":void 0},children:[(0,Ps.jsx)(ga.Cell,{children:(0,Ps.jsx)(Im,{state:r.state})}),(0,Ps.jsx)(ga.Cell,{children:(0,Ps.jsx)(Gm,{to:`${s.url}/${r.id}`,children:r.searchText})}),(0,Ps.jsx)(ga.Cell,{children:r.fileCount}),(0,Ps.jsxs)(ga.Cell,{children:[(0,Ps.jsx)(fo,{color:"yellow",name:"lock",size:"small"}),r.lockedFileCount]}),(0,Ps.jsx)(ga.Cell,{children:r.responseCount}),(0,Ps.jsx)(ga.Cell,{children:r.endedAt?new Date(r.endedAt).toLocaleTimeString():"-"}),(0,Ps.jsx)(ga.Cell,{children:(0,Ps.jsx)($m,{loading:i,onRemove:()=>a((()=>t(r))),onStop:()=>a((()=>n(r))),search:r,style:{cursor:"pointer"}})})]})},Zm=e=>{let{connecting:t=!1,error:n,onRemove:r=()=>{},onStop:i=()=>{},searches:o={}}=e;return(0,Ps.jsx)(Ra,{className:"search-list-card",raised:!0,children:(0,Ps.jsx)(Ra.Content,{children:(0,Ps.jsx)("div",{className:"search-list-wrapper",children:(0,Ps.jsx)(em,{connecting:t&&(0,Ps.jsx)(ac,{active:!0,inline:"centered",size:"small"}),error:n&&(0,Ps.jsx)(Xp,{caption:n}),children:(0,Ps.jsxs)(ga,{className:"unstackable",size:"large",children:[(0,Ps.jsx)(ga.Header,{children:(0,Ps.jsxs)(ga.Row,{children:[(0,Ps.jsx)(ga.HeaderCell,{className:"search-list-action",children:(0,Ps.jsx)(fo,{name:"info circle"})}),(0,Ps.jsx)(ga.HeaderCell,{className:"search-list-phrase",children:"Search"}),(0,Ps.jsx)(ga.HeaderCell,{className:"search-list-files",children:"Files"}),(0,Ps.jsx)(ga.HeaderCell,{className:"search-list-locked",children:"Locked"}),(0,Ps.jsx)(ga.HeaderCell,{className:"search-list-responses",children:"Responses"}),(0,Ps.jsx)(ga.HeaderCell,{className:"search-list-started",children:"Ended"}),(0,Ps.jsx)(ga.HeaderCell,{className:"search-list-action"})]})}),(0,Ps.jsx)(ga.Body,{children:Object.values(o).sort(((e,t)=>new Date(t.startedAt)-new Date(e.startedAt))).map((e=>(0,Ps.jsx)(Xm,{onRemove:r,onStop:i,search:e},e.id)))})]})})})})})};var eg,tg=new Uint8Array(16);function ng(){if(!eg&&!(eg="undefined"!==typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!==typeof msCrypto&&"function"===typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return eg(tg)}const rg=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;const ig=function(e){return"string"===typeof e&&rg.test(e)};for(var og=[],sg=0;sg<256;++sg)og.push((sg+256).toString(16).substr(1));const ag=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(og[e[t+0]]+og[e[t+1]]+og[e[t+2]]+og[e[t+3]]+"-"+og[e[t+4]]+og[e[t+5]]+"-"+og[e[t+6]]+og[e[t+7]]+"-"+og[e[t+8]]+og[e[t+9]]+"-"+og[e[t+10]]+og[e[t+11]]+og[e[t+12]]+og[e[t+13]]+og[e[t+14]]+og[e[t+15]]).toLowerCase();if(!ig(n))throw TypeError("Stringified UUID is invalid");return n};const lg=function(e,t,n){var r=(e=e||{}).random||(e.rng||ng)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=r[i];return t}return ag(r)},cg=function(){var e,t;let{server:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[r,o]=(0,we.useState)(!0),[s,a]=(0,we.useState)(void 0),[l,c]=(0,we.useState)({}),[u,h]=(0,we.useState)(!1),[d,f]=(0,we.useState)(!1),[p,m]=(0,we.useState)(!1),g=(0,we.useRef)(),{id:v}=function(){var e=ec(Rl).match;return e?e.params:{}}(),y=tc(),b=rc(),w=()=>{o(!0)},x=()=>{o(!1),a(void 0)},k=e=>{o(!1),a(e)},S=e=>{c(e),x()};(0,we.useEffect)((()=>{w();const e=de({url:`${i}/search`});e.on("list",(e=>{S(e.reduce(((e,t)=>(e[t.id]=t,e)),{})),x()})),e.on("update",(e=>{S((t=>({...t,[e.id]:e})))})),e.on("delete",(e=>{S((t=>(delete t[e.id],{...t})))})),e.on("create",(e=>{S((t=>({...t,[e.id]:e})))})),e.onreconnecting((e=>{var t;return k(null!==(t=null===e||void 0===e?void 0:e.message)&&void 0!==t?t:"Disconnected")})),e.onreconnected((()=>x())),e.onclose((e=>{var t;return k(null!==(t=null===e||void 0===e?void 0:e.message)&&void 0!==t?t:"Disconnected")}));return(async()=>{try{w(),await e.start()}catch(r){var t,n;Pm.error(null!==(t=null===r||void 0===r?void 0:r.message)&&void 0!==t?t:"Failed to connect"),k(null!==(n=null===r||void 0===r?void 0:r.message)&&void 0!==n?n:"Failed to connect")}})(),()=>{e.stop()}}),[]);const C=async function(){var e,t;let{navigate:n=!1,search:r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const i=null===g||void 0===g||null===(e=g.current)||void 0===e||null===(t=e.inputRef)||void 0===t?void 0:t.current,o=r||i.value,s=lg();try{m(!0),await(e=>{let{id:t,searchText:n}=e;return ge.post("/searches",{id:t,searchText:n})})({id:s,searchText:o});try{i.value="",i.focus()}catch{}m(!1),n&&y.push(`${b.url.replace(`/${v}`,"")}/${s}`)}catch(u){var a,l,c;console.error(u),Pm.error(null!==(a=null!==(l=null===u||void 0===u||null===(c=u.response)||void 0===c?void 0:c.data)&&void 0!==l?l:null===u||void 0===u?void 0:u.message)&&void 0!==a?a:u),m(!1)}},E=async e=>{try{h(!0),await(e=>{let{id:t}=e;return ge.delete(`/searches/${encodeURIComponent(t)}`)})({id:e.id}),c((t=>(delete t[e.id],{...t}))),h(!1)}catch(i){var t,n,r;console.error(i),Pm.error(null!==(t=null!==(n=null===s||void 0===s||null===(r=s.response)||void 0===r?void 0:r.data)&&void 0!==n?n:null===s||void 0===s?void 0:s.message)&&void 0!==t?t:s),h(!1)}},T=async e=>{try{f(!0),await(e=>{let{id:t}=e;return ge.put(`/searches/${encodeURIComponent(t)}`)})({id:e.id}),f(!1)}catch(i){var t,n,r;console.error(i),Pm.error(null!==(t=null!==(n=null===i||void 0===i||null===(r=i.response)||void 0===r?void 0:r.data)&&void 0!==n?n:null===i||void 0===i?void 0:i.message)&&void 0!==t?t:i),f(!1)}};if(r)return(0,Ps.jsx)(Zp,{});var O;if(s)return(0,Ps.jsx)(Xp,{caption:null!==(O=null===s||void 0===s?void 0:s.message)&&void 0!==O?O:s});if(v){if(l[v])return(0,Ps.jsx)(Hm,{creating:p,disabled:!(null!==n&&void 0!==n&&n.isConnected),onCreate:C,onRemove:E,onStop:T,removing:u,search:l[v],stopping:d});y.replace(b.url.replace(`/${v}`,""))}return null===g||void 0===g||null===(e=g.current)||void 0===e||null===(t=e.inputRef)||void 0===t||t.current.focus(),(0,Ps.jsxs)(Ps.Fragment,{children:[(0,Ps.jsxs)(vi,{className:"search-segment",raised:!0,children:[(0,Ps.jsx)("div",{className:"search-segment-icon",children:(0,Ps.jsx)(fo,{name:"search",size:"big"})}),(0,Ps.jsx)(oc,{action:(0,Ps.jsxs)(Ps.Fragment,{children:[(0,Ps.jsx)($a,{disabled:p||!n.isConnected,icon:"plus",onClick:C}),(0,Ps.jsx)($a,{disabled:p||!n.isConnected,icon:"search",onClick:()=>C({navigate:!0})})]}),className:"search-input",disabled:p||!n.isConnected,input:(0,Ps.jsx)("input",{"data-lpignore":"true",placeholder:n.isConnected?"Search phrase":"Connect to server to perform a search",type:"search"}),loading:p,onKeyUp:e=>"Enter"===e.key?C():"",placeholder:"Search phrase",ref:g,size:"big"})]}),0===Object.keys(l).length?(0,Ps.jsx)(Ns,{caption:"No searches to display",icon:"search"}):(0,Ps.jsx)(Zm,{connecting:r,error:s,onRemove:E,onStop:T,searches:l})]})},ug=1024;let hg=0;class dg{constructor(e,t){this.from=e,this.to=t}}class fg{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.id=hg++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=mg.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}}fg.closedBy=new fg({deserialize:e=>e.split(" ")}),fg.openedBy=new fg({deserialize:e=>e.split(" ")}),fg.group=new fg({deserialize:e=>e.split(" ")}),fg.contextHash=new fg({perNode:!0}),fg.lookAhead=new fg({perNode:!0}),fg.mounted=new fg({perNode:!0});const pg=Object.create(null);class mg{constructor(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):pg,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),r=new mg(e.name||"",t,e.id,n);if(e.props)for(let i of e.props)if(Array.isArray(i)||(i=i(r)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}return r}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(fg.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(" "))t[r]=e[n];return e=>{for(let n=e.prop(fg.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}}mg.none=new mg("",Object.create(null),0,8);class gg{constructor(e){this.types=e;for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:0;return new Ng(this.topNode,e)}cursorAt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=vg.get(this)||this.topNode,r=new Ng(n);return r.moveTo(e,t),vg.set(this,r._tree),r}get topNode(){return new Tg(this,0,0,null)}resolve(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Eg(vg.get(this)||this.topNode,e,t,!1);return vg.set(this,n),n}resolveInner(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=Eg(yg.get(this)||this.topNode,e,t,!0);return yg.set(this,n),n}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,o=e.mode||0,s=(o&bg.IncludeAnonymous)>0;for(let a=this.cursor(o|bg.IncludeAnonymous);;){let e=!1;if(a.from<=i&&a.to>=r&&(!s&&a.type.isAnonymous||!1!==t(a))){if(a.firstChild())continue;e=!0}for(;e&&n&&(s||!a.type.isAnonymous)&&n(a),!a.nextSibling();){if(!a.parent())return;e=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.children.length<=8?this:Ig(mg.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,n)=>new wg(this.type,e,t,n,this.propValues)),e.makeTree||((e,t,n)=>new wg(mg.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=ug,reused:o=[],minRepeatType:s=r.types.length}=e,a=Array.isArray(n)?new xg(n,n.length):n,l=r.types,c=0,u=0;function h(e,t,n,v,y){let{id:b,start:w,end:x,size:k}=a,S=u;for(;k<0;){if(a.next(),-1==k){let t=o[b];return n.push(t),void v.push(w-e)}if(-3==k)return void(c=b);if(-4==k)return void(u=b);throw new RangeError(`Unrecognized record size: ${k}`)}let C,E,T=l[b],O=w-e;if(x-w<=i&&(E=m(a.pos-t,y))){let t=new Uint16Array(E.size-E.skip),n=a.pos-E.size,i=t.length;for(;a.pos>n;)i=g(E.start,t,i);C=new kg(t,x-E.start,r),O=E.start-e}else{let e=a.pos-k;a.next();let t=[],n=[],r=b>=s?b:-1,o=0,l=x;for(;a.pos>e;)r>=0&&a.id==r&&a.size>=0?(a.end<=l-i&&(f(t,n,w,o,a.end,l,r,S),o=t.length,l=a.end),a.next()):h(w,e,t,n,r);if(r>=0&&o>0&&o-1&&o>0){let e=d(T);C=Ig(T,t,n,0,t.length,0,x-w,e,e)}else C=p(T,t,n,x-w,S-x)}n.push(C),v.push(O)}function d(e){return(t,n,r)=>{let i,o,s=0,a=t.length-1;if(a>=0&&(i=t[a])instanceof wg){if(!a&&i.type==e&&i.length==r)return i;(o=i.prop(fg.lookAhead))&&(s=n[a]+i.length+o)}return p(e,t,n,r,s)}}function f(e,t,n,i,o,s,a,l){let c=[],u=[];for(;e.length>i;)c.push(e.pop()),u.push(t.pop()+n-o);e.push(p(r.types[a],c,u,s-o,l-s)),t.push(o-n)}function p(e,t,n,r){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5?arguments[5]:void 0;if(c){let e=[fg.contextHash,c];o=o?[e].concat(o):[e]}if(i>25){let e=[fg.lookAhead,i];o=o?[e].concat(o):[e]}return new wg(e,t,n,r,o)}function m(e,t){let n=a.fork(),r=0,o=0,l=0,c=n.end-i,u={size:0,start:0,skip:0};e:for(let i=n.pos-e;n.pos>i;){let e=n.size;if(n.id==t&&e>=0){u.size=r,u.start=o,u.skip=l,l+=4,r+=4,n.next();continue}let a=n.pos-e;if(e<0||a=s?4:0,d=n.start;for(n.next();n.pos>a;){if(n.size<0){if(-3!=n.size)break e;h+=4}else n.id>=s&&(h+=4);n.next()}o=d,r+=e,l+=h}return(t<0||r==e)&&(u.size=r,u.start=o,u.skip=l),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:o,size:l}=a;if(a.next(),l>=0&&r4){let r=a.pos-(l-4);for(;a.pos>r;)n=g(e,t,n)}t[--n]=s,t[--n]=o-e,t[--n]=i-e,t[--n]=r}else-3==l?c=r:-4==l&&(u=r);return n}let v=[],y=[];for(;a.pos>0;)h(e.start||0,e.bufferStart||0,v,y,-1);let b=null!==(t=e.length)&&void 0!==t?t:v.length?y[0]+v[0].length:0;return new wg(l[e.topID],v.reverse(),y.reverse(),b)}(e)}}wg.empty=new wg(mg.none,[],[],0);class xg{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new xg(this.buffer,this.index)}}class kg{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return mg.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return s}slice(e,t,n){let r=this.buffer,i=new Uint16Array(t-e),o=0;for(let s=e,a=0;s=t&&nt;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function Cg(e,t){let n=e.childBefore(t);for(;n;){let t=n.lastChild;if(!t||t.to!=n.to)break;t.type.isError&&t.from==t.to?(e=n,n=t.prevSibling):n=t}return e}function Eg(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to4&&void 0!==arguments[4]?arguments[4]:0;for(let o=this;;){for(let{children:s,positions:a}=o._tree,l=t>0?s.length:-1;e!=l;e+=t){let l=s[e],c=a[e]+o.from;if(Sg(r,n,c,c+l.length))if(l instanceof kg){if(i&bg.ExcludeBuffers)continue;let s=l.findChild(0,l.buffer.length,t,n-c,r);if(s>-1)return new Pg(new _g(o,l,e,c),null,s)}else if(i&bg.IncludeAnonymous||!l.type.isAnonymous||Mg(l)){let s;if(!(i&bg.IgnoreMounts)&&l.props&&(s=l.prop(fg.mounted))&&!s.overlay)return new Tg(s.tree,c,e,o);let a=new Tg(l,c,e,o);return i&bg.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?l.children.length-1:0,t,n,r)}}if(i&bg.IncludeAnonymous||!o.type.isAnonymous)return null;if(e=o.index>=0?o.index+t:t<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t){let n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!(r&bg.IgnoreOverlays)&&(n=this._tree.prop(fg.mounted))&&n.overlay){let r=e-this.from;for(let{from:e,to:i}of n.overlay)if((t>0?e<=r:e=r:i>r))return new Tg(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(){return new Ng(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}get tree(){return this._tree}toTree(){return this._tree}resolve(e){return Eg(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,!1)}resolveInner(e){return Eg(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,!0)}enterUnfinishedNodesBefore(e){return Cg(this,e)}getChild(e){let t=Og(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null);return t.length?t[0]:null}getChildren(e){return Og(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return Ag(this,e)}}function Og(e,t,n,r){let i=e.cursor(),o=[];if(!i.firstChild())return o;if(null!=n)for(;!i.type.is(n);)if(!i.nextSibling())return o;for(;;){if(null!=r&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return null==r?o:[]}}function Ag(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length-1;for(let r=e.parent;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class _g{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class Pg{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return i<0?null:new Pg(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t){if((arguments.length>2&&void 0!==arguments[2]?arguments[2]:0)&bg.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new Pg(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Pg(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Pg(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(){return new Ng(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let o=n.buffer[this.index+1];e.push(n.slice(r,i,o)),t.push(0)}return new wg(this.type,e,t,this.to-this.from)}resolve(e){return Eg(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,!1)}resolveInner(e){return Eg(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,!0)}enterUnfinishedNodesBefore(e){return Cg(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e){let t=Og(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null);return t.length?t[0]:null}getChildren(e){return Og(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)}get node(){return this}matchContext(e){return Ag(this,e)}}class Ng{get name(){return this.type.name}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Tg)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return!!e&&(e instanceof Tg?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.mode;return this.buffer?!(n&bg.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&bg.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&bg.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&bg.IncludeAnonymous||e instanceof kg||!e.type.isAnonymous||Mg(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.move(1,e)}prev(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.move(-1,e)}moveTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=i+1;break e}r=this.stack[--i]}for(let r=n;r=0;i--){if(i<0)return Ag(this.node,e,r);let o=n[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function Mg(e){return e.children.some((e=>e instanceof kg||!e.type.isAnonymous||Mg(e)))}const jg=new WeakMap;function Rg(e,t){if(!e.isAnonymous||t instanceof kg||t.type!=e)return 1;let n=jg.get(t);if(null==n){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof wg)){n=1;break}n+=Rg(e,r)}jg.set(t,n)}return n}function Ig(e,t,n,r,i,o,s,a,l){let c=0;for(let f=r;f=u)break;p+=t}if(c==i+1){if(p>u){let e=n[i];t(e.children,e.positions,0,e.children.length,r[i]+a);continue}h.push(n[i])}else{let t=r[c-1]+n[c-1].length-f;h.push(Ig(e,n,r,i,c,f,t,null,l))}d.push(f+a-o)}}(t,n,r,i,0),(a||l)(h,d,s)}class Dg{constructor(e,t,n,r){let i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(i?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=[new Dg(0,e.length,e,0,!1,n)];for(let i of t)i.to>e.length&&r.push(i);return r}static applyChanges(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:128;if(!t.length)return e;let r=[],i=1,o=e.length?e[0]:null;for(let s=0,a=0,l=0;;s++){let c=s=n)for(;o&&o.from=t.from||u<=t.to||l){let e=Math.max(t.from,a)-l,n=Math.min(t.to,u)-l;t=e>=n?null:new Dg(e,n,t.tree,t.offset+l,s>0,!!c)}if(t&&r.push(t),o.to>u)break;o=inew dg(e.from,e.to))):[new dg(0,0)]:[new dg(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}}class Bg{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new fg({perNode:!0});class Fg{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Hg.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=[];return this.decompose(e,t,n,0),Hg.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new Wg(this),i=new Wg(e);for(let o=t,s=t;;){if(r.next(o),i.next(o),o=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(s+=r.value.length,r.done||s>=n)return!0}}iter(){return new Wg(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:1)}iterRange(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length;return new Vg(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new qg(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new zg(e):Hg.from(zg.split(e,[])):Fg.empty}}class zg extends Fg{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e);super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.text[i],s=r+o.length;if((t?n:s)>=e)return new Kg(r,s,n,o);r=s+1,n++}}decompose(e,t,n,r){let i=e<=0&&t>=this.length?this:new zg(Ug(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&r){let e=n.pop(),t=$g(i.text,e.text.slice(),0,i.length);if(t.length<=32)n.push(new zg(t,e.length+i.length));else{let e=t.length>>1;n.push(new zg(t.slice(0,e)),new zg(t.slice(e)))}}else n.push(i)}replace(e,t,n){if(!(n instanceof zg))return super.replace(e,t,n);let r=$g(this.text,$g(n.text,Ug(this.text,0,e)),t),i=this.length+n.length-(t-e);return r.length<=32?new zg(r,i):Hg.from(zg.split(r,[]),i)}sliceString(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"\n",r="";for(let i=0,o=0;i<=t&&oe&&o&&(r+=n),ei&&(r+=s.slice(Math.max(0,e-i),t-i)),i=a+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let i of e)n.push(i),r+=i.length+1,32==n.length&&(t.push(new zg(n,r)),n=[],r=-1);return r>-1&&t.push(new zg(n,r)),t}}class Hg extends Fg{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,r){for(let i=0;;i++){let o=this.children[i],s=r+o.length,a=n+o.lines-1;if((t?a:s)>=e)return o.lineInner(e,t,n,r);r=s+1,n=a+1}}decompose(e,t,n,r){for(let i=0,o=0;o<=t&&i=o){let i=r&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!i?n.push(s):s.decompose(e-o,t-o,n,i)}o=a+1}}replace(e,t,n){if(n.lines=i&&t<=s){let a=o.replace(e-i,t-i,n),l=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>l>>6){let i=this.children.slice();return i[r]=a,new Hg(i,this.length-(t-e)+n.length)}return super.replace(i,s,a)}i=s+1}return super.replace(e,t,n)}sliceString(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"\n",r="";for(let i=0,o=0;ie&&i&&(r+=n),eo&&(r+=s.sliceString(e-o,t-o,n)),o=a+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Hg))return 0;let n=0,[r,i,o,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,i+=t){if(r==o||i==s)return n;let a=this.children[r],l=e.children[i];if(a!=l)return n+a.scanIdentical(l,t);n+=a.length+1}}static from(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.reduce(((e,t)=>e+t.length+1),-1),n=0;for(let d of e)n+=d.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new zg(n,t)}let r=Math.max(32,n>>5),i=r<<1,o=r>>1,s=[],a=0,l=-1,c=[];function u(e){let t;if(e.lines>i&&e instanceof Hg)for(let n of e.children)u(n);else e.lines>o&&(a>o||!a)?(h(),s.push(e)):e instanceof zg&&a&&(t=c[c.length-1])instanceof zg&&e.lines+t.lines<=32?(a+=e.lines,l+=e.length+1,c[c.length-1]=new zg(t.text.concat(e.text),t.length+1+e.length)):(a+e.lines>r&&h(),a+=e.lines,l+=e.length+1,c.push(e))}function h(){0!=a&&(s.push(1==c.length?c[0]:Hg.from(c,l)),l=-1,a=c.length=0)}for(let d of e)u(d);return h(),1==s.length?s[0]:new Hg(s,t)}}function $g(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e9;for(let i=0,o=0,s=!0;o=n&&(l>r&&(a=a.slice(0,r-i)),i1&&void 0!==arguments[1]?arguments[1]:1;this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof zg?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],o=i>>1,s=r instanceof zg?r.text.length:r.children.length;if(o==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(r instanceof zg){let i=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=0==e?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[o+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof zg?i.text.length:i.children.length)<<1))}}}next(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Vg{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Wg(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class qg{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,{done:t,lineBreak:n,value:r}=this.inner.next(e);return t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(Fg.prototype[Symbol.iterator]=function(){return this.iter()},Wg.prototype[Symbol.iterator]=Vg.prototype[Symbol.iterator]=qg.prototype[Symbol.iterator]=function(){return this});class Kg{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}let Qg="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((e=>e?parseInt(e,36):1));for(let n=1;ne)return Qg[t-1]<=e;return!1}function Jg(e){return e>=127462&&e<=127487}const Yg=8205;function Xg(e,t){return(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?Zg:ev)(e,t,!(arguments.length>3&&void 0!==arguments[3])||arguments[3])}function Zg(e,t,n){if(t==e.length)return t;t&&tv(e.charCodeAt(t))&&nv(e.charCodeAt(t-1))&&t--;let r=rv(e,t);for(t+=ov(r);t=0&&Jg(rv(e,r));)n++,r-=2;if(n%2==0)break;t+=2}}}return t}function ev(e,t,n){for(;t>0;){let r=Zg(e,t-2,n);if(r=56320&&e<57344}function nv(e){return e>=55296&&e<56320}function rv(e,t){let n=e.charCodeAt(t);if(!nv(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return tv(r)?r-56320+(n-55296<<10)+65536:n}function iv(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function ov(e){return e<65536?1:2}const sv=/\r\n?|\n/;var av=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(av||(av={}));class lv{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t1&&void 0!==arguments[1]&&arguments[1])}get invertedDesc(){let e=[];for(let t=0;t1&&void 0!==arguments[1]&&arguments[1];return e.empty?this:fv(this,e,t)}mapPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:av.Simple,r=0,i=0;for(let o=0;oe)return i+(e-r);i+=s}else{if(n!=av.Simple&&l>=e&&(n==av.TrackDel&&re||n==av.TrackBefore&&re))return null;if(l>e||l==e&&t<0&&!s)return e==r||t<0?i:i+a;i+=a}r=l}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;for(let n=0,r=0;n=0&&r<=t&&i>=e)return!(rt)||"cover";r=i}return!1}toString(){let e="";for(let t=0;t=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some((e=>"number"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new lv(e)}static create(e){return new lv(e)}}class cv extends lv{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return dv(this,((t,n,r,i,o)=>e=e.replace(r,r+(n-t),o)),!1),e}mapDesc(e){return fv(this,e,arguments.length>1&&void 0!==arguments[1]&&arguments[1],!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,i=0;r=0){t[r]=s,t[r+1]=o;let a=r>>1;for(;n.length1&&void 0!==arguments[1]&&arguments[1];return e.empty?this:fv(this,e,t,!0)}iterChanges(e){dv(this,e,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}get desc(){return lv.create(this.sections)}filter(e){let t=[],n=[],r=[],i=new mv(this);e:for(let o=0,s=0;;){let a=o==e.length?1e9:e[o++];for(;s0&&hv(n,t,i.text),i.forward(e),s+=e}let l=e[o++];for(;s>1].toJSON()))}return e}static of(e,t,n){let r=[],i=[],o=0,s=null;function a(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&!r.length)return;os||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let u=c?"string"==typeof c?Fg.of(c.split(n||sv)):c:Fg.empty,h=u.length;if(e==s&&0==h)return;eo&&uv(r,e-o,-1),uv(r,s-e,h),hv(i,r,u),o=s}}(e),a(!s),s}static empty(e){return new cv(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;rt&&"string"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==i.length)t.push(i[0],0);else{for(;n.length3&&void 0!==arguments[3]&&arguments[3];if(0==t&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:0==t&&0==e[i]?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function hv(e,t,n){if(0==n.length)return;let r=t.length-2>>1;if(r>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(i,c,o,u,h),i=c,o=u}}}function fv(e,t,n){let r=[],i=arguments.length>3&&void 0!==arguments[3]&&arguments[3]?[]:null,o=new mv(e),s=new mv(t);for(let a=-1;;)if(-1==o.ins&&-1==s.ins){let e=Math.min(o.len,s.len);uv(r,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||a==o.i||0==o.off&&(s.len=0&&a=0)){if(o.done&&s.done)return i?cv.createSet(r,i):lv.create(r);throw new Error("Mismatched change set lengths")}{let e=0,t=o.len;for(;t;)if(-1==s.ins){let n=Math.min(t,s.len);e+=n,t-=n,s.forward(n)}else{if(!(0==s.ins&&s.len2&&void 0!==arguments[2]&&arguments[2]?[]:null,i=new mv(e),o=new mv(t);for(let s=!1;;){if(i.done&&o.done)return r?cv.createSet(n,r):lv.create(n);if(0==i.ins)uv(n,i.len,0,s),i.next();else if(0!=o.len||o.done){if(i.done||o.done)throw new Error("Mismatched change set lengths");{let e=Math.min(i.len2,o.len),t=n.length;if(-1==i.ins){let t=-1==o.ins?-1:o.off?0:o.ins;uv(n,e,t,s),r&&t&&hv(r,n,o.text)}else-1==o.ins?(uv(n,i.off?0:i.len,e,s),r&&hv(r,n,i.textBit(e))):(uv(n,i.off?0:i.len,o.off?0:o.ins,s),r&&!o.off&&hv(r,n,o.text));s=(i.ins>e||o.ins>=0&&o.len>e)&&(s||n.length>t),i.forward2(e),o.forward(e)}}else uv(n,0,o.ins,s),r&&hv(r,n,o.text),o.next()}}class mv{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?Fg.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Fg.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class gv{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return 16&this.flags?this.to:this.from}get head(){return 16&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 4&this.flags?-1:8&this.flags?1:0}get bidiLevel(){let e=3&this.flags;return 3==e?null:e}get goalColumn(){let e=this.flags>>5;return 33554431==e?void 0:e}map(e){let t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return this.empty?t=n=e.mapPos(this.from,r):(t=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),t==this.from&&n==this.to?this:new gv(t,n,this.flags)}extend(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;if(e<=this.anchor&&t>=this.anchor)return vv.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return vv.range(this.anchor,n)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return vv.range(e.anchor,e.head)}static create(e,t,n){return new gv(e,t,n)}}class vv{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return e.empty?this:vv.create(this.ranges.map((n=>n.map(e,t))),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;t1&&void 0!==arguments[1])||arguments[1];return vv.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.mainIndex,n=this.ranges.slice();return n[t]=e,vv.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map((e=>e.toJSON())),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new vv(e.ranges.map((e=>gv.fromJSON(e))),e.main)}static single(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return new vv([vv.range(e,t)],0)}static create(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(0==e.length)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;r1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;return gv.create(e,e,(0==t?0:t<0?4:8)|(null==n?3:Math.min(2,n))|(null!==r&&void 0!==r?r:33554431)<<5)}static range(e,t,n,r){let i=(null!==n&&void 0!==n?n:33554431)<<5|(null==r?3:Math.min(2,r));return te?4:0)|i)}static normalized(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e[t];e.sort(((e,t)=>e.from-t.from)),t=e.indexOf(n);for(let r=1;rn.head?vv.range(s,o):vv.range(o,s))}}return new vv(e,t)}}function yv(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}let bv=0;class wv{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=bv++,this.default=e([]),this.extensions="function"==typeof i?i(this):i}static define(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new wv(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:xv),!!e.static,e.enables)}of(e){return new kv([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new kv(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new kv(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],(n=>t(n.field(e))))}}function xv(e,t){return e==t||e.length==t.length&&e.every(((e,n)=>e===t[n]))}class kv{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=bv++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,i=this.id,o=e[i]>>1,s=2==this.type,a=!1,l=!1,c=[];for(let u of this.dependencies)"doc"==u?a=!0:"selection"==u?l=!0:0==(1&(null!==(t=e[u.id])&&void 0!==t?t:1))&&c.push(e[u.id]);return{create:e=>(e.values[o]=n(e),1),update(e,t){if(a&&t.docChanged||l&&(t.docChanged||t.selection)||Cv(e,c)){let t=n(e);if(s?!Sv(t,e.values[o],r):!r(t,e.values[o]))return e.values[o]=t,1}return 0},reconfigure:(e,t)=>{let a,l=t.config.address[i];if(null!=l){let i=Fv(t,l);if(this.dependencies.every((n=>n instanceof wv?t.facet(n)===e.facet(n):!(n instanceof Ov)||t.field(n,!1)==e.field(n,!1)))||(s?Sv(a=n(e),i,r):r(a=n(e),i)))return e.values[o]=i,0}else a=n(e);return e.values[o]=a,1}}}}function Sv(e,t,n){if(e.length!=t.length)return!1;for(let r=0;re[t.id])),i=n.map((e=>e.type)),o=r.filter((e=>!(1&e))),s=e[t.id]>>1;function a(e){let n=[];for(let t=0;te===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Tv).find((e=>e.field==this));return((null===t||void 0===t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}init(e){return[this,Tv.of({field:this,create:e})]}get extension(){return this}}const Av=4,_v=3,Pv=2,Nv=1;function Mv(e){return t=>new Rv(t,e)}const jv={highest:Mv(0),high:Mv(Nv),default:Mv(Pv),low:Mv(_v),lowest:Mv(Av)};class Rv{constructor(e,t){this.inner=e,this.prec=t}}class Iv{of(e){return new Dv(this,e)}reconfigure(e){return Iv.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Dv{constructor(e,t){this.compartment=e,this.inner=t}}class Lv{constructor(e,t,n,r,i,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,n){let r=[],i=Object.create(null),o=new Map;for(let h of function(e,t,n){let r=[[],[],[],[],[]],i=new Map;function o(e,s){let a=i.get(e);if(null!=a){if(a<=s)return;let t=r[a].indexOf(e);t>-1&&r[a].splice(t,1),e instanceof Dv&&n.delete(e.compartment)}if(i.set(e,s),Array.isArray(e))for(let t of e)o(t,s);else if(e instanceof Dv){if(n.has(e.compartment))throw new RangeError("Duplicate use of compartment in extensions");let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),o(r,s)}else if(e instanceof Rv)o(e.inner,e.prec);else if(e instanceof Ov)r[s].push(e),e.provides&&o(e.provides,s);else if(e instanceof kv)r[s].push(e),e.facet.extensions&&o(e.facet.extensions,Pv);else{let t=e.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(t,s)}}return o(e,Pv),r.reduce(((e,t)=>e.concat(t)))}(e,t,o))h instanceof Ov?r.push(h):(i[h.facet.id]||(i[h.facet.id]=[])).push(h);let s=Object.create(null),a=[],l=[];for(let h of r)s[h.id]=l.length<<1,l.push((e=>h.slot(e)));let c=null===n||void 0===n?void 0:n.config.facets;for(let h in i){let e=i[h],t=e[0].facet,r=c&&c[h]||[];if(e.every((e=>0==e.type)))if(s[t.id]=a.length<<1|1,xv(r,e))a.push(n.facet(t));else{let r=t.combine(e.map((e=>e.value)));a.push(n&&t.compare(r,n.facet(t))?n.facet(t):r)}else{for(let t of e)0==t.type?(s[t.id]=a.length<<1|1,a.push(t.value)):(s[t.id]=l.length<<1,l.push((e=>t.dynamicSlot(e))));s[t.id]=l.length<<1,l.push((n=>Ev(n,t,e)))}}let u=l.map((e=>e(s)));return new Lv(e,o,u,s,a,i)}}function Bv(e,t){if(1&t)return 2;let n=t>>1,r=e.status[n];if(4==r)throw new Error("Cyclic dependency between fields and/or facets");if(2&r)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Fv(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const zv=wv.define(),Hv=wv.define({combine:e=>e.some((e=>e)),static:!0}),$v=wv.define({combine:e=>e.length?e[0]:void 0,static:!0}),Uv=wv.define(),Wv=wv.define(),Vv=wv.define(),qv=wv.define({combine:e=>!!e.length&&e[0]});class Kv{constructor(e,t){this.type=e,this.value=t}static define(){return new Qv}}class Qv{of(e){return new Kv(this,e)}}class Gv{constructor(e){this.map=e}of(e){return new Jv(this,e)}}class Jv{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new Jv(this.type,t)}is(e){return this.type==e}static define(){return new Gv((arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}}Jv.reconfigure=Jv.define(),Jv.appendConfig=Jv.define();class Yv{constructor(e,t,n,r,i,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=i,this.scrollIntoView=o,this._doc=null,this._state=null,n&&yv(n,t.newLength),i.some((e=>e.type==Yv.time))||(this.annotations=i.concat(Yv.time.of(Date.now())))}static create(e,t,n,r,i,o){return new Yv(e,t,n,r,i,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Yv.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function Xv(e,t){let n=[];for(let r=0,i=0;;){let o,s;if(r=e[r]))o=e[r++],s=e[r++];else{if(!(i=0;i--){let o=n[i](e);o&&Object.keys(o).length&&(r=Zv(r,ey(t,o,e.changes.newLength),!0))}return r==e?e:Yv.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}(n?function(e){let t=e.startState,n=!0;for(let i of t.facet(Uv)){let t=i(e);if(!1===t){n=!1;break}Array.isArray(t)&&(n=!0===n?t:Xv(n,t))}if(!0!==n){let r,i;if(!1===n)i=e.changes.invertedDesc,r=cv.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=Yv.create(t,r,e.selection&&e.selection.map(i),Jv.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(Wv);for(let i=r.length-1;i>=0;i--){let n=r[i](e);e=n instanceof Yv?n:Array.isArray(n)&&1==n.length&&n[0]instanceof Yv?n[0]:ty(t,ry(n),!1)}return e}(i):i)}Yv.time=Kv.define(),Yv.userEvent=Kv.define(),Yv.addToHistory=Kv.define(),Yv.remote=Kv.define();const ny=[];function ry(e){return null==e?ny:Array.isArray(e)?e:[e]}var iy=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(iy||(iy={}));const oy=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let sy;try{sy=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(pm){}function ay(e){return t=>{if(!/\S/.test(t))return iy.Space;if(function(e){if(sy)return sy.test(e);for(let t=0;t"\x80"&&(n.toUpperCase()!=n.toLowerCase()||oy.test(n)))return!0}return!1}(t))return iy.Word;for(let n=0;n-1)return iy.Word;return iy.Other}}class ly{constructor(e,t,n,r,i,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,o&&(o._state=this);for(let s=0;s1&&void 0!==arguments[1])||arguments[1],n=this.config.address[e.id];if(null!=n)return Bv(this,n),Fv(this,n);if(t)throw new RangeError("Field is not present in this state")}update(){for(var e=arguments.length,t=new Array(e),n=0;ni.set(t,e))),n=null),i.set(o.value.compartment,o.value.extension)):o.is(Jv.reconfigure)?(n=null,r=o.value):o.is(Jv.appendConfig)&&(n=null,r=ry(r).concat(o.value));if(n)t=e.startState.values.slice();else{n=Lv.resolve(r,i,this),t=new ly(n,this.doc,this.selection,n.dynamicSlots.map((()=>null)),((e,t)=>t.reconfigure(e,this)),null).values}new ly(n,e.newDoc,e.newSelection,t,((t,n)=>n.update(t,e)),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:e},range:vv.cursor(t.from+e.length)})))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],o=ry(n.effects);for(let s=1;s0&&void 0!==arguments[0]?arguments[0]:[];return e instanceof cv?e:cv.of(e,this.doc.length,this.facet(ly.lineSeparator))}toText(e){return Fg.of(e.split(this.facet(ly.lineSeparator)||sv))}sliceDoc(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.doc.length;return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(Bv(this,t),Fv(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Ov&&null!=this.config.address[r.id]&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;if(!e||"string"!=typeof e.doc)throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(n)for(let i in n)if(Object.prototype.hasOwnProperty.call(e,i)){let t=n[i],o=e[i];r.push(t.init((e=>t.spec.fromJSON(o,e))))}return ly.create({doc:e.doc,selection:vv.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Lv.resolve(e.extensions||[],new Map),n=e.doc instanceof Fg?e.doc:Fg.of((e.doc||"").split(t.staticFacet(ly.lineSeparator)||sv)),r=e.selection?e.selection instanceof vv?e.selection:vv.single(e.selection.anchor,e.selection.head):vv.single(0);return yv(r,n.length),t.staticFacet(Hv)||(r=r.asSingle()),new ly(t,n,r,t.dynamicSlots.map((()=>null)),((e,t)=>t.create(e)),null)}get tabSize(){return this.facet(ly.tabSize)}get lineBreak(){return this.facet(ly.lineSeparator)||"\n"}get readOnly(){return this.facet(qv)}phrase(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r{if("$"==t)return"$";let r=+(t||1);return!r||r>n.length?e:n[r-1]}))),e}languageDataAt(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=[];for(let i of this.facet(zv))for(let o of i(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return ay(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),o=e-n,s=e-n;for(;o>0;){let e=Xg(t,o,!1);if(i(t.slice(e,o))!=iy.Word)break;o=e}for(;s2&&void 0!==arguments[2]?arguments[2]:{},r={};for(let i of e)for(let e of Object.keys(i)){let t=i[e],o=r[e];if(void 0===o)r[e]=t;else if(o===t||void 0===t);else{if(!Object.hasOwnProperty.call(n,e))throw new Error("Config merge conflict for field "+e);r[e]=n[e](o,t)}}for(let i in t)void 0===r[i]&&(r[i]=t[i]);return r}ly.allowMultipleSelections=Hv,ly.tabSize=wv.define({combine:e=>e.length?e[0]:4}),ly.lineSeparator=$v,ly.readOnly=qv,ly.phrases=wv.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every((n=>e[n]==t[n]))}}),ly.languageData=zv,ly.changeFilter=Uv,ly.transactionFilter=Wv,ly.transactionExtender=Vv,Iv.reconfigure=Jv.define();class uy{eq(e){return this==e}range(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return hy.create(e,t,this)}}uy.prototype.startSide=uy.prototype.endSide=0,uy.prototype.point=!1,uy.prototype.mapMode=av.TrackDel;class hy{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new hy(e,t,n)}}function dy(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class fy{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=n?this.to:this.from;for(let o=r,s=i.length;;){if(o==s)return o;let r=o+s>>1,a=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==o)return a>=0?o:s;a>=0?s=r:o=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,i);ic||l==c&&u.startSide>0&&u.endSide<=0)continue;(c-l||u.endSide-u.startSide)<0||(o<0&&(o=l),u.point&&(s=Math.max(s,c-l)),n.push(u),r.push(l-o),i.push(c-o))}return{mapped:n.length?new fy(r,i,n,s):null,pos:o}}}class py{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new py(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:i=this.length}=e,o=e.filter;if(0==t.length&&!o)return this;if(n&&(t=t.slice().sort(dy)),this.isEmpty)return t.length?py.of(t):this;let s=new vy(this,null,-1).goto(0),a=0,l=[],c=new my;for(;s.value||a=0){let e=t[a++];c.addInner(e.from,e.to,e.value)||l.push(e)}else 1==s.rangeIndex&&s.chunkIndexthis.chunkEnd(s.chunkIndex)||is.to||i=i&&e<=i+o.length&&!1===o.between(i,e-i,t-i,n))return}this.nextLayer.between(e,t,n)}}iter(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return yy.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return yy.from(e).goto(t)}static compare(e,t,n,r){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,o=e.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i)),s=t.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i)),a=gy(o,s,n),l=new wy(o,a,i),c=new wy(s,a,i);n.iterGaps(((e,t,n)=>xy(l,e,c,t,n,r))),n.empty&&0==n.length&&xy(l,0,c,0,0,r)}static eq(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3?arguments[3]:void 0;null==r&&(r=999999999);let i=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0)),o=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0));if(i.length!=o.length)return!1;if(!i.length)return!0;let s=gy(i,o),a=new wy(i,s,0).goto(n),l=new wy(o,s,0).goto(n);for(;;){if(a.to!=l.to||!ky(a.active,l.active)||a.point&&(!l.point||!a.point.eq(l.point)))return!1;if(a.to>r)return!0;a.next(),l.next()}}static spans(e,t,n,r){let i=new wy(e,null,arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1).goto(t),o=t,s=i.openStart;for(;;){let e=Math.min(i.to,n);if(i.point){let n=i.activeForPoint(i.to),a=i.pointFromo&&(r.span(o,e,i.active,s),s=i.openEnd(e));if(i.to>n)return s+(i.point&&i.to>n?1:0);o=i.to,i.next()}}static of(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new my;for(let r of e instanceof hy?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n0)return e.slice().sort(dy);t=r}return e}(e):e)n.add(r.from,r.to,r.value);return n.finish()}}py.empty=new py([],[],null,-1),py.empty.nextLayer=py.empty;class my{finishChunk(e){this.chunks.push(new fy(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new my)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(r<0)&&(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(py.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=py.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function gy(e,t,n){let r=new Map;for(let o of e)for(let e=0;e3&&void 0!==arguments[3]?arguments[3]:0;this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9;return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,r=[];for(let i=0;i=n&&r.push(new vy(o,t,n,i));return 1==r.length?r[0]:new yy(r)}get startSide(){return this.value?this.value.startSide:0}goto(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9;for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)by(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)by(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),by(this.heap,0)}}}function by(e,t){for(let n=e[t];;){let r=1+(t<<1);if(r>=e.length)break;let i=e[r];if(r+1=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}class wy{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=yy.from(e,t,n)}goto(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9;return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Sy(this.active,e),Sy(this.activeTo,e),Sy(this.activeRank,e),this.minActive=Ey(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Sy(n,r)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let e=this.cursor.value;if(e.point){if(!(t&&this.cursor.to==this.to&&this.cursor.from=0&&n[t]=0&&!(this.activeRank[n]e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function xy(e,t,n,r,i,o){e.goto(t),n.goto(r);let s=r+i,a=r,l=r-t;for(;;){let t=e.to+l-n.to||e.endSide-n.endSide,r=t<0?e.to+l:n.to,i=Math.min(r,s);if(e.point||n.point?e.point&&n.point&&(e.point==n.point||e.point.eq(n.point))&&ky(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,i,e.point,n.point):i>a&&!ky(e.active,n.active)&&o.compareRange(a,i,e.active,n.active),r>s)break;a=r,t<=0&&e.next(),t>=0&&n.next()}}function ky(e,t){if(e.length!=t.length)return!1;for(let n=0;n=t;r--)e[r+1]=e[r];e[t]=n}function Ey(e,t){let n=-1,r=1e9;for(let i=0;i2&&void 0!==arguments[2]?arguments[2]:e.length,r=0;for(let i=0;i=t)return i;if(i==e.length)break;o+=9==e.charCodeAt(i)?n-o%n:1,i=Xg(e,i)}return!0===r?-1:e.length}const Ay="undefined"==typeof Symbol?"__\u037c":Symbol.for("\u037c"),_y="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),Py="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Ny{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,o,s){let a=[],l=/^@(\w+)\b/.exec(e[0]),c=l&&"keyframes"==l[1];if(l&&null==t)return o.push(e[0]+";");for(let n in t){let s=t[n];if(/&/.test(n))i(n.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),s,o);else if(s&&"object"==typeof s){if(!l)throw new RangeError("The value of a property ("+n+") should be a primitive value.");i(r(n),s,a,c)}else null!=s&&a.push(n.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+s+";")}(a.length||c)&&o.push((!n||l||s?e:e.map(n)).join(", ")+" {"+a.join(" ")+"}")}for(let o in e)i(r(o),e[o],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=Py[Ay]||1;return Py[Ay]=e+1,"\u037c"+e.toString(36)}static mount(e,t){(e[_y]||new jy(e)).mount(Array.isArray(t)?t:[t])}}let My=new Map;class jy{constructor(e){let t=e.ownerDocument||e,n=t.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let r=My.get(t);if(r)return e.adoptedStyleSheets=[r.sheet,...e.adoptedStyleSheets],e[_y]=r;this.sheet=new n.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],My.set(t,this)}else{this.styleTag=t.createElement("style");let n=e.head||e;n.insertBefore(this.styleTag,n.firstChild)}this.modules=[],e[_y]=this}mount(e){let t=this.sheet,n=0,r=0;for(let i=0;i-1&&(this.modules.splice(s,1),r--,s=-1),-1==s){if(this.modules.splice(r++,0,o),t)for(let e=0;e",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Dy="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Ly="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),By=0;By<10;By++)Ry[48+By]=Ry[96+By]=String(By);for(By=1;By<=24;By++)Ry[By+111]="F"+By;for(By=65;By<=90;By++)Ry[By]=String.fromCharCode(By+32),Iy[By]=String.fromCharCode(By);for(var Fy in Ry)Iy.hasOwnProperty(Fy)||(Iy[Fy]=Ry[Fy]);function zy(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function Hy(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function $y(e,t){if(!t.anchorNode)return!1;try{return Hy(e,t.anchorNode)}catch(pm){return!1}}function Uy(e){return 3==e.nodeType?eb(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function Wy(e,t,n,r){return!!n&&(qy(e,t,n,r,-1)||qy(e,t,n,r,1))}function Vy(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function qy(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Ky(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=Vy(e)+(i<0?0:1),e=n}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(i<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=i<0?Ky(e):0}}}function Ky(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Qy(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function Gy(e){return{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}class Jy{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Ky(t):0),n,Math.min(e.focusOffset,n?Ky(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}let Yy,Xy=null;function Zy(e){if(e.setActive)return e.setActive();if(Xy)return e.focus(Xy);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==Xy?{get preventScroll(){return Xy={preventScroll:!0},!0}}:void 0),!Xy){Xy=!1;for(let e=0;e2&&void 0!==arguments[2]?arguments[2]:t,r=Yy||(Yy=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function tb(e,t,n){let r={key:t,code:t,keyCode:n,which:n,cancelable:!0},i=new KeyboardEvent("keydown",r);i.synthetic=!0,e.dispatchEvent(i);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,e.dispatchEvent(o),i.defaultPrevented||o.defaultPrevented}function nb(e){for(;e.attributes.length;)e.removeAttributeNode(e.attributes[0])}class rb{constructor(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];this.node=e,this.offset=t,this.precise=n}static before(e,t){return new rb(e.parentNode,Vy(e),t)}static after(e,t){return new rb(e.parentNode,Vy(e)+1,t)}}const ib=[];class ob{constructor(){this.parent=null,this.dom=null,this.dirty=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(2&this.dirty){let n,r=this.dom,i=null;for(let o of this.children){if(o.dirty){if(!o.dom&&(n=i?i.nextSibling:r.firstChild)){let e=ob.get(n);(!e||!e.parent&&e.canReuseDOM(o))&&o.reuseDOM(n)}o.sync(e,t),o.dirty=0}if(n=i?i.nextSibling:r.firstChild,t&&!t.written&&t.node==r&&n!=o.dom&&(t.written=!0),o.dom.parentNode==r)for(;n&&n!=o.dom;)n=sb(n);else r.insertBefore(o.dom,n);i=o.dom}for(n=i?i.nextSibling:r.firstChild,n&&t&&t.node==r&&(t.written=!0);n;)n=sb(n)}else if(1&this.dirty)for(let n of this.children)n.dirty&&(n.sync(e,t),n.dirty=0)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let r=0==Ky(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==this.dom)break;0==r&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}n=r<0?e:e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!ob.get(n);)n=n.nextSibling;if(!n)return this.length;for(let r=0,i=0;;r++){let e=this.children[r];if(e.dom==n)return i;i+=e.length+e.breakAfter}}domBoundsAround(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=-1,i=-1,o=-1,s=-1;for(let a=0,l=n,c=n;at)return n.domBoundsAround(e,t,l);if(u>=e&&-1==r&&(r=a,i=l),l>t&&n.dom.parentNode==this.dom){o=a,s=c;break}c=u,l=u+n.breakAfter}return{from:i,to:s<0?n+this.length:s,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.dirty|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.dirty|=2),1&t.dirty)return;t.dirty|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.dirty&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ib;this.markDirty();for(let r=e;r0&&void 0!==arguments[0]?arguments[0]:this.length;return new ab(this.children,e,this.children.length)}childPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==e?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,r,i,o){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor}getSide(){return 0}destroy(){this.parent=null}}function sb(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}ob.prototype.breakAfter=0;class ab{constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}findPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;for(;;){if(e>this.pos||e==this.pos&&(t>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function lb(e,t,n,r,i,o,s,a,l){let{children:c}=e,u=c.length?c[t]:null,h=o.length?o[o.length-1]:null,d=h?h.breakAfter:s;if(!(t==r&&u&&!s&&!d&&o.length<2&&u.merge(n,i,o.length?h:null,0==n,a,l))){if(r0&&(!s&&o.length&&u.merge(n,u.length,o[0],!1,a,0)?u.breakAfter=o.shift().breakAfter:(n2);var xb={mac:wb||/Mac/.test(ub.platform),windows:/Win/.test(ub.platform),linux:/Linux|X11/.test(ub.platform),ie:mb,ie_version:fb?hb.documentMode||6:pb?+pb[1]:db?+db[1]:0,gecko:gb,gecko_version:gb?+(/Firefox\/(\d+)/.exec(ub.userAgent)||[0,0])[1]:0,chrome:!!vb,chrome_version:vb?+vb[1]:0,ios:wb,android:/Android\b/.test(ub.userAgent),webkit:yb,safari:bb,webkit_version:yb?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=hb.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class kb extends ob{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){3==e.nodeType&&this.createDOM(e)}merge(e,t,n){return(!n||n instanceof kb&&!(this.length-(t-e)+n.length>256))&&(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new kb(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new rb(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return Cb(this.dom,e,t)}}class Sb extends ob{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;super(),this.mark=e,this.children=t,this.length=n;for(let r of t)r.setParent(this)}setAttrs(e){if(nb(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.dirty|=6)}sync(e,t){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,r,i,o){return(!n||!(!(n instanceof Sb&&n.mark.eq(this.mark))||e&&i<=0||te&&t.push(n=e&&(r=i),n=o,i++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new Sb(this.mark,t,o)}domAtPos(e){return Mb(this,e)}coordsAt(e,t){return Rb(this,e,t)}}function Cb(e,t,n){let r=e.nodeValue.length;t>r&&(t=r);let i=t,o=t,s=0;0==t&&n<0||t==r&&n>=0?xb.chrome||xb.gecko||(t?(i--,s=1):o=0)?0:a.length-1];return xb.safari&&!s&&0==l.width&&(l=Array.prototype.find.call(a,(e=>e.width))||l),s?Qy(l,s<0):l||null}class Eb extends ob{constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}static create(e,t,n){return new(e.customView||Eb)(e,t,n)}split(e){let t=Eb.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,n,r,i,o){return!(n&&(!(n instanceof Eb&&this.widget.compare(n.widget))||e>0&&i<=0||t0)?rb.before(this.dom):rb.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let r=this.dom.getClientRects(),i=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let s=o?r.length-1:0;i=r[s],!(e>0?0==s:s==r.length-1||i.tope.domAtPos(t)),((e,t)=>new rb(e,Math.min(t,e.nodeValue.length)))):new rb(n,Math.min(e,n.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(e,t){let{topView:n,text:r}=this.widget;return n?_b(e,t,n,r,this.length-n.length):Math.min(t,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(e,t){let{topView:n,text:r}=this.widget;return n?Ob(e,t,n,r,this.length-n.length,((e,t,n)=>e.coordsAt(t,n)),((e,t,n)=>Cb(e,t,n))):Cb(r,e,t)}destroy(){var e;super.destroy(),null===(e=this.widget.topView)||void 0===e||e.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function Ob(e,t,n,r,i,o,s){if(n instanceof Sb){for(let a=n.dom.firstChild;a;a=a.nextSibling){let n=ob.get(a);if(n){let l=Hy(a,r),c=n.length+(l?i:0);if(e0?rb.before(this.dom):rb.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Fg.empty}get isHidden(){return!0}}function Mb(e,t){let n=e.dom,{children:r}=e,i=0;for(let o=0;io&&t0;o--){let e=r[o-1];if(e.dom.parentNode==n)return e.domAtPos(e.length)}for(let o=i;o0&&t instanceof Sb&&i.length&&(r=i[i.length-1])instanceof Sb&&r.mark.eq(t.mark)?jb(r,t.children[0],n-1):(i.push(t),t.setParent(e)),e.length+=t.length}function Rb(e,t,n){let r=null,i=-1,o=null,s=-1;!function e(t,a){for(let l=0,c=0;l=a&&(u.children.length?e(u,a-c):(!o||o.isHidden&&n>0)&&(h>a||c==h&&u.getSide()>0)?(o=u,s=a-c):(c0?3e8:-4e8:t>0?1e8:-1e8,new Ub(e,t,t,n,e.widget||null,!1)}static replace(e){let t,n,r=!!e.block;if(e.isBlockGap)t=-5e8,n=4e8;else{let{start:i,end:o}=Wb(e,r);t=(i?r?-3e8:-1:5e8)-1,n=1+(o?r?2e8:1:-6e8)}return new Ub(e,t,n,r,e.widget||null,!0)}static line(e){return new $b(e)}static set(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return py.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}zb.none=py.empty;class Hb extends zb{constructor(e){let{start:t,end:n}=Wb(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){return this==e||e instanceof Hb&&this.tagName==e.tagName&&this.class==e.class&&Db(this.attrs,e.attrs)}range(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Hb.prototype.point=!1;class $b extends zb{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof $b&&this.spec.class==e.spec.class&&Db(this.spec.attributes,e.spec.attributes)}range(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}$b.prototype.mapMode=av.TrackBefore,$b.prototype.point=!0;class Ub extends zb{constructor(e,t,n,r,i,o){super(t,n,i,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?av.TrackBefore:av.TrackAfter:av.TrackDel}get type(){return this.startSide=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ub&&function(e,t){return e==t||!!(e&&t&&e.compare(t))}(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function Wb(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{inclusiveStart:n,inclusiveEnd:r}=e;return null==n&&(n=e.inclusive),null==r&&(r=e.inclusive),{start:null!==n&&void 0!==n?n:t,end:null!==r&&void 0!==r?r:t}}function Vb(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}Ub.prototype.point=!0;class qb extends ob{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,r,i,o){if(n){if(!(n instanceof qb))return!1;this.dom||n.transferDOM(this)}return r&&this.setDeco(n?n.attrs:null),cb(this,e,t,n?n.children:[],i,o),!0}split(e){let t=new qb;if(t.breakAfter=this.breakAfter,0==this.length)return t;let{i:n,off:r}=this.childPos(e);r&&(t.append(this.children[n].split(r),0),this.children[n].merge(r,this.children[n].length,null,!1,0,0),n++);for(let i=n;i0&&0==this.children[n-1].length;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Db(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){jb(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Ib(t,this.attrs||{})),n&&(this.attrs=Ib({class:n},this.attrs||{}))}domAtPos(e){return Mb(this,e)}reuseDOM(e){"DIV"==e.nodeName&&(this.setDOM(e),this.dirty|=6)}sync(e,t){var n;this.dom?4&this.dirty&&(nb(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(Lb(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&ob.get(r)instanceof Sb;)r=r.lastChild;if(!r||!this.length||"BR"!=r.nodeName&&0==(null===(n=ob.get(r))||void 0===n?void 0:n.isEditable)&&(!xb.ios||!this.children.some((e=>e instanceof kb)))){let e=document.createElement("BR");e.cmIgnore=!0,this.dom.appendChild(e)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let e,t=0;for(let n of this.children){if(!(n instanceof kb)||/[^ -~]/.test(n.text))return null;let r=Uy(n.dom);if(1!=r.length)return null;t+=r[0].width,e=r[0].height}return t?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:t/this.length,textHeight:e}:null}coordsAt(e,t){let n=Rb(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:e}=this.parent.view.viewState,t=n.bottom-n.top;if(Math.abs(t-e.lineHeight)<2&&e.textHeight=t){if(i instanceof qb)return i;if(o>t)break}r=o+i.breakAfter}return null}}class Kb extends ob{constructor(e,t,n){super(),this.widget=e,this.length=t,this.type=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,r,i,o){return!(n&&(!(n instanceof Kb&&this.widget.compare(n.widget))||e>0&&i<=0||t0&&void 0!==arguments[0]?arguments[0]:this.bufferMarks;this.pendingBuffer&&(this.curLine.append(Gb(new Nb(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skip);if(this.skip=0,r)throw new Error("Ran out of text content when drawing inline views");if(n){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}this.text=t,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(Gb(new kb(this.text.slice(this.textOff,this.textOff+r)),t),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=0}}span(e,t,n,r){this.buildText(t-e,n,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,n,r,i,o){if(this.disallowBlockEffectsFor[o]&&n instanceof Ub){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let s=t-e;if(n instanceof Ub)if(n.block){let{type:e}=n;e!=Fb.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new Kb(n.widget||new Jb("div"),s,e))}else{let o=Eb.create(n.widget||new Jb("span"),s,s?0:n.startSide),a=this.atCursorPos&&!o.isEditable&&i<=r.length&&(e0),l=!o.isEditable&&(er.length||n.startSide<=0),c=this.getLine();2!=this.pendingBuffer||a||o.isEditable||(this.pendingBuffer=0),this.flushBuffer(r),a&&(c.append(Gb(new Nb(1),r),i),i=r.length+Math.max(0,i-r.length)),c.append(Gb(o,r),i),this.atCursorPos=l,this.pendingBuffer=l?er.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);s&&(this.textOff+s<=this.text.length?this.textOff+=s:(this.skip+=s-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=i)}static build(e,t,n,r,i){let o=new Qb(e,t,n,i);return o.openEnd=py.spans(r,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Gb(e,t){for(let n of t)e=new Sb(n,[e],e.length);return e}class Jb extends Bb{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const Yb=wv.define(),Xb=wv.define(),Zb=wv.define(),ew=wv.define(),tw=wv.define(),nw=wv.define(),rw=wv.define(),iw=wv.define({combine:e=>e.some((e=>e))}),ow=wv.define({combine:e=>e.some((e=>e))});class sw{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"nearest",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"nearest",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:5;this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i}map(e){return e.empty?this:new sw(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}}const aw=Jv.define({map:(e,t)=>e.map(t)});function lw(e,t,n){let r=e.facet(ew);r.length?r[0](t):window.onerror?window.onerror(String(t),n,void 0,void 0,t):n?console.error(n+":",t):console.error(t)}const cw=wv.define({combine:e=>!e.length||e[0]});let uw=0;const hw=wv.define();class dw{constructor(e,t,n,r){this.id=e,this.create=t,this.domEventHandlers=n,this.extension=r(this)}static define(e,t){const{eventHandlers:n,provide:r,decorations:i}=t||{};return new dw(uw++,e,n,(e=>{let t=[hw.of(e)];return i&&t.push(gw.of((t=>{let n=t.plugin(e);return n?i(n):zb.none}))),r&&t.push(r(e)),t}))}static fromClass(e,t){return dw.define((t=>new e(t)),t)}}class fw{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(lw(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(pm){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){lw(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(n){lw(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const pw=wv.define(),mw=wv.define(),gw=wv.define(),vw=wv.define(),yw=wv.define();function bw(e){let t=0,n=0,r=0,i=0;for(let o of e.state.facet(yw)){let s=o(e);s&&(null!=s.left&&(t=Math.max(t,s.left)),null!=s.right&&(n=Math.max(n,s.right)),null!=s.top&&(r=Math.max(r,s.top)),null!=s.bottom&&(i=Math.max(i,s.bottom)))}return{left:t,right:n,top:r,bottom:i}}const ww=wv.define();class xw{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new xw(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toAc)break;i+=2}if(!a)return n;new xw(a.fromA,a.toA,a.fromB,a.toB).addToSet(n),o=a.toA,s=a.toB}}}class kw{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=cv.empty(this.startState.doc.length);for(let i of n)this.changes=this.changes.compose(i.changes);let r=[];this.changes.iterChangedRanges(((e,t,n,i)=>r.push(new xw(e,t,n,i)))),this.changedRanges=r}static create(e,t,n){return new kw(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((e=>e.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}var Sw=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(Sw||(Sw={}));const Cw=Sw.LTR,Ew=Sw.RTL;function Tw(e){let t=[];for(let n=0;n=t){if(s.level==n)return o;(i<0||(0!=r?r<0?s.fromt:e[i].level>s.level))&&(i=o)}}if(i<0)throw new RangeError("Index out of range");return i}}const jw=[];function Rw(e,t){let n=e.length,r=t==Cw?1:2,i=t==Cw?2:1;if(!e||1==r&&!Nw.test(e))return Iw(n);for(let a=0,l=r,c=r;a=0;e-=3)if(Pw[e+1]==-l){let t=Pw[e+2],n=2&t?r:4&t?1&t?i:r:0;n&&(jw[u]=jw[Pw[e]]=n),h=e;break}}else{if(189==Pw.length)break;Pw[h++]=u,Pw[h++]=a,Pw[h++]=d}else if(2==(c=jw[u])||1==c){let e=c==r;d=e?0:1;for(let t=h-3;t>=0;t-=3){let n=Pw[t+2];if(2&n)break;if(e)Pw[t+2]|=2;else{if(4&n)break;Pw[t+2]|=4}}}for(let a=0;a