openrtc 2.0.0-rc.2 → 2.0.0-rc.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +11 -1
  2. package/dist/DelegatingRuntimeAdapter-7Y3gss5D.d.ts +134 -0
  3. package/dist/OpenRTCShared-LDKG5RPN.js +1 -0
  4. package/dist/WasmBridge-T5XMT6FH.js +1 -0
  5. package/dist/chunk-5OHYIHPT.js +1 -0
  6. package/dist/chunk-DA3HSI3K.js +2 -0
  7. package/dist/chunk-FAPRYEWI.js +2 -0
  8. package/dist/chunk-HTAWPIP2.js +2 -0
  9. package/dist/chunk-PPZRTJHE.js +3 -0
  10. package/dist/chunk-PQK5SJ47.js +1 -0
  11. package/dist/{chunk-RD3JEGGF.js → chunk-QHSM5NFZ.js} +2 -2
  12. package/dist/{chunk-7Z6N46RB.js → chunk-RRMBD5OL.js} +1 -1
  13. package/dist/{chunk-A3IAG6EL.js → chunk-WWC767HK.js} +1 -1
  14. package/dist/chunk-Z2WVSXPW.js +1 -0
  15. package/dist/deviceManagement-PHY5TIOS.js +1 -0
  16. package/dist/deviceProfile-3BEQZLJF.js +2 -0
  17. package/dist/deviceRoster-GHF6MWXF.js +1 -0
  18. package/dist/dist-FIVA6EPA.js +277 -0
  19. package/dist/factories-SMMQHXUH.js +1 -0
  20. package/dist/index.d.ts +4 -6
  21. package/dist/index.js +1 -1
  22. package/dist/ipcFactory-AR3VIBM4.js +1 -0
  23. package/dist/native.d.ts +4 -7
  24. package/dist/native.js +1 -1
  25. package/dist/openrtc-3YHRRPAG.js +2 -0
  26. package/dist/openrtc_bg.wasm +0 -0
  27. package/dist/runtime/WasmRuntimeAdapter.d.ts +3 -3
  28. package/dist/runtime/WasmRuntimeAdapter.js +1 -1
  29. package/dist/runtime/device-status.d.ts +2 -2
  30. package/dist/runtime/index.d.ts +21 -73
  31. package/dist/runtime/index.js +1 -2
  32. package/dist/testing.d.ts +7 -17
  33. package/dist/testing.js +1 -1
  34. package/dist/transport/index.d.ts +2 -2
  35. package/dist/transport/index.js +1 -1
  36. package/dist/{types-BVJr065k.d.ts → types-BwmoJU2O.d.ts} +3 -1
  37. package/dist/{OpenRTCShared-ZQPu5LqL.d.ts → types-DE4iPkMB.d.ts} +268 -8
  38. package/dist/{types-DkgaCyqS.d.ts → types-oGGnaSW2.d.ts} +2 -2
  39. package/package.json +1 -25
  40. package/dist/DelegatingRuntimeAdapter-DqfHkjLy.d.ts +0 -373
  41. package/dist/OpenRTCShared-TKAQLONA.js +0 -1
  42. package/dist/WasmBridge-2A22U7RU.js +0 -1
  43. package/dist/auth/index.d.ts +0 -78
  44. package/dist/auth/index.js +0 -1
  45. package/dist/auth/internal.d.ts +0 -4
  46. package/dist/auth/internal.js +0 -1
  47. package/dist/chunk-2QHDEGVX.js +0 -1
  48. package/dist/chunk-3USHQ7QW.js +0 -3
  49. package/dist/chunk-5LRLWIT5.js +0 -1
  50. package/dist/chunk-6TAVJ46R.js +0 -1
  51. package/dist/chunk-BXFXPIXO.js +0 -1
  52. package/dist/chunk-F2XGNLXL.js +0 -2
  53. package/dist/chunk-GW7P3D54.js +0 -1
  54. package/dist/chunk-IEQTFQ3Q.js +0 -1
  55. package/dist/chunk-K37WVIZL.js +0 -1
  56. package/dist/chunk-N26S7V4N.js +0 -1
  57. package/dist/chunk-N4SX7C3W.js +0 -2
  58. package/dist/chunk-NB4H5TP3.js +0 -1
  59. package/dist/chunk-PODAMIL6.js +0 -2
  60. package/dist/chunk-UEYM6WTT.js +0 -2
  61. package/dist/chunk-VK6KX433.js +0 -1
  62. package/dist/chunk-YBXGNKM7.js +0 -2
  63. package/dist/chunk-YQWQDTQ3.js +0 -2
  64. package/dist/factories-SIVMTIHJ.js +0 -1
  65. package/dist/ipc-CflAVodw.d.ts +0 -11
  66. package/dist/ipcFactory-QY44OIKA.js +0 -1
  67. package/dist/runtime/legacy.d.ts +0 -18
  68. package/dist/runtime/legacy.js +0 -1
  69. package/dist/runtime/tauri.d.ts +0 -6
  70. package/dist/runtime/tauri.js +0 -1
  71. package/dist/tauri-Cz9n17g8.d.ts +0 -33
  72. package/dist/types-DNl4KHHY.d.ts +0 -195
