import { router } from '@kit.ArkUI';
import { ASPropName, DeviceType } from '../../../common/Constants';
import { UIExtensionsManager } from '../../../UIExtensionsManager';
import { BusinessError } from '@ohos.base';
import { FoxitRDKNative, PDFViewCtrlModel } from 'foxit_rdk';
import { AppFileUtil } from '../../../utils/AppFileUtil'
import { AppDmUtil } from '../../../utils/AppDmUtil'
import { AppUtil } from '../../../utils/AppUtil'
import { MoreConstants } from '../../more/MoreMenuConstants'
import { IModule, MODULE_NAME } from '../../../IModule';
import { DocInfoModule, IDocViewEvent } from './DocInfoModule'
import { MoreMenuModule } from '../../more/MoreMenuModule';
import { SecurityInfoView } from './SecurityInfo'
import './SecurityInfo'
import { FSDisplayUtil } from '../../../utils/FSDisplayUtil';


class DocumentInfo {
  public mFilePath : string | null = null;
  public mFileName : string | null = null;
  public mHeader : string | null = null;
  public mFastWebView: boolean = false;
  public mTagPDF: boolean = false;
  public mPageSize: string | null = null;
  public mPageCount: string | null = null;
  public mTitle: string | null = null;
  public mSubject: string | null = null;
  public mCreator: string | null = null;
  public mAuthor: string | null = null;
  public mProducer: string | null = null;
  public mKeywords: string | null = null;
  public mFileSize: string | null = null;
  public mModTime: string | null = null;
  public mCreateTime: string | null = null;
  public mSecurity: string | null = null;

  public static readonly METADATA_KEY_TITLE: string = "Title";
  public static readonly METADATA_KEY_SUBJECT: string = "Subject";
  public static readonly METADATA_KEY_AUTHOR: string = "Author";
  public static readonly METADATA_KEY_PRODUCER: string = "Producer";
  public static readonly METADATA_KEY_CREATOR: string = "Creator";
  public static readonly METADATA_KEY_KEYWORDS: string = "Keywords";

  constructor() {
  }
}

class SummaryInfo {
  private mFilePath: string | null = null;
  private mContext: Context;
  private mUiExtManager: UIExtensionsManager | null;
  private mViewCtrl: PDFViewCtrlModel;
  private mIsChangeTitle: boolean = false;
  private mIsChangeSubject: boolean = false;
  private mIsChangeAuthor: boolean = false;
  private mIsChangeProducer: boolean = false;
  private mIsChangeCreator: boolean = false;
  private mIsChangeKeywords: boolean = false;
  public mSecurityContent: Resource | null = null;
  public isClickable: boolean = true;
  public mThumbnail: PixelMap | null = null;
  public mInfo: DocumentInfo | null = null;

  constructor(context: Context, viewCtrl: PDFViewCtrlModel) {
    this.mContext = context;
    this.mViewCtrl = viewCtrl;
    this.mUiExtManager = this.mViewCtrl.getUIExtensionsManager() as UIExtensionsManager;
  }

  init(): void {
    let doc = this.mViewCtrl.getDoc();
    if (doc == null) return;
    this.mInfo = this.getDocumentInfo();
    AppUtil.getFileThumbnail(this.mContext, this.mFilePath!).then((pixelMap)=>{
      this.mThumbnail = pixelMap;
    });
    this.mIsChangeTitle = false;
    this.mIsChangeSubject = false;
    this.mIsChangeAuthor = false;
    this.mIsChangeProducer = false;
    this.mIsChangeCreator = false;
    this.mIsChangeKeywords = false;
    this.isClickable = true;

    switch (doc.GetEncryptionType()) {
      case FoxitRDKNative.pdf.PDFDoc.e_EncryptPassword:
        this.mSecurityContent = $r('app.string.rv_doc_info_security_standard');
        break;
      case FoxitRDKNative.pdf.PDFDoc.e_EncryptCertificate:
        this.mSecurityContent = $r('app.string.rv_doc_info_security_pubkey');
        break;
      case FoxitRDKNative.pdf.PDFDoc.e_EncryptRMS:
        this.mSecurityContent = $r('app.string.rv_doc_info_security_rms');
        break;
      case FoxitRDKNative.pdf.PDFDoc.e_EncryptCustom:
        this.mSecurityContent = $r('app.string.rv_doc_info_security_custom');
        break;
      case FoxitRDKNative.pdf.PDFDoc.e_EncryptCDRM:
        this.mSecurityContent = $r('app.string.rv_doc_info_security_cdrm');
        break;
      default:
        if (this.mFilePath != null && this.mFilePath.toLowerCase().endsWith(".ppdf")) {
          this.mSecurityContent = $r('app.string.rv_doc_info_security_rms');
        } else {
          this.mSecurityContent = $r('app.string.rv_doc_info_security_no');
          this.isClickable = false;
          //mRootLayout.findComponentById('rv_doc_info_security_layout').setClickedListener(null);
          //mIvSecurityDetail.setVisibility(Component.Visibility.GONE);
        }
        break;
    }
  }

