functionqa(t=globalThis.window){returnt?.SECUREBIT_DEBUG===!0}functionjs({targetWindow:t=globalThis.window,webrtcManagerRef:e,onClearData:n,clearConsole:r=()=>{typeofconsole.clear=="function"&&console.clear()}}){returnqa(t)?(t.forceCleanup=()=>{n(),e.current&&e.current.disconnect()},t.clearLogs=r,t.webrtcManagerRef=e,()=>{deletet.forceCleanup,deletet.clearLogs,deletet.webrtcManagerRef}):()=>{}}varYa="securebit-net";vares="ice-device-key",ns="ice-settings";functionrs(){returntypeofindexedDB<"u"&&typeofcrypto<"u"&&!!crypto.subtle}functionss(){returnnewPromise((t,e)=>{letn;try{n=indexedDB.open(Ya,1)}catch(r){e(r);return}n.onupgradeneeded=()=>{letr=n.result;r.objectStoreNames.contains("kv")||r.createObjectStore("kv")},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)})}functionts(t,e){returnnewPromise((n,r)=>{letc=t.transaction("kv","readonly").objectStore("kv").get(e);c.onsuccess=()=>n(c.result),c.onerror=()=>r(c.error)})}function$s(t,e,n){returnnewPromise((r,i)=>{letc=t.transaction("kv","readwrite");c.objectStore("kv").put(n,e),c.oncomplete=()=>r(),c.onerror=()=>i(c.error)})}functionKa(t,e){returnnewPromise((n,r)=>{leti=t.transaction("kv","readwrite");i.objectStore("kv").delete(e),i.oncomplete=()=>n(),i.onerror=()=>r(i.error)})}asyncfunctionQa(t){lete=awaitts(t,es);if(einstanceofCryptoKey)returne;letn=awaitcrypto.subtle.generateKey({name:"AES-GCM",length:256},!1,["encrypt","decrypt"]);returnawait$s(t,es,n),n}asyncfunctionqs(t){if(!rs())thrownewError("Persistent storage is not available in this browser");lete=awaitss(),n=awaitQa(e),r=JSON.stringify({version:1,servers:Array.isArray(t?.servers)?t.servers:[],privacyMode:t?.privacyMode==="relay-only"?"relay-only":"standard"}),i=crypto.getRandomValues(newUint8Array(12)),c=awaitcrypto.subtle.encrypt({name:"AES-GCM",iv:i},n,newTextEncoder().encode(r));await$s(e,ns,{iv:Array.from(i),data:Array.from(newUint8Array(c))})}asyncfunctionYs(){if(!rs())returnnull;try{lett=awaitss(),e=awaitts(t,ns);if(!e||!Array.isArray(e.iv)||!Array.isArray(e.data))returnnull;letn=awaitts(t,es);if(!(ninstanceofCryptoKey))returnnull;letr=awaitcrypto.subtle.decrypt({name:"AES-GCM",iv:newUint8Array(e.iv)},n,newUint8Array(e.data)),i=JSON.parse(newTextDecoder().decode(r));return{servers:Array.isArray(i.servers)?i.servers:[],privacyMode:i.privacyMode==="relay-only"?"relay-only":"standard"}}catch{returnnull}}asyncfunctionis(){if(rs())try{lett=awaitss();awaitKa(t,ns)}catch{}}varXa="/api/turn-credentials",Xs=["turn.securebit.chat","144.172.96.126"];varKs=[6e4,3e5,9e5];functionJs(t){lete=/^turns?:([^:?\s]+)/i.exec(String(t||"").trim());returne?e[1].toLowerCase():null}functionJa(t){return!t||typeoft!="object"?!1:(Array.isArray(t.urls)?t.urls:[t.urls]).some(n=>Xs.includes(Js(n)))}functioner(t){if(typeoft!="string"||t.length===0||t.length>512)return!1;for(lete=0;e<t.length;e++){letn=t.charCodeAt(e);if(n<32||n===127)return!1}return!0}functionZa(t,e){if(!Array.isArray(t)||!e||!er(e.username)||!er(e.credential))return!1;letn=!1;for(letroft)Ja(r)&&(r.username=e.username,r.credential=e.credential,n=!0);if(!n&&Array.isArray(e.urls)){letr=e.urls.filter(i=>er(i)&&Xs.includes(Js(i)));r.length>0&&(t.push({urls:r,username:e.username,credential:e.credential}),n=!0)}returnn}functioneo(t,e){letn=t&&Array.isArray(t.iceServers)?t.iceServers[0]:null;if(!n||!er(n.username)||!er(n.credential))returnnull;letr=Number(String(n.username).split(":")[0]);if(!Number.isFinite(r)||r<=e)returnnull;leti=Number(t.ttl);return{urls:Array.isArray(n.urls)?n.urls.slice(0,8):[],username:n.username,credential:n.credential,expiry:r,ttl:Number.isFinite(i)&&i>0?i:r-e}}varQs=!1;functionZs(t={}){if(Qs||typeofwindow>"u"||typeoffetch!="function")return;Qs=!0;lete=t.getList||(()=>window.SECUREBIT_ICE_SERVERS),n=0,r=0,i=null,c=0,d=m=>{i&&clearTimeout(i),i=setTimeout(h,m)};asyncfunctionh(){i=null;try{letm=awaitfetch(Xa,{method:"POST",cache:"no-store",credentials:"omit"});if(!m.ok)thrownewError(`HTTP ${m.status}`);letv=eo(awaitm.json(),Date.now()/1e3)
Pleasewaitforreal-timecryptographicverificationtocomplete.`,"sec.verificationUnavailable":"Security verification not available","chat.placeholder":"Type an encrypted message\u2026","chat.send":"Send message","chat.sendFiles":"Send files","chat.hideFiles":"Hide files","chat.recordVoice":"Record voice message","chat.sendVoice":"Send voice message","chat.discard":"Discard","chat.codeBlock":"Send as a code block (expands the input)","chat.codeHint":"Code snippet \xB7 formatting preserved \xB7 \u2318\u21B5 to send","chat.viewOnce":"View once","chat.viewOnceTitle":"View once - vanishes after the peer reads it","chat.viewOncePrefix":"View once \xB7 ","chat.viewOnceTap":"View once \xB7 tap to reveal","chat.viewedOnce":"Viewed once","chat.disappearing":"Disappearing message - deletes on both sides","chat.disappearAfter":"Disappear after","chat.visibleFor":"Visible for","chat.timerPrefix":"Timer \xB7 ","chat.expired":"This message has expired","chat.deleteForEveryone":"Delete for everyone","chat.sending":"Sending","chat.delivered":"Delivered","chat.notSent":"Not sent","chat.notSentReason":"Not sent - the secure channel is not ready. Reconnect to continue.","chat.encrypted":"Encrypted","chat.decrypted":"Decrypted","chat.encryptedOnDevice":"Encrypted on your device","chat.uploading":"Uploading","chat.downloading":"Downloading","chat.transferring":"Transferring\u2026","chat.copied":"Copied!","chat.collapse":"Collapse","chat.closeMenu":"Close menu","chat.newChat":"New chat","chat.newGroup":"New group","chat.createGroup":"Create a group","chat.groupChats":"Group chats","chat.secureChat":"Secure chat","chat.nameThis":"Name this chat","chat.rename":"Rename chat (local only)","chat.renameHint":"Double-click to rename","chat.localLabel":"Local label \xB7 stored only on this device","chat.setStatus":"Set your status","chat.yourStatusPrefix":"Your status - ","chat.meshHint":"Up to 8 peers \xB7 P2P mesh","chat.offline":"Offline","chat.noNetwork":"No network \xB7 reconnecting","chat.startVoiceCall":"Start encrypted voice call","chat.startVideoCall":"Start encrypted video call","chat.verifyForCalls":"Verify the session to enable calls","chat.e2eeNote":"Every message is end-to-end encrypted on your device before it leaves.","chat.peersOnly":"Sent end-to-end to connected peers only - never stored on a server.","flow.invitationCreated":"Secure invitation created","flow.invitationCreatedBang":"Secure invitation created and encrypted!","flow.responseCreated":"Secure response created","flow.responseCreatedBang":"Secure response created!","flow.sendInvitation":"Send the invitation code to your interlocutor via a secure channel (voice call, SMS, etc.).","flow.sendResponse":"Send the response code to the initiator via a secure channel or let them scan the QR code below.","flow.sendEncryptedCode":"Send the encrypted code","flow.sendTheResponse":"Send the response","flow.pasteOrWrite":"Paste or write code\u2026","flow.processingInvitation":"Processing the secure invitation...","flow.processingResponse":"Processing the secure response...","flow.finalizing":"Finalizing the secure connection...","flow.channelEstablished":"Secure channel established","flow.channelReady":"Secure channel is ready","flow.restoring":"Restoring connection\u2026","flow.invitationCaptured":"Invitation captured.","err.needInvitation":"You need to insert the invitation code from your interlocutor.","err.needResponse":"You need to insert the response code from your interlocutor.","err.responseFormat":"Invalid response format - please check the code","err.responseNoKey":"Invalid response code - missing or corrupted cryptographic key. Please check the code and try again.","err.responseNoSignKey":"Invalid response code - missing signature verification key. Please check the code and try again.","err.responseOutdated":"Response data is outdated - please use a fresh invitation","err.setupError":"Connection setup error","err.notReady":"Connection not ready","err.securityBreach":"Security breach detected - connection rejected","err.securityValidation":"Security validation failed - poss
`),n.style.transform="translate3d(0,"+(t?Math.round(t.offsetTop):0)+"px,0)"};i();letc=setInterval(i,200);return()=>{clearInterval(c),n.remove()}}vartc=t=>()=>{if(t&&t.current){lete=()=>{t.current&&t.current.scrollTo({top:t.current.scrollHeight,behavior:Or()})};e(),setTimeout(e,50),setTimeout(e,150),setTimeout(e,300),requestAnimationFrame(()=>{setTimeout(e,100)})}},ia=asynct=>{lete=null;try{t&&window.EnhancedSecureCryptoUtils&&(e=awaitwindow.EnhancedSecureCryptoUtils.calculateSecurityLevel(t))}catch{}if(!e){alert(`Security verification in progress\u2026