import { createSidecarProxy } from '../../sidecar/create-proxy';

// The officer-caldav sidecar has TWO consumers in the platform and they need different things, so the
// port capture lives here and both import it.
//
//  • `caldavRouter` — the ordinary JSON door for Officer's own UI. Behind userMiddleware, forwarded by
//    the shared factory with `X-Officer-User`, exactly like every other sidecar.
//  • `davSyncRouter` — the DAV door for phones. Cannot use the factory: it forwards only three headers
//    (`create-proxy.ts:88`) and DAV dies without `Depth`, and it derives the user from a platform JWT
//    that a DAV client has no way to hold.
//
// Hence one registration, two forwarders. The factory's own comment says it must never grow per-app
// logic, so the DAV-specific half is a separate file rather than a branch inside it.
const proxy = createSidecarProxy({ name: 'caldav', prefix: '/api/caldav' });

export const caldavRouter = proxy.router;
export const getCaldavUrl = proxy.getHttpUrl;
