'use client'; import { Fragment, useState, useEffect } from 'react'; import { Dialog, DialogPanel, DialogTitle, Transition, TransitionChild, Button, } from '@headlessui/react'; import { updateAppConfig } from '@/lib/client/dexie'; interface PrivacyModalProps { isOpen: boolean; onAccept?: () => void; onDismiss?: () => void; } function PrivacyModalBody({ origin }: { origin: string }) { return (
Service Operator
This instance is hosted at {origin || 'this server'}.

We value your privacy. This application uses strictly necessary cookies for authentication and anonymous analytics to improve performance. Your documents are stored securely and encrypted at rest.

For full details on data collection, processing, and your rights, please review our complete{' '} Privacy Policy.

); } export function PrivacyModal({ isOpen, onAccept, onDismiss }: PrivacyModalProps) { const [origin, setOrigin] = useState(''); const [agreed, setAgreed] = useState(false); useEffect(() => { if (typeof window === 'undefined') return; setOrigin(window.location.origin); }, []); useEffect(() => { if (isOpen) { setAgreed(false); } }, [isOpen]); const handleAccept = async () => { await updateAppConfig({ privacyAccepted: true }); if (typeof window !== 'undefined') { window.dispatchEvent(new Event('openreader:privacyAccepted')); } onAccept?.(); }; return ( { })}>
Privacy & Data Usage
setAgreed(e.target.checked)} className="h-4 w-4 rounded border-gray-300 text-accent focus:ring-accent bg-base" />
{' '} Privacy Policy
); } /** * Function to programmatically show the privacy popup * This can be called from signin/signup components */ export function showPrivacyModal(options?: { authEnabled?: boolean }): void { // Create a temporary container for the popup const container = document.createElement('div'); container.id = 'privacy-modal-container'; document.body.appendChild(container); const origin = typeof window !== 'undefined' ? window.location.origin : ''; void options; // Import React and render the popup import('react-dom/client').then(({ createRoot }) => { import('react').then((React) => { const root = createRoot(container); const PopupWrapper = () => { const [show, setShow] = useState(true); const handleClose = () => { setShow(false); }; return ( { root.unmount(); container.remove(); }} >
Privacy & Data Usage
); }; root.render(React.createElement(PopupWrapper)); }); }); }