"use strict";var k=Object.create;var n=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var j=Object.getPrototypeOf;var F=Object.prototype.hasOwnProperty;var g=(t,r)=>n(t,"name",{value:r,configurable:true});var X=(t,r)=>{for(var e in r)n(t,e,{get:r[e],enumerable:true})};var h=(t,r,e,o)=>{if(r&&typeof r==="object"||typeof r==="function"){for(let s of L(r))if(!F.call(t,s)&&s!==e)n(t,s,{get:()=>r[s],enumerable:!(o=u(r,s))||o.enumerable})}return t};var a=(t,r,e)=>(e=t!=null?k(j(t)):{},h(r||!t||!t.__esModule?n(e,"default",{value:t,enumerable:true}):e,t));var z=t=>h(n({},"__esModule",{value:true}),t);var S=(t,r,e,o)=>{var s=o>1?void 0:o?u(r,e):r;for(var l=t.length-1,p;l>=0;l--)if(p=t[l])s=(o?p(r,e,s):p(s))||s;if(o&&s)n(r,e,s);return s};var q={};X(q,{default:()=>J});module.exports=z(q);var i=require("react/jsx-runtime");var w=a(require("classnames"));var E=require("mobx");var m=require("mobx-react");var R=require("react");var d=require("react-intl");var M=a(require("react-topbar-progress-indicator"));var I=require("../../../config");var P=a(require("../../../features/webControls/containers/WebControlsScreen"));var C=a(require("../../MediaSource"));var B=a(require("../../ui/StatusBarTargetUrl"));var D=a(require("../../ui/WebviewLoader"));var O=a(require("./ServiceDisabled"));var y=a(require("./ServiceWebview"));var W=a(require("./WebviewCrashHandler"));var N=a(require("./WebviewErrorHandler"));const T=(0,d.defineMessages)({hibernatingMessage:{id:"service.hibernating.message",defaultMessage:"This service is currently hibernating."},hibernatingAction:{id:"service.hibernating.action",defaultMessage:"Try switching services or reloading Ferdium."}});let c=class extends R.Component{autorunDisposer;forceRepaintTimeout;constructor(r){super(r);this.state={forceRepaint:false,targetUrl:"",statusBarVisible:false}}componentDidMount(){this.autorunDisposer=(0,E.autorun)(()=>{if(this.props.service.isActive){this.setState({forceRepaint:true});this.forceRepaintTimeout=setTimeout(()=>{this.setState({forceRepaint:false})},100)}})}componentWillUnmount(){this.autorunDisposer();clearTimeout(this.forceRepaintTimeout)}render(){const{detachService:r,service:e,setWebviewRef:o,reload:s,edit:l,enable:p,stores:v,isSpellcheckerEnabled:A,intl:b}=this.props;const{navigationBarBehaviour:f,navigationBarManualActive:_}=v.settings.app;const x=f==="always"||f==="custom"&&e.recipe.id===I.CUSTOM_WEBSITE_RECIPE_ID||_;const H=(0,w.default)({services__webview:true,"services__webview-wrapper":true,"is-active":e.isActive,"services__webview--force-repaint":this.state.forceRepaint});const U=this.state.statusBarVisible?(0,i.jsx)(B.default,{text:this.state.targetUrl}):null;return(0,i.jsxs)("div",{className:H,"data-name":e.name,style:{order:e.order},children:[e.isActive&&e.isEnabled&&(0,i.jsxs)(i.Fragment,{children:[e.hasCrashed&&(0,i.jsx)(W.default,{name:e.recipe.name,reload:s}),e.isEnabled&&e.isLoading&&e.isFirstLoad&&!e.isHibernating&&!e.isServiceAccessRestricted&&(0,i.jsx)(D.default,{loaded:false,name:e.name}),e.isProgressbarEnabled&&e.isLoadingPage&&!e.isFirstLoad&&(0,i.jsx)(M.default,{}),e.isError&&(0,i.jsx)(N.default,{name:e.recipe.name,errorMessage:e.errorMessage,reload:s,edit:l})]}),e.isEnabled?(0,i.jsx)(i.Fragment,{children:e.isHibernating?(0,i.jsxs)("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",textAlign:"center"},children:[(0,i.jsx)("span",{role:"img","aria-label":"Sleeping Emoji",style:{fontSize:42},children:"\u{1F634}"}),(0,i.jsx)("br",{}),(0,i.jsx)("br",{}),b.formatMessage(T.hibernatingMessage),(0,i.jsx)("br",{}),b.formatMessage(T.hibernatingAction)]}):(0,i.jsxs)(i.Fragment,{children:[x&&(0,i.jsx)(P.default,{service:e}),(0,i.jsx)(C.default,{service:e}),(0,i.jsx)(y.default,{service:e,setWebviewReference:o,detachService:r,isSpellcheckerEnabled:A,stores:v})]})}):(0,i.jsx)(i.Fragment,{children:e.isActive&&(0,i.jsx)(O.default,{name:e.name===""?e.recipe.name:e.name,enable:p})}),U]})}};g(c,"ServiceView");c=S([(0,m.inject)("stores","actions"),m.observer],c);var J=(0,d.injectIntl)(c);
