# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import, unicode_literals

import os
import logging
import click

import AppKit

from collections import Mapping

from Foundation import *
from AppKit import *

from avashell.utils import resource_path
from avashell.osx.window import Window
from ava import launcher
from ava.user import status
from ..base import *
from . import msgbox
from .cocoa import Delegate


_NOTIFICATIONS = True
try:
    from Foundation import NSUserNotification, NSUserNotificationCenter
except ImportError:
    _NOTIFICATIONS = False

logger = logging.getLogger(__name__)


def applicationSupportFolder(self):
    paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,NSUserDomainMask,True)
    basePath = (len(paths) > 0 and paths[0]) or NSTemporaryDirectory()
    fullPath = basePath.stringByAppendingPathComponent_("Ava")
    if not os.path.exists(fullPath):
        os.mkdir(fullPath)
    return fullPath


def notification(title, subtitle, message, data=None, sound=True):
    """Send a notification to Notification Center (Mac OS X 10.8+). If running on a version of Mac OS X that does not