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