{"version":3,"sources":["../../web.ts"],"names":["translatedConnection","connection","window","navigator","mozConnection","webkitConnection","result","type","effectiveType","NetworkWeb","handleOnline","status","connected","connectionType","notifyListeners","handleOffline","addEventListener","this","unavailable","onLine","Network"],"mappings":"mQAgBA,SAASA,IACP,IAAMC,EACJC,OAAOC,UAAUF,YACjBC,OAAOC,UAAUC,eACjBF,OAAOC,UAAUE,iBACfC,EAAyB,UACvBC,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,CAEO,IAAMG,EAAW,kDACtB,mBAKG,OALH,qBACE,gBAyBMC,aAAe,WACrB,IAEMC,EAA2B,CAC/BC,WAAW,EACXC,eAJqBb,KAOvB,EAAKc,gBAAgB,sBAAuBH,EAC9C,EAEQ,EAAAI,cAAgB,WAMtB,EAAKD,gBAAgB,sBALY,CAC/BF,WAAW,EACXC,eAAgB,QAIpB,EA1CwB,qBAAXX,SACTA,OAAOc,iBAAiB,SAAU,EAAKN,cACvCR,OAAOc,iBAAiB,UAAW,EAAKD,gBACzC,CACH,CAkBC,OAlBA,uFAED,qGACOb,OAAOC,UAAW,CAAF,qBACbc,KAAKC,YACT,wDACD,OASF,OANKN,EAAYV,OAAOC,UAAUgB,OAC7BN,EAAiBb,IAEjBW,EAA2B,CAC/BC,YACAC,eAAgBD,EAAYC,EAAiB,QAC9C,kBAEMF,GAAM,gDACd,kDAlBA,MAkBA,EAzBqB,C,MAAQ,GAgD1BS,EAAU,IAAIX,C","file":"static/js/9.25ba4da2.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":""}