(this["webpackJsonpmitmproxy-client"]=this["webpackJsonpmitmproxy-client"]||[]).push([[0],{59:function(e,t,s){},65:function(e,t,s){"use strict";s.r(t);var n=s(1),i=s.n(n),r=s(20),o=s.n(r),a=(s(58),s(7)),c=s(8),l=s(15),h=s(14),d=s(52),u=s(10),p=s(13),j=(s(59),s(2)),v=s(22),b=s(16),y=s(43),f=s(30),w=s(0),O=function(e){Object(l.a)(s,e);var t=Object(h.a)(s);function s(e){var n;return Object(a.a)(this,s),(n=t.call(this,e)).state={show:!1,rule:{method:"ALL",url:"",action:1},haveRules:!1},n.handleClose=n.handleClose.bind(Object(v.a)(n)),n.handleShow=n.handleShow.bind(Object(v.a)(n)),n.handleSave=n.handleSave.bind(Object(v.a)(n)),n}return Object(c.a)(s,[{key:"handleClose",value:function(){this.setState({show:!1})}},{key:"handleShow",value:function(){this.setState({show:!0})}},{key:"handleSave",value:function(){var e=this.state.rule,t=[];e.url&&t.push({method:"ALL"===e.method?"":e.method,url:e.url,action:e.action}),this.props.onSave(t),this.handleClose(),this.setState({haveRules:!!t.length})}},{key:"render",value:function(){var e=this,t=this.state,s=t.rule,n=t.haveRules?"success":"primary";return Object(w.jsxs)("div",{children:[Object(w.jsx)(p.a,{variant:n,size:"sm",onClick:this.handleShow,children:"BreakPoint"}),Object(w.jsxs)(b.a,{show:this.state.show,onHide:this.handleClose,children:[Object(w.jsx)(b.a.Header,{closeButton:!0,children:Object(w.jsx)(b.a.Title,{children:"Set BreakPoint"})}),Object(w.jsxs)(b.a.Body,{children:[Object(w.jsxs)(u.a.Group,{as:y.a,children:[Object(w.jsx)(u.a.Label,{column:!0,sm:2,children:"Method"}),Object(w.jsx)(f.a,{sm:10,children:Object(w.jsxs)(u.a.Control,{as:"select",value:s.method,onChange:function(t){e.setState({rule:Object(j.a)(Object(j.a)({},s),{},{method:t.target.value})})},children:[Object(w.jsx)("option",{children:"ALL"}),Object(w.jsx)("option",{children:"GET"}),Object(w.jsx)("option",{children:"POST"}),Object(w.jsx)("option",{children:"PUT"}),Object(w.jsx)("option",{children:"DELETE"})]})})]}),Object(w.jsxs)(u.a.Group,{as:y.a,children:[Object(w.jsx)(u.a.Label,{column:!0,sm:2,children:"URL"}),Object(w.jsx)(f.a,{sm:10,children:Object(w.jsx)(u.a.Control,{value:s.url,onChange:function(t){e.setState({rule:Object(j.a)(Object(j.a)({},s),{},{url:t.target.value})})}})})]}),Object(w.jsxs)(u.a.Group,{as:y.a,children:[Object(w.jsx)(u.a.Label,{column:!0,sm:2,children:"Action"}),Object(w.jsx)(f.a,{sm:10,children:Object(w.jsxs)(u.a.Control,{as:"select",value:s.action,onChange:function(t){e.setState({rule:Object(j.a)(Object(j.a)({},s),{},{action:parseInt(t.target.value)})})},children:[Object(w.jsx)("option",{value:"1",children:"Request"}),Object(w.jsx)("option",{value:"2",children:"Response"}),Object(w.jsx)("option",{value:"3",children:"Both"})]})})]})]}),Object(w.jsxs)(b.a.Footer,{children:[Object(w.jsx)(p.a,{variant:"secondary",onClick:this.handleClose,children:"Close"}),Object(w.jsx)(p.a,{variant:"primary",onClick:this.handleSave,children:"Save"})]})]})]})}}]),s}(i.a.Component),x=function(e){return!!e&&(!!e.header&&(!!e.header["Content-Type"]&&/text|javascript|json|x-www-form-urlencoded|xml|form-data/.test(e.header["Content-Type"].join(""))))},m=function(e){return e?isNaN(e)||e<=0?"0":e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(2)," KB"):"".concat((e/1048576).toFixed(2)," MB"):"0"},R=function(e){for(var t="",s=new Uint8Array(e),n=s.byteLength,i=0;i=32&&s[r]<=126?i+=String.fromCharCode(s[r]):i+=".",(r+1)%16===0?(t+=" "+i,i="",t+="\n".concat((r+1).toString(16).padStart(8,"0"),": ")):(r+1)%8===0&&(t+=" ");if(i.length>0){for(var o=i.length;o<16;o++)t+=" ",(o+1)%8===0&&(t+=" ");t+=" "+i}return t};var g,E=function(e){Object(l.a)(s,e);var t=Object(h.a)(s);function s(){return Object(a.a)(this,s),t.apply(this,arguments)}return Object(c.a)(s,[{key:"shouldComponentUpdate",value:function(e){return e.isSelected!==this.props.isSelected||!function(e,t){if(e===t)return!0;var s=Object.keys(e),n=Object.keys(t);if(s.length!==n.length)return!1;for(var i=0;ithis.max){var t=this.items.shift();t&&this._map.delete(t.id)}}},{key:"get",value:function(e){return this._map.get(e)}},{key:"changeFilter",value:function(e){this.filterText=e}},{key:"changeFilterLazy",value:function(e,t){var s=this;this.filterTimer&&(clearTimeout(this.filterTimer),this.filterTimer=null),this.filterTimer=setTimeout((function(){s.filterText=e,t()}),300)}},{key:"clear",value:function(){this.items=[],this._map=new Map}}]),e}(),Y=[1,1,2,2,4,4,8,8,16,16,32,32],F=function(e){Object(l.a)(s,e);var t=Object(h.a)(s);function s(e){var n;return Object(a.a)(this,s),(n=t.call(this,e)).flowMgr=void 0,n.ws=void 0,n.wsUnmountClose=void 0,n.tableBottomRef=void 0,n.wsReconnCount=-1,n.flowMgr=new G,n.state={flows:n.flowMgr.showList(),flow:null,flowTab:"Headers",wsStatus:"close"},n.ws=null,n.wsUnmountClose=!1,n.tableBottomRef=i.a.createRef(),n}return Object(c.a)(s,[{key:"componentDidMount",value:function(){this.initWs()}},{key:"componentWillUnmount",value:function(){this.ws&&(this.wsUnmountClose=!0,this.ws.close(),this.ws=null)}},{key:"initWs",value:function(){var e,t=this;this.ws||(this.setState({wsStatus:"connecting"}),e=new URL(document.URL).host,this.ws=new WebSocket("ws://".concat(e,"/echo")),this.ws.binaryType="arraybuffer",this.ws.onopen=function(){t.wsReconnCount=-1,t.setState({wsStatus:"open"})},this.ws.onerror=function(e){var s;console.error("ERROR:",e),null===(s=t.ws)||void 0===s||s.close()},this.ws.onclose=function(){if(t.setState({wsStatus:"close"}),!t.wsUnmountClose){t.wsReconnCount++,t.ws=null;var e=Y[t.wsReconnCount]||Y[Y.length-1];console.info("will reconnect after ".concat(e," seconds")),setTimeout((function(){t.initWs()}),1e3*e)}},this.ws.onmessage=function(e){var s=function(e){if(e.byteLength<39)return null;var t=new Int8Array(e.slice(0,39));if(1!==t[0])return null;var s=t[1];if(!M.includes(s))return null;var n={type:s,id:(new TextDecoder).decode(e.slice(2,38)),waitIntercept:1===t[38]};if(39===e.byteLength)return n;if(s===g.REQUEST_BODY||s===g.RESPONSE_BODY)return n.content=e.slice(39),n;var i,r=(new TextDecoder).decode(e.slice(39));try{i=JSON.parse(r)}catch(o){return null}return n.content=i,n}(e.data);if(s){if(s.type===g.REQUEST){var n,i=new A(s);t.flowMgr.add(i);var r=!1;(null===(n=t.tableBottomRef)||void 0===n?void 0:n.current)&&function(e){var t=window.innerWidth||document.documentElement.clientWidth,s=window.innerHeight||document.documentElement.clientHeight,n=e.getBoundingClientRect(),i=n.top,r=n.right,o=n.bottom,a=n.left;return i>=0&&a>=0&&r<=t&&o<=s}(t.tableBottomRef.current)&&(r=!0),t.setState({flows:t.flowMgr.showList()},(function(){var e,s;r&&(null===(e=t.tableBottomRef)||void 0===e||null===(s=e.current)||void 0===s||s.scrollIntoView({behavior:"auto"}))}))}else if(s.type===g.REQUEST_BODY){var o=t.flowMgr.get(s.id);if(!o)return;o.addRequestBody(s),t.setState({flows:t.state.flows})}else if(s.type===g.RESPONSE){var a=t.flowMgr.get(s.id);if(!a)return;a.addResponse(s),t.setState({flows:t.state.flows})}else if(s.type===g.RESPONSE_BODY){var c=t.flowMgr.get(s.id);if(!c||!c.response)return;c.addResponseBody(s),t.setState({flows:t.state.flows})}}else console.error("parse error:",e.data)})}},{key:"render",value:function(){var e=this,t=this.state.flows;return Object(w.jsxs)("div",{className:"main-table-wrap",children:[Object(w.jsxs)("div",{className:"top-control",children:[Object(w.jsx)("div",{children:Object(w.jsx)(p.a,{size:"sm",onClick:function(){e.flowMgr.clear(),e.setState({flows:e.flowMgr.showList(),flow:null})},children:"Clear"})}),Object(w.jsx)("div",{children:Object(w.jsx)(u.a.Control,{size:"sm",placeholder:"Filter",onChange:function(t){var s=t.target.value;e.flowMgr.changeFilterLazy(s,(function(){e.setState({flows:e.flowMgr.showList()})}))}})}),Object(w.jsx)(O,{onSave:function(t){var s=function(e,t){if(e!==H.CHANGE_BREAK_POINT_RULES)throw new Error("invalid message type");var s=(new TextEncoder).encode(JSON.stringify(t)),n=new Uint8Array(2+s.byteLength);return n[0]=1,n[1]=e,n.set(s,2),n}(H.CHANGE_BREAK_POINT_RULES,t);e.ws&&e.ws.send(s)}}),Object(w.jsxs)("span",{children:["status: ",this.state.wsStatus]})]}),Object(w.jsxs)("div",{className:"table-wrap-div",children:[Object(w.jsxs)(d.a,{striped:!0,bordered:!0,size:"sm",style:{tableLayout:"fixed"},children:[Object(w.jsx)("thead",{children:Object(w.jsxs)("tr",{children:[Object(w.jsx)("th",{style:{width:"50px"},children:"No"}),Object(w.jsx)("th",{style:{width:"80px"},children:"Method"}),Object(w.jsx)("th",{style:{width:"200px"},children:"Host"}),Object(w.jsx)("th",{style:{width:"auto"},children:"Path"}),Object(w.jsx)("th",{style:{width:"150px"},children:"Type"}),Object(w.jsx)("th",{style:{width:"80px"},children:"Status"}),Object(w.jsx)("th",{style:{width:"90px"},children:"Size"}),Object(w.jsx)("th",{style:{width:"90px"},children:"Time"})]})}),Object(w.jsx)("tbody",{children:t.map((function(t){var s=t.preview();return Object(w.jsx)(E,{flow:s,isSelected:!(!e.state.flow||e.state.flow.id!==s.id),onShowDetail:function(){e.setState({flow:t})}},s.id)}))})]}),Object(w.jsx)("div",{ref:this.tableBottomRef,id:"hidden-bottom",style:{height:"0px",visibility:"hidden",marginBottom:"1px"}})]}),Object(w.jsx)(Q,{flow:this.state.flow,onClose:function(){e.setState({flow:null})},onReRenderFlows:function(){e.setState({flows:e.state.flows})},onMessage:function(t){e.ws&&e.ws.send(t)}})]})}}]),s}(i.a.Component),W=function(e){e&&e instanceof Function&&s.e(3).then(s.bind(null,67)).then((function(t){var s=t.getCLS,n=t.getFID,i=t.getFCP,r=t.getLCP,o=t.getTTFB;s(e),n(e),i(e),r(e),o(e)}))};o.a.render(Object(w.jsx)(i.a.StrictMode,{children:Object(w.jsx)(F,{})}),document.getElementById("root")),W()}},[[65,1,2]]]); //# sourceMappingURL=main.dab9e469.chunk.js.map