"use strict";

import React, { useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import GViewWebView from './GViewWebView';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * Inline preview for office documents (DOC / DOCX / XLS / XLSX / PPT /
 * PPTX / TXT / RTF / CSV) and other non-PDF formats supported by
 * Google's free gview rendering service.
 *
 *
 * Limitations (documented for the integrator):
 *   - Requires public URL — won't work for auth-gated downloads.
 *   - First load can take 2-5s on slow networks.
 *   - Read-only — no editing, no print/share buttons.
 *
 */
const DocumentViewer = ({
  url,
  fileName
}) => {
  const [errored, setErrored] = useState(false);
  if (errored) {
    return /*#__PURE__*/_jsxs(View, {
      style: styles.center,
      children: [/*#__PURE__*/_jsx(Text, {
        style: styles.errorTitle,
        children: fileName || 'Document'
      }), /*#__PURE__*/_jsx(Text, {
        style: styles.errorBody,
        children: "Couldn't render an inline preview. Tap the save icon above to download the file."
      })]
    });
  }
  return /*#__PURE__*/_jsx(GViewWebView, {
    url: url,
    onError: () => setErrored(true)
  });
};
export default DocumentViewer;
const styles = StyleSheet.create({
  center: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    padding: 24,
    gap: 8
  },
  errorTitle: {
    fontSize: 16,
    fontWeight: '600'
  },
  errorBody: {
    color: '#666',
    textAlign: 'center'
  }
});
//# sourceMappingURL=DocumentViewer.js.map