// Path: src/main/java/ninja/eivind/hotsreplayuploader/di/FXMLLoaderFactory.java
// public interface FXMLLoaderFactory extends Supplier<FXMLLoader> {
// }
// 
// Path: src/main/java/ninja/eivind/hotsreplayuploader/di/nodes/JavaFXNode.java
// @FunctionalInterface
// public interface JavaFXNode extends InitializingBean {
// 
// }
// 
// Path: src/main/java/ninja/eivind/hotsreplayuploader/services/platform/PlatformService.java
// public interface PlatformService {
// 
//     String USER_HOME = System.getProperty("user.home");
//     String APPLICATION_DIRECTORY_NAME = Constants.APPLICATION_NAME.replaceAll(" ", "");
// 
//     File getApplicationHome();
// 
//     File getHotSHome();
// 
//     /**
//      * Defines how the application reacts on window notifications like closing or hiding.
//      * @param primaryStage the main stage
//      */
//     default void setupWindowBehaviour(Stage primaryStage) {
//         Platform.setImplicitExit(false);
//         primaryStage.setOnHiding(value -> {
//             primaryStage.setIconified(true);
//             value.consume();
//         });
//     }
// 
//     default TrayIcon getTrayIcon(Stage primaryStage) throws PlatformNotSupportedException {
//         throw new PlatformNotSupportedException("Not implemented in " + getClass());
//     }
// 
//     default TrayIcon buildTrayIcon(URL imageURL, Stage primaryStage) {
//         final Image image = Toolkit.getDefaultToolkit().getImage(imageURL);
//         final PopupMenu popup = new PopupMenu();
//         final MenuItem showItem = new MenuItem("Show");
//         final MenuItem exitItem = new MenuItem("Exit");
// 
//         // Declare shared action for showItem and trayicon click
//         final Runnable openAction = () -> Platform.runLater(() -> {
//             primaryStage.setIconified(false);
//             primaryStage.show();
//             primaryStage.toFront();
//         });
//         popup.add(showItem);
//         popup.add(exitItem);
// 
//         final TrayIcon trayIcon = new TrayIcon(image, "Initializing tooltip", popup);
//         trayIcon.setImageAutoSize(true);
// 
//         // Add listeners
//         trayIcon.addMouseListener(new TrayMouseListenerBase() {
//             @Override
//             public void mouseClicked(final MouseEvent e) {
//                 if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() % 2 == 0) {
//                     openAction.run();
//                 }
//             }
//         });
//         showItem.addActionListener(e -> openAction.run());
//         exitItem.addActionListener(event -> shutdown());
//         return trayIcon;
// 
//     }
// 
//     /**
//      * Shuts down the application by delegating service cleanups
//      * to the Application Thread.
//      */
//     default void shutdown() {
//         // let JavaFX shut close its services gracefully
//         Platform.exit();
//     }
// 
//     void browse(String uri);
// 
//     URL getLogoUrl();
// 
//     boolean isPreloaderSupported();
// 
//     BattleLobbyTempDirectories getBattleLobbyTempDirectories();
// }


import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.ListView;
import javafx.scene.layout.VBox;
import ninja.eivind.hotsreplayuploader.di.FXMLLoaderFactory;
import ninja.eivind.hotsreplayuploader.di.nodes.JavaFXNode;
import ninja.eivind.hotsreplayuploader.services.platform.PlatformService;
import ninja.eivind.stormparser.StandaloneBattleLobbyParser;
import ninja.eivind.stormparser.models.Player;
import ninja.eivind.stormparser.models.Replay;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.Base64;
import java.util.List;
import java.util.stream.Collectors;
// Copyright 2016 Eivind Vegsundvåg
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ninja.eivind.hotsreplayuploader.window.nodes;



public class BattleLobbyNode extends VBox implements JavaFXNode {

    @Autowired
    private StandaloneBattleLobbyParser parser;

    @Autowired
    private PlatformService platformService;

    @FXML
    private ListView<String> teamOneList;

    @FXML
    private ListView<String> teamTwoList;

    @FXML
    private Hyperlink link;

    private static final String MATCH_PREVIEW_URL = "http://www.hotslogs.com/Player/MatchPreview?Data={{data}}";

