").data("index",b).append($("").text(d&&
d.friendly?d.friendly:c.connector)).append($(" ").html(UI.format.status(c))).append($(" ").html(a(c))).append($(" ").css("text-align","right").html($("").text("Edit").click(function(){UI.navto("Edit Protocol",$(this).closest("tr").data("index"))})).append($("").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the protocol "'+mist.data.config.protocols[a].connector+'"?')){mist.send(function(){UI.navto("Protocols")},
{deleteprotocol:mist.data.config.protocols[a]});mist.data.config.protocols.splice(a,1)}}))))}};Ba();UI.interval.set(function(){mist.send(function(){Ba()})},1E4);break;case "Edit Protocol":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}var K=!1;""!=b&&0<=b&&(K=!0);var U={};for(r in mist.data.config.protocols)U[mist.data.config.protocols[r].connector]=1;var Ca=function(a){var b=mist.data.capabilities.connectors[a],c=
-mist.convertBuildOptions(b,n);if(K)var d=$.extend({},n);c.push({type:"hidden",pointer:{main:n,index:"connector"},value:a});c.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};K?a.updateprotocol=[d,n]:a.addprotocol=n;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){F=$("").text("Dependencies:");$ul=$("");F.append($ul);if(typeof b.deps=="string")b.deps=
-b.deps.split(", ");for(var e in b.deps){a=$("").text(b.deps[e]+" ");$ul.append(a);typeof U[b.deps[e]]!="undefined"||typeof U[b.deps[e]+".exe"]!="undefined"?a.append($("").addClass("green").text("(Configured)")):a.append($("").addClass("red").text("(Not yet configured)"))}c.unshift({type:"text",text:F[0].innerHTML})}return UI.buildUI(c)},U={};for(r in mist.data.config.protocols)U[mist.data.config.protocols[r].connector]=1;if(K){var s=mist.data.config.protocols[b],n=s;c.find("h2").append(' "'+
-s.connector+'"');c.append(Ca(s.connector))}else{c.html($("").text("New Protocol"));var n={},u=[["",""]];for(r in mist.data.capabilities.connectors)u.push([r,mist.data.capabilities.connectors[r].friendly?mist.data.capabilities.connectors[r].friendly:r]);var R=$("");c.append(UI.buildUI([{label:"Protocol",type:"select",select:u,"function":function(){$(this).getval()!=""&&R.html(Ca($(this).getval()))}}])).append(R)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},
+mist.convertBuildOptions(b,p);if(K)var d=$.extend({},p);c.push({type:"hidden",pointer:{main:p,index:"connector"},value:a});c.push({type:"buttons",buttons:[{type:"save",label:"Save","function":function(){var a={};K?a.updateprotocol=[d,p]:a.addprotocol=p;mist.send(function(){UI.navto("Protocols")},a)}},{type:"cancel",label:"Cancel","function":function(){UI.navto("Protocols")}}]});if("deps"in b&&b.deps!=""){F=$("").text("Dependencies:");$ul=$("");F.append($ul);if(typeof b.deps=="string")b.deps=
+b.deps.split(", ");for(var e in b.deps){a=$("").text(b.deps[e]+" ");$ul.append(a);typeof U[b.deps[e]]!="undefined"||typeof U[b.deps[e]+".exe"]!="undefined"?a.append($("").addClass("green").text("(Configured)")):a.append($("").addClass("red").text("(Not yet configured)"))}c.unshift({type:"text",text:F[0].innerHTML})}return UI.buildUI(c)},U={};for(r in mist.data.config.protocols)U[mist.data.config.protocols[r].connector]=1;if(K){var s=mist.data.config.protocols[b],p=s;c.find("h2").append(' "'+
+s.connector+'"');c.append(Ca(s.connector))}else{c.html($("").text("New Protocol"));var p={},u=[["",""]];for(r in mist.data.capabilities.connectors)u.push([r,mist.data.capabilities.connectors[r].friendly?mist.data.capabilities.connectors[r].friendly:r]);var R=$("");c.append(UI.buildUI([{label:"Protocol",type:"select",select:u,"function":function(){$(this).getval()!=""&&R.html(Ca($(this).getval()))}}])).append(R)}break;case "Streams":if(!("capabilities"in mist.data)){c.html("Loading..");mist.send(function(){UI.navto(a)},
{capabilities:!0});return}var Da=$(""),L=$("").text("Loading..");c.append(UI.buildUI([{type:"help",help:"Here you can create, edit or delete new and existing streams. Go to stream preview or embed a video player on your website."},$("").css({width:"45.25em",display:"flex","justify-content":"flex-end"}).append(Da).append($("
").text("Create a new stream").click(function(){UI.navto("Edit")}))])).append(L);""==b&&(h=mist.stored.get(),"viewmode"in h&&(b=h.viewmode));Da.text("Switch to "+
("thumbnails"==b?"list":"thumbnail")+" view").click(function(){mist.stored.set("viewmode",b=="thumbnails"?"list":"thumbnails");UI.navto("Streams",b=="thumbnails"?"list":"thumbnails")});var A=$.extend(!0,{},mist.data.streams),ka=function(a,b){var c=$.extend({},b);delete c.meta;delete c.error;c.online=2;c.name=a;c.ischild=true;return c},la=function(b,d,e){L.remove();switch(b){case "thumbnails":var g=$("").addClass("preview_icons"),f;f=e||[];d.sort();d.unshift("");L.remove();c.append($("
").text(a)).append(UI.buildUI([{label:"Filter the streams",
type:"datalist",datalist:d,pointer:{main:{},index:"stream"},help:"If you type something here, the box below will only show streams with names that contain your text.","function":function(){var a=$(this).val();g.children().each(function(){$(this).hide();$(this).attr("data-stream").indexOf(a)>-1&&$(this).show()})}}]));d.shift();c.append($("").addClass("description").text("Choose a stream below.")).append(g);for(var i in d){var b=d[i],h="",j=$("").text("Delete").click(function(){var a=
@@ -121,28 +121,27 @@ b).attr("data-stream",b))}break;default:var m=$("").append($("").appe
c.append(i);i.stupidtable();var n=function(){var a=[],b;for(b in mist.data.active_streams)a.push({streams:[mist.data.active_streams[b]],fields:["clients"],start:-2});mist.send(function(){$.extend(true,A,mist.data.streams);var a=0;m.html("");d.sort();for(var b in d){var c=d[b],e;e=c in mist.data.streams?mist.data.streams[c]:A[c];var g=$("").css("text-align","right").html($("").addClass("description").text("Loading..")),f=0;if(typeof mist.data.totals!="undefined"&&typeof mist.data.totals[c]!=
"undefined"){var i=mist.data.totals[c].all_protocols.clients,f=0;if(i.length){for(a in i)f=f+i[a][1];f=Math.round(f/i.length)}}g.html(UI.format.number(f));if(f==0&&e.online==1)e.online=2;f=$(" ").css("text-align","right").css("white-space","nowrap");(!("ischild"in e)||!e.ischild)&&f.html($("").text("Settings").click(function(){UI.navto("Edit",$(this).closest("tr").data("index"))})).append($("").text("Delete").click(function(){var a=$(this).closest("tr").data("index");if(confirm('Are you sure you want to delete the stream "'+
a+'"?')){delete mist.data.streams[a];var b={};mist.data.LTS?b.deletestream=[a]:b.streams=mist.data.streams;mist.send(function(){UI.navto("Streams")},b)}}));i=$("").text(e.name);e.ischild&&i.css("padding-left","1em");var h=UI.format.status(e),M=$("").text("Preview").click(function(){UI.navto("Preview",$(this).closest("tr").data("index"))}),q=$("").text("Embed").click(function(){UI.navto("Embed",$(this).closest("tr").data("index"))});if("filesfound"in A[c]||e.online<0){h.html("");
-M="";g.html("");q=""}m.append($("").data("index",c).html($("").html(i).attr("title",e.name=="..."?"The results were truncated":e.name).addClass("overflow_ellipsis")).append($(" ").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($(" ").data("sort-value",e.online).html(h)).append(g).append($(" ").css("white-space","nowrap").html(M).append(q)).append(f));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var p=
-0,o=0;for(f in mist.data.streams){i=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!i)break;if(mist.inputMatch(i.source_match,mist.data.streams[f].source)){A[f].source=A[f].source+"*";A[f].filesfound=null;mist.send(function(a,b){var c=b.stream,d=0,e;a:for(e in a.browse.files){var f;for(f in mist.data.capabilities.inputs)if(!(f.indexOf("Buffer")>=0||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder")>=0||f.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[f].source_match,
-"/"+a.browse.files[e])){var g=c+"+"+a.browse.files[e];A[g]=ka(g,mist.data.streams[c]);A[g].source=mist.data.streams[c].source+a.browse.files[e];d++;if(d>=500){A[c+"+zzzzzzzzz"]={ischild:true,name:"...",online:-1};break a}}}"files"in a.browse&&a.browse.files.length?A[c].filesfound=true:mist.data.streams[c].filesfound=false;o++;if(p==o){mist.send(function(){n()},{active_streams:true});UI.interval.set(function(){n()},5E3)}},{browse:mist.data.streams[f].source},{stream:f});p++}}if(p==0){mist.send(function(){n()},
+M="";g.html("");q=""}m.append($(" ").data("index",c).html($("").html(i).attr("title",e.name=="..."?"The results were truncated":e.name).addClass("overflow_ellipsis")).append($(" ").text(e.source).attr("title",e.source).addClass("description").addClass("overflow_ellipsis").css("max-width","20em")).append($(" ").data("sort-value",e.online).html(h)).append(g).append($(" ").css("white-space","nowrap").html(M).append(q)).append(f));a++}},{totals:a,active_streams:true})};if(mist.data.LTS){var o=
+0,p=0;for(f in mist.data.streams){i=mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"];if(!i)break;if(mist.inputMatch(i.source_match,mist.data.streams[f].source)){A[f].source=A[f].source+"*";A[f].filesfound=null;mist.send(function(a,b){var c=b.stream,d=0,e;a:for(e in a.browse.files){var f;for(f in mist.data.capabilities.inputs)if(!(f.indexOf("Buffer")>=0||f.indexOf("Buffer.exe")>=0||f.indexOf("Folder")>=0||f.indexOf("Folder.exe")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[f].source_match,
+"/"+a.browse.files[e])){var g=c+"+"+a.browse.files[e];A[g]=ka(g,mist.data.streams[c]);A[g].source=mist.data.streams[c].source+a.browse.files[e];d++;if(d>=500){A[c+"+zzzzzzzzz"]={ischild:true,name:"...",online:-1};break a}}}"files"in a.browse&&a.browse.files.length?A[c].filesfound=true:mist.data.streams[c].filesfound=false;p++;if(o==p){mist.send(function(){n()},{active_streams:true});UI.interval.set(function(){n()},5E3)}},{browse:mist.data.streams[f].source},{stream:f});o++}}if(o==0){mist.send(function(){n()},
{active_streams:true});UI.interval.set(function(){n()},5E3)}}else{mist.send(function(){n()},{active_streams:true});UI.interval.set(function(){n()},5E3)}}};if(mist.data.LTS){var ma=0,Ea=0,u={},Fa=[];for(h in mist.data.streams)if(mist.inputMatch((mist.data.capabilities.inputs.Folder||mist.data.capabilities.inputs["Folder.exe"]).source_match,mist.data.streams[h].source))Fa.push(h),mist.send(function(a,c){var d=c.stream,e=0,f;a:for(f in a.browse.files){var g;for(g in mist.data.capabilities.inputs)if(!(g.indexOf("Buffer")>=
0||g.indexOf("Folder")>=0)&&mist.inputMatch(mist.data.capabilities.inputs[g].source_match,"/"+a.browse.files[f])){u[d+"+"+a.browse.files[f]]=true;e++;if(e>=500){u[d+"+zzzzzzzzz"]=true;break a}}}Ea++;ma==Ea&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){u[mist.data.active_streams[a]]=true;A[mist.data.active_streams[a]]=ka(mist.data.active_streams[a],mist.data.streams[c[0]])}}u=Object.keys(u);u=u.concat(Object.keys(mist.data.streams));
u.sort();la(b,u,Fa)},{active_streams:true})},{browse:mist.data.streams[h].source},{stream:h}),ma++;0==ma&&mist.send(function(){for(var a in mist.data.active_streams){var c=mist.data.active_streams[a].split("+");if(c.length>1&&c[0]in mist.data.streams){u[mist.data.active_streams[a]]=true;A[mist.data.active_streams[a]]=ka(mist.data.active_streams[a],mist.data.streams[c[0]])}}u=Object.keys(u);mist.data.streams&&(u=u.concat(Object.keys(mist.data.streams)));u.sort();la(b,u)},{active_streams:!0})}else la(b,
-Object.keys(mist.data.streams));break;case "Edit":if("undefined"==typeof mist.data.capabilities){mist.send(function(){UI.navto(a,b)},{capabilities:!0});c.append("Loading..");return}K=!1;""!=b&&(K=!0);if(K){var Ga=b,n=mist.data.streams[Ga];c.find("h2").append(' "'+Ga+'"')}else c.html($("").text("New Stream")),n={};var Ha=[];for(r in mist.data.capabilities.inputs)Ha.push(mist.data.capabilities.inputs[r].source_match);var da=$(" "),Ia=function(a){var c={};if(!mist.data.streams)mist.data.streams=
-{};mist.data.streams[n.name]=n;b!=n.name&&delete mist.data.streams[b];c.addstream={};c.addstream[n.name]=n;if(b!=n.name)c.deletestream=[b];if(n.stop_sessions&&b!=""){c.stop_sessions=b;delete n.stop_sessions}mist.send(function(){delete mist.data.streams[n.name].online;delete mist.data.streams[n.name].error;UI.navto(a,a=="Preview"?n.name:"")},c)},Ja=$("