@protobase/ui 0.62.4 → 0.63.0

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 (53) hide show
  1. package/dist/account/account-page.js +3 -0
  2. package/dist/account/blocks/connected-accounts-block.js +1 -1
  3. package/dist/account/blocks/personal-mail-block.js +36 -0
  4. package/dist/account/messages.js +4 -0
  5. package/dist/account/sign-in-providers-section.js +3 -3
  6. package/dist/app/app.d.ts +1 -1
  7. package/dist/app/app.js +22 -5
  8. package/dist/app/pages/render-node.js +2 -0
  9. package/dist/auth/auth-provider.js +7 -0
  10. package/dist/calls/call-check.js +2 -2
  11. package/dist/calls/call-controls.js +16 -4
  12. package/dist/calls/call-guests-panel.js +200 -0
  13. package/dist/calls/call-lobby-notice.js +34 -0
  14. package/dist/calls/call-message.js +4 -3
  15. package/dist/calls/call-people.js +3 -2
  16. package/dist/calls/call-stage.js +4 -2
  17. package/dist/calls/call-view.d.ts +9 -3
  18. package/dist/calls/call-view.js +37 -6
  19. package/dist/calls/call-waiting.js +20 -0
  20. package/dist/calls/guest-admission.js +40 -0
  21. package/dist/calls/guest-call-link.js +19 -0
  22. package/dist/calls/guest-call-page.js +82 -0
  23. package/dist/calls/messages.js +69 -3
  24. package/dist/calls/use-call-session.d.ts +7 -0
  25. package/dist/calls/use-call-session.js +27 -2
  26. package/dist/calls/use-guest-request.js +24 -0
  27. package/dist/data/api-provider.d.ts +8 -0
  28. package/dist/index.js +1 -1
  29. package/dist/organizations/messages.js +6 -0
  30. package/dist/organizations/organization-page.js +33 -1
  31. package/dist/package.js +1 -1
  32. package/dist/shell/assets/app-CKCVGFSR.js +9 -0
  33. package/dist/shell/assets/calls-DRnrKDC9.js +2 -0
  34. package/dist/shell/assets/{index-D8oHLXjS.js → index-BK-wuwB0.js} +2 -2
  35. package/dist/shell/assets/index-Be8nCyRW.css +2 -0
  36. package/dist/shell/assets/{records-map-DOXcutuQ.js → records-map-Bd5scHzJ.js} +2 -2
  37. package/dist/shell/assets/shared-protobase-ui-CU8QfOuc.js +2 -0
  38. package/dist/shell/index.html +4 -4
  39. package/dist/shell/protobase.shell.json +2 -2
  40. package/dist/shell/protobase.sw.js +2 -2
  41. package/dist/shell-source-maps/assets/app-CKCVGFSR.js.map +1 -0
  42. package/dist/shell-source-maps/assets/calls-DRnrKDC9.js.map +1 -0
  43. package/dist/shell-source-maps/assets/{index-D8oHLXjS.js.map → index-BK-wuwB0.js.map} +1 -1
  44. package/dist/shell-source-maps/assets/{records-map-DOXcutuQ.js.map → records-map-Bd5scHzJ.js.map} +1 -1
  45. package/dist/shell-source-maps/assets/shared-protobase-ui-CU8QfOuc.js.map +1 -0
  46. package/package.json +4 -4
  47. package/dist/shell/assets/app-B_ojAtG3.js +0 -9
  48. package/dist/shell/assets/calls-C63xSTRj.js +0 -2
  49. package/dist/shell/assets/index-BgcF_WZ0.css +0 -2
  50. package/dist/shell/assets/shared-protobase-ui-CX80Ectk.js +0 -2
  51. package/dist/shell-source-maps/assets/app-B_ojAtG3.js.map +0 -1
  52. package/dist/shell-source-maps/assets/calls-C63xSTRj.js.map +0 -1
  53. package/dist/shell-source-maps/assets/shared-protobase-ui-CX80Ectk.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"calls-C63xSTRj.js","names":["newPeerConnection","createPeerConnection","newPeerConnection","createPeerConnection","PublishRefused","reason","createPeerConnection","configuration","statsOf","stats","report","transport","stat","pair","lost","received","roundTrip","connectionOf","state","pc","member","midsByStreamId","mids","section","sdp","mid","stream","firefoxMade","inFirefox","politeTo","offer","peer","peerLink","createPeerConnection$2","peers","local","remote","publishing","publishes","sendOn","track","receivedTrack","sid","transceiver","emitTracks","onTracks","open","making","send","event","source","sending","connect","self","renew","disconnect","signal","from","description","collision","candidate","error","receive","message","present","publishNow","added","tracks","answered","next","sender","muted","negotiation","inFlight","again","waiting","start","settle","resolve","simulcastLayers","singleBitrate","trackRequest","layers","simulcast","layer","width","height","sendEncodings","sfuLink","createPeerConnection$1","early","offerId","offers","negotiate","key","restartIce","stopSending","i","onUnpublished","options","encodings","sids","backoff","attempt","socketUrl","resolved","url","leftCodes","failedCodes","joinCall","WebSocketOf","retryDelay","maxRetries","socket","link","participant","callId","members","ended","rejoin","opened","resumedSinceOpen","failures","chain","joined","result","setState","end","newLink","input","handle","before","call","resume","mode","closed","left","code","publishOptions","size"],"sources":["../../../../client/src/calls/publish-refused.ts","../../../../client/src/calls/media-link.ts","../../../../client/src/calls/connection-stats.ts","../../../../client/src/calls/msid-tracks.ts","../../../../client/src/calls/peer-link.ts","../../../../client/src/calls/negotiation.ts","../../../../client/src/calls/sfu-link.ts","../../../../client/src/calls/join-call.ts"],"sourcesContent":["/** The server refused tracks the member may not send, such as a camera for a member who may only listen. */\nexport class PublishRefused extends Error {\n constructor(reason: string) {\n super(reason)\n this.name = 'PublishRefused'\n }\n}\n","import type { CallConnection } from './connection-stats'\nimport type { CallClientMessage, CallRemoteTrack, CallResume, CallServerMessage, CallTrackSource } from '@protobase/schema/internal'\n\n/** A track of another member, with its media once the browser receives it. */\nexport type CallTrack = CallRemoteTrack & { track?: MediaStreamTrack }\n\n/** How a published video track is sent: with a media server, simulcast sends it in three sizes the server picks from. */\nexport type PublishOptions = { simulcast?: boolean }\n\n/** What a media link is made with: how it talks to Protobase and what it tells the page. */\nexport type MediaLinkInput = {\n iceServers: RTCIceServer[]\n send: (message: CallClientMessage) => void\n onTracks: (tracks: CallTrack[]) => void\n /** The media server stopped sending one of the member's tracks, such as after a demotion. */\n onUnpublished: (source: CallTrackSource) => void\n createPeerConnection?: (configuration: RTCConfiguration) => RTCPeerConnection\n}\n\n/**\n * One member's media in a call, over plain `RTCPeerConnection`s: to a media server (`sfuLink`) or to each other member\n * (`peerLink`). Both take the same messages and do the same things for the call; they differ in who answers an offer.\n */\nexport type MediaLink = {\n /** A message of the server; one at a time, in order. */\n receive: (message: CallServerMessage) => Promise<void>\n publish: (tracks: Partial<Record<CallTrackSource, MediaStreamTrack>>, options?: PublishOptions) => Promise<void>\n unpublish: (source: CallTrackSource) => Promise<void>\n mute: (source: CallTrackSource, muted: boolean) => void\n restartIce: () => Promise<void>\n /** What a new server session needs to resume the link; `undefined` when it cannot, and the member joins anew. */\n resumeState: (participant: string) => Promise<Omit<CallResume, 'call'> | undefined>\n /** After a resume: offers what changed while the session was lost. */\n resumed: () => Promise<void>\n /** How each of the member's connections fares now. */\n connections: () => Promise<CallConnection[]>\n /** The tracks the member sends, by source, to publish again after a rejoin. */\n sending: () => Map<CallTrackSource, { track: MediaStreamTrack; simulcast: boolean }>\n close: () => void\n}\n\nexport const createPeerConnection = (configuration: RTCConfiguration) => new RTCPeerConnection(configuration)\n","/**\n * How one of the member's connections fares: to another member (`member`), or to the media server (no `member`). Its\n * state, and once connected, the round trip of its network path and the share of the media it received that was lost.\n */\nexport type CallConnection = { member?: string; state: RTCPeerConnectionState; roundTripMs?: number; lostRatio?: number }\n\ntype Stat = { type: string; id: string; [field: string]: unknown }\n\n/** What `connectionOf` reads of a connection's stats: the selected candidate pair's round trip, and the received media's losses. */\nexport const statsOf = (report: Iterable<Stat>): Pick<CallConnection, 'roundTripMs' | 'lostRatio'> => {\n const stats = [...report]\n const transport = stats.find((stat) => stat.type === 'transport' && typeof stat.selectedCandidatePairId === 'string')\n // Firefox names no selected pair on its transport: it marks the pair itself.\n const pair = stats.find((stat) => stat.type === 'candidate-pair' && (stat.id === transport?.selectedCandidatePairId || (!transport && stat.selected === true) || (!transport && stat.nominated === true && stat.state === 'succeeded')))\n let lost = 0\n let received = 0\n for (const stat of stats) {\n if (stat.type !== 'inbound-rtp') continue\n lost += Math.max(0, Number(stat.packetsLost ?? 0))\n received += Number(stat.packetsReceived ?? 0)\n }\n const roundTrip = typeof pair?.currentRoundTripTime === 'number' ? pair.currentRoundTripTime * 1000 : undefined\n return { ...(roundTrip !== undefined && { roundTripMs: roundTrip }), ...(lost + received > 0 && { lostRatio: lost / (lost + received) }) }\n}\n\n/** How the connection fares now, as `CallConnection`. */\nexport const connectionOf = async (pc: RTCPeerConnection, member?: string): Promise<CallConnection> => {\n const state = pc.connectionState\n const report = state === 'connected' ? statsOf((await pc.getStats()).values() as Iterable<Stat>) : {}\n return { ...(member !== undefined && { member }), state, ...report }\n}\n","/**\n * The `mid` of each media section of a description by the sending browser's track id, which its `a=msid` line names: a\n * receiver's own track may have another id, when the browser reused one of its transceivers for the section.\n */\nexport const midsByTrackId = (sdp: string) => {\n const mids = new Map<string, string>()\n for (const section of sdp.split(/\\r?\\nm=/).slice(1)) {\n const mid = /^a=mid:(\\S+)/m.exec(section)?.[1]\n const track = /^a=msid:\\S+ (\\S+)/m.exec(section)?.[1]\n if (mid !== undefined && track !== undefined) mids.set(track, mid)\n }\n return mids\n}\n\n/**\n * The `mid` of each media section of a description by the id of the stream its `a=msid` line names. Unlike the track\n * id there, which Firefox makes up for each sender, both browsers write the sending page's stream id.\n */\nexport const midsByStreamId = (sdp: string) => {\n const mids = new Map<string, string>()\n for (const section of sdp.split(/\\r?\\nm=/).slice(1)) {\n const mid = /^a=mid:(\\S+)/m.exec(section)?.[1]\n const stream = /^a=msid:(\\S+) \\S+/m.exec(section)?.[1]\n if (mid !== undefined && stream !== undefined && stream !== '-') mids.set(stream, mid)\n }\n return mids\n}\n","import { PublishRefused } from './publish-refused'\nimport type { CallCandidate, CallDescription, CallRemoteTrack, CallServerMessage, CallTrackSource } from '@protobase/schema/internal'\nimport { createPeerConnection as newPeerConnection, type MediaLink, type MediaLinkInput } from './media-link'\nimport { connectionOf } from './connection-stats'\nimport { midsByStreamId } from './msid-tracks'\n\n// `makingOffer` is the local offer being set, while it is.\ntype Peer = { pc: RTCPeerConnection; polite: boolean; makingOffer?: Promise<void>; ignoreOffer: boolean; senders: Map<CallTrackSource, RTCRtpSender> }\n// Each sent track on a stream of its own, whose id names it: the receiving browser reads it in the description's msid.\ntype LocalTrack = { track: MediaStreamTrack; sid: string; stream: MediaStream }\n\n// Whether a description was made by Firefox, whose session lines name it, and whether this browser is Firefox.\nconst firefoxMade = (sdp: string) => /^o=mozilla/m.test(sdp)\nconst inFirefox = typeof navigator !== 'undefined' && /Firefox\\//.test(navigator.userAgent)\n\n/**\n * Who gives way when this side's offer crosses the other's: Firefox, when only one of the two is, since an offer\n * Chromium rolls back for Firefox's leaves their header extension ids clashing and Chromium's next offer fails;\n * otherwise the member whose id sorts first.\n */\nconst politeTo = (peer: { polite: boolean }, offer: string) => (inFirefox === firefoxMade(offer) ? peer.polite : inFirefox)\n\n/**\n * The media link without a media server: one `RTCPeerConnection` to each other member, whose browser answers, so either\n * side may offer. Protobase passes the descriptions and candidates between the two (\"perfect negotiation\": the member\n * whose id sorts first gives way when both offer at once, or Firefox to Chromium) and says who is in the call and which tracks each member\n * hears. A track goes by the id of the stream the sending browser sends it on, which the receiving browser sees too.\n */\nexport const peerLink = (self: string, { iceServers, send, onTracks, createPeerConnection = newPeerConnection }: MediaLinkInput): MediaLink => {\n const peers = new Map<string, Peer>()\n const local = new Map<CallTrackSource, LocalTrack>()\n let remote: CallRemoteTrack[] = []\n let publishing: { resolve: () => void; reject: (error: Error) => void } | undefined\n let publishes: Promise<unknown> = Promise.resolve()\n\n // Each sent track on a transceiver of its own: one the other side's offer made would keep that offer's msid, and the\n // other browser could not tell which track it carries.\n const sendOn = (pc: RTCPeerConnection, { track, stream }: LocalTrack) => pc.addTransceiver(track, { direction: 'sendonly', streams: [stream] }).sender\n\n const receivedTrack = ({ member, sid }: CallRemoteTrack) => {\n const pc = peers.get(member)?.pc\n const mid = pc?.remoteDescription && midsByStreamId(pc.remoteDescription.sdp).get(sid)\n return mid === undefined ? undefined : pc!.getTransceivers().find((transceiver) => transceiver.mid === mid)?.receiver.track\n }\n const emitTracks = () => onTracks(remote.map((track) => ({ ...track, ...(receivedTrack(track) && { track: receivedTrack(track) }) })))\n\n // The peer's connection, new, sending this member's tracks; the one before it, if any, is closed by the caller.\n const open = (member: string, peer: Peer) => {\n const pc = createPeerConnection({ iceServers })\n peer.pc = pc\n peer.senders = new Map()\n pc.onnegotiationneeded = async () => {\n const making = pc.setLocalDescription()\n peer.makingOffer = making\n try {\n await making\n if (peer.pc === pc) send({ type: 'signal', to: member, description: pc.localDescription!.toJSON() as CallDescription })\n } finally {\n if (peer.makingOffer === making) peer.makingOffer = undefined\n }\n }\n pc.onicecandidate = (event) => {\n if (event.candidate && peer.pc === pc) send({ type: 'signal', to: member, candidate: event.candidate.toJSON() as CallCandidate })\n }\n pc.oniceconnectionstatechange = () => {\n if (pc.iceConnectionState === 'failed') pc.restartIce()\n }\n pc.ontrack = () => emitTracks()\n for (const [source, sending] of local) peer.senders.set(source, sendOn(pc, sending))\n }\n const connect = (member: string) => {\n const peer = { polite: self < member, ignoreOffer: false } as Peer\n peers.set(member, peer)\n open(member, peer)\n return peer\n }\n /**\n * Chromium sometimes gathers no candidates on a connection whose first offer it rolled back, so neither side ever\n * checks: the side that gives way on a connection never negotiated starts on a new one instead, once its offer is set.\n */\n const renew = async (member: string, peer: Peer) => {\n await peer.makingOffer\n peer.pc.close()\n open(member, peer)\n }\n const disconnect = (member: string) => {\n peers.get(member)?.pc.close()\n peers.delete(member)\n }\n\n const signal = async (from: string, description?: CallDescription, candidate?: CallCandidate) => {\n // The other member may reach this browser before the list that names them does.\n const peer = peers.get(from) ?? connect(from)\n if (description) {\n const collision = description.type === 'offer' && (peer.makingOffer !== undefined || peer.pc.signalingState !== 'stable')\n peer.ignoreOffer = !politeTo(peer, description.sdp) && collision\n if (peer.ignoreOffer) return\n if (collision && !peer.pc.currentRemoteDescription) await renew(from, peer)\n }\n const { pc } = peer\n if (description) {\n await pc.setRemoteDescription(description)\n if (description.type === 'offer') {\n await pc.setLocalDescription()\n send({ type: 'signal', to: from, description: pc.localDescription!.toJSON() as CallDescription })\n }\n emitTracks()\n }\n // A candidate of an offer this side gave way on belongs to nothing here.\n if (candidate) {\n await pc.addIceCandidate(candidate).catch((error: unknown) => {\n if (!peer.ignoreOffer) throw error\n })\n }\n }\n\n const receive = async (message: CallServerMessage) => {\n switch (message.type) {\n case 'peers': {\n const present = new Set(message.members)\n for (const member of peers.keys()) if (!present.has(member)) disconnect(member)\n for (const member of present) if (!peers.has(member)) connect(member)\n return\n }\n case 'signal':\n return signal(message.from, message.description, message.candidate)\n case 'tracks':\n remote = message.tracks\n emitTracks()\n return\n case 'published':\n publishing?.resolve()\n return\n case 'publish-refused':\n publishing?.reject(new PublishRefused(message.reason))\n return\n }\n }\n\n const publishNow = async (tracks: Partial<Record<CallTrackSource, MediaStreamTrack>>) => {\n const added = Object.entries(tracks) as [CallTrackSource, MediaStreamTrack][]\n for (const [source] of added) if (local.has(source)) throw new Error(`The call already sends a ${source} track: unpublish it first`)\n if (added.length === 0) return\n const sending = added.map(([source, track]): [CallTrackSource, LocalTrack] => {\n const stream = new MediaStream([track])\n return [source, { track, sid: stream.id, stream }]\n })\n const answered = new Promise<void>((resolve, reject) => (publishing = { resolve, reject }))\n send({ type: 'publish', tracks: sending.map(([source, { track, sid }]) => ({ cid: sid, kind: track.kind as 'audio' | 'video', source })) })\n try {\n await answered\n } finally {\n publishing = undefined\n }\n for (const [source, track] of sending) {\n local.set(source, track)\n for (const peer of peers.values()) peer.senders.set(source, sendOn(peer.pc, track))\n }\n }\n\n return {\n receive,\n publish: (tracks) => {\n const next = publishes.then(() => publishNow(tracks))\n publishes = next.catch(() => {})\n return next\n },\n unpublish: async (source) => {\n const sending = local.get(source)\n if (!sending) return\n local.delete(source)\n for (const peer of peers.values()) {\n const sender = peer.senders.get(source)\n if (sender && peer.pc.signalingState !== 'closed') peer.pc.removeTrack(sender)\n peer.senders.delete(source)\n }\n send({ type: 'unpublish', sid: sending.sid })\n },\n mute: (source, muted) => {\n const sending = local.get(source)\n if (!sending) return\n sending.track.enabled = !muted\n send({ type: 'mute', sid: sending.sid, muted })\n },\n restartIce: async () => {\n for (const peer of peers.values()) peer.pc.restartIce()\n },\n // The browsers' connections outlast the server's session: a new one only needs the member's tracks.\n resumeState: async (participant) => ({\n participant,\n tracks: [...local].map(([source, { track, sid }]) => ({ cid: sid, sid, kind: track.kind as 'audio' | 'video', source })),\n }),\n resumed: async () => {},\n sending: () => new Map([...local].map(([source, { track }]) => [source, { track, simulcast: false }])),\n connections: () => Promise.all([...peers].map(([member, peer]) => connectionOf(peer.pc, member))),\n close: () => {\n publishing?.reject(new Error('The call ended'))\n for (const member of [...peers.keys()]) disconnect(member)\n },\n }\n}\n","/**\n * One offer in flight at a time: a change while an offer waits for its answer offers once more after it. `settled`\n * resolves once no offer is in flight or queued, so a caller can wait for its change to be agreed.\n */\nexport const negotiation = (offer: () => Promise<void>) => {\n let inFlight = false\n let again = false\n const waiting: (() => void)[] = []\n\n const start = async () => {\n inFlight = true\n again = false\n await offer()\n }\n const settle = () => {\n for (const resolve of waiting.splice(0)) resolve()\n }\n\n return {\n /** Offers now, or once the offer in flight is answered. */\n request: async () => {\n if (inFlight) {\n again = true\n return\n }\n await start()\n },\n /** The answer to the offer in flight arrived: offers again when a change came meanwhile. */\n answered: async () => {\n inFlight = false\n if (again) return start()\n settle()\n },\n /** The offer in flight will not be answered, such as on a lost session: it is made again by the next `request`. */\n abandon: () => {\n if (inFlight) again = true\n inFlight = false\n },\n /** Whether an offer waits to be made again after `abandon`. */\n get pending() {\n return again\n },\n settled: () => (inFlight || again ? new Promise<void>((resolve) => waiting.push(resolve)) : Promise.resolve()),\n /** Forgets every offer, for a new peer connection; whoever waited is let go. */\n reset: () => {\n inFlight = false\n again = false\n settle()\n },\n }\n}\n","import { PublishRefused } from './publish-refused'\nimport type { CallCandidate, CallRemoteTrack, CallResume, CallServerMessage, CallTrackRequest, CallTrackSource, CallVideoLayer } from '@protobase/schema/internal'\nimport { connectionOf } from './connection-stats'\nimport { createPeerConnection as newPeerConnection, type MediaLink, type MediaLinkInput, type PublishOptions } from './media-link'\nimport { negotiation } from './negotiation'\n\ntype LocalTrack = { source: CallTrackSource; track: MediaStreamTrack; transceiver: RTCRtpTransceiver; sid?: string; simulcast: boolean }\n\n// Simulcast in a quarter, half and full size: what the media server forwards to each member depends on how they show it.\nconst simulcastLayers = [\n { rid: 'q', quality: 'low', scale: 4, maxBitrate: 150_000 },\n { rid: 'h', quality: 'medium', scale: 2, maxBitrate: 500_000 },\n { rid: 'f', quality: 'high', scale: 1, maxBitrate: 1_200_000 },\n] as const\nconst singleBitrate = 1_200_000\n\nconst trackRequest = (source: CallTrackSource, track: MediaStreamTrack, simulcast: boolean): CallTrackRequest => {\n if (track.kind === 'audio') return { cid: track.id, kind: 'audio', source }\n const { width = 0, height = 0 } = track.getSettings()\n const layers: CallVideoLayer[] = simulcast\n ? simulcastLayers.map((layer) => ({ quality: layer.quality, width: Math.round(width / layer.scale), height: Math.round(height / layer.scale), bitrate: layer.maxBitrate }))\n : []\n return { cid: track.id, kind: 'video', source, width, height, ...(simulcast && { layers }) }\n}\n\nconst sendEncodings = (track: MediaStreamTrack, simulcast: boolean): RTCRtpEncodingParameters[] | undefined => {\n if (track.kind === 'audio') return undefined\n if (!simulcast) return [{ maxBitrate: singleBitrate }]\n return simulcastLayers.map((layer) => ({ rid: layer.rid, scaleResolutionDownBy: layer.scale, maxBitrate: layer.maxBitrate }))\n}\n\n/**\n * The media link to a media server, over a single `RTCPeerConnection`: the browser always offers, one offer at a time,\n * and the server's answer maps each receiving section's `mid` to the track it carries. The link holds no media library;\n * everything it says goes through `send` to Protobase, which speaks to the media server.\n */\nexport const sfuLink = ({ iceServers, send, onTracks, onUnpublished, createPeerConnection = newPeerConnection }: MediaLinkInput): MediaLink => {\n const pc = createPeerConnection({ iceServers, bundlePolicy: 'max-bundle' })\n const local = new Map<CallTrackSource, LocalTrack>()\n // Candidates that arrive before the first answer wait for it.\n const early: CallCandidate[] = []\n let mids: Record<string, string> = {}\n let remote: CallRemoteTrack[] = []\n let offerId = 0\n let publishing: { resolve: (tracks: { cid: string; sid: string }[]) => void; reject: (error: Error) => void } | undefined\n let publishes: Promise<unknown> = Promise.resolve()\n\n const offers = negotiation(async () => {\n const offer = await pc.createOffer()\n await pc.setLocalDescription(offer)\n send({ type: 'offer', sdp: offer.sdp!, id: ++offerId })\n })\n // Chrome refuses an offer with nothing in it: a member who only listens waits for the server's `sections`. Messages\n // from the server only start an offer, since its answer is a later message.\n const offer = async () => {\n if (pc.getTransceivers().length > 0) await offers.request()\n }\n const negotiate = async () => {\n await offer()\n await offers.settled()\n }\n\n const receivedTrack = (sid: string) => {\n const mid = Object.keys(mids).find((key) => mids[key] === sid)\n return mid === undefined ? undefined : pc.getTransceivers().find((transceiver) => transceiver.mid === mid)?.receiver.track\n }\n const emitTracks = () => onTracks(remote.map((track) => ({ ...track, ...(receivedTrack(track.sid) && { track: receivedTrack(track.sid) }) })))\n\n pc.onicecandidate = (event) => {\n if (event.candidate) send({ type: 'candidate', candidate: event.candidate.toJSON() as CallCandidate })\n }\n // A path that failed, such as after a network change, gets new ICE credentials.\n pc.oniceconnectionstatechange = () => {\n if (pc.iceConnectionState === 'failed') void restartIce()\n }\n pc.ontrack = () => emitTracks()\n\n const restartIce = async () => {\n pc.restartIce()\n await negotiate()\n }\n\n const stopSending = (source: CallTrackSource) => {\n const sending = local.get(source)\n if (!sending) return false\n local.delete(source)\n if (pc.signalingState !== 'closed') pc.removeTrack(sending.transceiver.sender)\n return true\n }\n\n const receive = async (message: CallServerMessage) => {\n switch (message.type) {\n case 'answer': {\n if (message.id !== offerId) return\n mids = { ...mids, ...message.mids }\n await pc.setRemoteDescription({ type: 'answer', sdp: message.sdp })\n for (const candidate of early.splice(0)) await pc.addIceCandidate(candidate)\n emitTracks()\n await offers.answered()\n return\n }\n case 'candidate':\n if (pc.remoteDescription) await pc.addIceCandidate(message.candidate)\n else early.push(message.candidate)\n return\n case 'sections':\n for (let i = 0; i < message.audio; i++) pc.addTransceiver('audio', { direction: 'recvonly' })\n for (let i = 0; i < message.video; i++) pc.addTransceiver('video', { direction: 'recvonly' })\n await offer()\n return\n case 'tracks':\n remote = message.tracks\n emitTracks()\n return\n case 'unpublished': {\n const sending = [...local.values()].find((track) => track.sid === message.sid)\n if (!sending) return\n stopSending(sending.source)\n await offer()\n onUnpublished(sending.source)\n return\n }\n case 'published':\n publishing?.resolve(message.tracks)\n return\n case 'publish-refused':\n publishing?.reject(new PublishRefused(message.reason))\n return\n }\n }\n\n const publishNow = async (tracks: Partial<Record<CallTrackSource, MediaStreamTrack>>, options: PublishOptions) => {\n const added = (Object.entries(tracks) as [CallTrackSource, MediaStreamTrack][]).map(([source, track]) => {\n if (local.has(source)) throw new Error(`The call already sends a ${source} track: unpublish it first`)\n const simulcast = track.kind === 'video' && Boolean(options.simulcast)\n const encodings = sendEncodings(track, simulcast)\n const transceiver = pc.addTransceiver(track, { direction: 'sendonly', ...(encodings && { sendEncodings: encodings }) })\n return { source, track, transceiver, simulcast } satisfies LocalTrack\n })\n if (added.length === 0) return\n const answered = new Promise<{ cid: string; sid: string }[]>((resolve, reject) => (publishing = { resolve, reject }))\n send({ type: 'publish', tracks: added.map((track) => trackRequest(track.source, track.track, track.simulcast)) })\n try {\n const sids = await answered\n for (const track of added) local.set(track.source, { ...track, sid: sids.find((sid) => sid.cid === track.track.id)!.sid })\n } catch (error) {\n for (const track of added) track.transceiver.stop()\n throw error\n } finally {\n publishing = undefined\n }\n await negotiate()\n }\n\n return {\n receive,\n /** Sends the tracks, under the sources they carry; rejects when the member may not send them. One publish at a time. */\n publish: (tracks: Partial<Record<CallTrackSource, MediaStreamTrack>>, options: PublishOptions = {}) => {\n const next = publishes.then(() => publishNow(tracks, options))\n publishes = next.catch(() => {})\n return next\n },\n /** Stops sending the source's track; the track itself goes on until the app stops it. */\n unpublish: async (source: CallTrackSource) => {\n if (stopSending(source)) await negotiate()\n },\n mute: (source: CallTrackSource, muted: boolean) => {\n const sending = local.get(source)\n if (!sending?.sid) return\n sending.track.enabled = !muted\n send({ type: 'mute', sid: sending.sid, muted })\n },\n restartIce,\n /** What a new server session needs to resume this link, after an offer still in flight is taken back. */\n resumeState: async (participant: string): Promise<Omit<CallResume, 'call'> | undefined> => {\n if (pc.signalingState === 'have-local-offer') {\n await pc.setLocalDescription({ type: 'rollback' })\n offers.abandon()\n }\n if (!pc.localDescription || !pc.remoteDescription) return undefined\n const tracks = [...local.values()].flatMap((track) => (track.sid ? [{ cid: track.track.id, sid: track.sid, kind: track.track.kind as 'audio' | 'video', source: track.source }] : []))\n return { participant, offer: pc.localDescription.sdp, answer: pc.remoteDescription.sdp, tracks }\n },\n /** After a resume: offers what changed while the session was lost. */\n resumed: async () => {\n if (offers.pending) await offer()\n },\n /** The tracks the member sends, by source, to publish again after a rejoin. */\n sending: () => new Map([...local.values()].map((track) => [track.source, { track: track.track, simulcast: track.simulcast }])),\n connections: async () => [await connectionOf(pc)],\n close: () => {\n publishing?.reject(new Error('The call ended'))\n offers.reset()\n pc.close()\n },\n }\n}\n","import type { CallClientMessage, CallLeftReason, CallRosterMember, CallServerMessage, CallTrackSource } from '@protobase/schema/internal'\nimport type { CallConnection } from './connection-stats'\nimport type { CallTrack, MediaLink, MediaLinkInput, PublishOptions } from './media-link'\nimport { peerLink } from './peer-link'\nimport { sfuLink } from './sfu-link'\n\n/** Where a call stands: `resuming` while the link to Protobase is restored, with media still flowing. */\nexport type CallState = { state: 'connecting' } | { state: 'joined' } | { state: 'resuming' } | { state: 'left'; reason: CallLeftReason; error?: unknown }\n\nexport type JoinCallOptions = {\n /**\n * The socket of the app's function that admits the member, such as `/api/functions/meeting?call=42`: a path on the\n * page's origin, or an absolute `http(s)` or `ws(s)` URL. The browser sends its session cookie with it.\n */\n url: string\n /** Every track of other members the member hears, whenever one comes, goes or its media arrives. */\n onTracks?: (tracks: CallTrack[]) => void\n /** Everyone in the call, the member too, in the order they came, whenever that changes. */\n onMembers?: (members: CallRosterMember[]) => void\n /** Who speaks how loudly, from 0 to 1, for the members whose level changed. */\n onSpeakers?: (speakers: { member: string; level: number }[]) => void\n onState?: (state: CallState) => void\n /** The media server stopped one of the member's own tracks, such as after a demotion. */\n onUnpublished?: (source: CallTrackSource) => void\n /** How long to wait before the `attempt`th try to restore a lost link. */\n retryDelayMs?: (attempt: number) => number\n /** How many tries in a row to restore a lost link, or to get in while the server fails, before the call is left. Default 8. */\n maxRetries?: number\n WebSocket?: typeof WebSocket\n createPeerConnection?: (configuration: RTCConfiguration) => RTCPeerConnection\n}\n\nexport type Call = {\n /** The call, as the record's calls list it and `calls.remove` takes it. */\n readonly id: string\n /** The member's participant in the media server. */\n readonly participant: string\n /** Everyone in the call now, the member too. */\n members: () => CallRosterMember[]\n /** Sends tracks under the sources they carry, such as `{ camera, microphone }`; rejects when the member may not. */\n publish: (tracks: Partial<Record<CallTrackSource, MediaStreamTrack>>, options?: PublishOptions) => Promise<void>\n unpublish: (source: CallTrackSource) => Promise<void>\n mute: (source: CallTrackSource, muted: boolean) => void\n /** How large remote video tracks are shown, so the media server sends a layer that fits, or `hidden` for none. */\n view: (sids: string[], size: { width: number; height: number } | 'hidden') => void\n /** New ICE credentials, such as after a network change; a failed connection restarts by itself. */\n restartIce: () => Promise<void>\n leave: () => void\n /** The tracks of other members the member hears now. */\n tracks: () => CallTrack[]\n /** How each of the member's connections fares now: to each other member, or to the media server. */\n connections: () => Promise<CallConnection[]>\n}\n\nconst backoff = (attempt: number) => Math.min(10_000, 500 * 2 ** attempt)\n\nconst socketUrl = (url: string) => {\n const resolved = new URL(url, globalThis.location?.href)\n resolved.protocol = resolved.protocol.replace(/^http/, 'ws')\n return resolved.href\n}\n\n/** Close codes after which the member is out of the call: left, or refused by the app. */\nconst leftCodes: Record<number, CallLeftReason> = { 1000: 'ended', 1008: 'removed' }\n/** Close codes of a server that failed, or was too busy, for now: getting in is tried again. */\nconst failedCodes = new Set([1011, 1013])\n\n/**\n * Joins a call through the app's function socket and resolves once the member is in it. Media flows over plain\n * `RTCPeerConnection`s, to the media server or straight to the other members, as the app's calls are configured;\n * Protobase relays their offers and answers and decides who is in the call and who hears whom. A lost socket, such as during a deploy, is restored with the browser's own state while\n * media keeps flowing; when the media server no longer knows the member, the call is joined again with the same tracks.\n */\nexport const joinCall = (options: JoinCallOptions): Promise<Call> => {\n const WebSocketOf = options.WebSocket ?? WebSocket\n const retryDelay = options.retryDelayMs ?? backoff\n const maxRetries = options.maxRetries ?? 8\n const url = socketUrl(options.url)\n\n let socket: WebSocket\n let link: MediaLink | undefined\n let participant = ''\n let callId = ''\n let members: CallRosterMember[] = []\n let remote: CallTrack[] = []\n let ended = false\n let rejoin = false\n // Whether the socket reached the server, and whether the server took the resume it sent.\n let opened = false\n let resumedSinceOpen = false\n let failures = 0\n let chain: Promise<void> = Promise.resolve()\n let joined: { resolve: (call: Call) => void; reject: (error: unknown) => void }\n const result = new Promise<Call>((resolve, reject) => (joined = { resolve, reject }))\n\n const send = (message: CallClientMessage) => {\n if (socket.readyState === WebSocketOf.OPEN) socket.send(JSON.stringify(message))\n }\n const setState = (state: CallState) => options.onState?.(state)\n\n const end = (reason: CallLeftReason, error?: unknown) => {\n if (ended) return\n ended = true\n link?.close()\n link = undefined\n if (socket.readyState === WebSocketOf.OPEN || socket.readyState === WebSocketOf.CONNECTING) socket.close(1000)\n joined.reject(error ?? new Error(`The call was left: ${reason}`))\n setState({ state: 'left', reason, ...(error !== undefined && { error }) })\n }\n\n // The link the call's mode needs: to a media server, or to each other member.\n const newLink = (joined: Extract<CallServerMessage, { type: 'joined' }>) => {\n const input: MediaLinkInput = {\n iceServers: joined.iceServers,\n send,\n onTracks: (tracks) => {\n remote = tracks\n options.onTracks?.(tracks)\n },\n onUnpublished: (source) => options.onUnpublished?.(source),\n ...(options.createPeerConnection && { createPeerConnection: options.createPeerConnection }),\n }\n return joined.mode === 'peer' ? peerLink(joined.participant, input) : sfuLink(input)\n }\n\n const handle = async (message: CallServerMessage) => {\n switch (message.type) {\n case 'joined': {\n const before = link?.sending()\n link?.close()\n participant = message.participant\n callId = message.call\n link = newLink(message)\n failures = 0\n setState({ state: 'joined' })\n joined.resolve(call)\n // A rejoin sends the same tracks again, outside the message chain, since its answer is a later message.\n for (const [source, { track, simulcast }] of before ?? []) void call.publish({ [source]: track }, { simulcast }).catch((error: unknown) => end('ended', error))\n return\n }\n case 'resumed':\n resumedSinceOpen = true\n failures = 0\n setState({ state: 'joined' })\n await link?.resumed()\n return\n case 'speakers':\n options.onSpeakers?.(message.speakers)\n return\n case 'members':\n members = message.members\n options.onMembers?.(members)\n return\n case 'left':\n if (message.reason === 'rejoin') rejoin = true\n else end(message.reason)\n return\n default:\n await link?.receive(message)\n }\n }\n\n const connect = (mode: 'join' | 'resume') => {\n opened = false\n resumedSinceOpen = false\n socket = new WebSocketOf(url)\n socket.onopen = () => {\n opened = true\n chain = chain.then(async () => {\n const resume = mode === 'resume' && link ? await link.resumeState(participant) : undefined\n send(resume ? { type: 'resume', call: callId, ...resume } : { type: 'join' })\n })\n }\n socket.onmessage = (event) => {\n const message = JSON.parse(String(event.data)) as CallServerMessage\n chain = chain.then(() => handle(message)).catch((error: unknown) => end('ended', error))\n }\n socket.onclose = (event) => {\n chain = chain.then(() => closed(mode, event.code))\n }\n }\n\n const closed = (mode: 'join' | 'resume', code: number) => {\n if (ended) return\n if (rejoin) {\n rejoin = false\n return connect('join')\n }\n const left = leftCodes[code]\n if (left) return end(left)\n if (!participant && !failedCodes.has(code)) return end('refused')\n failures++\n if (failures > maxRetries) return end(participant ? 'ended' : 'unavailable')\n setState(participant ? { state: 'resuming' } : { state: 'connecting' })\n // A resume the server got but did not take is not tried again: the member joins anew with the same tracks. One that\n // never reached a server, such as during a deploy, is tried again.\n const next = mode === 'resume' && opened && !resumedSinceOpen ? 'join' : 'resume'\n setTimeout(() => {\n if (!ended) connect(next)\n }, retryDelay(failures - 1))\n }\n\n const call: Call = {\n get id() {\n return callId\n },\n get participant() {\n return participant\n },\n members: () => members,\n publish: async (tracks, publishOptions) => {\n if (!link) throw new Error('The call was left')\n await link.publish(tracks, publishOptions)\n },\n unpublish: async (source) => {\n await link?.unpublish(source)\n },\n mute: (source, muted) => link?.mute(source, muted),\n view: (sids, size) => send(size === 'hidden' ? { type: 'view', sids, width: 0, height: 0, hidden: true } : { type: 'view', sids, ...size }),\n restartIce: async () => {\n await link?.restartIce()\n },\n leave: () => {\n if (ended) return\n send({ type: 'leave' })\n end('ended')\n },\n tracks: () => remote,\n connections: async () => (link ? link.connections() : []),\n }\n\n setState({ state: 'connecting' })\n connect('join')\n return result\n}\n"],"mappings":"AACA,IAAaI,EAAb,cAAoC,KAAM,CACxC,YAAY,EAAgB,CAC1B,MAAMC,CAAM,EACZ,KAAK,KAAO,gBACd,CACF,ECmCaC,EAAwB,GAAoC,IAAI,kBAAkBC,CAAa,EChC/FC,EAAW,GAA8E,CACpG,IAAMC,EAAQ,CAAC,GAAGC,CAAM,EAClBC,EAAYF,EAAM,KAAM,GAASG,EAAK,OAAS,aAAe,OAAOA,EAAK,yBAA4B,QAAQ,EAE9GC,EAAOJ,EAAM,KAAM,GAASG,EAAK,OAAS,mBAAqBA,EAAK,KAAOD,GAAW,yBAA4B,CAACA,GAAaC,EAAK,WAAa,IAAU,CAACD,GAAaC,EAAK,YAAc,IAAQA,EAAK,QAAU,YAAa,EACnOE,EAAO,EACPC,EAAW,EACf,IAAK,IAAMH,KAAQH,EACbG,EAAK,OAAS,gBAClB,GAAQ,KAAK,IAAI,EAAG,OAAOA,EAAK,aAAe,CAAC,CAAC,EACjD,GAAY,OAAOA,EAAK,iBAAmB,CAAC,GAE9C,IAAMI,EAAY,OAAOH,GAAM,sBAAyB,SAAWA,EAAK,qBAAuB,IAAO,IAAA,GACtG,MAAO,CAAE,GAAIG,IAAc,IAAA,IAAa,CAAE,YAAaA,CAAU,EAAI,GAAIF,EAAOC,EAAW,GAAK,CAAE,UAAWD,GAAQA,EAAOC,EAAU,CAAG,CAC3I,EAGaE,EAAe,MAAO,EAAuB,IAA6C,CACrG,IAAMC,EAAQC,EAAG,gBACXT,EAASQ,IAAU,YAAcV,GAAS,MAAMW,EAAG,SAAS,EAAA,CAAG,OAAO,CAAmB,EAAI,CAAC,EACpG,MAAO,CAAE,GAAIC,IAAW,I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F,OACN,MAAM,GACN,OAAQlB,EACR,WACA,QAASU,EAAM,QACf,UAAW,EAAK,IAAU,CACxBM,EAAS5H,EAAKnH,CAAK,EACnBgO,EAASD,EAAM,SAAS5G,CAAG,EAAI4G,EAAM,OAAQ,GAAWmB,IAAW/H,CAAG,EAAI,CAAC,GAAG4G,EAAO5G,CAAG,CAAC,CAC3F,CACD,GACA4G,EAAM,OAAS,IACd,EAAA3N,EAAA,KAAC,MAAD,CAAK,UAAU,uBACZ,SAAA2N,EAAM,IAAK,IACV,EAAA3N,EAAA,KAAC+O,GAAD,CAAiB,MAAOL,EAAQ3H,CAAG,EAAG,aAAgB6G,EAASD,EAAM,OAAQ,GAAWmB,IAAW/H,CAAG,CAAC,CAAI,EAA/FA,CAA+F,CAC5G,CACE,EAEJ,GAET","names":["__iconData","MicOff","createLucideIcon","Mic","MonitorUp","MonitorX","PhoneOff","Phone","VideoOff","Video","WifiOff","dayBefore","day","sameChatDay","viewerZone","dayIn","a","zone","b","chatDayLabel","time","today","now","text","formatWeekdayDate","ChatDivider","shown","label","line","cn","tone","import_jsx_runtime","RecordLink","rest","display","useOptionalListDisplay","around","useLayoutRecord","name","resource","AppLink","row","recordKey","signedInUserOf","state","useSignedInUser","useOptionalAuth","useMemo","keepPlaying","track","play","element","error","TrackVideo","ref","useCallback","TrackAudio","toggle","on","CallCheck","camera","cameraOn","Avatar","initialsOf","hueOf","member","notices","notice","Button","microphoneOn","microphone","onMicrophone","cameraAvailable","onCamera","onJoin","RouteLink","cancel","said","CallMessage","reason","onJoinAgain","gridColumns","width","count","callLayout","sharers","people","connectionQuality","roundTripMs","lostRatio","cannotConnect","since","activeSpeaker","loudest","level","levels","threshold","received","tracks","source","callPeople","members","self","shared","nameOf","speaker","own","theirs","screen","screenAudio","link","connections","connection","seen","CallControls","onShare","sharing","leave","buttonClass","CallTile","person","className","useWidth","setWidth","useState","observer","entry","stripMax","Grid","columns","Share","more","narrow","sharer","Tiles","layout","CallStage","messages","message","Spinner","controls","audio","key","readEveryMs","holdMs","levelOf","analyser","samples","sum","sample","useActiveSpeaker","setSpeaker","ids","import_react","context","analysers","last","timer","blockedNames","missingNames","one","media","kind","openDevices","stream","video","connectionsEveryMs","stop","useCallSession","phase","setPhase","devices","setDevices","setMicrophoneOn","setCameraOn","setTracks","setMembers","setConnections","setScreen","refusedSending","setRefusedSending","call","useRef","gone","opening","cancelled","opened","join","__vitePreload","joined","joinCall","made","sending","PublishRefused","url","toggleMicrophone","next","toggleCamera","stopSharing","toggleScreen","canShare","deviceNotices","CallView","session","auth","user","voices","useRecordCallAddress","useAppAddress","joining","address","target","to","open","href","RecordCall","useRecordCalls","client","useClient","queryClient","useQueryClient","keys","query","useQuery","queryKey","channel","offCalls","callsChannelEvent","offStatus","status","CallMark","isPending","ongoing","_Fragment","box","carouselSlides","images","image","shownImage","Carousel","slides","carousel","useCarousel","CarouselTrack","FileImage","fit","CarouselControls","Choices","options","option","value","onChange","usePickedLabels","sorted","keepPreviousData","fetchLabels","view","RecordPicker","useAdminMeta","resources","props","views","known","setKnown","fetched","labelOf","remember","current","RelationPicker","chosen","Token"],"ignoreList":[0,1,2,3,4,5,6,7,8],"sources":["../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/mic-off.mjs","../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/mic.mjs","../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/monitor-up.mjs","../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/monitor-x.mjs","../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/phone-off.mjs","../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/phone.mjs","../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/video-off.mjs","../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/video.mjs","../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/wifi-off.mjs","../../../src/chat/chat-day.ts","../../../src/chat/chat-divider.tsx","../../../src/app/displays/record-link.tsx","../../../src/auth/use-signed-in-user.ts","../../../src/calls/track-media.tsx","../../../src/calls/call-check.tsx","../../../src/calls/call-message.tsx","../../../src/calls/call-layout.ts","../../../src/calls/call-people.ts","../../../src/calls/call-controls.tsx","../../../src/calls/call-tile.tsx","../../../src/calls/use-width.ts","../../../src/calls/call-stage.tsx","../../../src/calls/use-audio-levels.ts","../../../src/calls/devices.ts","../../../src/calls/use-call-session.ts","../../../src/calls/call-view.tsx","../../../src/calls/use-record-call-address.ts","../../../src/calls/record-call.tsx","../../../src/calls/use-record-calls.ts","../../../src/calls/call-mark.tsx","../../../src/carousel/carousel-images.ts","../../../src/carousel/carousel.tsx","../../../src/primitives/choices.tsx","../../../src/app/use-picked-labels.ts","../../../src/app/record-picker.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"mic-off\",\n size: 24,\n node: [\n [\"path\", { d: \"M12 19v3\", key: \"npa21l\" }],\n [\"path\", { d: \"M15 9.34V5a3 3 0 0 0-5.68-1.33\", key: \"1gzdoj\" }],\n [\"path\", { d: \"M16.95 16.95A7 7 0 0 1 5 12v-2\", key: \"cqa7eg\" }],\n [\"path\", { d: \"M18.89 13.23A7 7 0 0 0 19 12v-2\", key: \"16hl24\" }],\n [\"path\", { d: \"m2 2 20 20\", key: \"1ooewy\" }],\n [\"path\", { d: \"M9 9v3a3 3 0 0 0 5.12 2.12\", key: \"r2i35w\" }]\n ]\n};\n__iconData.node;\nconst MicOff = createLucideIcon(__iconData);\n\nexport { __iconData, MicOff as default };\n//# sourceMappingURL=mic-off.mjs.map\n","/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"mic\",\n size: 24,\n node: [\n [\"path\", { d: \"M12 19v3\", key: \"npa21l\" }],\n [\"path\", { d: \"M19 10v2a7 7 0 0 1-14 0v-2\", key: \"1vc78b\" }],\n [\"rect\", { x: \"9\", y: \"2\", width: \"6\", height: \"13\", rx: \"3\", key: \"s6n7sd\" }]\n ]\n};\n__iconData.node;\nconst Mic = createLucideIcon(__iconData);\n\nexport { __iconData, Mic as default };\n//# sourceMappingURL=mic.mjs.map\n","/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"monitor-up\",\n size: 24,\n node: [\n [\"path\", { d: \"m9 10 3-3 3 3\", key: \"11gsxs\" }],\n [\"path\", { d: \"M12 13V7\", key: \"h0r20n\" }],\n [\"rect\", { width: \"20\", height: \"14\", x: \"2\", y: \"3\", rx: \"2\", key: \"48i651\" }],\n [\"path\", { d: \"M12 17v4\", key: \"1riwvh\" }],\n [\"path\", { d: \"M8 21h8\", key: \"1ev6f3\" }]\n ]\n};\n__iconData.node;\nconst MonitorUp = createLucideIcon(__iconData);\n\nexport { __iconData, MonitorUp as default };\n//# sourceMappingURL=monitor-up.mjs.map\n","/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"monitor-x\",\n size: 24,\n node: [\n [\"path\", { d: \"m14.5 12.5-5-5\", key: \"1jahn5\" }],\n [\"path\", { d: \"m9.5 12.5 5-5\", key: \"1k2t7b\" }],\n [\"rect\", { width: \"20\", height: \"14\", x: \"2\", y: \"3\", rx: \"2\", key: \"48i651\" }],\n [\"path\", { d: \"M12 17v4\", key: \"1riwvh\" }],\n [\"path\", { d: \"M8 21h8\", key: \"1ev6f3\" }]\n ]\n};\n__iconData.node;\nconst MonitorX = createLucideIcon(__iconData);\n\nexport { __iconData, MonitorX as default };\n//# sourceMappingURL=monitor-x.mjs.map\n","/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"phone-off\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272\",\n key: \"1wngk7\"\n }\n ],\n [\"path\", { d: \"M22 2 2 22\", key: \"y4kqgn\" }],\n [\n \"path\",\n {\n d: \"M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473\",\n key: \"10hv5p\"\n }\n ]\n ]\n};\n__iconData.node;\nconst PhoneOff = createLucideIcon(__iconData);\n\nexport { __iconData, PhoneOff as default };\n//# sourceMappingURL=phone-off.mjs.map\n","/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"phone\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384\",\n key: \"9njp5v\"\n }\n ]\n ]\n};\n__iconData.node;\nconst Phone = createLucideIcon(__iconData);\n\nexport { __iconData, Phone as default };\n//# sourceMappingURL=phone.mjs.map\n","/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"video-off\",\n size: 24,\n node: [\n [\n \"path\",\n { d: \"M10.66 6H14a2 2 0 0 1 2 2v2.5l5.248-3.062A.5.5 0 0 1 22 7.87v8.196\", key: \"w8jjjt\" }\n ],\n [\"path\", { d: \"M16 16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2\", key: \"1xawa7\" }],\n [\"path\", { d: \"m2 2 20 20\", key: \"1ooewy\" }]\n ]\n};\n__iconData.node;\nconst VideoOff = createLucideIcon(__iconData);\n\nexport { __iconData, VideoOff as default };\n//# sourceMappingURL=video-off.mjs.map\n","/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"video\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5\",\n key: \"ftymec\"\n }\n ],\n [\"rect\", { x: \"2\", y: \"6\", width: \"14\", height: \"12\", rx: \"2\", key: \"158x01\" }]\n ]\n};\n__iconData.node;\nconst Video = createLucideIcon(__iconData);\n\nexport { __iconData, Video as default };\n//# sourceMappingURL=video.mjs.map\n","/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"wifi-off\",\n size: 24,\n node: [\n [\"path\", { d: \"M12 20h.01\", key: \"zekei9\" }],\n [\"path\", { d: \"M8.5 16.429a5 5 0 0 1 7 0\", key: \"1bycff\" }],\n [\"path\", { d: \"M5 12.859a10 10 0 0 1 5.17-2.69\", key: \"1dl1wf\" }],\n [\"path\", { d: \"M19 12.859a10 10 0 0 0-2.007-1.523\", key: \"4k23kn\" }],\n [\"path\", { d: \"M2 8.82a15 15 0 0 1 4.177-2.643\", key: \"1grhjp\" }],\n [\"path\", { d: \"M22 8.82a15 15 0 0 0-11.288-3.764\", key: \"z3jwby\" }],\n [\"path\", { d: \"m2 2 20 20\", key: \"1ooewy\" }]\n ]\n};\n__iconData.node;\nconst WifiOff = createLucideIcon(__iconData);\n\nexport { __iconData, WifiOff as default };\n//# sourceMappingURL=wifi-off.mjs.map\n","import { formatWeekdayDate } from '../format/date'\nimport { dayIn, viewerZone } from '../format/zone'\nimport { text } from './messages'\n\nconst dayBefore = (day: string) => new Date(Date.parse(`${day}T00:00:00Z`) - 86_400_000).toISOString().slice(0, 10)\n\n/** Whether two ISO timestamps fall on the same day in `zone`, the viewer's unless given: a day divider goes between two messages that do not. */\nexport const sameChatDay = (a: string, b: string, zone = viewerZone()) => dayIn(Date.parse(a), zone) === dayIn(Date.parse(b), zone)\n\n/** The label of the divider above a day's first message, sent at `time`: \"Today\", \"Yesterday\" or \"Mon, 26 Oct 2026\", as the viewer's calendar in `zone` has it. */\nexport const chatDayLabel = (time: string, now = Date.now(), zone = viewerZone()) => {\n const day = dayIn(Date.parse(time), zone)\n const today = dayIn(now, zone)\n if (day === today) return text('today')\n if (day === dayBefore(today)) return text('yesterday')\n return formatWeekdayDate(Date.parse(`${day}T00:00:00Z`))\n}\n","import { cn } from '../lib/cn'\nimport { text } from './messages'\n\nexport type ChatDividerProps =\n /** A muted line between the messages of two days, labelled with the later one, such as by `chatDayLabel`. */\n | { tone?: 'day'; label: string }\n /** A line above the first message the reader has not seen, \"New messages\" unless labelled otherwise. */\n | { tone: 'new'; label?: string }\n\n/**\n * A line across a chat with a label in its middle, between the messages of two days or above the new ones. Marked\n * `data-chat-divider`, so a thread keeps the reader's place on the message below it, not on the divider.\n */\nexport const ChatDivider = ({ tone = 'day', label }: ChatDividerProps) => {\n const shown = label ?? text('newMessages')\n const line = cn('h-px flex-1', tone === 'new' ? 'bg-danger' : 'bg-border')\n return (\n <div role=\"separator\" aria-label={shown} data-tone={tone} data-chat-divider=\"\" className=\"flex items-center gap-3 text-xs font-medium\">\n <span className={line} />\n <span className={tone === 'new' ? 'text-danger' : 'text-muted-foreground'}>{shown}</span>\n <span className={line} />\n </div>\n )\n}\n","import type { AnchorHTMLAttributes } from 'react'\nimport type { KeyValue } from '@protobase/schema'\nimport { useLayoutRecord } from '../pages/record-scope'\nimport { AppLink } from '../use-app-address'\nimport { useOptionalListDisplay } from './display-context'\nimport type { ListDisplayRow } from './list-displays'\n\ntype Target = { row: ListDisplayRow; resource?: never; recordKey?: never } | { row?: never; resource?: string; recordKey: KeyValue | readonly KeyValue[] }\n\n/**\n * A link to a record's page, through the app's addresses: a list display's `row`, or a `recordKey` of `resource`. The\n * resource defaults to the list display's or the record's around it, so a custom component never writes a path.\n */\nexport const RecordLink = ({ row, resource, recordKey, ...rest }: AnchorHTMLAttributes<HTMLAnchorElement> & Target) => {\n const display = useOptionalListDisplay()\n const around = useLayoutRecord()\n const name = resource ?? display?.resource ?? around?.model.name\n if (name === undefined) throw new Error('RecordLink needs a resource outside a list display or a record')\n return <AppLink to={{ kind: 'record', resource: name, key: row ? row.key : recordKey }} {...rest} />\n}\n","import { useMemo } from 'react'\nimport { useOptionalAuth, type AuthState } from './auth-provider'\n\n/** Who is signed in: their user id, the id `.author()` stores and mentions hold, and their name. */\nexport type SignedInUser = { id: string; name?: string }\n\n/** The signed-in person of an auth state; none while it loads, for a visitor, and before the sign-in finished. */\nexport const signedInUserOf = (state: AuthState | undefined): SignedInUser | undefined => {\n if (state?.kind !== 'signed-in') return\n const { id, name } = state.user\n return { id, ...(name && { name }) }\n}\n\n/**\n * The signed-in person, from the session the app already holds, such as for a filter on their own user id;\n * `undefined` while the session loads, for a visitor and when nobody is signed in.\n */\nexport const useSignedInUser = (): SignedInUser | undefined => {\n const state = useOptionalAuth()?.state\n return useMemo(() => signedInUserOf(state), [state])\n}\n","import { useCallback, type VideoHTMLAttributes } from 'react'\n\n// Plays the element again whenever it pauses while its track is live: a media element the page takes out and puts\n// back, as React does when it moves a tile, is paused by the browser, and nothing else would play it again. A play the\n// browser cut short, or does not allow yet, is left to the next pause.\nconst keepPlaying = (element: HTMLMediaElement, track: MediaStreamTrack) => {\n element.srcObject = new MediaStream([track])\n const play = () => {\n if (track.readyState !== 'live') return\n element.play().catch((error: unknown) => {\n if (error instanceof DOMException && (error.name === 'AbortError' || error.name === 'NotAllowedError')) return\n throw error\n })\n }\n element.addEventListener('pause', play)\n return () => element.removeEventListener('pause', play)\n}\n\n/** A video element showing the track, muted, inline, playing as soon as it can and for as long as the track is live. */\nexport const TrackVideo = ({ track, ...rest }: { track: MediaStreamTrack } & VideoHTMLAttributes<HTMLVideoElement>) => {\n const ref = useCallback((element: HTMLVideoElement | null) => (element ? keepPlaying(element, track) : undefined), [track])\n return <video ref={ref} autoPlay playsInline muted {...rest} />\n}\n\n/** Plays the track's sound, unseen, for as long as the track is live. */\nexport const TrackAudio = ({ track }: { track: MediaStreamTrack }) => {\n const ref = useCallback((element: HTMLAudioElement | null) => (element ? keepPlaying(element, track) : undefined), [track])\n return <audio ref={ref} autoPlay />\n}\n","import { Mic, MicOff, Video, VideoOff } from 'lucide-react'\nimport { hueOf, initialsOf } from '../auth/user-to-shell'\nimport { cn } from '../lib/cn'\nimport { Avatar } from '../primitives/avatar'\nimport { Button } from '../primitives/button'\nimport { RouteLink, type RouteTarget } from '../primitives/route-link'\nimport { text } from './messages'\nimport { TrackVideo } from './track-media'\n\nexport type CallCheckProps = {\n name: string\n member: string\n /** The member's camera as it will be sent, to see before joining. */\n camera?: MediaStreamTrack\n microphoneOn: boolean\n cameraOn: boolean\n /** Whether the browser has a microphone and a camera it may use. */\n microphone: boolean\n cameraAvailable: boolean\n notices: string[]\n onMicrophone: () => void\n onCamera: () => void\n onJoin: () => void\n /** Where the member goes without joining. */\n cancel: RouteTarget\n}\n\nconst toggle = (on: boolean) => cn('size-10 rounded-full', !on && 'bg-danger-soft text-danger-text')\n\n/**\n * The check of the microphone and camera before joining: the member's own camera as the others will see it, or their\n * initials, microphone and camera on and off, plain messages for a blocked or missing device, and Join.\n */\nexport const CallCheck = ({ name, member, camera, microphoneOn, cameraOn, microphone, cameraAvailable, notices, onMicrophone, onCamera, onJoin, cancel }: CallCheckProps) => (\n <section aria-label={text('preview')} className=\"flex size-full min-h-0 flex-col items-center justify-center gap-3 bg-background p-4\">\n <figure className=\"relative flex aspect-video w-full max-w-md items-center justify-center overflow-hidden rounded-lg bg-neutral-900\">\n {camera && cameraOn ? <TrackVideo track={camera} aria-label={text('preview')} className=\"size-full -scale-x-100 object-cover\" /> : <Avatar initials={initialsOf(name)} hue={hueOf(member)} size=\"md\" className=\"size-16 text-xl ring-0\" />}\n </figure>\n {notices.length > 0 && (\n <div role=\"status\" className=\"flex w-full max-w-md flex-col gap-1\">\n {notices.map((notice) => (\n <p key={notice} className=\"rounded-md bg-warning-soft px-3 py-1.5 text-xs text-foreground\">\n {notice}\n </p>\n ))}\n </div>\n )}\n <div className=\"flex items-center gap-2\">\n <Button size=\"icon\" aria-label={text('microphone')} aria-pressed={microphoneOn} disabled={!microphone} className={toggle(microphoneOn)} onClick={onMicrophone}>\n {microphoneOn ? <Mic className=\"size-4\" /> : <MicOff className=\"size-4\" />}\n </Button>\n <Button size=\"icon\" aria-label={text('camera')} aria-pressed={cameraOn} disabled={!cameraAvailable} className={toggle(cameraOn)} onClick={onCamera}>\n {cameraOn ? <Video className=\"size-4\" /> : <VideoOff className=\"size-4\" />}\n </Button>\n <Button variant=\"primary\" className=\"h-10 rounded-full px-5\" onClick={onJoin}>\n {text('joinCall')}\n </Button>\n <RouteLink to={cancel} className=\"px-2 text-sm text-muted-foreground hover:text-foreground\">\n {text('leave')}\n </RouteLink>\n </div>\n </section>\n)\n","import type { CallLeftReason } from '@protobase/client/calls'\nimport { Button } from '../primitives/button'\nimport { text } from './messages'\n\nconst said: Record<Exclude<CallLeftReason, 'rejoin'>, Parameters<typeof text>[0]> = { ended: 'ended', removed: 'removed', full: 'full', refused: 'refused', unavailable: 'unavailable' }\n\n/** Why the member is not in the call, in plain words, and, unless they were removed, a way to join again. */\nexport const CallMessage = ({ reason, onJoinAgain }: { reason: CallLeftReason; onJoinAgain?: () => void }) => (\n <section role=\"status\" className=\"flex size-full min-h-0 flex-col items-center justify-center gap-3 bg-background p-4 text-center\">\n <p className=\"text-sm text-foreground\">{text(reason === 'rejoin' ? 'ended' : said[reason])}</p>\n {onJoinAgain && reason !== 'removed' && reason !== 'refused' && <Button onClick={onJoinAgain}>{text('callAgain')}</Button>}\n </section>\n)\n","/**\n * How a call's tiles are laid out: `alone` while the member is the only one in it, `grid` for everyone at the same\n * size, `share` with a screen share large and the people in a strip beside or under it.\n */\nexport type CallLayout = { kind: 'alone' } | { kind: 'grid'; columns: number } | { kind: 'share'; sharer: string }\n\n/** Below this width the view is a phone's: one column of two people, then two columns, and the strip goes under a share. */\nexport const narrowWidth = 640\n\n/** The columns a grid of `count` tiles takes in a view `width` pixels wide: as square as fits, fewer on a phone. */\nexport const gridColumns = (count: number, width: number) => {\n if (width < narrowWidth) return count <= 2 ? 1 : 2\n return Math.min(4, Math.ceil(Math.sqrt(count)))\n}\n\n/** The layout for these people, the member included, and the member sharing their screen, the first of them if several do. */\nexport const callLayout = ({ people, sharers, width }: { people: number; sharers: readonly string[]; width: number }): CallLayout => {\n if (sharers[0] !== undefined) return { kind: 'share', sharer: sharers[0] }\n if (people <= 1) return { kind: 'alone' }\n return { kind: 'grid', columns: gridColumns(people, width) }\n}\n\n/** How a connection fares, as its tile shows it: poor past a round trip of 400 ms or a loss of 5% of the media. */\nexport const connectionQuality = ({ roundTripMs, lostRatio }: { roundTripMs?: number; lostRatio?: number }) => ((roundTripMs ?? 0) > 400 || (lostRatio ?? 0) > 0.05 ? 'poor' : 'good')\n\n/** How long a connection may stay unconnected before its tile says the browser cannot connect to that person. */\nexport const connectGiveUpMs = 15_000\n\n/** Whether the browser cannot connect to someone: their connection failed, or is not up `connectGiveUpMs` after they came. */\nexport const cannotConnect = (state: RTCPeerConnectionState | undefined, since: number, now: number) => state === 'failed' || (state !== 'connected' && now - since >= connectGiveUpMs)\n\n/** The loudest of these levels, from 0 to 1, when one is loud enough to be someone speaking. */\nexport const activeSpeaker = (levels: ReadonlyMap<string, number>, threshold = 0.05) => {\n let loudest: [string, number] | undefined\n for (const [member, level] of levels) if (level >= threshold && (!loudest || level > loudest[1])) loudest = [member, level]\n return loudest?.[0]\n}\n","import type { CallConnection, CallRosterMember, CallTrack } from '@protobase/client/calls'\nimport { cannotConnect, connectionQuality } from './call-layout'\nimport type { CallPerson } from './call-person'\n\n/** What the member sends themselves: their own tracks, and which of them are on. */\nexport type OwnMedia = { microphone?: MediaStreamTrack; camera?: MediaStreamTrack; screen?: MediaStreamTrack; microphoneOn: boolean; cameraOn: boolean }\n\nexport type PeopleInput = {\n members: readonly CallRosterMember[]\n self: string\n tracks: readonly CallTrack[]\n own: OwnMedia\n nameOf: (member: string) => string\n speaker?: string\n connections: readonly CallConnection[]\n /** When this browser first knew of each member, by member: how long their connection has had to come up. */\n seen: ReadonlyMap<string, number>\n now: number\n}\n\nconst received = (tracks: readonly CallTrack[], source: CallTrack['source']) => tracks.find((track) => track.source === source && track.track)\n\n/** Everyone in the call as the view draws them, in the order they came, the member among them as `self`. */\nexport const callPeople = ({ members, self, tracks, own, nameOf, speaker, connections, seen, now }: PeopleInput): CallPerson[] => {\n const roster = members.some((member) => member.member === self) ? members : [{ member: self, joined_at: '' }, ...members]\n return roster.map(({ member }): CallPerson => {\n const shared = { member, name: nameOf(member), ...(speaker === member && { speaking: true }) }\n if (member === self) {\n return { ...shared, self: true, ...(own.camera && { camera: own.camera }), ...(own.microphone && { microphone: own.microphone }), ...(own.screen && { screen: own.screen }), microphoneOff: !own.microphone || !own.microphoneOn, cameraOff: !own.camera || !own.cameraOn }\n }\n const theirs = tracks.filter((track) => track.member === member)\n const [camera, microphone, screen, screenAudio] = (['camera', 'microphone', 'screen', 'screen-audio'] as const).map((source) => received(theirs, source))\n const link = connections.find((connection) => connection.member === member)\n const connection = cannotConnect(link?.state, seen.get(member) ?? now, now) ? 'failed' : link?.state === 'connected' ? connectionQuality(link) : undefined\n return {\n ...shared,\n ...(camera && { camera: camera.track! }),\n ...(microphone && { microphone: microphone.track! }),\n ...(screen && { screen: screen.track! }),\n ...(screenAudio && { screenAudio: screenAudio.track! }),\n microphoneOff: !microphone || microphone.muted,\n cameraOff: !camera || camera.muted,\n ...(connection && { connection }),\n }\n })\n}\n","import { Mic, MicOff, MonitorUp, MonitorX, PhoneOff, Video, VideoOff } from 'lucide-react'\nimport { buttonClass, Button } from '../primitives/button'\nimport { RouteLink, type RouteTarget } from '../primitives/route-link'\nimport { cn } from '../lib/cn'\nimport { text } from './messages'\n\nexport type CallControlsProps = {\n microphoneOn: boolean\n cameraOn: boolean\n /** Whether the member shares their screen; no share button where the browser cannot share one, as on a phone. */\n sharing?: boolean\n onMicrophone: () => void\n onCamera: () => void\n onShare?: () => void\n /** Where Leave goes, such as the record's page without its call: leaving the page leaves the call. */\n leave: RouteTarget\n}\n\nconst toggle = (on: boolean) => cn('size-10 rounded-full', !on && 'bg-danger-soft text-danger-text')\n\n/** The member's controls: microphone, camera and screen share on and off, and Leave, a link out of the call. */\nexport const CallControls = ({ microphoneOn, cameraOn, sharing, onMicrophone, onCamera, onShare, leave }: CallControlsProps) => (\n <div role=\"toolbar\" aria-label={text('joinCall')} className=\"flex shrink-0 items-center justify-center gap-2 py-2\">\n <Button size=\"icon\" aria-label={text('microphone')} aria-pressed={microphoneOn} title={text('microphone')} className={toggle(microphoneOn)} onClick={onMicrophone}>\n {microphoneOn ? <Mic className=\"size-4\" /> : <MicOff className=\"size-4\" />}\n </Button>\n <Button size=\"icon\" aria-label={text('camera')} aria-pressed={cameraOn} title={text('camera')} className={toggle(cameraOn)} onClick={onCamera}>\n {cameraOn ? <Video className=\"size-4\" /> : <VideoOff className=\"size-4\" />}\n </Button>\n {onShare && (\n <Button size=\"icon\" aria-label={sharing ? text('stopSharing') : text('shareScreen')} aria-pressed={Boolean(sharing)} title={sharing ? text('stopSharing') : text('shareScreen')} className=\"size-10 rounded-full\" onClick={onShare}>\n {sharing ? <MonitorX className=\"size-4\" /> : <MonitorUp className=\"size-4\" />}\n </Button>\n )}\n <RouteLink to={leave} className={cn(buttonClass({ variant: 'danger' }), 'h-10 rounded-full px-4')}>\n <PhoneOff className=\"size-4\" />\n {text('leave')}\n </RouteLink>\n </div>\n)\n","import { MicOff, WifiOff } from 'lucide-react'\nimport { hueOf, initialsOf } from '../auth/user-to-shell'\nimport { cn } from '../lib/cn'\nimport { Avatar } from '../primitives/avatar'\nimport type { CallPerson } from './call-person'\nimport { text } from './messages'\nimport { TrackVideo } from './track-media'\n\n/**\n * One person in a call: their camera, or their initials while it sends nothing; their name, a mark while their\n * microphone is off or their connection is poor, a ring while they speak, and a plain message when the member's\n * browser cannot connect to them. `screen` draws their screen share instead, whole.\n */\nexport const CallTile = ({ person, screen = false, className }: { person: CallPerson; screen?: boolean; className?: string }) => {\n const track = screen ? person.screen : person.cameraOff ? undefined : person.camera\n const label = screen ? (person.self ? text('youAreSharing') : text('sharing', person.name)) : person.self ? `${person.name} (${text('you')})` : person.name\n return (\n <figure\n data-member={person.member}\n data-speaking={person.speaking ? 'true' : undefined}\n aria-label={label}\n className={cn('relative flex min-h-0 min-w-0 items-center justify-center overflow-hidden rounded-lg bg-neutral-900 ring-offset-2 ring-offset-background', person.speaking && !screen && 'ring-2 ring-success', className)}\n >\n {track ? (\n <TrackVideo track={track} className={cn('size-full', screen ? 'object-contain' : 'object-cover', person.self && !screen && '-scale-x-100')} />\n ) : (\n <Avatar initials={initialsOf(person.name)} hue={hueOf(person.member)} size=\"md\" className=\"size-16 text-xl ring-0\" />\n )}\n {person.connection === 'failed' && !person.self && (\n <p role=\"status\" className=\"absolute inset-x-1 top-1 truncate rounded bg-black/70 px-2 py-1 text-center text-xs text-white\">\n {text('cannotConnect', person.name)}\n </p>\n )}\n <figcaption className=\"absolute bottom-1.5 left-1.5 flex max-w-[calc(100%-0.75rem)] items-center gap-1 rounded bg-black/60 px-1.5 py-0.5 text-xs text-white\">\n {!screen && person.microphoneOff && <MicOff role=\"img\" aria-label={text('muted')} className=\"size-3 shrink-0\" />}\n {!screen && person.connection === 'poor' && <WifiOff role=\"img\" aria-label={text('poorConnection')} className=\"size-3 shrink-0 text-warning\" />}\n <span className=\"truncate\">{label}</span>\n </figcaption>\n </figure>\n )\n}\n","import { useCallback, useState } from 'react'\n\n/** The width of the element the returned ref is put on, followed as it changes; 0 until it is drawn. */\nexport const useWidth = <T extends HTMLElement>() => {\n const [width, setWidth] = useState(0)\n const ref = useCallback((element: T | null) => {\n if (!element) return\n setWidth(element.clientWidth)\n const observer = new ResizeObserver(([entry]) => setWidth(entry!.contentRect.width))\n observer.observe(element)\n return () => observer.disconnect()\n }, [])\n return { ref, width }\n}\n","import { Spinner } from '../primitives/spinner'\nimport { cn } from '../lib/cn'\nimport { CallControls, type CallControlsProps } from './call-controls'\nimport { callLayout, type CallLayout } from './call-layout'\nimport type { CallPerson } from './call-person'\nimport { CallTile } from './call-tile'\nimport { text } from './messages'\nimport { TrackAudio } from './track-media'\nimport { useWidth } from './use-width'\n\nexport type CallStageProps = {\n /** Everyone in the call, the member too, in the order they came. */\n people: CallPerson[]\n /** `resuming` while the link to the server is restored; media keeps flowing meanwhile. */\n state: 'joining' | 'joined' | 'resuming'\n /** Plain messages for the member, such as a blocked camera. */\n notices?: string[]\n controls: CallControlsProps\n className?: string\n}\n\n// The most people the strip beside a screen share shows; the rest are a count.\nconst stripMax = 4\n\nconst Grid = ({ people, columns }: { people: CallPerson[]; columns: number }) => (\n <div className=\"grid size-full min-h-0 gap-2\" style={{ gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`, gridTemplateRows: `repeat(${Math.ceil(people.length / columns)}, minmax(0, 1fr))` }}>\n {people.map((person) => (\n <CallTile key={person.member} person={person} />\n ))}\n </div>\n)\n\nconst Share = ({ people, sharer, narrow }: { people: CallPerson[]; sharer: CallPerson; narrow: boolean }) => {\n const shown = people.slice(0, stripMax)\n const more = people.length - shown.length\n return (\n <div className={cn('flex size-full min-h-0 gap-2', narrow ? 'flex-col' : 'flex-row')}>\n <CallTile person={sharer} screen className=\"min-h-0 flex-1\" />\n <div className={cn('flex shrink-0 gap-2', narrow ? 'h-20 flex-row' : 'w-40 flex-col')}>\n {shown.map((person) => (\n <CallTile key={person.member} person={person} className={narrow ? 'aspect-video h-full' : 'aspect-video w-full'} />\n ))}\n {more > 0 && <p className=\"flex items-center justify-center rounded-lg bg-muted px-2 text-xs text-muted-foreground\">+{more}</p>}\n </div>\n </div>\n )\n}\n\nconst Tiles = ({ layout, people, narrow }: { layout: CallLayout; people: CallPerson[]; narrow: boolean }) => {\n if (layout.kind === 'share') return <Share people={people} sharer={people.find((person) => person.member === layout.sharer)!} narrow={narrow} />\n if (layout.kind === 'grid') return <Grid people={people} columns={layout.columns} />\n return (\n <div className=\"relative size-full min-h-0\">\n <CallTile person={people[0]!} className=\"size-full\" />\n <p className=\"absolute inset-x-0 top-3 text-center text-sm text-white drop-shadow\">{text('alone')}</p>\n </div>\n )\n}\n\n/**\n * A call as the member sees it, filling its parent: everyone at the same size, with the one speaking ringed; a screen\n * share large with the people beside it, or under it on a phone; the member alone; then the controls. The others'\n * sound plays unseen.\n */\nexport const CallStage = ({ people, state, notices = [], controls, className }: CallStageProps) => {\n const { ref, width } = useWidth<HTMLDivElement>()\n const narrow = width > 0 && width < 640\n const layout = callLayout({ people: people.length, sharers: people.filter((person) => person.screen).map((person) => person.member), width })\n const messages = [...(state === 'resuming' ? [text('reconnecting')] : []), ...notices]\n return (\n <section ref={ref} aria-label={text('joinCall')} data-layout={layout.kind} className={cn('flex size-full min-h-0 flex-col gap-2 bg-background p-2', className)}>\n {messages.length > 0 && (\n <div role=\"status\" className=\"flex shrink-0 flex-col gap-1\">\n {messages.map((message) => (\n <p key={message} className=\"flex items-center gap-2 rounded-md bg-warning-soft px-3 py-1.5 text-xs text-foreground\">\n {message === text('reconnecting') && <Spinner className=\"size-3\" />}\n {message}\n </p>\n ))}\n </div>\n )}\n <div className=\"min-h-0 flex-1\">\n {state === 'joining' ? (\n <p role=\"status\" className=\"flex size-full items-center justify-center gap-2 text-muted-foreground\">\n <Spinner className=\"size-4\" />\n {text('connecting')}\n </p>\n ) : (\n <Tiles layout={layout} people={people} narrow={narrow} />\n )}\n </div>\n <CallControls {...controls} />\n {people\n .filter((person) => !person.self)\n .flatMap((person) => [['microphone', person.microphone] as const, ['screen-audio', person.screenAudio] as const].map(([source, track]) => track && { key: `${person.member} ${source}`, track }))\n .filter((audio) => audio !== undefined)\n .map(({ key, track }) => (\n <TrackAudio key={key} track={track} />\n ))}\n </section>\n )\n}\n","import { useEffect, useState } from 'react'\nimport { activeSpeaker } from './call-layout'\n\n// How often the levels are read, and how long the last speaker keeps the ring after they stop, so it does not flicker.\nconst readEveryMs = 200\nconst holdMs = 1000\n\n// A level from 0 to 1: the root mean square of the samples.\nconst levelOf = (analyser: AnalyserNode, samples: Float32Array<ArrayBuffer>) => {\n analyser.getFloatTimeDomainData(samples)\n let sum = 0\n for (const sample of samples) sum += sample * sample\n return Math.min(1, Math.sqrt(sum / samples.length) * 4)\n}\n\n/** Who of these members is speaking, by the sound of their microphone tracks, read in the browser through Web Audio. */\nexport const useActiveSpeaker = (tracks: ReadonlyMap<string, MediaStreamTrack>) => {\n const [speaker, setSpeaker] = useState<string>()\n const ids = [...tracks].map(([member, track]) => `${member}:${track.id}`).join(',')\n useEffect(() => {\n if (tracks.size === 0 || typeof AudioContext === 'undefined') return\n const context = new AudioContext()\n const analysers = new Map(\n [...tracks].map(([member, track]) => {\n const analyser = context.createAnalyser()\n analyser.fftSize = 512\n context.createMediaStreamSource(new MediaStream([track])).connect(analyser)\n return [member, analyser] as const\n }),\n )\n const samples = new Float32Array(512)\n let last: { member: string; at: number } | undefined\n const timer = setInterval(() => {\n const loudest = activeSpeaker(new Map([...analysers].map(([member, analyser]) => [member, levelOf(analyser, samples)])))\n if (loudest) last = { member: loudest, at: Date.now() }\n setSpeaker(last && Date.now() - last.at < holdMs ? last.member : undefined)\n }, readEveryMs)\n return () => {\n clearInterval(timer)\n void context.close()\n }\n // Keyed by the tracks' ids, which `tracks` changes with, so a new map of the same tracks reads on.\n }, [ids])\n return speaker\n}\n","/** The member's microphone and camera as the browser gives them, and why one is missing: blocked, or none found. */\nexport type Devices = { microphone?: MediaStreamTrack; camera?: MediaStreamTrack; blocked: { microphone: boolean; camera: boolean }; none: boolean }\n\n// What `getUserMedia` rejects with for a device the person or the browser keeps from the page, or that is not there.\nconst blockedNames = new Set(['NotAllowedError', 'SecurityError'])\nconst missingNames = new Set(['NotFoundError', 'NotReadableError', 'OverconstrainedError'])\n\ntype Kind = 'audio' | 'video'\n\n// One kind of device: its track, or whether it is blocked or missing.\nconst one = async (media: MediaDevices, kind: Kind): Promise<{ track?: MediaStreamTrack; blocked: boolean }> => {\n try {\n const stream = await media.getUserMedia({ [kind]: true })\n return { track: stream.getTracks()[0]!, blocked: false }\n } catch (error) {\n if (!(error instanceof DOMException)) throw error\n if (blockedNames.has(error.name)) return { blocked: true }\n if (missingNames.has(error.name)) return { blocked: false }\n throw error\n }\n}\n\n/**\n * Asks for the microphone and the camera at once, so the browser asks the person once; when that is refused, each on\n * its own, to tell which one is blocked or missing.\n */\nexport const openDevices = async (media: MediaDevices = navigator.mediaDevices): Promise<Devices> => {\n try {\n const stream = await media.getUserMedia({ audio: true, video: true })\n return { microphone: stream.getAudioTracks()[0], camera: stream.getVideoTracks()[0], blocked: { microphone: false, camera: false }, none: false }\n } catch (error) {\n if (!(error instanceof DOMException) || !(blockedNames.has(error.name) || missingNames.has(error.name))) throw error\n }\n const [audio, video] = [await one(media, 'audio'), await one(media, 'video')]\n return {\n ...(audio.track && { microphone: audio.track }),\n ...(video.track && { camera: video.track }),\n blocked: { microphone: audio.blocked, camera: video.blocked },\n none: !audio.track && !video.track && !audio.blocked && !video.blocked,\n }\n}\n","import { useCallback, useEffect, useRef, useState } from 'react'\nimport type { Call, CallConnection, CallLeftReason, CallRosterMember, CallTrack } from '@protobase/client/calls'\nimport { openDevices, type Devices } from './devices'\n\n/** Where the member stands: checking their devices, joining, in the call (`resuming` while its link is restored), or out of it. */\nexport type CallPhase = { kind: 'check' } | { kind: 'joining' } | { kind: 'in'; resuming: boolean } | { kind: 'left'; reason: CallLeftReason }\n\n// How often the connections' state and quality are read while in the call.\nconst connectionsEveryMs = 2000\n\nconst stop = (tracks: readonly (MediaStreamTrack | undefined)[]) => {\n for (const track of tracks) track?.stop()\n}\n\n/**\n * The member's session in the call the app's function at `url` admits them to: their devices from the start, for the\n * check before joining; then the call, which `join` joins after the click, with what they send and receive, and who\n * is in it. Leaving the page leaves the call and stops the devices.\n */\nexport const useCallSession = (url: string) => {\n const [phase, setPhase] = useState<CallPhase>({ kind: 'check' })\n const [devices, setDevices] = useState<Devices>()\n const [microphoneOn, setMicrophoneOn] = useState(true)\n const [cameraOn, setCameraOn] = useState(true)\n const [tracks, setTracks] = useState<CallTrack[]>([])\n const [members, setMembers] = useState<CallRosterMember[]>([])\n const [connections, setConnections] = useState<CallConnection[]>([])\n const [screen, setScreen] = useState<{ video: MediaStreamTrack; audio?: MediaStreamTrack }>()\n const [refusedSending, setRefusedSending] = useState(false)\n const call = useRef<Call | undefined>(undefined)\n const gone = useRef(false)\n const own = useRef<(MediaStreamTrack | undefined)[]>([])\n const seen = useRef(new Map<string, number>())\n\n // The devices as they open: a join clicked before they did waits for them.\n const opening = useRef<Promise<Devices | undefined>>(Promise.resolve(undefined))\n\n useEffect(() => {\n let cancelled = false\n gone.current = false\n opening.current = openDevices().then((opened) => {\n if (cancelled) {\n stop([opened.microphone, opened.camera])\n return\n }\n own.current.push(opened.microphone, opened.camera)\n setDevices(opened)\n return opened\n })\n return () => {\n cancelled = true\n gone.current = true\n call.current?.leave()\n call.current = undefined\n stop(own.current)\n own.current = []\n }\n }, [])\n\n useEffect(() => {\n for (const { member } of members) if (!seen.current.has(member)) seen.current.set(member, Date.now())\n }, [members])\n\n useEffect(() => {\n if (phase.kind !== 'in') return\n const timer = setInterval(() => void call.current?.connections().then(setConnections), connectionsEveryMs)\n return () => clearInterval(timer)\n }, [phase.kind])\n\n const join = useCallback(async () => {\n setPhase({ kind: 'joining' })\n const { joinCall, PublishRefused } = await import('@protobase/client/calls')\n const joined = await joinCall({\n url,\n onTracks: setTracks,\n onMembers: setMembers,\n onState: (state) => {\n if (state.state === 'joined' || state.state === 'resuming') setPhase({ kind: 'in', resuming: state.state === 'resuming' })\n if (state.state === 'left') setPhase({ kind: 'left', reason: state.reason })\n },\n }).then(\n (made) => made,\n // A join that failed is left, and `onState` said why.\n () => undefined,\n )\n if (!joined) return\n if (gone.current) return joined.leave()\n call.current = joined\n const opened = await opening.current\n const sending = { ...(opened?.microphone && { microphone: opened.microphone }), ...(opened?.camera && { camera: opened.camera }) }\n await joined.publish(sending).then(\n () => {\n if (sending.microphone) joined.mute('microphone', !microphoneOn)\n if (sending.camera) joined.mute('camera', !cameraOn)\n },\n (error: unknown) => {\n if (!(error instanceof PublishRefused)) throw error\n setRefusedSending(true)\n },\n )\n }, [url, microphoneOn, cameraOn])\n\n const toggleMicrophone = useCallback(() => {\n const next = !microphoneOn\n setMicrophoneOn(next)\n if (devices?.microphone) devices.microphone.enabled = next\n call.current?.mute('microphone', !next)\n }, [microphoneOn, devices])\n\n const toggleCamera = useCallback(() => {\n const next = !cameraOn\n setCameraOn(next)\n if (devices?.camera) devices.camera.enabled = next\n call.current?.mute('camera', !next)\n }, [cameraOn, devices])\n\n const stopSharing = useCallback(async (shared: { video: MediaStreamTrack; audio?: MediaStreamTrack }) => {\n setScreen(undefined)\n stop([shared.video, shared.audio])\n await call.current?.unpublish('screen')\n if (shared.audio) await call.current?.unpublish('screen-audio')\n }, [])\n\n const toggleScreen = useCallback(async () => {\n if (screen) return stopSharing(screen)\n let display: MediaStream\n try {\n display = await navigator.mediaDevices.getDisplayMedia({ video: true, audio: true })\n } catch (error) {\n // The person closed the browser's picker without sharing.\n if (error instanceof DOMException && error.name === 'NotAllowedError') return\n throw error\n }\n const shared = { video: display.getVideoTracks()[0]!, ...(display.getAudioTracks()[0] && { audio: display.getAudioTracks()[0] }) }\n own.current.push(shared.video, shared.audio)\n shared.video.addEventListener('ended', () => void stopSharing(shared))\n await call.current?.publish({ screen: shared.video, ...(shared.audio && { 'screen-audio': shared.audio }) })\n setScreen(shared)\n }, [screen, stopSharing])\n\n const canShare = typeof navigator !== 'undefined' && typeof navigator.mediaDevices?.getDisplayMedia === 'function'\n\n return {\n phase,\n devices,\n microphoneOn,\n cameraOn,\n tracks,\n members,\n connections,\n screen,\n refusedSending,\n seen: seen.current,\n self: call.current?.participant,\n join,\n toggleMicrophone,\n toggleCamera,\n ...(canShare && { toggleScreen }),\n }\n}\n","import { useState } from 'react'\nimport { useOptionalAuth } from '../auth/auth-provider'\nimport type { RouteTarget } from '../primitives/route-link'\nimport { CallCheck } from './call-check'\nimport { CallMessage } from './call-message'\nimport { callPeople } from './call-people'\nimport { CallStage } from './call-stage'\nimport { text } from './messages'\nimport { useActiveSpeaker } from './use-audio-levels'\nimport { useCallSession } from './use-call-session'\n\nexport type CallViewProps = {\n /** The socket of the app's function that admits the member, as `joinCall` takes it, such as `/api/functions/call?conversation=7`. */\n url: string\n /** Where Leave goes; leaving the page leaves the call. */\n leave: RouteTarget\n /** A member's name, by the member the app's function admits them as, such as a user id; the member itself by default. */\n nameOf?: (member: string) => string\n className?: string\n}\n\nconst deviceNotices = (devices: ReturnType<typeof useCallSession>['devices'], refusedSending: boolean) => [\n ...(devices?.blocked.microphone ? [text('noMicrophone')] : []),\n ...(devices?.blocked.camera ? [text('noCamera')] : []),\n ...(devices?.none ? [text('noDevices')] : []),\n ...(refusedSending ? [text('refused')] : []),\n]\n\n/**\n * A call, ready-made, that fills its parent, such as a column beside a conversation's messages: a check of the\n * microphone and camera first, then, after Join, everyone in the call with the one speaking ringed, a screen share\n * large, microphone, camera, screen share and Leave, the quality of each connection, Reconnecting while the link is\n * restored, and plain words for a full call, a blocked device or someone the browser cannot connect to. Made for small\n * peer-to-peer calls, at a desktop's width or a phone's.\n */\nexport const CallView = ({ url, leave, nameOf = (member) => member, className }: CallViewProps) => {\n const session = useCallSession(url)\n const auth = useOptionalAuth()\n const user = auth?.state.kind === 'signed-in' ? auth.state.user : undefined\n const self = session.self ?? user?.id ?? ''\n const [now] = useState(() => Date.now())\n const { devices, phase } = session\n const own = { ...(devices?.microphone && { microphone: devices.microphone }), ...(devices?.camera && { camera: devices.camera }), ...(session.screen && { screen: session.screen.video }), microphoneOn: session.microphoneOn, cameraOn: session.cameraOn }\n const voices = new Map([...(devices?.microphone && session.microphoneOn ? [[self, devices.microphone] as const] : []), ...session.tracks.filter((track) => track.source === 'microphone' && track.track && !track.muted).map((track) => [track.member, track.track!] as const)])\n const speaker = useActiveSpeaker(phase.kind === 'in' ? voices : new Map())\n const notices = deviceNotices(devices, session.refusedSending)\n\n if (phase.kind === 'left') return <CallMessage reason={phase.reason} onJoinAgain={() => void session.join()} />\n if (phase.kind === 'check') {\n return (\n <CallCheck\n name={user?.name ?? text('you')}\n member={self}\n {...(devices?.camera && { camera: devices.camera })}\n microphoneOn={session.microphoneOn}\n cameraOn={session.cameraOn}\n microphone={Boolean(devices?.microphone)}\n cameraAvailable={Boolean(devices?.camera)}\n notices={notices}\n onMicrophone={session.toggleMicrophone}\n onCamera={session.toggleCamera}\n onJoin={() => void session.join()}\n cancel={leave}\n />\n )\n }\n const people = callPeople({ members: session.members, self, tracks: session.tracks, own, nameOf, ...(speaker && { speaker }), connections: session.connections, seen: session.seen, now: Math.max(now, Date.now()) })\n return (\n <CallStage\n {...(className && { className })}\n people={people}\n state={phase.kind === 'joining' ? 'joining' : phase.resuming ? 'resuming' : 'joined'}\n notices={notices}\n controls={{\n microphoneOn: session.microphoneOn && Boolean(devices?.microphone),\n cameraOn: session.cameraOn && Boolean(devices?.camera),\n sharing: Boolean(session.screen),\n onMicrophone: session.toggleMicrophone,\n onCamera: session.toggleCamera,\n ...(session.toggleScreen && { onShare: () => void session.toggleScreen!() }),\n leave,\n }}\n />\n )\n}\n","import { useAppAddress } from '../app/use-app-address'\n\n/**\n * A record's call as the app's address holds it: whether the page joins it (`call=join`), the link that joins it, as a\n * ring's Accept and a call mark's Join open it, and the link back to the record without the call, as Leave opens it.\n */\nexport const useRecordCallAddress = (resource: string, recordKey: string) => {\n const { address, href, open } = useAppAddress()\n const joining = address?.kind === 'record' && address.resource === resource && address.key === recordKey && address.call === 'join'\n const target = (to: string) => ({ href: to, onFollow: () => open(to) })\n return { joining, join: target(href({ kind: 'record', resource, key: recordKey, call: 'join' })), leave: target(href({ kind: 'record', resource, key: recordKey })) }\n}\n","import { CallView, type CallViewProps } from './call-view'\nimport { useRecordCallAddress } from './use-record-call-address'\n\nexport type RecordCallProps = Omit<CallViewProps, 'leave'> & { resource: string; recordKey: string }\n\n/**\n * The record's call view while the app's address joins it (`call=join`, as Accept and Join open it), and nothing\n * otherwise: put it beside the record's own content, such as on a full-area record page. Leave goes back to the record.\n */\nexport const RecordCall = ({ resource, recordKey, ...rest }: RecordCallProps) => {\n const { joining, leave } = useRecordCallAddress(resource, recordKey)\n if (!joining) return null\n return <CallView key={`${resource}/${recordKey}`} leave={leave} {...rest} />\n}\n","import { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useEffect } from 'react'\nimport type { RecordCall } from '@protobase/client'\nimport { callsChannelEvent } from '@protobase/schema/internal'\nimport { useClient } from '../data/api-provider'\nimport { keys } from '../data/query-keys'\n\n/**\n * A record's latest calls, the one going on first, kept current over the record's channel, on the one socket the page\n * shares for every channel it holds: the server sends the calls there whenever they change, so following a record's\n * calls opens no connection of its own on a page that holds a channel already. Read again whenever the channel joins,\n * as after a lost connection.\n */\nexport const useRecordCalls = (resource: string, recordKey: string) => {\n const client = useClient()\n const queryClient = useQueryClient()\n const key = keys.recordCalls(resource, recordKey)\n const query = useQuery({ queryKey: key, queryFn: () => client.calls(resource, recordKey) })\n\n useEffect(() => {\n const queryKey = keys.recordCalls(resource, recordKey)\n const channel = client.channel(resource, recordKey)\n // Only the server's own message: anyone on the channel can broadcast under the same event.\n const offCalls = channel.on(callsChannelEvent, (message) => message.server && queryClient.setQueryData<RecordCall[]>(queryKey, (message.payload as { items: RecordCall[] }).items))\n const offStatus = channel.onStatus((status) => status.state === 'joined' && void queryClient.invalidateQueries({ queryKey }))\n return () => {\n offCalls()\n offStatus()\n channel.leave()\n }\n }, [client, queryClient, resource, recordKey])\n\n return { ...query, ongoing: query.data?.find((call) => call.ended_at === null) }\n}\n","import { Phone } from 'lucide-react'\nimport { cn } from '../lib/cn'\nimport { buttonClass } from '../primitives/button'\nimport { RouteLink } from '../primitives/route-link'\nimport { text } from './messages'\nimport { useRecordCalls } from './use-record-calls'\nimport { useRecordCallAddress } from './use-record-call-address'\n\nexport type CallMarkProps = { resource: string; recordKey: string; className?: string }\n\n/**\n * A record's call, for the app to place where it wants, such as a conversation's header: Start call while there is\n * none, and \"Call in progress · 3 · Join\" while one goes on, live. Start call and Join are links to the record's page\n * that joins its call (`call=join`); on that page itself, Join is left out.\n */\nexport const CallMark = ({ resource, recordKey, className }: CallMarkProps) => {\n const { ongoing, isPending } = useRecordCalls(resource, recordKey)\n const { joining, join } = useRecordCallAddress(resource, recordKey)\n if (isPending) return null\n if (!ongoing) {\n if (joining) return null\n return (\n <RouteLink to={join} className={cn(buttonClass({ size: 'sm' }), className)}>\n <Phone className=\"size-3.5\" />\n {text('startCall')}\n </RouteLink>\n )\n }\n const count = ongoing.members.length\n return (\n <span role=\"status\" className={cn('inline-flex items-center gap-1.5 rounded-md bg-success-soft px-2 py-0.5 text-body text-foreground', className)}>\n <Phone className=\"size-3.5 text-success\" />\n {text('inProgress')}\n <span aria-hidden>·</span>\n <span aria-label={text('people', count)}>{count}</span>\n {!joining && (\n <>\n <span aria-hidden>·</span>\n <RouteLink to={join} className={buttonClass({ variant: 'primary', size: 'sm' })}>\n {text('join')}\n </RouteLink>\n </>\n )}\n </span>\n )\n}\n","import type { StoredFile } from '@protobase/client'\nimport { shownImage } from '../live/file-values'\n\n/** An image a carousel shows: a link with what it shows, or a file field's value, as records carry it. */\nexport type CarouselImage = { src: string; alt: string } | (StoredFile & { alt?: string })\n\n// A frame up to about half a page wide: of a file's variants, the smallest that covers it is drawn, the file itself when none does\nconst box = { width: 640, height: 480 }\n\n/** What each slide draws, in order: a file that is missing or is no raster image is left out. */\nexport const carouselSlides = (images: readonly CarouselImage[]) =>\n images.flatMap((image) => {\n if ('src' in image) return [{ image: { url: image.src }, alt: image.alt }]\n const shown = shownImage(image, box)\n return shown ? [{ image: shown, alt: image.alt ?? '' }] : []\n })\n","import { cn } from '../lib/cn'\nimport { FileImage } from '../live/file-image'\nimport { CarouselControls } from './carousel-controls'\nimport { carouselSlides, type CarouselImage } from './carousel-images'\nimport { CarouselTrack } from './carousel-track'\nimport { useCarousel } from './use-carousel'\n\nexport type CarouselProps = {\n /** The images in order: links with what each shows, or file field values. */\n images: readonly CarouselImage[]\n /** What the images are, read out with the carousel. */\n label?: string\n /** `cover` fills the frame and crops what overflows it, the default; `contain` shows each image whole. */\n fit?: 'cover' | 'contain'\n /** Whether a swipe steps through the images; off, it scrolls what the carousel sits in, such as a row that scrolls sideways. */\n swipe?: boolean\n /** The frame's classes, such as its aspect ratio, border and rounding. */\n className?: string\n}\n\n/**\n * Images side by side in a frame that snaps image by image, swiped on a touch screen or moved by arrows on hover, with\n * dots marking the one in view; the record cards' photos step the same way. A single image shows without arrows or dots.\n */\nexport const Carousel = ({ images, label, fit = 'cover', swipe = true, className }: CarouselProps) => {\n const slides = carouselSlides(images)\n const carousel = useCarousel(slides.length)\n return (\n <div role=\"group\" aria-roledescription=\"carousel\" aria-label={label} className={cn('group/carousel relative overflow-hidden', className)}>\n <CarouselTrack\n data-carousel-track\n carousel={carousel}\n swipe={swipe}\n slides={slides.map(({ image, alt }) => (\n <FileImage image={image} alt={alt} loading=\"lazy\" className={cn('size-full', fit === 'cover' ? 'object-cover' : 'object-contain')} />\n ))}\n />\n <CarouselControls carousel={carousel} count={slides.length} swipe={swipe} reveal=\"group-hover/carousel:opacity-100\" className=\"inset-0\" />\n </div>\n )\n}\n","import type { ReactNode } from 'react'\nimport { cn } from '../lib/cn'\n\nexport type ChoiceOption<T extends string> = { value: T; label: string; description?: ReactNode; disabled?: boolean }\n\n/**\n * `name` groups the radio buttons, so that the arrow keys move between them; `label` names the group for screen\n * readers. A disabled option shows and cannot be chosen.\n */\nexport type ChoicesProps<T extends string> = { name: string; label?: string; options: Array<ChoiceOption<T>>; value: T | undefined; onChange: (value: T) => void }\n\n/** One of a few options, each a card of its own row with a line that says what it means; the chosen one is outlined. */\nexport const Choices = <T extends string>({ name, label, options, value, onChange }: ChoicesProps<T>) => (\n <div role=\"radiogroup\" aria-label={label} className=\"flex flex-col gap-2\">\n {options.map((option) => (\n <label\n key={option.value}\n className={cn(\n 'block rounded-lg border p-3 transition-colors has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-primary',\n option.disabled ? 'cursor-default bg-background opacity-60' : option.value === value ? 'cursor-pointer border-primary bg-primary-soft' : 'cursor-pointer bg-background hover:bg-surface',\n )}\n >\n <input type=\"radio\" name={name} value={option.value} checked={option.value === value} disabled={option.disabled} onChange={() => onChange(option.value)} className=\"sr-only\" />\n <span className={cn('block font-medium', option.value === value && 'text-primary-text')}>{option.label}</span>\n {option.description && <span className=\"mt-0.5 block text-xs leading-snug text-muted-foreground\">{option.description}</span>}\n </label>\n ))}\n </div>\n)\n","import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'\nimport type { ResourceModel, ViewModel } from '@protobase/schema'\nimport { useClient } from '../data/api-provider'\nimport { keys } from '../data/query-keys'\nimport { fetchLabels, type Labels } from '../live/relation-labels'\n\n/** The names of the chosen records, fetched in one list call; the previous names stay while the next ones load. */\nexport const usePickedLabels = (target: ResourceModel, view: ViewModel | undefined, ids: string[]): Labels => {\n const client = useClient()\n const queryClient = useQueryClient()\n const sorted = [...new Set(ids)].sort()\n const labels = useQuery({\n queryKey: keys.pickedLabels(target.name, sorted.join(',')),\n enabled: sorted.length > 0,\n placeholderData: keepPreviousData,\n queryFn: () => fetchLabels(queryClient, client, target, sorted, view),\n })\n return labels.data ?? new Map()\n}\n","import { useState } from 'react'\nimport { Token } from '../primitives/token'\nimport { useAdminMeta } from './meta-gate'\nimport { RelationPicker } from './relation-picker'\nimport { usePickedLabels } from './use-picked-labels'\n\ntype One = {\n multiple?: false\n /** The chosen record's key, as text; `undefined` for none. */\n value: string | undefined\n onChange: (key: string) => void\n}\n\ntype Several = {\n multiple: true\n /** The chosen records' keys, as text. */\n value: string[]\n onChange: (keys: string[]) => void\n}\n\nexport type RecordPickerProps = (One | Several) & {\n /** The name of the resource whose records it picks. */\n resource: string\n invalid?: boolean\n}\n\n/**\n * Picks records of a resource of the app with the create form's relation picker: type to narrow them by their search\n * fields or title, scroll for more, choose with the mouse or the keyboard. With `multiple`, each choice is added as a\n * token that can be taken off again, and choosing a chosen record takes it off.\n */\nexport const RecordPicker = (props: RecordPickerProps) => {\n const { resources, views } = useAdminMeta()\n const target = resources[props.resource]\n if (!target) throw new Error(`RecordPicker: the app has no resource named \"${props.resource}\"`)\n if (target.primaryKey.length !== 1) throw new Error(`RecordPicker: \"${props.resource}\" has a composite key, which a picker cannot name`)\n const view = views[props.resource]\n const keys = props.multiple ? props.value : props.value === undefined ? [] : [props.value]\n // The names of records chosen here, so a choice shows its name before the names are fetched.\n const [known, setKnown] = useState<Record<string, string>>({})\n const fetched = usePickedLabels(target, view, keys)\n const labelOf = (key: string) => known[key] ?? fetched.get(key) ?? key\n const remember = (key: string, label: string) => setKnown((current) => ({ ...current, [key]: label }))\n\n if (!props.multiple) {\n const { value, onChange } = props\n return (\n <RelationPicker\n target={target}\n view={view}\n value={value ?? ''}\n label={value === undefined ? undefined : labelOf(value)}\n invalid={props.invalid}\n onChange={(key, label) => {\n remember(key, label)\n onChange(key)\n }}\n />\n )\n }\n\n const { value, onChange } = props\n return (\n <div className=\"flex flex-col gap-2\">\n <RelationPicker\n target={target}\n view={view}\n value=\"\"\n chosen={value}\n several\n invalid={props.invalid}\n onChange={(key, label) => {\n remember(key, label)\n onChange(value.includes(key) ? value.filter((chosen) => chosen !== key) : [...value, key])\n }}\n />\n {value.length > 0 && (\n <div className=\"flex flex-wrap gap-1\">\n {value.map((key) => (\n <Token key={key} label={labelOf(key)} onRemove={() => onChange(value.filter((chosen) => chosen !== key))} />\n ))}\n </div>\n )}\n </div>\n )\n}\n"],"file":"shared-protobase-ui-CX80Ectk.js","debugId":"97f3411c-b648-4ca9-acbb-6be69060b6df"}