<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<installer-gui-script minSpecVersion="2">
    <title>Sunscreensaver</title>
    <organization>com.sunscreensaver</organization>
    <domains enable_localSystem="true"/>
    <options customize="always" require-scripts="true" hostArchitectures="x86_64,arm64"/>
    <!-- Welcome text -->
    <welcome file="welcome.html"/>
    <!-- Choices - mutually exclusive like radio buttons -->
    <choices-outline>
        <line choice="install"/>
        <line choice="uninstall"/>
    </choices-outline>
    <!-- Install Choice -->
    <choice id="install" title="Install Sunscreensaver" description="Install the Sunscreensaver screensaver and helper application. Videos will be downloaded automatically." start_selected="true" start_enabled="true" selected="isInstallSelected()">
        <pkg-ref id="com.sunscreensaver.pkg"/>
    </choice>
    <!-- Uninstall Choice -->
    <choice id="uninstall" title="Uninstall Sunscreensaver" description="Remove Sunscreensaver completely, including all downloaded videos and settings." start_selected="false" start_enabled="true" selected="isUninstallSelected()">
        <pkg-ref id="com.sunscreensaver.uninstall"/>
    </choice>
    <!-- Package references -->
    <pkg-ref id="com.sunscreensaver.pkg" version="1.0.6" onConclusion="none" installKBytes="29525" updateKBytes="0">#Sunscreensaver-component.pkg</pkg-ref>
    <pkg-ref id="com.sunscreensaver.uninstall" version="1.0.6" onConclusion="none" installKBytes="0" updateKBytes="0">#Sunscreensaver-uninstall.pkg</pkg-ref>
    <!-- JavaScript for mutual exclusivity (radio button behavior) -->
    <script>
        // Last known state - track which was selected
        var lastInstallState = true;
        var lastUninstallState = false;
        
        function isInstallSelected() {
            var currentInstall = choices['install'].selected;
            var currentUninstall = choices['uninstall'].selected;
            
            // If uninstall was just selected, deselect install
            if (currentUninstall &amp;&amp; !lastUninstallState) {
                lastUninstallState = true;
                lastInstallState = false;
                return false;
            }
            
            // If install was just selected, ensure it stays selected
            if (currentInstall &amp;&amp; !lastInstallState) {
                lastInstallState = true;
                lastUninstallState = false;
            }
            
            return lastInstallState;
        }
        
        function isUninstallSelected() {
            var currentInstall = choices['install'].selected;
            var currentUninstall = choices['uninstall'].selected;
            
            // If install was just selected, deselect uninstall
            if (currentInstall &amp;&amp; !lastInstallState) {
                lastInstallState = true;
                lastUninstallState = false;
                return false;
            }
            
            // If uninstall was just selected, ensure it stays selected
            if (currentUninstall &amp;&amp; !lastUninstallState) {
                lastUninstallState = true;
                lastInstallState = false;
            }
            
            return lastUninstallState;
        }
    </script>
    <pkg-ref id="com.sunscreensaver.pkg">
        <bundle-version>
            <bundle CFBundleShortVersionString="1.0.6" CFBundleVersion="1.0.6" id="com.sunscreensaver.helper" path="Library/Screen Savers/Sunscreensaver.saver/Contents/Resources/SunscreensaverHelper.app"/>
            <bundle CFBundleShortVersionString="1.0.6" CFBundleVersion="1.0.6" id="com.sunscreensaver.uninstaller" path="Applications/Sunscreensaver Uninstaller.app"/>
            <bundle CFBundleShortVersionString="1.0.6" CFBundleVersion="1.0.6" id="com.sunscreensaver.screensaver" path="Library/Screen Savers/Sunscreensaver.saver"/>
        </bundle-version>
    </pkg-ref>
    <pkg-ref id="com.sunscreensaver.uninstall">
        <bundle-version/>
    </pkg-ref>
</installer-gui-script>