export const openDuplicateModal = ( ) => { document . querySelector < HTMLAnchorElement > ( '.js-close-question-link' ) ! . click ( ) ; const handler = ( _event , _jqXHR , ajaxOptions ) => { if ( ! ajaxOptions . url || ! /\/flags\/questions\/\d+\/close\/popup/ . test ( ajaxOptions . url ) ) { return ; } const duplicateRadio = document . querySelector < HTMLElement > ( '#closeReasonId-Duplicate' ) ; if ( duplicateRadio ) { duplicateRadio . click ( ) ; window . $ ( document ) . off ( 'ajaxComplete' , handler ) ; } } ; window . $ ( document ) . on ( 'ajaxComplete' , handler ) ; } ;