Loading
function(e,t,n){"use strict";n.d(t,{sL:()=>R,NP:()=>A,XQ:()=>g,Tn:()=>N,yA:()=>I,TC:()=>m,AV:()=>C,z8:()=>O});var i=n(17928),r=n(691540),s=n(857250),a=n(97483),o=n(228366),l=n(626584),u=n(952818),d=n(174459),c=n(723702),_=n(38405),h=n(19575),f=n(652215),E=n(375708);let p=new l.A("SystemServiceNativeUtils");function m(){return!!c.isPlatformEmbedded&&(h.Ay.IsSystemServiceInstalled()??!1)}function g(){return!!c.isPlatformEmbedded&&(h.Ay.CanSystemServiceBeInstalled()??!1)}function A(){let e=(0,i.bG)([u.Ay],()=>u.Ay.canShowAdminWarning),t=g();return!!c.isPlatformEmbedded&&e&&!m()&&t}function I(e){return!!c.isPlatformEmbedded&&e.canShowAdminWarning&&!m()&&!!c.isPlatformEmbedded&&!0===h.Ay.CanSystemServiceBeInstalled()}function T(e,t,n){u.Ay.getSystemServiceStatus(e).state!==t.state&&o.h.dispatch({type:"SYSTEM_SERVICE_INITIALIZE",status:t,modules:[e]}),"running"===t.state?(p.info(`${e} initialized.`),d.default.track(f.HAw.SYSTEM_SERVICE_INITIALIZE_ATTEMPTED,{success:!0,source:n,modules:[e]})):"failure"===t.state&&(p.info(`${e} failed to initialize.`,t),d.default.track(f.HAw.SYSTEM_SERVICE_INITIALIZE_ATTEMPTED,{success:!1,source:n,modules:[e]}))}function S(e){c.isPlatformEmbedded&&(h.Ay.InputEventServiceSetStatusCallback(t=>{T("input-service",t,e)}),h.Ay.InputEventServiceSetAllowed(!0),h.Ay.ToolServiceSetStatusCallback(t=>{T("tool-service",t,e)}),h.Ay.ToolServiceSetAllowed(!0))}async function N(e){if(c.isPlatformEmbedded&&m())try{await h.Ay.DoesSystemServiceHaveUpdate()&&await h.Ay.UpdateSystemService(),S(e)}catch(e){throw _.A.captureMessage("Error during system service initialization",{extra:{error:e}}),p.error("System service initialization failed",e),e}}async function C(){c.isPlatformEmbedded&&(h.Ay.InputEventServiceSetAllowed(!1),h.Ay.ToolServiceSetAllowed(!1),await o.h.dispatch({type:"SYSTEM_SERVICE_INITIALIZE",status:{state:"unknown"},modules:["input-service"]}),await o.h.dispatch({type:"SYSTEM_SERVICE_INITIALIZE",status:{state:"unknown"},modules:["tool-service"]}),p.info("System service terminated."))}function y(e){if(e instanceof Error)try{let t=JSON.parse(e.message);if(null==t.error_code||null==t.error_message)return;return t}catch(e){return}}function v(e,t){t&&(0,r.P0)(e)}async function R(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if(c.isPlatformEmbedded&&h.Ay.CanSystemServiceBeInstalled())try{await h.Ay.InstallSystemService(),p.info("System service installed."),d.default.track(f.HAw.SYSTEM_SERVICE_INSTALL_ATTEMPTED,{success:!0,source:e}),v((0,s.o)(E.intl.string(E.t.kQnWby),a.Ck.SUCCESS),t),S("after-install")}catch(i){let n=y(i);if(null==n&&i instanceof Error){v((0,s.o)(E.intl.formatToPlainString(E.t.sdKYCE,{error:i.message}),a.Ck.FAILURE),t),_.A.captureMessage("Unknown error during system service installation",{extra:{error:i}}),p.error("System service install failed.",i),d.default.track(f.HAw.SYSTEM_SERVICE_INSTALL_ATTEMPTED,{success:!1,source:e,error_message:i.message});return}if(null==n){v((0,s.o)(E.intl.formatToPlainString(E.t.sdKYCE,{error:i}),a.Ck.FAILURE),t),_.A.captureMessage("Really unknown error during system service installation",{extra:{error:i}}),p.error("System service install failed.",i),d.default.track(f.HAw.SYSTEM_SERVICE_INSTALL_ATTEMPTED,{success:!1,source:e,error_message:i?.toString()});return}if(d.default.track(f.HAw.SYSTEM_SERVICE_INSTALL_ATTEMPTED,{success:!1,source:e,error_code:n.error_code,error_message:n.error_message}),-0x7ff8fb39===n.error_code){v((0,s.o)(E.intl.string(E.t.xu9k8G),a.Ck.FAILURE),t),p.error("User cancelled system service install.");return}v((0,s.o)(E.intl.formatToPlainString(E.t.sdKYCE,{error:n.error_message}),a.Ck.FAILURE),t),0!==n.error_code&&_.A.captureMessage("Error during system service installation",{extra:{error:n}}),p.error("System service install failed.",n)}}async function O(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if(c.isPlatformEmbedded)try{await C(),await h.Ay.UninstallSystemService(),p.info("System service uninstalled."),v((0,s.o)(E.intl.string(E.t.dThS5H),a.Ck.SUCCESS),t),d.default.track(f.HAw.SYSTEM_SERVICE_UNINSTALL_ATTEMPTED,{success:!0,source:e})}catch(i){let n=y(i);if(null==n&&i instanceof Error){v((0,s.o)(E.intl.formatToPlainString(E.t.oHh3oI,{error:i.message}),a.Ck.FAILURE),t),_.A.captureMessage("Unknown error during system service uninstallation",{extra:{error:i}}),p.error("System service uninstall failed.",i),d.default.track(f.HAw.SYSTEM_SERVICE_UNINSTALL_ATTEMPTED,{success:!1,source:e,error_message:i.message});return}if(null==n){v((0,s.o)(E.intl.formatToPlainString(E.t.oHh3oI,{error:i}),a.Ck.FAILURE),t),_.A.captureMessage("Really unknown error during system service uninstallation",{extra:{error:i}}),p.error("System service uninstall failed.",i),d.default.track(f.HAw.SYSTEM_SERVICE_UNINSTALL_ATTEMPTED,{success:!1,source:e,error_message:i?.toString()});return}d.default.track(f.HAw.SYSTEM_SERVICE_UNINSTALL_ATTEMPTED,{success:!1,source:e,error_code:n.error_code,error_message:n.error_message}),v((0,s.o)(E.intl.formatToPlainString(E.t.oHh3oI,{error:n.error_message}),a.Ck.FAILURE),t),_.A.captureMessage("Error during system service uninstallation",{extra:{error:n}}),p.error("System service uninstall failed.",n)}}}