<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<installer-gui-script minSpecVersion="2">
    <title>SXAccess</title>
    <options customize="never" require-scripts="false" hostArchitectures="arm64"/>
    <allowed-os-versions>
        <os-version min="14.0"/>
    </allowed-os-versions>
    <domains enable_localSystem="true"/>
    <!-- The preinstall removes the command line agent. A Warn result lets the
         user continue after OK or quit the installer and keep the agent; the
         installer command ignores it. Detection mirrors the preinstall. -->
    <installation-check script="cliAgentCheck()"/>
    <script><![CDATA[
function cliAgentPresent() {
    if (system.files.fileExistsAtPath('/usr/local/bin/sxaccess')) return true;
    if (system.files.fileExistsAtPath('/Library/LaunchDaemons/sxaccess.plist')) return true;
    var app = system.files.bundleAtPath('/Applications/SXAccess.app');
    return app != null && app.CFBundleIdentifier == 'io.sxaccess.ui';
}
function cliAgentCheck() {
    if (!cliAgentPresent()) return true;
    my.result.type = 'Warn';
    my.result.title = 'The SXAccess command line agent will be removed';
    my.result.message = 'SXAccess and the command line agent cannot be installed on the same Mac. If you continue, the installer removes the agent and its menu bar app, and keeps their settings. To keep the command line agent, quit the installer now.';
    return false;
}
    ]]></script>
    <!-- must-close is only read inside a pkg-ref (Distribution XML reference). -->
    <pkg-ref id="com.sxguard.sxaccess.desktop.pkg">
        <must-close>
            <app id="com.sxguard.sxaccess.desktop"/>
            <app id="io.sxaccess.ui"/>
        </must-close>
        <bundle-version>
            <bundle CFBundleShortVersionString="1.0.0" CFBundleVersion="25" id="com.sxguard.sxaccess.desktop" path="SXAccess.app"/>
            <bundle CFBundleShortVersionString="1.0.0" CFBundleVersion="25" id="com.sxguard.sxaccess.desktop.tunnel" path="SXAccess.app/Contents/Library/SystemExtensions/com.sxguard.sxaccess.desktop.tunnel.systemextension"/>
        </bundle-version>
    </pkg-ref>
    <choices-outline>
        <line choice="default">
            <line choice="com.sxguard.sxaccess.desktop.pkg"/>
        </line>
    </choices-outline>
    <choice id="default"/>
    <choice id="com.sxguard.sxaccess.desktop.pkg" visible="false">
        <pkg-ref id="com.sxguard.sxaccess.desktop.pkg"/>
    </choice>
    <pkg-ref id="com.sxguard.sxaccess.desktop.pkg" version="25" onConclusion="none" installKBytes="69189" updateKBytes="0">#SXAccess-component.pkg</pkg-ref>
</installer-gui-script>