import{c as v}from"./chunk-J36J6JDY.js";import{a as E,e as T,f as p}from"./chunk-DR3P2OYP.js";import{B as g,H as O,Kb as u,Lb as I,sc as _,x as D}from"./chunk-IA4I4FFG.js";import{k as A}from"./chunk-24IZEI4V.js";var x=v("AppUpdate",{web:()=>import("./chunk-5I5A3CV7.js").then(n=>new n.AppUpdateWeb)});var o=[];for(let n=0;n<256;++n)o.push((n+256).toString(16).slice(1));function l(n,e=0){return(o[n[e+0]]+o[n[e+1]]+o[n[e+2]]+o[n[e+3]]+"-"+o[n[e+4]]+o[n[e+5]]+"-"+o[n[e+6]]+o[n[e+7]]+"-"+o[n[e+8]]+o[n[e+9]]+"-"+o[n[e+10]]+o[n[e+11]]+o[n[e+12]]+o[n[e+13]]+o[n[e+14]]+o[n[e+15]]).toLowerCase()}var L,y=new Uint8Array(16);function d(){if(!L){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");L=crypto.getRandomValues.bind(crypto)}return L(y)}var h={};function w(n,e,r){let s,c=n?._v6??!1;if(n){let t=Object.keys(n);t.length===1&&t[0]==="_v6"&&(n=void 0)}if(n)s=P(n.random??n.rng?.()??d(),n.msecs,n.nsecs,n.clockseq,n.node,e,r);else{let t=Date.now(),i=d();V(h,t,i),s=P(i,h.msecs,h.nsecs,c?void 0:h.clockseq,c?void 0:h.node,e,r)}return e??l(s)}function V(n,e,r){return n.msecs??=-1/0,n.nsecs??=0,e===n.msecs?(n.nsecs++,n.nsecs>=1e4&&(n.node=void 0,n.nsecs=0)):e>n.msecs?n.nsecs=0:e<n.msecs&&(n.node=void 0),n.node||(n.node=r.slice(10,16),n.node[0]|=1,n.clockseq=(r[8]<<8|r[9])&16383),n.msecs=e,n}function P(n,e,r,s,c,t,i=0){if(n.length<16)throw new Error("Random bytes length must be >= 16");if(!t)t=new Uint8Array(16),i=0;else if(i<0||i+16>t.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);e??=Date.now(),r??=0,s??=(n[8]<<8|n[9])&16383,c??=n.slice(10,16),e+=122192928e5;let f=((e&268435455)*1e4+r)%4294967296;t[i++]=f>>>24&255,t[i++]=f>>>16&255,t[i++]=f>>>8&255,t[i++]=f&255;let m=e/4294967296*1e4&268435455;t[i++]=m>>>8&255,t[i++]=m&255,t[i++]=m>>>24&15|16,t[i++]=m>>>16&255,t[i++]=s>>>8|128,t[i++]=s&255;for(let N=0;N<6;++N)t[i++]=c[N];return t}var a=w;var S=class n{constructor(){this.loading=g(_);this.injector=g(O);this.platform=g(u);this.electron=g(T);this.version=""}initapp(){return A(this,null,function*(){let e=yield this.loading.create({message:"Iniciando aplicaci\xF3n..."});if(e.present(),this.settings=this.injector.get(p),this.settings.clientId=a(),E.clientId=this.settings.clientId,yield this.settings.load()){this.platform.is("electron")&&(console.log("is Electron app"),this.initElectronApp()),(yield this.platform.ready())==="capacitor"&&this.platform.is("android")&&(console.log("is Capacitor over Android platform"),yield this.checkForUpdatesAndroid());let r=this.injector.get(I);this.settings.currentSettings[this.settings.MANDATORY_SELECTING_CHEF]&&this.settings.currentSettings[this.settings.COD_TIPO_PANTALLA]!==this.settings.TIPO_PANTALLA_SECOND_MONITOR&&this.settings.currentSettings[this.settings.COD_TIPO_PANTALLA]!==this.settings.TIPO_PANTALLA_SEATING?r.navigateRoot("chef-selection"):r.navigateRoot("home")}else yield this.settings.setValue(this.settings.PASSWORD,"2001");E.clientId=this.settings.clientId,e.dismiss()})}initElectronApp(){if(this.platform.is("electron")&&(this.settings.currentSettings[this.settings.DEBUG_MODE]&&this.electron.ipcRenderer.send(this.electron.channels.showDevTools),this.settings.currentSettings[this.settings.COD_TIPO_PANTALLA]===this.settings.TIPO_PANTALLA_SECOND_MONITOR&&this.electron.ipcRenderer.send(this.electron.channels.openInSecondMonitor),this.settings.currentSettings[this.settings.API_SERVER_URL]!=="")){let e=this.settings.currentSettings[this.settings.API_SERVER_URL];e.substr(e.length-1)!=="/"&&(e=e+"/"),this.electron.ipcRenderer.send(this.electron.channels.checkForUpdates,`${e}api/updates/KitchenControl/`),this.electron.ipcRenderer.on(this.electron.channels.updater,(r,s)=>{s==="update-available"&&this.electron.ipcRenderer.send(this.electron.channels.quitAndInstallUpdate)})}}checkForUpdatesAndroid(){return A(this,null,function*(){let{currentVersionCode:e}=yield x.getAppUpdateInfo(),r=this.settings.currentSettings[this.settings.API_SERVER_URL]+"/api/updates/KitchenControl/android/android.xml?localVersion="+e+"&arch=android";console.log(r)})}static{this.\u0275fac=function(r){return new(r||n)}}static{this.\u0275prov=D({token:n,factory:n.\u0275fac,providedIn:"root"})}};export{S as a};