  getDocumentInfo(): DocumentInfo | null {
    let info = new DocumentInfo();
    let doc : FoxitRDKNative.pdf.PDFDoc | null = this.mViewCtrl.getDoc();
    info.mFilePath = this.mFilePath;
    if (this.mFilePath != null) {
      info.mFileName = AppFileUtil.getFileNameWithoutExt(this.mFilePath);
      info.mFileSize = AppFileUtil.formatFileSize(AppFileUtil.getFileSize(this.mFilePath));
    }

    try{
      let metadata: FoxitRDKNative.pdf.Metadata = new FoxitRDKNative.pdf.Metadata(doc!);
      info.mHeader = doc!.GetHeader();
      info.mAuthor = this.getMetaValue(metadata, DocumentInfo.METADATA_KEY_AUTHOR, "");
      info.mSubject = this.getMetaValue(metadata, DocumentInfo.METADATA_KEY_SUBJECT, "");
      info.mCreateTime = AppDmUtil.formatDocumentDateTime(AppDmUtil.FORMAT_YYYY_MM_DD_HH_MM_SS, metadata.GetCreationDateTime());
      info.mModTime = AppDmUtil.formatDocumentDateTime(AppDmUtil.FORMAT_YYYY_MM_DD_HH_MM_SS, metadata.GetModifiedDateTime());
      info.mTitle = this.getMetaValue(metadata, DocumentInfo.METADATA_KEY_TITLE, "");
      info.mPageCount = `${doc!.GetPageCount()}`;
      info.mProducer = this.getMetaValue(metadata, DocumentInfo.METADATA_KEY_PRODUCER, "");
      info.mCreator = this.getMetaValue(metadata, DocumentInfo.METADATA_KEY_CREATOR, "");
      info.mKeywords = this.getMetaValue(metadata, DocumentInfo.METADATA_KEY_KEYWORDS, "");
      info.mTagPDF = this.isTaggedPDF();
      let pageBasicInfo: FoxitRDKNative.pdf.PageBasicInfo = doc!.GetPageBasicInfo(this.mViewCtrl.getCurrentPage());
      info.mPageSize = `${AppUtil.pointsToInches(pageBasicInfo.width).toFixed(2)}*${AppUtil.pointsToInches(pageBasicInfo.height).toFixed(2)} inch`
    } catch(err) {
      //console.log(err);
    }
    return info;
  }

  getMetaValue(metadata: FoxitRDKNative.pdf.Metadata, key: string, defaultValue: string): string {
    let subArray = metadata.GetValues(key);
    return subArray.GetSize() == 0 ? defaultValue : subArray.GetAt(0);
  }

  saveMetaValueOrNot(key: string, value: string): void {
    try {
      let metadata = new FoxitRDKNative.pdf.Metadata(this.mViewCtrl.getDoc()!);
      let oldValueArray = metadata.GetValues(key);
      if (oldValueArray.GetSize() == 0 && value != "") {
        oldValueArray.Add(value);
        metadata.SetValues(key, oldValueArray);
        (this.mViewCtrl.getUIExtensionsManager() as UIExtensionsManager).getDocumentManager().setDocModified(true);
      } else if (oldValueArray.GetSize() > 0 && oldValueArray.GetAt(0) != value) {
        oldValueArray.RemoveAll();
        oldValueArray.Add(value);
        metadata.SetValues(key, oldValueArray);
        (this.mViewCtrl.getUIExtensionsManager() as UIExtensionsManager).getDocumentManager().setDocModified(true);
      }
    } catch (err) {
      console.log(err);
    }
  }

  titleChange(value: string): void {
    this.mIsChangeTitle = true;
    this.mInfo!.mTitle = value;
  }

  subjectChange(value: string): void {
    this.mIsChangeSubject = true;
    this.mInfo!.mSubject = value;
  }

  AuthorChange(value: string): void {
    this.mIsChangeAuthor = true;
    this.mInfo!.mAuthor = value;
  }

