#ifndef WavTool_MacSupport_H
#define WavTool_MacSupport_H

#ifndef _MSC_VER
#ifdef __OBJC__
#import <AppKit/AppKit.h>

@class AppUpdaterDelegate;
#endif

#include <string>
#include <functional>
#include <sys/sysctl.h>

class MacSupport
{
public:
    MacSupport(std::function<void()> && clearTrustStore, std::function<void()> && editSearchPaths);
    void checkForUpdates();
    std::string generateOrLoadBridgeKeySeed(std::function<std::string(void)> && generate);
    void showStatusItemDropdownMenu(void * item);
    bool showTrustQuery();
    
    std::function<void()> clearTrustStore;
    std::function<void()> editSearchPaths;
private:
#ifdef __OBJC__
    // Expose ObjC type only to updater_sparkle.mm. This allows ARC to properly track its lifetime.
    AppUpdaterDelegate *_updaterDelegate;
#else
    void *_updaterDelegate;
#endif
};

// https://developer.apple.com/documentation/apple_silicon/about_the_rosetta_translation_environment
inline int processIsTranslated() {
    int ret = 0;
    size_t size = sizeof(ret);
    if (sysctlbyname("sysctl.proctranslated", &ret, &size, NULL, 0) == -1)
    {
        if (errno == ENOENT)
            return 0;
        return -1;
    }
    return ret;
}

#endif /* _MSC_VER */
#endif /* WavTool_MacSupport_H */
