import type { LayoutNode } from 'officerdev';
import { WorkspaceView } from 'officerdev';
import { useDashboardState } from 'state/useDashboardState';
import { defaultLayout } from './defaultLayout';

// /qr-transfer — TEMPORARY / EXPERIMENTAL.
//
// Move a file between two devices with no shared network, over animated QR codes: one panel displays a
// looping carousel of frames, the other scans it through the camera. Inspired by deedy/qr-data-transfer,
// but without its RaptorQ fountain coding — see apps/QrTransfer/protocol.ts for that trade and why it was
// made (the format is being reimplemented on iOS and Android, where simplicity beats optical efficiency).
//
// Both panels are pure client-side: nothing about a transfer reaches the server, which is the point.
// The receiver needs a secure origin for camera access — over the tailnet with HTTPS that is satisfied.

export const QrTransferScreen = () => {
  const workspace = useDashboardState<LayoutNode>('screens/qr-transfer', defaultLayout);

  return (
    <WorkspaceView
      workspace={workspace}
      locked
      appTypes={{ allowed: ['qr-send', 'qr-receive'], fallback: 'qr-send' }}
    />
  );
};