  ProducerChange(value: string): void {
    this.mIsChangeProducer = true;
    this.mInfo!.mProducer = value;
  }

  CreatorChange(value: string): void {
    this.mIsChangeCreator = true;
    this.mInfo!.mCreator = value;
  }

  keywordsChange(value: string): void {
    this.mIsChangeKeywords = true;
    this.mInfo!.mKeywords = value;
  }

  setTitle(): void {
    if (this.mIsChangeTitle && this.mInfo != null && this.mInfo.mTitle != null)
      this.saveMetaValueOrNot(DocumentInfo.METADATA_KEY_TITLE, this.mInfo.mTitle);
    this.mIsChangeTitle = false;
  }

  setSubject(): void {
    if(this.mIsChangeSubject && this.mInfo != null && this.mInfo.mSubject != null)
      this.saveMetaValueOrNot(DocumentInfo.METADATA_KEY_SUBJECT, this.mInfo.mSubject);
    this.mIsChangeSubject = false;
  }

  setAuthor(): void {
    if(this.mIsChangeAuthor && this.mInfo != null && this.mInfo.mAuthor != null)
      this.saveMetaValueOrNot(DocumentInfo.METADATA_KEY_AUTHOR, this.mInfo.mAuthor);
    this.mIsChangeAuthor = false;
  }

  setProducer(): void {
    if(this.mIsChangeProducer && this.mInfo != null && this.mInfo.mProducer != null)
      this.saveMetaValueOrNot(DocumentInfo.METADATA_KEY_PRODUCER, this.mInfo.mProducer);
    this.mIsChangeProducer = false;
  }

  setCreator(): void {
    if(this.mIsChangeCreator && this.mInfo != null && this.mInfo.mCreator != null)
      this.saveMetaValueOrNot(DocumentInfo.METADATA_KEY_CREATOR, this.mInfo.mCreator);
    this.mIsChangeCreator = false;
  }

  setKeywords(): void {
    if (this.mIsChangeKeywords && this.mInfo != null && this.mInfo.mKeywords != null)
      this.saveMetaValueOrNot(DocumentInfo.METADATA_KEY_KEYWORDS, this.mInfo.mKeywords);
    this.mIsChangeKeywords = false;
  }

  isFastWebViewPDF(): boolean {
    let doc = this.mViewCtrl.getDoc();
    if (doc != null) {
      try {
        return doc.IsLinearized();
      } catch (err) {
        console.log(err);
      }
    }
    return false;
  }

   private isTaggedPDF(): boolean {
    let doc = this.mViewCtrl.getDoc();
    if (doc != null) {
    try {
      return doc.IsTaggedPDF();
    } catch (err) {
      console.log(err)
    }
    }
     return false;
   }


  setFilePath(filePath: string | null): void {
    this.mFilePath = filePath;
  }
}

@Observed
export class DocInfoViewModel {
  private mFilePath : string | null = null;
  private mSummaryInfo: SummaryInfo;
  private mContext: Context;
  private mViewCtrl: PDFViewCtrlModel;

  constructor(context: Context, viewCtrl: PDFViewCtrlModel) {
    this.mContext = context;
    this.mViewCtrl = viewCtrl;
    this.mSummaryInfo = new SummaryInfo(this.mContext, this.mViewCtrl);
  }

  getSummaryInfo(): SummaryInfo {
    return this.mSummaryInfo;
  }

  init(filePath: string | null): void {
    this.mFilePath = filePath;
  }

  setFilePath(filePath: string): void {
    this.mFilePath = filePath;
    this.mSummaryInfo.setFilePath(this.mFilePath);
  }

  show(): void {
    if (this.mSummaryInfo == null) return;
    this.mSummaryInfo.init();
  }

  canPrint(): Resource {
    let canPrint = (this.mViewCtrl.getUIExtensionsManager() as UIExtensionsManager).getDocumentManager().canPrint();
    if (canPrint) {
      return $r('app.string.fx_string_allowed');
    } else {
      return $r('app.string.fx_string_notallowed');
    }
  }

  canFillForm(): Resource {
    let canFillForm = (this.mViewCtrl.getUIExtensionsManager() as UIExtensionsManager).getDocumentManager().canFillForm();
    if (canFillForm) {
      return $r('app.string.fx_string_allowed');
    } else {
      return $r('app.string.fx_string_notallowed');
    }
  }


