MCPcopy
hub / github.com/mitmproxy/mitmproxy / constructor

Method constructor

mitmproxy/tools/web/static/index-Be7e-cwP.js:7–7  ·  view source on GitHub ↗
(e,s)

Source from the content-addressed store, hash-verified

5`?(u.seenCR||u.line++,u.column=1,u.seenCR=!1):x==="\r"||x==="\u2028"||x==="\u2029"?(u.line++,u.column=1,u.seenCR=!0):(u.column++,u.seenCR=!1),v++;return Dt[c]=u,u}function xn(c,u){var v=vn(c),x=vn(u);return{start:{offset:c,line:v.line,column:v.column},end:{offset:u,line:x.line,column:x.column}}}function F(c){m<qe||(m>qe&&(qe=m,ns=[]),ns.push(c))}function Zo(c,u,v,x){function He(Ie){var Qe=1;for(Ie.sort(function(Pt,rt){return Pt.description<rt.description?-1:Pt.description>rt.description?1:0});Qe<Ie.length;)Ie[Qe-1]===Ie[Qe]?Ie.splice(Qe,1):Qe++}function Ne(Ie,Qe){function Pt($l){function Ot(Ge){return Ge.charCodeAt(0).toString(16).toUpperCase()}return $l.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(Ge){return"\\x0"+Ot(Ge)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(Ge){return"\\x"+Ot(Ge)}).replace(/[\u0100-\u0FFF]/g,function(Ge){return"\\u0"+Ot(Ge)}).replace(/[\u1000-\uFFFF]/g,function(Ge){return"\\u"+Ot(Ge)})}var rt=new Array(Ie.length),Mn,qn,_t;for(_t=0;_t<Ie.length;_t++)rt[_t]=Ie[_t].description;return Mn=Ie.length>1?rt.slice(0,-1).join(", ")+" or "+rt[Ie.length-1]:rt[0],qn=Qe?'"'+Pt(Qe)+'"':"end of input","Expected "+Mn+" but "+qn+" found."}return u!==null&&He(u),new e(Ne(u,v),u,v,x)}function _n(){var c,u,v,x;return R++,c=m,u=ze(),u!==n?(v=is(),v!==n?(x=ze(),x!==n?(u=f(v),c=u):(m=c,c=n)):(m=c,c=n)):(m=c,c=n),R--,c===n&&(u=n,R===0&&F(d)),c}function K(){var c;return R++,h.test(i.charAt(m))?(c=i.charAt(m),m++):(c=n,R===0&&F(g)),R--,c===n&&R===0&&F(p),c}function el(){var c;return R++,j.test(i.charAt(m))?(c=i.charAt(m),m++):(c=n,R===0&&F(y)),R--,c===n&&R===0&&F(_),c}function ze(){var c,u;for(R++,c=[],u=K();u!==n;)c.push(u),u=K();return R--,c===n&&(u=n,R===0&&F(w)),c}function is(){var c,u,v,x,He,Ne;return c=m,u=It(),u!==n?(v=ze(),v!==n?(i.charCodeAt(m)===124?(x=$,m++):(x=n,R===0&&F(N)),x!==n?(He=ze(),He!==n?(Ne=is(),Ne!==n?(u=E(u,Ne),c=u):(m=c,c=n)):(m=c,c=n)):(m=c,c=n)):(m=c,c=n)):(m=c,c=n),c===n&&(c=It()),c}function It(){var c,u,v,x,He,Ne;if(c=m,u=Lt(),u!==n?(v=ze(),v!==n?(i.charCodeAt(m)===38?(x=T,m++):(x=n,R===0&&F(P)),x!==n?(He=ze(),He!==n?(Ne=It(),Ne!==n?(u=L(u,Ne),c=u):(m=c,c=n)):(m=c,c=n)):(m=c,c=n)):(m=c,c=n)):(m=c,c=n),c===n){if(c=m,u=Lt(),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=It(),x!==n?(u=L(u,x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;c===n&&(c=Lt())}return c}function Lt(){var c,u,v,x;return c=m,i.charCodeAt(m)===33?(u=O,m++):(u=n,R===0&&F(M)),u!==n?(v=ze(),v!==n?(x=Lt(),x!==n?(u=U(x),c=u):(m=c,c=n)):(m=c,c=n)):(m=c,c=n),c===n&&(c=tl()),c}function tl(){var c,u,v,x,He,Ne;return c=m,i.charCodeAt(m)===40?(u=V,m++):(u=n,R===0&&F(W)),u!==n?(v=ze(),v!==n?(x=is(),x!==n?(He=ze(),He!==n?(i.charCodeAt(m)===41?(Ne=J,m++):(Ne=n,R===0&&F(z)),Ne!==n?(u=te(x),c=u):(m=c,c=n)):(m=c,c=n)):(m=c,c=n)):(m=c,c=n)):(m=c,c=n),c===n&&(c=sl()),c}function sl(){var c,u,v,x;if(c=m,i.substr(m,4)===Y?(u=Y,m+=4):(u=n,R===0&&F(Q)),u!==n&&(u=X()),c=u,c===n&&(c=m,i.substr(m,2)===Z?(u=Z,m+=2):(u=n,R===0&&F(ae)),u!==n&&(u=le()),c=u,c===n)){if(c=m,i.substr(m,2)===de?(u=de,m+=2):(u=n,R===0&&F(ye)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=Pe(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n){if(c=m,i.substr(m,3)===Se?(u=Se,m+=3):(u=n,R===0&&F(Ee)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=C(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n){if(c=m,i.substr(m,3)===he?(u=he,m+=3):(u=n,R===0&&F(B)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=oe(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n){if(c=m,i.substr(m,2)===q?(u=q,m+=2):(u=n,R===0&&F($e)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=nl(),x!==n?(u=We(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n){if(c=m,i.substr(m,8)===Oe?(u=Oe,m+=8):(u=n,R===0&&F(ee)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=Me(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n){if(c=m,i.substr(m,2)===Re?(u=Re,m+=2):(u=n,R===0&&F(re)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=ue(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n&&(c=m,i.substr(m,4)===ge?(u=ge,m+=4):(u=n,R===0&&F(Ae)),u!==n&&(u=nt()),c=u,c===n)){if(c=m,i.substr(m,4)===Je?(u=Je,m+=4):(u=n,R===0&&F(Zt)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=b(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n&&(c=m,i.substr(m,2)===S?(u=S,m+=2):(u=n,R===0&&F(A)),u!==n&&(u=H()),c=u,c===n)){if(c=m,i.substr(m,2)===Tt?(u=Tt,m+=2):(u=n,R===0&&F(es)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=Ce(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n){if(c=m,i.substr(m,3)===De?(u=De,m+=3):(u=n,R===0&&F(ut)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=Ke(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n){if(c=m,i.substr(m,3)===vt?(u=vt,m+=3):(u=n,R===0&&F(Rt)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=it(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n&&(c=m,i.substr(m,5)===At?(u=At,m+=5):(u=n,R===0&&F(ft)),u!==n&&(u=Fe()),c=u,c===n&&(c=m,i.substr(m,7)===Us?(u=Us,m+=7):(u=n,R===0&&F(no)),u!==n&&(u=io()),c=u,c===n))){if(c=m,i.substr(m,7)===Bs?(u=Bs,m+=7):(u=n,R===0&&F(ro)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=oo(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n){if(c=m,i.substr(m,2)===Ws?(u=Ws,m+=2):(u=n,R===0&&F(lo)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=co(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n&&(c=m,i.substr(m,2)===Ks?(u=Ks,m+=2):(u=n,R===0&&F(ao)),u!==n&&(u=uo()),c=u,c===n&&(c=m,i.substr(m,8)===zs?(u=zs,m+=8):(u=n,R===0&&F(fo)),u!==n&&(u=po()),c=u,c===n&&(c=m,i.substr(m,8)===Gs?(u=Gs,m+=8):(u=n,R===0&&F(ho)),u!==n&&(u=mo()),c=u,c===n&&(c=m,i.substr(m,7)===Ys?(u=Ys,m+=7):(u=n,R===0&&F(go)),u!==n&&(u=vo()),c=u,c===n))))){if(c=m,i.substr(m,4)===Js?(u=Js,m+=4):(u=n,R===0&&F(xo)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=_o(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n&&(c=m,i.substr(m,2)===Qs?(u=Qs,m+=2):(u=n,R===0&&F(jo)),u!==n&&(u=yo()),c=u,c===n&&(c=m,i.substr(m,4)===Xs?(u=Xs,m+=4):(u=n,R===0&&F(wo)),u!==n&&(u=bo()),c=u,c===n&&(c=m,i.substr(m,4)===Zs?(u=Zs,m+=4):(u=n,R===0&&F(So)),u!==n&&(u=$o()),c=u,c===n)))){if(c=m,i.substr(m,3)===en?(u=en,m+=3):(u=n,R===0&&F(Co)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=No(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n){if(c=m,i.substr(m,3)===tn?(u=tn,m+=3):(u=n,R===0&&F(ko)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=Eo(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n){if(c=m,i.substr(m,2)===sn?(u=sn,m+=2):(u=n,R===0&&F(To)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=Ro(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n){if(c=m,i.substr(m,2)===nn?(u=nn,m+=2):(u=n,R===0&&F(Ao)),u!==n){if(v=[],x=K(),x!==n)for(;x!==n;)v.push(x),x=K();else v=n;v!==n?(x=me(),x!==n?(u=rn(x),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;c===n&&(c=m,i.substr(m,10)===on?(u=on,m+=10):(u=n,R===0&&F(Do)),u!==n&&(u=Fo()),c=u,c===n&&(c=m,u=me(),u!==n&&(u=rn(u)),c=u))}}}}}}}}}}}}}}}}}return c}function nl(){var c,u,v,x;if(R++,c=m,ln.test(i.charAt(m))?(u=i.charAt(m),m++):(u=n,R===0&&F(cn)),u===n&&(u=null),u!==n){if(v=[],an.test(i.charAt(m))?(x=i.charAt(m),m++):(x=n,R===0&&F(dn)),x!==n)for(;x!==n;)v.push(x),an.test(i.charAt(m))?(x=i.charAt(m),m++):(x=n,R===0&&F(dn));else v=n;v!==n?(ln.test(i.charAt(m))?(x=i.charAt(m),m++):(x=n,R===0&&F(cn)),x===n&&(x=null),x!==n?(u=Lo(v),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;return R--,c===n&&(u=n,R===0&&F(Io)),c}function me(){var c,u,v,x;if(R++,c=m,i.charCodeAt(m)===34?(u=un,m++):(u=n,R===0&&F(fn)),u!==n){for(v=[],x=jn();x!==n;)v.push(x),x=jn();v!==n?(i.charCodeAt(m)===34?(x=un,m++):(x=n,R===0&&F(fn)),x!==n?(u=ts(v),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n){if(c=m,i.charCodeAt(m)===39?(u=pn,m++):(u=n,R===0&&F(hn)),u!==n){for(v=[],x=yn();x!==n;)v.push(x),x=yn();v!==n?(i.charCodeAt(m)===39?(x=pn,m++):(x=n,R===0&&F(hn)),x!==n?(u=ts(v),c=u):(m=c,c=n)):(m=c,c=n)}else m=c,c=n;if(c===n)if(c=m,u=m,R++,v=el(),R--,v===n?u=void 0:(m=u,u=n),u!==n){if(v=[],x=wn(),x!==n)for(;x!==n;)v.push(x),x=wn();else v=n;v!==n?(u=ts(v),c=u):(m=c,c=n)}else m=c,c=n}return R--,c===n&&(u=n,R===0&&F(Po)),c}function jn(){var c,u,v;return c=m,u=m,R++,Oo.test(i.charAt(m))?(v=i.charAt(m),m++):(v=n,R===0&&F(Mo)),R--,v===n?u=void 0:(m=u,u=n),u!==n?(i.length>m?(v=i.charAt(m),m++):(v=n,R===0&&F(ss)),v!==n?(u=xt(v),c=u):(m=c,c=n)):(m=c,c=n),c===n&&(c=m,i.charCodeAt(m)===92?(u=mn,m++):(u=n,R===0&&F(gn)),u!==n?(v=bn(),v!==n?(u=xt(v),c=u):(m=c,c=n)):(m=c,c=n)),c}function yn(){var c,u,v;return c=m,u=m,R++,qo.test(i.charAt(m))?(v=i.charAt(m),m++):(v=n,R===0&&F(Ho)),R--,v===n?u=void 0:(m=u,u=n),u!==n?(i.length>m?(v=i.charAt(m),m++):(v=n,R===0&&F(ss)),v!==n?(u=xt(v),c=u):(m=c,c=n)):(m=c,c=n),c===n&&(c=m,i.charCodeAt(m)===92?(u=mn,m++):(u=n,R===0&&F(gn)),u!==n?(v=bn(),v!==n?(u=xt(v),c=u):(m=c,c=n)):(m=c,c=n)),c}function wn(){var c,u,v;return c=m,u=m,R++,v=K(),R--,v===n?u=void 0:(m=u,u=n),u!==n?(i.length>m?(v=i.charAt(m),m++):(v=n,R===0&&F(ss)),v!==n?(u=xt(v),c=u):(m=c,c=n)):(m=c,c=n),c}function bn(){var c,u;return Vo.test(i.charAt(m))?(c=i.charAt(m),m++):(c=n,R===0&&F(Uo)),c===n&&(c=m,i.charCodeAt(m)===110?(u=Bo,m++):(u=n,R===0&&F(Wo)),u!==n&&(u=Ko()),c=u,c===n&&(c=m,i.charCodeAt(m)===114?(u=zo,m++):(u=n,R===0&&F(Go)),u!==n&&(u=Yo()),c=u,c===n&&(c=m,i.charCodeAt(m)===116?(u=Jo,m++):(u=n,R===0&&F(Qo)),u!==n&&(u=Xo()),c=u))),c}function il(c,u){function v(){return c.apply(this,arguments)||u.apply(this,arguments)}return v.desc=c.desc+" or "+u.desc,v}function rl(c,u){function v(){return c.apply(this,arguments)&&u.apply(this,arguments)}return v.desc=c.desc+" and "+u.desc,v}function ol(c){function u(){return!c.apply(this,arguments)}return u.desc="not "+c.desc,u}function ll(c){function u(){return c.apply(this,arguments)}return u.desc="("+c.desc+")",u}function Sn(c){return!0}Sn.desc="all flows";var $n=[new RegExp("text/javascript"),new RegExp("application/x-javascript"),new RegExp("application/javascript"),new RegExp("text/css"),new RegExp("image/.*"),new RegExp("font/.*"),new RegExp("application/font.*")];function Cn(c){if(c.response){for(var u=mt.getContentType(c.response),v=$n.length;v--;)if($n[v].test(u))return!0}return!1}Cn.desc="is asset";function cl(c){c=new RegExp(c,"i");function u(v){return!0}return u.desc="body matches "+c,u}function al(c){c=new RegExp(c,"i");function u(v){return!0}return u.desc="body request matches "+c,u}function dl(c){c=new RegExp(c,"i");function u(v){return!0}return u.desc="body response matches "+c,u}function ul(c){function u(v){return v.response&&v.response.status_code===c}return u.desc="resp. code is "+c,u}function fl(c){c=new RegExp(c,"i");function u(v){return c.test(v.comment)}return u.desc="comment matches "+c,u}function pl(c){c=new RegExp(c,"i");function u(v){return v.request&&(c.test(v.request.host)||c.test(v.request.pretty_host))}return u.desc="domain matches "+c,u}function Nn(c){return c.type==="dns"}Nn.desc="is a DNS Flow";function hl(c){c=new RegExp(c,"i");function u(v){return!!v.server_conn.address&&c.test(v.server_conn.address[0]+":"+v.server_conn.address[1])}return u.desc="destination address matches "+c,u}function kn(c){return!!c.error}kn.desc="has error";function ml(c){c=new RegExp(c,"i");function u(v){return v.request&&ct.match_header(v.request,c)||v.response&&mt.match_header(v.response,c)}return u.desc="header matches "+c,u}function gl(c){c=new RegExp(c,"i");function u(v){return v.request&&ct.match_header(v.request,c)}return u.desc="req. header matches "+c,u}function vl(c){c=new RegExp(c,"i");function u(v){return v.response&&mt.match_header(v.response,c)}return u.desc="resp. header matches "+c,u}function En(c){return c.type==="http"}En.desc="is an HTTP Flow";function Tn(c){return c.marked}Tn.desc="is marked";function xl(c){c=new RegExp(c,"i");function u(v){return c.test(v.marked)}return u.desc="marker matches "+c,u}function _l(c){c=new RegExp(c,"i");function u(v){return v.request&&c.test(v.request.method)}return u.desc="method matches "+c,u}function Rn(c){return c.request&&!c.response}Rn.desc="has no response";function An(c){return c.is_replay==="request"}An.desc="request has been replayed";function Dn(c){return c.is_replay==="response"}Dn.desc="response has been replayed";function Fn(c){return!!c.is_replay}Fn.desc="flow has been replayed";function jl(c){c=new RegExp(c,"i");function u(v){return!!v.client_conn.peername&&c.test(v.client_conn.peername[0]+":"+v.client_conn.peername[1])}return u.desc="source address matches "+c,u}function In(c){return!!c.response}In.desc="has response";function Ln(c){return c.type==="tcp"}Ln.desc="is a TCP Flow";function Pn(c){return c.type==="udp"}Pn.desc="is a UDP Flow";function yl(c){c=new RegExp(c,"i");function u(v){return v.request&&c.test(ct.getContentType(v.request))}return u.desc="req. content type matches "+c,u}function wl(c){c=new RegExp(c,"i");function u(v){return v.response&&c.test(mt.getContentType(v.response))}return u.desc="resp. content type matches "+c,u}function bl(c){c=new RegExp(c,"i");function u(v){return v.request&&c.test(ct.getContentType(v.request))||v.response&&c.test(mt.getContentType(v.response))}return u.desc="content type matches "+c,u}function Sl(c){c=new RegExp(c,"i");function u(v){if(v.type==="dns"){const x=v.request?.questions[0];return x&&c.test(x.name)}return v.request&&c.test(ct.pretty_url(v.request))}return u.desc="url matches "+c,u}function On(c){return!!c.websocket}if(On.desc="is a Websocket Flow",Ft=a(),Ft!==n&&m===i.length)return Ft;throw Ft!==n&&m<i.length&&F({type:"end",description:"end of input"}),Zo(null,ns,qe<i.length?i.charAt(qe):null,qe<i.length?xn(qe,qe+1):xn(qe,qe))}return{SyntaxError:e,parse:s}}();class Ye extends I.Component{static xhr;static doc;constructor(e,s){super(e,s),this.state={doc:Ye.doc}}componentDidMount(){Ye.xhr||(Ye.xhr=ne("/filter-help").then(e=>e.json()),Ye.xhr.catch(()=>{Ye.xhr=null})),this.state.doc||Ye.xhr.then(e=>{Ye.doc=e,this.setState({doc:e})})}render(){const{doc:e}=this.state;return e?o.jsx("table",{className:"table table-condensed",children:o.jsxs("tbody",{children:[e.commands.map(s=>o.jsxs("tr",{onClick:()=>this.props.selectHandler(s[0].split(" ")[0]+" "),children:[o.jsx("td",{children:s[0].replace(" "," ")}),o.jsx("td",{children:s[1]})]},s[1])),o.jsx("tr",{children:o.jsx("td",{colSpan:2,children:o.jsxs("a",{href:"https://mitmproxy.org/docs/latest/concepts-filters/",target:"_blank",rel:"noreferrer",children:[o.jsx("i",{className:"fa fa-external-link"}),"  mitmproxy docs"]})})},"docs-link")]})}):o.jsx("i",{className:"fa fa-spinner fa-spin"})}}var Xt=(t=>(t.SEARCH="search",t.HIGHLIGHT="tag",t.INTERCEPT="pause",t))(Xt||{});class Hs extends I.Component{inputRef=Te.createRef();constructor(e,s){super(e,s),this.state={value:this.props.value,focus:!1,mousefocus:!1},this.onChange=this.onChange.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.selectFilter=this.selectFilter.bind(this)}UNSAFE_componentWillReceiveProps(e){this.setState({value:e.value})}isValid(e){try{return e&&oi.parse(e),!0}catch{return!1}}getDesc(){if(!this.state.value)return o.jsx(Ye,{selectHandler:this.selectFilter});try{return oi.parse(this.state.value).desc}catch(e){return""+e}}onChange(e){const s=e.target.value;this.setState({value:s}),this.isValid(s)&&this.props.onChange(s)}onFocus(){this.setState({focus:!0})}onBlur(){this.setState({focus:!1})}onMouseEnter(){this.setState({mousefocus:!0})}onMouseLeave(){this.setState({mousefocus:!1})}onKeyDown(e){(e.key==="Escape"||e.key==="Enter")&&(this.blur(),this.setState({mousefocus:!1})),e.stopPropagation()}selectFilter(e){this.setState({value:e}),this.inputRef.current?.focus(),this.isValid(e)&&this.props.onChange(e)}blur(){this.inputRef.current?.blur()}select(){this.inputRef.current?.select()}render(){const{icon:e,color:s,placeholder:i}=this.props,{value:r,focus:n,mousefocus:l}=this.state;return o.jsxs("div",{className:je("filter-input input-group",{"has-error":!this.isValid(r)}),children:[o.jsx("span",{className:"input-group-addon",children:o.jsx("i",{className:"fa fa-fw fa-"+e,style:{color:s}})}),o.jsx("input",{type:"text",ref:this.inputRef,placeholder:i,className:"form-control",value:r,onChange:this.onChange,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown}),(n||l)&&o.jsxs("div",{className:"popover bottom",onMouseEnter:this.onMouseEnter,onMouseLeave:this.onMouseLeave,children:[o.jsx("div",{className:"arrow"}),o.jsx("div",{className:"popover-content",children:this.getDesc()})]})]})}}Zr.title="Flow List";function Zr(){const t=k.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsxs("div",{className:"menu-group",children:[o.jsxs("div",{className:"menu-content",children:[o.jsx(ju,{}),o.jsx(wu,{})]}),o.jsx("div",{className:"menu-legend",children:"Find"})]}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsxs("div",{className:"main-menu",children:[e,o.jsxs("div",{className:"menu-group",children:[o.jsxs("div",{className:"menu-content",children:[o.jsx(xu,{}),o.jsx(Su,{})]}),o.jsx("div",{className:"menu-legend",children:"Intercept"})]})]}),t[1]=s):s=t[1],s}function xu(){const t=k.c(5),e=G(),i=D(_u)||"";let r;t[0]!==e?(r=l=>e(Cs("intercept",l)),t[0]=e,t[1]=r):r=t[1];let n;return t[2]!==i||t[3]!==r?(n=o.jsx(Hs,{value:i,placeholder:"Intercept",icon:Xt.INTERCEPT,color:"hsl(208, 56%, 53%)",onChange:r}),t[2]=i,t[3]=r,t[4]=n):n=t[4],n}function _u(t){return t.options.intercept}function ju(){const t=k.c(5),e=G(),s=D(yu);let i;t[0]!==e?(i=n=>e(Ri(n)),t[0]=e,t[1]=i):i=t[1];let r;return t[2]!==i||t[3]!==s?(r=o.jsx(Hs,{value:s,placeholder:"Search",icon:Xt.SEARCH,color:"black",onChange:i}),t[2]=i,t[3]=s,t[4]=r):r=t[4],r}function yu(t){return t.ui.filter[ve.Search]}function wu(){const t=k.c(5),e=G(),s=D(bu);let i;t[0]!==e?(i=n=>e(Ai(n)),t[0]=e,t[1]=i):i=t[1];let r;return t[2]!==i||t[3]!==s?(r=o.jsx(Hs,{value:s,placeholder:"Highlight",icon:Xt.HIGHLIGHT,color:"hsl(48, 100%, 50%)",onChange:i}),t[2]=i,t[3]=s,t[4]=r):r=t[4],r}function bu(t){return t.ui.filter[ve.Highlight]}function Su(){const t=k.c(2),e=G();let s;return t[0]!==e?(s=o.jsx(pe,{className:"btn-sm",title:"[a]ccept all",icon:"fa-forward text-success",onClick:()=>e(Di()),children:"Resume All"}),t[0]=e,t[1]=s):s=t[1],s}function Vs(t){const e=k.c(6),{value:s,onChange:i,children:r}=t;let n;e[0]!==i||e[1]!==s?(n=o.jsx("input",{type:"checkbox",checked:s,onChange:i}),e[0]=i,e[1]=s,e[2]=n):n=e[2];let l;return e[3]!==r||e[4]!==n?(l=o.jsx("div",{className:"menu-entry",children:o.jsxs("label",{children:[n,r]})}),e[3]=r,e[4]=n,e[5]=l):l=e[5],l}function cs(t){const e=k.c(10),{name:s,children:i}=t,r=G();let n;e[0]!==s?(n=p=>p.options[s],e[0]=s,e[1]=n):n=e[1];const l=D(n),a=!!l;let d;e[2]!==r||e[3]!==s||e[4]!==l?(d=()=>r(Cs(s,!l)),e[2]=r,e[3]=s,e[4]=l,e[5]=d):d=e[5];let f;return e[6]!==i||e[7]!==a||e[8]!==d?(f=o.jsx(Vs,{value:a,onChange:d,children:i}),e[6]=i,e[7]=a,e[8]=d,e[9]=f):f=e[9],f}function $u(){const t=k.c(5),e=G(),s=D(Cu);let i;t[0]!==e?(i=()=>e(Gt()),t[0]=e,t[1]=i):i=t[1];let r;return t[2]!==i||t[3]!==s?(r=o.jsx(Vs,{value:s,onChange:i,children:"Display Event Log"}),t[2]=i,t[3]=s,t[4]=r):r=t[4],r}function Cu(t){return t.eventLog.visible}function Nu(){const t=k.c(5),e=G(),s=D(ku);let i;t[0]!==e?(i=()=>e(Ji()),t[0]=e,t[1]=i):i=t[1];let r;return t[2]!==i||t[3]!==s?(r=o.jsx(Vs,{value:s,onChange:i,children:"Display Command Bar"}),t[2]=i,t[3]=s,t[4]=r):r=t[4],r}function ku(t){return t.commandBar.visible}function as(t){const e=k.c(5),{children:s,resource:i}=t,r=`https://docs.mitmproxy.org/stable/${i}`;let n;e[0]!==s?(n=s||o.jsx("i",{className:"fa fa-question-circle"}),e[0]=s,e[1]=n):n=e[1];let l;return e[2]!==n||e[3]!==r?(l=o.jsx("a",{target:"_blank",href:r,rel:"noreferrer",children:n}),e[2]=n,e[3]=r,e[4]=l):l=e[4],l}eo.title="Options";function eo(){const t=k.c(16),e=G(),s=Eu;let i;t[0]!==e?(i=()=>e(s()),t[0]=e,t[1]=i):i=t[1];let r;t[2]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("sup",{children:"alpha"}),t[2]=r):r=t[2];let n;t[3]!==i?(n=o.jsx("div",{className:"menu-content",children:o.jsxs(pe,{title:"Open Options",icon:"fa-cogs text-primary",onClick:i,children:["Edit Options ",r]})}),t[3]=i,t[4]=n):n=t[4];let l;t[5]===Symbol.for("react.memo_cache_sentinel")?(l=o.jsx("div",{className:"menu-legend",children:"Options Editor"}),t[5]=l):l=t[5];let a;t[6]!==n?(a=o.jsxs("div",{className:"menu-group",children:[n,l]}),t[6]=n,t[7]=a):a=t[7];let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsxs(cs,{name:"anticache",children:["Strip cache headers"," ",o.jsx(as,{resource:"overview/features/#anticache"})]}),t[8]=d):d=t[8];let f;t[9]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsxs(cs,{name:"showhost",children:["Use host header for display"," ",o.jsx(as,{resource:"concepts/options/#showhost"})]}),t[9]=f):f=t[9];let p;t[10]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsxs("div",{className:"menu-group",children:[o.jsxs("div",{className:"menu-content",children:[d,f,o.jsxs(cs,{name:"ssl_insecure",children:["Don't verify server certificates"," ",o.jsx(as,{resource:"concepts/options/#ssl_insecure"})]})]}),o.jsx("div",{className:"menu-legend",children:"Quick Options"})]}),t[10]=p):p=t[10];let h;t[11]!==a?(h=o.jsxs(gt,{children:[a,p]}),t[11]=a,t[12]=h):h=t[12];let g;t[13]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsxs("div",{className:"menu-group",children:[o.jsxs("div",{className:"menu-content",children:[o.jsx($u,{}),o.jsx(Nu,{})]}),o.jsx("div",{className:"menu-legend",children:"View Options"})]}),t[13]=g):g=t[13];let _;return t[14]!==h?(_=o.jsxs("div",{children:[h,g]}),t[14]=h,t[15]=_):_=t[15],_}function Eu(){return dc("OptionModal")}const yt=async(t,e)=>{const s=(async()=>{const i=await Bt("export",e,`@${t.id}`);if(i.value)return i.value;throw i.error?i.error:i})();try{await gi(s)}catch(i){alert(i)}};to.title="Flow";function to(){const t=k.c(63),e=G(),s=D(Tu),i=s[0];let r;t[0]!==s?(r=s.some(_s),t[0]=s,t[1]=r):r=t[1];const n=r;if(s.length===0){let X;return t[2]===Symbol.for("react.memo_cache_sentinel")?(X=o.jsx("div",{}),t[2]=X):X=t[2],X}let l;t[3]!==e||t[4]!==s?(l=()=>e(ws(s)),t[3]=e,t[4]=s,t[5]=l):l=t[5];let a;t[6]!==s?(a=s.some(xs),t[6]=s,t[7]=a):a=t[7];const d=!a;let f;t[8]!==l||t[9]!==d?(f=o.jsx(pe,{title:"[r]eplay flow",icon:"fa-repeat text-primary",onClick:l,disabled:d,children:"Replay"}),t[8]=l,t[9]=d,t[10]=f):f=t[10];let p;t[11]!==e||t[12]!==s?(p=o.jsx(pe,{title:"[D]uplicate flow",icon:"fa-copy text-info",onClick:()=>e(Li(s)),children:"Duplicate"}),t[11]=e,t[12]=s,t[13]=p):p=t[13];let h;t[14]!==s?(h=s.some(bi),t[14]=s,t[15]=h):h=t[15];const g=!h;let _;t[16]!==e||t[17]!==s?(_=()=>e(Pi(s)),t[16]=e,t[17]=s,t[18]=_):_=t[18];let j;t[19]!==g||t[20]!==_?(j=o.jsx(pe,{disabled:g,title:"revert changes to flow [V]",icon:"fa-history text-warning",onClick:_,children:"Revert"}),t[19]=g,t[20]=_,t[21]=j):j=t[21];let y;t[22]!==e||t[23]!==s?(y=o.jsx(pe,{title:"[d]elete flow",icon:"fa-trash text-danger",onClick:()=>{e(Ii(s))},children:"Delete"}),t[22]=e,t[23]=s,t[24]=y):y=t[24];let w;t[25]!==s?(w=o.jsx(Mu,{flows:s}),t[25]=s,t[26]=w):w=t[26];let $;t[27]!==y||t[28]!==w||t[29]!==f||t[30]!==p||t[31]!==j?($=o.jsxs("div",{className:"menu-content",children:[f,p,j,y,w]}),t[27]=y,t[28]=w,t[29]=f,t[30]=p,t[31]=j,t[32]=$):$=t[32];let N;t[33]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx("div",{className:"menu-legend",children:"Flow Modification"}),t[33]=N):N=t[33];let E;t[34]!==$?(E=o.jsx(gt,{children:o.jsxs("div",{className:"menu-group",children:[$,N]})}),t[34]=$,t[35]=E):E=t[35];let T;t[36]!==i?(T=o.jsxs("div",{className:"menu-content",children:[o.jsx(Ru,{flow:i}),o.jsx(Iu,{flow:i})]}),t[36]=i,t[37]=T):T=t[37];let P;t[38]===Symbol.for("react.memo_cache_sentinel")?(P=o.jsx("div",{className:"menu-legend",children:"Export"}),t[38]=P):P=t[38];let L;t[39]!==T?(L=o.jsxs("div",{className:"menu-group",children:[T,P]}),t[39]=T,t[40]=L):L=t[40];const O=!n;let M;t[41]!==e||t[42]!==s?(M=()=>e(ys(s)),t[41]=e,t[42]=s,t[43]=M):M=t[43];let U;t[44]!==O||t[45]!==M?(U=o.jsx(pe,{disabled:O,title:"[a]ccept intercepted flow",icon:"fa-play text-success",onClick:M,children:"Resume"}),t[44]=O,t[45]=M,t[46]=U):U=t[46];const V=!n;let W;t[47]!==e||t[48]!==s?(W=()=>e(Fi(s)),t[47]=e,t[48]=s,t[49]=W):W=t[49];let J;t[50]!==V||t[51]!==W?(J=o.jsx(pe,{disabled:V,title:"kill intercepted flow [x]",icon:"fa-times text-danger",onClick:W,children:"Abort"}),t[50]=V,t[51]=W,t[52]=J):J=t[52];let z;t[53]!==U||t[54]!==J?(z=o.jsxs("div",{className:"menu-content",children:[U,J]}),t[53]=U,t[54]=J,t[55]=z):z=t[55];let te;t[56]===Symbol.for("react.memo_cache_sentinel")?(te=o.jsx("div",{className:"menu-legend",children:"Interception"}),t[56]=te):te=t[56];let Y;t[57]!==z?(Y=o.jsx(gt,{children:o.jsxs("div",{className:"menu-group",children:[z,te]})}),t[57]=z,t[58]=Y):Y=t[58];let Q;return t[59]!==E||t[60]!==L||t[61]!==Y?(Q=o.jsxs("div",{className:"flow-menu",children:[E,L,Y]}),t[59]=E,t[60]=L,t[61]=Y,t[62]=Q):Q=t[62],Q}function Tu(t){return t.flows.selected}const qt=t=>{const e=window.open(t,"_blank","noopener,noreferrer");e&&(e.opener=null)};function Ru(t){const e=k.c(24),{flow:s}=t,i=D(Fu);if(s.type!=="http"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx(pe,{icon:"fa-download",onClick:Du,disabled:!0,children:"Download"}),e[0]=r):r=e[0],r}if(s.request.contentLength&&!s.response?.contentLength){let r;e[1]!==s?(r=()=>qt(we.getContentURL(s,s.request)),e[1]=s,e[2]=r):r=e[2];const n=!i;let l;return e[3]!==r||e[4]!==n?(l=o.jsx(pe,{icon:"fa-download",onClick:r,disabled:n,children:"Download"}),e[3]=r,e[4]=n,e[5]=l):l=e[5],l}if(s.response){const r=s.response;if(!s.request.contentLength&&s.response.contentLength){let n;e[6]!==s||e[7]!==r?(n=()=>qt(we.getContentURL(s,r)),e[6]=s,e[7]=r,e[8]=n):n=e[8];const l=!i;let a;return e[9]!==n||e[10]!==l?(a=o.jsx(pe,{icon:"fa-download",onClick:n,disabled:l,children:"Download"}),e[9]=n,e[10]=l,e[11]=a):a=e[11],a}if(s.request.contentLength&&s.response.contentLength){const n=!i;let l;e[12]!==n?(l=o.jsx(pe,{icon:"fa-download",onClick:Au,disabled:n,children:"Download▾"}),e[12]=n,e[13]=l):l=e[13];let a;e[14]===Symbol.for("react.memo_cache_sentinel")?(a={placement:"bottom-start"},e[14]=a):a=e[14];let d;e[15]!==s?(d=o.jsx(ke,{onClick:()=>qt(we.getContentURL(s,s.request)),children:"Download request"}),e[15]=s,e[16]=d):d=e[16];let f;e[17]!==s||e[18]!==r?(f=o.jsx(ke,{onClick:()=>qt(we.getContentURL(s,r)),children:"Download response"}),e[17]=s,e[18]=r,e[19]=f):f=e[19];let p;return e[20]!==l||e[21]!==d||e[22]!==f?(p=o.jsxs(Et,{text:l,options:a,children:[d,f]}),e[20]=l,e[21]=d,e[22]=f,e[23]=p):p=e[23],p}}return null}function Au(){return 1}function Du(){return 0}function Fu(t){return t.flows.selected.length===1}function Iu(t){const e=k.c(20),{flow:s}=t,i=D(Pu),r=s.type!=="http"||!i;let n;e[0]!==r?(n=o.jsx(pe,{title:"Export flow.",icon:"fa-clone",onClick:Lu,disabled:r,children:"Export▾"}),e[0]=r,e[1]=n):n=e[1];let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l={placement:"bottom-start"},e[2]=l):l=e[2];let a;e[3]!==s?(a=o.jsx(ke,{onClick:()=>yt(s,"raw_request"),children:"Copy raw request"}),e[3]=s,e[4]=a):a=e[4];let d;e[5]!==s?(d=o.jsx(ke,{onClick:()=>yt(s,"raw_response"),children:"Copy raw response"}),e[5]=s,e[6]=d):d=e[6];let f;e[7]!==s?(f=o.jsx(ke,{onClick:()=>yt(s,"raw"),children:"Copy raw request and response"}),e[7]=s,e[8]=f):f=e[8];let p;e[9]!==s?(p=o.jsx(ke,{onClick:()=>yt(s,"curl"),children:"Copy as cURL"}),e[9]=s,e[10]=p):p=e[10];let h;e[11]!==s?(h=o.jsx(ke,{onClick:()=>yt(s,"httpie"),children:"Copy as HTTPie"}),e[11]=s,e[12]=h):h=e[12];let g;return e[13]!==n||e[14]!==a||e[15]!==d||e[16]!==f||e[17]!==p||e[18]!==h?(g=o.jsxs(Et,{className:"",text:n,options:l,children:[a,d,f,p,h]}),e[13]=n,e[14]=a,e[15]=d,e[16]=f,e[17]=p,e[18]=h,e[19]=g):g=e[19],g}function Lu(){return 1}function Pu(t){return t.flows.selected.length===1}const Ou={":red_circle:":"🔴",":orange_circle:":"🟠",":yellow_circle:":"🟡",":green_circle:":"🟢",":large_blue_circle:":"🔵",":purple_circle:":"🟣",":brown_circle:":"🟤"};function Mu(t){const e=k.c(5),{flows:s}=t,i=G();let r,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx(pe,{title:"mark flow",icon:"fa-paint-brush text-success",onClick:qu,children:"Mark▾"}),n={placement:"bottom-start"},e[0]=r,e[1]=n):(r=e[0],n=e[1]);let l;return e[2]!==i||e[3]!==s?(l=o.jsxs(Et,{className:"",text:r,options:n,children:[o.jsx(ke,{onClick:()=>i(Kn(s,"")),children:"⚪ (no marker)"}),Object.entries(Ou).map(a=>{const[d,f]=a;return o.jsxs(ke,{onClick:()=>i(Kn(s,d)),children:[f," ",d.replace(/[:_]/g," ")]},d)})]}),e[2]=i,e[3]=s,e[4]=l):l=e[4],l}function qu(){return 1}const li={[xe.Capture]:Xr,[xe.FlowList]:Zr,[xe.Options]:eo,[xe.Flow]:to};function Hu(){const t=k.c(26),e=G(),s=D(Uu),i=D(Vu),[r,n]=I.useState(!1);let l;t[0]!==i.length?(l=[xe.Capture,xe.FlowList,xe.Options],i.length>0&&l.push(xe.Flow),t[0]=i.length,t[1]=l):l=t[1];let a;t[2]!==s||t[3]!==e||t[4]!==i.length||t[5]!==r?(a=()=>{i.length>0&&!r?(e(Vt(xe.Flow)),n(!0)):i.length===0&&(r&&n(!1),s===xe.Flow&&e(Vt(xe.FlowList)))},t[2]=s,t[3]=e,t[4]=i.length,t[5]=r,t[6]=a):a=t[6];let d;t[7]!==s||t[8]!==i||t[9]!==r?(d=[i,r,s],t[7]=s,t[8]=i,t[9]=r,t[10]=d):d=t[10],I.useEffect(a,d);let f;t[11]!==e?(f=function(E,T){T.preventDefault(),e(Vt(E))},t[11]=e,t[12]=f):f=t[12];const p=f,h=li[s];let g;t[13]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(uu,{}),t[13]=g):g=t[13];let _;t[14]!==s||t[15]!==l||t[16]!==p?(_=l.map(N=>o.jsx("a",{href:"#",className:je({active:N===s}),onClick:E=>p(N,E),children:li[N].title},N)),t[14]=s,t[15]=l,t[16]=p,t[17]=_):_=t[17];let j;t[18]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(gt,{children:o.jsx(mu,{})}),t[18]=j):j=t[18];let y;t[19]!==_?(y=o.jsxs("nav",{className:"nav-tabs nav-tabs-lg",children:[g,_,j]}),t[19]=_,t[20]=y):y=t[20];let w;t[21]!==h?(w=o.jsx("div",{children:o.jsx(h,{})}),t[21]=h,t[22]=w):w=t[22];let $;return t[23]!==y||t[24]!==w?($=o.jsxs("header",{children:[y,w]}),t[23]=y,t[24]=w,t[25]=$):$=t[25],$}function Vu(t){return t.flows.selected}function Uu(t){return t.ui.tabs.current}const ds=function(){function t(i,r){function n(){this.constructor=i}n.prototype=r.prototype,i.prototype=new n}function e(i,r,n,l){this.message=i,this.expected=r,this.found=n,this.location=l,this.name="SyntaxError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,e)}t(e,Error);function s(i){var r=arguments.length>1?arguments[1]:{},n={},l={Expr:Re},a=Re,d=function(b,S){return[b,...S]},f=function(b){return[b]},p=function(){return""},h={type:"other",description:"string"},g='"',_={type:"literal",value:'"',description:'"\\""'},j=function(b){return b.join("")},y="'",w={type:"literal",value:"'",description:`"'"`},$=/^["\\]/,N={type:"class",value:'["\\\\]',description:'["\\\\]'},E={type:"any",description:"any character"},T=function(b){return b},P="\\",L={type:"literal",value:"\\",description:'"\\\\"'},O=/^['\\]/,M={type:"class",value:"['\\\\]",description:"['\\\\]"},U=/^['"\\]/,V={type:"class",value:`['"\\\\]`,description:`['"\\\\]`},W="n",J={type:"literal",value:"n",description:'"n"'},z=function(){return`
6`},te="r",Y={type:"literal",value:"r",description:'"r"'},Q=function(){return"\r"},X="t",Z={type:"literal",value:"t",description:'"t"'},ae=function(){return" "},le={type:"other",description:"whitespace"},de=/^[ \t\n\r]/,ye={type:"class",value:"[ \\t\\n\\r]",description:"[ \\t\\n\\r]"},Pe={type:"other",description:"control character"},Se=/^[|&!()~"]/,Ee={type:"class",value:'[|&!()~"]',description:'[|&!()~"]'},C=0,he=[{line:1,column:1,seenCR:!1}],B=0,oe=[],q=0,$e;if("startRule"in r){if(!(r.startRule in l))throw new Error(`Can't start parsing from rule "`+r.startRule+'".');a=l[r.startRule]}function We(b){var S=he[b],A,H;if(S)return S;for(A=b-1;!he[A];)A--;for(S=he[A],S={line:S.line,column:S.column,seenCR:S.seenCR};A<b;)H=i.charAt(A),H===`
7`?(S.seenCR||S.line++,S.column=1,S.seenCR=!1):H==="\r"||H==="\u2028"||H==="\u2029"?(S.line++,S.column=1,S.seenCR=!0):(S.column++,S.seenCR=!1),A++;return he[b]=S,S}function Oe(b,S){var A=We(b),H=We(S);return{start:{offset:b,line:A.line,column:A.column},end:{offset:S,line:H.line,column:H.column}}}function ee(b){C<B||(C>B&&(B=C,oe=[]),oe.push(b))}function Me(b,S,A,H){function Tt(Ce){var De=1;for(Ce.sort(function(ut,Ke){return ut.description<Ke.description?-1:ut.description>Ke.description?1:0});De<Ce.length;)Ce[De-1]===Ce[De]?Ce.splice(De,1):De++}function es(Ce,De){function ut(At){function ft(Fe){return Fe.charCodeAt(0).toString(16).toUpperCase()}return At.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(Fe){return"\\x0"+ft(Fe)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(Fe){return"\\x"+ft(Fe)}).replace(/[\u0100-\u0FFF]/g,function(Fe){return"\\u0"+ft(Fe)}).replace(/[\u1000-\uFFFF]/g,function(Fe){return"\\u"+ft(Fe)})}var Ke=new Array(Ce.length),vt,Rt,it;for(it=0;it<Ce.length;it++)Ke[it]=Ce[it].description;return vt=Ce.length>1?Ke.slice(0,-1).join(", ")+" or "+Ke[Ce.length-1]:Ke[0],Rt=De?'"'+ut(De)+'"':"end of input","Expected "+vt+" but "+Rt+" found."}return S!==null&&Tt(S),new e(es(S,A),S,A,H)}function Re(){var b,S,A,H;if(b=C,S=re(),S!==n){if(A=[],H=Je(),H!==n)for(;H!==n;)A.push(H),H=Je();else A=n;A!==n?(H=Re(),H!==n?(S=d(S,H),b=S):(C=b,b=n)):(C=b,b=n)}else C=b,b=n;if(b===n&&(b=C,S=re(),S!==n&&(S=f(S)),b=S,b===n)){for(b=C,S=[],A=Je();A!==n;)S.push(A),A=Je();S!==n&&(S=p()),b=S}return b}function re(){var b,S,A,H;if(q++,b=C,i.charCodeAt(C)===34?(S=g,C++):(S=n,q===0&&ee(_)),S!==n){for(A=[],H=ue();H!==n;)A.push(H),H=ue();A!==n?(i.charCodeAt(C)===34?(H=g,C++):(H=n,q===0&&ee(_)),H!==n?(S=j(A),b=S):(C=b,b=n)):(C=b,b=n)}else C=b,b=n;if(b===n){if(b=C,i.charCodeAt(C)===39?(S=y,C++):(S=n,q===0&&ee(w)),S!==n){for(A=[],H=ge();H!==n;)A.push(H),H=ge();A!==n?(i.charCodeAt(C)===39?(H=y,C++):(H=n,q===0&&ee(w)),H!==n?(S=j(A),b=S):(C=b,b=n)):(C=b,b=n)}else C=b,b=n;if(b===n){if(b=C,S=C,q++,A=Zt(),q--,A===n?S=void 0:(C=S,S=n),S!==n){if(A=[],H=Ae(),H!==n)for(;H!==n;)A.push(H),H=Ae();else A=n;A!==n?(S=j(A),b=S):(C=b,b=n)}else C=b,b=n;if(b===n){if(b=C,i.charCodeAt(C)===34?(S=g,C++):(S=n,q===0&&ee(_)),S!==n){for(A=[],H=ue();H!==n;)A.push(H),H=ue();A!==n?(S=j(A),b=S):(C=b,b=n)}else C=b,b=n;if(b===n)if(b=C,i.charCodeAt(C)===39?(S=y,C++):(S=n,q===0&&ee(w)),S!==n){for(A=[],H=ge();H!==n;)A.push(H),H=ge();A!==n?(S=j(A),b=S):(C=b,b=n)}else C=b,b=n}}}return q--,b===n&&(S=n,q===0&&ee(h)),b}function ue(){var b,S,A;return b=C,S=C,q++,$.test(i.charAt(C))?(A=i.charAt(C),C++):(A=n,q===0&&ee(N)),q--,A===n?S=void 0:(C=S,S=n),S!==n?(i.length>C?(A=i.charAt(C),C++):(A=n,q===0&&ee(E)),A!==n?(S=T(A),b=S):(C=b,b=n)):(C=b,b=n),b===n&&(b=C,i.charCodeAt(C)===92?(S=P,C++):(S=n,q===0&&ee(L)),S!==n?(A=nt(),A!==n?(S=T(A),b=S):(C=b,b=n)):(C=b,b=n)),b}function ge(){var b,S,A;return b=C,S=C,q++,O.test(i.charAt(C))?(A=i.charAt(C),C++):(A=n,q===0&&ee(M)),q--,A===n?S=void 0:(C=S,S=n),S!==n?(i.length>C?(A=i.charAt(C),C++):(A=n,q===0&&ee(E)),A!==n?(S=T(A),b=S):(C=b,b=n)):(C=b,b=n),b===n&&(b=C,i.charCodeAt(C)===92?(S=P,C++):(S=n,q===0&&ee(L)),S!==n?(A=nt(),A!==n?(S=T(A),b=S):(C=b,b=n)):(C=b,b=n)),b}function Ae(){var b,S,A;return b=C,S=C,q++,A=Je(),q--,A===n?S=void 0:(C=S,S=n),S!==n?(i.length>C?(A=i.charAt(C),C++):(A=n,q===0&&ee(E)),A!==n?(S=T(A),b=S):(C=b,b=n)):(C=b,b=n),b}function nt(){var b,S;return U.test(i.charAt(C))?(b=i.charAt(C),C++):(b=n,q===0&&ee(V)),b===n&&(b=C,i.charCodeAt(C)===110?(S=W,C++):(S=n,q===0&&ee(J)),S!==n&&(S=z()),b=S,b===n&&(b=C,i.charCodeAt(C)===114?(S=te,C++):(S=n,q===0&&ee(Y)),S!==n&&(S=Q()),b=S,b===n&&(b=C,i.charCodeAt(C)===116?(S=X,C++):(S=n,q===0&&ee(Z)),S!==n&&(S=ae()),b=S))),b}function Je(){var b;return q++,de.test(i.charAt(C))?(b=i.charAt(C),C++):(b=n,q===0&&ee(ye)),q--,b===n&&q===0&&ee(le),b}function Zt(){var b;return q++,Se.test(i.charAt(C))?(b=i.charAt(C),C++):(b=n,q===0&&ee(Ee)),q--,b===n&&q===0&&ee(Pe),b}if($e=a(),$e!==n&&C===i.length)return $e;throw $e!==n&&C<i.length&&ee({type:"end",description:"end of input"}),Me(null,oe,B<i.length?i.charAt(B):null,B<i.length?Oe(B,B+1):Oe(B,B))}return{SyntaxError:e,parse:s}}();function us(t,e=""){if(!t)return[];const s=[];for(const i of Object.keys(t))i.startsWith(e)&&s.push(i);return s}function Bu(t){const e=k.c(6),{results:s}=t,i=I.useRef(null);let r,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{i&&i.current.addEventListener("DOMNodeInserted",Ku)},n=[],e[0]=r,e[1]=n):(r=e[0],n=e[1]),I.useEffect(r,n);let l;e[2]!==s?(l=s.map(Wu),e[2]=s,e[3]=l):l=e[3];let a;return e[4]!==l?(a=o.jsx("div",{className:"command-result",ref:i,children:l}),e[4]=l,e[5]=a):a=e[5],a}function Wu(t,e){return o.jsxs("div",{children:[o.jsx("div",{children:o.jsxs("strong",{children:["$ ",t.command]})}),t.result]},e)}function Ku(t){const e=t.currentTarget;e.scroll({top:e.scrollHeight,behavior:"auto"})}function zu(t){const e=k.c(20),{nextArgs:s,currentArg:i,help:r,description:n,availableCommands:l}=t;let a;if(e[0]!==i||e[1]!==s){a=[];for(let w=0;w<s.length;w++){if(w==i){a.push(o.jsx("mark",{children:s[w]},w));continue}a.push(o.jsxs("span",{children:[s[w]," "]},w))}e[0]=i,e[1]=s,e[2]=a}else a=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx("div",{className:"arrow"}),e[3]=d):d=e[3];let f;e[4]!==a?(f=a.length>0&&o.jsxs("div",{children:[o.jsx("strong",{children:"Argument suggestion:"})," ",a]}),e[4]=a,e[5]=f):f=e[5];let p;e[6]!==r?(p=r?.includes("->")&&o.jsxs("div",{children:[o.jsx("strong",{children:"Signature help: "}),r]}),e[6]=r,e[7]=p):p=e[7];let h;e[8]!==n?(h=n&&o.jsxs("div",{children:["# ",n]}),e[8]=n,e[9]=h):h=e[9];let g;e[10]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("strong",{children:"Available Commands: "}),e[10]=g):g=e[10];let _;e[11]!==l?(_=JSON.stringify(l),e[11]=l,e[12]=_):_=e[12];let j;e[13]!==_?(j=o.jsxs("div",{children:[g,o.jsx("p",{className:"available-commands",children:_})]}),e[13]=_,e[14]=j):j=e[14];let y;return e[15]!==f||e[16]!==p||e[17]!==h||e[18]!==j?(y=o.jsxs("div",{className:"argument-suggestion popover top",children:[d,o.jsxs("div",{className:"popover-content",children:[f,p,h,j]})]}),e[15]=f,e[16]=p,e[17]=h,e[18]=j,e[19]=y):y=e[19],y}function Gu(){const t=k.c(45),[e,s]=I.useState(""),[i,r]=I.useState(""),[n,l]=I.useState(0);let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=[],t[0]=a):a=t[0];const[d,f]=I.useState(a);let p;t[1]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[1]=p):p=t[1];const[h,g]=I.useState(p);let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_={},t[2]=_):_=t[2];const[j,y]=I.useState(_);let w;t[3]===Symbol.for("react.memo_cache_sentinel")?(w=[],t[3]=w):w=t[3];const[$,N]=I.useState(w),[E,T]=I.useState(0),[P,L]=I.useState(""),[O,M]=I.useState("");let U;t[4]===Symbol.for("react.memo_cache_sentinel")?(U=[],t[4]=U):U=t[4];const[V,W]=I.useState(U);let J;t[5]===Symbol.for("react.memo_cache_sentinel")?(J=[],t[5]=J):J=t[5];const[z,te]=I.useState(J),[Y,Q]=I.useState(void 0);let X,Z;t[6]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{ne("/commands",{method:"GET"}).then(ef).then(re=>{y(re),f(us(re)),g(Object.keys(re))}).catch(Zu)},Z=[],t[6]=X,t[7]=Z):(X=t[6],Z=t[7]),I.useEffect(X,Z);let ae,le;t[8]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>{Bt("commands.history.get").then(re=>{te(re.value)}).catch(Xu)},le=[],t[8]=ae,t[9]=le):(ae=t[8],le=t[9]),I.useEffect(ae,le);let de;t[10]!==j?(de=(re,ue)=>{const ge=ds.parse(ue),Ae=ds.parse(re);L(j[ge[0]]?.signature_help),M(j[ge[0]]?.help||""),f(us(j,Ae[0])),g(us(j,ge[0]));const nt=j[ge[0]]?.parameters.map(Qu);nt&&(N([ge[0],...nt]),T(ge.length-1))},t[10]=j,t[11]=de):de=t[11];const ye=de;let Pe;t[12]===Symbol.for("react.memo_cache_sentinel")?(Pe=re=>{s(re.target.value),r(re.target.value),l(0)},t[12]=Pe):Pe=t[12];const Se=Pe;let Ee;t[13]!==h||t[14]!==d||t[15]!==n||t[16]!==Y||t[17]!==z||t[18]!==e||t[19]!==V?(Ee=re=>{if(re.key==="Enter"){const[ue,...ge]=ds.parse(e);te([...z,e]),Bt("commands.history.add",e).catch(Ju),ne.post(`/commands/${ue}`,{arguments:ge}).then(Yu).then(Ae=>{Q(void 0),N([]),W([...V,{command:e,result:JSON.stringify(Ae.value||Ae.error)}])}).catch(Ae=>{Q(void 0),N([]),W([...V,{command:e,result:Ae.toString()}])}),L(""),M(""),s(""),r(""),l(0),f(h)}if(re.key==="ArrowUp"){let ue;Y===void 0?ue=z.length-1:ue=Math.max(0,Y-1),s(z[ue]),r(z[ue]),Q(ue)}if(re.key==="ArrowDown"){if(Y===void 0)return;if(Y==z.length-1)s(""),r(""),Q(void 0);else{const ue=Y+1;s(z[ue]),r(z[ue]),Q(ue)}}re.key==="Tab"&&(s(d[n]),l((n+1)%d.length),re.preventDefault()),re.stopPropagation()},t[13]=h,t[14]=d,t[15]=n,t[16]=Y,t[17]=z,t[18]=e,t[19]=V,t[20]=Ee):Ee=t[20];const C=Ee;let he;t[21]!==j||t[22]!==e||t[23]!==i||t[24]!==ye?(he=re=>{if(!e){g(Object.keys(j));return}ye(i,e),re.stopPropagation()},t[21]=j,t[22]=e,t[23]=i,t[24]=ye,t[25]=he):he=t[25];const B=he;let oe;t[26]===Symbol.for("react.memo_cache_sentinel")?(oe=o.jsx("div",{className:"command-title",children:"Command Result"}),t[26]=oe):oe=t[26];let q;t[27]!==V?(q=o.jsx(Bu,{results:V}),t[27]=V,t[28]=q):q=t[28];let $e;t[29]!==h||t[30]!==E||t[31]!==O||t[32]!==$||t[33]!==P?($e=o.jsx(zu,{nextArgs:$,currentArg:E,help:P,description:O,availableCommands:h}),t[29]=h,t[30]=E,t[31]=O,t[32]=$,t[33]=P,t[34]=$e):$e=t[34];let We;t[35]===Symbol.for("react.memo_cache_sentinel")?(We=je("command-input input-group"),t[35]=We):We=t[35];let Oe;t[36]===Symbol.for("react.memo_cache_sentinel")?(Oe=o.jsx("span",{className:"input-group-addon",children:o.jsx("i",{className:"fa fa-fw fa-terminal"})}),t[36]=Oe):Oe=t[36];const ee=e||"";let Me;t[37]!==C||t[38]!==B||t[39]!==ee?(Me=o.jsxs("div",{className:We,children:[Oe,o.jsx("input",{type:"text",placeholder:"Enter command",className:"form-control",value:ee,onChange:Se,onKeyDown:C,onKeyUp:B})]}),t[37]=C,t[38]=B,t[39]=ee,t[40]=Me):Me=t[40];let Re;return t[41]!==q||t[42]!==$e||t[43]!==Me?(Re=o.jsxs("div",{className:"command",children:[oe,q,$e,Me]}),t[41]=q,t[42]=$e,t[43]=Me,t[44]=Re):Re=t[44],Re}function Yu(t){return t.json()}function Ju(){return 0}function Qu(t){return t.name}function Xu(t){return console.error(t)}function Zu(t){return console.error(t)}function ef(t){return t.json()}function tf(t){const e=k.c(7),{checked:s,onToggle:i,text:r}=t,n="btn btn-toggle "+(s?"btn-primary":"btn-default"),l="fa fa-fw "+(s?"fa-check-square-o":"fa-square-o");let a;e[0]!==l?(a=o.jsx("i",{className:l}),e[0]=l,e[1]=a):a=e[1];let d;return e[2]!==i||e[3]!==n||e[4]!==a||e[5]!==r?(d=o.jsxs("div",{className:n,onClick:i,children:[a," ",r]}),e[2]=i,e[3]=n,e[4]=a,e[5]=r,e[6]=d):d=e[6],d}class sf extends I.Component{static defaultProps={rowHeight:18};heights;viewport=Te.createRef();constructor(e){super(e),this.heights={},this.state={vScroll:kt()},this.onViewportUpdate=this.onViewportUpdate.bind(this)}componentDidMount(){window.addEventListener("resize",this.onViewportUpdate),this.onViewportUpdate()}componentWillUnmount(){window.removeEventListener("resize",this.onViewportUpdate)}getSnapshotBeforeUpdate(){return Es(this.viewport)}componentDidUpdate(e,s,i){i&&Jr(this.viewport),this.onViewportUpdate()}onViewportUpdate(){const e=this.viewport.current,s=kt({itemCount:this.props.events.length,rowHeight:this.props.rowHeight,viewportTop:e.scrollTop,viewportHeight:e.offsetHeight,itemHeights:this.props.events.map(i=>this.heights[i.id])});Kt(this.state.vScroll,s)||this.setState({vScroll:s})}setHeight(e,s){if(s&&!this.heights[e]){const i=s.offsetHeight;this.heights[e]!==i&&(this.heights[e]=i,this.onViewportUpdate())}}render(){const{vScroll:e}=this.state,{events:s}=this.props;return o.jsxs("pre",{ref:this.viewport,onScroll:this.onViewportUpdate,children:[o.jsx("div",{style:{height:e.paddingTop}}),s.slice(e.start,e.end).map(i=>o.jsxs("div",{ref:r=>{this.setHeight(i.id,r)},children:[o.jsx(nf,{event:i}),i.message]},i.id)),o.jsx("div",{style:{height:e.paddingBottom}})]})}}function nf(t){const e=k.c(4),{event:s}=t;let i;e[0]!==s.level?(i={web:"html5",debug:"bug",warn:"exclamation-triangle",error:"ban"}[s.level]||"info",e[0]=s.level,e[1]=i):i=e[1];const n=`fa fa-fw fa-${i}`;let l;return e[2]!==n?(l=o.jsx("i",{className:n}),e[2]=n,e[3]=l):l=e[3],l}class rf extends I.Component{static defaultProps={defaultHeight:200};dragStart;constructor(e,s){super(e,s),this.state={height:this.props.defaultHeight},this.onDragStart=this.onDragStart.bind(this),this.onDragMove=this.onDragMove.bind(this),this.onDragStop=this.onDragStop.bind(this)}onDragStart(e){e.preventDefault(),this.dragStart=this.state.height+e.pageY,window.addEventListener("mousemove",this.onDragMove),window.addEventListener("mouseup",this.onDragStop),window.addEventListener("dragend",this.onDragStop)}onDragMove(e){e.preventDefault(),this.setState({height:this.dragStart-e.pageY})}onDragStop(e){e.preventDefault(),window.removeEventListener("mousemove",this.onDragMove)}render(){const{height:e}=this.state,{filters:s,events:i,toggleFilter:r,close:n}=this.props;return o.jsxs("div",{className:"eventlog",style:{height:e},children:[o.jsxs("div",{onMouseDown:this.onDragStart,children:["Eventlog",o.jsxs("div",{className:"pull-right",children:[Object.values(Gi).map(l=>o.jsx(tf,{text:l,checked:s[l],onToggle:()=>r(l)},l)),o.jsx("i",{onClick:n,className:"fa fa-close"})]})]}),o.jsx(sf,{events:i})]})}}const of=zt(t=>({filters:t.eventLog.filters,events:t.eventLog.view}),{close:Gt,toggleFilter:zi})(rf);function lf(){const t=k.c(56),e=D(uf),{mode:s,intercept:i,showhost:r,upstream_cert:n,rawtcp:l,http2:a,websocket:d,anticache:f,anticomp:p,stickyauth:h,stickycookie:g,stream_large_bodies:_,listen_host:j,listen_port:y,server:w,ssl_insecure:$}=D(df),N=D(af),E=D(cf);let T;t[0]!==s?(T=s&&(s.length!==1||s[0]!=="regular")&&o.jsx("span",{className:"label label-success",children:s.join(",")}),t[0]=s,t[1]=T):T=t[1];let P;t[2]!==i?(P=i&&o.jsxs("span",{className:"label label-success",children:["Intercept: ",i]}),t[2]=i,t[3]=P):P=t[3];let L;t[4]!==$?(L=$&&o.jsx("span",{className:"label label-danger",children:"ssl_insecure"}),t[4]=$,t[5]=L):L=t[5];let O;t[6]!==r?(O=r&&o.jsx("span",{className:"label label-success",children:"showhost"}),t[6]=r,t[7]=O):O=t[7];let M;t[8]!==n?(M=!n&&o.jsx("span",{className:"label label-success",children:"no-upstream-cert"}),t[8]=n,t[9]=M):M=t[9];let U;t[10]!==l?(U=!l&&o.jsx("span",{className:"label label-success",children:"no-raw-tcp"}),t[10]=l,t[11]=U):U=t[11];let V;t[12]!==a?(V=!a&&o.jsx("span",{className:"label label-success",children:"no-http2"}),t[12]=a,t[13]=V):V=t[13];let W;t[14]!==d?(W=!d&&o.jsx("span",{className:"label label-success",children:"no-websocket"}),t[14]=d,t[15]=W):W=t[15];let J;t[16]!==f?(J=f&&o.jsx("span",{className:"label label-success",children:"anticache"}),t[16]=f,t[17]=J):J=t[17];let z;t[18]!==p?(z=p&&o.jsx("span",{className:"label label-success",children:"anticomp"}),t[18]=p,t[19]=z):z=t[19];let te;t[20]!==h?(te=h&&o.jsxs("span",{className:"label label-success",children:["stickyauth: ",h]}),t[20]=h,t[21]=te):te=t[21];let Y;t[22]!==g?(Y=g&&o.jsxs("span",{className:"label label-success",children:["stickycookie: ",g]}),t[22]=g,t[23]=Y):Y=t[23];let Q;t[24]!==_?(Q=_&&o.jsxs("span",{className:"label label-success",children:["stream: ",hi(_)]}),t[24]=_,t[25]=Q):Q=t[25];let X;t[26]!==N||t[27]!==E?(X=E>0&&o.jsxs("span",{className:"label label-default",children:[N," of ",E," flows selected"]}),t[26]=N,t[27]=E,t[28]=X):X=t[28];let Z;t[29]!==j||t[30]!==y||t[31]!==w?(Z=w&&o.jsxs("span",{className:"label label-primary",title:"HTTP Proxy Server Address",children:[j||"*",":",y||8080]}),t[29]=j,t[30]=y,t[31]=w,t[32]=Z):Z=t[32];let ae;t[33]!==Z?(ae=o.jsx(gt,{children:Z}),t[33]=Z,t[34]=ae):ae=t[34];let le;t[35]!==e?(le=o.jsxs("span",{className:"label label-default",title:"Mitmproxy Version",children:["mitmproxy ",e]}),t[35]=e,t[36]=le):le=t[36];let de;t[37]!==ae||t[38]!==le?(de=o.jsxs("div",{className:"pull-right",children:[ae,le]}),t[37]=ae,t[38]=le,t[39]=de):de=t[39];let ye;return t[40]!==T||t[41]!==P||t[42]!==te||t[43]!==Y||t[44]!==Q||t[45]!==X||t[46]!==de||t[47]!==L||t[48]!==O||t[49]!==M||t[50]!==U||t[51]!==V||t[52]!==W||t[53]!==J||t[54]!==z?(ye=o.jsxs("footer",{children:[T,P,L,O,M,U,V,W,J,z,te,Y,Q,X,de]}),t[40]=T,t[41]=P,t[42]=te,t[43]=Y,t[44]=Q,t[45]=X,t[46]=de,t[47]=L,t[48]=O,t[49]=M,t[50]=U,t[51]=V,t[52]=W,t[53]=J,t[54]=z,t[55]=ye):ye=t[55],ye}function cf(t){return t.flows.list.length}function af(t){return t.flows.selected.length}function df(t){return t.options}function uf(t){return t.backendState.version}function ff(t){const e=k.c(3),{children:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"modal-backdrop fade in"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsxs("div",{children:[i,o.jsx("div",{className:"modal modal-visible",id:"optionsModal",tabIndex:-1,role:"dialog","aria-labelledby":"options",children:o.jsx("div",{className:"modal-dialog modal-lg",role:"document",children:o.jsx("div",{className:"modal-content",children:s})})})]}),e[1]=s,e[2]=r):r=e[2],r}const pf=t=>{t.key!=="Escape"&&t.stopPropagation()};function so(t){const e=k.c(10);let s,i,r;e[0]!==t?({value:r,onChange:s,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);let n;e[4]!==s?(n=a=>s(a.target.checked),e[4]=s,e[5]=n):n=e[5];let l;return e[6]!==i||e[7]!==n||e[8]!==r?(l=o.jsx("div",{className:"checkbox",children:o.jsxs("label",{children:[o.jsx("input",{type:"checkbox",checked:r,onChange:n,...i}),"Enable"]})}),e[6]=i,e[7]=n,e[8]=r,e[9]=l):l=e[9],l}function ci(t){const e=k.c(10);let s,i,r;e[0]!==t?({value:r,onChange:s,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);const n=r||"";let l;e[4]!==s?(l=d=>s(d.target.value),e[4]=s,e[5]=l):l=e[5];let a;return e[6]!==i||e[7]!==n||e[8]!==l?(a=o.jsx("input",{type:"text",value:n,onChange:l,...i}),e[6]=i,e[7]=n,e[8]=l,e[9]=a):a=e[9],a}function ai(t){return function({onChange:s,...i}){return o.jsx(t,{onChange:r=>s(r||null),...i})}}function di(t){const e=k.c(10);let s,i,r;e[0]!==t?({value:r,onChange:s,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);let n;e[4]!==s?(n=a=>s(parseInt(a.target.value)),e[4]=s,e[5]=n):n=e[5];let l;return e[6]!==i||e[7]!==n||e[8]!==r?(l=o.jsx("input",{type:"number",value:r,onChange:n,...i}),e[6]=i,e[7]=n,e[8]=r,e[9]=l):l=e[9],l}function hf(t){const e=k.c(12);let s,i,r,n;if(e[0]!==t){const{value:d,onChange:f,choices:p,...h}=t;n=d,s=p,i=h,r=g=>f(g.target.value),e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n}else s=e[1],i=e[2],r=e[3],n=e[4];let l;e[5]!==s?(l=s.map(mf),e[5]=s,e[6]=l):l=e[6];let a;return e[7]!==i||e[8]!==r||e[9]!==l||e[10]!==n?(a=o.jsx("select",{onChange:r,value:n,...i,children:l}),e[7]=i,e[8]=r,e[9]=l,e[10]=n,e[11]=a):a=e[11],a}function mf(t){return o.jsx("option",{value:t,children:t},t)}function gf(t){const e=k.c(13);let s,i,r;e[0]!==t?({value:r,onChange:s,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r):(s=e[1],i=e[2],r=e[3]);const n=Math.max(r.length,1);let l;e[4]!==r?(l=r.join(`
8`),e[4]=r,e[5]=l):l=e[5];const[a,d]=Te.useState(l);let f;e[6]!==s?(f=g=>{const _=g.target.value;d(_),s(_.split(`
9`).map(xf).filter(vf))},e[6]=s,e[7]=f):f=e[7];const p=f;let h;return e[8]!==p||e[9]!==n||e[10]!==i||e[11]!==a?(h=o.jsx("textarea",{rows:n,value:a,onChange:p,...i}),e[8]=p,e[9]=n,e[10]=i,e[11]=a,e[12]=h):h=e[12],h}function vf(t){return t!==""}function xf(t){return t.trim()}const _f={bool:so,str:ci,int:di,"optional str":ai(ci),"optional int":ai(di),"sequence of str":gf};function jf(t){const e=k.c(16),{choices:s,type:i,value:r,onChange:n,name:l,error:a}=t;let d,f;if(e[0]!==d||e[1]!==s||e[2]!==n||e[3]!==i||e[4]!==r){if(f={onChange:n,value:r},s)d=hf,f.choices=s;else if(d=_f[i],!d)throw`unknown option type ${i}`;d!==so&&(f.className="form-control"),e[0]=d,e[1]=s,e[2]=n,e[3]=i,e[4]=r,e[5]=f,e[6]=d}else f=e[5],d=e[6];let p;e[7]!==a?(p=je({"has-error":a}),e[7]=a,e[8]=p):p=e[8];let h;e[9]!==d||e[10]!==l||e[11]!==f?(h=o.jsx(d,{name:l,onKeyDown:pf,...f}),e[9]=d,e[10]=l,e[11]=f,e[12]=h):h=e[12];let g;return e[13]!==p||e[14]!==h?(g=o.jsx("div",{className:p,children:h}),e[13]=p,e[14]=h,e[15]=g):g=e[15],g}function yf(t){const e=k.c(18),{name:s}=t,i=G();let r;e[0]!==s?(r=j=>j.options_meta[s]?.choices,e[0]=s,e[1]=r):r=e[1];const n=D(r);let l;e[2]!==s?(l=j=>j.options_meta[s]?.type,e[2]=s,e[3]=l):l=e[3];const a=D(l);let d;e[4]!==s?(d=j=>{const y=j.ui.optionsEditor[s];return y?y.value:j.options_meta[s]?.value},e[4]=s,e[5]=d):d=e[5];const f=D(d);let p;e[6]!==s?(p=j=>j.ui.optionsEditor[s]?.error,e[6]=s,e[7]=p):p=e[7];const h=D(p);let g;e[8]!==i||e[9]!==s?(g=j=>i(Cs(s,j)),e[8]=i,e[9]=s,e[10]=g):g=e[10];let _;return e[11]!==n||e[12]!==h||e[13]!==s||e[14]!==g||e[15]!==a||e[16]!==f?(_=o.jsx(jf,{name:s,choices:n,type:a,value:f,error:h,onChange:g}),e[11]=n,e[12]=h,e[13]=s,e[14]=g,e[15]=a,e[16]=f,e[17]=_):_=e[17],_}function wf(t){const e=k.c(4),{name:s}=t;let i;e[0]!==s?(i=l=>l.options_meta[s]?.help,e[0]=s,e[1]=i):i=e[1];const r=D(i);let n;return e[2]!==r?(n=o.jsx("div",{className:"help-block small",children:r}),e[2]=r,e[3]=n):n=e[3],n}function bf(t){const e=k.c(4),{name:s}=t;let i;e[0]!==s?(i=l=>l.options_meta[s]?.error,e[0]=s,e[1]=i):i=e[1];const r=D(i);if(!r)return null;let n;return e[2]!==r?(n=o.jsx("div",{className:"small text-danger",children:r}),e[2]=r,e[3]=n):n=e[3],n}function Sf(t){const e=k.c(2);let{value:s,defaultVal:i}=t;if(s===i)return null;{if(typeof i=="boolean")i=i?"true":"false";else if(Array.isArray(i)){if(Ht.isEmpty(Ht.compact(s))&&Ht.isEmpty(i))return null;i="[ ]"}else i===""?i='""':i===null&&(i="null");let r;return e[0]!==i?(r=o.jsxs("div",{className:"small",children:["Default: ",o.jsxs("strong",{children:[" ",i," "]})," "]}),e[0]=i,e[1]=r):r=e[1],r}}const $f=zt((t,{name:e})=>({value:t.options[e],defaultVal:t.options_meta[e]?.default}))(Sf);function Cf(){const t=k.c(24),e=G(),s=D(kf,Kt);let i,r,n,l;if(t[0]!==e||t[1]!==s){const h=s.sort();let g;t[6]!==e?(g=()=>e(Wi()),t[6]=e,t[7]=g):g=t[7];let _;t[8]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("i",{className:"fa fa-fw fa-times"}),t[8]=_):_=t[8];let j;t[9]!==g?(j=o.jsx("button",{type:"button",className:"close","data-dismiss":"modal",onClick:g,children:_}),t[9]=g,t[10]=j):j=t[10];let y;t[11]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx("div",{className:"modal-title",children:o.jsx("h4",{children:"Options"})}),t[11]=y):y=t[11],t[12]!==j?(l=o.jsxs("div",{className:"modal-header",children:[j,y]}),t[12]=j,t[13]=l):l=t[13],n="modal-body",i="form-horizontal",r=h.map(Nf),t[0]=e,t[1]=s,t[2]=i,t[3]=r,t[4]=n,t[5]=l}else i=t[2],r=t[3],n=t[4],l=t[5];let a;t[14]!==i||t[15]!==r?(a=o.jsx("div",{className:i,children:r}),t[14]=i,t[15]=r,t[16]=a):a=t[16];let d;t[17]!==n||t[18]!==a?(d=o.jsx("div",{className:n,children:a}),t[17]=n,t[18]=a,t[19]=d):d=t[19];let f;t[20]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsx("div",{className:"modal-footer"}),t[20]=f):f=t[20];let p;return t[21]!==l||t[22]!==d?(p=o.jsxs("div",{children:[l,d,f]}),t[21]=l,t[22]=d,t[23]=p):p=t[23],p}function Nf(t){return o.jsxs("div",{className:"form-group",children:[o.jsxs("div",{className:"col-xs-6",children:[o.jsx("label",{htmlFor:t,children:t}),o.jsx(wf,{name:t})]}),o.jsxs("div",{className:"col-xs-6",children:[o.jsx(yf,{name:t}),o.jsx(bf,{name:t}),o.jsx($f,{name:t})]})]},t)}function kf(t){return Object.keys(t.options_meta)}function Ef(){const t=k.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(ff,{children:o.jsx(Cf,{})}),t[0]=e):e=t[0],e}const Tf={OptionModal:Ef};function Rf(){const t=k.c(3),e=D(Af),s=e?Tf[e]:void 0;if(s){let i;return t[0]!==s?(i=o.jsx(s,{}),t[0]=s,t[1]=i):i=t[1],i}else{let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(o.Fragment,{}),t[2]=i):i=t[2],i}}function Af(t){return t.ui.modal.activeModal}class Df extends I.Component{state={};render=()=>{const{showEventLog:e,showCommandBar:s}=this.props;return this.state.error?(console.log("ERR",this.state),o.jsxs("div",{className:"container",children:[o.jsx("h1",{children:"mitmproxy has crashed."}),o.jsxs("pre",{children:[this.state.error.stack,o.jsx("br",{}),o.jsx("br",{}),"Component Stack:",this.state.errorInfo?.componentStack]}),o.jsxs("p",{children:["Please lodge a bug report at"," ",o.jsx("a",{href:"https://github.com/mitmproxy/mitmproxy/issues",children:"https://github.com/mitmproxy/mitmproxy/issues"}),"."]})]})):o.jsxs("div",{id:"container",tabIndex:0,children:[o.jsx(Hu,{}),o.jsx(lu,{}),s&&o.jsx(Gu,{},"commandbar"),e&&o.jsx(of,{},"eventlog"),o.jsx(lf,{}),o.jsx(Rf,{})]})};componentDidMount(){window.addEventListener("keydown",this.props.onKeyDown)}componentWillUnmount(){window.removeEventListener("keydown",this.props.onKeyDown)}componentDidCatch(e,s){this.setState({error:e,errorInfo:s})}}const Ff=zt(t=>({showEventLog:t.eventLog.visible,showCommandBar:t.commandBar.visible}),{onKeyDown:od})(Df),Ze={SEARCH:"s",HIGHLIGHT:"h",SHOW_EVENTLOG:"e",SHOW_COMMANDBAR:"c"};function If(t){const[e,s]=window.location.hash.substr(1).split("?",2),i=e.substr(1).split("/");if(i[0]==="flows"){if(i.length==3){const[r,n]=i.slice(1);t.dispatch(Ut(n));const l=()=>{const d=t.getState().flows.byId.get(r);d!==void 0&&(a(),t.dispatch(Ve([d])))},a=t.subscribe(l);l()}}else i[0]==="capture"&&t.dispatch(Vt(xe.Capture));s&&s.split("&").forEach(r=>{const[n,l]=r.split("=",2),a=decodeURIComponent(l);switch(n){case Ze.SEARCH:t.dispatch(Ri(a));break;case Ze.HIGHLIGHT:t.dispatch(Ai(a));break;case Ze.SHOW_EVENTLOG:t.getState().eventLog.visible||t.dispatch(Gt());break;case Ze.SHOW_COMMANDBAR:t.getState().commandBar.visible||t.dispatch(Ji());break;default:console.error(`unimplemented query arg: ${r}`)}})}function Lf(t){const e=t.getState(),s={[Ze.SEARCH]:e.ui.filter[ve.Search],[Ze.HIGHLIGHT]:e.ui.filter[ve.Highlight],[Ze.SHOW_EVENTLOG]:e.eventLog.visible,[Ze.SHOW_COMMANDBAR]:e.commandBar.visible},i=Object.keys(s).filter(l=>s[l]).map(l=>`${l}=${encodeURIComponent(s[l])}`).join("&");let r;e.ui.tabs.current===xe.Capture?r="/capture":e.flows.selected.length>0?r=`/flows/${e.flows.selected[0].id}/${e.ui.flow.tab}`:r="/flows",i&&(r+="?"+i);let n=window.location.pathname;n==="blank"&&(n="/"),window.location.hash.substr(1)!==r&&history.replaceState(void 0,"",`${n}#${r}`)}function Pf(t){If(t),t.subscribe(()=>Lf(t))}var lt=(t=>(t.State="state",t.Flows="flows",t.Events="events",t.Options="options",t))(lt||{});class Of{activeFetches;store;filterState;socket;messageQueue;constructor(e){this.activeFetches={},this.store=e,this.filterState=Ti,this.messageQueue=[],this.connect(),this.store.subscribe(this.onStoreUpdate.bind(this))}connect(){this.socket=new WebSocket(location.origin.replace("http","ws")+location.pathname.replace(/\/$/,"")+"/updates"),this.socket.addEventListener("open",()=>this.onOpen()),this.socket.addEventListener("close",e=>this.onClose(e)),this.socket.addEventListener("message",e=>this.onMessage(JSON.parse(e.data))),this.socket.addEventListener("error",e=>this.onError(e))}async onOpen(){for(const e of this.messageQueue)this.socket.send(JSON.stringify(e));this.messageQueue=[],this.store.dispatch(Cc()),await Promise.all([this.fetchData("state"),this.fetchData("flows"),this.fetchData("events"),this.fetchData("options")]),this.store.dispatch(Nc())}onStoreUpdate(){const e=this.store.getState().ui.filter;if(e!==this.filterState){for(const s of Object.values(ve))this.filterState[s]!==e[s]&&this.sendMessage({type:"flows/updateFilter",payload:{name:s,expr:e[s]}});this.filterState=e}}fetchData(e){const s=[];return this.activeFetches[e]=s,ne(`./${e}`).then(i=>i.json()).then(i=>{this.activeFetches[e]===s&&this.receive(e,i)})}onMessage(e){switch(e.type){case"flows/add":return this.queueOrDispatch("flows",Mi(e.payload));case"flows/update":return this.queueOrDispatch("flows",qi(e.payload));case"flows/filterUpdate":return this.queueOrDispatch("flows",Vi(e.payload));case"flows/remove":return this.queueOrDispatch("flows",Hi(e.payload));case"events/add":return this.queueOrDispatch("events",Ss(e.payload));case"options/update":return this.queueOrDispatch("options",$s(e.payload));case"state/update":return this.queueOrDispatch("state",Be(e.payload));case"flows/reset":return this.fetchData("flows");case"events/reset":return this.fetchData("events");default:Ct(e.type)}}sendMessage(e){this.socket.readyState===WebSocket.OPEN?this.socket.send(JSON.stringify(e)):this.socket.readyState===WebSocket.CONNECTING?this.messageQueue.push(e):console.error("WebSocket is not open. Cannot send:",e)}queueOrDispatch(e,s){const i=this.activeFetches[e];i!==void 0?i.push(s):this.store.dispatch(s)}receive(e,s){switch(e){case"state":this.store.dispatch(Ue(s));break;case"options":this.store.dispatch(Yt(s));break;case"events":this.store.dispatch(Ki(s));break;case"flows":this.store.dispatch(bs(s));break;default:Ct(e)}const i=this.activeFetches[e];delete this.activeFetches[e],i.forEach(r=>this.store.dispatch(r))}onClose(e){this.store.dispatch(kc(`Connection closed at ${new Date().toUTCString()} with error code ${e.code}.`)),console.error("websocket connection closed",e)}onError(...e){console.error("websocket connection errored",e)}}class Mf{store;constructor(e){this.store=e,this.onOpen()}onOpen(){this.fetchData(lt.Flows),this.fetchData(lt.Options)}fetchData(e){ne(`./${e}`).then(s=>s.json()).then(s=>{this.receive(e,s)})}receive(e,s){switch(e){case lt.Flows:this.store.dispatch(bs(s));break;case lt.Options:this.store.dispatch(Yt(s));break;case lt.State:throw"unreachable";case lt.Events:throw"unreachable";default:Ct(e)}}}window.MITMWEB_STATIC?window.backend=new Mf(Nt):window.backend=new Of(Nt);Pf(Nt);window.addEventListener("error",t=>{Nt.dispatch(hc(`${t.message}
10${t.error.stack}`))});document.addEventListener("DOMContentLoaded",()=>{const t=document.getElementById("mitmproxy");Pl.createRoot(t).render(o.jsx(Ol,{store:Nt,children:o.jsx(Ff,{})}))});

Callers

nothing calls this directly

Calls 1

bindMethod · 0.80

Tested by

no test coverage detected