{"version":3,"sources":["../../../src/web.ts"],"names":["translatedConnection","connection","window","navigator","mozConnection","webkitConnection","result","type","effectiveType","NetworkWeb","constructor","super","handleOnline","status","connected","connectionType","this","notifyListeners","handleOffline","addEventListener","getStatus","unavailable","onLine","Network"],"mappings":"uGAAA,sGAgBA,SAASA,IACP,MAAMC,EACJC,OAAOC,UAAUF,YACjBC,OAAOC,UAAUC,eACjBF,OAAOC,UAAUE,iBACnB,IAAIC,EAAyB,UAC7B,MAAMC,EAAON,EAAaA,EAAWM,MAAQN,EAAWO,cAAgB,KACxE,GAAID,GAAwB,kBAATA,EACjB,OAAQA,GAEN,IAAK,YACL,IAAK,WAgBL,IAAK,UACL,IAAK,KACL,IAAK,KACHD,EAAS,WACT,MAjBF,IAAK,OACHA,EAAS,OACT,MACF,IAAK,WACL,IAAK,OACL,IAAK,QAaL,IAAK,KACHA,EAAS,OACT,MAZF,IAAK,QACL,IAAK,UACHA,EAAS,UAef,OAAOA,CACT,CAEM,MAAOG,UAAmB,IAC9B,WAAAC,GACEC,QAyBM,KAAAC,aAAe,KACrB,MAEMC,EAA2B,CAC/BC,WAAW,EACXC,eAJqBf,KAOvBgB,KAAKC,gBAAgB,sBAAuBJ,EAAO,EAG7C,KAAAK,cAAgB,KAMtBF,KAAKC,gBAAgB,sBALY,CAC/BH,WAAW,EACXC,eAAgB,QAGiC,EAzC7B,qBAAXb,SACTA,OAAOiB,iBAAiB,SAAUH,KAAKJ,cACvCV,OAAOiB,iBAAiB,UAAWH,KAAKE,eAE5C,CAEA,eAAME,GACJ,IAAKlB,OAAOC,UACV,MAAMa,KAAKK,YACT,wDAIJ,MAAMP,EAAYZ,OAAOC,UAAUmB,OAC7BP,EAAiBf,IAOvB,MALiC,CAC/Bc,YACAC,eAAgBD,EAAYC,EAAiB,OAIjD,EAuBF,MAAMQ,EAAU,IAAId,C","file":"static/js/40.1c13f822.chunk.js","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n ConnectionStatus,\n ConnectionType,\n NetworkPlugin,\n} from './definitions';\n\ndeclare global {\n interface Navigator {\n connection: any;\n mozConnection: any;\n webkitConnection: any;\n }\n}\n\nfunction translatedConnection(): ConnectionType {\n const connection =\n window.navigator.connection ||\n window.navigator.mozConnection ||\n window.navigator.webkitConnection;\n let result: ConnectionType = 'unknown';\n const type = connection ? connection.type || connection.effectiveType : null;\n if (type && typeof type === 'string') {\n switch (type) {\n // possible type values\n case 'bluetooth':\n case 'cellular':\n result = 'cellular';\n break;\n case 'none':\n result = 'none';\n break;\n case 'ethernet':\n case 'wifi':\n case 'wimax':\n result = 'wifi';\n break;\n case 'other':\n case 'unknown':\n result = 'unknown';\n break;\n // possible effectiveType values\n case 'slow-2g':\n case '2g':\n case '3g':\n result = 'cellular';\n break;\n case '4g':\n result = 'wifi';\n break;\n default:\n break;\n }\n }\n return result;\n}\n\nexport class NetworkWeb extends WebPlugin implements NetworkPlugin {\n constructor() {\n super();\n if (typeof window !== 'undefined') {\n window.addEventListener('online', this.handleOnline);\n window.addEventListener('offline', this.handleOffline);\n }\n }\n\n async getStatus(): Promise {\n if (!window.navigator) {\n throw this.unavailable(\n 'Browser does not support the Network Information API',\n );\n }\n\n const connected = window.navigator.onLine;\n const connectionType = translatedConnection();\n\n const status: ConnectionStatus = {\n connected,\n connectionType: connected ? connectionType : 'none',\n };\n\n return status;\n }\n\n private handleOnline = () => {\n const connectionType = translatedConnection();\n\n const status: ConnectionStatus = {\n connected: true,\n connectionType: connectionType,\n };\n\n this.notifyListeners('networkStatusChange', status);\n };\n\n private handleOffline = () => {\n const status: ConnectionStatus = {\n connected: false,\n connectionType: 'none',\n };\n\n this.notifyListeners('networkStatusChange', status);\n };\n}\n\nconst Network = new NetworkWeb();\n\nexport { Network };\n"],"sourceRoot":""}