function createOpenInPlaygroundHandler(groups, groupName, block, ready, working, error) {
  return function () {
    // Open window (really a tab) immediately in this bog-standard, non-async, non-arrow handler to minimize the chance that browsers will block it/ ask permission.
    const pg = window.open(OPENING_IN_PLAYGROUND_PATH, '_blank')

    try {
      // Show that it's working
      putOpenInPlaygroundButton(block, working)

      // Try to maintain focus, this generally won't work due to malicious popup mitigations in browsers.
      pg.blur()
      window.focus()
    } catch (e) {
      report(e)
      // If any of those not only didn't work but actually errored, it's still not a problem. Continue...
    }

    // Asyncronously try to perform the share and update the new window accordingly.
    (async () => {
      try {
        const url = await shareToPlayground(groups, groupName)
        pg.location.replace(url)
        pg.focus()
        putOpenInPlaygroundButton(block, ready)
      } catch (e) {
        report('unable to open in playground', e)
        pg.close()
        putOpenInPlaygroundButton(block, error)
      }
    })()
  }
}
// NOTE: The user should not be able to trigger the returned function when the button is set to `working`.
The user should not be able to trigger the returned function when the button is set to `working`.
The user should not be able to trigger the returned function when the button is set to ` working ` .
function createOpenInPlaygroundHandler(groups, groupName, block, ready, working, error) {
  return function () {
    const pg = window.open(OPENING_IN_PLAYGROUND_PATH, '_blank')
    try {
      putOpenInPlaygroundButton(block, working)
      pg.blur()
      window.focus()
    } catch (e) {
      report(e)
    }
    (async () => {
      try {
        const url = await shareToPlayground(groups, groupName)
        pg.location.replace(url)
        pg.focus()
        putOpenInPlaygroundButton(block, ready)
      } catch (e) {
        report('unable to open in playground', e)
        pg.close()
        putOpenInPlaygroundButton(block, error)
      }
    })()
  }
}
function createOpenInPlaygroundHandler ( groups , groupName , block , ready , working , error ) { return function ( ) { const pg = window . open ( OPENING_IN_PLAYGROUND_PATH , '_blank' ) try { putOpenInPlaygroundButton ( block , working ) pg . blur ( ) window . focus ( ) } catch ( e ) { report ( e ) } ( async ( ) => { try { const url = await shareToPlayground ( groups , groupName ) pg . location . replace ( url ) pg . focus ( ) putOpenInPlaygroundButton ( block , ready ) } catch ( e ) { report ( 'unable to open in playground' , e ) pg . close ( ) putOpenInPlaygroundButton ( block , error ) } } ) ( ) } }
NOTE: The user should not be able to trigger the returned function when the button is set to `working`.
NOTE : The user should not be able to trigger the returned function when the button is set to ` working ` .
// Open window (really a tab) immediately in this bog-standard, non-async, non-arrow handler to minimize the chance that browsers will block it/ ask permission. // Show that it's working // Try to maintain focus, this generally won't work due to malicious popup mitigations in browsers. // If any of those not only didn't work but actually errored, it's still not a problem. Continue... // Asyncronously try to perform the share and update the new window accordingly.