  canAddAnnot(): Resource {
    let canAddAnnot = (this.mViewCtrl.getUIExtensionsManager() as UIExtensionsManager).getDocumentManager().canAddAnnot();
    if (canAddAnnot) {
      return $r('app.string.fx_string_allowed');
    } else {
      return $r('app.string.fx_string_notallowed');
    }
  }


  canAssemble(): Resource {
    let canFillForm = (this.mViewCtrl.getUIExtensionsManager() as UIExtensionsManager).getDocumentManager().canAssemble();
    if (canFillForm) {
      return $r('app.string.fx_string_allowed');
    } else {
      return $r('app.string.fx_string_notallowed');
    }
  }


  canModifyContents(): Resource {
    let canModifyContents = (this.mViewCtrl.getUIExtensionsManager() as UIExtensionsManager).getDocumentManager().canModifyContents();
    if (canModifyContents) {
      return $r('app.string.fx_string_allowed');
    } else {
      return $r('app.string.fx_string_notallowed');
    }
  }


  canCopyForAssess(): Resource {
    let canCopyForAssess = (this.mViewCtrl.getUIExtensionsManager() as UIExtensionsManager).getDocumentManager().canCopyForAssess();
    if (canCopyForAssess) {
      return $r('app.string.fx_string_allowed');
    } else {
      return $r('app.string.fx_string_notallowed');
    }
  }


  canCopy(): Resource {
    let canCopy = (this.mViewCtrl.getUIExtensionsManager() as UIExtensionsManager).getDocumentManager().canExtract();
    if (canCopy) {
      return $r('app.string.fx_string_allowed');
    } else {
      return $r('app.string.fx_string_notallowed');
    }
  }


  canSigning(): Resource {
    let canSigning = (this.mViewCtrl.getUIExtensionsManager() as UIExtensionsManager).getDocumentManager().canSigning();
    if (canSigning) {
      return $r('app.string.fx_string_allowed');
    } else {
      return $r('app.string.fx_string_notallowed');
    }
  }
}

@CustomDialog
struct CustomDialogSecurityInfoView {
  @StorageProp(ASPropName.SP_DIALOG_WIDTH) dialogWidth:number|string = 0;
  @StorageProp(ASPropName.SP_DIALOG_HEIGHT) dialogHeight:number = 0;

  controllerTwo?: CustomDialogController
  build() {
    Column() {
      SecurityInfoView( {dialogController_ext: this.controllerTwo })
    }
    .width(this.dialogWidth)
    .height(this.dialogHeight)
    .borderRadius(24)
    .backgroundColor($r('app.color.white'))
    }
}

@Entry({ routeName: 'DocInfoView' })
@Component
export struct DocInfoView {
  private mScroller: Scroller = new Scroller();
  private mDocInfoModule: DocInfoModule | undefined;
  //for pad
  private dialogController_ext?: CustomDialogController
  private dialogController?: CustomDialogController;
  @StorageProp(ASPropName.SP_CUTOUT_MARGIN) cutoutArea: Margin = {};

  private showProtectedDialog() {
    this.dialogController = new CustomDialogController({
      builder: CustomDialogSecurityInfoView(),
      customStyle: true,
      autoCancel: false,
    });
    this.dialogController.open();
  }

  @Builder
  securityItem(name: Resource, url: string, clickable: boolean) {
    Row() {
      Column() {
        Text(name)
          .fontSize('16vp')
          .fontColor($r('app.color.t4'))
      }
      .padding({left:'24vp'})
      .alignItems(HorizontalAlign.Start)
      Blank()
      Row()
        .width('10vp')
        .height('10vp')
        .margin({ right: '30vp' })
        .border({
          width: { top: '1vp', right: '1vp' },
          color: '#9C9C9C'
        })
        .rotate({ angle: 45 })
        .visibility(clickable ? Visibility.Visible : Visibility.Hidden)
    }
    .width('100%')
    .height('48vp')
    .backgroundColor(Color.Transparent)
    .onClick(() => {
      if(!clickable) {
        return
      }

      if (DeviceType.IS_PHONE) {
        try {
          router.pushNamedRoute({
            name: url
          })
        } catch (err) {
          let message = (err as BusinessError).message
          let code = (err as BusinessError).code
          console.error(`pushNamedRoute failed, code is ${code}, message is ${message}`);
        }
      } else {
        this.showProtectedDialog();
      }
    })
  }

