'use client';

import Link from 'next/link';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { isAxiosError } from 'axios';
import { format } from 'date-fns';
import { fr } from 'date-fns/locale';
import {
  ArrowLeft,
  CheckCircle2,
  CloudUpload,
  Copy,
  ExternalLink,
  FileText,
  Image as ImageIcon,
  Loader2,
  Lock,
  ScrollText,
  Shield,
  Trash2,
} from 'lucide-react';

import { PieceJournalDialog } from '@/components/coffre-fort/piece-journal-dialog';
import { StatutDossierBadge } from '@/components/dossiers/statut-dossier-badge';
import { Button } from '@/components/ui/button';
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from '@/components/ui/card';
import {
  archiveDossier,
  extractApiErrorMessage,
  fetchDossier,
  fetchMe,
  openPieceFile,
  removePiece,
  uploadPiece,
  type AuthUser,
  type Dossier,
  type Piece,
} from '@/lib/api';
import {
  estDossierScelle,
  estEnAttenteDArchivage,
  estEnCoursScellement,
  estScelle,
} from '@/lib/types';
import { cn } from '@/lib/utils';

const MAX_FILE_SIZE = 20 * 1024 * 1024;
const ACCEPTED_TYPES = [
  'application/pdf',
  'image/jpeg',
  'image/png',
] as const;

const TYPE_JUSTIFICATIF_OPTIONS = [
  { value: '', label: 'Non précisé' },
  { value: 'justificatif', label: 'Justificatif' },
] as const;

function dossierLabel(dossier: Dossier): string {
  if (dossier.immatriculation) {
    return dossier.immatriculation;
  }

  if (dossier.nom) {
    return dossier.nom;
  }

  return dossier.id_dossier;
}

function formatBytes(bytes: number | null): string {
  if (bytes === null) {
    return '—';
  }

  if (bytes < 1024) {
    return `${bytes} o`;
  }

  if (bytes < 1024 * 1024) {
    return `${Math.round(bytes / 1024)} Ko`;
  }

  return `${(bytes / (1024 * 1024)).toFixed(1)} Mo`;
}

function isPendingPiece(piece: Piece): boolean {
  return estEnAttenteDArchivage(piece);
}

function isSealingPiece(piece: Piece): boolean {
  return estEnCoursScellement(piece);
}

function canRemovePiece(piece: Piece): boolean {
  return estEnAttenteDArchivage(piece);
}

function isArchivedPiece(piece: Piece): boolean {
  return estScelle(piece);
}

function truncateHash(hash: string, start = 8, end = 6): string {
  if (hash.length <= start + end + 3) {
    return hash;
  }

  return `${hash.slice(0, start)}…${hash.slice(-end)}`;
}

function PieceIcon({ type }: { type: Piece['extension'] }) {
  if (type === 'pdf') {
    return <FileText className="h-5 w-5 text-primary" />;
  }

  return <ImageIcon className="h-5 w-5 text-primary" />;
}

type DossierDetailViewProps = {
  conteneurIdCont: string;
  dossierIdDossier: string;
};