    /**
     * @deprecated
     * @throws IOException
     */
    public BattleLobbyNode() throws IOException {
        this(FXMLLoader::new);
    }

// Path: src/main/java/ninja/eivind/hotsreplayuploader/di/FXMLLoaderFactory.java
// public interface FXMLLoaderFactory extends Supplier<FXMLLoader> {
// }
// 
// Path: src/main/java/ninja/eivind/hotsreplayuploader/di/nodes/JavaFXNode.java
// @FunctionalInterface
// public interface JavaFXNode extends InitializingBean {
// 
// }
// 
// Path: src/main/java/ninja/eivind/hotsreplayuploader/services/platform/PlatformService.java
// public interface PlatformService {
// 
//     String USER_HOME = System.getProperty("user.home");
//     String APPLICATION_DIRECTORY_NAME = Constants.APPLICATION_NAME.replaceAll(" ", "");
// 
//     File getApplicationHome();
// 
//     File getHotSHome();
// 
//     /**
//      * Defines how the application reacts on window notifications like closing or hiding.
//      * @param primaryStage the main stage
//      */
//     default void setupWindowBehaviour(Stage primaryStage) {
//         Platform.setImplicitExit(false);
//         primaryStage.setOnHiding(value -> {
//             primaryStage.setIconified(true);
//             value.consume();
//         });
//     }
// 
//     default TrayIcon getTrayIcon(Stage primaryStage) throws PlatformNotSupportedException {
//         throw new PlatformNotSupportedException("Not implemented in " + getClass());
//     }
// 
//     default TrayIcon buildTrayIcon(URL imageURL, Stage primaryStage) {
//         final Image image = Toolkit.getDefaultToolkit().getImage(imageURL);
//         final PopupMenu popup = new PopupMenu();
//         final MenuItem showItem = new MenuItem("Show");
//         final MenuItem exitItem = new MenuItem("Exit");
// 
//         // Declare shared action for showItem and trayicon click
//         final Runnable openAction = () -> Platform.runLater(() -> {
//             primaryStage.setIconified(false);
//             primaryStage.show();
//             primaryStage.toFront();
//         });
//         popup.add(showItem);
//         popup.add(exitItem);
// 
//         final TrayIcon trayIcon = new TrayIcon(image, "Initializing tooltip", popup);
//         trayIcon.setImageAutoSize(true);
// 
//         // Add listeners
//         trayIcon.addMouseListener(new TrayMouseListenerBase() {
//             @Override
//             public void mouseClicked(final MouseEvent e) {
//                 if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() % 2 == 0) {
//                     openAction.run();
//                 }
//             }
//         });
//         showItem.addActionListener(e -> openAction.run());
//         exitItem.addActionListener(event -> shutdown());
//         return trayIcon;
// 
//     }
// 
//     /**
//      * Shuts down the application by delegating service cleanups
//      * to the Application Thread.
//      */
//     default void shutdown() {
//         // let JavaFX shut close its services gracefully
//         Platform.exit();
//     }
// 
//     void browse(String uri);
// 
//     URL getLogoUrl();
// 
//     boolean isPreloaderSupported();
// 
//     BattleLobbyTempDirectories getBattleLobbyTempDirectories();
// }


// Path: src/main/java/ninja/eivind/hotsreplayuploader/window/nodes/BattleLobbyNode.java
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.ListView;
import javafx.scene.layout.VBox;
import ninja.eivind.hotsreplayuploader.di.FXMLLoaderFactory;
import ninja.eivind.hotsreplayuploader.di.nodes.JavaFXNode;
import ninja.eivind.hotsreplayuploader.services.platform.PlatformService;
import ninja.eivind.stormparser.StandaloneBattleLobbyParser;
import ninja.eivind.stormparser.models.Player;
import ninja.eivind.stormparser.models.Replay;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.util.Base64;
import java.util.List;
import java.util.stream.Collectors;

// Copyright 2016 Eivind Vegsundvåg
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package ninja.eivind.hotsreplayuploader.window.nodes;



public class BattleLobbyNode extends VBox implements JavaFXNode {

    @Autowired
    private StandaloneBattleLobbyParser parser;

    @Autowired
    private PlatformService platformService;

    @FXML
    private ListView<String> teamOneList;

    @FXML
    private ListView<String> teamTwoList;

    @FXML
    private Hyperlink link;

    private static final String MATCH_PREVIEW_URL = "http://www.hotslogs.com/Player/MatchPreview?Data={{data}}";

    /**
     * @deprecated
     * @throws IOException
     */
    public BattleLobbyNode() throws IOException {
        this(FXMLLoader::new);
    }

    public BattleLobbyNode(FXMLLoaderFactory factory) throws IOException {