  @Builder
   infoItem(title: Resource, content: string | Resource) {
    Row(){
      Text(title)
        .fontSize($r('app.float.ux_text_size_16fp'))
        .width(104)
        .align(Alignment.Start)
        .margin({left:'24vp'})
        .backgroundColor(Color.Transparent)
        .fontColor($r('app.color.t3'))
      Text(content)
        .fontSize($r('app.float.ux_text_size_16fp'))
        .fontColor($r('app.color.t4'))
        .align(Alignment.Start)
        .margin({left:$r('app.float.ux_margin_16vp'), right:$r('app.float.ux_margin_16vp')})
        .layoutWeight(1)
        .backgroundColor(Color.Transparent)
    }
    .width('100%')
    .height('48vp')
  }

  @Builder
  EditItem(title: Resource, content: string | Resource, placeholder: string | Resource,
    callbackChange: (value: string) => void, callbackMetaData: () => void) {
    Row(){
      Text(title)
        .fontSize($r('app.float.ux_text_size_16fp'))
        .fontColor($r('app.color.t3'))
        .width(104)
        .align(Alignment.Start)
        .margin({left:'24vp'})
      TextInput({text: content, placeholder: placeholder})
        .type(InputType.Normal)
        .placeholderColor($r('app.color.t3'))
        .placeholderFont({ size: $r('app.float.ux_text_size_16fp')})
        .fontSize($r('app.float.ux_text_size_16fp'))
        .fontColor($r('app.color.t4'))
        .layoutWeight(1)
        .margin({right:$r('app.float.ux_margin_16vp')})
        .borderRadius(0)
        .backgroundColor(Color.Transparent)
        .onChange((value: string) => {
          callbackChange(value);
        })
        .onBlur(() => {
          callbackMetaData();
        })
    }
    .width('100%')
    .height('48vp')
  }

  aboutToAppear(): void {
    this.mDocInfoModule = AppStorage.get<DocInfoModule>(MoreConstants.SP_KEY_DOC_INFO_PARAM);
    if (this.mDocInfoModule) {
      this.mDocInfoModule.registerDocViewEvent(this.docView);
    }
  }

  aboutToDisappear(): void {
    this.mDocInfoModule?.unregisterDocViewEvent(this.docView)
    this.mDocInfoModule?.unSetDocInfoStoreage();
  }

  private docView: IDocViewEvent = {
    updateSafeArea: (leftOffset: number, rightOffset: number): void => {
    },
    onTriggerDismissMenu: (): void => {
      this.closePage();
    }
  }

  @Builder
  NavigationBuilder() {
    Row() {
      Image($r('app.media.more_menu_left'))
        .objectFit(ImageFit.Contain)
        .width($r('app.float.fs_little_icon_size'))
        .margin({
          left: $r('app.float.ux_margin_16vp'),
          right: $r('app.float.ux_margin_16vp')
        })
        .interpolation(ImageInterpolation.High)
        .onClick(() => {
         this.closePage();
        })

      Text($r('app.string.rv_doc_info_fileinfo'))
        .fontSize($r('app.float.ux_text_size_20fp'))
        .fontColor($r('app.color.t4'))
    }
    .borderRadius(DeviceType.IS_PHONE ? 0 : { topLeft: 24, topRight: 24 })
    .width('100%')
    .height('56vp')
    .backgroundColor('#F4F4F4')
  }

  private closePage():void {
    if (DeviceType.IS_PHONE) {
      router.back()
    } else {
      this.dialogController_ext?.close();
    }
  }

