require('es6-promise').polyfill();
require('polyfills/foreach')
require('polyfills/includes')
import {get_url_parameter} from 'common/utilities'
import {color} from 'common/styles'

export const api_path = '/api/v1'
const [_, protocol, root_path] = /(.*):\/\/([-a-z0-9\.]+(:[0-9]+)?)/.exec(document.URL)
const secure = protocol.slice(-1) == "s" ? "s" : ""
export const make_websocket_path = ({client_type, id, auth_token}) => `ws${secure}://${root_path}/cable/${client_type}/${id}/${auth_token}/`
export const PRODUCTION = __RWR_ENV__ && __RWR_ENV__.name == "production"
export const DEV = get_url_parameter('debug') || !PRODUCTION && __RWR_ENV__.name == "development"

export {color}
export const card_width = 450

export const instant_job_users_fields = [
  {
    id: 'email',
    name: 'Adresse mail',
    category: 'comment',
  },
  {
    id: 'first_name',
    name: 'Prénom',
    category: 'comment',
  },
  {
    id: 'last_name',
    name: 'Nom',
    category: 'comment',
  },
  {
    id: 'phone_number',
    name: 'Numéro de téléphone',
    category: 'comment',
  },
  {
    id: 'postal_code',
    name: 'Code postal',
    category: 'comment',
  },
]

export const sentry_dsn = 'https://219f92aee5c642948dec080d9059f684@sentry.io/117881'
export const touch_enabled = "ontouchstart" in document.documentElement

window.tap = (...args) => {
  DEV && console.log(...args)
  return args[0]
}
