'use strict';
import { c } from 'react/compiler-runtime';
import { jsxs, jsx } from 'react/jsx-runtime';
import { Sheet, SheetTrigger, SheetContent, SheetTitle, SheetDescription } from '../../fd-component-toolbox/sheet/Sheet.js';
import React, { useState, useEffect } from 'react';
import { useTitle } from '../../meta/page/use-title.js';
import EditUserForm from '../edit-user-form/EditUserForm.js';
import { onOpenEditUserSheet } from './EditUserSheet.funcs.js';
import { pageTitleUserList } from '../user-list/UserList.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
function EditUserSheet(t0) {
  const $ = c(14);
  const {
    children,
    onEditClick,
    userData
  } = t0;
  const [isOpen, setIsOpen] = useState(false);
  const {
    setTitle
  } = useTitle();
  let t1;
  let t2;
  if ($[0] !== isOpen || $[1] !== setTitle) {
    t1 = () => {
      if (!isOpen) {
        setTitle?.(pageTitleUserList);
      }
    };
    t2 = [isOpen, setTitle];
    $[0] = isOpen;
    $[1] = setTitle;
    $[2] = t1;
    $[3] = t2;
  } else {
    t1 = $[2];
    t2 = $[3];
  }
  useEffect(t1, t2);
  let t3;
  if ($[4] !== onEditClick) {
    t3 = open => onOpenEditUserSheet(setIsOpen, open, onEditClick);
    $[4] = onEditClick;
    $[5] = t3;
  } else {
    t3 = $[5];
  }
  let t4;
  if ($[6] !== children || $[7] !== isOpen || $[8] !== onEditClick || $[9] !== t3 || $[10] !== userData) {
    let t5;
    if ($[12] !== onEditClick) {
      t5 = () => onOpenEditUserSheet(setIsOpen, false, onEditClick);
      $[12] = onEditClick;
      $[13] = t5;
    } else {
      t5 = $[13];
    }
    t4 = jsxs(Sheet, {
      open: isOpen,
      onOpenChange: t3,
      children: [jsx(SheetTrigger, {
        render: React.isValidElement(children) ? children : jsx("span", {
          children
        })
      }), jsxs(SheetContent, {
        className: "w-3/4 overflow-y-auto md:w-1/2 xl:w-1/4",
        children: [jsx(SheetTitle, {
          className: "absolute overflow-hidden border-0 p-0 whitespace-nowrap text-transparent",
          children: "SheetContent"
        }), jsx(SheetDescription, {}), jsx(EditUserForm, {
          userData,
          onCancelClick: t5
        })]
      })]
    });
    $[6] = children;
    $[7] = isOpen;
    $[8] = onEditClick;
    $[9] = t3;
    $[10] = userData;
    $[11] = t4;
  } else {
    t4 = $[11];
  }
  return t4;
}
__name(EditUserSheet, "EditUserSheet");

export { EditUserSheet };
