// load global styling
require("../theme/index.scss");

import Mira from "./mira.jsx";

document.addEventListener("DOMContentLoaded", function() {

	let HOST_NAME = window.location.search.match(/hostname=([^&]*)/);
	HOST_NAME = HOST_NAME && HOST_NAME.length === 2 ? HOST_NAME[1] : window.location.hostname || "localhost";

	let PORT = window.location.search.match(/port=([0-9]*)/);
	if (PORT && PORT.length === 2) {
		PORT = parseInt(PORT[1], 10);
	} else if (/^http(s)?:$/.test(window.location.protocol)) {
		PORT = parseInt(window.location.port, 10);
	}
	PORT = !PORT || isNaN(PORT) ? 8086 : PORT;

	Mira.init({
		port : PORT,
		hostname : HOST_NAME,
		element : document.getElementById("app-container")
	});
});

// load global styling
require("../theme/index.scss");

import Mira from "./mira.jsx";

document.addEventListener("DOMContentLoaded", function() {

	let HOST_NAME = window.location.search.match(/hostname=([^&]*)/);
	HOST_NAME = HOST_NAME && HOST_NAME.length === 2 ? HOST_NAME[1] : window.location.hostname || "localhost";

	let PORT = window.location.search.match(/port=([0-9]*)/);
	if (PORT && PORT.length === 2) {
		PORT = parseInt(PORT[1], 10);
	} else if (!__DEBUG__ && /^http(s)?:$/.test(window.location.protocol)) { // don't use served port when running webpack-dev-server
		PORT = parseInt(window.location.port, 10);
	}
	PORT = !PORT || isNaN(PORT) ? 8086 : PORT;

	Mira.init({
		port : PORT,
		hostname : HOST_NAME,
		element : document.getElementById("app-container")
	});
});

use 8086 port fallback when running dev build