text: import{S as t,i as e,s as a,e as n,t as s,c as o,a as r,g as l,d as i,f as c,F as u,h as d,k as f,n as m,b as h,G as p,H as g,a4 as v,a5 as w,j as E,m as S,o as b,a6 as k,v as y,r as $,w as I,Q as D,z as T,a7 as V,l as x,u as O,M as N,N as M,L,R as H,B as _}from"../../chunks/vendor-5d015fce.js";import{T as j}from"../../chunks/index-b7ca9129.js";import{T as B,n as C,x as P,a as R,g as F}from"../../chunks/requests-b02e315d.js";import{s as U,a as K,b as q}from"../../chunks/store-50f97f41.js";/* empty css                                                       */function A(t){let e,a,f,m,h,p,g=t[2].frame+"",v=t[2].timestamp.toFixed(3)+"";return{c(){e=n("h6"),a=s("Frame: "),f=s(g),m=s(" at time t="),h=s(v),p=s(" seconds.")},l(t){e=o(t,"H6",{});var n=r(e);a=l(n,"Frame: "),f=l(n,g),m=l(n," at time t="),h=l(n,v),p=l(n," seconds."),n.forEach(i)},m(t,n){c(t,e,n),u(e,a),u(e,f),u(e,m),u(e,h),u(e,p)},p(t,e){4&e&&g!==(g=t[2].frame+"")&&d(f,g),4&e&&v!==(v=t[2].timestamp.toFixed(3)+"")&&d(h,v)},d(t){t&&i(e)}}}function W(t){let e,a,s,l,d,v,w=t[0]&&A(t);return{c(){e=n("div"),w&&w.c(),a=f(),s=n("img"),this.h()},l(t){e=o(t,"DIV",{ref:!0,class:!0});var n=r(e);w&&w.l(n),a=m(n),s=o(n,"IMG",{src:!0,alt:!0}),n.forEach(i),this.h()},h(){s.src!==(l=t[1])&&h(s,"src",l),h(s,"alt",J),h(e,"ref","display"),h(e,"class","image-display")},m(t,n){c(t,e,n),w&&w.m(e,null),u(e,a),u(e,s),d||(v=p(e,"click",z),d=!0)},p(t,[n]){t[0]?w?w.p(t,n):(w=A(t),w.c(),w.m(e,a)):w&&(w.d(1),w=null),2&n&&s.src!==(l=t[1])&&h(s,"src",l)},i:g,o:g,d(t){t&&i(e),w&&w.d(),d=!1,v()}}}let J="carla viewer";function z(){console.log(frame)}function G(t,e,a){let{sensorName:n=""}=e,{showStats:s=!0}=e,{src:o=""}=e,{meta:r={frame:0,timestamp:0}}=e,{sensorData:l={}}=e;return t.$$set=t=>{"sensorName"in t&&a(3,n=t.sensorName),"showStats"in t&&a(0,s=t.showStats),"src"in t&&a(1,o=t.src),"meta"in t&&a(2,r=t.meta),"sensorData"in t&&a(4,l=t.sensorData)},[s,o,r,n,l]}class Q extends t{constructor(t){super(),e(this,t,G,W,a,{sensorName:3,showStats:0,src:1,meta:2,sensorData:4})}}var X=[{latitude:.0009193044393214223,longitude:.001347095566868799,altitude:8},{latitude:.0008084837556765478,longitude:.0013115403148145012,altitude:8},{latitude:.0007186522272633056,longitude:.001383405537544063,altitude:8},{latitude:.0006288206988642742,longitude:.0013115403148145012,altitude:8},{latitude:.0005389891704510319,longitude:.001383405537544063,altitude:7.5},{latitude:.0004491576420520005,longitude:.0013115403148145012,altitude:6},{latitude:.0003593261136387582,longitude:.001383405537544063,altitude:5},{latitude:.00026949458522551595,longitude:.0013115403148145012,altitude:3},{latitude:.00017966305681227368,longitude:.001383405537544063,altitude:2.5},{latitude:8983152841324227e-20,longitude:.0013115403148145012,altitude:2},{latitude:0,longitude:.001383405537544063,altitude:2},{latitude:-8983152842745312e-20,longitude:.0013115403148145012,altitude:2},{latitude:-.00017966305682648454,longitude:.001383405537544063,altitude:1},{latitude:-.00026949458522551595,longitude:.0013115403148145012,altitude:1}];function Y(t){let e,a,g,T,V,x,O,N,M,L,H,_,j,C,P,R,F,U,K,q,A,W,J,z,G,X,Y,Z,tt,et,at,nt,st,ot,rt,lt,it,ct,ut,dt,ft,mt,ht,pt,gt,vt,wt,Et,St,bt,kt,yt,$t,It,Dt,Tt,Vt,xt,Ot,Nt,Mt,Lt,Ht,_t,jt,Bt,Ct,Pt,Rt,Ft,Ut,Kt,qt,At,Wt,Jt,zt,Gt,Qt,Xt,Yt,Zt,te,ee,ae,ne,se,oe,re,le,ie,ce,ue,de,fe=t[5].throttle.toFixed(3)+"",me=t[5].brake.toFixed(3)+"",he=t[5].steer.toFixed(3)+"";function pe(e){t[17](e)}function ge(e){t[18](e)}e=new B({});let ve={sensorName:"autopilot-camera1",showStats:!0};function we(e){t[19](e)}function Ee(e){t[20](e)}void 0!==t[0]&&(ve.src=t[0]),void 0!==t[2]&&(ve.meta=t[2]),J=new Q({props:ve}),v.push((()=>w(J,"src",pe))),v.push((()=>w(J,"meta",ge)));let Se={sensorName:"autopilot-camera2",showStats:!0};return void 0!==t[1]&&(Se.src=t[1]),void 0!==t[3]&&(Se.meta=t[3]),Y=new Q({props:Se}),v.push((()=>w(Y,"src",we))),v.push((()=>w(Y,"meta",Ee))),{c(){E(e.$$.fragment),a=f(),g=n("div"),T=n("div"),V=n("button"),x=s("Start Simulation"),O=f(),N=n("div"),M=n("div"),L=n("button"),H=s("Stop Simulation"),_=f(),j=n("hr"),C=f(),P=n("div"),R=n("div"),F=n("div"),U=n("div"),K=n("div"),q=n("h4"),A=s("Dash Cam"),W=f(),E(J.$$.fragment),X=f(),E(Y.$$.fragment),et=f(),at=n("div"),nt=n("h4"),st=s("Manual Control"),ot=f(),rt=n("input"),lt=f(),it=n("h4"),ct=s("Vehicle Inputs"),ut=f(),dt=n("div"),ft=n("div"),mt=n("label"),ht=s("Throttle:"),pt=f(),gt=n("div"),vt=n("div"),wt=s(fe),Et=f(),St=n("div"),bt=n("div"),kt=n("label"),yt=s("Brake:"),$t=f(),It=n("div"),Dt=n("div"),Tt=s(me),Vt=f(),xt=n("div"),Ot=n("div"),Nt=n("label"),Mt=s("Steer:"),Lt=f(),Ht=n("div"),_t=n("div"),jt=s(he),Bt=f(),Ct=n("div"),Pt=n("div"),Rt=n("h4"),Ft=s("Position"),Ut=f(),Kt=n("p"),qt=s(t[7]),At=f(),Wt=n("div"),Jt=n("h4"),zt=s("Orientation"),Gt=f(),Qt=n("p"),Xt=s(t[8]),Yt=f(),Zt=n("div"),te=n("h4"),ee=s("Speed"),ae=f(),ne=n("p"),se=s(t[6]),oe=f(),re=n("div"),le=n("button"),ie=s("Reset Vehicle"),this.h()},l(n){S(e.$$.fragment,n),a=m(n),g=o(n,"DIV",{class:!0});var s=r(g);T=o(s,"DIV",{class:!0});var c=r(T);V=o(c,"BUTTON",{class:!0});var u=r(V);x=l(u,"Start Simulation"),u.forEach(i),c.forEach(i),s.forEach(i),O=m(n),N=o(n,"DIV",{class:!0});var d=r(N);M=o(d,"DIV",{class:!0});var f=r(M);L=o(f,"BUTTON",{class:!0});var h=r(L);H=l(h,"Stop Simulation"),h.forEach(i),f.forEach(i),d.forEach(i),_=m(n),j=o(n,"HR",{}),C=m(n),P=o(n,"DIV",{class:!0});var p=r(P);R=o(p,"DIV",{class:!0});var v=r(R);F=o(v,"DIV",{class:!0});var w=r(F);U=o(w,"DIV",{class:!0});var E=r(U);K=o(E,"DIV",{class:!0});var b=r(K);q=o(b,"H4",{});var k=r(q);A=l(k,"Dash Cam"),k.forEach(i),W=m(b),S(J.$$.fragment,b),X=m(b),S(Y.$$.fragment,b),b.forEach(i),et=m(E),at=o(E,"DIV",{class:!0});var y=r(at);nt=o(y,"H4",{});var $=r(nt);st=l($,"Manual Control"),$.forEach(i),ot=m(y),rt=o(y,"INPUT",{type:!0}),lt=m(y),it=o(y,"H4",{});var I=r(it);ct=l(I,"Vehicle Inputs"),I.forEach(i),ut=m(y),dt=o(y,"DIV",{});var D=r(dt);ft=o(D,"DIV",{cols:!0,class:!0});var B=r(ft);mt=o(B,"LABEL",{for:!0});var z=r(mt);ht=l(z,"Throttle:"),z.forEach(i),B.forEach(i),pt=m(D),gt=o(D,"DIV",{class:!0});var G=r(gt);vt=o(G,"DIV",{class:!0});var Q=r(vt);wt=l(Q,fe),Q.forEach(i),G.forEach(i),D.forEach(i),Et=m(y),St=o(y,"DIV",{});var Z=r(St);bt=o(Z,"DIV",{class:!0});var tt=r(bt);kt=o(tt,"LABEL",{for:!0});var ce=r(kt);yt=l(ce,"Brake:"),ce.forEach(i),tt.forEach(i),$t=m(Z),It=o(Z,"DIV",{class:!0});var ue=r(It);Dt=o(ue,"DIV",{class:!0});var de=r(Dt);Tt=l(de,me),de.forEach(i),ue.forEach(i),Z.forEach(i),Vt=m(y),xt=o(y,"DIV",{});var pe=r(xt);Ot=o(pe,"DIV",{class:!0});var ge=r(Ot);Nt=o(ge,"LABEL",{for:!0});var ve=r(Nt);Mt=l(ve,"Steer:"),ve.forEach(i),ge.forEach(i),Lt=m(pe),Ht=o(pe,"DIV",{cols:!0,class:!0});var we=r(Ht);_t=o(we,"DIV",{class:!0});var Ee=r(_t);jt=l(Ee,he),Ee.forEach(i),we.forEach(i),pe.forEach(i),Bt=m(y),Ct=o(y,"DIV",{class:!0});var Se=r(Ct);Pt=o(Se,"DIV",{});var be=r(Pt);Rt=o(be,"H4",{});var ke=r(Rt);Ft=l(ke,"Position"),ke.forEach(i),Ut=m(be),Kt=o(be,"P",{class:!0});var ye=r(Kt);qt=l(ye,t[7]),ye.forEach(i),be.forEach(i),At=m(Se),Wt=o(Se,"DIV",{});var $e=r(Wt);Jt=o($e,"H4",{});var Ie=r(Jt);zt=l(Ie,"Orientation"),Ie.forEach(i),Gt=m($e),Qt=o($e,"P",{class:!0});var De=r(Qt);Xt=l(De,t[8]),De.forEach(i),$e.forEach(i),Yt=m(Se),Zt=o(Se,"DIV",{});var Te=r(Zt);te=o(Te,"H4",{});var Ve=r(te);ee=l(Ve,"Speed"),Ve.forEach(i),ae=m(Te),ne=o(Te,"P",{class:!0});var xe=r(ne);se=l(xe,t[6]),xe.forEach(i),Te.forEach(i),Se.forEach(i),oe=m(y),re=o(y,"DIV",{class:!0});var Oe=r(re);le=o(Oe,"BUTTON",{class:!0});var Ne=r(le);ie=l(Ne,"Reset Vehicle"),Ne.forEach(i),Oe.forEach(i),y.forEach(i),E.forEach(i),w.forEach(i),v.forEach(i),p.forEach(i),this.h()},h(){h(V,"class","w3-col w3-input w3-border"),h(T,"class","w3-rest"),h(g,"class","w3-row w3-section"),h(L,"class","w3-col w3-input w3-border"),h(M,"class","w3-rest"),h(N,"class","w3-row w3-section"),h(K,"class","col-xl-6"),h(rt,"type","checkbox"),h(mt,"for","range-throttle"),h(ft,"cols","2"),h(ft,"class","align-self-center"),h(vt,"class","mt-2"),h(gt,"class","align-self-center"),h(kt,"for","range-brake"),h(bt,"class","align-self-center"),h(Dt,"class","mt-2"),h(It,"class","align-self-center"),h(Nt,"for","range-throttle"),h(Ot,"class","align-self-center"),h(_t,"class","mt-2"),h(Ht,"cols","2"),h(Ht,"class","align-self-center"),h(Kt,"class","svelte-au1azq"),h(Qt,"class","svelte-au1azq"),h(ne,"class","svelte-au1azq"),h(Ct,"class","mt-3"),h(le,"class","my-1 align-self-center"),h(re,"class","text-center"),h(at,"class","col-xl-6"),h(U,"class","w3-container"),h(F,"class","autopilot"),h(R,"class","w3-responsive"),h(P,"class","w3-container")},m(n,s){b(e,n,s),c(n,a,s),c(n,g,s),u(g,T),u(T,V),u(V,x),c(n,O,s),c(n,N,s),u(N,M),u(M,L),u(L,H),c(n,_,s),c(n,j,s),c(n,C,s),c(n,P,s),u(P,R),u(R,F),u(F,U),u(U,K),u(K,q),u(q,A),u(K,W),b(J,K,null),u(K,X),b(Y,K,null),u(U,et),u(U,at),u(at,nt),u(nt,st),u(at,ot),u(at,rt),rt.checked=t[4],u(at,lt),u(at,it),u(it,ct),u(at,ut),u(at,dt),u(dt,ft),u(ft,mt),u(mt,ht),u(dt,pt),u(dt,gt),u(gt,vt),u(vt,wt),u(at,Et),u(at,St),u(St,bt),u(bt,kt),u(kt,yt),u(St,$t),u(St,It),u(It,Dt),u(Dt,Tt),u(at,Vt),u(at,xt),u(xt,Ot),u(Ot,Nt),u(Nt,Mt),u(xt,Lt),u(xt,Ht),u(Ht,_t),u(_t,jt),u(at,Bt),u(at,Ct),u(Ct,Pt),u(Pt,Rt),u(Rt,Ft),u(Pt,Ut),u(Pt,Kt),u(Kt,qt),u(Ct,At),u(Ct,Wt),u(Wt,Jt),u(Jt,zt),u(Wt,Gt),u(Wt,Qt),u(Qt,Xt),u(Ct,Yt),u(Ct,Zt),u(Zt,te),u(te,ee),u(Zt,ae),u(Zt,ne),u(ne,se),u(at,oe),u(at,re),u(re,le),u(le,ie),ce=!0,ue||(de=[p(V,"click",t[11]),p(L,"click",t[12]),p(rt,"change",t[21]),p(rt,"change",t[9]),p(le,"click",t[10])],ue=!0)},p(t,e){const a={};!z&&1&e[0]&&(z=!0,a.src=t[0],k((()=>z=!1))),!G&&4&e[0]&&(G=!0,a.meta=t[2],k((()=>G=!1))),J.$set(a);const n={};!Z&&2&e[0]&&(Z=!0,n.src=t[1],k((()=>Z=!1))),!tt&&8&e[0]&&(tt=!0,n.meta=t[3],k((()=>tt=!1))),Y.$set(n),16&e[0]&&(rt.checked=t[4]),(!ce||32&e[0])&&fe!==(fe=t[5].throttle.toFixed(3)+"")&&d(wt,fe),(!ce||32&e[0])&&me!==(me=t[5].brake.toFixed(3)+"")&&d(Tt,me),(!ce||32&e[0])&&he!==(he=t[5].steer.toFixed(3)+"")&&d(jt,he),(!ce||128&e[0])&&d(qt,t[7]),(!ce||256&e[0])&&d(Xt,t[8]),(!ce||64&e[0])&&d(se,t[6])},i(t){ce||(y(e.$$.fragment,t),y(J.$$.fragment,t),y(Y.$$.fragment,t),ce=!0)},o(t){$(e.$$.fragment,t),$(J.$$.fragment,t),$(Y.$$.fragment,t),ce=!1},d(t){I(e,t),t&&i(a),t&&i(g),t&&i(O),t&&i(N),t&&i(_),t&&i(j),t&&i(C),t&&i(P),I(J),I(Y),ue=!1,D(de)}}}let Z=.1;function tt(t,e){let a=0;for(let n=0;n<3;n++)a+=t[n]*e[n];return a}function et(t){return Math.sqrt(tt(t,t))}function at(t,e,a){let n,s,{time_limit:o=30}=e,{attack_time:r=20}=e,l=!1,i=!1,{title:c}=e,{input_data:u}=e,d="",f="",m={timestamp:0,frame:0},h={timestamp:0,frame:0},p=[{name:"autopilot-gnss",type:"gnss"},{name:"autopilot-imu",type:"imu"},{name:"autopilot-tachometer",type:"tachometer"},{name:"autopilot-camera1",type:"camera"},{name:"autopilot-camera2",type:"camera"}],g=!1,v=null,w=!1,E=0,S=X,b=0,k=[0,-1,0],y={throttle:0,brake:0,steer:0},$={Kp:.5,Ki:.001,Kd:.02,tau:1,integrator:0,differentiator:0,lastError:0,lastMeasurement:0},I={Kp:.01,Ki:0,Kd:.01,tau:1,integrator:0,differentiator:0,lastError:0,lastMeasurement:0},D={},x="",O="-",N="",M="Lat: -, Lon: -, Alt: -",L="",H="-";function _(t){let e=D[t];return e||null}function j(t){let e=String.fromCharCode(t.keyCode).toLowerCase();g&&v===e||(g=!0,v=e,"w"===e?a(5,y.throttle=1,y):"a"===e?a(5,y.steer=-1,y):"s"===e?a(5,y.brake=1,y):"d"===e&&a(5,y.steer=1,y),P())}function B(t){g=!1;let e=String.fromCharCode(t.keyCode).toLowerCase();"w"===e?a(5,y.throttle=0,y):"a"===e?a(5,y.steer=0,y):"s"===e?a(5,y.brake=0,y):"d"===e&&a(5,y.steer=0,y),P()}function P(){V({method:"POST",url:"/control",data:y,headers:{"content-type":"application/json"}}).catch((function(t){C.danger("apply control failed")}))}function R(){s=performance.now(),console.log("start_time",n,"end_time:",s);let t=(s-n)/1e3;t>o&&(l=!0),console.log("diff time",t,"attack time;",r,"time_limit",o),t>r&&(i=!0,console.log("starting the attack!"));let e=D["autopilot-tachometer"].speed,c=D["autopilot-gnss"],u=D["autopilot-imu"].orientation,d=S[b];i&&(U?(c.longitude+=.005,U=!U):c.longitude-=.005);let f=function(t,e){let a=e-t,n=t,s=$.Kp*a,o=$.integrator+.5*$.Ki*Z*($.lastError+a),r=(2*$.Kd*(n-$.lastMeasurement)+(2*$.tau-Z)*$.differentiator)/(2*$.tau+Z),l=Math.min(Math.max(s+o+r,-1),1);return $.integrator=o,$.differentiator=r,$.lastError=a,$.lastMeasurement=n,l}(e,5),m=function(t,e,a){let n=[60*(a.longitude-t.longitude)*1852,60*-(a.latitude-t.latitude)*1852,0],s=Math.acos(Math.min(Math.max(tt(n,k)/(et(n)*et(k)),-1),1));s=s/Math.PI*180,function(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}(k,n)[2]<0&&(s=360-s);let o=s-e;o>180?o-=360:o<-180&&(o+=360);let r=e,l=I.Kp*o,i=I.integrator+.5*I.Ki*Z*(I.lastError+o),c=(2*I.Kd*(r-I.lastMeasurement)+(2*I.tau-Z)*I.differentiator)/(2*I.tau+Z),u=Math.min(Math.max(l+i+c,-1),1);I.integrator=i,I.differentiator=c,I.lastError=o,I.lastMeasurement=r,et(n)<2&&b++;b>=S.length&&(b=0);return u}(c,u,d);f>=0?(a(5,y.throttle=Math.min(f,.75),y),a(5,y.brake=0,y)):(a(5,y.throttle=0,y),a(5,y.brake=Math.min(Math.abs(f),1),y)),m>y.steer+.1?m=y.steer+.1:m<y.steer-.1&&(m=y.steer-.1),a(5,y.steer=m>=0?Math.min(1,m):Math.max(-1,m),y),P(),l&&(E&&clearInterval(E),F(),P())}function F(){b=0,a(5,y.throttle=0,y),a(5,y.brake=1,y),a(5,y.steer=0,y),$.integrator=0,$.differentiator=0,$.lastError=0,$.lastMeasurement=0,I.integrator=0,I.differentiator=0,I.lastError=0,I.lastMeasurement=0,V({method:"POST",url:"/config",headers:{"content-type":"application/json"},data:{simulation:{reset:!0}}}).then((()=>{console.log("Simulation was reset!")}),(t=>{console.log(t)}))}T((async()=>{V({method:"POST",url:"/config",headers:{"content-type":"application/json"},data:{newSensors:p}}).then((t=>{p.forEach((t=>{!function(t){let e="http://localhost:8000/sensor/"+t.type+"/"+t.name+"/websocket";e=e.replace("http","ws");let n=new WebSocket(e);n.onopen=function(){console.log("WebSocket connection established with "+e)},n.onmessage=function(e){let n=JSON.parse(e.data);D[t.name]=n,"autopilot-camera1"==t.name&&(a(0,d="data:image/jpeg;base64,"+n.image),a(2,m={timestamp:n.timestamp,frame:n.frame})),"autopilot-camera2"==t.name&&(a(1,f="data:image/jpeg;base64,"+n.image),a(3,h={timestamp:n.timestamp,frame:n.frame})),"autopilot-tachometer"==t.name&&(x=_("autopilot-tachometer"),x&&a(6,O=x.speed.toFixed(3)+" m/s")),"autopilot-gnss"==t.name&&(N=_("autopilot-gnss"),N&&a(7,M="Lat: "+N.latitude+" °\nLon: "+N.longitude+" °\nAlt: "+N.altitude.toFixed(2)+" m")),"autopilot-imu"==t.name&&(L=_("autopilot-imu"),L&&a(8,H=L.orientation.toFixed(3)+" °"))}}(t)}));let e={enabled:!0,updateInterval:.1,imageWidth:800,imageHeight:600,fov:90},n="/sensor/camera/autopilot-camera1";V({method:"POST",url:n,data:{settings:e},headers:{"content-type":"application/json"}}).catch((function(t){C.danger("axos request 1 to carla failed")})),e.position={x:-6,y:0,z:5},e.rotation={roll:0,pitch:-35,yaw:0},n="/sensor/camera/autopilot-camera2",V({method:"POST",url:n,data:{settings:e},headers:{"content-type":"application/json"}}).catch((function(t){C.danger("axos request 2 to carla failed")}));n="/sensor/imu/autopilot-imu",V({method:"POST",url:n,data:{settings:{enabled:!0,updateInterval:.1}},headers:{"content-type":"application/json"}}).catch((function(t){C.danger("axos request 3 to carla failed")}));n="/sensor/gnss/autopilot-gnss",V({method:"POST",url:n,data:{settings:{enabled:!0,updateInterval:.1}},headers:{"content-type":"application/json"}}).catch((function(t){C.danger("axos request 4 to carla failed")}));n="/sensor/tachometer/autopilot-tachometer",V({method:"POST",url:n,data:{settings:{enabled:!0,updateInterval:.1}},headers:{"content-type":"application/json"}}).then((()=>{C.info("autopilot mode on.")})),C.success("The required sensors for the autopilot have been successfully created.")}),(t=>{C.danger("failed to call /config sensor")}))}));let U=!0;return t.$$set=t=>{"time_limit"in t&&a(13,o=t.time_limit),"attack_time"in t&&a(14,r=t.attack_time),"title"in t&&a(15,c=t.title),"input_data"in t&&a(16,u=t.input_data)},[d,f,m,h,w,y,O,M,H,function(){console.log("manual control:",w),w?(window.addEventListener("keydown",j),window.addEventListener("keyup",B),E&&clearInterval(E),a(5,y.throttle=0,y),a(5,y.brake=1,y),a(5,y.steer=0,y)):(window.removeEventListener("keydown",j),window.removeEventListener("keyup",B),E=setInterval(R,20))},F,function(){E&&clearInterval(E),l=!1,i=!1,n=performance.now(),s=performance.now(),a(4,w=!1),window.removeEventListener("keydown",j),window.removeEventListener("keyup",B),E=setInterval(R,20)},function(){l=!1,i=!1,clearInterval(E),F()},o,r,c,u,function(t){d=t,a(0,d)},function(t){m=t,a(2,m)},function(t){f=t,a(1,f)},function(t){h=t,a(3,h)},function(){w=this.checked,a(4,w)}]}class nt extends t{constructor(t){super(),e(this,t,at,Y,a,{time_limit:13,attack_time:14,title:15,input_data:16},[-1,-1])}}function st(t){let e,a,d,v,w,E,S,b,k,y;return{c(){e=n("div"),a=n("span"),d=s("×"),v=f(),w=n("img"),S=f(),b=n("div"),this.h()},l(t){e=o(t,"DIV",{id:!0,class:!0});var n=r(e);a=o(n,"SPAN",{class:!0});var s=r(a);d=l(s,"×"),s.forEach(i),v=m(n),w=o(n,"IMG",{class:!0,id:!0,src:!0}),S=m(n),b=o(n,"DIV",{id:!0,class:!0}),r(b).forEach(i),n.forEach(i),this.h()},h(){h(a,"class","close svelte-rk4oiy"),h(w,"class","modal-content svelte-rk4oiy"),h(w,"id","img01"),w.src!==(E="")&&h(w,"src",""),h(b,"id","caption"),h(b,"class","svelte-rk4oiy"),h(e,"id","myModal"),h(e,"class","modal svelte-rk4oiy")},m(t,n){c(t,e,n),u(e,a),u(a,d),u(e,v),u(e,w),u(e,S),u(e,b),k||(y=p(a,"click",ot),k=!0)},p:g,i:g,o:g,d(t){t&&i(e),k=!1,y()}}}function ot(){document.getElementById("myModal").style.display="none"}function rt(t,e){var a=document.getElementById("myModal"),n=document.getElementById("img01"),s=document.getElementById("caption");a.style.display="block",n.src=t,s.innerHTML=e}function lt(t,e,a){return[rt]}class it extends t{constructor(t){super(),e(this,t,lt,st,a,{changeImage:0})}get changeImage(){return rt}}function ct(t,e,a){const n=t.slice();return n[32]=e[a],n[34]=a,n}function ut(t,e,a){const n=t.slice();return n[35]=e[a],n[34]=a,n}function dt(t,e,a){const n=t.slice();return n[35]=e[a],n[34]=a,n}function ft(t,e,a){const n=t.slice();return n[38]=e[a],n[39]=e,n[40]=a,n}function mt(t){let e,a,g,v,w,E,S,b,k,I,T,V,x,N,M,L,H,j,B,C,P,R,F,U,K,q,A,W,J,z,G,Q,X,Y,Z,tt,et="configurations"in t[1]&&ht(t);return{c(){e=n("h4"),a=s("Scenario: "),g=s(t[3]),v=s(" Number of Containers: "),w=s(t[4]),E=s("."),S=f(),b=n("div"),k=n("div"),I=n("button"),T=s("Start Simulation"),V=f(),x=n("div"),N=n("button"),M=s("Stop Simulation"),L=f(),H=n("div"),j=n("button"),B=s("Reset WS Connection"),C=f(),P=n("hr"),R=f(),F=n("section"),U=n("h3"),K=s("Application Logs"),q=f(),A=n("button"),W=s("Clear Logs"),J=f(),et&&et.c(),z=f(),G=n("br"),Q=f(),X=n("hr"),this.h()},l(n){e=o(n,"H4",{});var s=r(e);a=l(s,"Scenario: "),g=l(s,t[3]),v=l(s," Number of Containers: "),w=l(s,t[4]),E=l(s,"."),s.forEach(i),S=m(n),b=o(n,"DIV",{class:!0});var c=r(b);k=o(c,"DIV",{class:!0});var u=r(k);I=o(u,"BUTTON",{class:!0});var d=r(I);T=l(d,"Start Simulation"),d.forEach(i),u.forEach(i),V=m(c),x=o(c,"DIV",{class:!0});var f=r(x);N=o(f,"BUTTON",{class:!0});var h=r(N);M=l(h,"Stop Simulation"),h.forEach(i),f.forEach(i),L=m(c),H=o(c,"DIV",{class:!0});var p=r(H);j=o(p,"BUTTON",{class:!0});var y=r(j);B=l(y,"Reset WS Connection"),y.forEach(i),p.forEach(i),c.forEach(i),C=m(n),P=o(n,"HR",{class:!0}),R=m(n),F=o(n,"SECTION",{class:!0});var $=r(F);U=o($,"H3",{});var D=r(U);K=l(D,"Application Logs"),D.forEach(i),$.forEach(i),q=m(n),A=o(n,"BUTTON",{class:!0});var O=r(A);W=l(O,"Clear Logs"),O.forEach(i),J=m(n),et&&et.l(n),z=m(n),G=o(n,"BR",{}),Q=m(n),X=o(n,"HR",{class:!0}),this.h()},h(){h(I,"class","w3-col w3-input w3-border"),h(k,"class","w3-third"),h(N,"class","w3-col w3-input w3-border"),h(x,"class","w3-third"),h(j,"class","w3-col w3-input w3-border"),h(H,"class","w3-third"),h(b,"class","w3-row w3-section"),h(P,"class","svelte-drd2kv"),h(F,"class","page-headline"),h(A,"class","w3-col w3-input w3-border w3-button"),h(X,"class","svelte-drd2kv")},m(n,s){c(n,e,s),u(e,a),u(e,g),u(e,v),u(e,w),u(e,E),c(n,S,s),c(n,b,s),u(b,k),u(k,I),u(I,T),u(b,V),u(b,x),u(x,N),u(N,M),u(b,L),u(b,H),u(H,j),u(j,B),c(n,C,s),c(n,P,s),c(n,R,s),c(n,F,s),u(F,U),u(U,K),c(n,q,s),c(n,A,s),u(A,W),c(n,J,s),et&&et.m(n,s),c(n,z,s),c(n,G,s),c(n,Q,s),c(n,X,s),Y=!0,Z||(tt=[p(I,"click",t[15]),p(N,"click",t[16]),p(j,"click",t[17]),p(A,"click",t[8])],Z=!0)},p(t,e){(!Y||8&e[0])&&d(g,t[3]),(!Y||16&e[0])&&d(w,t[4]),"configurations"in t[1]?et?(et.p(t,e),2&e[0]&&y(et,1)):(et=ht(t),et.c(),y(et,1),et.m(z.parentNode,z)):et&&(_(),$(et,1,1,(()=>{et=null})),O())},i(t){Y||(y(et),Y=!0)},o(t){$(et),Y=!1},d(t){t&&i(e),t&&i(S),t&&i(b),t&&i(C),t&&i(P),t&&i(R),t&&i(F),t&&i(q),t&&i(A),t&&i(J),et&&et.d(t),t&&i(z),t&&i(G),t&&i(Q),t&&i(X),Z=!1,D(tt)}}}function ht(t){let e,a,n=t[1].configurations.length>0&&pt(t);return{c(){n&&n.c(),e=x()},l(t){n&&n.l(t),e=x()},m(t,s){n&&n.m(t,s),c(t,e,s),a=!0},p(t,a){t[1].configurations.length>0?n?(n.p(t,a),2&a[0]&&y(n,1)):(n=pt(t),n.c(),y(n,1),n.m(e.parentNode,e)):n&&(_(),$(n,1,1,(()=>{n=null})),O())},i(t){a||(y(n),a=!0)},o(t){$(n),a=!1},d(t){n&&n.d(t),t&&i(e)}}}function pt(t){let e,a,n=t[1].configurations,s=[];for(let r=0;r<n.length;r+=1)s[r]=Et(ft(t,n,r));const o=t=>$(s[t],1,1,(()=>{s[t]=null}));return{c(){for(let t=0;t<s.length;t+=1)s[t].c();e=x()},l(t){for(let e=0;e<s.length;e+=1)s[e].l(t);e=x()},m(t,n){for(let e=0;e<s.length;e+=1)s[e].m(t,n);c(t,e,n),a=!0},p(t,a){if(34&a[0]){let r;for(n=t[1].configurations,r=0;r<n.length;r+=1){const o=ft(t,n,r);s[r]?(s[r].p(o,a),y(s[r],1)):(s[r]=Et(o),s[r].c(),y(s[r],1),s[r].m(e.parentNode,e))}for(_(),r=n.length;r<s.length;r+=1)o(r);O()}},i(t){if(!a){for(let t=0;t<n.length;t+=1)y(s[t]);a=!0}},o(t){s=s.filter(Boolean);for(let e=0;e<s.length;e+=1)$(s[e]);a=!1},d(t){N(s,t),t&&i(e)}}}function gt(t){let e,a,n=t[40].toString()in t[5],s=n&&vt(t);return{c(){s&&s.c(),e=x()},l(t){s&&s.l(t),e=x()},m(t,n){s&&s.m(t,n),c(t,e,n),a=!0},p(t,a){32&a[0]&&(n=t[40].toString()in t[5]),n?s?(s.p(t,a),32&a[0]&&y(s,1)):(s=vt(t),s.c(),y(s,1),s.m(e.parentNode,e)):s&&(_(),$(s,1,1,(()=>{s=null})),O())},i(t){a||(y(s),a=!0)},o(t){$(s),a=!1},d(t){s&&s.d(t),t&&i(e)}}}function vt(t){let e,a,n=t[5][t[40].toString()].length>0,s=n&&wt(t);return{c(){s&&s.c(),e=x()},l(t){s&&s.l(t),e=x()},m(t,n){s&&s.m(t,n),c(t,e,n),a=!0},p(t,a){32&a[0]&&(n=t[5][t[40].toString()].length>0),n?s?(s.p(t,a),32&a[0]&&y(s,1)):(s=wt(t),s.c(),y(s,1),s.m(e.parentNode,e)):s&&(_(),$(s,1,1,(()=>{s=null})),O())},i(t){a||(y(s),a=!0)},o(t){$(s),a=!1},d(t){s&&s.d(t),t&&i(e)}}}function wt(t){let e,a,h,p,g,D,T=t[38].container_info.name+"";function V(e){t[18](e,t[40])}let x={title:t[38].container_info.name,headers:Object.keys(t[5][t[40].toString()][0])};return void 0!==t[5][t[40].toString()]&&(x.data=t[5][t[40].toString()]),p=new j({props:x}),v.push((()=>w(p,"data",V))),{c(){e=n("h5"),a=s(T),h=f(),E(p.$$.fragment)},l(t){e=o(t,"H5",{});var n=r(e);a=l(n,T),n.forEach(i),h=m(t),S(p.$$.fragment,t)},m(t,n){c(t,e,n),u(e,a),c(t,h,n),b(p,t,n),D=!0},p(e,n){t=e,(!D||2&n[0])&&T!==(T=t[38].container_info.name+"")&&d(a,T);const s={};2&n[0]&&(s.title=t[38].container_info.name),32&n[0]&&(s.headers=Object.keys(t[5][t[40].toString()][0])),!g&&32&n[0]&&(g=!0,s.data=t[5][t[40].toString()],k((()=>g=!1))),p.$set(s)},i(t){D||(y(p.$$.fragment,t),D=!0)},o(t){$(p.$$.fragment,t),D=!1},d(t){t&&i(e),t&&i(h),I(p,t)}}}function Et(t){let e,a,n=Object.keys(t[5]).length>0,s=n&&gt(t);return{c(){s&&s.c(),e=x()},l(t){s&&s.l(t),e=x()},m(t,n){s&&s.m(t,n),c(t,e,n),a=!0},p(t,a){32&a[0]&&(n=Object.keys(t[5]).length>0),n?s?(s.p(t,a),32&a[0]&&y(s,1)):(s=gt(t),s.c(),y(s,1),s.m(e.parentNode,e)):s&&(_(),$(s,1,1,(()=>{s=null})),O())},i(t){a||(y(s),a=!0)},o(t){$(s),a=!1},d(t){s&&s.d(t),t&&i(e)}}}function St(t){let e,a,d,g,v,w,E,S,b,k,y,$,I,T,V,x,O,N,L,H,_,j,B,C=t[6].length>0&&bt(t);return{c(){e=n("div"),a=n("div"),d=n("button"),g=s("Start Simulation"),v=f(),w=n("hr"),E=f(),S=n("div"),b=n("h1"),k=n("b"),y=s("Edit Files"),$=f(),C&&C.c(),I=f(),T=n("hr"),V=f(),x=n("div"),O=n("div"),N=n("button"),L=s("Delete Files"),H=f(),_=n("hr"),this.h()},l(t){e=o(t,"DIV",{class:!0});var n=r(e);a=o(n,"DIV",{class:!0});var s=r(a);d=o(s,"BUTTON",{class:!0});var c=r(d);g=l(c,"Start Simulation"),c.forEach(i),s.forEach(i),n.forEach(i),v=m(t),w=o(t,"HR",{class:!0}),E=m(t),S=o(t,"DIV",{class:!0});var u=r(S);b=o(u,"H1",{class:!0,style:!0});var f=r(b);k=o(f,"B",{});var h=r(k);y=l(h,"Edit Files"),h.forEach(i),f.forEach(i),u.forEach(i),$=m(t),C&&C.l(t),I=m(t),T=o(t,"HR",{class:!0}),V=m(t),x=o(t,"DIV",{class:!0});var p=r(x);O=o(p,"DIV",{class:!0});var D=r(O);N=o(D,"BUTTON",{class:!0});var M=r(N);L=l(M,"Delete Files"),M.forEach(i),D.forEach(i),p.forEach(i),H=m(t),_=o(t,"HR",{class:!0}),this.h()},h(){h(d,"class","w3-col w3-input w3-border"),h(a,"class","w3-rest"),h(e,"class","w3-row w3-section"),h(w,"class","svelte-drd2kv"),h(b,"class","w3-text-yellow"),M(b,"text-shadow","1px 1px 0 #444"),h(S,"class","w3-panel w3-blue"),h(T,"class","svelte-drd2kv"),h(N,"class","w3-col w3-input w3-border"),h(O,"class","w3-rest"),h(x,"class","w3-row w3-section"),h(_,"class","svelte-drd2kv")},m(n,s){c(n,e,s),u(e,a),u(a,d),u(d,g),c(n,v,s),c(n,w,s),c(n,E,s),c(n,S,s),u(S,b),u(b,k),u(k,y),c(n,$,s),C&&C.m(n,s),c(n,I,s),c(n,T,s),c(n,V,s),c(n,x,s),u(x,O),u(O,N),u(N,L),c(n,H,s),c(n,_,s),j||(B=[p(d,"click",t[11]),p(N,"click",t[12])],j=!0)},p(t,e){t[6].length>0?C?C.p(t,e):(C=bt(t),C.c(),C.m(I.parentNode,I)):C&&(C.d(1),C=null)},d(t){t&&i(e),t&&i(v),t&&i(w),t&&i(E),t&&i(S),t&&i($),C&&C.d(t),t&&i(I),t&&i(T),t&&i(V),t&&i(x),t&&i(H),t&&i(_),j=!1,D(B)}}}function bt(t){let e,a,s,l,d,p,g=Object.keys(t[6][0]),v=[];for(let n=0;n<g.length;n+=1)v[n]=kt(dt(t,g,n));let w=t[6],E=[];for(let n=0;n<w.length;n+=1)E[n]=Dt(ct(t,w,n));return{c(){e=n("div"),a=n("div"),s=n("table"),l=n("thead"),d=n("tr");for(let t=0;t<v.length;t+=1)v[t].c();p=f();for(let t=0;t<E.length;t+=1)E[t].c();this.h()},l(t){e=o(t,"DIV",{class:!0});var n=r(e);a=o(n,"DIV",{class:!0});var c=r(a);s=o(c,"TABLE",{class:!0,style:!0});var u=r(s);l=o(u,"THEAD",{});var f=r(l);d=o(f,"TR",{class:!0});var h=r(d);for(let e=0;e<v.length;e+=1)v[e].l(h);h.forEach(i),f.forEach(i),p=m(u);for(let e=0;e<E.length;e+=1)E[e].l(u);u.forEach(i),c.forEach(i),n.forEach(i),this.h()},h(){h(d,"class","w3-dark-grey"),h(s,"class","w3-table-all"),M(s,"width","100%"),h(a,"class","w3-responsive"),h(e,"class","w3-container")},m(t,n){c(t,e,n),u(e,a),u(a,s),u(s,l),u(l,d);for(let e=0;e<v.length;e+=1)v[e].m(d,null);u(s,p);for(let e=0;e<E.length;e+=1)E[e].m(s,null)},p(t,e){if(64&e[0]){let a;for(g=Object.keys(t[6][0]),a=0;a<g.length;a+=1){const n=dt(t,g,a);v[a]?v[a].p(n,e):(v[a]=kt(n),v[a].c(),v[a].m(d,null))}for(;a<v.length;a+=1)v[a].d(1);v.length=g.length}if(8256&e[0]){let a;for(w=t[6],a=0;a<w.length;a+=1){const n=ct(t,w,a);E[a]?E[a].p(n,e):(E[a]=Dt(n),E[a].c(),E[a].m(s,null))}for(;a<E.length;a+=1)E[a].d(1);E.length=w.length}},d(t){t&&i(e),N(v,t),N(E,t)}}}function kt(t){let e,a,f=t[35]+"";return{c(){e=n("th"),a=s(f)},l(t){e=o(t,"TH",{});var n=r(e);a=l(n,f),n.forEach(i)},m(t,n){c(t,e,n),u(e,a)},p(t,e){64&e[0]&&f!==(f=t[35]+"")&&d(a,f)},d(t){t&&i(e)}}}function yt(t){let e,a,f=t[32][t[35]]+"";return{c(){e=n("td"),a=s(f)},l(t){e=o(t,"TD",{});var n=r(e);a=l(n,f),n.forEach(i)},m(t,n){c(t,e,n),u(e,a)},p(t,e){64&e[0]&&f!==(f=t[32][t[35]]+"")&&d(a,f)},d(t){t&&i(e)}}}function $t(t){let e,a,f,m,h=t[32][t[35]]+"";return{c(){e=n("td"),a=s(h)},l(t){e=o(t,"TD",{});var n=r(e);a=l(n,h),n.forEach(i)},m(n,s){c(n,e,s),u(e,a),f||(m=p(e,"click",t[13]),f=!0)},p(t,e){64&e[0]&&h!==(h=t[32][t[35]]+"")&&d(a,h)},d(t){t&&i(e),f=!1,m()}}}function It(t){let e;function a(t,e){return"filename"==t[35]?$t:yt}let n=a(t),s=n(t);return{c(){s.c(),e=x()},l(t){s.l(t),e=x()},m(t,a){s.m(t,a),c(t,e,a)},p(t,o){n===(n=a(t))&&s?s.p(t,o):(s.d(1),s=n(t),s&&(s.c(),s.m(e.parentNode,e)))},d(t){s.d(t),t&&i(e)}}}function Dt(t){let e,a,s=Object.keys(t[6][0]),l=[];for(let n=0;n<s.length;n+=1)l[n]=It(ut(t,s,n));return{c(){e=n("tr");for(let t=0;t<l.length;t+=1)l[t].c();a=f()},l(t){e=o(t,"TR",{});var n=r(e);for(let e=0;e<l.length;e+=1)l[e].l(n);a=m(n),n.forEach(i)},m(t,n){c(t,e,n);for(let a=0;a<l.length;a+=1)l[a].m(e,null);u(e,a)},p(t,n){if(8256&n[0]){let o;for(s=Object.keys(t[6][0]),o=0;o<s.length;o+=1){const r=ut(t,s,o);l[o]?l[o].p(r,n):(l[o]=It(r),l[o].c(),l[o].m(e,a))}for(;o<l.length;o+=1)l[o].d(1);l.length=s.length}},d(t){t&&i(e),N(l,t)}}}function Tt(t){let e,a,s,r,l;function u(e){t[19](e)}let d={title:"AutoPilot Component"};return void 0!==t[7]&&(d.input_data=t[7]),e=new nt({props:d}),v.push((()=>w(e,"input_data",u))),{c(){E(e.$$.fragment),s=f(),r=n("hr"),this.h()},l(t){S(e.$$.fragment,t),s=m(t),r=o(t,"HR",{class:!0}),this.h()},h(){h(r,"class","svelte-drd2kv")},m(t,a){b(e,t,a),c(t,s,a),c(t,r,a),l=!0},p(t,n){const s={};!a&&128&n[0]&&(a=!0,s.input_data=t[7],k((()=>a=!1))),e.$set(s)},i(t){l||(y(e.$$.fragment,t),l=!0)},o(t){$(e.$$.fragment,t),l=!1},d(t){I(e,t),t&&i(s),t&&i(r)}}}function Vt(t){let e,a,d,p,g,v,w,k,D,T,V,x,N,H,j,C,P,R,F;a=new B({});p=new it({props:{}}),t[14](p);let U="Communication"==t[2]&&mt(t),K="Static"==t[2]&&St(t),q="Driving Simulation"==t[2]&&Tt(t);return{c(){e=f(),E(a.$$.fragment),d=f(),E(p.$$.fragment),g=f(),v=n("hr"),w=f(),k=n("div"),D=n("h1"),T=n("b"),V=s("Simulation"),x=f(),N=n("hr"),H=f(),U&&U.c(),j=f(),K&&K.c(),C=f(),q&&q.c(),P=f(),R=n("hr"),this.h()},l(t){L('[data-svelte="svelte-1smsifb"]',document.head).forEach(i),e=m(t),S(a.$$.fragment,t),d=m(t),S(p.$$.fragment,t),g=m(t),v=o(t,"HR",{class:!0}),w=m(t),k=o(t,"DIV",{class:!0});var n=r(k);D=o(n,"H1",{class:!0,style:!0});var s=r(D);T=o(s,"B",{});var c=r(T);V=l(c,"Simulation"),c.forEach(i),s.forEach(i),n.forEach(i),x=m(t),N=o(t,"HR",{class:!0}),H=m(t),U&&U.l(t),j=m(t),K&&K.l(t),C=m(t),q&&q.l(t),P=m(t),R=o(t,"HR",{class:!0}),this.h()},h(){document.title="Simulation",h(v,"class","svelte-drd2kv"),h(D,"class","w3-text-yellow"),M(D,"text-shadow","1px 1px 0 #444"),h(k,"class","w3-panel w3-blue"),h(N,"class","svelte-drd2kv"),h(R,"class","svelte-drd2kv")},m(t,n){c(t,e,n),b(a,t,n),c(t,d,n),b(p,t,n),c(t,g,n),c(t,v,n),c(t,w,n),c(t,k,n),u(k,D),u(D,T),u(T,V),c(t,x,n),c(t,N,n),c(t,H,n),U&&U.m(t,n),c(t,j,n),K&&K.m(t,n),c(t,C,n),q&&q.m(t,n),c(t,P,n),c(t,R,n),F=!0},p(t,e){p.$set({}),"Communication"==t[2]?U?(U.p(t,e),4&e[0]&&y(U,1)):(U=mt(t),U.c(),y(U,1),U.m(j.parentNode,j)):U&&(_(),$(U,1,1,(()=>{U=null})),O()),"Static"==t[2]?K?K.p(t,e):(K=St(t),K.c(),K.m(C.parentNode,C)):K&&(K.d(1),K=null),"Driving Simulation"==t[2]?q?(q.p(t,e),4&e[0]&&y(q,1)):(q=Tt(t),q.c(),y(q,1),q.m(P.parentNode,P)):q&&(_(),$(q,1,1,(()=>{q=null})),O())},i(t){F||(y(a.$$.fragment,t),y(p.$$.fragment,t),y(U),y(q),F=!0)},o(t){$(a.$$.fragment,t),$(p.$$.fragment,t),$(U),$(q),F=!1},d(n){n&&i(e),I(a,n),n&&i(d),t[14](null),I(p,n),n&&i(g),n&&i(v),n&&i(w),n&&i(k),n&&i(x),n&&i(N),n&&i(H),U&&U.d(n),n&&i(j),K&&K.d(n),n&&i(C),q&&q.d(n),n&&i(P),n&&i(R)}}}function xt(t,e,a){let n,s=[],o={},r="";const l=U.subscribe((t=>{s=t})),i=K.subscribe((t=>{a(1,o=t)})),c=q.subscribe((t=>{a(2,r=t)}));let u=[],d=[];H((()=>{l(),i(),c();for(let t=0;t<u.length;t++)u[t].close();for(let t=0;t<d.length;t++)d[t].close()}));let f="Please create and select a scenario before starting the simulation.",m=!1,h=0,p=[],g={},w=[],E=[];function S(){for(const[t,e]of Object.entries(g))a(5,g[t]=[],g)}async function b(t){if(!m)return void C.danger("please create and activate a scenario first.");"start"==t&&S(),R("/simulation/comm","POST",{command:t,configs:o},(function(t){t.data&&(C.success("simulation started."),console.log("response of simulation",t.data))}))}function k(){for(var t=0;t<u.length;t++)ws=u[t],ws.close()}T((async()=>{let t="";for(let e=0;e<s.length;e++)s[e].activated&&(a(3,f=s[e].name),m=!0,t="/api/db1/scenario_configurations/ref-"+s[e]._id);!function(t,e){P(t,(function(t){let a=JSON.parse(t.response);a.data&&a.data.length>0&&(K.set(a.data[0]),e())}))}(t,(function(){if("Communication"==o.type){"configurations"in o&&a(4,h=o.configurations.length);for(var t=0;t<h;t++){a(5,g[t.toString()]=[],g);let e="ws://localhost:8000/simulation/comm/ws/"+t.toString(),n=new WebSocket(e);n.onopen=function(){window.console.log("Successfully connected to the echo websocket server...")},n.onmessage=function(t){let e=JSON.parse(t.data);console.log(e,"printing JSON now");let n=e.client_index,s=JSON.parse(e.data);"status"in s?p[n]=s.status:a(5,g[n]=[...g[n],s],g)},u.push(n)}}if("Static"==o.type){console.log("hello static sample");let t=new WebSocket("ws://localhost:8000/simulation/static/ws");t.onopen=function(){window.console.log("static simulation websocket")},t.onmessage=function(t){let e=JSON.parse(t.data);a(6,w=[...w,e])},d.push(t)}"Communication"==o.type&&console.log("hello driving scenario")}))}));return[n,o,r,f,h,g,w,E,S,b,k,function(){R("/simulation/static","POST",{configs:o},(function(t){t.data&&(C.success("simulation started."),console.log("response of simulation",t.data))}))},function(){R("/simulation/static","DELETE",{configs:o},(function(t){t.data&&(C.success("Delete successful."),a(6,w=[]),console.log("response of simulation",t.data))}))},function(){let t=this.innerText;F("/simulation/static","POST",{configs:o,filename:t},(function(e){if(e){let a=new Blob([e.response],{type:"octet/stream"}),s=(window.URL||window.webkitURL).createObjectURL(a);n.changeImage(s,t)}}))},function(t){v[t?"unshift":"push"]((()=>{n=t,a(0,n)}))},()=>b("start"),()=>b("stop"),()=>k(),function(e,n){t.$$.not_equal(g[n.toString()],e)&&(g[n.toString()]=e,a(5,g))},function(t){E=t,a(7,E)}]}export default class extends t{constructor(t){super(),e(this,t,xt,Vt,a,{},[-1,-1])}}
  