@@ -0,0 +1 @@
1
+ import {b,e}from'./chunk-C7YN5MSV.js';import {xchacha20poly1305}from'@noble/ciphers/chacha.js';function I(){if(typeof globalThis<"u"&&globalThis.__OPENRTC_DEBUG__===true)return true;if(typeof localStorage<"u")try{return localStorage.getItem("openrtc:debug")==="1"}catch{return false}return false}function L(t,e,r){if(I()){if(typeof r>"u"){console[t](e);return}console[t](e,r);}}function z(t,e){L("debug",t,e);}function $(t,e){L("info",t,e);}function G(t,e){L("log",t,e);}function H(t){return new Promise(e=>setTimeout(e,t))}function K(t){let e=new Uint8Array(t.byteLength);return e.set(t),e}function P(t){let e=t.reduce((s,c)=>s+c.byteLength,0),r=new Uint8Array(e),a=0;for(let s of t)r.set(s,a),a+=s.byteLength;return r}function Q(t,e,r){let a=e*Math.pow(2,Math.max(0,t-1));return Math.min(r,a)}function j(t){try{let e=t;return !!e&&!!e.send&&typeof e.send.getWriter=="function"&&!!e.recv&&typeof e.recv.getReader=="function"}catch{return false}}function J(t,e,r){let a=t;if(!a)return null;try{let s=a.send,c=a.recv;if(!s||typeof s.getWriter!="function"||!c||typeof c.getReader!="function")return null;let f=typeof a.endpoint_id=="string"&&a.endpoint_id.trim().length>0?a.endpoint_id:e,i=Number.isSafeInteger(a.transport_stable_id)&&Number(a.transport_stable_id)>0?Number(a.transport_stable_id):void 0,y=Number.isSafeInteger(r)&&Number(r)>0?Number(r):void 0;if(i!==void 0&&y!==void 0&&i!==y)return null;let o=i??y;return {send:s,recv:c,endpoint_id:f,...o?{transport_stable_id:o}:{}}}catch{return null}}function Z(t,e){let r={send:t.send,recv:e,endpoint_id:typeof t.endpoint_id=="string"?t.endpoint_id:"",...Number.isSafeInteger(t.transport_stable_id)&&Number(t.transport_stable_id)>0?{transport_stable_id:Number(t.transport_stable_id)}:{}};return t?.applicationCryptoWrapped===true&&(r.applicationCryptoWrapped=true),r}async function ee(t,e){if(!t)return false;try{let r=t.send?.getWriter?.();if(r)try{await r.close();}catch{}finally{try{r.releaseLock();}catch{}}}catch{}try{let r=t.recv?.getReader?.();if(r)try{await r.cancel(e);}catch{}finally{try{r.releaseLock();}catch{}}}catch{}return true}function te(t,e,r={}){let a=r.context??"prependBytesToReader",s=r.traceId,c=e.byteLength===0,f=r.pendingRead??null,i=o=>r.release?.(o),y=(o,n)=>r.log?.(o,n);return new ReadableStream({async pull(o){if(!c){c=true,o.enqueue(e);return}if(f){let l=f;f=null;let d;try{d=await l;}catch(u){o.error(u),i("pending-read-error"),y("prepend-bytes:pending-read-error",{context:a,traceId:s||null,error:u?.message||String(u)});return}if(d.done){o.close(),i("pending-done");return}d.value&&o.enqueue(d.value);return}let n;try{n=await t.read();}catch(l){o.error(l),i("read-error"),y("prepend-bytes:read-error",{context:a,traceId:s||null,error:l?.message||String(l)});return}let{done:p,value:b}=n;if(p){o.close(),i("done");return}b&&o.enqueue(b);},async cancel(o){i("cancel");}})}async function re(t,e){let r=t.read(),a=e-Date.now();if(a<=0)return {status:"timeout",pendingRead:r};let s=Symbol("probe-timeout"),c,f=new Promise(i=>{c=setTimeout(()=>i(s),a);});try{let i=await Promise.race([r,f]);if(i===s)return {status:"timeout",pendingRead:r};let{done:y,value:o}=i;return y?{status:"done"}:{status:"data",value:o&&o.byteLength>0?new Uint8Array(o):new Uint8Array(0)}}finally{c&&clearTimeout(c);}}var N=b,k=new Set(N);function R(t){if(typeof t!="string")return;let e=t.trim().toLowerCase();return k.has(e)?e:void 0}function oe(t){let e$1=R(t);return e$1?e(e$1).baseProtocol==="iroh":false}function ie(t){let e$1=R(t);if(!e$1)return false;let r=e(e$1);return r.baseProtocol==="iroh"&&(r.locality==="nearby"||r.locality==="direct-internet")}function se(t){let e$1=R(t);return e$1?e(e$1).family==="optional-route":false}function ue(t){let e$1=R(t);return e$1?e(e$1).baseProtocol==="webrtc":false}function ce(t,e,r=false){return t==="relay"||e==="relay"?"webrtc-turn":t==="host"&&e==="host"||r&&t&&e?"webrtc-lan":"webrtc"}function le(t){let e$1=R(t);return e$1?e(e$1).independentlyInstantiable:false}var m=new Uint8Array([79,82,84,67,69,49]),T=2,A=8,h=24,_=32,C=3,D=16*1024*1024,q=4096;function F(t,e){if(t.byteLength<e.byteLength)return false;let r=0;for(let a=0;a<e.byteLength;a+=1)r|=t[a]^e[a];return r===0}function W(t){let e=new Uint8Array(t),r=globalThis.crypto;if(!r||typeof r.getRandomValues!="function")throw new Error("[OpenRTC] application payload crypto requires crypto.getRandomValues");return r.getRandomValues(e),e}function V(t,e){let r="";for(let a of e)r+=a.toString(16).padStart(2,"0");return `${t}:${r}`}function v(t){if(!F(t,m))return null;let e=t[m.byteLength];return e===T?e:null}function M(t){return v(t)===T&&t.byteLength>m.byteLength+1+A+h}function fe(t,e={}){if(!(t instanceof Uint8Array)||t.byteLength!==_)throw new Error(`[OpenRTC] application payload crypto key must be ${_} bytes`);let r=new Uint8Array(t),a=e.requireEncrypted??true,s=e.randomBytes??W,c=e.replayProtection??true,f=0,i=new Set,y=[];return {requireEncrypted:a,protectPayload(o,n){let p=s(h);if(!(p instanceof Uint8Array)||p.byteLength!==h)throw new Error(`[OpenRTC] application payload crypto nonce must be ${h} bytes`);let b=new Uint8Array(1+n.byteLength);b[0]=o,b.set(n,1);let l=xchacha20poly1305(r,p).encrypt(b);if(!c)throw new Error("[OpenRTC] ORTCE1 v1 envelopes are not supported; replay protection is required");let d=new Uint8Array(m.byteLength+1+A+p.byteLength+l.byteLength),u=0;d.set(m,u),u+=m.byteLength,d[u]=T,u+=1;let S=f;return f+=1,new DataView(d.buffer,d.byteOffset+u,A).setBigUint64(0,BigInt(S),false),u+=A,d.set(p,u),u+=p.byteLength,d.set(l,u),d},openPayload(o,n){if(!M(n))return a?null:n;if(v(n)!==T)return null;let b=m.byteLength+1,l=Number(new DataView(n.buffer,n.byteOffset+b,A).getBigUint64(0,false));if(!Number.isFinite(l))return null;let d=b+A,u=d+h,S=n.slice(d,u),w=c?V(l,S):null;if(w&&i.has(w))return null;let O=n.slice(u),U;try{U=xchacha20poly1305(r,S).decrypt(O);}catch{return null}if(U.byteLength<1||U[0]!==o)return null;if(w)for(i.add(w),y.push(w);y.length>q;){let x=y.shift();x&&i.delete(x);}return U.slice(1)}}}function Y(t){let e=new Uint8Array(4+t.byteLength);return new DataView(e.buffer,e.byteOffset,e.byteLength).setUint32(0,t.byteLength,false),e.set(t,4),e}function be(t,e={}){let r=e.typeId??C,a=e.maxFrameBytes??D;if(!Number.isInteger(r)||r<0||r>255)throw new Error("[OpenRTC] raw application crypto stream typeId must be an integer from 0 to 255");if(!Number.isInteger(a)||a<=0)throw new Error("[OpenRTC] raw application crypto maxFrameBytes must be a positive integer");let s=n=>t.protectPayload(r,n),c=n=>t.openPayload(r,n),f=()=>new TransformStream({transform(n,p){p.enqueue(Y(s(new Uint8Array(n))));}}),i=()=>{let n=new Uint8Array(0);return new TransformStream({transform(p,b){for(n=P([n,new Uint8Array(p)]);n.byteLength>=4;){let l=new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,false);if(l===0||l>a)throw new Error("[OpenRTC] invalid encrypted raw stream frame length");if(n.byteLength<4+l)return;let d=n.slice(4,4+l);n=n.slice(4+l);let u=c(d);if(!u)throw new Error("[OpenRTC] encrypted raw stream frame failed authentication");b.enqueue(u);}},flush(){if(n.byteLength!==0)throw new Error("[OpenRTC] encrypted raw stream ended mid-frame")}})},y=n=>n.pipeThrough(i()),o=n=>{let p=f();return p.readable.pipeTo(n).catch(()=>{}),p.writable};return {typeId:r,protectFrame:s,openFrame:c,createOutboundTransform:f,createInboundTransform:i,wrapReadable:y,wrapWritable:o,wrapBiStream(n){return {...n,send:o(n.send),recv:y(n.recv)}}}}export{I as a,z as b,$ as c,G as d,H as e,K as f,P as g,Q as h,j as i,J as j,Z as k,ee as l,te as m,re as n,N as o,R as p,oe as q,ie as r,se as s,ue as t,ce as u,le as v,M as w,fe as x,be as y};
@@ -1,2 +1,2 @@
1
- import {c as c$1}from'./chunk-C7YN5MSV.js';var b=new Set;function l(e,t){b.has(e)||(b.add(e),console.warn(t));}function T(e){return /^pk_(live|test)_[0-9a-f]{40}$/.test(e)}async function j(e,t){let n=`${e}:${t}`,o=new TextEncoder().encode(n),s=await crypto.subtle.digest("SHA-256",o);return Array.from(new Uint8Array(s)).map(h=>h.toString(16).padStart(2,"0")).join("")}function c(e){let t=typeof e.apiKey=="string"?e.apiKey.trim():"";if(t)return T(t)||l(`invalid-api-key:${t.slice(0,10)}`,"[pluto-rtc] The provided `apiKey` does not match the expected format (pk_live_... or pk_test_...). Create an app at https://api.openrtc.app/developer."),`app_${t.slice(-16)}`;throw new Error("[openrtc] `apiKey` is required. Create an app at https://api.openrtc.app/developer.")}function a(e){return e.authMode?e.authMode:("apiKey"in e&&typeof e.apiKey=="string"&&e.apiKey.trim().length>0&&typeof(e.spaceKey??e.space)=="string"&&(e.spaceKey??e.space).trim().length>0||l("default-auth-mode","[pluto-rtc] `authMode` is not set; defaulting to `anonymous` for compatibility."),"anonymous")}function B(e){let t=typeof e.projectId=="string"?e.projectId.trim():"";return t||(l("default-project-id","[pluto-rtc] `projectId` is not set; defaulting to the built-in PlutoRTC Firebase project."),i)}function y(e){return e.trim().replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function H(e){let t="storagePrefix"in e&&typeof e.storagePrefix=="string"?y(e.storagePrefix):"";return t||y(c(e))||"default"}var R={devicesPerUser:100,maxRooms:1e4,maxMembersPerRoom:250,maxPersonalDevices:25e3},W=R;var x=[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun.cloudflare.com:3478"}],v={iceServers:x},Q={};var P=["iroh-relay","iroh","moq"];function A(e){return (Array.isArray(e.urls)?e.urls:[e.urls]).some(n=>typeof n=="string"&&(n.startsWith("turn:")||n.startsWith("turns:")))}function M(e){let n=(Array.isArray(e.urls)?e.urls:[e.urls]).filter(r=>typeof r=="string"&&!r.startsWith("stun:"));return n.length===0?null:{...e,urls:Array.isArray(e.urls)?n:n[0]}}function d(e){if(e)return e.map(t=>M(t)).filter(t=>t!==null)}function f(e,t){let n=new Set(["iroh-relay","iroh","moq"]);t&&n.add("webrtc");let r=(e??P).filter(o=>n.has(o));return r.length>0?r:[...P]}function Y(e){return !!e?.transports?.webrtc}function $(e,t){let n=e?.transports?.webrtc||void 0;if(n)return e?.strictMode||n.privacyMode?{...n,iceServers:d(n.iceServers),iceTransportPolicy:"relay"}:n.iceTransportPolicy==="relay"&&!(Array.isArray(n.iceServers)&&n.iceServers.some(o=>A(o)))?(t?.("[Client] Overriding relay-only ICE policy to all because no TURN servers are configured"),{...n,iceTransportPolicy:"all"}):n}var O=/^[A-Za-z0-9._-]+$/,w="[redacted]";function I(e){let t;try{t=new URL(e);}catch{throw new Error("[OpenRTC] transports.moq.relayUrl must be a valid HTTPS URL.")}if(t.protocol!=="https:")throw new Error("[OpenRTC] transports.moq.relayUrl must use HTTPS/WebTransport.");if(t.hash)throw new Error("[OpenRTC] transports.moq.relayUrl must not contain a fragment.");if(t.searchParams.has("jwt"))throw new Error("[OpenRTC] transports.moq.relayUrl must not contain a jwt query parameter; use transports.moq.accessToken.");return t}function p(e){return I(e.trim()).toString()}function X(e,t){let n=I(e.trim());if(t!==void 0){let r=t.trim();if(!r)throw new Error("[OpenRTC] transports.moq.accessToken must not be empty when provided.");if(new TextEncoder().encode(r).byteLength>16384)throw new Error("[OpenRTC] transports.moq.accessToken exceeds the maximum supported size.");if(!O.test(r))throw new Error("[OpenRTC] transports.moq.accessToken must be a URL-safe JWT.");n.searchParams.append("jwt",r);}return n.toString()}function Z(e){try{let t=new URL(e);return t.search="",t.hash="",t.toString()}catch{return "invalid-moq-relay-url"}}function V(e,t){let n=e instanceof Error?`${e.name}: ${e.message}`:String(e),r=t?.trim();return r?n.split(r).join(w):n}var D=[...c$1];function u(e){let t=e.spaceKey??e.space;return {...e,...t!==void 0?{spaceKey:t}:{}}}function C(e){return {...e,iceServers:e.iceServers?e.iceServers.map(t=>({...t})):e.iceServers}}function k(e){return {...e}}function N(e){return {...e}}function E(e){if(e)return {iroh:typeof e.iroh=="object"?N(e.iroh):e.iroh,webrtc:typeof e.webrtc=="object"?C(e.webrtc):e.webrtc,ble:typeof e.ble=="object"?{...e.ble}:e.ble,moq:typeof e.moq=="object"?k(e.moq):e.moq}}function U(e){if(e.strictMode&&!e.transports&&(e.transports={iroh:{relayOnly:true}}),!!e.transports){if(e.transports.webrtc===true?e.transports.webrtc=C(v):e.transports.webrtc===false&&(e.transports.webrtc=void 0),e.transports.moq===true)throw new Error("[OpenRTC] transports.moq=true is ambiguous because no anonymous MoQ relay is available; provide transports.moq.relayUrl explicitly.");if(e.transports.moq===false)e.transports.moq=void 0;else if(e.transports.moq&&typeof e.transports.moq=="object"){let t=e.transports.moq,n=t.relayUrl?.trim(),r=t.accessToken;if(r!==void 0&&!r.trim())throw new Error("[OpenRTC] transports.moq.accessToken must not be empty when provided.");e.transports.moq={...t,...n?{relayUrl:p(n)}:{},...r!==void 0?{accessToken:r.trim()}:{}};}e.transports.iroh===true?e.transports.iroh={}:e.transports.iroh===false&&(e.transports.iroh=void 0);}}function _(e){if(!e.strictMode||!e.transports)return;let t=e.transports.iroh&&typeof e.transports.iroh=="object"?e.transports.iroh:{};e.transports.iroh={...t,relayOnly:true,relayTransportPolicy:t.relayTransportPolicy??"websocketRequired",localDiscovery:false,localDiscoveryMode:void 0},e.transports.ble=void 0;let n=e.transports.webrtc;n&&typeof n=="object"&&(e.transports.webrtc={...n,privacyMode:true,lanMode:false,iceServers:d(n.iceServers)??[],iceTransportPolicy:"relay"});let r=e.transports.moq;if(r&&typeof r=="object"){let o=r.relayUrl?.trim();if(!o)throw new Error("[OpenRTC] strictMode requires an explicit transports.moq.relayUrl.");e.transports.moq={...r,relayUrl:p(o)};}}function ae(e){let t=u(e),n=c(t),r=a(t),o={strictMode:false,disableIrohFallback:false,transportPriority:[...D],...t,authMode:r,transports:E(t.transports)};U(o),_(o),o.strictMode&&(o.transportPriority=f(t.transportPriority,!!o.transports?.webrtc));let s=S(o),m=(o.discoveryMode??"space")==="space"?"client-open":"client-auth";return {appTag:n,authMode:r,configuredPersistenceMode:s,options:o,roomCreationMode:m}}function S(e){let t=e.transports?.iroh;return e.endpointIdPersistence??e.nodeIdPersistence??(typeof t=="object"?t.persistenceMode:void 0)??"ephemeral"}function se(e){return "options"in e&&"configuredPersistenceMode"in e?{apiKey:e.options.apiKey,authMode:a(e.options),projectId:e.options.projectId,storagePrefix:e.options.storagePrefix,nodeIdPersistence:e.configuredPersistenceMode}:{apiKey:e.apiKey,authMode:a(e),projectId:e.projectId,storagePrefix:e.storagePrefix,nodeIdPersistence:S(e)}}function le(e,t){t&&(e.transports={...e.transports||{},...t});}var i="pluto-rtc-prod",L="https://api.openrtc.app",q="https://gateway.openrtc.app",pe={apiKey:"AIzaSyA62Krj-7ZYFT5xjrTUq7mXana41Ahj_mM",authDomain:"api.openrtc.app",projectId:i,storageBucket:"pluto-rtc-prod.firebasestorage.app",messagingSenderId:"607066575224",appId:"1:607066575224:web:ed3f51825ba228db92b88d",recaptchaSiteKey:"6LfGv2gtAAAAALFAuE_kpLYpNBpk2IsKiLIGdOGl"};function ue(e){let t=u(e),r=(typeof t.projectId=="string"&&t.projectId.trim()?t.projectId.trim():void 0)??i,o=r===i;return {...t,projectId:r,coordinationGateway:t.coordinationGateway??(o?{endpoint:q,controlPlaneEndpoint:L,environment:"production"}:void 0)}}
2
- export{L as a,pe as b,ue as c,j as d,c as e,a as f,B as g,H as h,W as i,x as j,v as k,Q as l,Y as m,$ as n,X as o,Z as p,V as q,u as r,ae as s,se as t,le as u};
1
+ import {c as c$1}from'./chunk-C7YN5MSV.js';var b=new Set;function l(e,t){b.has(e)||(b.add(e),console.warn(t));}function T(e){return /^pk_(live|test)_[0-9a-f]{40}$/.test(e)}async function j(e,t){let n=`${e}:${t}`,o=new TextEncoder().encode(n),s=await crypto.subtle.digest("SHA-256",o);return Array.from(new Uint8Array(s)).map(h=>h.toString(16).padStart(2,"0")).join("")}function c(e){let t=typeof e.apiKey=="string"?e.apiKey.trim():"";if(t)return T(t)||l(`invalid-api-key:${t.slice(0,10)}`,"[pluto-rtc] The provided `apiKey` does not match the expected format (pk_live_... or pk_test_...). Create an app at https://api.openrtc.app/developer."),`app_${t.slice(-16)}`;throw new Error("[openrtc] `apiKey` is required. Create an app at https://api.openrtc.app/developer.")}function a(e){return e.authMode?e.authMode:("apiKey"in e&&typeof e.apiKey=="string"&&e.apiKey.trim().length>0&&typeof(e.spaceKey??e.space)=="string"&&(e.spaceKey??e.space).trim().length>0||l("default-auth-mode","[pluto-rtc] `authMode` is not set; defaulting to `anonymous` for compatibility."),"anonymous")}function B(e){let t=typeof e.projectId=="string"?e.projectId.trim():"";return t||(l("default-project-id","[pluto-rtc] `projectId` is not set; defaulting to the built-in PlutoRTC Firebase project."),i)}function y(e){return e.trim().replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function H(e){let t="storagePrefix"in e&&typeof e.storagePrefix=="string"?y(e.storagePrefix):"";return t||y(c(e))||"default"}var R={devicesPerUser:100,maxRooms:1e4,maxMembersPerRoom:250,maxPersonalDevices:25e3},W=R;var x=[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun.cloudflare.com:3478"}],v={iceServers:x},Q={};var P=["iroh-relay","iroh","moq"];function A(e){return (Array.isArray(e.urls)?e.urls:[e.urls]).some(n=>typeof n=="string"&&(n.startsWith("turn:")||n.startsWith("turns:")))}function M(e){let n=(Array.isArray(e.urls)?e.urls:[e.urls]).filter(r=>typeof r=="string"&&!r.startsWith("stun:"));return n.length===0?null:{...e,urls:Array.isArray(e.urls)?n:n[0]}}function d(e){if(e)return e.map(t=>M(t)).filter(t=>t!==null)}function f(e,t){let n=new Set(["iroh-relay","iroh","moq"]);t&&n.add("webrtc");let r=(e??P).filter(o=>n.has(o));return r.length>0?r:[...P]}function Y(e){return !!e?.transports?.webrtc}function $(e,t){let n=e?.transports?.webrtc||void 0;if(n)return e?.strictMode||n.privacyMode?{...n,iceServers:d(n.iceServers),iceTransportPolicy:"relay"}:n.iceTransportPolicy==="relay"&&!(Array.isArray(n.iceServers)&&n.iceServers.some(o=>A(o)))?(t?.("[Client] Overriding relay-only ICE policy to all because no TURN servers are configured"),{...n,iceTransportPolicy:"all"}):n}var O=/^[A-Za-z0-9._-]+$/,w="[redacted]";function I(e){let t;try{t=new URL(e);}catch{throw new Error("[OpenRTC] transports.moq.relayUrl must be a valid HTTPS URL.")}if(t.protocol!=="https:")throw new Error("[OpenRTC] transports.moq.relayUrl must use HTTPS/WebTransport.");if(t.hash)throw new Error("[OpenRTC] transports.moq.relayUrl must not contain a fragment.");if(t.searchParams.has("jwt"))throw new Error("[OpenRTC] transports.moq.relayUrl must not contain a jwt query parameter; use transports.moq.accessToken.");return t}function p(e){return I(e.trim()).toString()}function X(e,t){let n=I(e.trim());if(t!==void 0){let r=t.trim();if(!r)throw new Error("[OpenRTC] transports.moq.accessToken must not be empty when provided.");if(new TextEncoder().encode(r).byteLength>16384)throw new Error("[OpenRTC] transports.moq.accessToken exceeds the maximum supported size.");if(!O.test(r))throw new Error("[OpenRTC] transports.moq.accessToken must be a URL-safe JWT.");n.searchParams.append("jwt",r);}return n.toString()}function Z(e){try{let t=new URL(e);return t.search="",t.hash="",t.toString()}catch{return "invalid-moq-relay-url"}}function V(e,t){let n=e instanceof Error?`${e.name}: ${e.message}`:String(e),r=t?.trim();return r?n.split(r).join(w):n}var D=[...c$1];function u(e){let t=e.spaceKey??e.space;return {...e,...t!==void 0?{spaceKey:t}:{}}}function C(e){return {...e,iceServers:e.iceServers?e.iceServers.map(t=>({...t})):e.iceServers}}function k(e){return {...e}}function N(e){return {...e}}function E(e){if(e)return {iroh:typeof e.iroh=="object"?N(e.iroh):e.iroh,webrtc:typeof e.webrtc=="object"?C(e.webrtc):e.webrtc,ble:typeof e.ble=="object"?{...e.ble}:e.ble,moq:typeof e.moq=="object"?k(e.moq):e.moq}}function U(e){if(e.strictMode&&!e.transports&&(e.transports={iroh:{relayOnly:true}}),!!e.transports){if(e.transports.webrtc===true?e.transports.webrtc=C(v):e.transports.webrtc===false&&(e.transports.webrtc=void 0),e.transports.moq===true)throw new Error("[OpenRTC] transports.moq=true is ambiguous because no anonymous MoQ relay is available; provide transports.moq.relayUrl explicitly.");if(e.transports.moq===false)e.transports.moq=void 0;else if(e.transports.moq&&typeof e.transports.moq=="object"){let t=e.transports.moq,n=t.relayUrl?.trim(),r=t.accessToken;if(r!==void 0&&!r.trim())throw new Error("[OpenRTC] transports.moq.accessToken must not be empty when provided.");e.transports.moq={...t,...n?{relayUrl:p(n)}:{},...r!==void 0?{accessToken:r.trim()}:{}};}e.transports.iroh===true?e.transports.iroh={}:e.transports.iroh===false&&(e.transports.iroh=void 0);}}function _(e){if(!e.strictMode||!e.transports)return;let t=e.transports.iroh&&typeof e.transports.iroh=="object"?e.transports.iroh:{};e.transports.iroh={...t,relayOnly:true,relayTransportPolicy:t.relayTransportPolicy??"websocketRequired",localDiscovery:false,localDiscoveryMode:void 0},e.transports.ble=void 0;let n=e.transports.webrtc;n&&typeof n=="object"&&(e.transports.webrtc={...n,privacyMode:true,lanMode:false,iceServers:d(n.iceServers)??[],iceTransportPolicy:"relay"});let r=e.transports.moq;if(r&&typeof r=="object"){let o=r.relayUrl?.trim();if(!o)throw new Error("[OpenRTC] strictMode requires an explicit transports.moq.relayUrl.");e.transports.moq={...r,relayUrl:p(o)};}}function ae(e){let t=u(e),n=c(t),r=a(t),o={strictMode:false,disableIrohFallback:false,transportPriority:[...D],...t,authMode:r,transports:E(t.transports)};U(o),_(o),o.strictMode&&(o.transportPriority=f(t.transportPriority,!!o.transports?.webrtc));let s=S(o),m=(o.discoveryMode??"space")==="space"?"client-open":"client-auth";return {appTag:n,authMode:r,configuredPersistenceMode:s,options:o,roomCreationMode:m}}function S(e){let t=e.transports?.iroh;return e.endpointIdPersistence??e.nodeIdPersistence??(typeof t=="object"?t.persistenceMode:void 0)??"ephemeral"}function se(e){return "options"in e&&"configuredPersistenceMode"in e?{apiKey:e.options.apiKey,authMode:a(e.options),projectId:e.options.projectId,storagePrefix:e.options.storagePrefix,nodeIdPersistence:e.configuredPersistenceMode}:{apiKey:e.apiKey,authMode:a(e),projectId:e.projectId,storagePrefix:e.storagePrefix,nodeIdPersistence:S(e)}}function le(e,t){t&&(e.transports={...e.transports||{},...t});}var i="pluto-rtc-prod",L="https://api.openrtc.app",q="https://gateway.openrtc.app";function pe(e){let t=u(e),r=(typeof t.projectId=="string"&&t.projectId.trim()?t.projectId.trim():void 0)??i,o=r===i;return {...t,projectId:r,coordinationGateway:t.coordinationGateway??(o?{endpoint:q,controlPlaneEndpoint:L,environment:"production"}:void 0)}}
2
+ export{pe as a,j as b,c,a as d,B as e,H as f,W as g,x as h,v as i,Q as j,Y as k,$ as l,X as m,Z as n,V as o,u as p,ae as q,se as r,le as s};
@@ -1,2 +1,2 @@
1
- import {d as d$2,c}from'./chunk-VK6KX433.js';import {a,d as d$1}from'./chunk-C7YN5MSV.js';import {x25519}from'@noble/curves/ed25519.js';import {hkdf}from'@noble/hashes/hkdf.js';import {sha256}from'@noble/hashes/sha2.js';var A=3e4,d=class d{constructor(){this.name="webrtc";this.pc=null;this.dc=null;this.state="disconnected";this.pendingCandidates=[];this.connectTimeoutId=null;this.iceDisconnectedGraceTimer=null;this.iceRestartAttempted=false;this.localNodeId="";this.remoteNodeId="";this.candidatesGathered=0;this.sdpOfferSent=false;this.sdpAnswerReceived=false;this._terminalFailure=false;this.activeAttemptId=0;this.negotiationId=null;this.disconnectedGraceExtensions=0;this.offerInFlight=false;this.messageListeners=[];this.stateListeners=[];this.internalSignalSender=null;}get isReady(){return this.state==="connected"}isTerminalFailure(){return this._terminalFailure}getNegotiationId(){return this.negotiationId}getDataChannelReadyState(){return this.dc?.readyState??null}getNativeTransport(){return this.pc}setSignalSender(e){this.internalSignalSender=e;}async init(e,n,t){this.closePeerResources();let i=++this.activeAttemptId;this.localNodeId=e,this.remoteNodeId=n,this.candidatesGathered=0,this.sdpOfferSent=false,this.sdpAnswerReceived=false,this._terminalFailure=false,this.offerInFlight=false,this.pendingCandidates=[],this.disconnectedGraceExtensions=0,this.negotiationId=typeof t?.negotiationId=="string"&&t.negotiationId.trim().length>0?t.negotiationId.trim():this.createNegotiationId(),this.setState("connecting"),this.startConnectTimeout(i);let a=t.rtcConfig||{},s=typeof t?.forceRole=="string"&&(t.forceRole==="initiator"||t.forceRole==="responder")?t.forceRole:null,c=s?s==="initiator":e>n;d$2(`[WebRTCTransport] init \u2014 role=${c?"initiator":"responder"}`,{local:e.slice(0,12),remote:n.slice(0,12),negotiationId:this.negotiationId,forcedRole:s});try{d$2("[WebRTCTransport] Creating RTCPeerConnection",{iceServers:a.iceServers?.length??0}),this.pc=new RTCPeerConnection(a);}catch(R){console.error("[WebRTCTransport] RTCPeerConnection constructor failed",R),this.setState("failed");return}let T=this.pc.createDataChannel("pluto-dc",{negotiated:true,id:0});this.setupDataChannel(T,i),this.setupPCHandlers(c,i),c&&queueMicrotask(()=>{this.createAndSendOffer(i,"initial-initiator");});}setupDataChannel(e,n){this.dc=e,e.onopen=()=>{this.isCurrentAttempt(n,e)&&(d$2("[WebRTCTransport] DataChannel opened \u2014 upgrade complete"),this.promoteConnectedIfReady("datachannel-open"));},e.onmessage=t=>{if(!this.isCurrentAttempt(n,e))return;let i=typeof t.data=="string"?new TextEncoder().encode(t.data):new Uint8Array(t.data);this.messageListeners.forEach(a=>a(i));},e.onclose=()=>{this.isCurrentAttempt(n,e)&&(d$2("[WebRTCTransport] DataChannel closed"),(this.state==="connected"||this.state==="connecting")&&this.setState("disconnected"));},e.onerror=t=>{if(!this.isCurrentAttempt(n,e))return;console.warn("[WebRTCTransport] DataChannel error",t);let i=t?.error?.message??"";if((i.includes("User-Initiated Abort")||i.includes("Close called"))&&this.state==="connected"&&e.readyState!=="open"){console.warn("[WebRTCTransport] DataChannel aborted post-connect; forcing disconnected state",{readyState:e.readyState,connectionState:this.pc?.connectionState,iceConnectionState:this.pc?.iceConnectionState}),this.setState("disconnected");return}this.state==="connecting"&&this.setState("failed");};}setupPCHandlers(e,n){let t=this.pc;t&&(t.onicecandidate=i=>{this.isCurrentAttempt(n,void 0,t)&&(i.candidate?(this.candidatesGathered++,d$2(`[WebRTCTransport] ICE candidate #${this.candidatesGathered}: ${i.candidate.type} ${i.candidate.protocol} ${i.candidate.address??"?"}:${i.candidate.port}`),this.internalSignalSender?this.internalSignalSender({transport:"webrtc",type:"candidate",candidate:i.candidate,negotiationId:this.negotiationId??void 0}).catch(a=>{console.warn("[WebRTCTransport] Failed sending local ICE candidate signal",{error:a,gatheringState:t?.iceGatheringState,iceConnectionState:t?.iceConnectionState});}):console.warn("[WebRTCTransport] ICE candidate dropped \u2014 no signal sender!")):this.candidatesGathered===0?(console.warn("[WebRTCTransport] ICE gathering complete with 0 candidates \u2014 failing immediately.","If both peers are on the same page, WebRTC requires separate tabs or devices.",{local:this.localNodeId.slice(0,12),remote:this.remoteNodeId.slice(0,12)}),this._terminalFailure=true,this.setState("failed")):d$2(`[WebRTCTransport] ICE gathering complete \u2014 ${this.candidatesGathered} candidate(s)`));},t.onnegotiationneeded=async()=>{e&&await this.createAndSendOffer(n,"negotiationneeded");},t.onconnectionstatechange=()=>{if(!this.isCurrentAttempt(n,void 0,t))return;let i=t.connectionState;if(d$2(`[WebRTCTransport] Connection state: ${i}`),i==="connected")this.promoteConnectedIfReady("pc-connected");else if(i==="failed"){if(this.iceDisconnectedGraceTimer){console.warn("[WebRTCTransport] pc.connectionState=failed during grace window \u2014 deferring to grace timer",{iceState:t.iceConnectionState,iceRestartAttempted:this.iceRestartAttempted});return}console.error("[WebRTCTransport] Connection failed",{iceState:t.iceConnectionState,gatheringState:t.iceGatheringState,signalingState:t.signalingState,candidatesGathered:this.candidatesGathered,sdpOfferSent:this.sdpOfferSent,sdpAnswerReceived:this.sdpAnswerReceived}),this.clearIceDisconnectedGrace("pc-failed"),this.setState("failed");}else i==="closed"?(this.clearIceDisconnectedGrace("pc-closed"),this.setState("disconnected")):i==="disconnected"&&(d$2("[WebRTCTransport] pc.connectionState=disconnected, deferring to ICE grace period"),this.startIceDisconnectedGrace(n,t,e,"pc-disconnected"));},t.oniceconnectionstatechange=()=>{if(!this.isCurrentAttempt(n,void 0,t))return;let i=t.iceConnectionState;if(d$2(`[WebRTCTransport] ICE connection state: ${i}`,{gatheringState:t.iceGatheringState,signalingState:t.signalingState,candidatesGathered:this.candidatesGathered,hasSdpOffer:this.sdpOfferSent,hasSdpAnswer:this.sdpAnswerReceived,hasRemoteDescription:!!t.remoteDescription,hasLocalDescription:!!t.localDescription}),i==="failed"){if(this.iceDisconnectedGraceTimer){console.warn("[WebRTCTransport] ice failed during grace window \u2014 deferring to grace timer");return}console.error("[WebRTCTransport] ICE failed \u2014 likely NAT traversal issue or no matching candidates",{gatheringState:t.iceGatheringState,signalingState:t.signalingState,candidatesGathered:this.candidatesGathered}),this.clearIceDisconnectedGrace("ice-failed"),this.setState("failed");}else i==="disconnected"?this.startIceDisconnectedGrace(n,t,e,"ice-disconnected"):(i==="connected"||i==="completed")&&(this.iceDisconnectedGraceTimer&&d$2("[WebRTCTransport] ice-recovered \u2014 cancelling grace timer"),this.clearIceDisconnectedGrace("ice-recovered"),this.iceRestartAttempted=false,this.promoteConnectedIfReady("ice-connected"));},t.onicegatheringstatechange=()=>{this.isCurrentAttempt(n,void 0,t)&&d$2(`[WebRTCTransport] ICE gathering state: ${t.iceGatheringState}`,{iceConnectionState:t.iceConnectionState,signalingState:t.signalingState,hasLocalDesc:!!t.localDescription,hasRemoteDesc:!!t.remoteDescription});});}async createAndSendOffer(e,n){let t=this.pc;if(!(!t||!this.isCurrentAttempt(e,void 0,t))&&t.signalingState==="stable"&&!(this.sdpOfferSent&&t.localDescription?.type==="offer")&&!this.offerInFlight){d$2(`[WebRTCTransport] Creating offer (${n})`),this.offerInFlight=true;try{let i=await t.createOffer();if(await t.setLocalDescription(i),!this.isCurrentAttempt(e,void 0,t))return;if(this.sdpOfferSent=!0,this.internalSignalSender)try{await this.internalSignalSender({transport:"webrtc",type:"sdp",sdp:i,negotiationId:this.negotiationId??void 0});}catch(a){console.warn("[WebRTCTransport] Offer signaling failed (non-fatal)",{error:a,negotiationId:this.negotiationId,signalingState:t.signalingState,iceConnectionState:t.iceConnectionState});}else console.warn("[WebRTCTransport] No signal sender \u2014 offer not transmitted");}catch(i){console.error("[WebRTCTransport] Offer creation failed",i),this.closePeerResources(),this.setState("failed");}finally{this.isCurrentAttempt(e,void 0,t)&&(this.offerInFlight=false);}}}handleSignalingMessage(e){if(!this.pc||e.transport!=="webrtc")return;let n=this.normalizeNegotiationId(e?.negotiationId);if(n&&this.negotiationId&&n!==this.negotiationId){c("[WebRTCTransport] Ignoring stale signaling message for a different negotiation",{signalType:e?.type??null,signalNegotiationId:n,activeNegotiationId:this.negotiationId});return}if(e.type==="candidate"){let t=e.candidate;d$2("[WebRTCTransport] Received remote ICE candidate",{hasRemoteDesc:!!this.pc.remoteDescription,type:t?.type,protocol:t?.protocol,address:t?.address}),this.pc.remoteDescription?this.pc.addIceCandidate(t).catch(i=>{console.warn("[WebRTCTransport] addIceCandidate failed",i);}):(this.pendingCandidates.push(t),d$2(`[WebRTCTransport] Buffered remote candidate \u2014 ${this.pendingCandidates.length} pending`));}else if(e.type==="sdp"){let t=e.sdp,i=t.type==="offer",a=t.type==="answer";if(a&&this.pc.signalingState!=="have-local-offer"){c("[WebRTCTransport] Ignoring SDP answer because no local offer is pending",{signalingState:this.pc.signalingState,iceConnectionState:this.pc.iceConnectionState,signalNegotiationId:n,activeNegotiationId:this.negotiationId,hasLocalDescription:!!this.pc.localDescription,hasRemoteDescription:!!this.pc.remoteDescription});return}d$2(`[WebRTCTransport] Received SDP ${t.type} \u2014 applying remote description`),a&&(this.sdpAnswerReceived=true),this.pc.setRemoteDescription(t).then(async()=>{if(a&&(d$2("[WebRTCTransport] Remote SDP answer applied",{signalingState:this.pc?.signalingState,iceConnectionState:this.pc?.iceConnectionState,hasLocalDescription:!!this.pc?.localDescription,hasRemoteDescription:!!this.pc?.remoteDescription}),this.promoteConnectedIfReady("sdp-answer-applied")),this.pendingCandidates.length&&(d$2(`[WebRTCTransport] Flushing ${this.pendingCandidates.length} buffered candidate(s)`),this.pendingCandidates.forEach(s=>this.pc?.addIceCandidate(s)),this.pendingCandidates=[]),i){d$2("[WebRTCTransport] Creating answer (responder)");let s=await this.pc.createAnswer();if(await this.pc.setLocalDescription(s),d$2("[WebRTCTransport] Answer sent"),this.internalSignalSender)try{await this.internalSignalSender({transport:"webrtc",type:"sdp",sdp:s,negotiationId:n??this.negotiationId??void 0});}catch(c){throw console.warn("[WebRTCTransport] Failed sending SDP answer signal",{error:c,signalingState:this.pc?.signalingState,hasLocalDescription:!!this.pc?.localDescription,hasRemoteDescription:!!this.pc?.remoteDescription}),c}else console.warn("[WebRTCTransport] No signal sender \u2014 answer not transmitted");}}).catch(s=>{console.error(`[WebRTCTransport] setRemoteDescription (${t.type}) failed`,s),this.setState("failed");});}}async send(e){if(this.dc&&this.dc.readyState==="open"){let n=new Uint8Array(e);this.dc.send(n);}else throw new Error("WebRTC DataChannel not open")}getBufferedAmount(){return this.dc?.bufferedAmount??0}async waitForDrain(e){!this.dc||this.dc.bufferedAmount<=e||await new Promise(n=>{let t=this.dc;if(!t){n();return}t.bufferedAmountLowThreshold=e,t.onbufferedamountlow=()=>{t.onbufferedamountlow=null,n();};});}close(){this.closePeerResources(),this.setState("disconnected");}onMessage(e){this.messageListeners.push(e);}onStateChange(e){this.stateListeners.push(e);}setState(e){this.state!==e&&(this.state=e,(e==="connected"||e==="failed"||e==="disconnected")&&this.clearConnectTimeout(),this.stateListeners.forEach(n=>n(e)));}startConnectTimeout(e){this.clearConnectTimeout(),this.connectTimeoutId=setTimeout(()=>{this.activeAttemptId===e&&this.state==="connecting"&&(console.warn(`[WebRTCTransport] Timed out after ${d.ICE_CONNECT_TIMEOUT_MS}ms`,{iceState:this.pc?.iceConnectionState,gatheringState:this.pc?.iceGatheringState,signalingState:this.pc?.signalingState,candidatesGathered:this.candidatesGathered,sdpOfferSent:this.sdpOfferSent,sdpAnswerReceived:this.sdpAnswerReceived,hasRemoteDescription:!!this.pc?.remoteDescription,hasLocalDescription:!!this.pc?.localDescription}),this.setState("failed"));},d.ICE_CONNECT_TIMEOUT_MS);}clearConnectTimeout(){this.connectTimeoutId&&(clearTimeout(this.connectTimeoutId),this.connectTimeoutId=null);}startIceDisconnectedGrace(e,n,t,i){if(!this.iceDisconnectedGraceTimer){if(this.iceRestartAttempted)d$2("[WebRTCTransport] ice-disconnected grace (restart already attempted)",{reason:i});else if(this.iceRestartAttempted=true,t){try{d$2("[WebRTCTransport] ice-restart-attempted",{reason:i,isInitiator:t}),n.restartIce();}catch(a){console.warn("[WebRTCTransport] restartIce threw",a);}this.sendIceRestartOffer(e,n);}else d$2("[WebRTCTransport] ice-restart deferred to initiator",{reason:i});this.iceDisconnectedGraceTimer=setTimeout(()=>{if(this.iceDisconnectedGraceTimer=null,this.activeAttemptId!==e||this.pc!==n)return;let a=n.iceConnectionState,s=n.connectionState,c=this.dc?.readyState??"missing";if(a==="connected"||a==="completed"||s==="connected"||c==="open"){d$2("[WebRTCTransport] ice-grace expired \u2014 recovered",{ice:a,conn:s,dcReadyState:c});return}if(this.disconnectedGraceExtensions<1){this.disconnectedGraceExtensions+=1,console.warn("[WebRTCTransport] ice-grace expired \u2014 extending once before fail",{ice:a,conn:s,dcReadyState:c,extension:this.disconnectedGraceExtensions}),this.startIceDisconnectedGrace(e,n,t,`${i}:extended`);return}console.warn("[WebRTCTransport] ice-grace expired \u2014 marking failed",{ice:a,conn:s}),this.setState("failed");},d.ICE_DISCONNECTED_GRACE_MS);}}async sendIceRestartOffer(e,n){try{let t=await n.createOffer({iceRestart:!0});if(!this.isCurrentAttempt(e,void 0,n)||(await n.setLocalDescription(t),!this.isCurrentAttempt(e,void 0,n)))return;this.internalSignalSender?(await this.internalSignalSender({transport:"webrtc",type:"sdp",sdp:t,negotiationId:this.negotiationId??void 0}),d$2("[WebRTCTransport] ice-restart re-offer sent",{negotiationId:this.negotiationId})):console.warn("[WebRTCTransport] ice-restart re-offer dropped \u2014 no signal sender");}catch(t){console.warn("[WebRTCTransport] ice-restart re-offer failed",t);}}clearIceDisconnectedGrace(e){this.iceDisconnectedGraceTimer&&(clearTimeout(this.iceDisconnectedGraceTimer),this.iceDisconnectedGraceTimer=null);}promoteConnectedIfReady(e){let n=this.dc?.readyState??"missing";if(n!=="open"){d$2("[WebRTCTransport] Deferring connected state until DataChannel is open",{reason:e,dcReadyState:n,iceConnectionState:this.pc?.iceConnectionState,connectionState:this.pc?.connectionState});return}this.clearIceDisconnectedGrace(`connected:${e}`),this.disconnectedGraceExtensions=0,this.setState("connected");}closePeerResources(){this.activeAttemptId+=1,this.clearConnectTimeout(),this.clearIceDisconnectedGrace("close"),this.iceRestartAttempted=false,this.pendingCandidates=[],this._terminalFailure=false,this.negotiationId=null,this.disconnectedGraceExtensions=0,this.offerInFlight=false,this.dc&&(this.dc.onopen=null,this.dc.onmessage=null,this.dc.onclose=null,this.dc.onerror=null,this.dc.readyState!=="closed"&&this.dc.close(),this.dc=null),this.pc&&(this.pc.onicecandidate=null,this.pc.onnegotiationneeded=null,this.pc.onconnectionstatechange=null,this.pc.oniceconnectionstatechange=null,this.pc.connectionState!=="closed"&&this.pc.close(),this.pc=null);}isCurrentAttempt(e,n,t){return !(this.activeAttemptId!==e||n&&this.dc!==n||t&&this.pc!==t)}createNegotiationId(){return `ts-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}normalizeNegotiationId(e){if(typeof e!="string")return null;let n=e.trim();return n.length>0?n:null}};d.ICE_CONNECT_TIMEOUT_MS=A,d.ICE_DISCONNECTED_GRACE_MS=3e4;var h=d;var v={iroh:{available:false,reason:"iroh is constructed by the OpenRTC runtime, not the legacy ITransport factory."},"iroh-quic":{available:false,reason:"iroh-quic is a path label, not a standalone transport."},"iroh-relay":{available:false,reason:"iroh-relay is a path label, not a standalone transport."},"iroh-lan":{available:false,reason:"iroh-lan is a path label, not a standalone transport."},ble:{available:false,reason:"ble requires a separately licensed native host companion and current physical-device evidence."},webrtc:{available:true},"webrtc-lan":{available:false,reason:"webrtc-lan is a path label, not a standalone transport."},"webrtc-turn":{available:false,reason:"webrtc-turn is a path label, not a standalone transport."},moq:{available:false,reason:"MoQ is constructed by the route lifecycle, not the legacy ITransport factory."}};function I(r){return r.implementation==="route-adapter"?"plugin":r.implementation==="core"?"native":"path-label"}function w(){return Object.fromEntries(a.map(r=>[r.id,{...r,routeImplementation:r.implementation,implementation:I(r),protocol:r.id,preferredRank:d$1[r.id],...v[r.id]}]))}var f=class{static createTransport(e){if(this.assertProtocolAvailable(e),e==="webrtc")return new h;throw new Error(`[TransportFactory] '${e}' is not implemented as an ITransport plugin.`)}static getProtocolCapability(e){return {...this.capabilityMap[e]}}static getProtocolCapabilities(){return Object.fromEntries(a.map(e=>[e.id,this.getProtocolCapability(e.id)]))}static getPreferredProtocolOrder(e={}){let n=e.runtime??"any",t=e.includePathLabels??true;return a.filter(i=>t||i.implementation!=="path-label").filter(i=>n==="browser"?i.browser:n==="native"?i.native:i.browser||i.native).sort((i,a)=>d$1[i.id]-d$1[a.id]).map(i=>i.id)}static assertProtocolAvailable(e){let n=this.capabilityMap[e];if(!n.available||n.maturity==="unsupported"){let t=n.reason?` ${n.reason}`:"";throw new Error(`[TransportFactory] Protocol '${e}' is unsupported.${t}`)}}};f.capabilityMap=w();function _(r){return f.getPreferredProtocolOrder(r)}var g=32,S="openrtc:x25519-hkdf:v1",C=new TextEncoder().encode("openrtc:application-crypto:v1");function u(r,e){if(!(e instanceof Uint8Array)||e.byteLength!==g)throw new Error(`[OpenRTC] ${r} must be ${g} bytes`)}function E(r,e){let[n,t]=r<=e?[r,e]:[e,r],i=new TextEncoder().encode(n),a=new TextEncoder().encode(t),s=new Uint8Array(C.byteLength+1+i.byteLength+1+a.byteLength),c=0;return s.set(C,c),c+=C.byteLength,s[c]=0,c+=1,s.set(i,c),c+=i.byteLength,s[c]=0,c+=1,s.set(a,c),s}function K(r=e=>{let n=new Uint8Array(e);return globalThis.crypto.getRandomValues(n),n}){let e=r(g);return u("key agreement secret",e),{publicKey:x25519.getPublicKey(e),secretKey:e}}function U(r,e,n,t){u("key agreement local secret",r),u("key agreement remote public key",e);let i=x25519.getSharedSecret(r,e);return hkdf(sha256,i,void 0,E(n,t),32)}function $(r){return Array.from(sha256(r).slice(0,6),e=>e.toString(16).padStart(2,"0")).join("")}function F(r){u("key agreement public key",r);let e="";for(let t=0;t<r.byteLength;t+=1)e+=String.fromCharCode(r[t]);let n=btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return {algorithm:S,publicKey:n}}function k(r){if(!r||r.algorithm!==S)return null;let e=typeof r.publicKey=="string"?r.publicKey.trim():"";if(!e)return null;let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=n.length%4===0?n:n+"=".repeat(4-n.length%4),i=Uint8Array.from(atob(t),a=>a.charCodeAt(0));return i.byteLength!==g?null:i}
1
+ import {d as d$2,c}from'./chunk-PQK5SJ47.js';import {a,d as d$1}from'./chunk-C7YN5MSV.js';import {x25519}from'@noble/curves/ed25519.js';import {hkdf}from'@noble/hashes/hkdf.js';import {sha256}from'@noble/hashes/sha2.js';var A=3e4,d=class d{constructor(){this.name="webrtc";this.pc=null;this.dc=null;this.state="disconnected";this.pendingCandidates=[];this.connectTimeoutId=null;this.iceDisconnectedGraceTimer=null;this.iceRestartAttempted=false;this.localNodeId="";this.remoteNodeId="";this.candidatesGathered=0;this.sdpOfferSent=false;this.sdpAnswerReceived=false;this._terminalFailure=false;this.activeAttemptId=0;this.negotiationId=null;this.disconnectedGraceExtensions=0;this.offerInFlight=false;this.messageListeners=[];this.stateListeners=[];this.internalSignalSender=null;}get isReady(){return this.state==="connected"}isTerminalFailure(){return this._terminalFailure}getNegotiationId(){return this.negotiationId}getDataChannelReadyState(){return this.dc?.readyState??null}getNativeTransport(){return this.pc}setSignalSender(e){this.internalSignalSender=e;}async init(e,n,t){this.closePeerResources();let i=++this.activeAttemptId;this.localNodeId=e,this.remoteNodeId=n,this.candidatesGathered=0,this.sdpOfferSent=false,this.sdpAnswerReceived=false,this._terminalFailure=false,this.offerInFlight=false,this.pendingCandidates=[],this.disconnectedGraceExtensions=0,this.negotiationId=typeof t?.negotiationId=="string"&&t.negotiationId.trim().length>0?t.negotiationId.trim():this.createNegotiationId(),this.setState("connecting"),this.startConnectTimeout(i);let a=t.rtcConfig||{},s=typeof t?.forceRole=="string"&&(t.forceRole==="initiator"||t.forceRole==="responder")?t.forceRole:null,c=s?s==="initiator":e>n;d$2(`[WebRTCTransport] init \u2014 role=${c?"initiator":"responder"}`,{local:e.slice(0,12),remote:n.slice(0,12),negotiationId:this.negotiationId,forcedRole:s});try{d$2("[WebRTCTransport] Creating RTCPeerConnection",{iceServers:a.iceServers?.length??0}),this.pc=new RTCPeerConnection(a);}catch(R){console.error("[WebRTCTransport] RTCPeerConnection constructor failed",R),this.setState("failed");return}let T=this.pc.createDataChannel("pluto-dc",{negotiated:true,id:0});this.setupDataChannel(T,i),this.setupPCHandlers(c,i),c&&queueMicrotask(()=>{this.createAndSendOffer(i,"initial-initiator");});}setupDataChannel(e,n){this.dc=e,e.onopen=()=>{this.isCurrentAttempt(n,e)&&(d$2("[WebRTCTransport] DataChannel opened \u2014 upgrade complete"),this.promoteConnectedIfReady("datachannel-open"));},e.onmessage=t=>{if(!this.isCurrentAttempt(n,e))return;let i=typeof t.data=="string"?new TextEncoder().encode(t.data):new Uint8Array(t.data);this.messageListeners.forEach(a=>a(i));},e.onclose=()=>{this.isCurrentAttempt(n,e)&&(d$2("[WebRTCTransport] DataChannel closed"),(this.state==="connected"||this.state==="connecting")&&this.setState("disconnected"));},e.onerror=t=>{if(!this.isCurrentAttempt(n,e))return;console.warn("[WebRTCTransport] DataChannel error",t);let i=t?.error?.message??"";if((i.includes("User-Initiated Abort")||i.includes("Close called"))&&this.state==="connected"&&e.readyState!=="open"){console.warn("[WebRTCTransport] DataChannel aborted post-connect; forcing disconnected state",{readyState:e.readyState,connectionState:this.pc?.connectionState,iceConnectionState:this.pc?.iceConnectionState}),this.setState("disconnected");return}this.state==="connecting"&&this.setState("failed");};}setupPCHandlers(e,n){let t=this.pc;t&&(t.onicecandidate=i=>{this.isCurrentAttempt(n,void 0,t)&&(i.candidate?(this.candidatesGathered++,d$2(`[WebRTCTransport] ICE candidate #${this.candidatesGathered}: ${i.candidate.type} ${i.candidate.protocol} ${i.candidate.address??"?"}:${i.candidate.port}`),this.internalSignalSender?this.internalSignalSender({transport:"webrtc",type:"candidate",candidate:i.candidate,negotiationId:this.negotiationId??void 0}).catch(a=>{console.warn("[WebRTCTransport] Failed sending local ICE candidate signal",{error:a,gatheringState:t?.iceGatheringState,iceConnectionState:t?.iceConnectionState});}):console.warn("[WebRTCTransport] ICE candidate dropped \u2014 no signal sender!")):this.candidatesGathered===0?(console.warn("[WebRTCTransport] ICE gathering complete with 0 candidates \u2014 failing immediately.","If both peers are on the same page, WebRTC requires separate tabs or devices.",{local:this.localNodeId.slice(0,12),remote:this.remoteNodeId.slice(0,12)}),this._terminalFailure=true,this.setState("failed")):d$2(`[WebRTCTransport] ICE gathering complete \u2014 ${this.candidatesGathered} candidate(s)`));},t.onnegotiationneeded=async()=>{e&&await this.createAndSendOffer(n,"negotiationneeded");},t.onconnectionstatechange=()=>{if(!this.isCurrentAttempt(n,void 0,t))return;let i=t.connectionState;if(d$2(`[WebRTCTransport] Connection state: ${i}`),i==="connected")this.promoteConnectedIfReady("pc-connected");else if(i==="failed"){if(this.iceDisconnectedGraceTimer){console.warn("[WebRTCTransport] pc.connectionState=failed during grace window \u2014 deferring to grace timer",{iceState:t.iceConnectionState,iceRestartAttempted:this.iceRestartAttempted});return}console.error("[WebRTCTransport] Connection failed",{iceState:t.iceConnectionState,gatheringState:t.iceGatheringState,signalingState:t.signalingState,candidatesGathered:this.candidatesGathered,sdpOfferSent:this.sdpOfferSent,sdpAnswerReceived:this.sdpAnswerReceived}),this.clearIceDisconnectedGrace("pc-failed"),this.setState("failed");}else i==="closed"?(this.clearIceDisconnectedGrace("pc-closed"),this.setState("disconnected")):i==="disconnected"&&(d$2("[WebRTCTransport] pc.connectionState=disconnected, deferring to ICE grace period"),this.startIceDisconnectedGrace(n,t,e,"pc-disconnected"));},t.oniceconnectionstatechange=()=>{if(!this.isCurrentAttempt(n,void 0,t))return;let i=t.iceConnectionState;if(d$2(`[WebRTCTransport] ICE connection state: ${i}`,{gatheringState:t.iceGatheringState,signalingState:t.signalingState,candidatesGathered:this.candidatesGathered,hasSdpOffer:this.sdpOfferSent,hasSdpAnswer:this.sdpAnswerReceived,hasRemoteDescription:!!t.remoteDescription,hasLocalDescription:!!t.localDescription}),i==="failed"){if(this.iceDisconnectedGraceTimer){console.warn("[WebRTCTransport] ice failed during grace window \u2014 deferring to grace timer");return}console.error("[WebRTCTransport] ICE failed \u2014 likely NAT traversal issue or no matching candidates",{gatheringState:t.iceGatheringState,signalingState:t.signalingState,candidatesGathered:this.candidatesGathered}),this.clearIceDisconnectedGrace("ice-failed"),this.setState("failed");}else i==="disconnected"?this.startIceDisconnectedGrace(n,t,e,"ice-disconnected"):(i==="connected"||i==="completed")&&(this.iceDisconnectedGraceTimer&&d$2("[WebRTCTransport] ice-recovered \u2014 cancelling grace timer"),this.clearIceDisconnectedGrace("ice-recovered"),this.iceRestartAttempted=false,this.promoteConnectedIfReady("ice-connected"));},t.onicegatheringstatechange=()=>{this.isCurrentAttempt(n,void 0,t)&&d$2(`[WebRTCTransport] ICE gathering state: ${t.iceGatheringState}`,{iceConnectionState:t.iceConnectionState,signalingState:t.signalingState,hasLocalDesc:!!t.localDescription,hasRemoteDesc:!!t.remoteDescription});});}async createAndSendOffer(e,n){let t=this.pc;if(!(!t||!this.isCurrentAttempt(e,void 0,t))&&t.signalingState==="stable"&&!(this.sdpOfferSent&&t.localDescription?.type==="offer")&&!this.offerInFlight){d$2(`[WebRTCTransport] Creating offer (${n})`),this.offerInFlight=true;try{let i=await t.createOffer();if(await t.setLocalDescription(i),!this.isCurrentAttempt(e,void 0,t))return;if(this.sdpOfferSent=!0,this.internalSignalSender)try{await this.internalSignalSender({transport:"webrtc",type:"sdp",sdp:i,negotiationId:this.negotiationId??void 0});}catch(a){console.warn("[WebRTCTransport] Offer signaling failed (non-fatal)",{error:a,negotiationId:this.negotiationId,signalingState:t.signalingState,iceConnectionState:t.iceConnectionState});}else console.warn("[WebRTCTransport] No signal sender \u2014 offer not transmitted");}catch(i){console.error("[WebRTCTransport] Offer creation failed",i),this.closePeerResources(),this.setState("failed");}finally{this.isCurrentAttempt(e,void 0,t)&&(this.offerInFlight=false);}}}handleSignalingMessage(e){if(!this.pc||e.transport!=="webrtc")return;let n=this.normalizeNegotiationId(e?.negotiationId);if(n&&this.negotiationId&&n!==this.negotiationId){c("[WebRTCTransport] Ignoring stale signaling message for a different negotiation",{signalType:e?.type??null,signalNegotiationId:n,activeNegotiationId:this.negotiationId});return}if(e.type==="candidate"){let t=e.candidate;d$2("[WebRTCTransport] Received remote ICE candidate",{hasRemoteDesc:!!this.pc.remoteDescription,type:t?.type,protocol:t?.protocol,address:t?.address}),this.pc.remoteDescription?this.pc.addIceCandidate(t).catch(i=>{console.warn("[WebRTCTransport] addIceCandidate failed",i);}):(this.pendingCandidates.push(t),d$2(`[WebRTCTransport] Buffered remote candidate \u2014 ${this.pendingCandidates.length} pending`));}else if(e.type==="sdp"){let t=e.sdp,i=t.type==="offer",a=t.type==="answer";if(a&&this.pc.signalingState!=="have-local-offer"){c("[WebRTCTransport] Ignoring SDP answer because no local offer is pending",{signalingState:this.pc.signalingState,iceConnectionState:this.pc.iceConnectionState,signalNegotiationId:n,activeNegotiationId:this.negotiationId,hasLocalDescription:!!this.pc.localDescription,hasRemoteDescription:!!this.pc.remoteDescription});return}d$2(`[WebRTCTransport] Received SDP ${t.type} \u2014 applying remote description`),a&&(this.sdpAnswerReceived=true),this.pc.setRemoteDescription(t).then(async()=>{if(a&&(d$2("[WebRTCTransport] Remote SDP answer applied",{signalingState:this.pc?.signalingState,iceConnectionState:this.pc?.iceConnectionState,hasLocalDescription:!!this.pc?.localDescription,hasRemoteDescription:!!this.pc?.remoteDescription}),this.promoteConnectedIfReady("sdp-answer-applied")),this.pendingCandidates.length&&(d$2(`[WebRTCTransport] Flushing ${this.pendingCandidates.length} buffered candidate(s)`),this.pendingCandidates.forEach(s=>this.pc?.addIceCandidate(s)),this.pendingCandidates=[]),i){d$2("[WebRTCTransport] Creating answer (responder)");let s=await this.pc.createAnswer();if(await this.pc.setLocalDescription(s),d$2("[WebRTCTransport] Answer sent"),this.internalSignalSender)try{await this.internalSignalSender({transport:"webrtc",type:"sdp",sdp:s,negotiationId:n??this.negotiationId??void 0});}catch(c){throw console.warn("[WebRTCTransport] Failed sending SDP answer signal",{error:c,signalingState:this.pc?.signalingState,hasLocalDescription:!!this.pc?.localDescription,hasRemoteDescription:!!this.pc?.remoteDescription}),c}else console.warn("[WebRTCTransport] No signal sender \u2014 answer not transmitted");}}).catch(s=>{console.error(`[WebRTCTransport] setRemoteDescription (${t.type}) failed`,s),this.setState("failed");});}}async send(e){if(this.dc&&this.dc.readyState==="open"){let n=new Uint8Array(e);this.dc.send(n);}else throw new Error("WebRTC DataChannel not open")}getBufferedAmount(){return this.dc?.bufferedAmount??0}async waitForDrain(e){!this.dc||this.dc.bufferedAmount<=e||await new Promise(n=>{let t=this.dc;if(!t){n();return}t.bufferedAmountLowThreshold=e,t.onbufferedamountlow=()=>{t.onbufferedamountlow=null,n();};});}close(){this.closePeerResources(),this.setState("disconnected");}onMessage(e){this.messageListeners.push(e);}onStateChange(e){this.stateListeners.push(e);}setState(e){this.state!==e&&(this.state=e,(e==="connected"||e==="failed"||e==="disconnected")&&this.clearConnectTimeout(),this.stateListeners.forEach(n=>n(e)));}startConnectTimeout(e){this.clearConnectTimeout(),this.connectTimeoutId=setTimeout(()=>{this.activeAttemptId===e&&this.state==="connecting"&&(console.warn(`[WebRTCTransport] Timed out after ${d.ICE_CONNECT_TIMEOUT_MS}ms`,{iceState:this.pc?.iceConnectionState,gatheringState:this.pc?.iceGatheringState,signalingState:this.pc?.signalingState,candidatesGathered:this.candidatesGathered,sdpOfferSent:this.sdpOfferSent,sdpAnswerReceived:this.sdpAnswerReceived,hasRemoteDescription:!!this.pc?.remoteDescription,hasLocalDescription:!!this.pc?.localDescription}),this.setState("failed"));},d.ICE_CONNECT_TIMEOUT_MS);}clearConnectTimeout(){this.connectTimeoutId&&(clearTimeout(this.connectTimeoutId),this.connectTimeoutId=null);}startIceDisconnectedGrace(e,n,t,i){if(!this.iceDisconnectedGraceTimer){if(this.iceRestartAttempted)d$2("[WebRTCTransport] ice-disconnected grace (restart already attempted)",{reason:i});else if(this.iceRestartAttempted=true,t){try{d$2("[WebRTCTransport] ice-restart-attempted",{reason:i,isInitiator:t}),n.restartIce();}catch(a){console.warn("[WebRTCTransport] restartIce threw",a);}this.sendIceRestartOffer(e,n);}else d$2("[WebRTCTransport] ice-restart deferred to initiator",{reason:i});this.iceDisconnectedGraceTimer=setTimeout(()=>{if(this.iceDisconnectedGraceTimer=null,this.activeAttemptId!==e||this.pc!==n)return;let a=n.iceConnectionState,s=n.connectionState,c=this.dc?.readyState??"missing";if(a==="connected"||a==="completed"||s==="connected"||c==="open"){d$2("[WebRTCTransport] ice-grace expired \u2014 recovered",{ice:a,conn:s,dcReadyState:c});return}if(this.disconnectedGraceExtensions<1){this.disconnectedGraceExtensions+=1,console.warn("[WebRTCTransport] ice-grace expired \u2014 extending once before fail",{ice:a,conn:s,dcReadyState:c,extension:this.disconnectedGraceExtensions}),this.startIceDisconnectedGrace(e,n,t,`${i}:extended`);return}console.warn("[WebRTCTransport] ice-grace expired \u2014 marking failed",{ice:a,conn:s}),this.setState("failed");},d.ICE_DISCONNECTED_GRACE_MS);}}async sendIceRestartOffer(e,n){try{let t=await n.createOffer({iceRestart:!0});if(!this.isCurrentAttempt(e,void 0,n)||(await n.setLocalDescription(t),!this.isCurrentAttempt(e,void 0,n)))return;this.internalSignalSender?(await this.internalSignalSender({transport:"webrtc",type:"sdp",sdp:t,negotiationId:this.negotiationId??void 0}),d$2("[WebRTCTransport] ice-restart re-offer sent",{negotiationId:this.negotiationId})):console.warn("[WebRTCTransport] ice-restart re-offer dropped \u2014 no signal sender");}catch(t){console.warn("[WebRTCTransport] ice-restart re-offer failed",t);}}clearIceDisconnectedGrace(e){this.iceDisconnectedGraceTimer&&(clearTimeout(this.iceDisconnectedGraceTimer),this.iceDisconnectedGraceTimer=null);}promoteConnectedIfReady(e){let n=this.dc?.readyState??"missing";if(n!=="open"){d$2("[WebRTCTransport] Deferring connected state until DataChannel is open",{reason:e,dcReadyState:n,iceConnectionState:this.pc?.iceConnectionState,connectionState:this.pc?.connectionState});return}this.clearIceDisconnectedGrace(`connected:${e}`),this.disconnectedGraceExtensions=0,this.setState("connected");}closePeerResources(){this.activeAttemptId+=1,this.clearConnectTimeout(),this.clearIceDisconnectedGrace("close"),this.iceRestartAttempted=false,this.pendingCandidates=[],this._terminalFailure=false,this.negotiationId=null,this.disconnectedGraceExtensions=0,this.offerInFlight=false,this.dc&&(this.dc.onopen=null,this.dc.onmessage=null,this.dc.onclose=null,this.dc.onerror=null,this.dc.readyState!=="closed"&&this.dc.close(),this.dc=null),this.pc&&(this.pc.onicecandidate=null,this.pc.onnegotiationneeded=null,this.pc.onconnectionstatechange=null,this.pc.oniceconnectionstatechange=null,this.pc.connectionState!=="closed"&&this.pc.close(),this.pc=null);}isCurrentAttempt(e,n,t){return !(this.activeAttemptId!==e||n&&this.dc!==n||t&&this.pc!==t)}createNegotiationId(){return `ts-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}normalizeNegotiationId(e){if(typeof e!="string")return null;let n=e.trim();return n.length>0?n:null}};d.ICE_CONNECT_TIMEOUT_MS=A,d.ICE_DISCONNECTED_GRACE_MS=3e4;var h=d;var v={iroh:{available:false,reason:"iroh is constructed by the OpenRTC runtime, not the legacy ITransport factory."},"iroh-quic":{available:false,reason:"iroh-quic is a path label, not a standalone transport."},"iroh-relay":{available:false,reason:"iroh-relay is a path label, not a standalone transport."},"iroh-lan":{available:false,reason:"iroh-lan is a path label, not a standalone transport."},ble:{available:false,reason:"ble requires a separately licensed native host companion and current physical-device evidence."},webrtc:{available:true},"webrtc-lan":{available:false,reason:"webrtc-lan is a path label, not a standalone transport."},"webrtc-turn":{available:false,reason:"webrtc-turn is a path label, not a standalone transport."},moq:{available:false,reason:"MoQ is constructed by the route lifecycle, not the legacy ITransport factory."}};function I(r){return r.implementation==="route-adapter"?"plugin":r.implementation==="core"?"native":"path-label"}function w(){return Object.fromEntries(a.map(r=>[r.id,{...r,routeImplementation:r.implementation,implementation:I(r),protocol:r.id,preferredRank:d$1[r.id],...v[r.id]}]))}var f=class{static createTransport(e){if(this.assertProtocolAvailable(e),e==="webrtc")return new h;throw new Error(`[TransportFactory] '${e}' is not implemented as an ITransport plugin.`)}static getProtocolCapability(e){return {...this.capabilityMap[e]}}static getProtocolCapabilities(){return Object.fromEntries(a.map(e=>[e.id,this.getProtocolCapability(e.id)]))}static getPreferredProtocolOrder(e={}){let n=e.runtime??"any",t=e.includePathLabels??true;return a.filter(i=>t||i.implementation!=="path-label").filter(i=>n==="browser"?i.browser:n==="native"?i.native:i.browser||i.native).sort((i,a)=>d$1[i.id]-d$1[a.id]).map(i=>i.id)}static assertProtocolAvailable(e){let n=this.capabilityMap[e];if(!n.available||n.maturity==="unsupported"){let t=n.reason?` ${n.reason}`:"";throw new Error(`[TransportFactory] Protocol '${e}' is unsupported.${t}`)}}};f.capabilityMap=w();function _(r){return f.getPreferredProtocolOrder(r)}var g=32,S="openrtc:x25519-hkdf:v1",C=new TextEncoder().encode("openrtc:application-crypto:v1");function u(r,e){if(!(e instanceof Uint8Array)||e.byteLength!==g)throw new Error(`[OpenRTC] ${r} must be ${g} bytes`)}function E(r,e){let[n,t]=r<=e?[r,e]:[e,r],i=new TextEncoder().encode(n),a=new TextEncoder().encode(t),s=new Uint8Array(C.byteLength+1+i.byteLength+1+a.byteLength),c=0;return s.set(C,c),c+=C.byteLength,s[c]=0,c+=1,s.set(i,c),c+=i.byteLength,s[c]=0,c+=1,s.set(a,c),s}function K(r=e=>{let n=new Uint8Array(e);return globalThis.crypto.getRandomValues(n),n}){let e=r(g);return u("key agreement secret",e),{publicKey:x25519.getPublicKey(e),secretKey:e}}function U(r,e,n,t){u("key agreement local secret",r),u("key agreement remote public key",e);let i=x25519.getSharedSecret(r,e);return hkdf(sha256,i,void 0,E(n,t),32)}function $(r){return Array.from(sha256(r).slice(0,6),e=>e.toString(16).padStart(2,"0")).join("")}function F(r){u("key agreement public key",r);let e="";for(let t=0;t<r.byteLength;t+=1)e+=String.fromCharCode(r[t]);let n=btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return {algorithm:S,publicKey:n}}function k(r){if(!r||r.algorithm!==S)return null;let e=typeof r.publicKey=="string"?r.publicKey.trim():"";if(!e)return null;let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=n.length%4===0?n:n+"=".repeat(4-n.length%4),i=Uint8Array.from(atob(t),a=>a.charCodeAt(0));return i.byteLength!==g?null:i}
2
2
  export{A as a,f as b,_ as c,g as d,S as e,K as f,U as g,$ as h,F as i,k as j};
@@ -1 +1 @@
1
- import {t}from'./chunk-YBXGNKM7.js';var a=class{constructor(e){this.backend=e;}get currentUser(){return this.backend.currentUser}setAuthContext(e){return this.backend.setAuthContext?.(e)}async signInAnonymously(){return this.backend.signInAnonymously()}async signInWithPluto(){if(typeof this.backend.signInWithPluto!="function")throw new Error("Selected runtime adapter does not support Pluto SSO.");return this.backend.signInWithPluto()}async signOut(){return this.backend.signOut()}async stopAuthScopedActivity(){typeof this.backend.stopAuthScopedActivity=="function"&&await this.backend.stopAuthScopedActivity();}usesCoordinationGateway(){return this.backend.usesCoordinationGateway?.()===true}async joinCoordinationRoom(e,n,t){if(!this.backend.joinCoordinationRoom)throw new Error("Selected runtime adapter does not support coordination rooms.");await this.backend.joinCoordinationRoom(e,n,t);}async leaveCoordinationRoom(e){if(!this.backend.leaveCoordinationRoom)throw new Error("Selected runtime adapter does not support coordination rooms.");await this.backend.leaveCoordinationRoom(e);}async getCoordinationRoomMembers(e){if(!this.backend.getCoordinationRoomMembers)throw new Error("Selected runtime adapter does not support coordination rooms.");return this.backend.getCoordinationRoomMembers(e)}watchCoordinationRoomMembers(e,n){if(!this.backend.watchCoordinationRoomMembers)throw new Error("Selected runtime adapter does not support coordination rooms.");return this.backend.watchCoordinationRoomMembers(e,n)}async getTurnCredentials(){return this.backend.getTurnCredentials()}async updatePresence(e,n,t,i,r){return this.backend.updatePresence(e,n,t,i,r)}async refreshLivePresence(e,n,t){if(typeof this.backend.refreshLivePresence!="function")throw new Error("Selected runtime adapter does not support refreshLivePresence().");return this.backend.refreshLivePresence(e,n,t)}async setOffline(e){return this.backend.setOffline(e)}async cleanupStaleDevices(){return this.backend.cleanupStaleDevices()}async searchDevices(e){return this.backend.searchDevices(e)}async listDevicesWithStatus(){if(typeof this.backend.listDevicesWithStatus!="function")throw new Error("Selected runtime adapter does not support listDevicesWithStatus().");return this.backend.listDevicesWithStatus()}async getPeerSession(e){return typeof this.backend.getPeerSession!="function"?null:this.backend.getPeerSession(e)}async listPeerSessions(){return typeof this.backend.listPeerSessions!="function"?[]:this.backend.listPeerSessions()}async waitForSettledPeer(e,n){return typeof this.backend.waitForSettledPeer!="function"?null:this.backend.waitForSettledPeer(e,n)}async resolvePeerIdentity(e){return typeof this.backend.resolvePeerIdentity!="function"?{peerId:null,deviceId:null,deviceIdHint:null,nodeId:null}:this.backend.resolvePeerIdentity(e)}async resolvePeerConnectionRecords(e){return typeof this.backend.resolvePeerConnectionRecords!="function"?[]:this.backend.resolvePeerConnectionRecords(e)}async updateDevice(e,n){return this.backend.updateDevice(e,n)}async deleteDevice(e){return this.backend.deleteDevice(e)}onDevicesChange(e,n){return this.backend.onDevicesChange(e,n)}onAuthChange(e){return this.backend.onAuthChange(e)}async checkForSSOToken(){return this.backend.checkForSSOToken()}async waitForAuth(){return this.backend.waitForAuth()}async sendMessage(e,n,t,i){return this.backend.sendMessage(e,n,t,i)}async pollMessages(e){return this.backend.pollMessages(e)}watchFriendDevices(e,n){let t=this.backend;return t.watchFriendDevices?t.watchFriendDevices(e,n):()=>{}}async updateFriendTicket(e){let n=this.backend;n.updateFriendTicket&&await n.updateFriendTicket(e);}async subscribeDevices(e){return this.backend.subscribeDevices(e)}startAutoConnect(e,n){this.backend.startAutoConnect(e,n);}async submitDesiredPeerProjection(e,n){if(typeof this.backend.submitDesiredPeerProjection!="function")throw new Error("Selected runtime adapter does not support desired-peer projections.");await this.backend.submitDesiredPeerProjection(e,n);}startPresenceLoop(e,n,t,i,r){this.backend.startPresenceLoop(e,n,t,i,r);}async createSession(e){return this.backend.createSession(e)}async updateSession(e,n){return this.backend.updateSession(e,n)}async subscribeSessions(e){return this.backend.subscribeSessions(e)}forceReconnectSnapshot(){this.backend.forceReconnectSnapshot();}async getLocalDeviceId(){return typeof this.backend.getLocalDeviceId!="function"?null:this.backend.getLocalDeviceId()}async getLocalDeviceInfo(){return typeof this.backend.getLocalDeviceInfo!="function"?null:this.backend.getLocalDeviceInfo()}async updateLocalDeviceName(e){return typeof this.backend.updateLocalDeviceName!="function"?null:this.backend.updateLocalDeviceName(e)}async startManagedSessionNative(e){let n=this.backend;if(typeof n.startManagedSessionNative!="function")throw new Error("Selected runtime adapter does not support startManagedSessionNative().");return n.startManagedSessionNative(e)}async notifyNetworkChange(e){return typeof this.backend.notifyNetworkChange!="function"?null:this.backend.notifyNetworkChange(e)}async getManagedNodeId(e){if(console.info("[DelegatingRuntimeAdapter][getManagedNodeId] enter",{hasMethod:typeof this.backend.getManagedNodeId=="function",backendCtor:this.backend.constructor?.name??null}),typeof this.backend.getManagedNodeId!="function")return null;let n=await this.backend.getManagedNodeId(e);return console.info("[DelegatingRuntimeAdapter][getManagedNodeId] resolved",{result:n}),n}async startPresenceLoopOnce(e,n,t,i,r){let o=this.backend;if(typeof o.startPresenceLoopOnce!="function")throw new Error("Selected runtime adapter does not support startPresenceLoopOnce().");return o.startPresenceLoopOnce(e,n,t,i,r)}async startAutoConnectOnce(e,n){let t=this.backend;if(typeof t.startAutoConnectOnce!="function")throw new Error("Selected runtime adapter does not support startAutoConnectOnce().");return t.startAutoConnectOnce(e,n)}async getEndpointTicket(){if(typeof this.backend.getEndpointTicket!="function")throw new Error("Selected runtime adapter does not support getEndpointTicket().");return this.backend.getEndpointTicket()}async getEndpointTicketWithToken(e,n){let t=this.backend;return typeof t.getEndpointTicketWithToken!="function"?null:t.getEndpointTicketWithToken(e,n)}async registerSessionToken(e,n,t){let i=this.backend;typeof i.registerSessionToken=="function"&&await i.registerSessionToken(e,n,t);}async revokeSessionTokensByScope(e){let n=this.backend;return typeof n.revokeSessionTokensByScope!="function"?[]:n.revokeSessionTokensByScope(e)}async openPeerBi(e,n){if(typeof this.backend.openPeerBi!="function")throw new Error("Selected runtime adapter does not support openPeerBi().");return this.backend.openPeerBi(e,n)}async incoming_streams(){let e=this.backend;if(typeof e.incoming_streams!="function")throw new Error("Selected runtime adapter does not support incoming_streams().");return e.incoming_streams()}async is_current_transport_stable_id(e,n){let t=this.backend;return typeof t.is_current_transport_stable_id!="function"?false:t.is_current_transport_stable_id(e,n)}async openPeerNativeBi(e,n,t){let i=this.backend;if(typeof i.openPeerNativeBi!="function")throw new Error("Selected runtime adapter does not support openPeerNativeBi().");return i.openPeerNativeBi(e,n,t)}async openPeerBiTransportOnly(e,n){let t=this.backend;return typeof t.openPeerBiTransportOnly=="function"?t.openPeerBiTransportOnly(e,n):this.openPeerBi(e,n)}async openPeerUni(e,n){if(typeof this.backend.openPeerUni!="function")throw new Error("Selected runtime adapter does not support openPeerUni().");return this.backend.openPeerUni(e,n)}async connectToDevice(e){if(typeof this.backend.connectToDevice!="function")throw new Error("Selected runtime adapter does not support connectToDevice().");return this.backend.connectToDevice(e)}async disconnectDevice(e){if(typeof this.backend.disconnectDevice!="function")throw new Error("Selected runtime adapter does not support disconnectDevice().");return this.backend.disconnectDevice(e)}async setAutoConnectExcluded(e,n){if(typeof this.backend.setAutoConnectExcluded!="function")throw new Error("Selected runtime adapter does not support setAutoConnectExcluded().");return this.backend.setAutoConnectExcluded(e,n)}async isConnected(e){return this.backend.isConnected(e)}async getConnectionStates(){return typeof this.backend.getConnectionStates!="function"?[]:this.backend.getConnectionStates()}onConnectionStateChange(e){return typeof this.backend.onConnectionStateChange!="function"?()=>{}:this.backend.onConnectionStateChange(e)}async sendExplicitFilePath(e,n,t){if(typeof this.backend.sendExplicitFilePath!="function")throw new Error("Selected runtime adapter does not support sendExplicitFilePath().");return this.backend.sendExplicitFilePath(e,n,t)}async sendExplicitFileData(e){if(typeof this.backend.sendExplicitFileData!="function")throw new Error("Selected runtime adapter does not support sendExplicitFileData().");return this.backend.sendExplicitFileData(e)}async getTransferHistory(e){return typeof this.backend.getTransferHistory!="function"?[]:this.backend.getTransferHistory(e)}async deleteTransferJob(e){if(typeof this.backend.deleteTransferJob=="function")return this.backend.deleteTransferJob(e)}getRuntimeCapabilities(){let e=this.backend;return typeof e.getRuntimeCapabilities=="function"?e.getRuntimeCapabilities():t()}async onIncomingNativeMessage(e){let n=this.backend;return typeof n.onIncomingNativeMessage!="function"?()=>{}:n.onIncomingNativeMessage(e)}unwrap(){return this.backend}setCoreClient(e){let n=this.backend;typeof n.setCoreClient=="function"&&n.setCoreClient(e);}};export{a};
1
+ import {v}from'./chunk-FAPRYEWI.js';var a=class{constructor(e){this.backend=e;}get currentUser(){return this.backend.currentUser}setAuthContext(e){return this.backend.setAuthContext?.(e)}async signInAnonymously(){return this.backend.signInAnonymously()}async signInWithPluto(){if(typeof this.backend.signInWithPluto!="function")throw new Error("Selected runtime adapter does not support Pluto SSO.");return this.backend.signInWithPluto()}async signOut(){return this.backend.signOut()}async stopAuthScopedActivity(){typeof this.backend.stopAuthScopedActivity=="function"&&await this.backend.stopAuthScopedActivity();}usesCoordinationGateway(){return this.backend.usesCoordinationGateway?.()===true}async joinCoordinationRoom(e,n,t){if(!this.backend.joinCoordinationRoom)throw new Error("Selected runtime adapter does not support coordination rooms.");await this.backend.joinCoordinationRoom(e,n,t);}async leaveCoordinationRoom(e){if(!this.backend.leaveCoordinationRoom)throw new Error("Selected runtime adapter does not support coordination rooms.");await this.backend.leaveCoordinationRoom(e);}async getCoordinationRoomMembers(e){if(!this.backend.getCoordinationRoomMembers)throw new Error("Selected runtime adapter does not support coordination rooms.");return this.backend.getCoordinationRoomMembers(e)}watchCoordinationRoomMembers(e,n){if(!this.backend.watchCoordinationRoomMembers)throw new Error("Selected runtime adapter does not support coordination rooms.");return this.backend.watchCoordinationRoomMembers(e,n)}async getTurnCredentials(){return this.backend.getTurnCredentials()}async updatePresence(e,n,t,i,r){return this.backend.updatePresence(e,n,t,i,r)}async refreshLivePresence(e,n,t){if(typeof this.backend.refreshLivePresence!="function")throw new Error("Selected runtime adapter does not support refreshLivePresence().");return this.backend.refreshLivePresence(e,n,t)}async setOffline(e){return this.backend.setOffline(e)}async cleanupStaleDevices(){return this.backend.cleanupStaleDevices()}async searchDevices(e){return this.backend.searchDevices(e)}async listDevicesWithStatus(){if(typeof this.backend.listDevicesWithStatus!="function")throw new Error("Selected runtime adapter does not support listDevicesWithStatus().");return this.backend.listDevicesWithStatus()}async getPeerSession(e){return typeof this.backend.getPeerSession!="function"?null:this.backend.getPeerSession(e)}async listPeerSessions(){return typeof this.backend.listPeerSessions!="function"?[]:this.backend.listPeerSessions()}async waitForSettledPeer(e,n){return typeof this.backend.waitForSettledPeer!="function"?null:this.backend.waitForSettledPeer(e,n)}async resolvePeerIdentity(e){return typeof this.backend.resolvePeerIdentity!="function"?{peerId:null,deviceId:null,deviceIdHint:null,nodeId:null}:this.backend.resolvePeerIdentity(e)}async resolvePeerConnectionRecords(e){return typeof this.backend.resolvePeerConnectionRecords!="function"?[]:this.backend.resolvePeerConnectionRecords(e)}async updateDevice(e,n){return this.backend.updateDevice(e,n)}async deleteDevice(e){return this.backend.deleteDevice(e)}onDevicesChange(e,n){return this.backend.onDevicesChange(e,n)}onAuthChange(e){return this.backend.onAuthChange(e)}async checkForSSOToken(){return this.backend.checkForSSOToken()}async waitForAuth(){return this.backend.waitForAuth()}async sendMessage(e,n,t,i){return this.backend.sendMessage(e,n,t,i)}async pollMessages(e){return this.backend.pollMessages(e)}watchFriendDevices(e,n){let t=this.backend;return t.watchFriendDevices?t.watchFriendDevices(e,n):()=>{}}async updateFriendTicket(e){let n=this.backend;n.updateFriendTicket&&await n.updateFriendTicket(e);}async subscribeDevices(e){return this.backend.subscribeDevices(e)}startAutoConnect(e,n){this.backend.startAutoConnect(e,n);}async submitDesiredPeerProjection(e,n){if(typeof this.backend.submitDesiredPeerProjection!="function")throw new Error("Selected runtime adapter does not support desired-peer projections.");await this.backend.submitDesiredPeerProjection(e,n);}startPresenceLoop(e,n,t,i,r){this.backend.startPresenceLoop(e,n,t,i,r);}async createSession(e){return this.backend.createSession(e)}async updateSession(e,n){return this.backend.updateSession(e,n)}async subscribeSessions(e){return this.backend.subscribeSessions(e)}forceReconnectSnapshot(){this.backend.forceReconnectSnapshot();}async getLocalDeviceId(){return typeof this.backend.getLocalDeviceId!="function"?null:this.backend.getLocalDeviceId()}async getLocalDeviceInfo(){return typeof this.backend.getLocalDeviceInfo!="function"?null:this.backend.getLocalDeviceInfo()}async updateLocalDeviceName(e){return typeof this.backend.updateLocalDeviceName!="function"?null:this.backend.updateLocalDeviceName(e)}async startManagedSessionNative(e){let n=this.backend;if(typeof n.startManagedSessionNative!="function")throw new Error("Selected runtime adapter does not support startManagedSessionNative().");return n.startManagedSessionNative(e)}async notifyNetworkChange(e){return typeof this.backend.notifyNetworkChange!="function"?null:this.backend.notifyNetworkChange(e)}async getManagedNodeId(e){if(console.info("[DelegatingRuntimeAdapter][getManagedNodeId] enter",{hasMethod:typeof this.backend.getManagedNodeId=="function",backendCtor:this.backend.constructor?.name??null}),typeof this.backend.getManagedNodeId!="function")return null;let n=await this.backend.getManagedNodeId(e);return console.info("[DelegatingRuntimeAdapter][getManagedNodeId] resolved",{result:n}),n}async startPresenceLoopOnce(e,n,t,i,r){let o=this.backend;if(typeof o.startPresenceLoopOnce!="function")throw new Error("Selected runtime adapter does not support startPresenceLoopOnce().");return o.startPresenceLoopOnce(e,n,t,i,r)}async startAutoConnectOnce(e,n){let t=this.backend;if(typeof t.startAutoConnectOnce!="function")throw new Error("Selected runtime adapter does not support startAutoConnectOnce().");return t.startAutoConnectOnce(e,n)}async getEndpointTicket(){if(typeof this.backend.getEndpointTicket!="function")throw new Error("Selected runtime adapter does not support getEndpointTicket().");return this.backend.getEndpointTicket()}async getEndpointTicketWithToken(e,n){let t=this.backend;return typeof t.getEndpointTicketWithToken!="function"?null:t.getEndpointTicketWithToken(e,n)}async registerSessionToken(e,n,t,i){let r=this.backend;typeof r.registerSessionToken=="function"&&await r.registerSessionToken(e,n,t,i);}async revokeSessionTokensByScope(e){let n=this.backend;return typeof n.revokeSessionTokensByScope!="function"?[]:n.revokeSessionTokensByScope(e)}async openPeerBi(e,n){if(typeof this.backend.openPeerBi!="function")throw new Error("Selected runtime adapter does not support openPeerBi().");return this.backend.openPeerBi(e,n)}async incoming_streams(){let e=this.backend;if(typeof e.incoming_streams!="function")throw new Error("Selected runtime adapter does not support incoming_streams().");return e.incoming_streams()}async is_current_transport_stable_id(e,n){let t=this.backend;return typeof t.is_current_transport_stable_id!="function"?false:t.is_current_transport_stable_id(e,n)}async openPeerNativeBi(e,n,t){let i=this.backend;if(typeof i.openPeerNativeBi!="function")throw new Error("Selected runtime adapter does not support openPeerNativeBi().");return i.openPeerNativeBi(e,n,t)}async openPeerBiTransportOnly(e,n){let t=this.backend;return typeof t.openPeerBiTransportOnly=="function"?t.openPeerBiTransportOnly(e,n):this.openPeerBi(e,n)}async openPeerUni(e,n){if(typeof this.backend.openPeerUni!="function")throw new Error("Selected runtime adapter does not support openPeerUni().");return this.backend.openPeerUni(e,n)}async connectToDevice(e){if(typeof this.backend.connectToDevice!="function")throw new Error("Selected runtime adapter does not support connectToDevice().");return this.backend.connectToDevice(e)}async disconnectDevice(e){if(typeof this.backend.disconnectDevice!="function")throw new Error("Selected runtime adapter does not support disconnectDevice().");return this.backend.disconnectDevice(e)}async setAutoConnectExcluded(e,n){if(typeof this.backend.setAutoConnectExcluded!="function")throw new Error("Selected runtime adapter does not support setAutoConnectExcluded().");return this.backend.setAutoConnectExcluded(e,n)}async isConnected(e){return this.backend.isConnected(e)}async getConnectionStates(){return typeof this.backend.getConnectionStates!="function"?[]:this.backend.getConnectionStates()}onConnectionStateChange(e){return typeof this.backend.onConnectionStateChange!="function"?()=>{}:this.backend.onConnectionStateChange(e)}async sendExplicitFilePath(e,n,t){if(typeof this.backend.sendExplicitFilePath!="function")throw new Error("Selected runtime adapter does not support sendExplicitFilePath().");return this.backend.sendExplicitFilePath(e,n,t)}async sendExplicitFileData(e){if(typeof this.backend.sendExplicitFileData!="function")throw new Error("Selected runtime adapter does not support sendExplicitFileData().");return this.backend.sendExplicitFileData(e)}async getTransferHistory(e){return typeof this.backend.getTransferHistory!="function"?[]:this.backend.getTransferHistory(e)}async deleteTransferJob(e){if(typeof this.backend.deleteTransferJob=="function")return this.backend.deleteTransferJob(e)}getRuntimeCapabilities(){let e=this.backend;return typeof e.getRuntimeCapabilities=="function"?e.getRuntimeCapabilities():v()}async onIncomingNativeMessage(e){let n=this.backend;return typeof n.onIncomingNativeMessage!="function"?()=>{}:n.onIncomingNativeMessage(e)}unwrap(){return this.backend}setCoreClient(e){let n=this.backend;typeof n.setCoreClient=="function"&&n.setCoreClient(e);}};export{a};
@@ -0,0 +1 @@
1
+ function o(n){let e=String(n?.message??n??"").toLowerCase();return e?e.includes("__tauri_internals__")||e.includes("window is not defined")||e.includes("cannot read properties of undefined")?"runtime-unavailable":e.includes("timeout after")?"timeout":e.includes("not found")||e.includes("not allowed")||e.includes("unknown command")||e.includes("plugin not found")||e.includes("plugin:openrtc-tauri-plugin")?"command-unavailable":"unknown":"unknown"}function s(n){return o(n)==="command-unavailable"}function u(n,e="native runtime"){if(!n||typeof n!="object")throw new Error(`[openrtc] ${e} requires a valid IPC bridge object.`);if(typeof n.invoke!="function")throw new Error(`[openrtc] ${e} IPC bridge is missing invoke(command, args).`);if(typeof n.listen!="function")throw new Error(`[openrtc] ${e} IPC bridge is missing listen(event, handler).`);return n}var t=null;async function l(){return t||(t=(async()=>{let n="openrtc-tauri",e="../../../tauri/src/runtime/ipc";try{return await import(n)}catch(r){try{return await import(e)}catch(i){let a=new Error("[openrtc] Native support now lives in the first-party `openrtc-tauri` package. Install `openrtc-tauri` (and `@tauri-apps/api`) or pass an explicit IPC bridge to OpenRTC.native(...).");throw a.cause={packageError:r,workspaceError:i},a}}})()),t}function c(){let n=null,e=async()=>(n||(n=l().then(r=>u(r.createTauriIpcBridge(),"openrtc-tauri"))),n);return {async invoke(r,i){return (await e()).invoke(r,i)},async listen(r,i){return (await e()).listen(r,i)},async isAvailable(){try{let r=await e();return typeof r.isAvailable=="function"?!!await r.isAvailable():!0}catch{return false}}}}export{o as a,s as b,u as c,c as d};
@@ -0,0 +1 @@
1
+ function a(e){let t=e.split(".")[1];if(!t)throw new Error("OpenRTC returned a malformed credential.");let r=t.replace(/-/g,"+").replace(/_/g,"/");return String(JSON.parse(atob(r.padEnd(Math.ceil(r.length/4)*4,"="))).jti??"")}async function d(e){if(e.source.type!=="device-certificate")throw new Error("Device management requires an authenticated device certificate.");let t=async r=>{let c=a(r.token),n=await(await e.key()).proof((i,o)=>["openrtc:v2:device-management",c,e.action,e.targetDeviceId??"",e.exceptCurrent?"except-current":"include-current",i,o].join(":"));return e.post({action:e.action,deviceCertificate:r.token,currentDeviceId:e.currentDeviceId,...e.targetDeviceId?{targetDeviceId:e.targetDeviceId}:{},...e.exceptCurrent?{exceptCurrent:true}:{},deviceProof:n})};try{return await t(e.source)}catch(r){if(!e.isStale(r))throw r;let c=await e.source.recoverRejectedCertificate?.();if(!c)throw r;return t(c)}}export{d as manageDevice};
@@ -0,0 +1,2 @@
1
+ function c(t){let n=t?.trim();if(n){if(new TextEncoder().encode(n).byteLength>4*1024)throw new Error("[OpenRTC] Device profile metadata must not exceed 4 KiB.");return n}}function d(t,n,e){let i=t?.trim();if(i){if(i.length>e||/[\u0000-\u001f\u007f]/u.test(i))throw new Error(`[OpenRTC] Device profile ${n} is invalid.`);return i}}function p(t=typeof navigator>"u"?void 0:navigator){if(!t)return {name:"Web Browser",platform:"web"};let n=t,e=n.userAgent??"",i=`${n.userAgentData?.platform??""} ${n.platform??""}`.toLowerCase(),m=/ipad/i.test(e)||i.includes("mac")&&Number(n.maxTouchPoints??0)>1,r=/android/i.test(e)||i.includes("android")?"android":/iphone|ipod/i.test(e)?"ios":m?"ipados":/windows/i.test(e)||i.includes("win")?"windows":/macintosh|mac os x/i.test(e)||i.includes("mac")?"macos":/linux/i.test(e)||i.includes("linux")?"linux":"web",f=(n.userAgentData?.brands??[]).map(({brand:a})=>a.toLowerCase()),o=a=>f.some(u=>u.includes(a)),s=/edgios|edga|edg\//i.test(e)||o("edge")?"Edge":/fxios|firefox/i.test(e)||o("firefox")?"Firefox":/crios|chrome|chromium/i.test(e)||o("chrome")||o("chromium")?"Chrome":/safari/i.test(e)?"Safari":"Web";return {name:r==="web"?`${s} Browser`:`${s} on ${r==="ios"?"iPhone":r==="ipados"?"iPad":r==="android"?"Android":r==="macos"?"macOS":r==="windows"?"Windows":r==="linux"?"Linux":"Web"}`,platform:r}}function g(t,n){let e=p();return {name:d(t?.name,"name",120)??(n==="native"&&e.platform==="web"?"Native device":e.name),platform:d(t?.platform,"platform",80)??(n==="native"&&e.platform==="web"?"desktop":e.platform),metadata:c(t?.metadata)}}
2
+ export{p as inferOpenRTCDeviceProfile,g as resolveDeviceProfile};
@@ -0,0 +1 @@
1
+ function c(t){return typeof t=="string"?t.trim():""}function a(t){return t.name?.trim()||"Enrolled device"}function l(t){return {deviceId:t.deviceId,deviceName:a(t),online:false,ticket:"",presenceStatus:"offline",connectable:false,platformType:t.platform?.trim()||void 0,createdAt:t.enrolledAtMs,lastSeenAt:t.lastGrantAtMs}}function v(t){return {...l(t),presenceStatus:"offline",connectable:false,connectionStatus:"disconnected",settledReady:false,readinessState:"offline",readinessReason:"enrolled-device-offline",peerHealth:"unknown",scopes:[]}}function s(t,o){let n=o.deviceName?.trim(),e=o.platformType?.trim();return {...t,...o,deviceName:n||t.deviceName,platformType:e||t.platformType,createdAt:o.createdAt??t.createdAt,lastSeenAt:o.lastSeenAt??t.lastSeenAt}}var d=class{constructor(o){this.enrolled=new Map;this.replace(o);}replace(o){this.enrolled.clear();for(let n of o){let e=c(n.deviceId);e&&this.enrolled.set(e,{...n,deviceId:e});}}remove(o){let n=c(o);n&&this.enrolled.delete(n);}retain(o){let n=c(o);for(let e of this.enrolled.keys())e!==n&&this.enrolled.delete(e);}mergeDevices(o){let n=new Map;for(let e of this.enrolled.values())n.set(e.deviceId,l(e));for(let e of o){let i=c(e.deviceId);if(!i)continue;let r=n.get(i);n.set(i,r?s(r,{...e,deviceId:i}):{...e,deviceId:i});}return [...n.values()].sort((e,i)=>e.deviceId.localeCompare(i.deviceId))}mergeStatus(o){let n=new Map;for(let e of this.enrolled.values())n.set(e.deviceId,v(e));for(let e of o){let i=c(e.deviceId);if(!i)continue;let r=n.get(i);n.set(i,r?s(r,{...e,deviceId:i}):{...e,deviceId:i});}return [...n.values()].sort((e,i)=>e.deviceId.localeCompare(i.deviceId))}};export{d as AuthenticatedDeviceRoster};
@@ -0,0 +1,277 @@
1
+ var se=()=>{};var ae=function(t){let e=[],n=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=i&63|128):(i&64512)===55296&&r+1<t.length&&(t.charCodeAt(r+1)&64512)===56320?(i=65536+((i&1023)<<10)+(t.charCodeAt(++r)&1023),e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=i&63|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=i&63|128);}return e},He=function(t){let e=[],n=0,r=0;for(;n<t.length;){let i=t[n++];if(i<128)e[r++]=String.fromCharCode(i);else if(i>191&&i<224){let s=t[n++];e[r++]=String.fromCharCode((i&31)<<6|s&63);}else if(i>239&&i<365){let s=t[n++],o=t[n++],a=t[n++],c=((i&7)<<18|(s&63)<<12|(o&63)<<6|a&63)-65536;e[r++]=String.fromCharCode(55296+(c>>10)),e[r++]=String.fromCharCode(56320+(c&1023));}else {let s=t[n++],o=t[n++];e[r++]=String.fromCharCode((i&15)<<12|(s&63)<<6|o&63);}}return e.join("")},ce={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();let n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let i=0;i<t.length;i+=3){let s=t[i],o=i+1<t.length,a=o?t[i+1]:0,c=i+2<t.length,l=c?t[i+2]:0,u=s>>2,d=(s&3)<<4|a>>4,h=(a&15)<<2|l>>6,m=l&63;c||(m=64,o||(h=64)),r.push(n[u],n[d],n[h],n[m]);}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(ae(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):He(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();let n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let i=0;i<t.length;){let s=n[t.charAt(i++)],a=i<t.length?n[t.charAt(i)]:0;++i;let l=i<t.length?n[t.charAt(i)]:64;++i;let d=i<t.length?n[t.charAt(i)]:64;if(++i,s==null||a==null||l==null||d==null)throw new M;let h=s<<2|a>>4;if(r.push(h),l!==64){let m=a<<4&240|l>>2;if(r.push(m),d!==64){let A=l<<6&192|d;r.push(A);}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t);}}},M=class extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError";}},je=function(t){let e=ae(t);return ce.encodeByteArray(e,true)},$=function(t){return je(t).replace(/\./g,"")},le=function(t){try{return ce.decodeString(t,!0)}catch(e){console.error("base64Decode failed: ",e);}return null};function ze(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}var Ve=()=>ze().__FIREBASE_DEFAULTS__,We=()=>{if(typeof process>"u"||typeof process.env>"u")return;let t=process.env.__FIREBASE_DEFAULTS__;if(t)return JSON.parse(t)},Ge=()=>{if(typeof document>"u")return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);}catch{return}let e=t&&le(t[1]);return e&&JSON.parse(e)},ue=()=>{try{return se()||Ve()||We()||Ge()}catch(t){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);return}},Je=t=>ue()?.emulatorHosts?.[t],fe=t=>{let e=Je(t);if(!e)return;let n=e.lastIndexOf(":");if(n<=0||n+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);let r=parseInt(e.substring(n+1),10);return e[0]==="["?[e.substring(1,n-1),r]:[e.substring(0,n),r]},F=()=>ue()?.config;var T=class{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,n)=>{this.resolve=e,this.reject=n;});}wrapCallback(e){return (n,r)=>{n?this.reject(n):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(n):e(n,r));}}};function he(){try{return typeof indexedDB=="object"}catch{return false}}function de(){return new Promise((t,e)=>{try{let n=!0,r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),t(!0);},i.onupgradeneeded=()=>{n=!1;},i.onerror=()=>{e(i.error?.message||"");};}catch(n){e(n);}})}var Ke="FirebaseError",b=class t extends Error{constructor(e,n,r){super(n),this.code=e,this.customData=r,this.name=Ke,Object.setPrototypeOf(this,t.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,C.prototype.create);}},C=class{constructor(e,n,r){this.service=e,this.serviceName=n,this.errors=r;}create(e,...n){let r=n[0]||{},i=`${this.service}/${e}`,s=this.errors[e],o=s?qe(s,r):"Error",a=`${this.serviceName}: ${o} (${i}).`;return new b(i,a,r)}};function qe(t,e){return t.replace(Ye,(n,r)=>{let i=e[r];return i!=null?String(i):`<${r}?>`})}var Ye=/\{\$([^}]+)}/g;function N(t,e){if(t===e)return true;let n=Object.keys(t),r=Object.keys(e);for(let i of n){if(!r.includes(i))return false;let s=t[i],o=e[i];if(oe(s)&&oe(o)){if(!N(s,o))return false}else if(s!==o)return false}for(let i of r)if(!n.includes(i))return false;return true}function oe(t){return t!==null&&typeof t=="object"}function S(t){return t&&t._delegate?t._delegate:t}function U(t){try{return (t.startsWith("http://")||t.startsWith("https://")?new URL(t).hostname:t).endsWith(".cloudworkstations.dev")}catch{return false}}async function pe(t){return (await fetch(t,{credentials:"include"})).ok}var y=class{constructor(e,n,r){this.name=e,this.instanceFactory=n,this.type=r,this.multipleInstances=false,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null;}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}};var w="[DEFAULT]";var H=class{constructor(e,n){this.name=e,this.container=n,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map;}get(e){let n=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(n)){let r=new T;if(this.instancesDeferred.set(n,r),this.isInitialized(n)||this.shouldAutoInitialize())try{let i=this.getOrInitializeService({instanceIdentifier:n});i&&r.resolve(i);}catch{}}return this.instancesDeferred.get(n).promise}getImmediate(e){let n=this.normalizeInstanceIdentifier(e?.identifier),r=e?.optional??false;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(i){if(r)return null;throw i}else {if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(Qe(e))try{this.getOrInitializeService({instanceIdentifier:w});}catch{}for(let[n,r]of this.instancesDeferred.entries()){let i=this.normalizeInstanceIdentifier(n);try{let s=this.getOrInitializeService({instanceIdentifier:i});r.resolve(s);}catch{}}}}clearInstance(e=w){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e);}async delete(){let e=Array.from(this.instances.values());await Promise.all([...e.filter(n=>"INTERNAL"in n).map(n=>n.INTERNAL.delete()),...e.filter(n=>"_delete"in n).map(n=>n._delete())]);}isComponentSet(){return this.component!=null}isInitialized(e=w){return this.instances.has(e)}getOptions(e=w){return this.instancesOptions.get(e)||{}}initialize(e={}){let{options:n={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);let i=this.getOrInitializeService({instanceIdentifier:r,options:n});for(let[s,o]of this.instancesDeferred.entries()){let a=this.normalizeInstanceIdentifier(s);r===a&&o.resolve(i);}return i}onInit(e,n){let r=this.normalizeInstanceIdentifier(n),i=this.onInitCallbacks.get(r)??new Set;i.add(e),this.onInitCallbacks.set(r,i);let s=this.instances.get(r);return s&&e(s,r),()=>{i.delete(e);}}invokeOnInitCallbacks(e,n){let r=this.onInitCallbacks.get(n);if(r)for(let i of r)try{i(e,n);}catch{}}getOrInitializeService({instanceIdentifier:e,options:n={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:Xe(e),options:n}),this.instances.set(e,r),this.instancesOptions.set(e,n),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r);}catch{}return r||null}normalizeInstanceIdentifier(e=w){return this.component?this.component.multipleInstances?e:w:e}shouldAutoInitialize(){return !!this.component&&this.component.instantiationMode!=="EXPLICIT"}};function Xe(t){return t===w?void 0:t}function Qe(t){return t.instantiationMode==="EAGER"}var k=class{constructor(e){this.name=e,this.providers=new Map;}addComponent(e){let n=this.getProvider(e.name);if(n.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);n.setComponent(e);}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e);}getProvider(e){if(this.providers.has(e))return this.providers.get(e);let n=new H(e,this);return this.providers.set(e,n),n}getProviders(){return Array.from(this.providers.values())}};var f;(function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT";})(f||(f={}));var et={debug:f.DEBUG,verbose:f.VERBOSE,info:f.INFO,warn:f.WARN,error:f.ERROR,silent:f.SILENT},tt=f.INFO,nt={[f.DEBUG]:"log",[f.VERBOSE]:"log",[f.INFO]:"info",[f.WARN]:"warn",[f.ERROR]:"error"},rt=(t,e,...n)=>{if(e<t.logLevel)return;let r=new Date().toISOString(),i=nt[e];if(i)console[i](`[${r}] ${t.name}:`,...n);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)},x=class{constructor(e){this.name=e,this._logLevel=tt,this._logHandler=rt,this._userLogHandler=null;}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in f))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e;}setLogLevel(e){this._logLevel=typeof e=="string"?et[e]:e;}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e;}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e;}debug(...e){this._userLogHandler&&this._userLogHandler(this,f.DEBUG,...e),this._logHandler(this,f.DEBUG,...e);}log(...e){this._userLogHandler&&this._userLogHandler(this,f.VERBOSE,...e),this._logHandler(this,f.VERBOSE,...e);}info(...e){this._userLogHandler&&this._userLogHandler(this,f.INFO,...e),this._logHandler(this,f.INFO,...e);}warn(...e){this._userLogHandler&&this._userLogHandler(this,f.WARN,...e),this._logHandler(this,f.WARN,...e);}error(...e){this._userLogHandler&&this._userLogHandler(this,f.ERROR,...e),this._logHandler(this,f.ERROR,...e);}};var it=(t,e)=>e.some(n=>t instanceof n),me,ge;function st(){return me||(me=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ot(){return ge||(ge=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var be=new WeakMap,z=new WeakMap,ye=new WeakMap,j=new WeakMap,W=new WeakMap;function at(t){let e=new Promise((n,r)=>{let i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o);},s=()=>{n(g(t.result)),i();},o=()=>{r(t.error),i();};t.addEventListener("success",s),t.addEventListener("error",o);});return e.then(n=>{n instanceof IDBCursor&&be.set(n,t);}).catch(()=>{}),W.set(e,t),e}function ct(t){if(z.has(t))return;let e=new Promise((n,r)=>{let i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o);},s=()=>{n(),i();},o=()=>{r(t.error||new DOMException("AbortError","AbortError")),i();};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o);});z.set(t,e);}var V={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return z.get(t);if(e==="objectStoreNames")return t.objectStoreNames||ye.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return g(t[e])},set(t,e,n){return t[e]=n,true},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?true:e in t}};function Ee(t){V=t(V);}function lt(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...n){let r=t.call(R(this),e,...n);return ye.set(r,e.sort?e.sort():[e]),g(r)}:ot().includes(t)?function(...e){return t.apply(R(this),e),g(be.get(this))}:function(...e){return g(t.apply(R(this),e))}}function ut(t){return typeof t=="function"?lt(t):(t instanceof IDBTransaction&&ct(t),it(t,st())?new Proxy(t,V):t)}function g(t){if(t instanceof IDBRequest)return at(t);if(j.has(t))return j.get(t);let e=ut(t);return e!==t&&(j.set(t,e),W.set(e,t)),e}var R=t=>W.get(t);function we(t,e,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){let o=indexedDB.open(t,e),a=g(o);return r&&o.addEventListener("upgradeneeded",c=>{r(g(o.result),c.oldVersion,c.newVersion,g(o.transaction),c);}),n&&o.addEventListener("blocked",c=>n(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),i&&c.addEventListener("versionchange",l=>i(l.oldVersion,l.newVersion,l));}).catch(()=>{}),a}var ft=["get","getKey","getAll","getAllKeys","count"],ht=["put","add","delete","clear"],G=new Map;function _e(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(G.get(e))return G.get(e);let n=e.replace(/FromIndex$/,""),r=e!==n,i=ht.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||ft.includes(n)))return;let s=async function(o,...a){let c=this.transaction(o,i?"readwrite":"readonly"),l=c.store;return r&&(l=l.index(a.shift())),(await Promise.all([l[n](...a),i&&c.done]))[0]};return G.set(e,s),s}Ee(t=>({...t,get:(e,n,r)=>_e(e,n)||t.get(e,n,r),has:(e,n)=>!!_e(e,n)||t.has(e,n)}));var K=class{constructor(e){this.container=e;}getPlatformInfoString(){return this.container.getProviders().map(n=>{if(dt(n)){let r=n.getImmediate();return `${r.library}/${r.version}`}else return null}).filter(n=>n).join(" ")}};function dt(t){return t.getComponent()?.type==="VERSION"}var q="@firebase/app",Ae="0.15.1";var E=new x("@firebase/app"),pt="@firebase/app-compat",mt="@firebase/analytics-compat",gt="@firebase/analytics",bt="@firebase/app-check-compat",yt="@firebase/app-check",Et="@firebase/auth",_t="@firebase/auth-compat",wt="@firebase/database",At="@firebase/data-connect",vt="@firebase/database-compat",Dt="@firebase/functions",Ct="@firebase/functions-compat",St="@firebase/installations",It="@firebase/installations-compat",Ot="@firebase/messaging",Tt="@firebase/messaging-compat",Nt="@firebase/performance",kt="@firebase/performance-compat",xt="@firebase/remote-config",Rt="@firebase/remote-config-compat",Bt="@firebase/storage",Lt="@firebase/storage-compat",Pt="@firebase/firestore",Mt="@firebase/ai",$t="@firebase/firestore-compat",Ft="firebase";var Y="[DEFAULT]",Ut={[q]:"fire-core",[pt]:"fire-core-compat",[gt]:"fire-analytics",[mt]:"fire-analytics-compat",[yt]:"fire-app-check",[bt]:"fire-app-check-compat",[Et]:"fire-auth",[_t]:"fire-auth-compat",[wt]:"fire-rtdb",[At]:"fire-data-connect",[vt]:"fire-rtdb-compat",[Dt]:"fire-fn",[Ct]:"fire-fn-compat",[St]:"fire-iid",[It]:"fire-iid-compat",[Ot]:"fire-fcm",[Tt]:"fire-fcm-compat",[Nt]:"fire-perf",[kt]:"fire-perf-compat",[xt]:"fire-rc",[Rt]:"fire-rc-compat",[Bt]:"fire-gcs",[Lt]:"fire-gcs-compat",[Pt]:"fire-fst",[$t]:"fire-fst-compat",[Mt]:"fire-vertex","fire-js":"fire-js",[Ft]:"fire-js-all"};var B=new Map,Ht=new Map,X=new Map;function ve(t,e){try{t.container.addComponent(e);}catch(n){E.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n);}}function I(t){let e=t.name;if(X.has(e))return E.debug(`There were multiple attempts to register component ${e}.`),false;X.set(e,t);for(let n of B.values())ve(n,t);for(let n of Ht.values())ve(n,t);return true}function Ie(t,e){let n=t.container.getProvider("heartbeat").getImmediate({optional:true});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function Oe(t){return t==null?false:t.settings!==void 0}var jt={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},_=new C("app","Firebase",jt);var Q=class{constructor(e,n,r){this._isDeleted=false,this._options={...e},this._config={...n},this._name=n.name,this._automaticDataCollectionEnabled=n.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new y("app",()=>this,"PUBLIC"));}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e;}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e;}checkDestroyed(){if(this.isDeleted)throw _.create("app-deleted",{appName:this._name})}};function zt(t,e={}){let n=t;typeof e!="object"&&(e={name:e});let r={name:Y,automaticDataCollectionEnabled:true,...e},i=r.name;if(typeof i!="string"||!i)throw _.create("bad-app-name",{appName:String(i)});if(n||(n=F()),!n)throw _.create("no-options");let s=B.get(i);if(s){if(N(n,s.options)&&N(r,s.config))return s;throw _.create("duplicate-app",{appName:i})}let o=new k(i);for(let c of X.values())o.addComponent(c);let a=new Q(n,r,o);return B.set(i,a),a}function Te(t=Y){let e=B.get(t);if(!e&&t===Y&&F())return zt();if(!e)throw _.create("no-app",{appName:t});return e}function v(t,e,n){let r=Ut[t]??t;n&&(r+=`-${n}`);let i=r.match(/\s|\//),s=e.match(/\s|\//);if(i||s){let o=[`Unable to register library "${r}" with version "${e}":`];i&&o.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&s&&o.push("and"),s&&o.push(`version name "${e}" contains illegal characters (whitespace or "/")`),E.warn(o.join(" "));return}I(new y(`${r}-version`,()=>({library:r,version:e}),"VERSION"));}var Vt="firebase-heartbeat-database",Wt=1,O="firebase-heartbeat-store",J=null;function Ne(){return J||(J=we(Vt,Wt,{upgrade:(t,e)=>{switch(e){case 0:try{t.createObjectStore(O);}catch(n){console.warn(n);}}}}).catch(t=>{throw _.create("idb-open",{originalErrorMessage:t.message})})),J}async function Gt(t){try{let n=(await Ne()).transaction(O),r=await n.objectStore(O).get(ke(t));return await n.done,r}catch(e){if(e instanceof b)E.warn(e.message);else {let n=_.create("idb-get",{originalErrorMessage:e?.message});E.warn(n.message);}}}async function De(t,e){try{let r=(await Ne()).transaction(O,"readwrite");await r.objectStore(O).put(e,ke(t)),await r.done;}catch(n){if(n instanceof b)E.warn(n.message);else {let r=_.create("idb-set",{originalErrorMessage:n?.message});E.warn(r.message);}}}function ke(t){return `${t.name}!${t.options.appId}`}var Jt=1024,Kt=30,Z=class{constructor(e){this.container=e,this._heartbeatsCache=null;let n=this.container.getProvider("app").getImmediate();this._storage=new ee(n),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r));}async triggerHeartbeat(){try{let n=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=Ce();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(i=>i.date===r))return;if(this._heartbeatsCache.heartbeats.push({date:r,agent:n}),this._heartbeatsCache.heartbeats.length>Kt){let i=Yt(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(i,1);}return this._storage.overwrite(this._heartbeatsCache)}catch(e){E.warn(e);}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return "";let e=Ce(),{heartbeatsToSend:n,unsentEntries:r}=qt(this._heartbeatsCache.heartbeats),i=$(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=e,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(e){return E.warn(e),""}}};function Ce(){return new Date().toISOString().substring(0,10)}function qt(t,e=Jt){let n=[],r=t.slice();for(let i of t){let s=n.find(o=>o.agent===i.agent);if(s){if(s.dates.push(i.date),Se(n)>e){s.dates.pop();break}}else if(n.push({agent:i.agent,dates:[i.date]}),Se(n)>e){n.pop();break}r=r.slice(1);}return {heartbeatsToSend:n,unsentEntries:r}}var ee=class{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck();}async runIndexedDBEnvironmentCheck(){return he()?de().then(()=>true).catch(()=>false):false}async read(){if(await this._canUseIndexedDBPromise){let n=await Gt(this.app);return n?.heartbeats?n:{heartbeats:[]}}else return {heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){let r=await this.read();return De(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){let r=await this.read();return De(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}};function Se(t){return $(JSON.stringify({version:2,heartbeats:t})).length}function Yt(t){if(t.length===0)return -1;let e=0,n=t[0].date;for(let r=1;r<t.length;r++)t[r].date<n&&(n=t[r].date,e=r);return e}function Xt(t){I(new y("platform-logger",e=>new K(e),"PRIVATE")),I(new y("heartbeat",e=>new Z(e),"PRIVATE")),v(q,Ae,t),v(q,Ae,"esm2020"),v("fire-js","");}Xt("");var Qt="type.googleapis.com/google.protobuf.Int64Value",Zt="type.googleapis.com/google.protobuf.UInt64Value";function Le(t,e){let n={};for(let r in t)t.hasOwnProperty(r)&&(n[r]=e(t[r]));return n}function L(t){if(t==null)return null;if(t instanceof Number&&(t=t.valueOf()),typeof t=="number"&&isFinite(t)||t===true||t===false||Object.prototype.toString.call(t)==="[object String]")return t;if(t instanceof Date)return t.toISOString();if(Array.isArray(t))return t.map(e=>L(e));if(typeof t=="function"||typeof t=="object")return Le(t,e=>L(e));throw new Error("Data cannot be encoded in JSON: "+t)}function D(t){if(t==null)return t;if(t["@type"])switch(t["@type"]){case Qt:case Zt:{let e=Number(t.value);if(isNaN(e))throw new Error("Data cannot be decoded from JSON: "+t);return e}default:throw new Error("Data cannot be decoded from JSON: "+t)}return Array.isArray(t)?t.map(e=>D(e)):typeof t=="function"||typeof t=="object"?Le(t,e=>D(e)):t}var ie="functions";var xe={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"},p=class t extends b{constructor(e,n,r){super(`${ie}/${e}`,n||""),this.details=r,Object.setPrototypeOf(this,t.prototype);}};function en(t){if(t>=200&&t<300)return "ok";switch(t){case 0:return "internal";case 400:return "invalid-argument";case 401:return "unauthenticated";case 403:return "permission-denied";case 404:return "not-found";case 409:return "aborted";case 429:return "resource-exhausted";case 499:return "cancelled";case 500:return "internal";case 501:return "unimplemented";case 503:return "unavailable";case 504:return "deadline-exceeded"}return "unknown"}function P(t,e){let n=en(t),r=n,i;try{let s=e&&e.error;if(s){let o=s.status;if(typeof o=="string"){if(!xe[o])return new p("internal","internal");n=xe[o],r=o;}let a=s.message;typeof a=="string"&&(r=a),i=s.details,i!==void 0&&(i=D(i));}}catch{}return n==="ok"?null:new p(n,r,i)}var te=class{constructor(e,n,r,i){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,Oe(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.auth=n.getImmediate({optional:true}),this.messaging=r.getImmediate({optional:true}),this.auth||n.get().then(s=>this.auth=s,()=>{}),this.messaging||r.get().then(s=>this.messaging=s,()=>{}),this.appCheck||i?.get().then(s=>this.appCheck=s,()=>{});}async getAuthToken(){if(this.auth)try{return (await this.auth.getToken())?.accessToken}catch{return}}async getMessagingToken(){if(!(!this.messaging||!("Notification"in self)||Notification.permission!=="granted"))try{return await this.messaging.getToken()}catch{return}}async getAppCheckToken(e){if(this.serverAppAppCheckToken)return this.serverAppAppCheckToken;if(this.appCheck){let n=e?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken();return n.error?null:n.token}return null}async getContext(e){let n=await this.getAuthToken(),r=await this.getMessagingToken(),i=await this.getAppCheckToken(e);return {authToken:n,messagingToken:r,appCheckToken:i}}};var ne="us-central1",tn=/^data: (.*?)(?:\n|$)/;function nn(t){let e=null;return {promise:new Promise((n,r)=>{e=setTimeout(()=>{r(new p("deadline-exceeded","deadline-exceeded"));},t);}),cancel:()=>{e&&clearTimeout(e);}}}var re=class{constructor(e,n,r,i,s=ne,o=(...a)=>fetch(...a)){this.app=e,this.fetchImpl=o,this.emulatorOrigin=null,this.contextProvider=new te(e,n,r,i),this.cancelAllRequests=new Promise(a=>{this.deleteService=()=>Promise.resolve(a());});try{let a=new URL(s);this.customDomain=a.origin+(a.pathname==="/"?"":a.pathname),this.region=ne;}catch{this.customDomain=null,this.region=s;}}_delete(){return this.deleteService()}_url(e){let n=this.app.options.projectId;return this.emulatorOrigin!==null?`${this.emulatorOrigin}/${n}/${this.region}/${e}`:this.customDomain!==null?`${this.customDomain}/${e}`:`https://${this.region}-${n}.cloudfunctions.net/${e}`}};function rn(t,e,n){let r=U(e);t.emulatorOrigin=`http${r?"s":""}://${e}:${n}`,r&&pe(t.emulatorOrigin+"/backends");}function sn(t,e,n){let r=i=>cn(t,e,i,n||{});return r.stream=(i,s)=>ln(t,e,i,s),r}function on(t,e,n){let r=i=>$e(t,e,i,n||{});return r.stream=(i,s)=>Fe(t,e,i,s||{}),r}function Pe(t){return t.emulatorOrigin&&U(t.emulatorOrigin)?"include":void 0}async function an(t,e,n,r,i){n["Content-Type"]="application/json";let s;try{s=await r(t,{method:"POST",body:JSON.stringify(e),headers:n,credentials:Pe(i)});}catch{return {status:0,json:null}}let o=null;try{o=await s.json();}catch{}return {status:s.status,json:o}}async function Me(t,e){let n={},r=await t.contextProvider.getContext(e.limitedUseAppCheckTokens);return r.authToken&&(n.Authorization="Bearer "+r.authToken),r.messagingToken&&(n["Firebase-Instance-ID-Token"]=r.messagingToken),r.appCheckToken!==null&&(n["X-Firebase-AppCheck"]=r.appCheckToken),n}function cn(t,e,n,r){let i=t._url(e);return $e(t,i,n,r)}async function $e(t,e,n,r){n=L(n);let i={data:n},s=await Me(t,r),o=r.timeout||7e4,a=nn(o),c=await Promise.race([an(e,i,s,t.fetchImpl,t),a.promise,t.cancelAllRequests]);if(a.cancel(),!c)throw new p("cancelled","Firebase Functions instance was deleted.");let l=P(c.status,c.json);if(l)throw l;if(!c.json)throw new p("internal","Response is not valid JSON object.");let u=c.json.data;if(typeof u>"u"&&(u=c.json.result),typeof u>"u")throw new p("internal","Response is missing data field.");return {data:D(u)}}function ln(t,e,n,r){let i=t._url(e);return Fe(t,i,n,r||{})}async function Fe(t,e,n,r){n=L(n);let i={data:n},s=await Me(t,r);s["Content-Type"]="application/json",s.Accept="text/event-stream";let o;try{o=await t.fetchImpl(e,{method:"POST",body:JSON.stringify(i),headers:s,signal:r?.signal,credentials:Pe(t)});}catch(h){if(h instanceof Error&&h.name==="AbortError"){let A=new p("cancelled","Request was cancelled.");return {data:Promise.reject(A),stream:{[Symbol.asyncIterator](){return {next(){return Promise.reject(A)}}}}}}let m=P(0,null);return {data:Promise.reject(m),stream:{[Symbol.asyncIterator](){return {next(){return Promise.reject(m)}}}}}}let a,c,l=new Promise((h,m)=>{a=h,c=m;});r?.signal?.addEventListener("abort",()=>{let h=new p("cancelled","Request was cancelled.");c(h);});let u=o.body.getReader(),d=un(u,a,c,r?.signal);return {stream:{[Symbol.asyncIterator](){let h=d.getReader();return {async next(){let{value:m,done:A}=await h.read();return {value:m,done:A}},async return(){return await h.cancel(),{done:true,value:void 0}}}}},data:l}}function un(t,e,n,r){let i=(o,a)=>{let c=o.match(tn);if(!c)return;let l=c[1];try{let u=JSON.parse(l);if("result"in u){e(D(u.result));return}if("message"in u){a.enqueue(D(u.message));return}if("error"in u){let d=P(0,u);a.error(d),n(d);return}}catch(u){if(u instanceof p){a.error(u),n(u);return}}},s=new TextDecoder;return new ReadableStream({start(o){let a="";return c();async function c(){if(r?.aborted){let l=new p("cancelled","Request was cancelled");return o.error(l),n(l),Promise.resolve()}try{let{value:l,done:u}=await t.read();if(u){a.trim()&&i(a.trim(),o),o.close();return}if(r?.aborted){let h=new p("cancelled","Request was cancelled");o.error(h),n(h),await t.cancel();return}a+=s.decode(l,{stream:!0});let d=a.split(`
2
+ `);a=d.pop()||"";for(let h of d)h.trim()&&i(h.trim(),o);return c()}catch(l){let u=l instanceof p?l:P(0,null);o.error(u),n(u);}}},cancel(){return t.cancel()}})}var Re="@firebase/functions",Be="0.13.5";var fn="auth-internal",hn="app-check-internal",dn="messaging-internal";function pn(t){let e=(n,{instanceIdentifier:r})=>{let i=n.getProvider("app").getImmediate(),s=n.getProvider(fn),o=n.getProvider(dn),a=n.getProvider(hn);return new re(i,s,o,a,r)};I(new y(ie,e,"PUBLIC").setMultipleInstances(true)),v(Re,Be,t),v(Re,Be,"esm2020");}function Un(t=Te(),e=ne){let r=Ie(S(t),ie).getImmediate({identifier:e}),i=fe("functions");return i&&mn(r,...i),r}function mn(t,e,n){rn(S(t),e,n);}function Hn(t,e,n){return sn(S(t),e,n)}function jn(t,e,n){return on(S(t),e,n)}pn();/*! Bundled license information:
3
+
4
+ @firebase/util/dist/node-esm/index.node.esm.js:
5
+ @firebase/util/dist/node-esm/index.node.esm.js:
6
+ @firebase/util/dist/node-esm/index.node.esm.js:
7
+ @firebase/util/dist/node-esm/index.node.esm.js:
8
+ @firebase/util/dist/node-esm/index.node.esm.js:
9
+ @firebase/util/dist/node-esm/index.node.esm.js:
10
+ @firebase/util/dist/node-esm/index.node.esm.js:
11
+ @firebase/util/dist/node-esm/index.node.esm.js:
12
+ @firebase/util/dist/node-esm/index.node.esm.js:
13
+ @firebase/util/dist/node-esm/index.node.esm.js:
14
+ @firebase/util/dist/node-esm/index.node.esm.js:
15
+ @firebase/logger/dist/esm/index.esm.js:
16
+ (**
17
+ * @license
18
+ * Copyright 2017 Google LLC
19
+ *
20
+ * Licensed under the Apache License, Version 2.0 (the "License");
21
+ * you may not use this file except in compliance with the License.
22
+ * You may obtain a copy of the License at
23
+ *
24
+ * http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software
27
+ * distributed under the License is distributed on an "AS IS" BASIS,
28
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
+ * See the License for the specific language governing permissions and
30
+ * limitations under the License.
31
+ *)
32
+
33
+ @firebase/util/dist/node-esm/index.node.esm.js:
34
+ @firebase/util/dist/node-esm/index.node.esm.js:
35
+ (**
36
+ * @license
37
+ * Copyright 2022 Google LLC
38
+ *
39
+ * Licensed under the Apache License, Version 2.0 (the "License");
40
+ * you may not use this file except in compliance with the License.
41
+ * You may obtain a copy of the License at
42
+ *
43
+ * http://www.apache.org/licenses/LICENSE-2.0
44
+ *
45
+ * Unless required by applicable law or agreed to in writing, software
46
+ * distributed under the License is distributed on an "AS IS" BASIS,
47
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
+ * See the License for the specific language governing permissions and
49
+ * limitations under the License.
50
+ *)
51
+
52
+ @firebase/util/dist/node-esm/index.node.esm.js:
53
+ (**
54
+ * @license
55
+ * Copyright 2017 Google LLC
56
+ *
57
+ * Licensed under the Apache License, Version 2.0 (the "License");
58
+ * you may not use this file except in compliance with the License.
59
+ * You may obtain a copy of the License at
60
+ *
61
+ * http://www.apache.org/licenses/LICENSE-2.0
62
+ *
63
+ * Unless required by applicable law or agreed to in writing, software
64
+ * distributed under the License is distributed on an "AS IS" BASIS,
65
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66
+ * See the License for the specific language governing permissions and
67
+ * limitations under the License.
68
+ *)
69
+ (**
70
+ * @license
71
+ * Copyright 2021 Google LLC
72
+ *
73
+ * Licensed under the Apache License, Version 2.0 (the "License");
74
+ * you may not use this file except in compliance with the License.
75
+ * You may obtain a copy of the License at
76
+ *
77
+ * http://www.apache.org/licenses/LICENSE-2.0
78
+ *
79
+ * Unless required by applicable law or agreed to in writing, software
80
+ * distributed under the License is distributed on an "AS IS" BASIS,
81
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
82
+ * See the License for the specific language governing permissions and
83
+ * limitations under the License.
84
+ *)
85
+
86
+ @firebase/util/dist/node-esm/index.node.esm.js:
87
+ @firebase/component/dist/esm/index.esm.js:
88
+ @firebase/app/dist/esm/index.esm.js:
89
+ @firebase/app/dist/esm/index.esm.js:
90
+ @firebase/app/dist/esm/index.esm.js:
91
+ (**
92
+ * @license
93
+ * Copyright 2019 Google LLC
94
+ *
95
+ * Licensed under the Apache License, Version 2.0 (the "License");
96
+ * you may not use this file except in compliance with the License.
97
+ * You may obtain a copy of the License at
98
+ *
99
+ * http://www.apache.org/licenses/LICENSE-2.0
100
+ *
101
+ * Unless required by applicable law or agreed to in writing, software
102
+ * distributed under the License is distributed on an "AS IS" BASIS,
103
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
104
+ * See the License for the specific language governing permissions and
105
+ * limitations under the License.
106
+ *)
107
+
108
+ @firebase/util/dist/node-esm/index.node.esm.js:
109
+ (**
110
+ * @license
111
+ * Copyright 2020 Google LLC
112
+ *
113
+ * Licensed under the Apache License, Version 2.0 (the "License");
114
+ * you may not use this file except in compliance with the License.
115
+ * You may obtain a copy of the License at
116
+ *
117
+ * http://www.apache.org/licenses/LICENSE-2.0
118
+ *
119
+ * Unless required by applicable law or agreed to in writing, software
120
+ * distributed under the License is distributed on an "AS IS" BASIS,
121
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
122
+ * See the License for the specific language governing permissions and
123
+ * limitations under the License.
124
+ *)
125
+
126
+ @firebase/util/dist/node-esm/index.node.esm.js:
127
+ (**
128
+ * @license
129
+ * Copyright 2021 Google LLC
130
+ *
131
+ * Licensed under the Apache License, Version 2.0 (the "License");
132
+ * you may not use this file except in compliance with the License.
133
+ * You may obtain a copy of the License at
134
+ *
135
+ * http://www.apache.org/licenses/LICENSE-2.0
136
+ *
137
+ * Unless required by applicable law or agreed to in writing, software
138
+ * distributed under the License is distributed on an "AS IS" BASIS,
139
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
140
+ * See the License for the specific language governing permissions and
141
+ * limitations under the License.
142
+ *)
143
+ (**
144
+ * @license
145
+ * Copyright 2025 Google LLC
146
+ *
147
+ * Licensed under the Apache License, Version 2.0 (the "License");
148
+ * you may not use this file except in compliance with the License.
149
+ * You may obtain a copy of the License at
150
+ *
151
+ * http://www.apache.org/licenses/LICENSE-2.0
152
+ *
153
+ * Unless required by applicable law or agreed to in writing, software
154
+ * distributed under the License is distributed on an "AS IS" BASIS,
155
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
156
+ * See the License for the specific language governing permissions and
157
+ * limitations under the License.
158
+ *)
159
+
160
+ @firebase/app/dist/esm/index.esm.js:
161
+ (**
162
+ * @license
163
+ * Copyright 2019 Google LLC
164
+ *
165
+ * Licensed under the Apache License, Version 2.0 (the "License");
166
+ * you may not use this file except in compliance with the License.
167
+ * You may obtain a copy of the License at
168
+ *
169
+ * http://www.apache.org/licenses/LICENSE-2.0
170
+ *
171
+ * Unless required by applicable law or agreed to in writing, software
172
+ * distributed under the License is distributed on an "AS IS" BASIS,
173
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
174
+ * See the License for the specific language governing permissions and
175
+ * limitations under the License.
176
+ *)
177
+ (**
178
+ * @license
179
+ * Copyright 2023 Google LLC
180
+ *
181
+ * Licensed under the Apache License, Version 2.0 (the "License");
182
+ * you may not use this file except in compliance with the License.
183
+ * You may obtain a copy of the License at
184
+ *
185
+ * http://www.apache.org/licenses/LICENSE-2.0
186
+ *
187
+ * Unless required by applicable law or agreed to in writing, software
188
+ * distributed under the License is distributed on an "AS IS" BASIS,
189
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ * See the License for the specific language governing permissions and
191
+ * limitations under the License.
192
+ *)
193
+
194
+ @firebase/app/dist/esm/index.esm.js:
195
+ (**
196
+ * @license
197
+ * Copyright 2021 Google LLC
198
+ *
199
+ * Licensed under the Apache License, Version 2.0 (the "License");
200
+ * you may not use this file except in compliance with the License.
201
+ * You may obtain a copy of the License at
202
+ *
203
+ * http://www.apache.org/licenses/LICENSE-2.0
204
+ *
205
+ * Unless required by applicable law or agreed to in writing, software
206
+ * distributed under the License is distributed on an "AS IS" BASIS,
207
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
208
+ * See the License for the specific language governing permissions and
209
+ * limitations under the License.
210
+ *)
211
+ (**
212
+ * @license
213
+ * Copyright 2019 Google LLC
214
+ *
215
+ * Licensed under the Apache License, Version 2.0 (the "License");
216
+ * you may not use this file except in compliance with the License.
217
+ * You may obtain a copy of the License at
218
+ *
219
+ * http://www.apache.org/licenses/LICENSE-2.0
220
+ *
221
+ * Unless required by applicable law or agreed to in writing, software
222
+ * distributed under the License is distributed on an "AS IS" BASIS,
223
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
224
+ * See the License for the specific language governing permissions and
225
+ * limitations under the License.
226
+ *)
227
+
228
+ @firebase/functions/dist/esm/index.esm.js:
229
+ (**
230
+ * @license
231
+ * Copyright 2017 Google LLC
232
+ *
233
+ * Licensed under the Apache License, Version 2.0 (the "License");
234
+ * you may not use this file except in compliance with the License.
235
+ * You may obtain a copy of the License at
236
+ *
237
+ * http://www.apache.org/licenses/LICENSE-2.0
238
+ *
239
+ * Unless required by applicable law or agreed to in writing, software
240
+ * distributed under the License is distributed on an "AS IS" BASIS,
241
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
242
+ * See the License for the specific language governing permissions and
243
+ * limitations under the License.
244
+ *)
245
+ (**
246
+ * @license
247
+ * Copyright 2020 Google LLC
248
+ *
249
+ * Licensed under the Apache License, Version 2.0 (the "License");
250
+ * you may not use this file except in compliance with the License.
251
+ * You may obtain a copy of the License at
252
+ *
253
+ * http://www.apache.org/licenses/LICENSE-2.0
254
+ *
255
+ * Unless required by applicable law or agreed to in writing, software
256
+ * distributed under the License is distributed on an "AS IS" BASIS,
257
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
258
+ * See the License for the specific language governing permissions and
259
+ * limitations under the License.
260
+ *)
261
+ (**
262
+ * @license
263
+ * Copyright 2019 Google LLC
264
+ *
265
+ * Licensed under the Apache License, Version 2.0 (the "License");
266
+ * you may not use this file except in compliance with the License.
267
+ * You may obtain a copy of the License at
268
+ *
269
+ * http://www.apache.org/licenses/LICENSE-2.0
270
+ *
271
+ * Unless required by applicable law or agreed to in writing, software
272
+ * distributed under the License is distributed on an "AS IS" BASIS,
273
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
274
+ * See the License for the specific language governing permissions and
275
+ * limitations under the License.
276
+ *)
277
+ */export{p as FunctionsError,mn as connectFunctionsEmulator,Un as getFunctions,Hn as httpsCallable,jn as httpsCallableFromURL};
@@ -0,0 +1 @@
1
+ import {a as a$2}from'./chunk-5OHYIHPT.js';import {u,a as a$3}from'./chunk-PPZRTJHE.js';import'./chunk-Z2WVSXPW.js';import'./chunk-WWC767HK.js';import'./chunk-FAPRYEWI.js';import {a as a$1}from'./chunk-QHSM5NFZ.js';import'./chunk-NT5YHZQH.js';import'./chunk-RRMBD5OL.js';import'./chunk-PQK5SJ47.js';import'./chunk-C7YN5MSV.js';var s=false;function a(){s||(s=true,a$3(async()=>{let t=await import('./openrtc-3YHRRPAG.js');return {initWasm:t.default,WasmClient:t.WasmClient,start:t.start}}));}async function d(t){a();let e=a$1(t),{WasmBridge:i}=await import('./WasmBridge-T5XMT6FH.js');return a$2(e,new i(e))}function y(t,e){let i=a$1(t);return a$2(i,new u({...i,bridge:e}))}export{y as createIpcClient,d as createWasmClient};