export function DossierDetailView({ conteneurIdCont, dossierIdDossier }: DossierDetailViewProps) {
  const fileInputRef = useRef<HTMLInputElement>(null);
  const [user, setUser] = useState<AuthUser | null>(null);
  const [dossier, setDossier] = useState<Dossier | null>(null);
  const [pieces, setPieces] = useState<Piece[]>([]);
  const [isLoading, setIsLoading] = useState(true);
  const [loadError, setLoadError] = useState<string | null>(null);
  const [isDragOver, setIsDragOver] = useState(false);
  const [isUploading, setIsUploading] = useState(false);
  const [uploadError, setUploadError] = useState<string | null>(null);
  const [isArchiving, setIsArchiving] = useState(false);
  const [archiveError, setArchiveError] = useState<string | null>(null);
  const [archiveSuccess, setArchiveSuccess] = useState<string | null>(null);
  const [removingId, setRemovingId] = useState<number | null>(null);
  const [removeError, setRemoveError] = useState<string | null>(null);
  const [viewingId, setViewingId] = useState<number | null>(null);
  const [viewError, setViewError] = useState<string | null>(null);
  const [copiedId, setCopiedId] = useState<number | null>(null);
  const [typeJustificatif, setTypeJustificatif] = useState<
    Record<number, string>
  >({});
  const [pieceJournal, setPieceJournal] = useState<Piece | null>(null);

  const canManagePieces = user?.role_ccfn === 'UTI-S';
  // La liste des dossiers est fermée aux administrateurs (§5.6.1, §5.6.2) :
  // pour eux, le retour ramène au coffre-fort qu'ils administrent.
  const retour = canManagePieces
    ? {
        href: `/liste-dossiers?id_cont=${conteneurIdCont}`,
        label: 'Retour à la liste des dossiers',
      }
    : { href: '/coffre-fort', label: 'Retour au coffre-fort' };
  const dossierScelle = dossier ? estDossierScelle(dossier) : false;
  const peutDeposer = canManagePieces && !dossierScelle;

  const piecesAAarchiver = useMemo(
    () => pieces.filter(isPendingPiece),
    [pieces],
  );
  const piecesEnAttente = useMemo(
    () => pieces.filter((piece) => isPendingPiece(piece) || isSealingPiece(piece)),
    [pieces],
  );
  const piecesArchivees = useMemo(
    () => pieces.filter(isArchivedPiece),
    [pieces],
  );

  const loadDossier = useCallback(async () => {
    setIsLoading(true);
    setLoadError(null);

    try {
      const [currentUser, detail] = await Promise.all([
        fetchMe(),
        fetchDossier(conteneurIdCont, dossierIdDossier),
      ]);
      setUser(currentUser);
      setDossier(detail.dossier);
      setPieces(detail.pieces ?? []);
    } catch (error) {
      if (isAxiosError(error) && error.response?.status === 404) {
        setLoadError('Dossier introuvable.');
      } else if (isAxiosError(error) && error.response?.status === 401) {
        setLoadError('Session expirée. Veuillez vous reconnecter.');
      } else {
        setLoadError('Impossible de charger le dossier.');
      }
    } finally {
      setIsLoading(false);
    }
  }, [conteneurIdCont, dossierIdDossier]);

  useEffect(() => {
    void loadDossier();
  }, [loadDossier]);

  async function handleUpload(file: File) {
    if (!canManagePieces) {
      setUploadError(
        'Seuls les utilisateurs UTI-S peuvent déposer des documents.',
      );
      return;
    }

    if (dossierScelle) {
      setUploadError(
        'Ce dossier est scellé : aucun nouveau document ne peut y être déposé.',
      );
      return;
    }

    if (!ACCEPTED_TYPES.includes(file.type as (typeof ACCEPTED_TYPES)[number])) {
      setUploadError('Seuls les formats PDF, JPEG et PNG sont acceptés.');
      return;
    }

    if (file.size > MAX_FILE_SIZE) {
      setUploadError('Le fichier ne doit pas dépasser 20 Mo.');
      return;
    }

    setIsUploading(true);
    setUploadError(null);

    try {
      await uploadPiece(conteneurIdCont, dossierIdDossier, file);
      const detail = await fetchDossier(conteneurIdCont, dossierIdDossier);
      setDossier(detail.dossier);
      setPieces(detail.pieces ?? []);
    } catch (error) {
      setUploadError(
        extractApiErrorMessage(error, 'Impossible de déposer la pièce.'),
      );
    } finally {
      setIsUploading(false);
      if (fileInputRef.current) {
        fileInputRef.current.value = '';
      }
    }
  }

  function handleFileInputChange(event: React.ChangeEvent<HTMLInputElement>) {
    const file = event.target.files?.[0];
    if (file) {
      void handleUpload(file);
    }
  }

  function handleDrop(event: React.DragEvent<HTMLDivElement>) {
    event.preventDefault();
    setIsDragOver(false);
    setUploadError(null);

    if (!peutDeposer || isUploading) {
      return;
    }

    const file = event.dataTransfer.files?.[0];
    if (file) {
      void handleUpload(file);
    }
  }

  async function handleArchive() {
    if (!canManagePieces) {
      setArchiveError(
        'Seuls les utilisateurs UTI-S peuvent archiver des documents.',
      );
      return;
    }

    if (dossierScelle) {
      setArchiveError(
        'Ce dossier est scellé : aucun nouvel archivage n’est possible.',
      );
      return;
    }

    setIsArchiving(true);
    setArchiveError(null);
    setArchiveSuccess(null);
    setRemoveError(null);

    try {
      const result = await archiveDossier(conteneurIdCont, dossierIdDossier);

      const detail = await fetchDossier(conteneurIdCont, dossierIdDossier);
      setDossier(detail.dossier);
      setPieces(detail.pieces ?? []);

      if (result.resultats.echecs > 0 && result.resultats.scelles > 0) {
        setArchiveSuccess(
          `${result.resultats.scelles} objet(s) archivé(s) dans le coffre-fort.`,
        );
        setArchiveError(
          `${result.resultats.echecs} pièce(s) en échec — consultez le détail ci-dessous.`,
        );
      } else if (result.resultats.echecs > 0) {
        setArchiveError(result.message);
      } else {
        setArchiveSuccess(result.message);
      }

      for (let attempt = 0; attempt < 15; attempt++) {
        const refreshed = await fetchDossier(conteneurIdCont, dossierIdDossier);
        setDossier(refreshed.dossier);
        setPieces(refreshed.pieces ?? []);

        const encoreEnCours = refreshed.pieces.some(
          (piece) => estEnAttenteDArchivage(piece) || estEnCoursScellement(piece),
        );

        if (!encoreEnCours) {
          break;
        }

        await new Promise((resolve) => window.setTimeout(resolve, 2000));
      }
    } catch (error) {
      setArchiveError(
        extractApiErrorMessage(error, 'Impossible d’archiver les pièces.'),
      );
    } finally {
      setIsArchiving(false);
    }
  }

  async function handleView(piece: Piece) {
    setViewingId(piece.id);
    setViewError(null);

    try {
      await openPieceFile(piece);
    } catch (error) {
      if (error instanceof Error && !isAxiosError(error)) {
        setViewError(error.message);
      } else if (isAxiosError(error)) {
        setViewError(
          (error.response?.data as { message?: string })?.message ??
            'Impossible d’ouvrir le document.',
        );
      } else {
        setViewError('Impossible d’ouvrir le document.');
      }
    } finally {
      setViewingId(null);
    }
  }

  async function handleRemove(pieceId: number) {
    if (!canManagePieces) {
      setRemoveError(
        'Seuls les utilisateurs UTI-S peuvent retirer une pièce non scellée.',
      );
      return;
    }

    setRemovingId(pieceId);
    setRemoveError(null);
    setArchiveError(null);
    setArchiveSuccess(null);

    try {
      await removePiece(pieceId);
      setPieces((current) => current.filter((piece) => piece.id !== pieceId));
    } catch (error) {
      setRemoveError(
        extractApiErrorMessage(error, 'Impossible de retirer la pièce.'),
      );
    } finally {
      setRemovingId(null);
    }
  }

  async function handleCopyEmpreinte(pieceId: number, empreinte: string) {
    try {
      await navigator.clipboard.writeText(empreinte);
      setCopiedId(pieceId);
      window.setTimeout(() => setCopiedId(null), 2000);
    } catch {
      setUploadError('Impossible de copier l’empreinte.');
    }
  }

  if (isLoading) {
    return (
      <div className="flex items-center justify-center gap-2 py-24 text-sm text-muted-foreground">
        <Loader2 className="h-5 w-5 animate-spin" />
        Chargement du dossier…
      </div>
    );
  }

  if (loadError || !dossier) {
    return (
      <Card>
        <CardContent className="space-y-4 py-10 text-center">
          <p className="text-sm text-destructive">
            {loadError ?? 'Dossier introuvable.'}
          </p>
          <Button asChild variant="outline">
            <Link href={retour.href}>
              <ArrowLeft className="h-4 w-4" />
              {retour.label}
            </Link>
          </Button>
        </CardContent>
      </Card>
    );
  }

  return (
    <>
      <div className="mb-8">
        <Button asChild variant="ghost" className="mb-4 -ml-3">
          <Link href={retour.href}>
            <ArrowLeft className="h-4 w-4" />
            {retour.label}
          </Link>
        </Button>

        <div className="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
          <div>
            <h1 className="text-2xl font-bold tracking-tight">
              {dossierLabel(dossier)}
            </h1>
            <p className="mt-1 font-mono text-xs text-muted-foreground">
              {dossier.id_cont}
            </p>
            <div className="mt-3 flex flex-wrap gap-3 text-sm text-muted-foreground">
              {dossier.description ? (
                <span>{dossier.description}</span>
              ) : null}
              {dossier.immatriculation ? (
                <span>Immat. : {dossier.immatriculation}</span>
              ) : null}
              {dossier.type_demarche ? (
                <span>Démarche : {dossier.type_demarche}</span>
              ) : null}
              <span>
                {dossier.objets_numeriques_count ?? 0} document
                {(dossier.objets_numeriques_count ?? 0) > 1 ? 's' : ''}
              </span>
              {dossier.cree_par ? (
                <span>Créé par {dossier.cree_par.nom}</span>
              ) : null}
            </div>
          </div>

          <StatutDossierBadge dossier={dossier} className="px-3 py-1" />
        </div>
      </div>

      {/* §5.6.1 et §5.6.2 : un administrateur n'accède en aucun cas aux objets numériques. */}
      {!canManagePieces ? (
        <Card>
          <CardContent className="flex flex-col items-center gap-3 py-12 text-center">
            <Lock className="h-10 w-10 text-muted-foreground/60" />
            <div>
              <p className="font-medium">Contenu du dossier non accessible</p>
              <p className="mt-1 max-w-md text-sm text-muted-foreground">
                Votre profil ({user?.role_ccfn ?? '—'}) administre le coffre-fort mais
                n&apos;accède pas aux objets numériques qu&apos;il conserve.
                Connectez-vous avec un compte UTI-S pour déposer, consulter ou
                archiver des documents.
              </p>
            </div>
          </CardContent>
        </Card>
      ) : (
        <>
      {/* Le retour d'archivage reste visible même après le scellement du dossier. */}
      {archiveSuccess ? (
        <p className="mb-4 text-sm text-emerald-600">{archiveSuccess}</p>
      ) : null}

      {/* Dossier scellé : le dépôt et l'archivage sont définitivement clos. */}
      {!dossierScelle ? (
        <>
      <Card className="mb-8">
        <CardHeader>
          <CardTitle className="text-lg">Déposer des documents</CardTitle>
        </CardHeader>
        <CardContent>
          <div
            className={cn(
              'flex flex-col items-center justify-center rounded-lg border-2 border-dashed px-6 py-10 transition-colors',
              isDragOver
                ? 'border-primary bg-primary/5'
                : 'border-muted-foreground/25',
              !peutDeposer && 'pointer-events-none opacity-50',
            )}
            onDragOver={(event) => {
              event.preventDefault();
              setIsDragOver(true);
            }}
            onDragLeave={() => setIsDragOver(false)}
            onDrop={handleDrop}
          >
            {isUploading ? (
              <Loader2 className="mb-3 h-10 w-10 animate-spin text-primary" />
            ) : (
              <CloudUpload className="mb-3 h-10 w-10 text-muted-foreground/60" />
            )}
            <p className="text-sm font-medium">
              Glissez-déposez vos fichiers ici
            </p>
            <p className="mt-1 text-xs text-muted-foreground">
              PDF, JPEG ou PNG — 20 Mo maximum par fichier
            </p>
            <input
              ref={fileInputRef}
              type="file"
              accept=".pdf,.jpg,.jpeg,.png,application/pdf,image/jpeg,image/png"
              className="hidden"
              disabled={!peutDeposer || isUploading}
              onChange={handleFileInputChange}
            />
            <Button
              type="button"
              variant="outline"
              className="mt-4"
              disabled={!peutDeposer || isUploading}
              onClick={() => fileInputRef.current?.click()}
            >
              Parcourir
            </Button>
          </div>

          {uploadError ? (
            <p className="mt-3 text-sm text-destructive">{uploadError}</p>
          ) : null}

        </CardContent>
      </Card>

      <Card className="mb-8">
        <CardHeader className="flex flex-row items-start justify-between gap-4 space-y-0">
          <div>
            <CardTitle className="text-lg">
              À archiver ({piecesEnAttente.length})
            </CardTitle>
            <CardDescription className="mt-1.5">
              Ces fichiers sont téléversés mais pas encore scellés dans le
              coffre-fort. Ils restent modifiables jusqu&apos;à l&apos;archivage.
            </CardDescription>
          </div>
          <Button
            type="button"
            disabled={
              isArchiving ||
              piecesAAarchiver.length === 0 ||
              !peutDeposer
            }
            onClick={() => void handleArchive()}
          >
            {isArchiving ? (
              <>
                <Loader2 className="h-4 w-4 animate-spin" />
                Archivage…
              </>
            ) : (
              <>
                <Shield className="h-4 w-4" />
                Archiver dans le coffre ({piecesAAarchiver.length})
              </>
            )}
          </Button>
        </CardHeader>
        <CardContent>
          {archiveError ? (
            <p className="mb-4 text-sm text-destructive">{archiveError}</p>
          ) : null}

          {removeError ? (
            <p className="mb-4 text-sm text-destructive">{removeError}</p>
          ) : null}

          {piecesEnAttente.length === 0 ? (
            <p className="py-6 text-center text-sm text-muted-foreground">
              Aucune pièce en attente d&apos;archivage.
            </p>
          ) : (
            <div className="space-y-3">
              {piecesEnAttente.map((piece) => (
                <div
                  key={piece.id}
                  className="flex flex-col gap-3 rounded-lg border p-4 sm:flex-row sm:items-center sm:justify-between"
                >
                  <div className="flex min-w-0 items-start gap-3">
                    <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10">
                      <PieceIcon type={piece.type_mime} />
                    </div>
                    <div className="min-w-0">
                      <p className="truncate font-medium">
                        {piece.nom_fichier ?? 'Sans nom'}
                      </p>
                      <p className="text-xs text-muted-foreground">
                        {formatBytes(piece.taille_octets)}
                        {' · '}
                        {piece.statut === 'echec'
                          ? 'Échec de scellement'
                          : isSealingPiece(piece)
                            ? 'Scellement en cours'
                            : 'À archiver'}
                      </p>
                      {piece.statut === 'echec' && piece.message_echec ? (
                        <p className="mt-1 text-xs text-destructive">
                          {piece.message_echec}
                        </p>
                      ) : null}
                      <select
                        className="mt-2 h-8 rounded-md border border-input bg-background px-2 text-xs"
                        value={typeJustificatif[piece.id] ?? ''}
                        onChange={(event) =>
                          setTypeJustificatif((current) => ({
                            ...current,
                            [piece.id]: event.target.value,
                          }))
                        }
                      >
                        {TYPE_JUSTIFICATIF_OPTIONS.map((option) => (
                          <option key={option.value} value={option.value}>
                            {option.label}
                          </option>
                        ))}
                      </select>
                    </div>
                  </div>

                  <Button
                    type="button"
                    variant="outline"
                    size="sm"
                    className="shrink-0 text-destructive hover:text-destructive"
                    disabled={
                      removingId === piece.id ||
                      !canRemovePiece(piece) ||
                      !canManagePieces
                    }
                    title={
                      isSealingPiece(piece)
                        ? 'Scellement en cours'
                        : estScelle(piece)
                          ? 'Cette pièce est déjà scellée'
                          : undefined
                    }
                    onClick={() => void handleRemove(piece.id)}
                  >
                    {removingId === piece.id ? (
                      <Loader2 className="h-4 w-4 animate-spin" />
                    ) : (
                      <Trash2 className="h-4 w-4" />
                    )}
                    Retirer
                  </Button>
                </div>
              ))}
            </div>
          )}
        </CardContent>
      </Card>
        </>
      ) : null}

      <Card>
        <CardHeader>
          <CardTitle className="text-lg">
            Documents archivés ({piecesArchivees.length})
          </CardTitle>
          {viewError ? (
            <CardDescription className="text-destructive">
              {viewError}
            </CardDescription>
          ) : null}
        </CardHeader>
        <CardContent className="p-0 sm:p-0">
          {piecesArchivees.length === 0 ? (
            <p className="px-6 py-10 text-center text-sm text-muted-foreground">
              Aucun document archivé pour le moment.
            </p>
          ) : (
            <div className="overflow-x-auto">
              <table className="w-full text-sm">
                <thead>
                  <tr className="border-b bg-muted/40 text-left text-xs text-muted-foreground">
                    <th className="px-6 py-3 font-medium">Document</th>
                    <th className="px-4 py-3 font-medium">Déposé le</th>
                    <th className="px-4 py-3 font-medium">Intégrité</th>
                    <th className="px-4 py-3 font-medium">Empreinte</th>
                    <th className="px-6 py-3 font-medium">Action</th>
                  </tr>
                </thead>
                <tbody>
                  {piecesArchivees.map((piece) => (
                    <tr key={piece.id} className="border-b last:border-0">
                      <td className="px-6 py-4">
                        <div className="flex items-start gap-3">
                          <div className="mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-primary/10">
                            <PieceIcon type={piece.type_mime} />
                          </div>
                          <div>
                            <p className="font-medium">
                              {piece.nom_fichier ?? 'Sans nom'}
                            </p>
                            <select
                              className="mt-1.5 h-7 rounded-md border border-input bg-background px-2 text-xs text-muted-foreground"
                              value={typeJustificatif[piece.id] ?? ''}
                              onChange={(event) =>
                                setTypeJustificatif((current) => ({
                                  ...current,
                                  [piece.id]: event.target.value,
                                }))
                              }
                            >
                              {TYPE_JUSTIFICATIF_OPTIONS.map((option) => (
                                <option key={option.value} value={option.value}>
                                  {option.label}
                                </option>
                              ))}
                            </select>
                          </div>
                        </div>
                      </td>
                      <td className="px-4 py-4 text-muted-foreground">
                        {piece.depose_le
                          ? format(new Date(piece.depose_le), 'dd/MM/yyyy', {
                              locale: fr,
                            })
                          : '—'}
                      </td>
                      <td className="px-4 py-4">
                        {piece.idu !== null && piece.statut === 'scelle' ? (
                          <span className="inline-flex items-center gap-1.5 text-emerald-700">
                            <CheckCircle2 className="h-4 w-4" />
                            Conforme
                          </span>
                        ) : (
                          <span className="text-muted-foreground">Détruit</span>
                        )}
                      </td>
                      <td className="px-4 py-4">
                        {piece.empreinte ? (
                          <div className="flex items-center gap-2">
                            <code className="font-mono text-xs text-muted-foreground">
                              {truncateHash(piece.empreinte)}
                            </code>
                            <button
                              type="button"
                              className="text-muted-foreground transition-colors hover:text-foreground"
                              title="Copier l'empreinte"
                              onClick={() =>
                                void handleCopyEmpreinte(
                                  piece.id,
                                  piece.empreinte!,
                                )
                              }
                            >
                              <Copy className="h-3.5 w-3.5" />
                            </button>
                            {copiedId === piece.id ? (
                              <span className="text-xs text-emerald-600">
                                Copié
                              </span>
                            ) : null}
                          </div>
                        ) : (
                          '—'
                        )}
                      </td>
                      <td className="px-6 py-4">
                        <div className="flex flex-wrap items-center gap-2">
                          <Button
                            type="button"
                            variant="outline"
                            size="sm"
                            disabled={
                              piece.idu === null ||
                              piece.statut !== 'scelle' ||
                              viewingId === piece.id
                            }
                            onClick={() => void handleView(piece)}
                          >
                            {viewingId === piece.id ? (
                              <Loader2 className="h-4 w-4 animate-spin" />
                            ) : (
                              <ExternalLink className="h-4 w-4" />
                            )}
                            Consulter
                          </Button>

                          {/* §5.2.6 : Lire Journal appelée avec l'IDU de cet ON. */}
                          <Button
                            type="button"
                            variant="ghost"
                            size="sm"
                            disabled={piece.idu === null}
                            onClick={() => setPieceJournal(piece)}
                          >
                            <ScrollText className="h-4 w-4" />
                            Journal
                          </Button>
                        </div>
                      </td>
                    </tr>
                  ))}
                </tbody>
              </table>
            </div>
          )}
        </CardContent>
      </Card>

      <PieceJournalDialog
        piece={pieceJournal}
        onOpenChange={(open) => {
          if (!open) {
            setPieceJournal(null);
          }
        }}
      />
        </>
      )}
    </>
  );
}
