<?xml version="1.0" encoding="UTF-8"?>
<installer-gui-script authoringTool="Packages" authoringToolVersion="1.2.9" authoringToolBuild="603" minSpecVersion="1.0">
    <options customize="always"/>
    <volume-check script="volume_check()"/>
    <!--+==========================+
        |       Presentation       |
        +==========================+-->
    <title>DISTRIBUTION_TITLE</title>
    <!--+==========================+
        |         Installer        |
        +==========================+-->
    <choices-outline>
        <line choice="installer_choice_1"/>
        <line choice="installer_choice_2"/>
        <line choice="installer_choice_3"/>
        <line choice="installer_choice_4"/>
        <line choice="installer_choice_5"/>
    </choices-outline>
    <choice id="installer_choice_1" start_visible="false" start_enabled="false" start_selected="true" title="Mevo Webcam App" description="">
        <pkg-ref id="logitech.mevowebcamapp"/>
    </choice>
    <choice id="installer_choice_2" start_selected="installer_choice_2_selected(true)" selected="installer_choice_2_selected(false)" title="INSTALLER_CHOICE_2_TITLE" description="">
        <pkg-ref id="RunAfter"/>
    </choice>
    <choice id="installer_choice_3" start_selected="installer_choice_3_selected(true)" selected="installer_choice_3_selected(false)" title="Uninstall" description="">
        <pkg-ref id="Uninstall"/>
    </choice>
    <choice id="installer_choice_4" start_visible="false" start_enabled="installer_choice_4_requirement(false,true)" start_selected="installer_choice_4_requirement(false,false)" title="CMIOPlugin" description="">
        <pkg-ref id="com.mevo.cmio.plugin"/>
    </choice>
    <choice id="installer_choice_5" start_visible="false" title="Finalize" description="">
        <pkg-ref id="Finalize"/>
    </choice>
    <!--+==========================+
        |    Package References    |
        +==========================+-->
    <pkg-ref id="RunAfter" version="1.0" auth="Root" installKBytes="0">#Launch_on_system_startup.pkg</pkg-ref>
    <pkg-ref id="logitech.mevowebcamapp" version="0.0.13" auth="Root" installKBytes="64204" onConclusion="RequireRestart">#Mevo_Webcam_App.pkg</pkg-ref>
    <pkg-ref id="Finalize" version="1.0" auth="Root" installKBytes="0">#Finalize.pkg</pkg-ref>
    <pkg-ref id="Uninstall" version="1.0" auth="Root" installKBytes="0">#Uninstall.pkg</pkg-ref>
    <pkg-ref id="com.mevo.cmio.plugin" version="1.0" auth="Root" installKBytes="832">#CMIOPlugin.pkg</pkg-ref>
    <!--+==========================+
        |    JavaScript Scripts    |
        +==========================+-->
    <script>

	const __IC_FLAT_DISTRIBUTION__=true;
	const IC_OS_DISTRIBUTION_TYPE_ANY=0;
	const IC_OS_DISTRIBUTION_TYPE_CLIENT=1;
	const IC_DISK_TYPE_DESTINATION=0;
	const IC_OS_DISTRIBUTION_TYPE_SERVER=2;
	const IC_DISK_TYPE_STARTUP_DISK=1;

	function IC_CheckOS(inDiskType,inMustBeInstalled,inMinimumVersion,inMaximumVersion,inDistributionType)
	{
		var tOSVersion=undefined;
		
		/* Check Version Constraints */
		
		if (inDiskType==IC_DISK_TYPE_DESTINATION)
		{
			if (my.target.systemVersion!=undefined)
			{
				tOSVersion=my.target.systemVersion.ProductVersion;
			}
			
			/* Check if no OS is installed on the potential target */
			
			if (tOSVersion==undefined)
			{
				return (inMustBeInstalled==false);
			}
			
			if (inMustBeInstalled==false)
			{
				return false;
			}
		}
		else
		{
			tOSVersion=system.version.ProductVersion;
		}
		
		if (system.compareVersions(tOSVersion,inMinimumVersion)==-1)
			return false;
			
		if (inMaximumVersion!=undefined &amp;&amp;
			system.compareVersions(tOSVersion,inMaximumVersion)==1)
			return false;
		
		/* Check Distribution Type */
		
		if (inDistributionType!=IC_OS_DISTRIBUTION_TYPE_ANY)
		{
			var tIsServer;
			
			if (system.compareVersions(tOSVersion,'10.8.0')==-1)
			{
				if (inDiskType==IC_DISK_TYPE_DESTINATION)
				{
					tIsServer=system.files.fileExistsAtPath(my.target.mountpoint+'/System/Library/CoreServices/ServerVersion.plist');
				}
				else
				{
					tIsServer=system.files.fileExistsAtPath('/System/Library/CoreServices/ServerVersion.plist');
				}
			}
			else
			{
				if (inDiskType==IC_DISK_TYPE_DESTINATION)
				{
					tIsServer=system.files.fileExistsAtPath(my.target.mountpoint+'/Applications/Server.app');
				}
				else
				{
					tIsServer=system.files.fileExistsAtPath('/Applications/Server.app');
				}
			}
			
			if (inDistributionType==IC_OS_DISTRIBUTION_TYPE_CLIENT &amp;&amp; tIsServer==true)
			{
				return false;
			}
			
			if (inDistributionType==IC_OS_DISTRIBUTION_TYPE_SERVER &amp;&amp; tIsServer==false)
			{
				return false;
			}
		}
		
		return true;
	}

	function volume_check()
	{
		var tResult;

		tResult=IC_CheckOS(IC_DISK_TYPE_DESTINATION,true,'10.13',undefined,IC_OS_DISTRIBUTION_TYPE_ANY);

		if (tResult==false)
		{
			my.result.message = system.localizedString('REQUIREMENT_FAILED_MESSAGE_VOLUME_CHECK_1');
			my.result.type = 'Fatal';
		}

		return tResult;
	}

	function installer_choice_2_selected(isStart)
	{
		var tSelected;

		tSelected=!choices.installer_choice_3.selected;

		if (isStart==true)
		{
			return tSelected;
		}

		return (tSelected &amp;&amp; my.choice.selected);
	}

	function installer_choice_3_selected(isStart)
	{
		var tSelected;

		tSelected=!choices.installer_choice_2.enabled;

		if (isStart==true)
		{
			return tSelected;
		}

		return (tSelected &amp;&amp; my.choice.selected);
	}

	function installer_choice_4_requirement(inCheckVisibilityOnly,inShowFailedToolTip)
	{
		var tResult;

		tResult=IC_CheckOS(IC_DISK_TYPE_DESTINATION,true,'10.13','12.2.99',IC_OS_DISTRIBUTION_TYPE_ANY);

		if (tResult==false)
		{
			if (inCheckVisibilityOnly==true)
			{
				tResult=true;
			}
		}

		if (tResult==true)
		{
			tResult=IC_CheckOS(IC_DISK_TYPE_DESTINATION,true,'10.13','12.2.99',IC_OS_DISTRIBUTION_TYPE_ANY);

		}

		return tResult;
	}

    </script>
</installer-gui-script>