window.client_id ||= "client#{Math.round(Math.random()*1000000)}"
#$translations.en.attributes.state ||= {}
$translations.en.attributes.state ||= {}
$translations.en.attributes.project_instance_action ||= {}
Ember.assign $translations.en.attributes.state,
  inquiry: 'Issue'
Ember.assign $translations.en.attributes.project_instance_action,
  inquiry_at: 'Issue'
default_globals =
  flash_message: ''
  preload_resources_fulfilled: true
  current_user: null
  workflow_action_definition:
    value_type_options: ['boolean', 'date', 'number', 'select', 'string', 'text', 'timestamp']
  workflow_action_offset:
    offset_unit_options: ['day']
  week_days: [
    {name: 'monday',    index: 1}
    {name: 'tuesday',   index: 2}
    {name: 'wednesday', index: 3}
    {name: 'thursday',  index: 4}
    {name: 'friday',    index: 5}
    {name: 'saturday',  index: 6}
    {name: 'sunday',    index: 0}
  ]

  operation_running: '' # moment start time of running operation

  project:
    instance_scope_options: ['instance', 'batch']

  workflow_group:
    batch_element_threshold_unit_options: ['businessday', 'day', 'week']

  project_instance:
    states: ['uncategorized', 'unplanned', 'planned', 'active', 'overdue', 'any_rejected', 'all_completed']

  project_instance_group:
    states: ['pending', 'overdue', 'active', 'inquiry', 'rejected', 'completed']

  project_instance_action:
    states: ['pending', 'planned', 'overdue', 'active', 'inquiry', 'rejected', 'completed']
    final_states: ['inquiry', 'rejected', 'completed']

  action_event:
    event_keys: ['state', 'value', 'note']

  time_formatting: 'LLL'
  date_formatting: 'LL'

export globals = Ember.Object.create default_globals, window.app_globals

initialize = (application) ->
  application.register 'service:globals', globals, instantiate: false #, singleton: true
  application.inject 'controller', 'globals', 'service:globals'
  application.inject 'component', 'globals', 'service:globals'
  application.inject 'component', 'router', 'router:main'
  application.inject 'component', 'store', 'service:store'
  application.inject 'view', 'globals', 'service:globals'
  application.inject 'router', 'globals', 'service:globals'

GlobalsInitializer =
  name: 'globals'
  initialize: initialize

export {initialize}
export default GlobalsInitializer
