{"version":3,"sources":["node_modules/browserify/node_modules/browser-pack/_prelude.js","admin/javascript/src/boot/index.js","admin/javascript/src/components/form-action/index.js","admin/javascript/src/sections/campaign-admin/controller.js","admin/javascript/src/sections/campaign-admin/index.js","admin/javascript/src/state/config/action-types.js","admin/javascript/src/state/config/actions.js","admin/javascript/src/state/config/reducer.js","admin/javascript/src/state/records/action-types.js","admin/javascript/src/state/records/reducer.js","admin/javascript/src/state/schema/action-types.js","admin/javascript/src/state/schema/reducer.js","node_modules/redux-logger/lib/index.js"],"names":[],"mappings":"AAAA;;;ACAA;;;;AACA;;AACA;;;;AACA;;;;AACA;;;;AAEA;;IAAY;;AACZ;;;;AACA;;;;AACA;;;;AAIA;;;;;;;;AAEA,SAAS,OAAT,GAAmB;AACjB,4BAAgB,GAAhB,CAAoB,QAApB,qBADiB;AAEjB,4BAAgB,GAAhB,CAAoB,SAApB,qBAFiB;AAGjB,4BAAgB,GAAhB,CAAoB,SAApB,qBAHiB;;AAKjB,MAAM,eAAe,EAAf,CALW;AAMjB,MAAM,cAAc,4BAAgB,0BAAgB,MAAhB,EAAhB,CAAd,CANW;AAOjB,MAAM,4BAA4B,kDAAiC,4BAAjC,qBAA5B,CAPW;;AAUjB,SAAO,KAAP,GAAe,0BAA0B,WAA1B,EAAuC,YAAvC,CAAf,CAViB;;AAajB,gBAAc,SAAd,CAAwB,OAAO,EAAP,CAAU,MAAV,CAAxB,CAA0C,OAAO,KAAP,CAAa,QAAb,CAA1C,CAbiB;CAAnB;;AAoBA,sBAAE,MAAF,EAAU,OAAV,CAAkB,EAAE,OAAO,iBAAM;AAAE,cAAF;GAAN,EAA3B;;;;;;;;;;;ACnCA;;;;AACA;;;;;;;;;;;;IAEM;;;AACJ,WADI,mBACJ,CAAY,KAAZ,EAAmB;0BADf,qBACe;;uEADf,gCAEI,QADW;;AAGjB,UAAK,WAAL,GAAmB,MAAK,WAAL,CAAiB,IAAjB,OAAnB,CAHiB;;GAAnB;;eADI;;6BAOK;AACP,aAC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,0BAAW,OAAO,MAAP,CAAc,EAAd,EAAkB,KAAlB,sBACf,YAAa,QADE,CAAX,CAAP,CALF;;AArCF;AA+CI,aAAO,KAAP,CADF;AA9CF,GAJoD;CAAtD;;kBAuDe;;;;;;;;AC7Df,IAAM,eAAe;AACnB,cAAY,YAAZ;CADI;;kBAIS;;;;;;;;kBCCS;;AALxB;;;;AACA;;;;;;;;AAEA,IAAM,eAAe,0BAAW,EAAX,CAAf;;AAES,SAAS,aAAT,GAA4D;MAArC,8DAAQ,4BAA6B;MAAf,+DAAS,oBAAM;;AACzE,UAAQ,OAAO,IAAP;;AAEN,SAAK,sBAAa,UAAb;AAAyB;AAC5B,YAAM,KAAK,OAAO,OAAP,CAAe,MAAf,CAAsB,UAAtB,CADiB;AAE5B,eAAO,0BAAW,OAAO,MAAP,CAAc,EAAd,EAAkB,KAAlB,sBAA4B,IAAK,OAAO,OAAP,CAAjC,CAAX,CAAP,CAF4B;OAA9B;;AAFF;AAQI,aAAO,KAAP,CADF;AAPF,GADyE;CAA5D;;;ACLf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"bundle-framework.js","sourceRoot":"/source/","sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o.\n// `window.onload` happens AFTER these Entwine hooks which means\n// the store is undefined when the is constructed.\n$('body').entwine({ onadd: () => { appBoot(); } });\n","import React from 'react';\nimport SilverStripeComponent from 'silverstripe-component';\n\nclass FormActionComponent extends SilverStripeComponent {\n constructor(props) {\n super(props);\n\n this.handleClick = this.handleClick.bind(this);\n }\n\n render() {\n return (\n \n );\n }\n\n /**\n * Returns the necessary button classes based on the given props\n *\n * @returns string\n */\n getButtonClasses() {\n let buttonClasses = 'btn';\n\n // Add 'type' class\n buttonClasses += ` btn-${this.props.style}`;\n\n // If there is no text\n if (typeof this.props.label === 'undefined') {\n buttonClasses += ' no-text';\n }\n\n // Add icon class\n if (typeof this.props.icon !== 'undefined') {\n buttonClasses += ` font-icon-${this.props.icon}`;\n }\n\n // Add loading class\n if (this.props.loading === true) {\n buttonClasses += ' btn--loading';\n }\n\n // Add disabled class\n if (this.props.disabled === true) {\n buttonClasses += ' disabled';\n }\n\n return buttonClasses;\n }\n\n /**\n * Returns markup for the loading icon\n *\n * @returns object|null\n */\n getLoadingIcon() {\n if (this.props.loading) {\n return (\n
\n \n \n \n \n \n
\n );\n }\n\n return null;\n }\n\n /**\n * Event handler triggered when a user clicks the button.\n *\n * @param object event\n * @returns null\n */\n handleClick(event) {\n this.props.handleClick(event);\n }\n\n}\n\nFormActionComponent.propTypes = {\n handleClick: React.PropTypes.func.isRequired,\n label: React.PropTypes.string,\n type: React.PropTypes.string,\n loading: React.PropTypes.bool,\n icon: React.PropTypes.string,\n disabled: React.PropTypes.bool,\n style: React.PropTypes.string,\n};\n\nFormActionComponent.defaultProps = {\n type: 'button',\n style: 'secondary',\n};\n\nexport default FormActionComponent;\n","import React from 'react';\nimport { connect } from 'react-redux';\nimport SilverStripeComponent from 'silverstripe-component';\nimport FormAction from 'components/form-action/index';\nimport i18n from 'i18n';\nimport NorthHeader from 'components/north-header/index';\nimport FormBuilder from 'components/form-builder/index';\n\nclass CampaignAdminContainer extends SilverStripeComponent {\n\n constructor(props) {\n super(props);\n\n this.addCampaign = this.addCampaign.bind(this);\n }\n\n render() {\n const schemaUrl = this.props.config.forms.editForm.schemaUrl;\n\n return (\n
\n \n \n \n
\n );\n }\n\n addCampaign() {\n // Add campaign\n }\n\n}\n\nCampaignAdminContainer.propTypes = {\n config: React.PropTypes.shape({\n forms: React.PropTypes.shape({\n editForm: React.PropTypes.shape({\n schemaUrl: React.PropTypes.string,\n }),\n }),\n }),\n sectionConfigKey: React.PropTypes.string.isRequired,\n};\n\nfunction mapStateToProps(state, ownProps) {\n return {\n config: state.config.sections[ownProps.sectionConfigKey],\n };\n}\n\nexport default connect(mapStateToProps)(CampaignAdminContainer);\n","import $ from 'jQuery';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport { Provider } from 'react-redux';\nimport CampaignAdmin from './controller';\n\n// eslint-disable-next-line no-shadow\n$.entwine('ss', ($) => {\n $('.cms-content.CampaignAdmin').entwine({\n onadd() {\n ReactDOM.render(\n \n \n \n , this[0]);\n },\n\n onremove() {\n ReactDOM.unmountComponentAtNode(this[0]);\n },\n });\n});\n","export default {\n SET_CONFIG: 'SET_CONFIG',\n};\n","import ACTION_TYPES from './action-types';\n\n/**\n * Sets global config for the application.\n *\n * @param object config\n */\nexport function setConfig(config) {\n return (dispatch) =>\n dispatch({\n type: ACTION_TYPES.SET_CONFIG,\n payload: { config },\n });\n}\n","import deepFreeze from 'deep-freeze';\nimport ACTION_TYPES from './action-types';\n\nfunction configReducer(state = {}, action) {\n switch (action.type) {\n\n case ACTION_TYPES.SET_CONFIG:\n return deepFreeze(Object.assign({}, state, action.payload.config));\n\n default:\n return state;\n\n }\n}\n\nexport default configReducer;\n","export default {\n CREATE_RECORD: 'CREATE_RECORD',\n UPDATE_RECORD: 'UPDATE_RECORD',\n DELETE_RECORD: 'DELETE_RECORD',\n FETCH_RECORDS_REQUEST: 'FETCH_RECORDS_REQUEST',\n FETCH_RECORDS_FAILURE: 'FETCH_RECORDS_FAILURE',\n FETCH_RECORDS_SUCCESS: 'FETCH_RECORDS_SUCCESS',\n DELETE_RECORD_REQUEST: 'DELETE_RECORD_REQUEST',\n DELETE_RECORD_FAILURE: 'DELETE_RECORD_FAILURE',\n DELETE_RECORD_SUCCESS: 'DELETE_RECORD_SUCCESS',\n};\n","import deepFreeze from 'deep-freeze';\nimport ACTION_TYPES from './action-types';\n\nconst initialState = {\n};\n\nfunction recordsReducer(state = initialState, action) {\n let records;\n let recordType;\n\n switch (action.type) {\n\n case ACTION_TYPES.CREATE_RECORD:\n return deepFreeze(Object.assign({}, state, {\n\n }));\n\n case ACTION_TYPES.UPDATE_RECORD:\n return deepFreeze(Object.assign({}, state, {\n\n }));\n\n case ACTION_TYPES.DELETE_RECORD:\n return deepFreeze(Object.assign({}, state, {\n\n }));\n\n case ACTION_TYPES.FETCH_RECORDS_REQUEST:\n return state;\n\n case ACTION_TYPES.FETCH_RECORDS_FAILURE:\n return state;\n\n case ACTION_TYPES.FETCH_RECORDS_SUCCESS:\n recordType = action.payload.recordType;\n // TODO Automatic pluralisation from recordType\n records = action.payload.data._embedded[`${recordType}s`];\n return deepFreeze(Object.assign({}, state, {\n [recordType]: records,\n }));\n\n case ACTION_TYPES.DELETE_RECORD_REQUEST:\n return state;\n\n case ACTION_TYPES.DELETE_RECORD_FAILURE:\n return state;\n\n case ACTION_TYPES.DELETE_RECORD_SUCCESS:\n recordType = action.payload.recordType;\n records = state[recordType]\n .filter(record => record.ID !== action.payload.id);\n\n return deepFreeze(Object.assign({}, state, {\n [recordType]: records,\n }));\n\n default:\n return state;\n }\n}\n\nexport default recordsReducer;\n","const ACTION_TYPES = {\n SET_SCHEMA: 'SET_SCHEMA',\n};\n\nexport default ACTION_TYPES;\n","import deepFreeze from 'deep-freeze';\nimport ACTION_TYPES from './action-types';\n\nconst initialState = deepFreeze({});\n\nexport default function schemaReducer(state = initialState, action = null) {\n switch (action.type) {\n\n case ACTION_TYPES.SET_SCHEMA: {\n const id = action.payload.schema.schema_url;\n return deepFreeze(Object.assign({}, state, { [id]: action.payload }));\n }\n\n default:\n return state;\n }\n}\n","\"use strict\";\n\nfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\nfunction _typeof(obj) { return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj; }\n\nvar repeat = function repeat(str, times) {\n return new Array(times + 1).join(str);\n};\nvar pad = function pad(num, maxLength) {\n return repeat(\"0\", maxLength - num.toString().length) + num;\n};\nvar formatTime = function formatTime(time) {\n return \"@ \" + pad(time.getHours(), 2) + \":\" + pad(time.getMinutes(), 2) + \":\" + pad(time.getSeconds(), 2) + \".\" + pad(time.getMilliseconds(), 3);\n};\n\n// Use the new performance api to get better precision if available\nvar timer = typeof performance !== \"undefined\" && typeof performance.now === \"function\" ? performance : Date;\n\n/**\n * parse the level option of createLogger\n *\n * @property {string | function | object} level - console[level]\n * @property {object} action\n * @property {array} payload\n * @property {string} type\n */\n\nfunction getLogLevel(level, action, payload, type) {\n switch (typeof level === \"undefined\" ? \"undefined\" : _typeof(level)) {\n case \"object\":\n return typeof level[type] === \"function\" ? level[type].apply(level, _toConsumableArray(payload)) : level[type];\n case \"function\":\n return level(action);\n default:\n return level;\n }\n}\n\n/**\n * Creates logger with followed options\n *\n * @namespace\n * @property {object} options - options for logger\n * @property {string | function | object} options.level - console[level]\n * @property {boolean} options.duration - print duration of each action?\n * @property {boolean} options.timestamp - print timestamp with each action?\n * @property {object} options.colors - custom colors\n * @property {object} options.logger - implementation of the `console` API\n * @property {boolean} options.logErrors - should errors in action execution be caught, logged, and re-thrown?\n * @property {boolean} options.collapsed - is group collapsed?\n * @property {boolean} options.predicate - condition which resolves logger behavior\n * @property {function} options.stateTransformer - transform state before print\n * @property {function} options.actionTransformer - transform action before print\n * @property {function} options.errorTransformer - transform error before print\n */\n\nfunction createLogger() {\n var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];\n var _options$level = options.level;\n var level = _options$level === undefined ? \"log\" : _options$level;\n var _options$logger = options.logger;\n var logger = _options$logger === undefined ? console : _options$logger;\n var _options$logErrors = options.logErrors;\n var logErrors = _options$logErrors === undefined ? true : _options$logErrors;\n var collapsed = options.collapsed;\n var predicate = options.predicate;\n var _options$duration = options.duration;\n var duration = _options$duration === undefined ? false : _options$duration;\n var _options$timestamp = options.timestamp;\n var timestamp = _options$timestamp === undefined ? true : _options$timestamp;\n var transformer = options.transformer;\n var _options$stateTransfo = options.stateTransformer;\n var // deprecated\n stateTransformer = _options$stateTransfo === undefined ? function (state) {\n return state;\n } : _options$stateTransfo;\n var _options$actionTransf = options.actionTransformer;\n var actionTransformer = _options$actionTransf === undefined ? function (actn) {\n return actn;\n } : _options$actionTransf;\n var _options$errorTransfo = options.errorTransformer;\n var errorTransformer = _options$errorTransfo === undefined ? function (error) {\n return error;\n } : _options$errorTransfo;\n var _options$colors = options.colors;\n var colors = _options$colors === undefined ? {\n title: function title() {\n return \"#000000\";\n },\n prevState: function prevState() {\n return \"#9E9E9E\";\n },\n action: function action() {\n return \"#03A9F4\";\n },\n nextState: function nextState() {\n return \"#4CAF50\";\n },\n error: function error() {\n return \"#F20404\";\n }\n } : _options$colors;\n\n // exit if console undefined\n\n if (typeof logger === \"undefined\") {\n return function () {\n return function (next) {\n return function (action) {\n return next(action);\n };\n };\n };\n }\n\n if (transformer) {\n console.error(\"Option 'transformer' is deprecated, use stateTransformer instead\");\n }\n\n var logBuffer = [];\n function printBuffer() {\n logBuffer.forEach(function (logEntry, key) {\n var started = logEntry.started;\n var startedTime = logEntry.startedTime;\n var action = logEntry.action;\n var prevState = logEntry.prevState;\n var error = logEntry.error;\n var took = logEntry.took;\n var nextState = logEntry.nextState;\n\n var nextEntry = logBuffer[key + 1];\n if (nextEntry) {\n nextState = nextEntry.prevState;\n took = nextEntry.started - started;\n }\n // message\n var formattedAction = actionTransformer(action);\n var isCollapsed = typeof collapsed === \"function\" ? collapsed(function () {\n return nextState;\n }, action) : collapsed;\n\n var formattedTime = formatTime(startedTime);\n var titleCSS = colors.title ? \"color: \" + colors.title(formattedAction) + \";\" : null;\n var title = \"action \" + (timestamp ? formattedTime : \"\") + \" \" + formattedAction.type + \" \" + (duration ? \"(in \" + took.toFixed(2) + \" ms)\" : \"\");\n\n // render\n try {\n if (isCollapsed) {\n if (colors.title) logger.groupCollapsed(\"%c \" + title, titleCSS);else logger.groupCollapsed(title);\n } else {\n if (colors.title) logger.group(\"%c \" + title, titleCSS);else logger.group(title);\n }\n } catch (e) {\n logger.log(title);\n }\n\n var prevStateLevel = getLogLevel(level, formattedAction, [prevState], \"prevState\");\n var actionLevel = getLogLevel(level, formattedAction, [formattedAction], \"action\");\n var errorLevel = getLogLevel(level, formattedAction, [error, prevState], \"error\");\n var nextStateLevel = getLogLevel(level, formattedAction, [nextState], \"nextState\");\n\n if (prevStateLevel) {\n if (colors.prevState) logger[prevStateLevel](\"%c prev state\", \"color: \" + colors.prevState(prevState) + \"; font-weight: bold\", prevState);else logger[prevStateLevel](\"prev state\", prevState);\n }\n\n if (actionLevel) {\n if (colors.action) logger[actionLevel](\"%c action\", \"color: \" + colors.action(formattedAction) + \"; font-weight: bold\", formattedAction);else logger[actionLevel](\"action\", formattedAction);\n }\n\n if (error && errorLevel) {\n if (colors.error) logger[errorLevel](\"%c error\", \"color: \" + colors.error(error, prevState) + \"; font-weight: bold\", error);else logger[errorLevel](\"error\", error);\n }\n\n if (nextStateLevel) {\n if (colors.nextState) logger[nextStateLevel](\"%c next state\", \"color: \" + colors.nextState(nextState) + \"; font-weight: bold\", nextState);else logger[nextStateLevel](\"next state\", nextState);\n }\n\n try {\n logger.groupEnd();\n } catch (e) {\n logger.log(\"—— log end ——\");\n }\n });\n logBuffer.length = 0;\n }\n\n return function (_ref) {\n var getState = _ref.getState;\n return function (next) {\n return function (action) {\n // exit early if predicate function returns false\n if (typeof predicate === \"function\" && !predicate(getState, action)) {\n return next(action);\n }\n\n var logEntry = {};\n logBuffer.push(logEntry);\n\n logEntry.started = timer.now();\n logEntry.startedTime = new Date();\n logEntry.prevState = stateTransformer(getState());\n logEntry.action = action;\n\n var returnedValue = undefined;\n if (logErrors) {\n try {\n returnedValue = next(action);\n } catch (e) {\n logEntry.error = errorTransformer(e);\n }\n } else {\n returnedValue = next(action);\n }\n\n logEntry.took = timer.now() - logEntry.started;\n logEntry.nextState = stateTransformer(getState());\n\n printBuffer();\n\n if (logEntry.error) throw logEntry.error;\n return returnedValue;\n };\n };\n };\n}\n\nmodule.exports = createLogger;"]}