  build() {
    Column() {
      this.NavigationBuilder();
      Scroll(this.mScroller) {
        Column() {
          Column() {
            Image(this.mDocInfoModule?.getView()?.getSummaryInfo().mThumbnail)
              .width('100vp')
              .height('132vp')
              .align(Alignment.Center)
              .border({ width: 1 })
              .borderColor($r('app.color.p2'))
              .margin({top: $r('app.float.ux_margin_20vp')})

            Text(this.mDocInfoModule?.getView()?.getSummaryInfo().getDocumentInfo()?.mFileName)
              .maxLines(1)
              .fontSize($r('app.float.ux_text_size_14fp'))
              .fontColor($r('app.color.t4'))
              .width('100%')
              .height($r('app.float.ux_item_subtitle_height'))
              .align(Alignment.Center)
              .textAlign(TextAlign.Center)
              .margin({left: '16vp', right: '16vp'})
              .textOverflow( {overflow: TextOverflow.MARQUEE })
          }
          .align(Alignment.Center)
          .width('100%')
          .height(188)

          Text($r('app.string.menu_document_item_desc'))
            .fontSize($r('app.float.ux_text_size_14fp'))
            .fontColor($r('app.color.t3'))
            .align(Alignment.Start)
            .height($r('app.float.ux_item_subtitle_height'))
            .padding({left:'16vp'})
            .width('100%')
          this.infoItem($r('app.string.menu_more_pdf_version'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mHeader!);
          this.infoItem($r('app.string.menu_more_fast_web_view'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mFastWebView ? $r('app.string.fx_string_yes') : $r('app.string.fx_string_no'));
          this.infoItem($r('app.string.menu_more_tagged_pdf'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mTagPDF ? $r('app.string.fx_string_yes') : $r('app.string.fx_string_no'));
          this.infoItem($r('app.string.menu_more_page_size'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mPageSize!);
          this.infoItem($r('app.string.menu_more_pages'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mPageCount!)
          this.EditItem($r('app.string.fm_history_file_name'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mTitle!,
            $r('app.string.menu_more_add_a_title'),
            (value: string) => {
              this.mDocInfoModule?.getView()?.getSummaryInfo().titleChange(value);
            },
            () => {
              this.mDocInfoModule?.getView()?.getSummaryInfo().setTitle();
            })
          this.EditItem($r('app.string.fm_history_pdf_subject'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mSubject!,
            $r('app.string.menu_more_add_a_subject'),
            (value: string) => {
              this.mDocInfoModule?.getView()?.getSummaryInfo().subjectChange(value);
            },
            () => {
              this.mDocInfoModule?.getView()?.getSummaryInfo().setSubject();
            })
          this.EditItem($r('app.string.menu_more_creator'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mCreator!,
            $r('app.string.menu_more_add_a_creator'),
            (value: string) => {
              this.mDocInfoModule?.getView()?.getSummaryInfo().CreatorChange(value);
            },
            () => {
              this.mDocInfoModule?.getView()?.getSummaryInfo().setCreator();
            })
          this.EditItem($r('app.string.fm_history_pdf_author'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mAuthor!,
            $r('app.string.menu_more_add_an_author'),
            (value: string) => {
              this.mDocInfoModule?.getView()?.getSummaryInfo().AuthorChange(value);
            },
            () => {
              this.mDocInfoModule?.getView()?.getSummaryInfo().setAuthor();
            })
          this.EditItem($r('app.string.menu_more_producer'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mProducer!,
            $r('app.string.menu_more_add_a_producer'),
            (value: string) => {
              this.mDocInfoModule?.getView()?.getSummaryInfo().ProducerChange(value);
            },
            () => {
              this.mDocInfoModule?.getView()?.getSummaryInfo().setProducer();
            })
          this.EditItem($r('app.string.menu_more_keywords'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mKeywords!,
            $r('app.string.menu_more_add_keywords'),
            (value: string) => {
              this.mDocInfoModule?.getView()?.getSummaryInfo().keywordsChange(value);
            },
            () => {
              this.mDocInfoModule?.getView()?.getSummaryInfo().setKeywords();
            })
          this.infoItem($r('app.string.menu_more_document_size'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mFileSize!)
          this.infoItem($r('app.string.fm_history_file_last_modify_time'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mModTime!)
          this.infoItem($r('app.string.fm_history_file_create_time'), this.mDocInfoModule?.getView()?.getSummaryInfo().mInfo?.mCreateTime!)
          Text($r('app.string.rv_doc_info_security'))
            .fontSize($r('app.float.ux_text_size_14fp'))
            .fontColor($r('app.color.t3'))
            .align(Alignment.Start)
            .padding({left:'16vp'})
            .width('100%')
            .height($r('app.float.ux_item_subtitle_height'))
          this.securityItem(this.mDocInfoModule?.getView()?.getSummaryInfo().mSecurityContent!, 'SecurityInfoView',
            this.mDocInfoModule?.getView()?.getSummaryInfo().isClickable!)
        }
      }
      .padding({ left: this.cutoutArea.left, right: this.cutoutArea.right })
      .layoutWeight(1)
      .width('100%')
      .scrollable(ScrollDirection.Vertical)
      .scrollBar(BarState.Off)
      .backgroundColor(Color.White)
      .borderRadius({bottomLeft: DeviceType.IS_PHONE ? 0 : 24, bottomRight: DeviceType.IS_PHONE ? 0 : 24})
    }
    .width('100%')
    .height('100%')
    .borderRadius(DeviceType.IS_PHONE ? 0 : 24)
    .backgroundColor(DeviceType.IS_PAD ? $r('app.color.fx_color_translucent') : $r('app.color.theme'))
    .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
  }
}

