"use strict";var D=Object.create;var l=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var O=Object.getPrototypeOf;var C=Object.prototype.hasOwnProperty;var c=(t,s)=>l(t,"name",{value:s,configurable:true});var B=(t,s)=>{for(var e in s)l(t,e,{get:s[e],enumerable:true})};var I=(t,s,e,r)=>{if(s&&typeof s==="object"||typeof s==="function"){for(let o of $(s))if(!C.call(t,o)&&o!==e)l(t,o,{get:()=>s[o],enumerable:!(r=y(s,o))||r.enumerable})}return t};var d=(t,s,e)=>(e=t!=null?D(O(t)):{},I(s||!t||!t.__esModule?l(e,"default",{value:t,enumerable:true}):e,t));var W=t=>I(l({},"__esModule",{value:true}),t);var S=(t,s,e,r)=>{var o=r>1?void 0:r?y(s,e):s;for(var n=t.length-1,u;n>=0;n--)if(u=t[n])o=(r?u(s,e,o):u(o))||o;if(r&&o)l(s,e,o);return o};var x={};B(x,{default:()=>q});module.exports=W(x);var i=require("react/jsx-runtime");var m=require("mobx-react");var M=require("react");var g=require("react-intl");var v=d(require("react-jss"));var P=require("../../api/utils/auth");var w=d(require("../../components/ui/Modal"));var N=d(require("../../components/ui/button"));var T=require("../../components/ui/headline");var k=d(require("../../components/ui/input/index"));var f=require("../../config");var h=require("./store");const b=require("../../preload-safe-debug")("Ferdium:feature:publishDebugInfo");const a=(0,g.defineMessages)({title:{id:"feature.publishDebugInfo.title",defaultMessage:"Publish debug information"},info:{id:"feature.publishDebugInfo.info",defaultMessage:"Publishing your debug information helps us find issues and errors in Ferdium. By publishing your debug information you accept Ferdium Debugger's privacy policy and terms of service"},error:{id:"feature.publishDebugInfo.error",defaultMessage:"There was an error while trying to publish the debug information. Please try again later or view the console for more information."},privacy:{id:"feature.publishDebugInfo.privacy",defaultMessage:"Privacy policy"},terms:{id:"feature.publishDebugInfo.terms",defaultMessage:"Terms of service"},publish:{id:"feature.publishDebugInfo.publish",defaultMessage:"Accept and publish"},published:{id:"feature.publishDebugInfo.published",defaultMessage:"Your debug log was published and is now available at"}});const j=c(t=>({modal:{width:"80%",maxWidth:600,background:t.styleTypes.primary.contrast,paddingTop:30},headline:{fontSize:20,marginBottom:20,marginTop:-27},info:{paddingBottom:20},link:{color:`${t.styleTypes.primary.accent} !important`,padding:10,cursor:"pointer"},button:{width:"100%",marginTop:10,cursor:"pointer"}}),"styles");let p=class extends M.Component{constructor(s){super(s);this.state={log:null,error:false,isSendingLogs:false}}close(){h.state.isModalVisible=false;this.setState({log:null,error:false,isSendingLogs:false})}async publishDebugInfo(){b("debugInfo: starting publish");this.setState({isSendingLogs:true});const s=JSON.stringify(this.props.stores?.app?.debugInfo);const e=await(0,P.sendAuthRequest)(`${f.DEBUG_API}/create`,{method:"POST",body:JSON.stringify({log:s})},false);b(`debugInfo: publishing status: ${e.status}`);if(e.status===200){const r=await e.json();if(r.id){this.setState({log:r.id})}else{this.setState({error:true})}}else{this.setState({error:true})}b("debugInfo: finished publishing")}render(){const{isModalVisible:s}=h.state;const{classes:e,intl:r}=this.props;const{log:o,error:n,isSendingLogs:u}=this.state;return(0,i.jsxs)(w.default,{isOpen:s,shouldCloseOnOverlayClick:true,className:`${e.modal} publish-debug`,close:()=>this.close(),children:[(0,i.jsx)(T.H1,{className:e.headline,children:r.formatMessage(a.title)}),o&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("p",{className:e.info,children:r.formatMessage(a.published)}),(0,i.jsx)(k.default,{showLabel:false,value:`${f.DEBUG_API}/${o}`,readOnly:true})]}),n&&(0,i.jsx)("p",{className:e.info,children:r.formatMessage(a.error)}),!o&&!n&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("p",{className:e.info,children:r.formatMessage(a.info)}),(0,i.jsx)("a",{href:`${f.DEBUG_API}/privacy.html`,target:"_blank",className:e.link,rel:"noreferrer",children:r.formatMessage(a.privacy)}),(0,i.jsx)("a",{href:`${f.DEBUG_API}/terms.html`,target:"_blank",className:e.link,rel:"noreferrer",children:r.formatMessage(a.terms)}),(0,i.jsx)(N.default,{type:"button",label:r.formatMessage(a.publish),className:e.button,onClick:()=>this.publishDebugInfo(),disabled:u})]})]})}};c(p,"PublishDebugLogModal");p=S([(0,m.inject)("stores","actions"),m.observer],p);var q=(0,g.injectIntl)((0,v.default)(j,{injectTheme:true})(p));
